:root {
  --brand: oklch(42% .072 185);
  --brand-deep: oklch(31% .058 185);
  --brand-soft: oklch(94.5% .026 180);
  --accent: oklch(62% .145 54);
  --accent-soft: oklch(95% .035 60);
  --success: oklch(48% .105 155);
  --success-soft: oklch(94.5% .032 150);
  --warning: oklch(53% .125 68);
  --warning-soft: oklch(95% .042 76);
  --danger: oklch(50% .17 25);
  --danger-soft: oklch(95.5% .03 25);
  --ink: oklch(25% .024 235);
  --ink-strong: oklch(17.5% .026 235);
  --muted: oklch(46% .022 230);
  --muted-light: oklch(54% .02 225);
  --paper: oklch(97.7% .009 85);
  --surface: oklch(99.2% .006 85);
  --surface-2: oklch(94.5% .014 82);
  --surface-3: oklch(91.5% .018 82);
  --line: oklch(86% .017 82);
  --line-strong: oklch(65% .026 78);
  --sidebar: oklch(19% .021 235);
  --sidebar-2: oklch(23% .022 235);
  --sidebar-text: oklch(91% .014 82);
  --sidebar-muted: oklch(72% .018 82);
  --shadow-float: 0 24px 70px -34px oklch(18% .025 235 / .38);
  --shadow-lift: 0 12px 28px -22px oklch(18% .025 235 / .32);
  --ring: 0 0 0 3px oklch(42% .072 185 / .22);
  --radius-xs: 4px;
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --font-sans: "Segoe UI Variable Text", "Segoe UI Variable", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, sans-serif;
  --font-ui: var(--font-sans);
  --font-display: var(--font-sans);
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --text-xs: .8125rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: clamp(1.5rem, 1.38rem + .45vw, 1.875rem);
  --text-display: clamp(2.5rem, 2rem + 2.15vw, 4rem);
  --leading-tight: 1.2;
  --leading-snug: 1.4;
  --leading-body: 1.65;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-toggle: cubic-bezier(.65, 0, .35, 1);
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-ui);
  font-synthesis: none;
  font-kerning: normal;
  font-optical-sizing: auto;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); color: var(--ink); font-size: var(--text-base); font-weight: var(--weight-regular); line-height: var(--leading-body); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
small { font-size: var(--text-xs); line-height: 1.5; }
a { color: var(--brand-deep); }
svg { display: block; }
::selection { background: var(--brand-soft); color: var(--ink-strong); }
::placeholder { color: var(--muted-light); opacity: 1; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.icon-sprite { position: fixed; width: 0; height: 0; overflow: hidden; pointer-events: none; }

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link { position: fixed; left: 18px; top: -64px; z-index: 300; background: var(--ink-strong); color: var(--surface); padding: 11px 16px; text-decoration: none; border-radius: var(--radius-sm); white-space: nowrap; }
.skip-link:focus { top: 18px; }
.eyebrow, .folio { margin: 0; color: var(--brand); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .09em; line-height: 1.4; text-transform: uppercase; }
.folio { font-variant-numeric: tabular-nums; }

.brand-symbol { position: relative; width: 38px; height: 42px; flex: 0 0 38px; display: block; border: 1px solid currentColor; color: inherit; }
.brand-symbol::before { content: ""; position: absolute; inset: 4px -5px -5px 4px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; opacity: .45; }
.brand-symbol::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 9px; border-top: 1px solid currentColor; box-shadow: 0 -5px 0 currentColor; opacity: .72; }
.brand-symbol i { position: absolute; width: 15px; height: 1px; top: 11px; left: 11px; background: currentColor; transform: rotate(-42deg); transform-origin: center; }

/* Login — architectural editorial, not a marketing landing page. */
.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.22fr) minmax(390px, .78fr); background: var(--paper); }
.login-brand { position: relative; isolation: isolate; min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: clamp(42px, 6vw, 88px) clamp(42px, 8vw, 132px); color: var(--sidebar-text); background: var(--sidebar); }
.login-brand::before { content: ""; position: absolute; z-index: -1; inset: 0; background-image: linear-gradient(oklch(91% .014 82 / .055) 1px, transparent 1px), linear-gradient(90deg, oklch(91% .014 82 / .055) 1px, transparent 1px); background-size: 48px 48px; mask-image: linear-gradient(90deg, transparent, black 26%, black); }
.login-brand::after { content: "01"; position: absolute; z-index: -1; right: clamp(32px, 5vw, 84px); bottom: -0.18em; color: oklch(91% .014 82 / .045); font-family: var(--font-display); font-size: clamp(15rem, 28vw, 32rem); line-height: 1; font-variant-numeric: lining-nums; }
.login-brand-lockup { display: flex; align-items: center; gap: 17px; color: var(--sidebar-text); }
.login-brand-lockup strong { font-family: var(--font-display); font-size: 1.2rem; font-weight: var(--weight-bold); letter-spacing: .035em; }
.login-statement { position: relative; max-width: 800px; padding-left: clamp(20px, 2vw, 32px); border-left: 1px solid oklch(91% .014 82 / .36); }
.login-statement .folio { color: oklch(78% .06 66); }
.login-statement h1 { max-width: 10ch; margin: 18px 0 24px; color: var(--sidebar-text); font-family: var(--font-display); font-size: clamp(3rem, 5.35vw, 5.75rem); font-weight: var(--weight-bold); line-height: 1.02; letter-spacing: -.035em; text-wrap: balance; }
.login-statement p { margin: 0; color: var(--sidebar-muted); font-size: var(--text-sm); font-weight: var(--weight-semibold); letter-spacing: .08em; }
.login-panel { width: min(430px, calc(100% - 48px)); align-self: center; justify-self: center; display: grid; gap: var(--space-5); padding: 38px 0 44px; border-top: 2px solid var(--brand); }
.login-panel header { display: grid; gap: 10px; margin-bottom: 8px; }
.login-panel h2, dialog h2 { margin: 0; color: var(--ink-strong); font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: var(--leading-tight); letter-spacing: -.02em; }

label { display: grid; gap: 8px; color: var(--ink); font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: 1.5; }
input, textarea, select { width: 100%; min-height: 46px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-strong); padding: 10px 13px; outline: none; transition: border-color 150ms var(--ease-toggle), box-shadow 150ms var(--ease-toggle), background 150ms var(--ease-toggle); }
textarea { min-height: 104px; resize: vertical; line-height: 1.7; }
input:hover, textarea:hover, select:hover { border-color: var(--brand); }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: var(--ring); }
input[type="file"] { padding: 8px; }
input[type="file"]::file-selector-button { min-height: 32px; margin-right: 12px; border: 0; border-radius: var(--radius-xs); padding: 5px 10px; color: var(--brand-deep); background: var(--brand-soft); font-size: var(--text-sm); font-weight: var(--weight-semibold); cursor: pointer; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 17px; color: var(--ink); background: transparent; font-size: var(--text-sm); font-weight: var(--weight-semibold); letter-spacing: .005em; line-height: 1.35; text-decoration: none; white-space: nowrap; transition: color 150ms var(--ease-toggle), background 150ms var(--ease-toggle), border-color 150ms var(--ease-toggle); }
.button:active { filter: brightness(.96); }
.button:disabled { opacity: .5; cursor: wait; transform: none; }
.button[aria-busy="true"] { position: relative; padding-right: 38px; }
.button[aria-busy="true"]::before { content: ""; position: absolute; right: 14px; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: busy-spin 700ms linear infinite; }
.button.primary { position: relative; overflow: hidden; background: var(--brand-deep); color: var(--surface); }
.button.primary::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 220ms var(--ease-out); }
.button.primary:hover { background: var(--brand); }
.button.primary:hover::after { transform: scaleX(1); }
.button.secondary { border-color: var(--line-strong); background: transparent; }
.button.secondary:hover { border-color: var(--brand); color: var(--brand-deep); background: var(--brand-soft); }
.button.danger { border-color: color-mix(in oklch, var(--danger) 38%, var(--line)); color: var(--danger); background: var(--danger-soft); }
.form-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: var(--text-sm); line-height: 1.55; }

