
/*
 * Serve & Charge design tokens — Mica: tinted, desaturated backdrop, translucent layered
 * surfaces with blur, hairline borders with a lighter top edge, ~8px radii, depth from
 * layering rather than heavy shadows. Components use these variables, never raw hex.
 */
:root {
  color-scheme: light;
  --sac-accent: #1952ad;
  --sac-accent-strong: #123f86;
  --sac-accent-soft: rgb(25 82 173 / 0.1);
  --sac-text-on-accent: #ffffff;

  --sac-backdrop: radial-gradient(1200px 700px at 10% -10%, #dfe7f5 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 10%, #e9e4f2 0%, transparent 55%), #eef1f5;
  --sac-surface: rgb(255 255 255 / 0.72);
  --sac-surface-solid: #ffffff;
  --sac-surface-2: rgb(248 250 252 / 0.85);
  --sac-surface-hover: rgb(15 23 42 / 0.045);
  --sac-border: rgb(15 23 42 / 0.1);
  --sac-border-top: rgb(255 255 255 / 0.9);
  --sac-border-strong: rgb(15 23 42 / 0.2);
  /* Form fields need 3:1 against the surface (WCAG 1.4.11); decorative lines keep border-strong. */
  --sac-input-border: rgb(15 23 42 / 0.48);

  --sac-text: #1f2933;
  --sac-text-muted: #5b6776;
  --sac-text-faint: #6b7584;

  --sac-ok: #1f7a4d;
  --sac-warn: #965300;
  --sac-danger: #b42318;
  --sac-ok-soft: rgb(31 122 77 / 0.12);
  --sac-warn-soft: rgb(150 83 0 / 0.12);
  --sac-danger-soft: rgb(180 35 24 / 0.1);

  --sac-shadow: 0 1px 2px rgb(15 23 42 / 0.05), 0 8px 24px rgb(15 23 42 / 0.06);
  --sac-radius: 8px;
  --sac-radius-sm: 5px;
  --sac-blur: saturate(140%) blur(18px);
  --sac-font: "Inter", "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --sac-font-mono: ui-monospace, "JetBrains Mono", SFMono-Regular, monospace;

  /* Chart series (categorical, fixed order; validated with the dataviz palette checker). */
  --sac-series-1: #1952ad;
  --sac-series-2: #eb6834;
  --sac-series-3: #1baf7a;
  --sac-series-4: #eda100;
  --sac-chart-grid: rgb(15 23 42 / 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    /* Lighter accent for text on dark surfaces; filled accent areas carry dark text (white would be 2.5:1). */
    --sac-accent: #7aa5e8;
    --sac-accent-strong: #9dbdf0;
    --sac-accent-soft: rgb(122 165 232 / 0.16);
    --sac-text-on-accent: #0b1220;
    --sac-backdrop: radial-gradient(1200px 700px at 10% -10%, #1d2738 0%, transparent 60%),
      radial-gradient(900px 600px at 110% 10%, #261f33 0%, transparent 55%), #12161d;
    --sac-surface: rgb(32 37 46 / 0.72);
    --sac-surface-solid: #1c2129;
    --sac-surface-2: rgb(40 46 56 / 0.8);
    --sac-surface-hover: rgb(255 255 255 / 0.06);
    --sac-border: rgb(255 255 255 / 0.09);
    --sac-border-top: rgb(255 255 255 / 0.14);
    --sac-border-strong: rgb(255 255 255 / 0.2);
  --sac-input-border: rgb(255 255 255 / 0.38);
    --sac-input-border: rgb(255 255 255 / 0.38);
    --sac-text: #e6e9ee;
    --sac-text-muted: #a3adbb;
    --sac-text-faint: #8a94a2;
    --sac-ok: #4cc38a;
    --sac-warn: #f0a44b;
    --sac-danger: #f97066;
    --sac-shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
    --sac-series-1: #5b8fe0;
    --sac-series-2: #d95926;
    --sac-series-3: #199e70;
    --sac-series-4: #c98500;
    --sac-chart-grid: rgb(255 255 255 / 0.08);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  /* Lighter accent for text on dark surfaces; filled accent areas carry dark text (white would be 2.5:1). */
  --sac-accent: #7aa5e8;
  --sac-accent-strong: #9dbdf0;
  --sac-accent-soft: rgb(122 165 232 / 0.16);
  --sac-text-on-accent: #0b1220;
  --sac-backdrop: radial-gradient(1200px 700px at 10% -10%, #1d2738 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 10%, #261f33 0%, transparent 55%), #12161d;
  --sac-surface: rgb(32 37 46 / 0.72);
  --sac-surface-solid: #1c2129;
  --sac-surface-2: rgb(40 46 56 / 0.8);
  --sac-surface-hover: rgb(255 255 255 / 0.06);
  --sac-border: rgb(255 255 255 / 0.09);
  --sac-border-top: rgb(255 255 255 / 0.14);
  --sac-border-strong: rgb(255 255 255 / 0.2);
  --sac-input-border: rgb(255 255 255 / 0.38);
  --sac-text: #e6e9ee;
  --sac-text-muted: #a3adbb;
  --sac-text-faint: #8a94a2;
  --sac-ok: #4cc38a;
  --sac-warn: #f0a44b;
  --sac-danger: #f97066;
  --sac-shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
  --sac-series-1: #5b8fe0;
  --sac-series-2: #d95926;
  --sac-series-3: #199e70;
  --sac-series-4: #c98500;
  --sac-chart-grid: rgb(255 255 255 / 0.08);
}

html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--sac-backdrop);
  background-attachment: fixed;
  color: var(--sac-text);
  font-family: var(--sac-font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Layered translucent surface — the basic Mica card. */
.sac-card {
  background: var(--sac-surface);
  backdrop-filter: var(--sac-blur);
  -webkit-backdrop-filter: var(--sac-blur);
  border: 1px solid var(--sac-border);
  border-top-color: var(--sac-border-top);
  border-radius: var(--sac-radius);
  box-shadow: var(--sac-shadow);
}
/* Secondary text: hints, captions, meta lines. */
.sac-muted {
  color: var(--sac-text-muted);
}
/* Numbers in tables and totals: tabular figures, right-aligned. */
.sac-num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Button; add .primary for the one main action of a view, .danger for destructive ones. */
.sac-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--sac-radius-sm);
  border: 1px solid var(--sac-border-strong);
  background: var(--sac-surface-solid);
  color: var(--sac-text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.sac-btn:hover:not(:disabled) {
  background: var(--sac-surface-hover);
}
.sac-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.sac-btn.primary {
  background: var(--sac-accent);
  border-color: var(--sac-accent);
  color: var(--sac-text-on-accent);
}
.sac-btn.primary:hover:not(:disabled) {
  background: var(--sac-accent-strong);
}
.sac-btn.danger {
  color: var(--sac-danger);
}
.sac-btn:focus-visible,
.sac-input:focus-visible {
  outline: 2px solid var(--sac-accent);
  outline-offset: 1px;
}

/* Text field, select and textarea (3:1 border contrast). */
.sac-input {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--sac-radius-sm);
  border: 1px solid var(--sac-input-border);
  background: var(--sac-surface-solid);
  color: var(--sac-text);
  font: inherit;
  min-width: 0;
}
textarea.sac-input {
  height: auto;
  padding: 8px 10px;
}
/* Label above a form field. */
.sac-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--sac-text-muted);
  margin-bottom: 4px;
}
/* Inline validation message under a field (ADR-002: no dialogs for this). */
.sac-field-error {
  color: var(--sac-danger);
  font-size: 12px;
  margin-top: 4px;
}

/* Small status chip; .ok, .warn, .danger, data-mode for the organisation mode. */
.sac-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--sac-surface-2);
  border: 1px solid var(--sac-border);
}
.sac-badge.ok {
  color: var(--sac-ok);
  background: var(--sac-ok-soft);
  border-color: transparent;
}
.sac-badge.warn {
  color: var(--sac-warn);
  background: var(--sac-warn-soft);
  border-color: transparent;
}
/* Organisation mode (ILV stays neutral). */
.sac-badge[data-mode='Municipal'] {
  color: var(--sac-ok);
  background: var(--sac-ok-soft);
  border-color: transparent;
}
.sac-badge[data-mode='ManagedServices'] {
  color: var(--sac-accent);
  background: var(--sac-accent-soft);
  border-color: transparent;
}
.sac-badge.danger {
  color: var(--sac-danger);
  background: var(--sac-danger-soft);
  border-color: transparent;
}

