:root {
  color-scheme: light;
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 64px;
  --bg: #f5f5f2;
  --panel: #ffffff;
  --panel-soft: #f8f8f6;
  --text: #222426;
  --muted: #6b7280;
  --line: #d8d8d2;
  --accent: #0f766e;
  --accent-contrast: #ffffff;
  --accent-dark: #115e59;
  --status-bg: #ecfdf5;
  --status-text: #115e59;
  --success: #16a34a;
  --warm: #a16207;
  --danger: #b91c1c;
  --shadow: 0 16px 48px rgba(30, 35, 40, 0.12);
  --compact-panel-header-height: 64px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151719;
  --panel: #202326;
  --panel-soft: #292d31;
  --text: #f4f1e8;
  --muted: #a7adb5;
  --line: #363b40;
  --accent: #2dd4bf;
  --accent-contrast: #09201d;
  --accent-dark: #99f6e4;
  --status-bg: #123c37;
  --status-text: #99f6e4;
  --success: #4ade80;
  --warm: #f5c36b;
  --danger: #f87171;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.demo-home-link {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 90;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
}

.demo-home-link .button-icon {
  width: 16px;
  height: 16px;
}

html {
  scrollbar-width: thin;
  scrollbar-gutter: stable;
  scrollbar-color: transparent transparent;
}

html:hover,
html:focus-within {
  scrollbar-color: var(--line) transparent;
}

html::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: transparent;
}

html:hover::-webkit-scrollbar-thumb,
html:focus-within::-webkit-scrollbar-thumb {
  background: var(--line);
}

button,
input,
select,
textarea {
  font: inherit;
}

.auth-required .shell,
.auth-required .reader,
.auth-required .settings-page,
.auth-required .ai-panel,
.auth-required .metadata-editor {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 38%),
    radial-gradient(circle at 80% 18%, rgba(161, 98, 7, 0.12), transparent 32%),
    var(--bg);
}

.login-screen[hidden] {
  display: none;
}

.login-panel {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 46px;
  height: 46px;
}

.login-eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.login-brand h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-soft);
  outline: none;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.login-submit {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-contrast);
  background: var(--accent);
  font-weight: 780;
  cursor: pointer;
}

.login-submit:disabled {
  opacity: 0.65;
  cursor: progress;
}

.login-feedback {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.login-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.share-fallback-body {
  min-height: 100vh;
  margin: 0;
  background: #f8fafc;
  color: #172033;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.share-fallback-shell {
  padding: 18px 20px 56px;
}

.share-fallback-banner {
  max-width: 1100px;
  margin: 0 auto 18px;
  border-bottom: 1px solid #d9e2ec;
  padding-bottom: 14px;
}

.share-fallback-brand {
  color: #0f766e;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.share-fallback-banner h1 {
  margin: 8px 0;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  line-height: 1.15;
}

.share-fallback-banner p {
  margin: 0;
  color: #607086;
  font-size: 0.95rem;
  line-height: 1.55;
}

.share-fallback-frame {
  display: block;
  width: min(1100px, 100%);
  min-height: 70vh;
  margin: 0 auto;
  border: 0;
  border-radius: 12px;
  background: #ffffff;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  transition: grid-template-columns 220ms ease, width 220ms ease;
}

.sidebar-collapsed .shell {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.ai-panel-open .shell {
  width: calc(100% - var(--ai-panel-width, 420px));
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  transition: width 180ms ease, grid-template-columns 220ms ease;
}

.sidebar-collapsed.ai-panel-open .shell {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: visible;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  background: var(--panel-soft);
  border-right: 1px solid var(--line);
  transition: padding 220ms ease;
}

.sidebar-resize {
  position: absolute;
  top: 0;
  right: -5px;
  bottom: 0;
  z-index: 3;
  width: 10px;
  cursor: col-resize;
  touch-action: none;
}

.sidebar-resize::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 5px;
  width: 1px;
  background: color-mix(in srgb, var(--line) 72%, transparent);
}

.sidebar-resize:hover::before,
.sidebar-resizing .sidebar-resize::before {
  background: color-mix(in srgb, var(--accent) 72%, transparent);
}

.sidebar-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  min-width: 0;
  border: 0;
  padding: 4px 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: justify-content 220ms ease;
}

.brand:hover h1 {
  color: var(--accent-dark);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: block;
  object-fit: contain;
  box-shadow: 0 0 0 1px rgba(20, 26, 23, 0.08);
  transition: width 220ms ease, height 220ms ease, border-radius 220ms ease;
}

[data-theme="dark"] .brand-mark {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
  transform-origin: left center;
  transition: opacity 160ms ease, transform 220ms ease, max-width 220ms ease;
}

.sidebar-collapse-toggle {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, justify-self 220ms ease;
}

.sidebar-collapse-toggle:hover {
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent-dark);
}

.collapse-icon {
  transition: transform 160ms ease;
}

.sidebar-collapsed .collapse-icon {
  transform: rotate(180deg);
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.new-card h3,
.new-card p,
.reader h2,
.reader p,
.item-card h3,
.item-card p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.1;
}

