:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #17202b;
  --muted: #5b6676;
  --brand: #1e3a5f;
  --brand-ink: #ffffff;
  --accent: #c98a12;
  --accent-soft: #fdf4e3;
  --critical: #b42318;
  --critical-soft: #fdecea;
  --high: #b54708;
  --high-soft: #fef3e6;
  --medium: #1f5fa8;
  --medium-soft: #e8f0fb;
  --ok: #177245;
  --ok-soft: #e7f5ee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  /* System fonts only (strict CSP). Nirmala UI covers every Indic script on Windows; Noto on Android/Linux. */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Nirmala UI", "Noto Sans", "Noto Sans Devanagari",
    "Noto Sans Bengali", "Noto Sans Gujarati", "Noto Sans Gurmukhi", "Noto Sans Oriya", "Noto Sans Tamil",
    "Noto Sans Telugu", "Noto Sans Kannada", "Noto Sans Malayalam", "Kohinoor Devanagari", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #161d27;
    --surface-2: #1d2633;
    --border: #2c3748;
    --text: #e6eaf0;
    --muted: #98a3b3;
    --brand: #9cc0ea;
    --brand-ink: #0f141b;
    --accent: #f0b445;
    --accent-soft: #2e2512;
    --critical: #f97066;
    --critical-soft: #3a1714;
    --high: #fdb022;
    --high-soft: #35260f;
    --medium: #84adf0;
    --medium-soft: #162640;
    --ok: #47cd89;
    --ok-soft: #10301f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 48px; outline: none; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---- top bar ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: #1e3a5f; color: #f5b942; display: grid; place-items: center; font-family: Georgia, serif; font-size: 18px; }