/* Page title (shared/page-header.ts sets it). */
h1.sac-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
/* Section title within a page or card. */
h2.sac-subtitle {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

/* AG Grid picks its colours from the tokens. */
.ag-theme-sac {
  --ag-background-color: transparent;
  --ag-foreground-color: var(--sac-text);
  --ag-header-background-color: var(--sac-surface-2);
  --ag-border-color: var(--sac-border);
  --ag-row-hover-color: var(--sac-surface-hover);
  --ag-selected-row-background-color: var(--sac-accent-soft);
  --ag-font-family: var(--sac-font);
  --ag-font-size: 13px;
}

/*
 * Print (reports, analyses, capture sheets): light colours whatever the theme, no translucent
 * surfaces, no tool bars. Grids print their own full-width tables (data-grid.ts), the page margins
 * carry organisation, period, title, date and "Seite x von y" (core/print.ts).
 */
@media print {
  :root:root:root {
    color-scheme: light;
    --sac-backdrop: #fff;
    --sac-surface: #fff;
    --sac-surface-solid: #fff;
    --sac-surface-2: #f4f5f7;
    --sac-surface-hover: transparent;
    --sac-border: #d0d4da;
    --sac-border-top: #d0d4da;
    --sac-border-strong: #8a929c;
    --sac-text: #000;
    --sac-text-muted: #444;
    --sac-text-faint: #666;
    --sac-accent: #1952ad;
    --sac-ok: #1f7a4d;
    --sac-warn: #8a4d00;
    --sac-danger: #b42318;
    --sac-shadow: none;
    --sac-blur: none;
    --sac-series-1: #1952ad;
    --sac-series-2: #eb6834;
    --sac-series-3: #1baf7a;
    --sac-series-4: #eda100;
    --sac-chart-grid: rgb(15 23 42 / 0.12);
  }
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  body { font-size: 10pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sac-no-print, sac-page-header .actions, sac-page-header .help-btn, sac-tabs, ngx-sonner-toaster, sac-excel-menu { display: none !important; }
  .sac-card { box-shadow: none !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; border: 0 !important; background: transparent !important; padding-left: 0 !important; padding-right: 0 !important; }
  .sac-title { font-size: 15pt; }
  h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
  /* Charts scale down to the page width (keeping their proportions) and never split across pages. */
  sac-chart { display: block; break-inside: avoid; page-break-inside: avoid; }
  sac-chart [echarts], sac-chart [echarts] > div { width: 100% !important; height: auto !important; }
  sac-chart canvas { position: static !important; width: auto !important; height: auto !important; max-width: 100% !important; max-height: 120mm !important; }
}

/* The Werkstatt in the design system of Serve & Charge (docs/policies/design-system.md): the build puts
   web/src/styles.css (tokens, .sac-* classes) in front of this file, which adds only the Werkstatt's own
   layout, built from the tokens. No colour values here. */
* { box-sizing: border-box; }
/* Additions to the design system's classes, for the Werkstatt's own layout. */
.sac-card { padding: 16px; min-width: 0; }
a.sac-btn { text-decoration: none; }
.sac-btn.ghost { border-color: transparent; background: transparent; }
.sac-btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.advanced { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; font-size: 12px; color: var(--sac-text-muted); white-space: nowrap; cursor: pointer; }
.detail { white-space: pre-wrap; font-family: var(--sac-font-mono); font-size: 11px; color: var(--sac-text-muted); background: var(--sac-surface-hover); border-radius: var(--sac-radius-sm); padding: 6px 8px; margin: 8px 0 0; max-height: 160px; overflow: auto; }
[hidden] { display: none !important; }
.plain-page { max-width: 36rem; margin: 15vh auto; padding: 0 16px; }
.plain-page h1 { font-size: 20px; }

html, body { min-height: 100%; }
body { line-height: 1.5; }
a { color: var(--sac-accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 8px; }
.faint { color: var(--sac-text-faint); font-size: 12px; }
.mono { font-family: var(--sac-font-mono); font-size: 12px; }


.sac-btn:focus-visible, .sac-input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--sac-accent); outline-offset: 1px; }
.sac-btn.ghost { border-color: transparent; background: transparent; }
.sac-btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.sac-btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.sac-input { width: 100%; }
textarea.sac-input { resize: vertical; min-height: 44px; }
label { display: block; font-weight: 550; margin: 12px 0 4px; }
.hint { color: var(--sac-text-muted); font-size: 13px; margin-top: 4px; }
.choice { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 0; cursor: pointer; }
.choice input { margin-top: 4px; flex: none; }


/* Shell */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: var(--sac-surface);
  backdrop-filter: var(--sac-blur);
  -webkit-backdrop-filter: var(--sac-blur);
  border-bottom: 1px solid var(--sac-border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; text-decoration: none; color: var(--sac-text); white-space: nowrap; }
.brand .logo { width: 26px; height: 26px; border-radius: 6px; background: var(--sac-accent); display: grid; place-items: center; }
.brand .logo svg { stroke: var(--sac-text-on-accent); }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.nav a {
  padding: 6px 12px; border-radius: var(--sac-radius-sm);
  color: var(--sac-text-muted); text-decoration: none; font-weight: 550; white-space: nowrap;
}
.nav a:hover { background: var(--sac-surface-hover); color: var(--sac-text); }
.nav a.active { background: var(--sac-accent-soft); color: var(--sac-accent); }
.who { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.usage { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--sac-text-muted); white-space: nowrap; }
.usage strong { color: var(--sac-text); font-weight: 650; }
.usage .win { display: inline-flex; align-items: center; gap: 6px; }
.usage .meter { width: 48px; height: 6px; border-radius: 3px; background: var(--sac-surface-hover); overflow: hidden; display: inline-block; }
.usage .meter span { display: block; height: 100%; border-radius: 3px; }
.usage .meter .ok { background: var(--sac-ok); }
.usage .meter .warn { background: var(--sac-warn); }
.usage .meter .danger { background: var(--sac-danger); }
main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* Request list */
.requests { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.request { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; }
.request:hover { border-color: var(--sac-border-strong); }
.request .title { font-weight: 650; font-size: 15px; overflow-wrap: anywhere; }
.request.cta { border-color: var(--sac-accent); }
.main-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.empty { text-align: center; padding: 48px 16px; }

/* Phase stepper */
.phases { display: flex; gap: 4px 14px; align-items: center; flex-wrap: wrap; }
.phase { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sac-text-faint); }
.phase .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--sac-border-strong); }
.phase.done { color: var(--sac-text-muted); }
.phase.done .dot { background: var(--sac-ok); border-color: var(--sac-ok); }
.phase.now { color: var(--sac-accent); font-weight: 650; }
.phase.now .dot { border-color: var(--sac-accent); background: var(--sac-accent-soft); }