.workspace-brand-name {
  font-family: "Fraunces", "Noto Serif SC", "Noto Serif JP", Georgia, "Times New Roman", serif;
  font-style: normal;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.workspace-brand-name em {
  color: var(--accent);
  font-style: italic;
  font-weight: 600;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.new-button {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: var(--accent-contrast);
  background: var(--accent);
  cursor: pointer;
  margin-bottom: 22px;
}

.sidebar-main {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  transition: opacity 160ms ease, transform 220ms ease, max-height 220ms ease;
}

.sidebar-main:hover,
.sidebar-main:focus-within {
  scrollbar-width: none;
}

.sidebar-main::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.sidebar-tools {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-width: 0;
  position: relative;
  transition: justify-content 220ms ease;
}

.sidebar-tool-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
}

.settings-toggle,
.project-link,
.github-link {
  min-width: 42px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.topbar-settings-toggle {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  background: var(--panel);
  color: var(--muted);
}

.topbar-settings-toggle .button-icon {
  width: 16px;
  height: 16px;
  opacity: 0.82;
  stroke-width: 1.55;
}

.profile-avatar-large {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 850;
}

.profile-avatar-upload {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.profile-avatar-upload:hover {
  border-color: var(--accent);
}

.profile-avatar-large {
  width: 54px;
  height: 54px;
  border-radius: 10px;
}

.profile-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-card-header {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.profile-card-header strong,
.profile-card-header span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-card-header span,
.profile-stats span {
  color: var(--muted);
  font-size: 12px;
}

.profile-stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.profile-stats strong {
  font-size: 13px;
  font-weight: 760;
  text-align: right;
}

.profile-stats .agent-state-text {
  color: var(--muted);
}

.profile-stats .agent-state-text.connected {
  color: var(--accent-dark);
}

.profile-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.profile-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.project-link,
.github-link {
  grid-auto-flow: column;
  gap: 7px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
}

.project-link {
  flex: 1 1 auto;
  max-width: 112px;
  justify-content: center;
}

.github-link {
  flex: 0 0 42px;
  width: 42px;
  padding: 0;
}

.project-link span,
.github-link span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.github-link span {
  display: none;
}

.project-link img {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}

.github-mark {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.project-link:hover,
.github-link:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.settings-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.settings-toggle {
  width: 42px;
}

.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
  padding: 18px 10px;
}

.sidebar-collapsed .sidebar-resize {
  display: none;
}

.sidebar-collapsed .sidebar-header {
  grid-template-columns: 1fr;
  justify-items: center;
}

.sidebar-collapsed .brand {
  justify-content: center;
}

.sidebar-collapsed .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.sidebar-collapsed .brand-copy {
  max-width: 0;
  opacity: 0;
  transform: translateX(-8px);
  overflow: hidden;
  pointer-events: none;
}

.sidebar-collapsed .sidebar-main {
  max-height: 0;
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
}

.sidebar-collapsed .project-link,
.sidebar-collapsed .github-link {
  width: 42px;
  min-width: 42px;
  padding: 0;
  overflow: hidden;
  color: var(--muted);
}

.sidebar-collapsed .project-link span,
.sidebar-collapsed .github-link span {
  display: none;
}

.sidebar-collapsed .sidebar-tools {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sidebar-collapsed .sidebar-tool-group {
  flex-direction: column;
}

.nav-section {
  margin: 18px 0;
}

.nav-section-header {
  width: 100%;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 8px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
  letter-spacing: 0;
  cursor: pointer;
}

.nav-section-header:hover {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  background: color-mix(in srgb, var(--accent) 11%, var(--panel));
  color: var(--accent-dark);
}

.nav-section-arrow {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: rotate(90deg);
  transition: transform 140ms ease;
}

.nav-section.collapsed .nav-section-arrow {
  transform: rotate(0deg);
}

.nav-section.collapsed .nav-list,
.nav-section.collapsed .tag-list {
  display: none;
}

.nav-list,
.tag-list {
  display: grid;
  gap: 6px;
}

.nav-item,
.tag-filter {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
}

.nav-item:hover,
.tag-filter:hover,
.nav-item.active,
.tag-filter.active {
  border-color: var(--line);
  background: var(--panel);
}

.workspace {
  container-type: inline-size;
  padding: 24px;
  min-width: 0;
  transition: margin-right 160ms ease;
}

.reader-open .workspace {
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

.ai-panel-open .reader,
.ai-panel-open .settings-page {
  right: var(--ai-panel-width, 420px);
}

.topbar {
  position: relative;
  z-index: 1;
  container-type: inline-size;
  margin-bottom: 18px;
}

.topbar-tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
}

.import-topbar-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}

.import-topbar-button:hover {
  background: var(--accent-dark);
}

.topbar-control-group {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-toggle-group,
.quick-filter-toggle-group {
  height: 42px;
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.filter-shell {
  position: relative;
}

.filter-toggle,
.magic-button,
.ai-panel-toggle {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.filter-toggle {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.magic-button,
.ai-panel-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-dark);
}

.filter-toggle {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.magic-button:hover,
.ai-panel-toggle:hover,
.ai-panel-toggle.active {
  border-color: var(--accent);
  background: var(--status-bg);
}

.filter-toggle:hover,
.filter-toggle.active {
  color: var(--accent-dark);
}

#favorite-filter.active {
  color: var(--warm);
}

#multi-filter-toggle.active {
  color: var(--accent-dark);
}

.multi-filter-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 25;
  width: min(340px, calc(100vw - 48px));
  max-height: min(560px, calc(100vh - 150px));
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sort-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 26;
  width: 220px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sort-popover button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.sort-popover button:hover,
.sort-popover button.active {
  border-color: var(--line);
  background: var(--panel-soft);
}

.multi-filter-popover[hidden],
.sort-popover[hidden] {
  display: none;
}

.multi-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.multi-filter-header h3,
.multi-filter-section h4 {
  margin: 0;
}

.multi-filter-header h3 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 15px;
}

.multi-filter-header-actions {
  display: flex;
  gap: 6px;
}

.multi-filter-header button,
.multi-filter-header-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.multi-filter-header-actions button {
  min-height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

.multi-filter-header-actions button.active {
  border-color: var(--accent);
  background: var(--status-bg);
  color: var(--accent-dark);
}

.multi-filter-section {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.multi-filter-title-count {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.multi-filter-options {
  display: grid;
  gap: 6px;
}

.multi-filter-option {
  min-height: 34px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 8px;
  cursor: pointer;
}

.multi-filter-option:hover {
  border-color: var(--line);
  background: var(--panel-soft);
}

.multi-filter-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.multi-filter-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-filter-count {
  color: var(--muted);
  font-size: 12px;
}

.search {
  position: relative;
  display: grid;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 120px;
  color: var(--muted);
  font-size: 12px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  z-index: 1;
  width: 15px;
  height: 15px;
  color: var(--muted);
  opacity: 0.76;
  pointer-events: none;
  transform: translateY(-50%);
}

.search-icon circle,
.search-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-search-group {
  position: relative;
  min-width: 220px;
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-job-toggle {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.topbar-job-toggle:hover,
.topbar-job-toggle.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--panel-soft);
}

.topbar-job-toggle span {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 4px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 10px;
  line-height: 1;
}

.ai-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 30;
  min-width: 320px;
  max-width: min(720px, calc(100vw - 120px));
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 180ms ease;
  will-change: transform;
  pointer-events: none;
  overscroll-behavior: contain;
}

.ai-panel-open .ai-panel {
  transform: translateX(0);
  pointer-events: auto;
}

.ai-panel-resize {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -5px;
  z-index: 4;
  width: 10px;
  cursor: col-resize;
  touch-action: none;
}

.ai-panel-resize::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 1px;
  background: color-mix(in srgb, var(--line) 72%, transparent);
}

.ai-panel-resize:hover::before,
.ai-panel-resizing .ai-panel-resize::before {
  background: color-mix(in srgb, var(--accent) 72%, transparent);
}

.ai-panel-resizing,
.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}

.ai-panel-resizing .reader iframe,
.ai-composer-resizing .reader iframe,
.sidebar-resizing .reader iframe {
  pointer-events: none;
}

.ai-panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  height: var(--compact-panel-header-height);
  min-height: var(--compact-panel-header-height);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.ai-panel-title-row {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.ai-panel-header h2,
.ai-context-card span,
.ai-context-card strong,
.ai-message p,
.ai-panel-actions span {
  margin: 0;
}

.ai-panel-header h2 {
  flex: 0 0 auto;
  font-size: 17px;
  line-height: 1.28;
}

.ai-panel-title-row span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

#ai-context-compact {
  flex: 1 1 auto;
  display: flex;
  align-items: baseline;
  gap: 0;
  overflow: hidden;
  white-space: nowrap;
}

#ai-context-compact .ai-context-prefix {
  flex: 0 0 auto;
}

#ai-context-compact .ai-context-value {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-context-card {
  display: grid;
  gap: 6px;
  margin: 14px 18px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.ai-context-card[hidden] {
  display: none;
}

.ai-panel:not(.has-ai-messages) .ai-context-card {
  margin: auto 18px;
}

.ai-panel:not(.has-ai-messages) .ai-chat-log-shell {
  display: none;
}

.ai-context-card span,
.ai-panel-actions > span {
  color: var(--muted);
  font-size: 12px;
}

.ai-context-card strong {
  font-size: 14px;
}

.ai-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 18px;
}

.ai-message {
  display: grid;
  gap: 6px;
  max-width: 92%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  line-height: 1.5;
}

.ai-message.user {
  justify-self: end;
  background: var(--status-bg);
}

.ai-message > strong {
  font-size: 12px;
  color: var(--muted);
}

.ai-message-body {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--text);
}

.ai-message-body p,
.ai-message-body ul,
.ai-message-body ol,
.ai-message-body blockquote,
.ai-message-body pre,
.ai-message-body h3,
.ai-message-body h4,
.ai-message-body h5 {
  margin: 0;
}

.ai-message-body ul,
.ai-message-body ol {
  padding-left: 22px;
}

.ai-message-body li + li {
  margin-top: 7px;
}

.ai-message-body h3,
.ai-message-body h4,
.ai-message-body h5 {
  line-height: 1.4;
  font-weight: 750;
}

.ai-message-body h3 {
  font-size: 15px;
}

.ai-message-body h4 {
  font-size: 14px;
}

.ai-message-body h5 {
  font-size: 13px;
  color: var(--muted);
}

.ai-message-body blockquote {
  border-left: 3px solid var(--line);
  padding-left: 10px;
  color: var(--muted);
}

.ai-message-body pre {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel);
}