/* Product shell */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 40; height: 100vh; display: flex; flex-direction: column; overflow: hidden; overscroll-behavior: contain; padding: 24px 14px max(20px, env(safe-area-inset-bottom)); color: var(--sidebar-text); background: var(--sidebar); }
.sidebar::after { content: ""; position: absolute; top: 0; right: 14px; bottom: 0; border-right: 1px solid oklch(91% .014 82 / .07); pointer-events: none; }
.sidebar-scrim { display: none; }
.brand { position: relative; display: flex; align-items: center; gap: 14px; padding: 2px 10px 26px; color: var(--sidebar-text); text-decoration: none; }
.brand > span:last-child { display: grid; gap: 3px; }
.brand strong { font-family: var(--font-display); font-size: 1.05rem; font-weight: var(--weight-bold); letter-spacing: .025em; }
.brand small { color: var(--sidebar-muted); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .07em; }
.brand-symbol { color: var(--accent); }
nav { display: grid; gap: 2px; overflow-y: auto; padding: 0 3px 0 0; scrollbar-width: thin; scrollbar-color: var(--sidebar-2) transparent; }
.nav-label { margin: 21px 12px 8px; color: oklch(72% .018 82 / .72); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .08em; }
.nav-item { position: relative; width: 100%; min-height: 44px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: var(--radius-sm); padding: 9px 12px; color: var(--sidebar-muted); background: transparent; text-align: left; font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1.4; transition: color 150ms var(--ease-toggle), background 150ms var(--ease-toggle); }
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: square; stroke-linejoin: miter; }
.nav-item b { margin-left: auto; color: oklch(72% .018 82 / .58); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.nav-item:hover { color: var(--sidebar-text); background: var(--sidebar-2); }
.nav-item.active { color: var(--sidebar-text); background: oklch(27% .03 207); }
.nav-item.active::after { content: ""; position: absolute; right: 0; top: 11px; bottom: 11px; width: 2px; background: var(--accent); }
.nav-item.active svg { color: oklch(78% .09 178); }
.sidebar-footer { position: relative; margin-top: auto; padding: 18px 10px 0; border-top: 1px solid oklch(91% .014 82 / .12); }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip > span:first-child { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border: 1px solid oklch(91% .014 82 / .18); border-radius: 50%; color: var(--sidebar-text); background: var(--sidebar-2); font-family: var(--font-display); font-weight: var(--weight-bold); }
.user-chip > span:last-child { min-width: 0; }
.user-chip strong, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { color: var(--sidebar-text); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.user-chip small { margin-top: 2px; color: var(--sidebar-muted); font-size: var(--text-xs); }
.identity-badge { display: inline-flex; margin-top: 11px; padding: 4px 8px; border: 1px solid oklch(91% .014 82 / .18); border-radius: 99px; color: var(--sidebar-muted); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .03em; }
.text-button { min-height: 42px; border: 0; background: transparent; color: var(--sidebar-muted); padding: 11px 0 0; font-size: var(--text-xs); font-weight: var(--weight-medium); }
.text-button:hover { color: var(--sidebar-text); }

main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar-inner { width: 100%; max-width: 1640px; min-height: 88px; margin-inline: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 17px clamp(24px, 4vw, 58px); }
.page-heading { min-width: 0; }
.topbar h1 { max-width: min(980px, 70vw); margin: 4px 0 0; overflow: hidden; color: var(--ink-strong); font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: var(--leading-tight); letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
#page-title:focus-visible { outline: 0; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { display: none; width: 44px; height: 44px; place-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); background: var(--surface); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.page { width: 100%; max-width: 1640px; margin-inline: auto; padding: clamp(28px, 3vw, 48px) clamp(24px, 4vw, 58px) 88px; }

/* Dashboard */
.workbench-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(290px, .58fr); gap: clamp(36px, 6vw, 96px); align-items: end; min-height: 230px; padding: 6px 0 34px; border-bottom: 1px solid var(--ink-strong); }
.workbench-hero::before { content: ""; position: absolute; left: 0; bottom: -1px; width: min(180px, 24%); height: 3px; background: var(--brand); }
.workbench-title { max-width: 16ch; margin: 14px 0 14px; color: var(--ink-strong); font-family: var(--font-display); font-size: var(--text-display); font-weight: var(--weight-bold); line-height: 1.06; letter-spacing: -.035em; text-wrap: balance; }
.workbench-lead { max-width: 62ch; margin: 0; color: var(--muted); font-size: var(--text-base); line-height: 1.72; }
.workbench-lead strong, .workbench-lead span { display: -webkit-box; overflow: hidden; overflow-wrap: anywhere; -webkit-box-orient: vertical; }
.workbench-lead strong { margin-bottom: 5px; color: var(--ink-strong); font-size: 1.0625rem; font-weight: var(--weight-semibold); -webkit-line-clamp: 1; }
.workbench-lead span { -webkit-line-clamp: 2; }
.workbench-hero .button { margin-top: 24px; }
.workbench-brief { display: grid; border-top: 1px solid var(--line-strong); }
.brief-row { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.brief-row span { color: var(--muted); font-size: var(--text-sm); }
.brief-row strong { color: var(--ink-strong); font-family: var(--font-display); font-size: 1.75rem; font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.workflow-lane { counter-reset: workflow; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 30px 0 8px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.workflow-step { position: relative; min-height: 118px; display: grid; grid-template-columns: auto 1fr auto; align-content: center; gap: 4px 15px; padding: 24px 26px; border: 0; border-right: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; transition: background 180ms var(--ease-toggle); }
.workflow-step:last-child { border-right: 0; }
.workflow-step::after { content: "→"; grid-column: 3; grid-row: 1 / span 2; align-self: center; color: var(--muted-light); font-size: 1.1rem; transform: translateX(-5px); transition: color 180ms var(--ease-toggle), transform 220ms var(--ease-out); }
.workflow-step:hover { background: var(--brand-soft); }
.workflow-step:hover::after { color: var(--brand); transform: none; }
.workflow-step .step-index { grid-row: 1 / span 2; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--brand); border-radius: 50%; color: var(--brand-deep); background: transparent; font-size: var(--text-xs); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.workflow-step strong { color: var(--ink-strong); font-family: var(--font-display); font-size: 1.0625rem; font-weight: var(--weight-bold); }
.workflow-step p { grid-column: 2; margin: 3px 0 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }

/* Content primitives */
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.metric { min-height: 128px; padding: 19px 22px; border-right: 1px solid var(--line); background: transparent; }
.metric:last-child { border-right: 0; }
.metric small { color: var(--muted); font-size: var(--text-xs); }
.metric strong { display: block; margin-top: 13px; color: var(--ink-strong); font-family: var(--font-display); font-size: 2rem; font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.metric span { display: block; margin-top: 8px; overflow-wrap: anywhere; color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 48px 0 16px; }
.section-head.compact { margin-top: 0; }
.section-head.first { margin-top: 0; }
.section-head h2 { margin: 0; color: var(--ink-strong); font-family: var(--font-display); font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: 1.3; letter-spacing: -.015em; }
.section-head p { margin: 7px 0 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }
.panel { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); box-shadow: 0 1px 0 oklch(18% .025 235 / .025), var(--shadow-lift); }
.table-wrap { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: 1.55; font-variant-numeric: tabular-nums; }
th { color: var(--muted); background: var(--surface-2); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .045em; text-align: left; text-transform: uppercase; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { transition: background 120ms var(--ease-toggle); }
tbody tr:hover { background: color-mix(in oklch, var(--brand-soft) 44%, var(--surface)); }
tr:last-child td { border-bottom: 0; }
td { overflow-wrap: anywhere; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 99px; color: var(--brand-deep); background: var(--brand-soft); font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1.4; white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.failed { color: var(--danger); background: var(--danger-soft); }
.status.queued, .status.parsing, .status.running, .status.in_progress { color: var(--warning); background: var(--warning-soft); }
.project-grid { container-type: inline-size; display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1px; border: 1px solid var(--line); background: var(--line); }
.project-grid > .empty { background: var(--paper); }
.project-card { position: relative; min-height: 205px; display: flex; flex-direction: column; padding: 24px 25px 22px; border: 0; color: var(--ink); background: var(--paper); text-align: left; transition: color 160ms var(--ease-toggle), background 160ms var(--ease-toggle); }
.project-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); transform: scaleY(0); transform-origin: top; transition: transform 220ms var(--ease-out); }
.project-card::after { content: "↗"; position: absolute; right: 22px; bottom: 18px; color: var(--muted-light); transform: translate(-5px, 5px); transition: color 160ms var(--ease-toggle), transform 220ms var(--ease-out); }
.project-card:hover { color: var(--brand-deep); background: var(--surface); }
.project-card:hover::before { transform: scaleY(1); }
.project-card:hover::after { color: var(--brand); transform: none; }
.project-card h3 { max-width: 25ch; margin: 24px 0 9px; overflow-wrap: anywhere; color: var(--ink-strong); font-family: var(--font-display); font-size: 1.125rem; font-weight: var(--weight-bold); line-height: var(--leading-snug); letter-spacing: -.01em; }
.project-card p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--muted); font-size: var(--text-sm); line-height: 1.65; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.project-card footer { display: flex; justify-content: space-between; gap: 14px; margin-top: auto; padding: 23px 28px 0 0; color: var(--muted); font-size: var(--text-xs); line-height: 1.45; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.split { display: grid; grid-template-columns: minmax(290px, .72fr) minmax(0, 1.28fr); gap: 24px; align-items: start; }
.stack { display: grid; gap: 20px; }
.form-panel { display: grid; gap: 17px; padding: 24px; }
.form-panel h3, .operation-card h3, .instance-list h3, .knowledge-list h3, .image-card h3 { margin: 0 0 8px; color: var(--ink-strong); font-family: var(--font-display); font-size: 1.125rem; font-weight: var(--weight-bold); line-height: 1.35; letter-spacing: -.01em; }
.form-panel p { margin: 0; font-size: var(--text-sm); line-height: 1.65; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar > * { width: auto; }
.empty { min-height: 180px; display: grid; place-content: center; gap: 7px; padding: 48px 24px; color: var(--muted); text-align: center; }
.empty::before { content: "—"; color: var(--accent); font-family: var(--font-display); font-size: 1.4rem; }
.empty strong { color: var(--ink-strong); font-family: var(--font-display); font-size: 1.0625rem; font-weight: var(--weight-bold); }

/* Project archive import */
.import-disclosure { margin: 40px 0 0; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.import-disclosure summary { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--ink-strong); font-size: var(--text-sm); font-weight: var(--weight-semibold); cursor: pointer; list-style: none; }
.import-disclosure summary small { margin-left: auto; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-regular); }
.import-disclosure summary::-webkit-details-marker { display: none; }
.import-disclosure summary::after { content: "+"; color: var(--brand); font-family: var(--font-display); font-size: 1.4rem; font-weight: 400; transition: transform 180ms var(--ease-out); }
.import-disclosure[open] summary::after { transform: rotate(45deg); }
.import-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; padding: 0 0 24px; }

/* Project workspace */
.project-commandbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.project-switcher { width: min(380px, 100%); min-height: 40px; }
.project-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 26px; align-items: center; padding: 17px 0; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.project-summary p { max-width: 76ch; margin: 7px 0 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.65; }
.project-summary > div:last-child { display: grid; justify-items: end; gap: 7px; }
.project-summary small { color: var(--muted); font-size: var(--text-xs); }
.work-mode-rail { display: grid; grid-template-columns: 168px minmax(0, 1fr); margin-top: 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line-strong); }
.work-mode-heading { display: grid; align-content: center; gap: 5px; padding: 14px 18px 14px 0; border-right: 1px solid var(--line); }
.work-mode-heading strong { color: var(--ink-strong); font-family: var(--font-display); font-size: 1rem; font-weight: var(--weight-bold); }
.work-mode-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.work-mode-option { position: relative; min-height: 94px; display: grid; grid-template-columns: 31px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 11px; align-content: center; border: 0; border-right: 1px solid var(--line); padding: 14px 17px; color: var(--muted); background: transparent; text-align: left; transition: color 150ms var(--ease-toggle), background 150ms var(--ease-toggle); }
.work-mode-option:last-child { border-right: 0; }
.work-mode-option::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; background: var(--accent); transform: scaleY(0); transition: transform 180ms var(--ease-out); }
.work-mode-option > span { grid-row: 1 / span 2; align-self: center; color: var(--muted-light); font-size: var(--text-xs); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.work-mode-option strong { color: inherit; font-family: var(--font-display); font-size: .9375rem; font-weight: var(--weight-bold); line-height: 1.35; }
.work-mode-option small { display: -webkit-box; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-regular); line-height: 1.45; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.work-mode-option:hover { color: var(--ink-strong); background: var(--surface); }
.work-mode-option.active { color: var(--brand-deep); background: color-mix(in oklch, var(--brand-soft) 56%, var(--paper)); }
.work-mode-option.active::before { transform: scaleY(1); }
.workspace-tabs { position: relative; display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)); gap: 0; margin: 24px 0 28px; border-bottom: 1px solid var(--line-strong); overflow-x: auto; }
.workspace-tabs button { position: relative; min-height: 50px; border: 0; padding: 11px 15px; color: var(--muted); background: transparent; font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap; }
.workspace-tabs button::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--brand); transform: scaleX(0); transition: transform 200ms var(--ease-out); }
.workspace-tabs button:hover { color: var(--ink-strong); background: var(--surface); }
.workspace-tabs button.active { color: var(--brand-deep); }
.workspace-tabs button.active::after { transform: scaleX(1); }
.workspace-panel { min-height: 360px; animation: panel-in 360ms var(--ease-out); }
.operation-grid { display: grid; grid-template-columns: 1.15fr .925fr .925fr; gap: 0; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.operation-grid.single-operation { grid-template-columns: minmax(0, 1fr); }
.operation-grid.single-operation .operation-card { max-width: 760px; border-right: 1px solid var(--line); }
.operation-grid.review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.operation-card { position: relative; display: grid; align-content: start; gap: 17px; padding: 26px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; }
.operation-card:last-child { border-right: 0; }
.operation-card:first-child { background: color-mix(in oklch, var(--brand-soft) 42%, var(--paper)); }
.operation-card p { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.65; }
.step-number { position: absolute; right: 20px; top: 20px; color: var(--accent); font-size: var(--text-xs); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.check { display: flex; grid-template-columns: none; align-items: center; gap: 9px; }
.check input { width: auto; min-height: auto; margin: 0; accent-color: var(--brand); }
.inline-checks { display: flex; flex-wrap: wrap; gap: 18px; }
.generation-layout { grid-template-columns: minmax(320px, .66fr) minmax(0, 1.34fr); }
.instance-list { overflow: hidden; }
.instance-list > header { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.instance-list > header h3 { margin: 3px 0 0; }
.button.compact { min-height: 40px; padding-inline: 13px; font-size: var(--text-xs); }
.instance-track { display: grid; }
.instance-option, .artifact-list > button { position: relative; width: 100%; display: grid; gap: 5px; border: 0; border-top: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.instance-option { min-height: 96px; padding: 17px 36px 17px 20px; }
.artifact-list > button { padding: 14px 24px 14px 2px; }
.instance-option::after, .artifact-list > button::after { content: "→"; position: absolute; right: 13px; top: 50%; color: var(--muted-light); transform: translate(-4px, -50%); transition: transform 180ms var(--ease-out), color 180ms var(--ease-toggle); }
.artifact-list > button::after { right: 3px; }
.instance-option::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; background: var(--accent); transform: scaleY(0); transition: transform 180ms var(--ease-out); }
.instance-option:first-child, .artifact-list > button:first-child { border-top: 0; }
.instance-option:hover, .artifact-list > button:hover { color: var(--brand-deep); }
.instance-option:hover::after, .artifact-list > button:hover::after { color: var(--brand); transform: translate(0, -50%); }
.instance-option.active { color: var(--brand-deep); background: var(--brand-soft); }
.instance-option.active::before { transform: scaleY(1); }
.instance-option span, .artifact-list span { overflow-wrap: anywhere; color: var(--muted); font-size: var(--text-xs); line-height: 1.5; }
.instance-option small { color: var(--muted-light); font-size: var(--text-xs); line-height: 1.45; overflow-wrap: anywhere; }
.instance-empty { display: grid; gap: 6px; padding: 26px 20px; color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }
.instance-empty strong { color: var(--ink-strong); font-family: var(--font-display); font-weight: var(--weight-bold); }
.instance-editor-heading, .generation-step-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.instance-key-badge { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); padding: 6px 9px; color: var(--muted); background: var(--surface-2); font-size: var(--text-xs); }
.instance-key-badge code, .instance-binding code { font-family: var(--font-mono); font-variant-ligatures: none; }
.field-note { padding-top: 11px; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--text-xs); line-height: 1.55; }
.generation-step { position: relative; }
.instance-binding { flex: 0 1 250px; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 9px; padding-left: 15px; border-left: 2px solid var(--accent); text-align: right; }
.instance-binding span { grid-column: 1 / -1; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .05em; text-transform: uppercase; }
.instance-binding strong { overflow: hidden; color: var(--ink-strong); font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.instance-binding code { color: var(--accent); font-size: var(--text-xs); }
.generation-scope { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0; border: 1px solid var(--line-strong); padding: 0; background: var(--line); }
.generation-scope legend { width: 100%; margin-bottom: 9px; color: var(--ink); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.generation-scope label { position: relative; min-width: 0; cursor: pointer; }
.generation-scope input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.generation-scope label > span { min-height: 96px; display: grid; align-content: center; gap: 5px; padding: 14px 15px; color: var(--muted); background: var(--surface); transition: color 150ms var(--ease-toggle), background 150ms var(--ease-toggle); }
.generation-scope strong { color: inherit; font-family: var(--font-display); font-size: .9375rem; font-weight: var(--weight-bold); line-height: 1.35; }
.generation-scope small { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: var(--text-xs); line-height: 1.45; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.generation-scope input:checked + span { color: var(--brand-deep); background: var(--brand-soft); box-shadow: inset 0 -2px var(--brand); }
.generation-scope input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
#section-titles-field { transition: opacity 150ms var(--ease-toggle); }
#section-titles-field.is-disabled { opacity: .5; }
.title-reference { display: grid; gap: 9px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--text-xs); line-height: 1.5; }
.title-reference > div { display: flex; flex-wrap: wrap; gap: 6px; }
.title-reference button { min-height: 36px; max-width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 99px; padding: 6px 11px; color: var(--brand-deep); background: transparent; font-size: var(--text-xs); font-weight: var(--weight-medium); text-overflow: ellipsis; white-space: nowrap; }
.title-reference button:hover { border-color: var(--brand); background: var(--brand-soft); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.artifact-editor textarea { min-height: 440px; font-size: .95rem; line-height: 1.8; }
.knowledge-list { max-height: 720px; overflow-y: auto; }
.knowledge-list article { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.knowledge-list article:last-child { border-bottom: 0; }
.knowledge-list article p { max-width: 78ch; color: var(--muted); font-size: var(--text-sm); line-height: 1.72; white-space: pre-wrap; }
.knowledge-list article footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.scope, .dev-tag { display: inline-flex; padding: 4px 7px; border: 1px solid var(--line-strong); border-radius: 99px; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: 1.35; }
.dev-tag { margin-left: 7px; color: var(--brand-deep); background: var(--brand-soft); }
.notice { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.notice::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.notice strong { font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: 1.5; }
.notice.warning { color: var(--warning); }
.notice.success { color: var(--success); }
.image-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.image-card { padding: 12px; }
.image-card { position: relative; content-visibility: auto; contain-intrinsic-size: 360px 420px; }
.image-select { position: absolute; z-index: 2; top: 20px; left: 20px; display: inline-flex; align-items: center; gap: 5px; margin: 0; padding: 5px 8px; border-radius: var(--radius-xs); background: var(--background); color: var(--ink); font-size: var(--text-xs); box-shadow: 0 2px 12px oklch(20% .02 235 / .16); }
.image-preview-trigger { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.image-thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-xs); background: var(--surface-2); display: block; }
.image-placeholder { aspect-ratio: 4 / 3; display: grid; place-items: center; border-radius: var(--radius-xs); color: var(--muted-light); background: var(--surface-2); font-family: var(--font-display); font-size: 1.25rem; letter-spacing: .12em; }
.image-card h3 { margin-top: 15px; font-size: 1rem; line-height: 1.5; }
.image-card small { color: var(--muted); font-size: var(--text-xs); }
.image-prompt-title { display: block; width: 100%; margin: 14px 0 5px; padding: 0; border: 0; color: var(--ink-strong); background: transparent; font-family: var(--font-display); font-size: 1rem; font-weight: var(--weight-bold); line-height: 1.45; text-align: left; cursor: text; }
.image-prompt-title:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.image-project-name { display: block; margin-bottom: 8px; }
.image-archive-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-top: 8px; color: var(--muted); font-size: var(--text-xs); }
.image-archive-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-help { display: block; margin-top: 5px; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-regular); }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.row-actions a, .row-actions button, .text-danger { min-height: 34px; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--brand-deep); padding: 5px 0; font-size: var(--text-xs); font-weight: var(--weight-medium); text-decoration: none; }
.row-actions a:hover, .row-actions button:hover { border-bottom-color: currentColor; }
.row-actions button:disabled { color: var(--muted-light); cursor: not-allowed; }
.row-actions .text-danger, .text-danger { color: var(--danger); }
.export-toolbar { justify-content: flex-end; }
.download-menu { position: relative; }
.download-menu > summary { list-style: none; cursor: pointer; }
.download-menu > summary::-webkit-details-marker { display: none; }
.download-menu-panel { position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; min-width: 240px; display: grid; padding: 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-float); }
.download-menu-panel a { min-height: 36px; display: flex; align-items: center; padding: 6px 11px; border-radius: var(--radius-xs); color: var(--ink); font-size: var(--text-sm); font-weight: var(--weight-medium); text-decoration: none; }
.download-menu-panel a:hover, .download-menu-panel a:focus-visible { color: var(--brand-deep); background: var(--brand-soft); }
.download-section { padding: 6px 0; border-bottom: 1px solid var(--line); }
.download-section:last-child { border-bottom: none; }
.download-section strong { display: block; padding: 4px 11px 8px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.flow-intro { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; margin-bottom: 18px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.flow-intro .step-index { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--brand); border-radius: 50%; color: var(--brand-deep); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.flow-intro h2, .flow-intro p { margin: 0; }
.flow-intro p { margin-top: 3px; color: var(--muted); font-size: var(--text-sm); }
.flow-intro > strong { color: var(--brand-deep); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.auxiliary-tools { margin-top: 28px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.auxiliary-tools > summary { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 4px; color: var(--ink); cursor: pointer; font-weight: var(--weight-semibold); }
.auxiliary-tools > summary::marker { color: var(--brand); }
.auxiliary-tools-body { display: grid; gap: 18px; padding: 0 0 22px; }
.auxiliary-tools-body #classic-analysis-form { border-style: dashed; }
.download-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 28px; margin-bottom: 28px; padding: 26px 28px; color: var(--surface); background: var(--brand-deep); }
.download-panel h2, .download-panel p { margin: 0; }
.download-panel p { max-width: 64ch; margin-top: 6px; color: var(--brand-soft); font-size: var(--text-sm); }
.download-panel .eyebrow { color: var(--accent); }
.download-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.download-panel .button.primary { color: var(--brand-deep); background: var(--surface); }
.download-panel .button.secondary { border-color: color-mix(in oklch, var(--surface) 55%, transparent); color: var(--surface); }
.table-pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0 0; color: var(--muted); font-size: var(--text-sm); }
.table-pagination > div { display: flex; gap: 8px; }
#project-file-table-shell[aria-busy="true"] { opacity: .62; }
.project-card { content-visibility: auto; contain-intrinsic-size: 205px; }
.workspace-panel { contain: layout paint; }
.artifact-viewbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 34px 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line-strong); }
.artifact-viewbar h2 { margin: 4px 0 0; }
.view-switch { display: inline-grid; grid-template-columns: repeat(2, minmax(112px, 1fr)); border: 1px solid var(--line-strong); padding: 3px; background: var(--surface-2); }
.view-switch button { min-height: 40px; border: 0; padding: 8px 15px; color: var(--muted); background: transparent; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.view-switch button.active { color: var(--brand-deep); background: var(--surface); box-shadow: 0 1px 4px oklch(25% .03 235 / .08); }
.reader-shell { display: grid; grid-template-columns: minmax(220px, .34fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.reader-toc { position: sticky; top: 102px; max-height: calc(100dvh - 126px); overflow: auto; overscroll-behavior: contain; border-top: 2px solid var(--brand-deep); }
.reader-toc > div { padding: 18px 4px 14px; border-bottom: 1px solid var(--line); }
.reader-toc h3 { margin: 4px 0; }
.reader-toc > div small { color: var(--muted); font-variant-numeric: tabular-nums; }
.reader-toc nav { display: grid; }
.reader-toc nav button { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 3px 10px; border: 0; border-bottom: 1px solid var(--line); padding: 13px 5px; color: var(--ink); background: transparent; text-align: left; }
.reader-toc nav button > span { grid-row: 1 / 3; color: var(--muted-light); font-family: var(--font-mono); font-size: var(--text-xs); }
.reader-toc nav button strong { overflow: hidden; font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.reader-toc nav button small { color: var(--muted); font-size: var(--text-xs); }
.reader-toc nav button.loaded::after { content: ""; position: absolute; right: 4px; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.reader-toc nav button:hover, .reader-toc nav button:focus-visible { color: var(--brand-deep); background: color-mix(in oklch, var(--brand-soft) 48%, transparent); }
.reader-stage { min-width: 0; }
.reader-progress { position: sticky; z-index: 4; top: 74px; height: 3px; overflow: hidden; background: var(--line); }
.reader-progress span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 100ms linear; }
.reader-document { background: var(--surface); box-shadow: 0 18px 50px oklch(25% .025 240 / .08); }
.reader-article { max-width: 82ch; margin: 0 auto; padding: clamp(42px, 7vw, 82px) clamp(28px, 7vw, 76px); border-bottom: 1px solid var(--line); content-visibility: auto; contain-intrinsic-size: 900px; }
.reader-article:last-child { border-bottom: 0; }
.reader-article > header { position: relative; margin-bottom: 36px; padding-bottom: 20px; border-bottom: 1px solid var(--line-strong); }
.reader-article > header h2 { max-width: 24ch; margin: 8px 0 0; font-size: clamp(1.65rem, 3vw, 2.3rem); line-height: 1.25; }
.reader-edit-link { position: absolute; right: 0; bottom: 20px; min-height: 36px; border: 0; border-bottom: 1px solid var(--line-strong); padding: 5px 0; color: var(--brand-deep); background: transparent; font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.reader-copy { color: var(--ink); font-size: 1.025rem; line-height: 1.95; overflow-wrap: anywhere; }
.reader-copy p { margin: .55em 0; }
.reader-copy h2, .reader-copy h3, .reader-copy h4, .reader-copy h5, .reader-copy h6 { margin: 1.8em 0 .7em; color: var(--ink-strong); line-height: 1.4; }
.reader-copy .reader-list-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 4px; margin: .45em 0; padding-left: 10px; }
.reader-copy .reader-list-item span { color: var(--accent); font-weight: var(--weight-semibold); }
.reader-paragraph-gap { height: .8em; }
.reader-load-more { width: 100%; margin-top: 18px; }
.reader-empty { min-height: 460px; display: grid; place-content: center; justify-items: center; padding: 48px; text-align: center; }
.reader-empty > span { color: var(--accent); font-family: var(--font-mono); font-size: var(--text-xs); }
.reader-empty h2 { margin: 12px 0 8px; }
.reader-empty p { max-width: 46ch; margin: 0; color: var(--muted); line-height: 1.7; }
.generated-history { margin-top: 34px; border-top: 2px solid var(--brand-deep); }
.generated-history-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 2px; border-bottom: 1px solid var(--line); }
.generated-history-head h2, .generated-history-head p { margin: 0; }
.generated-history-head h2 { margin-top: 4px; }
.generated-history-head p { margin-top: 6px; color: var(--muted); font-size: var(--text-sm); }
.generated-history-layout { display: grid; grid-template-columns: minmax(230px, .34fr) minmax(0, 1fr); min-height: 440px; border-bottom: 1px solid var(--line-strong); }
.generated-history-layout nav { max-height: 640px; overflow: auto; border-right: 1px solid var(--line); }
.generated-history-layout nav button { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 3px 9px; border: 0; border-bottom: 1px solid var(--line); padding: 15px 14px; color: var(--ink); background: transparent; text-align: left; }
.generated-history-layout nav button > span { grid-row: 1 / 3; color: var(--muted-light); font-family: var(--font-mono); font-size: var(--text-xs); }
.generated-history-layout nav button strong { overflow: hidden; font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; }
.generated-history-layout nav button small { color: var(--muted); font-size: var(--text-xs); }
.generated-history-layout nav button:hover, .generated-history-layout nav button.active { color: var(--brand-deep); background: var(--brand-soft); }
.generated-history-preview { max-height: 640px; overflow: auto; padding: clamp(28px, 5vw, 58px); background: var(--surface); }
.generated-history-preview > header { margin-bottom: 28px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.generated-history-preview h3 { margin: 7px 0 0; font-size: 1.55rem; }
.generated-history-empty { padding: 34px 2px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.progress { position: relative; width: 100%; min-width: 86px; height: 4px; overflow: hidden; border-radius: 99px; background: var(--line); }
.progress i { display: block; height: 100%; background: var(--brand); }
.progress.indeterminate i { width: 34% !important; animation: task-indeterminate 1.35s var(--ease-out) infinite; }
.task-progress-meta { min-width: 130px; display: flex; align-items: center; gap: 9px; }
.task-progress-meta > span { min-width: 3ch; color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); text-align: right; }
.task-section-head p { max-width: 48ch; margin: 6px 0 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }
.task-head-actions { display: flex; align-items: center; gap: 12px; }
.task-live-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: var(--text-xs); }
.task-live-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-light); }
.task-live-status.active::before { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.task-live-status.offline { color: var(--danger); }
.task-live-status.offline::before { background: var(--danger); }
.task-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 14px; border: 1px solid var(--line); background: var(--surface); }
.task-summary > div { display: flex; align-items: baseline; gap: 9px; padding: 14px 18px; border-right: 1px solid var(--line); }
.task-summary > div:last-child { border-right: 0; }
.task-summary strong { font-family: var(--font-mono); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.task-summary span { color: var(--muted); font-size: var(--text-xs); }
.task-summary .has-error strong { color: var(--danger); }
.task-result { max-width: 310px; overflow-wrap: anywhere; }

@keyframes task-indeterminate {
  from { transform: translateX(-120%); }
  to { transform: translateX(310%); }
}

dialog { width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; border: 0; border-radius: var(--radius-md); padding: 0; background: var(--surface); box-shadow: var(--shadow-float); }
dialog::backdrop { background: oklch(18% .025 235 / .58); backdrop-filter: blur(2px); }
.dialog-form { display: grid; gap: 20px; padding: 32px; border-top: 3px solid var(--brand); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; right: 24px; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 100; max-width: min(420px, calc(100vw - 32px)); padding: 14px 17px; border-left: 3px solid var(--accent); border-radius: var(--radius-sm); color: var(--surface); background: var(--ink-strong); box-shadow: var(--shadow-lift); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
.toast.show { opacity: 1; transform: none; }
.toast.error { border-left-color: oklch(72% .13 28); background: var(--danger); }

@keyframes panel-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes busy-spin { to { transform: rotate(360deg); } }

@container (max-width: 620px) {
  .project-card { border-left-width: 1px; }
}

@media (max-width: 1180px) {
  .operation-grid { grid-template-columns: 1fr 1fr; }
  .operation-card { border-bottom: 1px solid var(--line); }
  .operation-card:first-child { grid-column: 1 / -1; border-right: 0; }
  .operation-card:last-child { border-bottom: 0; }
  .operation-grid.review-grid .operation-card { grid-column: auto; border-bottom: 0; }
  .operation-grid.review-grid .operation-card:first-child { border-right: 1px solid var(--line); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .work-mode-rail { grid-template-columns: 1fr; }
  .work-mode-heading { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-right: 0; }
  .generation-layout { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 218px minmax(0, 1fr); }
  .workbench-hero, .split, .import-grid, .generation-layout { grid-template-columns: 1fr; }
  .workbench-hero { min-height: 0; }
  .workbench-title { max-width: 18ch; }
  .workflow-lane { grid-template-columns: 1fr; }
  .workflow-step { min-height: 92px; border-right: 0; border-bottom: 1px solid var(--line); }
  .workflow-step:last-child { border-bottom: 0; }
  .project-commandbar { align-items: flex-start; flex-direction: column; }
  .export-toolbar { justify-content: flex-start; }
  .operation-grid.review-grid { grid-template-columns: 1fr; }
  .operation-grid.review-grid .operation-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .operation-grid.review-grid .operation-card:last-child { border-bottom: 0; }
  .download-panel { grid-template-columns: 1fr; }
  .download-actions { justify-content: flex-start; }
  .reader-shell, .generated-history-layout { grid-template-columns: 1fr; }
  .reader-toc { position: static; max-height: none; }
  .reader-toc nav { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 280px; overflow: auto; }
  .reader-toc nav button:nth-child(odd) { border-right: 1px solid var(--line); }
  .generated-history-layout nav { max-height: 280px; border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 780px) {
  :root { --text-xs: .875rem; }
  body { padding-bottom: env(safe-area-inset-bottom); }
  body.nav-open { overflow: hidden; }
  input, textarea, select { font-size: 1rem; }
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { min-height: 42vh; padding: 30px 24px 38px; }
  .login-brand::after { right: 12px; font-size: clamp(10rem, 48vw, 17rem); }
  .login-brand-lockup .brand-symbol { width: 30px; height: 34px; flex-basis: 30px; }
  .login-statement { margin-top: 64px; }
  .login-statement h1 { margin-block: 13px 18px; font-size: clamp(2.55rem, 13vw, 4.2rem); }
  .login-panel { width: calc(100% - 48px); margin: 42px 24px 56px; justify-self: stretch; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(286px, calc(100vw - 54px)); height: 100dvh; transform: translateX(-104%); box-shadow: var(--shadow-float); transition: transform 300ms var(--ease-out); }
  body.nav-open .sidebar { transform: none; }
  .sidebar-scrim { position: fixed; z-index: 35; inset: 0; display: block; visibility: hidden; background: oklch(18% .025 235 / .46); opacity: 0; transition: opacity 220ms var(--ease-toggle), visibility 220ms; }
  body.nav-open .sidebar-scrim { visibility: visible; opacity: 1; }
  .topbar { position: sticky; }
  .topbar-inner { min-height: 74px; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; padding: 12px 16px; }
  .icon-button { display: grid; }
  .topbar h1 { max-width: 45vw; font-size: 1.25rem; }
  .topbar .eyebrow { display: none; }
  .top-actions .button { min-width: 44px; padding-inline: 12px; }
  .quick-project-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .page { padding: 24px 18px 64px; }
  .metric-grid, .project-grid { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .project-card { border-left-width: 1px; }
  .project-summary { grid-template-columns: 1fr; }
  .project-summary > div:last-child { justify-items: start; }
  .work-mode-options { grid-template-columns: 1fr; }
  .work-mode-option { min-height: 78px; border-right: 0; border-bottom: 1px solid var(--line); }
  .work-mode-option:last-child { border-bottom: 0; }
  .workspace-tabs { grid-template-columns: repeat(5, minmax(105px, 1fr)); }
  .operation-grid { grid-template-columns: 1fr; }
  .operation-card, .operation-card:first-child { grid-column: auto; border-right: 0; }
  .operation-grid.single-operation .operation-card { max-width: none; border-right: 0; }
  .flow-intro { grid-template-columns: auto minmax(0, 1fr); }
  .flow-intro > strong { grid-column: 2; }
  .table-pagination { align-items: stretch; flex-direction: column; }
  .download-menu-panel { left: 0; right: auto; }
  .generation-scope { grid-template-columns: 1fr; }
  .generation-scope label > span { min-height: 78px; }
  .artifact-viewbar, .generated-history-head { align-items: stretch; flex-direction: column; }
  .view-switch { width: 100%; }
  .reader-toc nav { grid-template-columns: 1fr; }
  .reader-toc nav button:nth-child(odd) { border-right: 0; }
  .reader-article { padding: 38px 22px 48px; }
  .reader-article > header { padding-right: 0; }
  .reader-edit-link { position: static; margin-top: 14px; }
  .section-head { margin-top: 38px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  .toast { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
}

@media (max-width: 460px) {
  .login-brand { min-height: 38vh; }
  .login-statement { margin-top: 44px; }
  .workbench-title { font-size: 2.45rem; }
  .workflow-step { padding-inline: 18px; }
  .project-commandbar .toolbar, .project-commandbar .toolbar > * { width: 100%; }
  .export-toolbar .button { width: auto; flex: 1 1 42%; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .instance-list > header, .instance-editor-heading, .generation-step-head { align-items: stretch; flex-direction: column; }
  .instance-list > header .button { width: 100%; }
  .instance-binding { flex-basis: auto; padding-left: 12px; text-align: left; }
  .instance-binding strong { overflow: visible; text-overflow: clip; white-space: normal; }
}

@media (pointer: coarse) {
  .nav-item, .row-actions a, .row-actions button, .button.compact { min-height: 44px; }
}

@media (hover: hover) {
  .project-card:hover { background: var(--surface); }
}

@media (forced-colors: active) {
  .status, .button, .panel, input, textarea, select, .project-card, .work-mode-option, .instance-option { border: 1px solid CanvasText; }
  .nav-item.active::after, .button.primary::after, .project-card::before { background: Highlight; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition-duration: .01ms !important; }
}


/* Action panel (borrowed from local Streamlit UI) */
.action-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.action-kicker { color: var(--brand); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .05em; text-transform: uppercase; }
.action-panel h2 { margin: 0.25rem 0 0; font-size: var(--text-lg); }
.action-panel p { margin: 0.25rem 0 0; color: var(--muted); font-size: var(--text-sm); }
.action-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.action-pill { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; }
.action-pill.ready { background: var(--success-soft); color: var(--success); }
.action-pill.pending { background: var(--warning-soft); color: var(--warning); }

/* Structured analysis cards */
.structured-analysis-shell { margin-block-end: 1.5rem; }
.structured-analysis { display: grid; gap: 1.25rem; }
.sa-head { margin-bottom: 0; }
.sa-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.sa-card { position: relative; display: grid; grid-template-columns: 4px 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.sa-card-bar { background: var(--brand); }
.sa-card:nth-child(2) .sa-card-bar { background: var(--accent); }
.sa-card:nth-child(3) .sa-card-bar { background: var(--success); }
.sa-card:nth-child(4) .sa-card-bar { background: var(--warning); }
.sa-card:nth-child(5) .sa-card-bar { background: oklch(55% .12 280); }
.sa-card:nth-child(6) .sa-card-bar { background: oklch(55% .11 160); }
.sa-card:nth-child(7) .sa-card-bar { background: oklch(55% .13 30); }
.sa-card-body { padding: clamp(1rem, 2vw, 1.5rem); min-width: 0; }
.sa-card h3 { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.625rem; color: var(--ink-strong); font-size: 1rem; }
.sa-number { display: inline-grid; place-items: center; min-width: 1.75rem; height: 1.75rem; border-radius: var(--radius-xs); background: var(--surface-2); color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.sa-body { font-size: 0.9375rem; line-height: 1.68; color: var(--ink); }
.sa-body h3, .sa-body h4 { font-size: 0.9375rem; margin: 0.75rem 0 0.25rem; color: var(--ink-strong); }
.sa-body p { margin: 0.35rem 0; }
.sa-body .reader-list-item { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 4px; margin: 0.25rem 0; }
.sa-body .reader-list-item span { color: var(--accent); font-weight: var(--weight-semibold); }
.sa-card.is-collapsed .sa-body { max-height: 360px; overflow: hidden; mask-image: linear-gradient(to bottom, black 78%, transparent 100%); }
.sa-card .sa-expand { margin-top: 0.5rem; font-size: 0.8125rem; }
.sa-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; margin: 0.75rem 0; }
.sa-table th, .sa-table td { border: 1px solid var(--line); padding: 0.4rem 0.5rem; text-align: left; vertical-align: top; }
.sa-table th { background: var(--surface-2); font-weight: var(--weight-semibold); }
.sa-table tr:nth-child(even) td { background: var(--paper); }
.sa-table td { word-break: break-word; }



/* Artifact grouping */
.artifact-group { margin-bottom: 0.75rem; }
.artifact-group summary { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; padding: 0.25rem 0; }
.artifact-group summary .muted { font-size: 0.75rem; color: var(--muted); }
.artifact-group-actions { margin-left: auto; display: flex; gap: 0.5rem; font-size: 0.75rem; }
.artifact-group-actions a { color: var(--accent); text-decoration: none; }
.artifact-group-actions a:hover { text-decoration: underline; }
.artifact-group > button { margin-left: 0.75rem; }



/* Outline selector in generation panel */
.outline-selector { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.875rem; background: var(--surface); }
.outline-selector-toolbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; padding-bottom: 0.625rem; border-bottom: 1px solid var(--line); }
.outline-selector-hint { margin-left: auto; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.outline-group { margin-bottom: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--paper); overflow: hidden; }
.outline-group:last-child { margin-bottom: 0; }
.outline-group-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0.7rem; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.outline-group-header strong { color: var(--ink-strong); font-size: 0.9375rem; font-weight: var(--weight-bold); }
.outline-group-meta { display: flex; align-items: center; gap: 0.4rem; }
.outline-group-meta .button.text { min-height: auto; padding: 0.15rem 0.35rem; font-size: 0.75rem; color: var(--brand-deep); }
.outline-group-meta .button.text:hover { color: var(--accent); }
.outline-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; padding: 0.65rem; }
.outline-chip { position: relative; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.65rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 0.85rem; line-height: 1.35; transition: border-color 150ms var(--ease-toggle), background 150ms var(--ease-toggle), color 150ms var(--ease-toggle); }
.outline-chip:hover { border-color: var(--brand); background: var(--brand-soft); }
.outline-chip input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.outline-chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--ink-strong); }
.outline-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.outline-chip span:first-of-type { font-weight: var(--weight-medium); }
.outline-chip .word-count-badge { color: var(--muted); font-size: 0.75rem; font-weight: var(--weight-semibold); }
.outline-chip.chapter-chip { border-radius: var(--radius-xs); font-weight: var(--weight-semibold); }
.word-count-badge { display: inline-flex; align-items: center; padding: 0.15rem 0.4rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 0.75rem; font-weight: var(--weight-semibold); }
.outline-summary { padding: 0; border: 0; background: transparent; }
.outline-summary-card { display: grid; gap: 0.35rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--brand-soft); }
.outline-summary-card strong { color: var(--brand-deep); font-size: 1rem; }
.outline-summary-card span { color: var(--muted); font-size: 0.875rem; line-height: 1.55; }



/* Outline editor */
#outline-editor summary { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
#outline-editor summary h3 { margin: 0; font-size: 1rem; }
.inline-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.inline-actions .button { font-size: 0.875rem; padding: 0.4rem 0.7rem; }



/* Download menu refinements */
.download-menu-panel { min-width: 280px; max-width: min(420px, calc(100vw - 32px)); }
.download-menu-panel a { min-height: 34px; }
.download-section strong { letter-spacing: .04em; }
.template-list-shell { display: grid; gap: 2px; padding: 2px 0; }
.template-list-shell .muted { padding: 6px 11px; font-size: var(--text-xs); line-height: 1.5; }
.template-list-shell code { font-family: var(--font-mono); font-size: 0.75rem; background: var(--surface-2); padding: 0.1rem 0.3rem; border-radius: var(--radius-xs); }
.template-link.disabled { pointer-events: none; opacity: .55; color: var(--muted); cursor: not-allowed; }

@media (max-width: 780px) {
  .task-section-head { align-items: stretch; }
  .task-head-actions { justify-content: space-between; }
  .task-summary > div { align-items: center; flex-direction: column; gap: 2px; padding: 12px 6px; text-align: center; }
  .task-table { padding: 0; border: 0; background: transparent; overflow: visible; }
  .task-table table, .task-table tbody { display: grid; gap: 12px; }
  .task-table thead { display: none; }
  .task-table tr { display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
  .task-table td { display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: start; padding: 0; border: 0; text-align: left; }
  .task-table td::before { content: attr(data-label); color: var(--muted); font-size: var(--text-xs); }
  .task-table td:first-child { grid-column: 1; display: block; }
  .task-table td:nth-child(2) { grid-column: 2; display: block; }
  .task-table td:nth-child(n + 3) { grid-column: 1 / -1; }
  .task-table td:last-child:empty { display: none; }
  .task-progress-meta { width: 100%; min-width: 0; }
  .task-result { max-width: none; }
}


/* Outline editor clarity */
#outline-editor-help { font-size: var(--text-xs); color: var(--muted); line-height: 1.55; margin: 0; }
.outline-visual-editor { display: grid; gap: 16px; }
.outline-edit-chapter { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.outline-edit-chapter > header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.outline-order { align-self: center; color: var(--brand); font: 700 1.25rem/1 var(--font-mono); }
.outline-edit-chapter label { margin: 0; }
.outline-edit-sections { display: grid; gap: 8px; }
.outline-edit-section { display: grid; grid-template-columns: 42px minmax(180px, 1.2fr) 120px minmax(220px, 2fr) auto; align-items: end; gap: 10px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-xs); }
.outline-section-order { align-self: center; color: var(--muted); font: 600 var(--text-xs)/1 var(--font-mono); }
.outline-move-actions { display: flex; align-items: center; gap: 4px; }
.outline-json-advanced { padding-top: 4px; border-top: 1px solid var(--line); }
.outline-json-advanced > summary { cursor: pointer; color: var(--muted); font-size: var(--text-sm); }
.button.danger { color: var(--danger); }

/* Export workbench — editorial production flow, not a settings popover */
.export-workbench { --paper: oklch(98% .012 84); --ink: oklch(24% .025 235); display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: start; }
.export-stage-rail { position: sticky; top: 96px; display: grid; gap: 2px; padding-top: 30px; }
.export-stage-rail > .eyebrow { margin-bottom: 14px; }
.export-stage-marker { display: grid; grid-template-columns: 28px 1fr; gap: 9px; align-items: baseline; padding: 10px 0; color: var(--muted); border-bottom: 1px solid var(--line); }
.export-stage-rail b { color: var(--brand); font-family: var(--font-mono); font-size: var(--text-xs); }
.export-stage-content { min-width: 0; }
.export-workbench-head { display: flex; justify-content: space-between; align-items: end; gap: 32px; padding: clamp(28px, 5vw, 64px) 0; border-bottom: 1px solid var(--line-strong); }
.export-workbench-head h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.045em; }
.export-workbench-head p { margin: 0; color: var(--muted); }
.export-workbench-head label { width: min(300px, 100%); margin: 0; }
.export-stage { scroll-margin-top: 92px; padding: clamp(46px, 7vw, 92px) 0; border-bottom: 1px solid var(--line-strong); }
.export-stage-heading { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 18px; margin-bottom: 28px; }
.export-stage-heading > span { color: var(--brand); font: 700 1.35rem/1 var(--font-mono); }
.export-stage-heading h3 { margin: -5px 0 6px; font-size: clamp(1.45rem, 2.5vw, 2.2rem); letter-spacing: -.035em; }
.export-stage-heading p { margin: 0; color: var(--muted); }
.document-preview { width: min(820px, 100%); min-height: 520px; max-height: 760px; margin-inline: auto; overflow: auto; padding: clamp(34px, 7vw, 76px); background: var(--paper); color: var(--ink); border: 1px solid oklch(84% .02 84); box-shadow: 0 24px 70px oklch(25% .025 235 / .12); }
.document-preview h3 { margin: 1.6em 0 .8em; font-size: 1.65rem; }
.document-preview h4 { margin: 1.45em 0 .7em; font-size: 1.28rem; }
.document-preview h5, .document-preview h6 { margin: 1.2em 0 .5em; font-size: 1.05rem; }
.document-preview p { margin: .65em 0; font-family: SimSun, serif; font-size: 1rem; line-height: 1.75; text-align: justify; }
.document-preview code { display: block; overflow: hidden; padding: 5px 8px; color: inherit; background: oklch(94% .014 84); font: .86rem/1.5 var(--font-sans); white-space: nowrap; text-overflow: ellipsis; }
.document-preview .preview-space { display: block; height: .45rem; }
.document-preview[data-preset="gongwen"] p { font-size: 1.06rem; line-height: 1.85; text-indent: 2em; }
.document-preview[data-preset="compact"] { padding: clamp(26px, 5vw, 54px); }
.document-preview[data-preset="compact"] p { font-size: .93rem; line-height: 1.52; }
.document-preview[data-preset="local_classic"] { padding: clamp(24px, 4vw, 42px); }
.document-preview[data-preset="local_classic"] p { font-size: .86rem; line-height: 1.35; text-indent: 2em; }
.document-preview[data-preset="review"] p { font-size: .96rem; line-height: 1.65; text-indent: 2em; }
.document-preview[data-heading-style="clean"] h3, .document-preview[data-heading-style="clean"] h4 { color: oklch(40% .07 170); }
.document-preview[data-heading-style="government"] h3 { text-align: center; }
.document-preview.formatted p {
  margin-block: var(--preview-paragraph-before, .65em) var(--preview-paragraph-after, .65em);
  font-size: var(--preview-font-size, 1rem);
  line-height: var(--preview-line-height, 1.25);
  letter-spacing: var(--preview-letter-spacing, 0);
  text-indent: var(--preview-indent, 2em);
}
.preview-loading, .export-preview-empty { min-height: 360px; display: grid; place-content: center; gap: 8px; text-align: center; color: var(--muted); }
.export-preview-empty strong { color: var(--ink); font-size: 1.1rem; }
.export-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; max-width: 820px; }
.export-settings-grid label { margin: 0; }
.export-setting-checks { display: flex; gap: 24px; margin-top: 22px; }
.export-advanced-settings { max-width: 820px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.export-advanced-settings > summary { width: fit-content; cursor: pointer; color: var(--muted); font-weight: 650; }
.export-detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.export-detail-grid label { margin: 0; }
.export-default-format { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; max-width: 820px; padding: 16px 0; border-block: 1px solid var(--line); }
.export-default-format span { color: var(--muted); }
.export-default-format .button { min-height: 36px; padding: 7px 12px; }
.compact-stage { padding-top: 24px; }
.compact-heading { margin-bottom: 18px; }
.export-ai-control { max-width: 820px; display: grid; gap: 14px; }
.export-ai-control textarea { min-height: 120px; }
.export-ai-control .button { justify-self: start; }
.export-prompt-preview { padding: 16px 0; border-block: 1px solid var(--line); }
.export-prompt-preview p { margin: 7px 0 0; color: var(--muted); line-height: 1.65; }
#export-ai-preview { margin-top: 32px; }
.export-version-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 820px; border: 1px solid var(--line); }
.export-version-choice > label { display: flex; gap: 12px; align-items: start; margin: 0; padding: 20px; cursor: pointer; }
.export-version-choice > label + label { border-left: 1px solid var(--line); }
.export-version-choice span { display: grid; gap: 3px; }
.export-version-choice small { color: var(--muted); }
.export-file-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.export-final { padding-bottom: 120px; }

@media (max-width: 900px) {
  .export-workbench { grid-template-columns: 1fr; }
  .export-stage-rail { position: sticky; top: 64px; z-index: 3; display: flex; overflow-x: auto; padding: 10px 0; background: var(--background); border-bottom: 1px solid var(--line); }
  .export-stage-rail > .eyebrow { display: none; }
  .export-stage-marker { flex: 0 0 auto; display: flex; padding: 8px 10px; border: 0; }
  .export-workbench-head { align-items: stretch; flex-direction: column; }
  .export-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .export-settings-grid, .export-version-choice { grid-template-columns: 1fr; }
  .export-version-choice > label + label { border-left: 0; border-top: 1px solid var(--line); }
  .document-preview { min-height: 440px; padding: 28px 22px; }
  .export-stage-heading { grid-template-columns: 38px minmax(0, 1fr); }
  .export-detail-grid { grid-template-columns: 1fr; }
  .export-default-format { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .outline-edit-chapter { padding: 14px; }
  .outline-edit-chapter > header { grid-template-columns: auto minmax(0, 1fr); }
  .outline-move-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .outline-edit-section { grid-template-columns: 34px minmax(0, 1fr); }
  .outline-edit-section > label, .outline-edit-section > button { grid-column: 2; }
  .outline-section-order { grid-row: 1 / span 4; align-self: start; padding-top: 28px; }
}
.outline-word-preview { display: flex; flex-wrap: wrap; gap: 0.75rem; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface-2); font-size: var(--text-xs); color: var(--muted); }
.outline-word-preview strong { color: var(--ink-strong); font-variant-numeric: tabular-nums; }


/* Outline editor: insert position + AI add */
.outline-add-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 0.75rem; align-items: start; }
.outline-add-row textarea { min-height: 60px; }

/* Per-section regenerate box */
.regenerate-box { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: 0.5rem; }
.regenerate-box textarea { min-height: 60px; }
.regenerate-box .button { justify-self: start; }

@media (max-width: 780px) {
  .outline-add-row { grid-template-columns: 1fr; }
}


/* Image card fallback + footer */
.image-missing { display: grid; place-items: center; color: var(--muted); font-size: 0.85rem; text-align: center; padding: 0.5rem; }
.image-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.25rem; }
.image-card-footer > span { display: inline-flex; align-items: center; gap: 12px; }
.image-download { color: var(--brand); font-size: var(--text-xs); font-weight: var(--weight-semibold); text-decoration: none; }
.image-download:hover { text-decoration: underline; }
.image-card-footer .text-danger { min-height: auto; padding: 0.15rem 0; font-size: 0.75rem; }
.image-viewer { width: min(1120px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line-strong); background: var(--background); color: var(--ink); }
.image-viewer::backdrop { background: oklch(16% .02 235 / .78); }
.image-viewer-bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: flex-end; gap: 8px; padding: 12px; background: var(--background); border-bottom: 1px solid var(--line); }
.image-viewer > img { display: block; max-width: 100%; max-height: calc(100dvh - 190px); margin: 0 auto; object-fit: contain; }
.image-viewer-copy { padding: 18px clamp(18px, 4vw, 42px) 24px; border-top: 1px solid var(--line); }
.image-viewer-copy p { margin: 0 0 8px; line-height: 1.6; }
.image-viewer-copy small { color: var(--muted); }
.image-library-tools { display: grid; gap: 14px; margin-bottom: 20px; padding-block: 16px; border-block: 1px solid var(--line); }
.image-stats { display: flex; flex-wrap: wrap; gap: 12px 28px; }
.image-stats span { color: var(--muted); font-size: var(--text-sm); }
.image-stats strong { margin-right: 5px; color: var(--ink-strong); font-family: var(--font-display); font-size: 1.15rem; }
.image-filters { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) auto auto; gap: 12px; align-items: end; }
.image-filters label { margin: 0; }
.image-pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 22px 0 6px; color: var(--muted); font-size: var(--text-sm); }