/* Request page */
.request-page { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; }
.main-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 440px; padding: 0; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; }
.messages-inner { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.jump { position: sticky; bottom: 4px; z-index: 1; align-self: center; margin-top: 8px; box-shadow: var(--sac-shadow); }
.msg { max-width: 760px; }
.msg .meta { font-size: 12px; color: var(--sac-text-faint); margin-bottom: 2px; }
.msg .bubble { padding: 10px 14px; border-radius: var(--sac-radius); background: var(--sac-surface-solid); border: 1px solid var(--sac-border); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; }
.msg.user .bubble { background: var(--sac-accent-soft); border-color: transparent; }
.msg.system .bubble { background: transparent; border-style: dashed; color: var(--sac-text-muted); }
.msg.system.error .bubble { border-color: var(--sac-danger); color: var(--sac-danger); }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble ul, .msg .bubble ol { margin: 4px 0; padding-left: 20px; }
.msg .bubble pre { white-space: pre-wrap; font-family: var(--sac-font-mono); font-size: 12px; }
.options { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 8px; }
.shots figure { margin: 0; }
.shots a { padding: 0; border: 1px solid var(--sac-border); border-radius: var(--sac-radius-sm); background: none; cursor: zoom-in; display: block; width: 100%; }
.shots img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; border-radius: var(--sac-radius-sm); }
.shots figcaption { font-size: 12px; color: var(--sac-text-muted); margin-top: 2px; }
.steps { font-size: 13px; color: var(--sac-text-muted); }
.steps summary { cursor: pointer; }
.steps ol { margin: 4px 0 0; padding-left: 18px; }
.steplist { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.working { display: flex; align-items: center; gap: 8px; color: var(--sac-text-muted); font-size: 13px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--sac-accent-soft); border-top-color: var(--sac-accent); border-radius: 50%; animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.composer { border-top: 1px solid var(--sac-border); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; background: var(--sac-surface-solid); border-radius: 0 0 var(--sac-radius) var(--sac-radius); }
.composer textarea { min-height: 64px; }
.attachments { display: flex; gap: 6px; flex-wrap: wrap; }
.attachments img { height: 48px; border-radius: 4px; border: 1px solid var(--sac-border); }
.cta-card { border-color: var(--sac-accent); background: var(--sac-accent-soft); }
.push-prompt { margin-bottom: 12px; gap: 12px; flex-wrap: wrap; border-color: var(--sac-accent); background: var(--sac-accent-soft); }
.push-prompt svg, .push svg { vertical-align: -3px; }
.push { display: inline-flex; align-items: center; gap: 6px; }
.push.on { color: var(--sac-accent); }
.push.blocked { color: var(--sac-text-muted); }
.cta-mobile { display: none; margin: 12px 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--sac-text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Rendered Markdown (documents, ADRs) */
.doc { overflow-wrap: anywhere; }
.doc h1 { font-size: 22px; margin: 0 0 12px; }
.doc h2 { font-size: 18px; margin: 24px 0 8px; }
.doc h3 { font-size: 15px; margin: 18px 0 6px; }
.doc table { border-collapse: collapse; display: block; overflow-x: auto; margin: 8px 0; font-size: 13px; }
.doc th, .doc td { border: 1px solid var(--sac-border); padding: 4px 8px; text-align: left; vertical-align: top; }
.doc th { background: var(--sac-surface-hover); }
.doc code { font-family: var(--sac-font-mono); font-size: 12px; background: var(--sac-surface-hover); padding: 1px 4px; border-radius: 3px; }
.doc pre { background: var(--sac-surface-hover); padding: 10px; border-radius: var(--sac-radius-sm); overflow-x: auto; }
.doc pre code { background: none; padding: 0; }
.doc img { max-width: 100%; }
.doc blockquote { margin: 8px 0; padding: 2px 12px; border-left: 3px solid var(--sac-border-strong); color: var(--sac-text-muted); }
.doc .annotate { margin-left: 8px; vertical-align: middle; visibility: hidden; }
.doc h1:hover .annotate, .doc h2:hover .annotate, .doc h3:hover .annotate, .doc .annotate:focus { visibility: visible; }
@media (hover: none) { .doc .annotate { visibility: visible; } }
.diff { white-space: pre-wrap; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.diff ins { background: var(--sac-ok-soft); text-decoration: none; }
.diff del { background: var(--sac-danger-soft); }
.diff .diff-gap { color: var(--sac-text-faint); display: block; }
.change-file .diff { padding: 8px 12px; }

/* The request's views. */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--sac-border); overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--sac-text-muted); text-decoration: none; font-weight: 550; white-space: nowrap; }
.tabs a:hover { color: var(--sac-text); }
.tabs a.on { color: var(--sac-accent); border-bottom-color: var(--sac-accent); }
.tab-panel { min-height: 320px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--sac-border-strong); border-radius: var(--sac-radius-sm); overflow: hidden; }
.seg button { height: 28px; padding: 0 10px; border: 0; background: var(--sac-surface-solid); color: var(--sac-text-muted); font: inherit; font-size: 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--sac-border-strong); }
.seg button[aria-pressed="true"] { background: var(--sac-accent-soft); color: var(--sac-accent); font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--sac-accent); outline-offset: -2px; }
.change-file { border: 1px solid var(--sac-border); border-radius: var(--sac-radius-sm); overflow: hidden; background: var(--sac-surface-solid); }
.change-file > header, .change-file > summary { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--sac-surface-2); overflow-wrap: anywhere; }
.change-file > summary { cursor: pointer; }
.pad { padding: 8px 12px; margin: 0; }