.ai-message-body code {
  border-radius: 5px;
  padding: 1px 4px;
  background: var(--panel);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.ai-message-body pre code {
  padding: 0;
  background: transparent;
}

.ai-message-body a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-message.pending .ai-message-body {
  color: var(--muted);
  font-style: italic;
}

.ai-typing {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.ai-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 18px;
}

.ai-typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.35;
  animation: aiTypingDot 1.05s ease-in-out infinite;
}

.ai-typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.ai-typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes aiTypingDot {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  40% {
    opacity: 0.95;
    transform: translateY(-2px);
  }
}

.ai-message-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
}

.ai-message-sources > span {
  flex: 0 0 auto;
  white-space: nowrap;
}

.ai-message-sources em,
.ai-message-sources a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  flex: 0 1 auto;
  width: fit-content;
  min-width: 0;
  max-width: min(260px, calc(100% - 42px));
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-style: normal;
  color: var(--text);
  background: var(--panel);
  text-decoration: none;
}

.ai-message-sources a:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.ai-message-sources em span,
.ai-message-sources a span {
  color: var(--accent);
  font-weight: 650;
  white-space: nowrap;
}

.ai-message-sources em.external span,
.ai-message-sources a.external span {
  color: #0369a1;
}

.ai-message-sources em b,
.ai-message-sources a b {
  min-width: 0;
  overflow: hidden;
  display: block;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  line-height: 1.35;
}

.ai-composer {
  --ai-composer-height: 172px;
  position: relative;
  flex: 0 0 var(--ai-composer-height);
  min-height: 142px;
  max-height: min(42vh, 320px);
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.ai-composer-resize {
  position: relative;
  flex: 0 0 8px;
  height: 8px;
  cursor: row-resize;
  z-index: 2;
}

.ai-composer-resize::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 42px;
  height: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 38%, transparent);
  transform: translateX(-50%);
}

.ai-composer-resizing {
  cursor: row-resize;
  user-select: none;
}

.ai-panel-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 10px;
}

.ai-panel-actions > #ai-generate-note {
  flex: 0 0 auto;
}

.ai-conversation-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.ai-source-options {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.ai-source-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
  width: fit-content;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.ai-source-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-source-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.ai-source-toggle-disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.ai-source-toggle-disabled input,
.ai-source-toggle-disabled span {
  cursor: not-allowed;
}

.ai-panel-actions button,
.ai-chat-form button {
  min-height: 34px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 11px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}

.ai-panel-actions .ai-job-toggle {
  margin: 0;
}

.ai-panel-actions .icon-action {
  position: relative;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-color: transparent;
  padding: 0;
  background: transparent;
  color: var(--muted);
  line-height: 1;
}

.ai-chat-log-shell {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}

.ai-panel-actions .icon-action:hover,
.ai-panel-actions .icon-action.active {
  color: var(--accent);
  background: transparent;
}

.ai-job-list,
.ai-history-list {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(100% + 8px);
  z-index: 4;
  width: auto;
  min-width: 0;
  max-width: calc(100% - 28px);
  max-height: min(320px, 48vh);
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, var(--accent) 8%);
  box-shadow: var(--shadow);
}

.topbar-job-list {
  left: auto;
  right: 52px;
  top: calc(100% + 8px);
  bottom: auto;
  width: min(420px, calc(100vw - 32px));
  max-width: min(420px, calc(100vw - 32px));
  max-height: min(420px, 56vh);
}

.ai-history-list {
  max-height: min(300px, 46vh);
}

.ai-job-list[hidden],
.ai-history-list[hidden] {
  display: none;
}

.ai-popover-head {
  position: sticky;
  top: -10px;
  z-index: 2;
  min-height: 30px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  align-items: center;
  gap: 8px;
  margin: -10px -10px 2px;
  padding: 10px 10px 8px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 68%, transparent);
  background: color-mix(in srgb, var(--panel) 94%, var(--accent) 6%);
  color: var(--muted);
  font-size: 12px;
}