.brand-name { font-size: 1.1rem; letter-spacing: -0.01em; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav button.link { padding: 7px 11px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 0.92rem; background: none; border: 0; cursor: pointer; font-family: inherit; }
.nav a:hover, .nav button.link:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav select { font-size: 0.85rem; padding: 6px 8px; }

/* ---- footer ---- */
.footer { border-top: 1px solid var(--border); background: var(--surface); font-size: 0.82rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }

/* ---- generic ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi-label { font-size: 0.78rem; color: var(--muted); }
.kpi-value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); }
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- forms ---- */
label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 0.92rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 110px; resize: vertical; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields .full { grid-column: 1 / -1; }
.fields-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .fields, .fields-3 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 0.88rem; margin: 6px 0; }
.check input { width: auto; margin-top: 3px; }
.section-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 8px; }
.field-error { color: var(--critical); font-size: 0.85rem; margin-top: 8px; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 0.9rem; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-accent { background: var(--accent); color: #1a1205; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--critical); border-color: var(--border); }
.btn-small { padding: 5px 10px; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

/* ---- landing ---- */
.hero { padding: 36px 0 28px; max-width: 760px; }
.hero h1 { font-size: 2.3rem; letter-spacing: -0.02em; }
.hero p { font-size: 1.08rem; color: var(--muted); }
.eyebrow { display: inline-block; font-size: 0.78rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.feature h3 { margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: 0.92rem; margin: 0; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; padding-left: 36px; position: relative; margin-bottom: 12px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 0.8rem; }

/* ---- auth ---- */
.auth { max-width: 440px; margin: 24px auto; }

/* ---- findings / badges ---- */
.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; }
.sev-critical { background: var(--critical-soft); color: var(--critical); }
.sev-high { background: var(--high-soft); color: var(--high); }
.sev-medium { background: var(--medium-soft); color: var(--medium); }
.sev-info { background: var(--ok-soft); color: var(--ok); }
.finding { border-left: 3px solid var(--border); padding: 8px 12px; background: var(--surface-2); border-radius: 0 8px 8px 0; margin-bottom: 8px; }
.finding.critical { border-color: var(--critical); }
.finding.high { border-color: var(--high); }
.finding.medium { border-color: var(--medium); }
.finding.info { border-color: var(--ok); }
.finding-title { font-weight: 600; font-size: 0.92rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.finding p { margin: 4px 0 0; font-size: 0.88rem; color: var(--muted); }
.next-step { background: var(--brand); color: var(--brand-ink); border-radius: var(--radius); padding: 16px 18px; }
.next-step h3 { color: inherit; }
.next-step p { margin: 4px 0; }
.authority { padding: 10px 0; border-bottom: 1px solid var(--border); }
.authority:last-child { border-bottom: 0; }
.authority-type { font-size: 0.72rem; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.authority-title { font-weight: 600; font-size: 0.92rem; }
.authority p { margin: 2px 0 0; font-size: 0.86rem; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* ---- cases list ---- */
.case-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.case-row:hover { background: var(--surface-2); }
.case-row:last-child { border-bottom: 0; }
@media (max-width: 700px) { .case-row { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.status { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-transform: capitalize; }
.empty { text-align: center; padding: 36px 12px; color: var(--muted); }

/* ---- documents ---- */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; color: var(--muted); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { opacity: 0.75; pointer-events: none; }
.dropzone p { margin: 0 0 8px; }
.upload-controls { justify-content: center; margin: 10px 0; }
.upload-controls select { width: auto; max-width: 100%; }
.dropzone [role="status"] { color: var(--text); font-weight: 600; margin: 8px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.imported { border-color: var(--accent); background: var(--accent-soft); margin-bottom: 16px; }
.imported ul { margin: 6px 0; padding-left: 18px; }
.card + .grid-2, .card + .card, .card + p { margin-top: 16px; }
label.btn { display: inline-flex; margin: 0; font-size: 0.9rem; }
.doc { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: center; flex-wrap: wrap; }
.doc:last-child { border-bottom: 0; }
.detected { background: var(--accent-soft); border-radius: 8px; padding: 12px; margin-top: 12px; }
.detected ul { margin: 6px 0 10px; padding-left: 18px; font-size: 0.88rem; }

/* ---- drafts ---- */
.draft-output { font-family: var(--mono); font-size: 0.82rem; white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; max-height: 560px; overflow: auto; min-height: 220px; }

/* ---- library ---- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 0.82rem; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.chip.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.lib-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.lib-item:last-child { border-bottom: 0; }
.lib-meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 2px; }
.lib-item h3 { font-size: 0.98rem; margin: 2px 0 4px; overflow-wrap: anywhere; }
.lib-item p { font-size: 0.88rem; color: var(--muted); margin: 0 0 4px; }

/* ---- toast ---- */
.toast { position: fixed; right: 16px; bottom: 16px; background: #17202b; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 0.9rem; z-index: 50; max-width: calc(100vw - 32px); }
.toast.error { background: #b42318; }

.disclaimer { font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { font: inherit; font-weight: 600; font-size: 0.9rem; padding: 10px 14px; border: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.prose h2 { margin-top: 1.4rem; }

/* ---- issues in dispute ---- */
.issue { padding: 12px 0; border-bottom: 1px solid var(--border); }
.issue:last-child { border-bottom: 0; }
.issue h4 { margin: 0 0 6px; font-size: 0.95rem; }
.evidence { margin: 6px 0 10px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; font-size: 0.86rem; }
[dir="rtl"] .evidence { border-left: 0; border-right: 3px solid var(--accent); border-radius: 6px 0 0 6px; }
.doc details { margin-top: 6px; }
.doc .status { margin-inline-start: 6px; }

/* ---- languages ---- */
.nav select.lang-switch { width: auto; min-width: 7.5rem; }
/* Indic scripts have tall vowel signs; give them room. */
html:not([lang="en"]) body { line-height: 1.6; }
html[lang="ur"] body { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Segoe UI", "Noto Naskh Arabic", var(--font); line-height: 1.9; }
/* Right-to-left (Urdu): mirror direction-dependent spacing. Numbers, codes and English legal text stay LTR. */
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] td.num, [dir="rtl"] th.num { text-align: left; }
[dir="rtl"] .finding { border-left: 0; border-right: 3px solid var(--border); border-radius: 8px 0 0 8px; }
[dir="rtl"] .finding.critical { border-right-color: var(--critical); }
[dir="rtl"] .finding.high { border-right-color: var(--high); }
[dir="rtl"] .finding.medium { border-right-color: var(--medium); }
[dir="rtl"] .finding.info { border-right-color: var(--ok); }
[dir="rtl"] .steps li { padding-left: 0; padding-right: 36px; }
[dir="rtl"] .steps li::before { left: auto; right: 0; }
[dir="rtl"] .toast { right: auto; left: 16px; }
[dir="rtl"] .detected ul, [dir="rtl"] .imported ul { padding-left: 0; padding-right: 18px; }
[dir="rtl"] .mono, [dir="rtl"] input[type="number"], [dir="rtl"] input[type="email"], [dir="rtl"] input[name="gstin"],
[dir="rtl"] input[name="din"], [dir="rtl"] .kpi-value { direction: ltr; unicode-bidi: isolate; text-align: right; }
/* Dates like 30-09-2026 and years like 2022-23 would otherwise be reordered inside right-to-left text. */
[dir="rtl"] td, [dir="rtl"] .finding p, [dir="rtl"] .next-step p { unicode-bidi: plaintext; }
[lang="en"][dir="ltr"] th, [lang="en"][dir="ltr"] td { text-align: left; }
.prose { max-width: 760px; }

/* GST expert */
.ai-answer { line-height: 1.6; overflow-wrap: anywhere; }
.ai-answer.ai-no { font-weight: 600; color: var(--critical); }
.md h2, .md h3, .md h4 { margin: 1.2em 0 0.4em; }
.md h2:first-child, .md h3:first-child { margin-top: 0; }
.md table { font-size: 0.92em; }
.md blockquote { margin: 0.6em 0; padding: 6px 12px; border-inline-start: 3px solid var(--accent); background: var(--accent-soft); }
.md code { font-family: var(--mono); font-size: 0.92em; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md ul, .md ol { padding-inline-start: 1.4em; }
.ai-question p { margin: 4px 0 0; white-space: pre-wrap; }
.expert-layout { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .expert-layout { grid-template-columns: 1fr; } }

/* legal repository */
.repo-text { white-space: pre-wrap; font-family: var(--font); font-size: 0.95rem; line-height: 1.55; margin: 0; overflow-wrap: anywhere; }
a.rref { font-family: var(--mono); font-size: 0.9em; padding: 0 3px; border-radius: 4px; background: var(--medium-soft); text-decoration: none; }
.badge.outcome-assessee { background: var(--ok-soft); color: var(--ok); }
.badge.outcome-department { background: var(--critical-soft); color: var(--critical); }
.badge.outcome-mixed, .badge.outcome-remand { background: var(--high-soft); color: var(--high); }
a.lib-item { display: block; color: inherit; text-decoration: none; }
a.lib-item:hover h3 { text-decoration: underline; }

/* ================= interactive app shell ================= */
.shell { flex: 1; display: flex; width: 100%; }
.shell > main.wrap { flex: 1; min-width: 0; }
.sidebar { display: none; }
body.signed-in .sidebar {
  display: flex; flex-direction: column; justify-content: space-between; width: 232px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px;
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
}
body.signed-in .shell > main.wrap { max-width: 1240px; padding-left: 28px; padding-right: 28px; }
body.signed-in.wide .shell > main.wrap { max-width: none; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 0.93rem; width: 100%; background: none; border: 0; font-family: inherit; cursor: pointer; text-align: left; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: var(--brand); color: var(--brand-ink); }
.side-icon { width: 20px; text-align: center; font-size: 1.05rem; }
.side-foot { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.side-user { display: flex; flex-direction: column; padding: 4px 12px 8px; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  body.signed-in .sidebar { position: static; width: 100%; height: auto; flex-direction: row; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  body.signed-in .sidebar nav { display: flex; gap: 2px; }
  .side-link { white-space: nowrap; padding: 8px 10px; width: auto; }
  .side-foot, .side-user { display: none; }
  body.signed-in .shell > main.wrap { padding-left: 16px; padding-right: 16px; }
}

/* ---- dashboard ---- */
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 18px 0; }
@media (max-width: 1100px) { .kpis-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi-alert { border-color: var(--critical); background: var(--critical-soft); }
.kpi-alert .kpi-value { color: var(--critical); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }  /* minmax: long case names must not widen the page */
.event { display: flex; gap: 14px; align-items: center; padding: 10px; border-radius: 10px; text-decoration: none; color: var(--text); border: 1px solid var(--border); }
.event + .event { margin-top: 8px; }
.event:hover { background: var(--surface-2); }
.event-date { width: 54px; flex-shrink: 0; text-align: center; background: var(--surface-2); border-radius: 8px; padding: 6px 0; display: flex; flex-direction: column; line-height: 1.2; }
.event-date span { font-size: 0.72rem; color: var(--muted); }
.due { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-left: 6px; }
.due-over { background: var(--critical); color: #fff; }
.due-hot { background: var(--critical-soft); color: var(--critical); }
.due-warm { background: var(--high-soft); color: var(--high); }
.due-cool { background: var(--surface-2); color: var(--muted); }
.due-over-label { color: var(--critical); }
.mini-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); align-items: center; }
.mini-row:last-child { border-bottom: 0; }
.mini-row:hover { background: var(--surface-2); }
.mini-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.status.st-done { background: var(--ok-soft); color: var(--ok); }
.status.st-running, .status.st-queued { background: var(--medium-soft); color: var(--medium); }
.status.st-failed { background: var(--critical-soft); color: var(--critical); }
.getting-started { max-width: 720px; margin-top: 18px; }

/* ---- wizard ---- */
.wizard { max-width: 920px; }
.stepper { list-style: none; padding: 0; margin: 14px 0 10px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.step, .step a { display: flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; font-size: 0.88rem; font-weight: 600; }
.step-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); flex-shrink: 0; }
.step.current { color: var(--text); }
.step.current .step-dot { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.step.done .step-dot { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
@media (max-width: 700px) { .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }
.wizard-body { padding: 24px; }
.wizard .dropzone { padding: 36px 20px; }
.autofilled input, .autofilled select { border-color: var(--accent); background: var(--accent-soft); }
.read-note { background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; }
.reading { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .progress > span { transition: none; } }

/* ---- chat ---- */
.chat { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; height: calc(100vh - 230px); min-height: 460px; }
.chat-threads { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.thread { text-align: left; font: inherit; font-size: 0.85rem; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--surface); border-color: var(--border); color: var(--text); }
.chat-main { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 14px; overflow-wrap: anywhere; }
.bubble-me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); white-space: pre-wrap; border-bottom-right-radius: 4px; }
.bubble-ai { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.chat-empty { margin: auto 0; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-input textarea { min-height: 44px; max-height: 160px; }
@media (max-width: 800px) { .chat { grid-template-columns: 1fr; height: auto; } .chat-threads { flex-direction: row; overflow-x: auto; } .chat-log { max-height: 60vh; } }

/* ---- side-by-side review ---- */
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; height: calc(100vh - 230px); min-height: 520px; }
.review-col { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.review-bar { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.review-bar select { flex: 1; min-width: 0; }
.review-doc, .review-out { flex: 1; min-height: 0; overflow: auto; }
.review-out { padding: 16px 20px; }
.review-tools { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.review-tools:empty { display: none; }
.doc-frame { width: 100%; height: 100%; border: 0; display: block; background: #525659; }
.editor-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; height: 100%; }
.editor { font-family: var(--mono); font-size: 0.82rem; height: 100%; min-height: 400px; resize: none; }
.editor-preview { overflow: auto; border-left: 1px solid var(--border); padding-left: 12px; }
@media (max-width: 1000px) { .review { grid-template-columns: 1fr; height: auto; } .review-doc { height: 70vh; } .editor-split { grid-template-columns: 1fr; } }

/* ---- repository drawer ---- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(16, 24, 40, 0.18); z-index: 40; display: flex; flex-direction: column; animation: slidein 0.18s ease-out; }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.drawer-body { padding: 16px; overflow-y: auto; flex: 1; }
.drawer-body .repo-text { font-size: 0.9rem; }
span.rref { font-family: var(--mono); font-size: 0.9em; padding: 0 3px; border-radius: 4px; background: var(--surface-2); }
.doc-pages { background: #525659; padding: 12px; display: flex; flex-direction: column; gap: 12px; align-items: center; min-height: 100%; }
.doc-page { width: 100%; max-width: 900px; aspect-ratio: auto 612 / 792; height: auto; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