/* Side by side: before | after; the changed words marked within a changed line. */
.sbs { font-family: var(--sac-font-mono); font-size: 12px; line-height: 1.55; }
.sbs.prose { font-family: var(--sac-font); font-size: 13px; }
.sbs-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sbs-head { font-family: var(--sac-font); font-size: 12px; font-weight: 600; color: var(--sac-text-muted); border-bottom: 1px solid var(--sac-border); }
.sbs-head > div { padding: 4px 12px; }
.sbs-cell { display: flex; gap: 10px; min-width: 0; padding: 1px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.sbs-cell.old { border-right: 1px solid var(--sac-border); }
.sbs .ln { display: none; flex: none; min-width: 4ch; text-align: right; color: var(--sac-text-faint); user-select: none; }
.sbs.numbered .ln { display: inline; }
.sbs .tx { min-width: 0; }
.sbs-row.del .old, .sbs-row.change .old { background: var(--sac-danger-soft); }
.sbs-row.add .new, .sbs-row.change .new { background: var(--sac-ok-soft); }
.sbs-cell.empty { background: var(--sac-surface-hover); }
.sbs del, .sbs ins { text-decoration: none; font-weight: 700; border-radius: 2px; }
.sbs del { color: var(--sac-danger); box-shadow: inset 0 -2px var(--sac-danger); }
.sbs ins { color: var(--sac-ok); box-shadow: inset 0 -2px var(--sac-ok); }
.sbs-gap { padding: 2px 12px; text-align: center; color: var(--sac-text-faint); background: var(--sac-surface-2); border-top: 1px solid var(--sac-border); border-bottom: 1px solid var(--sac-border); }

/* Pictures large, one message's at a time. */
.lightbox { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 16px;
  background: color-mix(in srgb, var(--sac-surface-solid) 97%, transparent); backdrop-filter: var(--sac-blur); -webkit-backdrop-filter: var(--sac-blur); }
.lb-bar { display: flex; align-items: center; gap: 8px; flex: none; }
.lb-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 10px; }
.lb-stage img { min-width: 0; max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid var(--sac-border); border-radius: var(--sac-radius-sm); box-shadow: var(--sac-shadow); background: var(--sac-surface-solid); }
.lb-nav { flex: none; width: 40px; height: 64px; justify-content: center; padding: 0; font-size: 24px; }
.lb-thumbs { display: flex; justify-content: center; gap: 6px; overflow-x: auto; flex: none; padding-bottom: 2px; }
.lb-thumbs button { flex: none; padding: 0; border: 2px solid transparent; border-radius: var(--sac-radius-sm); background: none; cursor: pointer; }
.lb-thumbs button.on { border-color: var(--sac-accent); }
.lb-thumbs button:focus-visible { outline: 2px solid var(--sac-accent); outline-offset: 1px; }
.lb-thumbs img { display: block; width: 80px; height: 52px; object-fit: cover; object-position: top; border-radius: 4px; }