.ai-popover-close {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.ai-popover-close:hover {
  border-color: var(--line);
  color: var(--text);
  background: var(--panel-soft);
}

.ai-history-row {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 3px 4px 3px 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.ai-history-row:hover,
.ai-history-row.active {
  border-color: var(--line);
  background: var(--panel-soft);
}

.ai-history-row-main {
  min-width: 0;
  display: grid;
  gap: 3px;
  border: 0;
  padding: 4px 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.ai-history-row-main strong,
.ai-history-row-main span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-history-row-main strong {
  font-size: 12px;
}

.ai-history-row-main span {
  color: var(--muted);
  font-size: 11px;
}

.ai-history-delete {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.ai-history-delete .button-icon {
  width: 14px;
  height: 14px;
}

.ai-history-delete:hover {
  border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.ai-job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}

.ai-job-row > div {
  min-width: 0;
}

.ai-job-row:last-child {
  border-bottom: 0;
}

.ai-job-row strong {
  display: block;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.ai-job-row .ai-run-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.ai-job-row .ai-run-meta span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.ai-job-progress-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent);
  animation: ai-job-pulse 1.1s ease-in-out infinite;
}

.ai-job-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-job-icon-button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.ai-job-icon-button:hover {
  border-color: var(--line);
  color: var(--accent);
  background: var(--panel-soft);
}

.ai-job-icon-button .button-icon {
  width: 15px;
  height: 15px;
}

.ai-job-detail-link {
  min-height: 28px;
  border: 0;
  padding: 0 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.ai-job-detail-link:hover {
  color: var(--accent);
}

.ai-job-more-button {
  width: 100%;
  min-height: 32px;
  margin-top: 4px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.ai-job-more-button:hover {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--accent);
}

.ai-job-detail {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  min-width: 0;
  margin-top: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--panel-soft) 78%, transparent);
  cursor: default;
}

.ai-job-detail p,
.ai-job-detail h4,
.ai-job-detail ol,
.ai-job-detail ul {
  margin: 0;
}

.ai-job-detail p {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.ai-job-detail p b {
  color: var(--text);
  font-weight: 700;
}

.ai-job-detail h4 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.ai-job-trace,
.ai-job-artifacts,
.ai-job-checklist {
  display: grid;
  gap: 5px;
  padding-left: 18px;
  color: var(--text);
  font-size: 11px;
}

.ai-job-trace li,
.ai-job-artifacts li,
.ai-job-checklist li {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ai-job-trace b,
.ai-job-artifacts b,
.ai-job-checklist span {
  font-weight: 700;
}

.ai-job-trace span,
.ai-job-trace em,
.ai-job-trace small,
.ai-job-artifacts em,
.ai-job-artifacts small,
.ai-job-checklist em {
  margin-left: 5px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.ai-job-trace small,
.ai-job-artifacts small {
  display: block;
  margin: 2px 0 0;
  line-height: 1.35;
}

.ai-artifact-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.ai-artifact-chips span {
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel);
  font-size: 10px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

@keyframes ai-job-pulse {
  0%, 100% {
    opacity: .36;
    transform: scale(.82);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.ai-chat-form {
  flex: 1 1 auto;
  min-height: 0;
  display: block;
  padding: 10px 14px 14px;
}

.ai-chat-input-box {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 82px;
}

.ai-chat-form textarea {
  width: 100%;
  height: 100%;
  min-height: 82px;
  max-height: none;
  resize: none;
  outline: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 52px 9px 10px;
  background: var(--panel-soft);
  color: var(--text);
  line-height: 1.45;
  overflow-y: auto;
}

.ai-chat-form textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.ai-chat-form button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  align-self: end;
  justify-self: end;
}

.ai-chat-form .ai-send-button .button-icon {
  width: 18px;
  height: 18px;
}

.search input,
.new-form select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--text);
}

.search input {
  padding-left: 36px;
}

.new-form select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.new-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  background: var(--panel);
}

.new-card-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.new-card h3 {
  font-size: 18px;
}

.status-pill {
  align-self: start;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--status-bg);
  color: var(--status-text);
  font-size: 12px;
}

.new-form {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px 112px;
  gap: 10px;
  align-items: start;
}

.new-prompt-box {
  position: relative;
  min-width: 0;
}

.new-prompt-box:has(textarea:placeholder-shown)::before {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  z-index: 1;
  width: 52px;
  border-radius: 0 7px 7px 0;
  background: linear-gradient(to right, color-mix(in srgb, var(--panel) 0%, transparent), var(--panel) 34%);
  pointer-events: none;
}

.new-prompt-box textarea {
  display: block;
  width: 100%;
  height: 42px;
  min-height: 42px;
  max-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  line-height: 1.45;
  resize: none;
  overflow: auto;
}

.new-prompt-box textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
  outline: none;
}

.new-prompt-box textarea:placeholder-shown {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-prompt-resize {
  position: absolute;
  right: 0;
  bottom: -4px;
  left: 0;
  z-index: 2;
  height: 10px;
  cursor: ns-resize;
}

.new-prompt-box:hover .new-prompt-resize::after,
.new-prompt-box.is-resizing .new-prompt-resize::after {
  opacity: 1;
}

.new-prompt-resize::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 4px;
  left: 12px;
  height: 1px;
  background: color-mix(in srgb, var(--accent) 46%, transparent);
  opacity: 0;
  transition: opacity 140ms ease;
}

.new-upload-button,
.new-generation-toggle {
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.new-upload-button {
  border-color: color-mix(in srgb, var(--accent) 56%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  color: var(--accent);
}

.new-upload-button .button-icon {
  width: 18px;
  height: 18px;
}

.new-upload-button:hover,
.new-upload-button.has-file {
  border-color: color-mix(in srgb, var(--accent) 68%, var(--line));
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
}

.new-generation-toggle:hover,
.new-generation-toggle[aria-expanded="true"] {
  border-color: var(--line);
  color: var(--text);
  background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
}

.new-file-main {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.new-file-name {
  min-width: 0;
  overflow: visible;
  color: var(--text);
  font-size: 13px;
}

.new-file-list {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.new-file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 3px 0;
}

.new-file-item-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-file-item-status {
  max-width: min(280px, 38vw);
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-file-item.is-ready .new-file-item-status {
  color: var(--muted);
}

.new-file-item.is-uploading .new-file-item-status {
  color: var(--accent-dark);
}

.new-file-item.has-error .new-file-item-status {
  color: var(--danger);
}

.new-file-item-progress {
  grid-column: 1 / -1;
  display: block;
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--line));
}

.new-file-item-progress[hidden] {
  display: none;
}

.new-file-item-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 120ms ease;
}

.new-file-item-remove {
  width: 20px;
  height: 20px;
  min-height: 20px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.new-file-item-remove:hover {
  color: var(--text);
}

.new-file-status {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-file-row.has-error .new-file-status,
.new-reference-name.has-error {
  color: var(--danger);
}

.new-file-progress {
  display: block;
  width: min(220px, 100%);
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--line));
}

.new-file-progress[hidden] {
  display: none;
}

.new-file-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 120ms ease;
}

.new-file-row {
  grid-column: 2 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.new-file-row[hidden] {
  display: none;
}

.new-file-remove {
  width: 20px;
  height: 20px;
  min-height: 20px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.new-file-remove:hover {
  background: transparent;
  color: var(--text);
}

.new-generation-drawer {
  grid-column: 1 / -1;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 220ms ease, opacity 160ms ease, transform 220ms ease;
}

.new-generation-drawer.is-open {
  max-height: 260px;
  opacity: 1;
  transform: translateY(0);
}

.new-generation-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.new-generation-options label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.new-generation-options select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--panel);
  color: var(--text);
}

.new-reference-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-top: 2px;
}

.new-reference-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.new-reference-button:hover,
.new-reference-button.has-file {
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
}

.new-reference-hint,
.new-reference-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-reference-name {
  color: var(--text);
}

.new-reference-name[hidden],
.new-reference-row .new-file-remove[hidden] {
  display: none;
}