@media (max-width: 700px) {
  .image-filters { grid-template-columns: 1fr; }
  .image-filters .button { width: 100%; }
  .image-card-footer a, .image-card-footer .text-danger { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
}


/* Template manager in download menu */
.template-row { display: grid; gap: 2px; padding: 6px 11px; border-bottom: 1px solid var(--line); }
.template-row:last-of-type { border-bottom: 0; }
.template-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--ink-strong); }
.template-name small { font-weight: var(--weight-regular); }
.template-links { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.template-links a { min-height: auto; padding: 2px 0; font-size: var(--text-xs); }
.template-links .text-danger { min-height: auto; padding: 2px 0; font-size: var(--text-xs); }
.template-upload { padding: 8px 11px 4px; border-top: 1px dashed var(--line); margin-top: 4px; }


/* Export settings panel in download menu */
.export-settings { display: grid; gap: 8px; }
.export-settings label { display: grid; gap: 4px; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--muted); }
.export-settings select { min-height: 36px; padding: 6px 9px; font-size: var(--text-xs); }
.export-setting-checks { display: flex; gap: 16px; flex-wrap: wrap; }
.export-setting-checks .check { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--ink); }
.export-setting-checks .check input { width: auto; min-height: auto; }
.template-links button { min-height: auto; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--brand-deep); padding: 2px 0; font-size: var(--text-xs); font-weight: var(--weight-medium); cursor: pointer; }
.template-links button:hover { border-bottom-color: currentColor; }