.knowledge { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.doclist { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; }
.doclist details { margin-bottom: 6px; }
.doclist summary { font-weight: 650; cursor: pointer; padding: 4px 0; }
.doclist a { display: block; padding: 4px 8px; border-radius: var(--sac-radius-sm); text-decoration: none; color: var(--sac-text); font-size: 13px; }
.doclist a:hover { background: var(--sac-surface-hover); }
.doclist a.active { background: var(--sac-accent-soft); color: var(--sac-accent); }
.doclist .st { display: block; font-size: 11px; color: var(--sac-text-faint); }
.annotation-form { margin: 8px 0 16px; }
.selection-pop { position: absolute; z-index: 20; }

.toasts { position: fixed; bottom: 16px; right: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; max-width: 480px; padding: 10px 14px; border-radius: var(--sac-radius); background: var(--sac-surface-solid); border: 1px solid var(--sac-border-strong); box-shadow: var(--sac-shadow); }
.toast.error { border-color: var(--sac-danger); color: var(--sac-danger); }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th, table.list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--sac-border); vertical-align: top; }
.scroll-x { overflow-x: auto; }

@media (max-width: 1180px) {
  .usage .reset { display: none; }
}
@media (max-width: 960px) {
  .request-page, .knowledge { grid-template-columns: minmax(0, 1fr); }
  .side, .doclist { position: static; max-height: none; }
  .cta-mobile { display: block; }
}
@media (max-width: 720px) {
  .sbs-row { grid-template-columns: minmax(0, 1fr); }
  .sbs-head, .sbs-row.same .old, .sbs-cell.empty { display: none; }
  .sbs-cell.old { border-right: 0; }
  .lb-nav { display: none; }
}
@media (max-width: 640px) {
  main { padding: 12px; }
  .top { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .nav { order: 3; flex-basis: 100%; }
  .who .name { display: none; }
  .push .lbl { display: none; }
  .usage .usd, .usage .reset, .usage .lbl { display: none; }
  .requests { grid-template-columns: minmax(0, 1fr); }
  .chat { height: calc(100dvh - 140px); min-height: 380px; }
}