.new-form button[type="submit"],
.card-footer button,
.card-footer a,
.button-link {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.new-form button[type="submit"] {
  height: 42px;
  min-height: 42px;
  align-self: start;
}

@container (max-width: 760px) {
  .new-form {
    grid-template-columns: 42px minmax(0, 1fr) 42px 112px;
  }

  .new-prompt-box {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .new-file-row {
    grid-column: 1 / -1;
  }

  .new-file-item {
    grid-template-columns: minmax(0, 1fr) 20px;
  }

  .new-file-item-status {
    grid-column: 1 / -1;
    max-width: 100%;
  }

  .new-generation-drawer {
    grid-row: 4;
  }

  .new-generation-options {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@container (max-width: 520px) {
  .new-form {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

  .new-form button[type="submit"] {
    grid-column: 1 / -1;
  }

  .new-generation-options {
    grid-template-columns: 1fr;
  }
}

.new-generation-toggle,
.new-upload-button,
.new-file-remove {
  text-decoration: none;
}

.new-feedback {
  min-height: 22px;
  margin: 22px 0 0;
  padding-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.content-grid.list-view {
  grid-template-columns: 1fr;
}

.item-card {
  min-height: 262px;
  display: grid;
  grid-template-rows: 30px 48px 72px 30px 38px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.content-grid.list-view .item-card {
  min-height: 112px;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1.25fr) minmax(210px, auto);
  grid-template-rows: 30px minmax(30px, auto) 30px;
  grid-template-areas:
    "top summary links"
    "title summary links"
    "tags summary footer";
  align-items: stretch;
  column-gap: 16px;
  row-gap: 8px;
  padding: 12px 16px;
}

.content-grid.list-view .card-topline {
  grid-area: top;
}

.content-grid.list-view .item-card h3 {
  grid-area: title;
  font-size: 16px;
}

.content-grid.list-view .item-card p {
  grid-area: summary;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.content-grid.list-view .card-tags {
  grid-area: tags;
  justify-content: flex-start;
  max-height: 56px;
}

.content-grid.list-view .card-footer {
  grid-area: footer;
}

.content-grid.list-view .card-date {
  justify-self: end;
  align-self: end;
}

.content-grid.list-view .card-links {
  grid-area: links;
  align-self: start;
}

.item-card:hover {
  box-shadow: var(--shadow);
}

.card-topline,
.card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.card-topline {
  min-width: 0;
  justify-content: space-between;
}

.card-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "date links";
  align-items: center;
}

.item-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
}

.item-icon-button,
.icon-action {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.item-icon-button:hover,
.icon-action:hover,
.item-icon-button.active,
.icon-action.active {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--warm);
}

.item-icon-button .button-icon,
.icon-action .button-icon {
  width: 16px;
  height: 16px;
}

.item-card h3 {
  font-size: 18px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.item-card p {
  color: var(--muted);
  line-height: 1.55;
  padding-bottom: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-tags,
.reader-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: start;
  min-width: 0;
  overflow: hidden;
}

.card-tags {
  max-height: 30px;
}

.card-tags span,
.reader-tags span {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--warm);
  font-size: 12px;
}

.card-links,
.reader-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reader-actions {
  position: absolute;
  top: 18px;
  right: 18px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  z-index: 1;
}

#reader-original {
  order: 4;
}

#reader-share {
  order: 5;
}

#reader-ai-panel-open {
  order: 6;
}

.card-footer a {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.source-type {
  grid-area: source;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-date {
  grid-area: date;
  color: var(--muted);
}

.card-links {
  grid-area: links;
  justify-content: flex-end;
}

.reader {
  position: fixed;
  inset: 84px 0 0 var(--sidebar-width);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--panel);
  z-index: 10;
  overflow: hidden;
  transition: left 220ms ease, right 180ms ease;
}

.sidebar-collapsed .reader {
  left: var(--sidebar-collapsed-width);
}

.reader[hidden] {
  display: none;
}

.reader-header {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 18px 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  max-height: min(280px, 45vh);
  overflow: hidden;
  position: relative;
  z-index: 2;
  will-change: max-height, padding;
  transition: padding 180ms ease, max-height 180ms ease;
}

.reader.compact-reader-header .reader-header {
  align-items: start;
  padding: 18px 18px 8px;
  height: var(--compact-panel-header-height);
  max-height: var(--compact-panel-header-height);
}

.reader.compact-reader-header .reader-heading {
  gap: 0;
}

.reader.compact-reader-header .reader-tags {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
}

.reader.compact-reader-header .reader-heading h2 {
  font-size: 17px;
  line-height: 1.28;
  -webkit-line-clamp: 1;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.button-icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-icon.moon-icon {
  fill: currentColor;
  stroke: none;
}

.reader-heading {
  display: grid;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  padding-right: 232px;
  transition: gap 180ms ease;
}

.reader-heading h2 {
  font-size: 24px;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  transition: font-size 180ms ease, line-height 180ms ease;
}

.reader-heading p {
  color: var(--muted);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.reader-tags {
  max-height: 30px;
  opacity: 1;
  transform: translateY(0);
  transition: max-height 180ms ease, opacity 140ms ease, transform 180ms ease;
}

.button-link {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

a.icon-action {
  text-decoration: none;
}

.reader-ai-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}

.reader-ai-button[hidden] {
  display: none;
}

.reader-ai-button:hover,
.reader-ai-button.active {
  background: var(--accent-dark);
}

.reader-ai-button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.reader-ai-button.danger:hover {
  filter: brightness(0.95);
}

.reader-frame-shell {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
  position: relative;
  z-index: 1;
}

.reader iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #ffffff;
}

.metadata-editor {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.38);
}

.metadata-editor[hidden] {
  display: none;
}

.metadata-dialog {
  width: min(620px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metadata-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.metadata-dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.metadata-dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.metadata-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 190px);
  gap: 12px;
  align-items: end;
}

.metadata-collection-field {
  min-width: 0;
}

.metadata-tags-row {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.metadata-field-label {
  color: var(--muted);
  font-size: 13px;
}

.metadata-dialog input,
.metadata-dialog textarea,
.metadata-dialog select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: var(--panel-soft);
  color: var(--text);
}

.metadata-dialog input,
.metadata-dialog select {
  height: 40px;
}

.metadata-dialog textarea {
  min-height: 112px;
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.5;
}

.metadata-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.metadata-tool-actions,
.metadata-submit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.metadata-actions button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}

.metadata-actions .secondary-button {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.metadata-actions .danger-secondary {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  color: var(--danger);
}

#share-revoke {
  margin-right: auto;
}

.share-expiry-row,
.share-row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.share-expiry-row {
  min-height: 24px;
  margin-top: -4px;
}

.share-expiry-row[hidden] {
  display: none;
}

.share-row-meta {
  justify-content: flex-start;
  flex-wrap: nowrap;
  min-width: 0;
}

.share-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: var(--muted);
}

.share-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent);
}

.share-status.is-active .share-status-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 16%, transparent);
}

.metadata-actions [hidden] {
  display: none;
}

.code-editor {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.46);
}

.code-editor[hidden] {
  display: none;
}

.code-editor-dialog {
  width: min(1180px, 100%);
  height: min(820px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.code-editor.is-fullscreen {
  padding: 0;
}

.code-editor.is-fullscreen .code-editor-dialog {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.code-editor-toolbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
}

.code-editor-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.code-editor-title strong {
  font-size: 0.95rem;
}

#code-editor-item-title {
  max-width: 52vw;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-editor-actions button {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}

.code-editor-actions .secondary-button {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.code-editor-body {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#code-editor-textarea {
  min-height: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 16px;
  resize: none;
  background: color-mix(in srgb, var(--panel-soft) 82%, #000 4%);
  color: var(--text);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  tab-size: 2;
  white-space: pre-wrap;
  outline: none;
}

.code-editor-floating-actions {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-editor-floating-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 8px;
  padding: 0;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  color: var(--text);
  cursor: pointer;
  opacity: 0.72;
  backdrop-filter: blur(8px);
}

.code-editor-floating-button:hover {
  opacity: 1;
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  color: var(--accent-dark);
}

.code-editor-floating-button[aria-pressed="false"] {
  color: var(--muted);
}

.code-editor-floating-button .button-icon {
  width: 18px;
  height: 18px;
}

#code-editor-textarea.no-wrap {
  overflow: auto;
  white-space: pre;
}

.code-editor-status {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

#code-editor-feedback {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-editor {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  background: rgba(15, 23, 42, 0.46);
}

.file-editor[hidden] {
  display: none;
}

.file-editor-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
}

.file-editor-toolbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.file-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-editor-actions button {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}

.file-editor-actions .secondary-button {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.file-editor-actions .secondary-button.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--accent-dark);
}

.file-editor-actions .icon-only-button {
  width: 36px;
  padding: 0;
  display: grid;
  place-items: center;
}

.file-editor-actions .icon-only-button .button-icon {
  width: 18px;
  height: 18px;
}

.file-editor-stage {
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--panel-soft);
}

#file-editor-frame {
  width: calc(100% - var(--file-editor-panel-width, 320px));
  height: 100%;
  border: 0;
  background: #fff;
  transition: width 180ms ease;
}

.file-editor.panel-collapsed #file-editor-frame {
  width: 100%;
}

.file-editor-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--file-editor-panel-width, 320px);
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 14px;
  border-left: 1px solid var(--line);
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transform: translateX(0);
  transition: transform 180ms ease;
  will-change: transform;
}

.file-editor-panel-resize {
  position: absolute;
  top: 0;
  bottom: 0;
  right: var(--file-editor-panel-width, 320px);
  width: 1px;
  cursor: col-resize;
  background: var(--line);
  z-index: 2;
  transition: right 180ms ease, opacity 160ms ease;
}

.file-editor-panel-resize::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  width: 8px;
  background: transparent;
}

.file-editor.panel-collapsed .file-editor-panel-resize {
  opacity: 0;
  pointer-events: none;
}

.file-editor-panel-floating-toggle {
  position: absolute;
  top: 10px;
  right: calc(var(--file-editor-panel-width, 320px) + 18px);
  z-index: 3;
  transition: right 180ms ease, opacity 160ms ease, border-color 160ms ease, color 160ms ease;
}

.file-editor.panel-collapsed .file-editor-panel-floating-toggle {
  right: 18px;
}

.file-editor-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
}

.file-editor-panel-header strong {
  font-size: 0.95rem;
}

#file-editor-selected-name,
#file-editor-feedback {
  color: var(--muted);
  font-size: 0.82rem;
}

.file-editor.panel-collapsed .file-editor-panel {
  width: var(--file-editor-panel-width, 320px);
  overflow: hidden;
  transform: translateX(100%);
}

.file-editor.panel-collapsed .file-editor-panel > :not(.file-editor-panel-header) {
  display: none;
}

.file-editor-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.file-editor-panel textarea,
.file-editor-panel input,
.file-editor-panel select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
}

.file-editor-panel textarea {
  min-height: 156px;
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.5;
}

.file-editor-panel input,
.file-editor-panel select {
  height: 38px;
  padding: 0 10px;
}

.file-editor-panel input[type="color"] {
  padding: 4px;
}

.file-editor-color-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.file-editor-inline-style {
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-editor-inline-style button {
  width: 32px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.file-editor-inline-style button[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--accent-dark);
}

.file-editor-actions button:disabled,
.file-editor-actions button[disabled] {
  opacity: 0.42;
  cursor: not-allowed;
  color: var(--muted);
  border-color: var(--line);
  background: var(--panel-soft);
}

.underline-sample {
  text-decoration: underline;
}

.strike-sample {
  text-decoration: line-through;
}

.file-editor-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.share-list {
  display: grid;
  gap: 10px;
}

.share-row.management-row {
  grid-template-columns: minmax(140px, 1fr) max-content max-content;
  align-items: center;
  column-gap: 14px;
}

.share-row .management-name {
  min-width: 0;
}

.share-row-details {
  min-width: max-content;
  max-width: none;
  overflow: visible;
  justify-self: start;
}

.share-row .management-name strong,
.share-row-title {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-row-title {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 760;
  text-align: left;
  cursor: pointer;
}

.share-row-title:hover {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.share-row .share-row-meta {
  margin-top: 0;
  max-width: none;
  overflow: visible;
  text-align: left;
}

.share-row .share-row-meta > span {
  flex: 0 0 auto;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.share-row .management-actions {
  justify-self: end;
  flex-wrap: nowrap;
}

.share-row .management-actions button {
  cursor: pointer;
}

.share-row .management-actions button:first-child {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: var(--danger);
}

@media (max-width: 760px) {
  .share-row.management-row {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .share-row .share-row-meta {
    margin-top: 6px;
  }

  .share-row .management-actions {
    justify-content: flex-start;
  }
}

#reader-share.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: var(--accent-dark);
}

.item-icon-button[data-item-action="share"].active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: var(--accent-dark);
}

.metadata-tag-picker {
  min-height: 40px;
  max-height: 154px;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  background: var(--panel-soft);
}

.metadata-chip {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.metadata-chip.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--accent-dark);
}

.metadata-chip.add-chip {
  border-style: dashed;
  color: var(--accent-dark);
}

.settings-page {
  position: fixed;
  inset: 0 0 0 var(--sidebar-width);
  z-index: 20;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
  transition: left 220ms ease, right 180ms ease;
}

.sidebar-collapsed .settings-page {
  left: var(--sidebar-collapsed-width);
}

.settings-page[hidden] {
  display: none;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.settings-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-header h2,
.section-heading h3,
.section-heading p,
.text-block p,
.settings-feedback {
  margin: 0;
}

.settings-header h2 {
  font-size: 26px;
}

.settings-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.settings-nav {
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
}

.settings-tab {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.settings-tab:hover,
.settings-tab.active {
  border-color: var(--line);
  background: var(--panel);
}

.settings-divider {
  height: 1px;
  margin: 10px 0;
  background: var(--line);
}

.settings-content {
  min-width: 0;
  overflow: auto;
  padding: 24px;
}

.settings-section {
  display: none;
  max-width: 920px;
}

.settings-section.active {
  display: grid;
  gap: 18px;
}

.section-heading {
  display: grid;
  gap: 8px;
}

.section-heading h3 {
  font-size: 22px;
}

.section-heading p,
.text-block {
  color: var(--muted);
  line-height: 1.65;
}

.settings-form {
  display: grid;
  gap: 14px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
}

.settings-form label,
.settings-field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-form .switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-form .switch-row input {
  width: 16px;
  height: 16px;
}

.settings-form input,
.settings-form select,
.settings-form textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: var(--panel-soft);
  color: var(--text);
}

.theme-mode-group {
  height: 40px;
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.theme-mode-group button {
  height: 32px;
  min-width: 88px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-mode-group button:hover {
  border-color: transparent;
  background: transparent;
  color: var(--text);
}

.theme-mode-group button.active {
  border-color: transparent;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 760;
  box-shadow: none;
}

.theme-mode-group button.active::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.theme-mode-group button.active:hover {
  border-color: transparent;
  background: transparent;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.settings-form textarea {
  min-height: 120px;
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid > * {
  min-width: 0;
}

.security-note {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-actions button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}

.settings-actions .secondary-button {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.logout-button {
  display: none;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--text);
  background: var(--panel-soft);
  cursor: pointer;
}

.auth-session-active .logout-button {
  display: inline-flex;
  align-items: center;
}

.settings-feedback {
  color: var(--muted);
  min-height: 20px;
}

.management-list {
  display: grid;
  gap: 10px;
}

.management-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.management-row-compact {
  grid-template-columns: minmax(150px, 1fr) auto;
}

.management-name {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.management-row strong {
  color: var(--text);
  font-weight: 600;
}

.ai-run-history {
  display: grid;
  gap: 14px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.ai-run-list,
.ai-generation-list,
.ai-conversation-list {
  display: grid;
  gap: 10px;
}

.ai-run-row,
.ai-generation-row,
.ai-conversation-row {
  grid-template-columns: minmax(180px, 1fr) auto;
}

.ai-run-row {
  grid-template-columns: minmax(200px, 0.4fr) minmax(0, 1fr) 74px;
  min-height: 64px;
  padding: 10px 12px;
}

.ai-run-row .management-name {
  display: contents;
}

.ai-run-row .management-name strong {
  min-width: 0;
  overflow: hidden;
  align-self: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-run-row code {
  color: var(--muted);
  font-size: 12px;
}

.ai-run-actions-inline {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.ai-run-actions-inline button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.ai-run-row .ai-run-actions-inline button {
  width: 58px;
  padding: 0;
  font-size: 13px;
}

.ai-run-actions-inline .ai-run-icon-button {
  width: 30px;
  min-height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
}

.ai-run-actions-inline .ai-run-icon-button .button-icon {
  width: 15px;
  height: 15px;
}

.ai-run-actions-inline .ai-run-icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.ai-run-actions-inline .primary-inline-button {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--accent);
  color: var(--accent-contrast);
}

.ai-run-actions-inline .primary-inline-button:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: var(--accent-contrast);
}

.ai-run-actions-inline .ai-run-status-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--panel-soft));
  color: var(--accent-dark);
  cursor: default;
}

.ai-run-queue-index {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.ai-generation-row-notice {
  grid-column: 1 / -1;
  margin-top: -2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.ai-run-detail-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.ai-generation-more-panel {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.ai-generation-detail {
  z-index: 72;
}

.ai-generation-detail-dialog {
  width: min(1240px, calc(100vw - 32px));
  height: min(920px, calc(100vh - 24px));
  min-height: min(720px, calc(100vh - 24px));
  display: grid;
  grid-template-rows: auto auto minmax(420px, 1fr) minmax(140px, 220px) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: color-mix(in srgb, var(--panel) 96%, var(--accent) 4%);
  box-shadow: var(--shadow);
}

.ai-generation-detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}

.ai-generation-detail-eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.ai-generation-detail-header h2 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-generation-detail-meta,
.ai-generation-detail-status,
.ai-generation-stage-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 12px;
}

.ai-generation-detail-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.ai-generation-detail-actions button {
  min-height: 34px;
}

.ai-generation-detail-actions button:disabled {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.72;
}

.ai-generation-detail-open-button {
  min-width: 116px;
  justify-content: center;
  gap: 8px;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 10%, transparent);
}

.ai-generation-detail-open-button:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
}

.ai-generation-detail-open-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 88%, #fff 12%);
  color: var(--accent-dark);
}

.ai-generation-detail-status {
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--panel-soft);
}

.ai-generation-detail-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  gap: 12px;
}

.ai-generation-stage-list,
.ai-generation-stage-panel {
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.ai-generation-stage-list {
  display: grid;
  align-content: start;
  gap: 3px;
  padding: 8px;
}

.ai-generation-stage-node {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  grid-template-areas:
    "dot title"
    "dot meta";
  gap: 1px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 48px;
  padding: 6px 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.ai-generation-stage-node:hover,
.ai-generation-stage-node.active {
  border-color: var(--line);
  background: var(--panel-soft);
}

.ai-generation-stage-node.failed {
  color: var(--danger);
}

.ai-generation-stage-dot {
  grid-area: dot;
  width: 9px;
  height: 9px;
  margin-top: 3px;
  border: 2px solid currentColor;
  border-radius: 999px;
  color: var(--accent);
}

.ai-generation-stage-node.running .ai-generation-stage-dot {
  background: var(--accent);
  animation: ai-job-pulse 1.1s ease-in-out infinite;
}

.ai-generation-stage-node strong,
.ai-generation-stage-node small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-generation-stage-node strong {
  grid-area: title;
  font-size: 14px;
}

.ai-generation-stage-node small {
  grid-area: meta;
  color: var(--muted);
  font-size: 13px;
}

.ai-generation-stage-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
}

.ai-generation-stage-loading {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.ai-generation-stage-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.ai-generation-stage-detail-head p,
.ai-generation-stage-detail-head h3,
.ai-generation-stage-panel h4,
.ai-generation-stage-panel p {
  margin: 0;
}

.ai-generation-stage-detail-head p {
  color: var(--muted);
  font-size: 12px;
}

.ai-generation-stage-detail-head h3 {
  margin-top: 3px;
  color: var(--text);
  font-size: 18px;
}

.ai-generation-stage-panel section {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.ai-generation-stage-panel h4 {
  color: var(--text);
  font-size: 12px;
}

.ai-generation-stage-panel p,
.ai-generation-stage-panel dl,
.ai-generation-detail-list {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.ai-generation-user-instruction p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
}

.ai-generation-detail-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
}

.ai-generation-detail-footer {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ai-generation-detail-footer section {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.ai-generation-detail-footer section > div {
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
}

.ai-generation-detail-footer h3 {
  margin: 0 0 8px;
  font-size: 12px;
}

.ai-generation-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ai-generation-chip-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 7px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 11px;
}

.ai-generation-chip-list em {
  color: var(--muted);
  font-style: normal;
}

.ai-generation-skill-group {
  display: grid;
  gap: 7px;
}

.ai-generation-skill-group + .ai-generation-skill-group {
  margin-top: 10px;
}

.ai-generation-skill-group h4 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.ai-generation-skill-list {
  min-height: 0;
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ai-generation-skill-list li {
  min-width: 0;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 8px;
  background: var(--panel-soft);
}

.ai-generation-skill-list div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.ai-generation-skill-list span,
.ai-generation-skill-list em,
.ai-generation-skill-list small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ai-generation-skill-list span {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.ai-generation-skill-list em,
.ai-generation-skill-list small {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.ai-run-detail-panel section {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-soft);
}

.ai-run-detail-panel h4 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.ai-run-detail-panel p,
.ai-run-detail-panel ul,
.ai-run-detail-panel ol,
.ai-run-detail-panel dl {
  margin: 0;
}

.ai-run-detail-panel ul,
.ai-run-detail-panel ol {
  padding-left: 18px;
}

.ai-run-detail-panel dl {
  display: grid;
  gap: 6px;
}

.ai-run-detail-panel dl div {
  display: grid;
  grid-template-columns: minmax(86px, auto) minmax(0, 1fr);
  gap: 8px;
}

.ai-run-detail-panel dt {
  color: var(--text);
}

.ai-run-detail-panel dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.ai-run-detail-panel li em {
  color: var(--accent);
  font-style: normal;
}

.ai-run-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.ai-run-row .ai-run-meta {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 3px;
}

.ai-run-meta-primary {
  min-width: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.ai-run-facts {
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-run-facts > * {
  flex: 0 0 auto;
}

.ai-generation-row .ai-run-meta,
.ai-conversation-row .ai-run-meta {
  justify-content: flex-end;
}

.ai-run-status {
  border-radius: 999px;
  padding: 2px 7px;
  font-style: normal;
  color: var(--muted);
  background: var(--panel-soft);
}

.ai-run-status.status-completed {
  color: #047857;
  background: rgba(16, 185, 129, 0.13);
}

.ai-run-status.status-failed {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.13);
}

.ai-run-status.status-running,
.ai-run-status.status-pending {
  color: #0369a1;
  background: rgba(14, 165, 233, 0.13);
}

.ai-run-error {
  color: var(--danger);
}

.ai-run-capability {
  color: var(--accent);
}

.ai-run-capability.muted {
  color: var(--muted);
}

@media (max-width: 760px) {
  .ai-run-row {
    grid-template-columns: 1fr;
  }

  .ai-run-row .management-name {
    display: grid;
  }

  .ai-run-actions-inline {
    justify-content: flex-start;
  }

  .ai-run-detail-panel {
    grid-template-columns: 1fr;
  }
}

.management-row label,
.management-actions-panel p {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.management-row input[type="text"],
.management-actions-panel input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel-soft);
  color: var(--text);
}

.management-row .switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.management-actions-panel {
  display: grid;
  gap: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.management-actions-panel p {
  margin: 0;
  line-height: 1.55;
}

.management-actions-panel div,
.management-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.management-actions-panel input {
  flex: 1 1 220px;
}

.management-actions button,
.management-actions-panel button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel-soft);
  color: var(--muted);
}

.management-actions button:disabled,
.management-actions-panel button:disabled,
.management-actions-panel input:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
  color: var(--muted);
}

.placeholder-panel {
  display: grid;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  color: var(--muted);
  line-height: 1.6;
}

.placeholder-panel strong {
  color: var(--text);
}

.placeholder-panel p {
  margin: 0;
}

@media (max-width: 900px) {
  .ai-generation-detail {
    padding: 12px;
  }

  .ai-generation-detail-dialog {
    width: 100%;
    height: calc(100vh - 24px);
    min-height: 0;
    grid-template-rows: auto auto minmax(0, 1fr) minmax(140px, 220px) auto;
  }

  .ai-generation-detail-header,
  .ai-generation-detail-body,
  .ai-generation-detail-footer {
    grid-template-columns: 1fr;
  }

  .ai-generation-stage-list {
    max-height: 220px;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .ai-panel-open .shell,
  .sidebar-collapsed.ai-panel-open .shell {
    width: auto;
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 35;
    height: auto;
    min-height: 58px;
    width: 100%;
    min-width: 0;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 10px;
    align-items: center;
  }

  .sidebar-resize {
    display: none;
  }

  .sidebar-tools {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
    padding-top: 0;
    justify-content: flex-end;
    gap: 8px;
  }

  .sidebar-tool-group {
    flex-direction: row;
    gap: 6px;
  }

  .sidebar-header {
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: minmax(0, 1fr) 32px;
    margin-bottom: 0;
  }

  .brand {
    justify-content: flex-start;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .sidebar-main {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    max-height: min(58vh, 420px);
    overflow-y: auto;
    padding: 8px 0 2px;
    transform: none;
    opacity: 1;
  }

  .sidebar-collapsed .shell {
    grid-template-columns: 1fr;
  }

  .sidebar-collapsed .sidebar {
    width: 100%;
    min-width: 0;
    padding: 8px 12px;
  }

  .sidebar-collapsed .sidebar-header {
    grid-template-columns: minmax(0, 1fr) 32px;
    justify-items: stretch;
  }

  .sidebar-collapsed .brand {
    justify-content: flex-start;
  }

  .sidebar-collapsed .brand-copy {
    max-width: 160px;
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .sidebar-collapsed .sidebar-main {
    display: none;
  }

  .reader-open .sidebar-main,
  .reader-open .sidebar-tools {
    display: none;
  }

  .reader-open .sidebar {
    grid-template-columns: 1fr;
  }

  .reader-open .sidebar-header {
    grid-template-columns: minmax(0, 1fr) 32px;
  }

  .sidebar-collapsed .sidebar-tools,
  .sidebar-collapsed .sidebar-tool-group {
    flex-direction: row;
  }

  .sidebar-collapsed .project-link,
  .sidebar-collapsed .github-link {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .project-link,
  .github-link {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .project-link span,
  .github-link span {
    display: none;
  }

  .new-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .new-form {
    grid-template-columns: 1fr;
  }

  .new-file-row {
    grid-column: 1 / -1;
  }

  .new-generation-options {
    grid-template-columns: 1fr;
  }

  .reader {
    inset: var(--mobile-reader-top, 58px) 0 0;
    grid-template-rows: auto auto;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .sidebar-collapsed .reader {
    left: 0;
  }

  .settings-page {
    inset: 0;
  }

  .sidebar-collapsed .settings-page {
    left: 0;
  }

  .ai-panel-open .reader,
  .ai-panel-open .settings-page {
    right: 0;
  }

  .ai-panel {
    width: min(420px, 100vw) !important;
    min-width: 0;
    max-width: 100vw;
  }

  .settings-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-nav {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
    padding: 12px 14px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .settings-nav::-webkit-scrollbar {
    display: none;
  }

  .settings-tab {
    width: auto;
    min-width: max-content;
    min-height: 40px;
    max-height: 40px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    text-align: center;
  }

  .settings-divider {
    width: 1px;
    height: 24px;
    margin: 0 2px;
    flex: 0 0 1px;
  }

  .settings-content {
    min-height: 0;
    padding: 20px 16px 28px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .metadata-title-row {
    grid-template-columns: 1fr;
  }

  .file-editor-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .file-editor-actions {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .file-editor-stage {
    display: grid;
    grid-template-rows: minmax(0, 1fr) minmax(220px, 36vh);
  }

  .file-editor.panel-collapsed .file-editor-stage {
    grid-template-rows: minmax(0, 1fr) 42px;
  }

  #file-editor-frame,
  .file-editor.panel-collapsed #file-editor-frame {
    width: 100%;
  }

  .file-editor-panel-resize {
    display: none;
  }

  .file-editor-panel {
    position: static;
    width: auto;
    transform: none;
    box-shadow: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .file-editor.panel-collapsed .file-editor-panel {
    width: auto;
    transform: none;
  }

  .file-editor-panel-floating-toggle,
  .file-editor.panel-collapsed .file-editor-panel-floating-toggle {
    right: 18px;
  }

  .file-editor-color-row {
    grid-template-columns: 1fr;
  }

  .management-row {
    grid-template-columns: 1fr;
  }

  .reader-header {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 12px 14px 10px;
    max-height: none;
    overflow: visible;
    position: relative;
  }

  .reader-actions {
    position: static;
    grid-column: 1 / -1;
    justify-content: flex-start;
    gap: 7px;
    overflow-x: auto;
    padding: 2px 0 4px;
    scrollbar-width: none;
  }

  .reader-actions::-webkit-scrollbar {
    display: none;
  }

  .reader.compact-reader-header .reader-header {
    height: auto;
    max-height: none;
    padding: 12px 14px 10px;
  }

  .reader.compact-reader-header .reader-tags {
    display: none;
  }

  .reader.compact-reader-header .reader-heading h2 {
    font-size: 24px;
    line-height: 1.25;
    -webkit-line-clamp: 2;
  }

  .reader-heading {
    padding-right: 0;
  }

  .reader-frame-shell {
    overflow: visible;
  }

  .reader iframe {
    height: auto;
    min-height: calc(100vh - var(--mobile-reader-top, 0px));
    overflow: hidden;
  }

  .content-grid.list-view .item-card {
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "title"
      "summary"
      "tags"
      "footer";
  }

  .content-grid.list-view .card-footer {
    align-items: stretch;
    flex-direction: row;
  }
}

@media (min-width: 901px) {
  .topbar {
    z-index: 12;
  }
}

@media (prefers-color-scheme: dark) {
  .share-fallback-body {
    background: #101820;
    color: #e6edf3;
  }

  .share-fallback-banner {
    border-color: #334155;
  }

  .share-fallback-banner p {
    color: #a9b6c6;
  }

  .share-fallback-frame {
    background: #111827;
  }
}

@container (max-width: 560px) {
  .topbar-search-group {
    flex: 1 0 100%;
  }
}
