/* Sanyu — UBOS GenAI Studio. Faithful to the design system in /Gen ai UI/styles.css
   Type: Newsreader (display serif), Geist (UI sans), JetBrains Mono (data).
   Palette: warm paper, ink, flat UBOS blue. Restrained — no gradients/glows. */
:root {
  --paper: #f6f7f8; --paper-2: #eef0f2;
  --surface: #ffffff; --surface-2: #fafbfc; --surface-3: #f1f3f5;
  --ink: #0f1620; --ink-2: #1f2937; --muted: #6b7280; --muted-2: #9aa3ad;
  --line: #e6e8ec; --line-2: #d4d8df;
  /* UBOS blue (mockup calls it "emerald") */
  --blue: #1e6fa3; --blue-2: #155a87; --blue-tint: #e6f1f8;
  --cyan: #2ba6d4; --cyan-tint: #e6f5fb;
  --terra: #c0392b; --terra-tint: #fbe9e6; --gold: #f1b73c; --green: #1e7d52;
  --r-sm: 5px; --r-md: 8px; --r-lg: 14px;
  --shadow-1: 0 1px 0 rgba(28,26,22,0.04), 0 0 0 1px var(--line);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Geist', -apple-system, system-ui, sans-serif; color: var(--ink);
  font-size: 13.5px; line-height: 1.5; background: var(--paper);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--blue); }
.mono, .act-steps { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }

#root, .app { height: 100vh; height: 100dvh; }
.app { display: grid; grid-template-columns: 248px 1fr; overflow: hidden; }

/* ───────── Sidebar (light) ───────── */
.sidebar { background: var(--surface-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 14px 12px 8px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 6px; margin-bottom: 8px; border-radius: var(--r-md); cursor: pointer; outline: none; }
.brand:hover { background: rgba(28,26,22,0.04); }
.brand:focus-visible { box-shadow: 0 0 0 2px var(--blue-tint); }
.brand img { width: 34px; height: 34px; object-fit: contain; }
.brand .divider { width: 1px; height: 30px; background: var(--line); }
.brand .t1 { font-family: 'Newsreader', serif; font-weight: 500; font-size: 20px; letter-spacing: -0.01em; line-height: 1; color: var(--ink); }
.brand .t2 { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 5px; }
.new-btn { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 500; padding: 9px 12px; border: none; border-radius: var(--r-md); margin-bottom: 8px; }
.new-btn:hover { background: var(--ink-2); }
.side-sec { padding: 4px 0; }
.side-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 16px 8px 8px; font-weight: 500; }
.collapse-head { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; cursor: pointer; }
.collapse-head:hover { color: var(--ink-2); }
.collapse-head .chev { display: inline-flex; color: var(--muted-2); transition: transform .15s; transform: rotate(-90deg); }
.collapse-head .chev.open { transform: rotate(0deg); }
/* Source on/off toggles */
.src-list { padding: 2px 0 6px; }
.src-hint { font-size: 10.5px; color: var(--muted-2); padding: 2px 8px 8px; line-height: 1.45; }
.src-toggle { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: none; background: none; padding: 5px 8px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 12px; }
.src-toggle:hover { background: rgba(28,26,22,0.04); }
.src-toggle .src-nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-toggle.off .src-nm { color: var(--muted-2); text-decoration: line-through; }
.src-sw { flex: none; width: 26px; height: 15px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .15s; }
.src-sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.22); }
.src-sw.on { background: var(--blue); }
.src-sw.on::after { transform: translateX(11px); }
/* Admin-disabled source: visible but locked — only an admin can re-enable it. */
.src-toggle.admin-off { cursor: default; opacity: .8; }
.src-toggle.admin-off .src-nm { text-decoration: none; font-style: italic; }
.src-admoff { flex: none; font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #7a5c10; background: rgba(241,183,60,.18); border-radius: 999px; padding: 2px 6px; }
.nav-btn { width: 100%; text-align: left; display: flex; align-items: center; gap: 9px; padding: 8px 9px; border: none; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.nav-btn:hover { background: rgba(28,26,22,0.04); }
.nav-btn.active { background: var(--blue-tint); color: var(--blue); }
.nav-btn svg { color: var(--muted); }
.nav-btn.active svg { color: var(--blue); }
.recent { overflow-y: auto; flex: 1; min-height: 0; }
.recent-item { width: 100%; text-align: left; padding: 6px 9px; border: none; background: none; color: var(--ink-2); font-size: 12.5px; border-radius: var(--r-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item:hover { background: rgba(28,26,22,0.04); }
.recent-item.active { background: var(--blue-tint); color: var(--blue); }
.recent-item.convo { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.recent-item.convo .convo-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item.convo .convo-del { border: none; background: none; color: var(--muted-2); padding: 2px; border-radius: 4px; opacity: 0; display: grid; place-items: center; }
.recent-item.convo:hover .convo-del { opacity: 1; }
.recent-item.convo .convo-del:hover { color: var(--terra); background: var(--terra-tint); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 11px 8px 4px; color: var(--muted); font-size: 11px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.foot-warn { margin-right: auto; display: inline-flex; align-items: center; gap: 7px; color: var(--terra); }
.dot-ok { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot-ok.dot-bad { background: var(--terra); }

/* ───────── Main ───────── */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper); }
.topbar { height: 49px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 20px; background: var(--paper); }
.topbar .title { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.topbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 2px; }
.seg button { border: none; background: none; padding: 5px 11px; border-radius: 5px; font-size: 12px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.ghost-btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 6px 11px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.ghost-btn:hover { background: rgba(28,26,22,0.04); }
.ghost-btn svg { vertical-align: middle; }

.workspace { flex: 1; display: grid; grid-template-columns: 1fr 288px; min-height: 0; }
.center { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.scroll { overflow-y: auto; flex: 1; min-height: 0; }

/* ───────── Chat ───────── */
.thread { max-width: 800px; margin: 0 auto; padding: 22px 28px 8px; width: 100%; }
.msg { display: flex; gap: 12px; margin-bottom: 24px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 600; font-size: 10px; font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
.avatar.user { background: var(--terra-tint); color: var(--terra); }
.avatar.ai { background: var(--blue-tint); color: var(--blue); }
.msg .body { flex: 1; min-width: 0; }
.msg .who { font-weight: 600; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.bubble { line-height: 1.6; color: var(--ink-2); font-size: 14px; }
.bubble p { margin: 0 0 10px; }
.bubble h1,.bubble h2,.bubble h3 { font-family: 'Newsreader', serif; font-weight: 500; line-height: 1.25; margin: 18px 0 8px; color: var(--ink); letter-spacing: -0.01em; }
.bubble h1 { font-size: 23px; } .bubble h2 { font-size: 19px; } .bubble h3 { font-size: 16px; }
.bubble table { border-collapse: collapse; width: 100%; margin: 12px 0 16px; font-size: 13px; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.bubble th, .bubble td { border-bottom: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.bubble thead th { background: var(--surface-3); font-weight: 600; color: var(--ink-2); }
.bubble tbody tr:last-child td { border-bottom: none; }
.bubble td:nth-child(n+2), .bubble th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
.bubble code { font-family: 'JetBrains Mono', monospace; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.bubble ul, .bubble ol { margin: 0 0 10px; padding-left: 22px; }
.bubble li { margin-bottom: 4px; }
.bubble strong { font-weight: 600; color: var(--ink); }
.cursor { display: inline-block; width: 7px; height: 14px; background: var(--blue); margin-left: 2px; vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Activity pill — one calm line while Sanyu works; click to reveal the real steps */
.activity { margin: 0 0 12px; }
.act-head { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; line-height: 1.3; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px 5px 9px; transition: color .15s ease, background .15s ease, border-color .15s ease; }
.act-head:hover { color: var(--ink-2); border-color: var(--line-2); background: var(--surface-2); }
.act-head:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--blue-tint); }
.activity.live .act-head { color: var(--blue); background: var(--blue-tint); border-color: transparent; }
.activity:not(.has-steps) .act-head { cursor: default; }
.act-verb { font-variant-numeric: tabular-nums; }
.act-glyph { display: inline-flex; }
.act-glyph svg { display: block; }
.act-glyph rect { transform-box: fill-box; transform-origin: 50% 100%; transform: scaleY(.62); }
.activity.live .act-glyph rect { animation: act-bar 1.15s ease-in-out infinite; }
.activity.live .act-glyph .b2 { animation-delay: .18s; }
.activity.live .act-glyph .b3 { animation-delay: .36s; }
@keyframes act-bar { 0%, 100% { transform: scaleY(.34); } 50% { transform: scaleY(1); } }
.act-dots { display: none; gap: 2.5px; align-items: center; margin-left: -2px; }
.activity.live .act-dots { display: inline-flex; }
.act-dots i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .28; animation: act-dot 1.3s ease-in-out infinite; }
.act-dots i:nth-child(2) { animation-delay: .18s; }
.act-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes act-dot { 0%, 100% { opacity: .22; } 45% { opacity: .95; } }
.act-chev { display: none; opacity: .65; transition: transform .18s ease; }
.activity.has-steps .act-chev { display: inline-flex; }
.act-chev svg { display: block; width: 12px; height: 12px; }
.activity.open .act-chev { transform: rotate(180deg); }
.act-steps { display: none; font-size: 11.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 12px; margin-top: 8px; }
.activity.open .act-steps { display: block; }
.act-steps .step { padding: 1.5px 0; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) {
  .activity.live .act-glyph rect, .act-dots i { animation: none; }
  .act-dots i { opacity: .55; }
}
.answer-meta { font-size: 11px; color: var(--muted-2); margin-top: 10px; font-variant-numeric: tabular-nums; }

/* Charts */
.chart { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; margin: 12px 0 16px; background: var(--surface); }
.chart .c-title { font-family: 'Newsreader', serif; font-weight: 500; font-size: 15px; margin-bottom: 12px; color: var(--ink); }
.bar-row { display: grid; grid-template-columns: 140px 1fr 80px; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 12.5px; }
.bar-row .lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--surface-3); border-radius: 4px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--blue); border-radius: 4px; }  /* height is overridden inline when a chart has several series */
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 500; font-size: 12px; }
.c-svg { width: 100%; height: auto; }
.c-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--ink-2); }
.c-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.c-axis { color: var(--muted-2); }
.c-unit { font-size: 11px; color: var(--muted); margin-top: 6px; }
/* Pie / donut: chart on the left, a readable legend with values beside it */
.pie-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.pie-svg { width: 190px; height: 190px; flex: none; }
.pie-legend { flex: 1; min-width: 190px; font-size: 12px; }
.pl-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.pl-row i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.pl-lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.pl-val { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.pl-pct { color: var(--muted); width: 50px; text-align: right; font-variant-numeric: tabular-nums; }

/* Composer */
.composer { border-top: 1px solid var(--line); background: var(--paper); padding: 14px 28px 18px; }
.composer .wrap { max-width: 800px; margin: 0 auto; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--ink-2); }
.chip:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-tint); }
.input-box { display: flex; align-items: flex-end; gap: 10px; border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 10px 12px; background: var(--surface); }
.input-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.input-box textarea { flex: 1; border: none; outline: none; resize: none; font-family: inherit; font-size: 14px; line-height: 1.5; max-height: 160px; background: transparent; color: var(--ink); }
.send { background: var(--blue); color: #fff; border: none; border-radius: var(--r-md); width: 36px; height: 36px; display: grid; place-items: center; flex: none; }
.send:disabled { background: var(--muted-2); cursor: default; }
.send:hover:not(:disabled) { background: var(--blue-2); }

/* Inspector */
.inspector { border-left: 1px solid var(--line); background: var(--surface-2); overflow-y: auto; padding: 16px; }
.insp-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 500; margin: 4px 0 12px; }
.src-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 11px 13px; margin-bottom: 8px; background: var(--surface); }
.src-card .nm { font-weight: 600; font-size: 12.5px; }
.src-card .meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.src-card .inds { margin-top: 7px; font-size: 11px; color: var(--ink-2); }
.src-card .inds span { display: inline-block; background: var(--paper-2); color: var(--ink-2); border-radius: 4px; padding: 2px 7px; margin: 2px 4px 0 0; }
.empty-note { color: var(--muted); font-size: 12.5px; line-height: 1.55; }

/* Hero (empty chat) */
.hero { max-width: 800px; margin: 0 auto; padding: 60px 28px 0; }
.hero .eyebrow, .landing .eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--paper-2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 5px; }
.hero h1 { font-family: 'Newsreader', serif; font-weight: 500; font-size: 34px; line-height: 1.15; margin: 18px 0 10px; letter-spacing: -0.01em; color: var(--ink); }
.hero h1 .accent { color: var(--blue); }
.hero p { color: var(--muted); font-size: 14.5px; line-height: 1.6; margin: 0; max-width: 620px; }

/* Chat landing (empty state) — input box raised and prominent */
.landing { max-width: 720px; margin: 0 auto; padding: clamp(26px, 8vh, 84px) 28px 40px; text-align: center; }
.landing-h1 { font-family: 'Newsreader', serif; font-weight: 500; font-size: 32px; line-height: 1.16; letter-spacing: -0.01em; color: var(--ink); margin: 15px 0 22px; }
.landing-h1 .accent { color: var(--blue); }
.landing-box { max-width: 660px; margin: 0 auto; text-align: left; }
.landing-box .input-box { box-shadow: 0 6px 22px rgba(15,22,32,.07); }
.landing-suggest { justify-content: center; margin-top: 16px; }
.landing-sub { color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 560px; margin: 24px auto 0; }

/* Documents */
.doc-pane { max-width: 880px; margin: 0 auto; width: 100%; padding: 24px 30px; }
.doc-pane h2.section { font-family: 'Newsreader', serif; font-weight: 500; font-size: 22px; margin: 4px 0 4px; letter-spacing: -0.01em; }
.tpl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 16px 0 22px; }
.tpl-card { text-align: left; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; background: var(--surface); box-shadow: var(--shadow-1); transition: border-color .12s; }
.tpl-card:hover { border-color: var(--line-2); }
.tpl-card.sel { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.tpl-card .dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.tpl-card .nm { font-family: 'Newsreader', serif; font-weight: 500; font-size: 16px; margin: 9px 0 5px; color: var(--ink); }
.tpl-card .ds { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.tpl-card .badges { margin-top: 11px; }
.tpl-card .badge { display: inline-block; background: var(--paper-2); color: var(--ink-2); font-size: 10.5px; border-radius: 4px; padding: 2px 8px; margin: 0 4px 4px 0; }
.gen-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 5px; color: var(--ink-2); }
.field input, .field select { width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 9px 11px; font-family: inherit; font-size: 14px; background: var(--surface); color: var(--ink); }
.field select { cursor: pointer; }
.field input:focus, .field select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.gen-btn { display: inline-flex; align-items: center; gap: 7px; background: var(--blue); color: #fff; border: none; border-radius: var(--r-md); padding: 9px 16px; font-weight: 500; font-size: 13px; }
.gen-btn:hover:not(:disabled) { background: var(--blue-2); }
.gen-btn:disabled { background: var(--muted-2); }
.doc-output { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 38px 46px; margin-top: 20px; box-shadow: var(--shadow-1); }
.doc-header { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--blue); padding-bottom: 16px; margin-bottom: 24px; }
.doc-header img { width: 50px; height: 50px; object-fit: contain; flex: none; }
.doc-header .dh-org { font-family: Arial, sans-serif; font-weight: 700; font-size: 14.5px; color: var(--blue); letter-spacing: .02em; }
.doc-header .dh-sub { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.doc-output.report .bubble { font-family: 'Newsreader', serif; font-size: 15.5px; line-height: 1.7; color: var(--ink-2); }
.doc-output.report .bubble code, .doc-output.report .act-steps { font-family: 'JetBrains Mono', monospace; }

.spinner { width: 15px; height: 15px; border: 2px solid var(--blue-tint); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 8px 30px rgba(15,22,32,.12); min-width: 174px; z-index: 30; overflow: hidden; padding: 4px; }
.menu-item { display: block; width: 100%; text-align: left; border: none; background: none; padding: 8px 12px; font-size: 12.5px; color: var(--ink-2); border-radius: 5px; }
.menu-item:hover { background: var(--blue-tint); color: var(--blue); }

@media (max-width: 1080px) { .workspace { grid-template-columns: 1fr; } .inspector { display: none; } }

/* ───────── Mobile: sidebar becomes an off-canvas drawer ───────── */
.nav-toggle { display: none; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; width: 33px; height: 30px; place-items: center; color: var(--ink-2); flex: none; }
.nav-toggle:hover { background: rgba(28,26,22,0.04); }
.nav-overlay { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 270px; max-width: 84vw; transform: translateX(-100%); transition: transform .22s ease; z-index: 50; box-shadow: 0 12px 44px rgba(15,22,32,.22); }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .nav-overlay { display: block; position: fixed; inset: 0; background: rgba(15,22,32,.42); z-index: 40; }
  .nav-toggle { display: inline-grid; }
  .topbar { padding: 0 10px; gap: 8px; }
  .tb-lbl { display: none; }
  .thread { padding: 16px 14px 8px; }
  .composer { padding: 12px 14px 16px; }
  .hero { padding: 38px 18px 0; }
  .hero h1 { font-size: 25px; }
  .landing { padding: 28px 16px 36px; }
  .landing-h1 { font-size: 23px; }
  .doc-pane { padding: 16px 14px; }
  .doc-output { padding: 20px 16px; }
  .doc-output.report .bubble { font-size: 14.5px; }
  .tpl-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 84px 1fr 50px; gap: 8px; }
  /* Wide tables (e.g. CPI by division) scroll horizontally instead of squeezing. */
  .bubble table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; font-size: 12px; white-space: nowrap; }
  .bubble th, .bubble td { padding: 6px 9px; }
  .modal-card { padding: 22px 20px; }
  .dc-fab span { display: none; }
  .dc-fab { padding: 12px; border-radius: 50%; }
}
/* Document + refinement rail (two columns on a wide screen) */
.doc-layout { display: block; }
.doc-layout.with-rail { display: grid; grid-template-columns: minmax(0, 1fr) 322px; gap: 20px; align-items: start; max-width: 1290px; margin: 0 auto; padding-right: 22px; }
.doc-layout.with-rail .doc-pane { margin: 0; padding-right: 6px; }
.doc-layout.with-rail > * { min-width: 0; }
.doc-rail { position: sticky; top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); margin-top: 24px; max-height: calc(100dvh - 96px); display: flex; flex-direction: column; }
.rf-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--line); font-family: 'Newsreader', serif; font-weight: 600; font-size: 15px; }
.rf-head > span { display: inline-flex; align-items: center; gap: 7px; }
.rf-head svg { color: var(--blue); }
.rf-body { padding: 12px 14px 14px; overflow-y: auto; }
.rf-hint { font-size: 11.5px; line-height: 1.5; color: var(--muted); margin: 0 0 10px; }
.rf-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px; }
.rf-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 11.5px; color: var(--ink-2); }
.rf-chip:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); background: var(--blue-tint); }
.rf-chip:disabled { opacity: .5; cursor: default; }
.rf-ta { width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 9px 11px; font-family: inherit; font-size: 13px; line-height: 1.5; resize: vertical; min-height: 62px; background: var(--surface); color: var(--ink); }
.rf-ta:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.rf-go { width: 100%; justify-content: center; margin-top: 8px; }
.rf-busy { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.rf-err { font-size: 12px; color: var(--terra); background: var(--terra-tint); border-radius: var(--r-sm); padding: 7px 9px; margin-top: 10px; }
.rf-undo { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin-top: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: var(--r-md); padding: 7px 10px; font-size: 12px; }
.rf-undo:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-tint); }
.rf-undo svg { width: 13px; height: 13px; }
.rf-log { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.rf-log-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 7px; }
.rf-log-item { display: flex; gap: 8px; font-size: 11.5px; line-height: 1.45; color: var(--ink-2); padding: 4px 0; border-bottom: 1px dashed var(--line); }
.rf-log-item:last-child { border-bottom: none; }
.rf-log-n { flex: none; width: 17px; height: 17px; border-radius: 50%; background: var(--blue-tint); color: var(--blue); font-size: 10px; font-weight: 600; display: grid; place-items: center; }
.rf-toggle.on { border-color: var(--blue); color: var(--blue); background: var(--blue-tint); }
/* Keep the "Ask Sanyu" bubble clear of the refinement rail on a wide screen. */
@media (min-width: 1081px) { .app.rail-open .dc-fab { right: 356px; } }
@media (max-width: 1080px) {
  /* minmax(0,…) not 1fr: a 1fr track floors at min-content, and a wide
     markdown table would then push the whole page sideways. */
  .doc-layout.with-rail { grid-template-columns: minmax(0, 1fr); padding-right: 0; }
  .doc-rail { position: static; max-height: none; margin: 0 auto 24px; width: calc(100% - 28px); max-width: 880px; }
}

/* Free-text "ask for any document" box */
.doc-req { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-1); margin-bottom: 18px; }
.doc-req-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.doc-req-row { display: flex; gap: 10px; align-items: flex-end; }
.doc-req-ta { flex: 1; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 10px 12px; font-family: inherit; font-size: 14px; line-height: 1.5; resize: vertical; min-height: 52px; background: var(--surface); }
.doc-req-ta:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.doc-or { display: flex; align-items: center; text-align: center; color: var(--muted-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; margin: 4px 0 14px; }
.doc-or::before, .doc-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.doc-or span { padding: 0 12px; }
@media (max-width: 560px) { .doc-req-row { flex-direction: column; align-items: stretch; } }

/* Document references / footnotes */
.doc-refs { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.doc-refs-title { font-family: 'Newsreader', serif; font-weight: 600; font-size: 15px; margin-bottom: 10px; color: var(--ink); }
.doc-refs-grp { margin-bottom: 11px; }
.doc-refs-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.doc-refs-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.doc-refs-list { margin: 0; padding-left: 20px; font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.doc-refs-list li { margin-bottom: 3px; }

/* Mode tabs (centered, Claude-desktop style) */
.modeseg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 3px; gap: 2px; }
.modeseg-btn { display: inline-flex; align-items: center; gap: 6px; border: none; background: none; color: var(--muted); font-size: 12.5px; font-weight: 500; padding: 5px 12px; border-radius: 6px; }
.modeseg-btn svg { width: 15px; height: 15px; }
.modeseg-btn:hover { color: var(--ink-2); }
.modeseg-btn.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.tb-lbl { font-size: 12px; color: var(--muted); margin-right: 6px; }
@media (max-width: 680px) {
  .modeseg-btn span { display: none; }
  .modeseg-btn { padding: 7px 11px; }
  .modeseg-btn svg { width: 17px; height: 17px; }
  .seg button { padding: 5px 9px; font-size: 11.5px; }
  .ghost-btn { padding: 6px 9px; }
}

/* ───────── Explore (data browser + AI insight) ───────── */
.ex-scroll { overflow: hidden; padding: 0; }
.ex-wrap { display: grid; grid-template-columns: 300px 1fr; height: 100%; }
.ex-left { border-right: 1px solid var(--line); padding: 14px 12px; display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); }
.ex-searchbar { margin-bottom: 10px; }
.ex-search { width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 9px 11px; font-family: inherit; font-size: 13px; background: var(--surface); }
.ex-search:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.ex-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.ex-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 11.5px; color: var(--ink-2); }
.ex-chip.on { background: var(--blue-tint); border-color: var(--blue); color: var(--blue); }
.ex-chip.admin-off { opacity: .5; text-decoration: line-through; cursor: not-allowed; }
.ex-results { overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 2px; }
.ex-result { text-align: left; border: none; background: none; padding: 7px 9px; border-radius: var(--r-sm); display: flex; flex-direction: column; gap: 2px; }
.ex-result:hover { background: rgba(28,26,22,0.04); }
.ex-result.on { background: var(--blue-tint); }
.ex-r-label { font-size: 12.5px; color: var(--ink-2); line-height: 1.3; }
.ex-r-meta { font-size: 10.5px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .04em; }
.ex-detail { padding: 22px 26px; overflow-y: auto; min-width: 0; }
.ex-empty { color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; height: 100%; min-height: 320px; padding: 30px; }
.ex-empty-ico { color: var(--muted-2); opacity: .5; }
.ex-empty p { max-width: 360px; font-size: 13.5px; line-height: 1.6; }
.ex-view { max-width: 760px; }
.ex-title { font-family: 'Newsreader', serif; font-weight: 500; font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
.ex-src { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.ex-views { display: inline-flex; gap: 2px; background: var(--surface-3); border-radius: 7px; padding: 3px; margin-bottom: 14px; }
.ex-vbtn { border: none; background: none; color: var(--muted); font-size: 12px; font-weight: 500; padding: 5px 11px; border-radius: 5px; }
.ex-vbtn.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.ex-chart { margin-bottom: 16px; }
.ex-insight { margin: 4px 0 18px; }
.ex-insight-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--blue); background: var(--blue-tint); color: var(--blue); border-radius: var(--r-md); padding: 9px 14px; font-size: 13px; font-weight: 500; }
.ex-insight-btn:hover:not(:disabled) { background: var(--blue); color: #fff; }
.ex-insight-btn svg { width: 15px; height: 15px; }
.ex-insight-text { border: 1px solid var(--cyan); background: var(--cyan-tint); border-radius: var(--r-md); padding: 13px 15px; }
.ex-insight-head { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); margin-bottom: 7px; }
.ex-insight-head svg { width: 14px; height: 14px; }
.ex-insight-text .bubble { font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.ex-insight-text .bubble p { margin: 0; }
.ex-context { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--cyan); border-radius: var(--r-md); padding: 11px 14px; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); margin-bottom: 14px; max-height: 200px; overflow-y: auto; white-space: pre-wrap; }
.ex-tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.ex-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.ex-table th, .ex-table td { border-bottom: 1px solid var(--line); padding: 7px 12px; text-align: left; white-space: nowrap; }
.ex-table thead th { background: var(--surface-3); font-weight: 600; color: var(--ink-2); position: sticky; top: 0; }
.ex-table td:nth-child(n+2), .ex-table th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
.ex-table tbody tr:last-child td { border-bottom: none; }
@media (max-width: 760px) {
  .ex-scroll { overflow-y: auto; }
  .ex-wrap { grid-template-columns: 1fr; height: auto; }
  .ex-left { border-right: none; border-bottom: 1px solid var(--line); max-height: 44vh; }
  .ex-detail { padding: 16px; }
}

/* Table ⇄ chart toolbar + CSV download */
.viz-bar { display: flex; gap: 6px; margin-bottom: 7px; }
.viz-btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 6px; }
.viz-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-tint); }
.viz-btn svg { width: 13px; height: 13px; }
.viz-sel { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-family: inherit; font-size: 11px; font-weight: 500; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.viz-sel:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.viz-sel:disabled { opacity: .5; cursor: default; }
.viz-wrap { margin: 12px 0 16px; }
.viz-wrap table { margin: 0 !important; }
.chart .viz-bar { margin-bottom: 10px; }
.chart-as-table table { margin: 8px 0 0 !important; }
.table-as-chart .chart { margin: 0; }

/* Answer-style control: segmented (desktop) / icon dropdown (mobile) */
.style-wrap { position: relative; display: inline-flex; }
.style-menu-btn { display: none; }
.style-menu { right: 0; }
.style-menu-btn .sm-cur { font-size: 12px; }
.menu-item.on { background: var(--blue-tint); color: var(--blue); }
@media (max-width: 680px) {
  .style-seg { display: none; }
  .style-menu-btn { display: inline-flex; }
}

/* Source hover card (replaces the native title tooltip) */
.src-card-pop { position: fixed; display: none; z-index: 90; pointer-events: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: 0 10px 30px rgba(15,22,32,.18); padding: 10px 13px; max-width: 250px; }
.scp-name { font-weight: 600; font-size: 12.5px; color: var(--ink); line-height: 1.35; margin-bottom: 5px; }
.scp-meta { font-size: 11px; color: var(--blue); margin-bottom: 2px; }
.scp-yrs { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scp-note { font-size: 11px; color: #7a5c10; margin-top: 6px; line-height: 1.5; }
/* Brand hover card (SANYU acronym + what it is) */
.brand-card-pop { position: fixed; display: none; z-index: 90; pointer-events: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: 0 10px 30px rgba(15,22,32,.18); padding: 12px 14px; max-width: 280px; }
.bcp-name { font-family: 'Newsreader', serif; font-weight: 500; font-size: 17px; color: var(--ink); line-height: 1; }
.bcp-full { font-size: 11.5px; font-weight: 600; color: var(--blue); margin: 5px 0 7px; line-height: 1.35; }
.bcp-desc { font-size: 11.5px; color: var(--ink-2); line-height: 1.5; }
.bcp-hint { font-size: 10.5px; color: var(--muted-2); margin-top: 8px; text-transform: uppercase; letter-spacing: .08em; }

/* Sidebar footer + About modal */
.side-foot { gap: 7px; }
.foot-status { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-about { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 11px; padding: 3px 9px; border-radius: 999px; flex: none; }
.foot-about:hover { border-color: var(--blue); color: var(--blue); }
.modal-overlay { position: fixed; inset: 0; background: rgba(15,22,32,.42); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-card { position: relative; background: var(--surface); border-radius: var(--r-lg); box-shadow: 0 20px 60px rgba(15,22,32,.3); max-width: 480px; width: 100%; padding: 26px 28px; max-height: 86vh; overflow-y: auto; }
.modal-close { position: absolute; top: 12px; right: 12px; border: none; background: none; color: var(--muted); font-size: 15px; padding: 5px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--surface-3); color: var(--ink); }
.about-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.about-brand img { width: 40px; height: 40px; object-fit: contain; }
.about-name { font-family: 'Newsreader', serif; font-weight: 500; font-size: 24px; line-height: 1; }
.about-sub { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.about-full { font-weight: 600; color: var(--blue); font-size: 14px; margin: 0 0 12px; }
.about-p { color: var(--ink-2); font-size: 13.5px; line-height: 1.6; margin: 0 0 16px; }
.about-srctitle { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.about-srclist { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.about-srcchip { background: var(--paper-2); color: var(--ink-2); font-size: 11.5px; border-radius: 5px; padding: 3px 9px; }
.about-foot { color: var(--muted-2); font-size: 11.5px; margin: 0; }

/* Doc-mode chat: floating button + slide-in drawer */
.dc-fab { position: fixed; right: 18px; bottom: 18px; z-index: 45; display: inline-flex; align-items: center; gap: 8px; background: var(--blue); color: #fff; border: none; border-radius: 999px; padding: 11px 16px; font-size: 13px; font-weight: 500; box-shadow: 0 8px 24px rgba(30,111,163,.34); }
.dc-fab:hover { background: var(--blue-2); }
.dc-fab svg { color: #fff; }
.dc-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw; background: var(--surface); border-left: 1px solid var(--line); z-index: 60; display: flex; flex-direction: column; box-shadow: -12px 0 44px rgba(15,22,32,.16); }
.dc-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); font-family: 'Newsreader', serif; font-weight: 600; font-size: 16px; }
.dc-close { border: none; background: none; color: var(--muted); font-size: 14px; padding: 4px 8px; border-radius: 5px; }
.dc-close:hover { background: var(--surface-3); color: var(--ink); }
.dc-scroll { flex: 1; overflow-y: auto; padding: 14px 16px; }
.dc-thread.thread { max-width: none; margin: 0; padding: 0; }
.dc-composer { border-top: 1px solid var(--line); padding: 11px 14px; }

@media print {
  @page { margin: 18mm 16mm; }
  .dc-fab, .dc-drawer, .doc-rail, .viz-bar { display: none !important; }
  .doc-layout, .doc-layout.with-rail { display: block !important; max-width: none !important; padding: 0 !important; }
  .sidebar, .topbar, .inspector, .composer, .suggest, .nav-overlay, .nav-toggle,
  .tpl-grid, .field, .gen-btn, .gen-card, .answer-meta, .empty-note, .cursor { display: none !important; }
  html, body, .app, .main, .workspace, .center, .scroll, .doc-pane {
    height: auto !important; max-height: none !important; overflow: visible !important;
    background: #fff !important; display: block !important; margin: 0 !important; padding: 0 !important;
  }
  .doc-pane { max-width: none !important; }
  .doc-output, .doc-output.report { border: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; background: #fff !important; }
  .doc-header { border-bottom: 2px solid #1e6fa3 !important; padding-bottom: 10pt !important; margin-bottom: 16pt !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-header img { width: 46px !important; height: 46px !important; }
  .doc-header .dh-org { color: #1e6fa3 !important; }
  .doc-output.report .bubble { font-family: 'Newsreader', Georgia, serif !important; font-size: 11.5pt !important; line-height: 1.5 !important; color: #000 !important; }
  .bubble h1 { font-size: 21pt !important; margin: 0 0 6pt !important; line-height: 1.15; }
  .bubble h2 { font-size: 14pt !important; border-bottom: 1px solid #9aa3ad; padding-bottom: 3pt; margin: 15pt 0 7pt !important; break-after: avoid; }
  .bubble h3 { font-size: 12pt !important; margin: 12pt 0 5pt !important; break-after: avoid; }
  .bubble p, .bubble li { orphans: 3; widows: 3; }
  /* A print page is ~794px wide, so the <=860px mobile rule (block + nowrap +
     overflow-x) would otherwise apply and CLIP the right-hand columns of a wide
     table off the page. Put tables back to normal, wrapping layout for print. */
  .bubble table { font-size: 9.5pt !important; border: 1px solid #333 !important; break-inside: avoid;
    display: table !important; width: 100% !important; table-layout: fixed; overflow: visible !important; white-space: normal !important; }
  .bubble th, .bubble td { border: 1px solid #9aa3ad !important; padding: 4pt 7pt !important;
    white-space: normal !important; overflow-wrap: break-word; }
  .bubble thead th { background: #edf0f3 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chart { break-inside: avoid; border: 1px solid #ccc !important; padding: 8pt 10pt !important; }
  .bar-fill, .avatar.ai, .avatar.user { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000 !important; text-decoration: none; }
}

/* ---------- account / sign-in (sidebar) ---------- */
.account { position: relative; border-top: 1px solid var(--line); padding: 8px 2px 2px; margin-top: 6px; }
.signin-btn { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: 12.5px; font-weight: 500; padding: 8px 10px; border-radius: var(--r-md); }
.signin-btn:hover { border-color: var(--blue); color: var(--blue); }
.signin-btn svg { vertical-align: middle; }
.acct-about-link { display: block; width: 100%; margin-top: 6px; border: none; background: none; color: var(--muted); font-size: 11.5px; padding: 4px; border-radius: 6px; cursor: pointer; }
.acct-about-link:hover { color: var(--blue); }
/* Compact account: avatar + name; click opens the menu below. */
.acct-btn { display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0; border: 1px solid transparent; background: none; padding: 6px 7px; border-radius: var(--r-md); text-align: left; cursor: pointer; }
.acct-btn:hover { background: rgba(28,26,22,0.04); }
.account.open .acct-btn { background: rgba(28,26,22,0.05); border-color: var(--line); }
.acct-avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.acct-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-chev { flex: none; color: var(--muted-2); display: grid; place-items: center; transition: transform .16s ease; }
.acct-chev.open { transform: rotate(180deg); }
.acct-chev svg { width: 14px; height: 14px; }
/* Dropdown opens upward (account sits at the sidebar foot). */
.acct-menu { position: absolute; left: 2px; right: 2px; bottom: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 10px 34px rgba(15,22,32,.16); z-index: 40; padding: 5px; }
.acct-menu-id { padding: 7px 9px 9px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.acct-menu-name { font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-menu-email { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: none; background: none; padding: 8px 9px; font-size: 12.5px; color: var(--ink-2); border-radius: 6px; cursor: pointer; }
.acct-menu-item:hover { background: var(--blue-tint); color: var(--blue); }
.acct-menu-item svg { width: 16px; height: 16px; flex: none; }
.acct-menu-sep { height: 1px; background: var(--line); margin: 5px 0; }

/* ---------- login modal ---------- */
.login-modal { max-width: 380px; }
.login-hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0 0 14px; }
.login-err { background: var(--terra-tint); color: var(--terra); font-size: 12.5px; padding: 8px 11px; border-radius: var(--r-sm); margin-bottom: 12px; }
.login-field { display: block; margin-bottom: 12px; }
.login-field > span { display: block; font-size: 12px; color: var(--ink-2); font-weight: 500; margin-bottom: 5px; }
.login-input { width: 100%; box-sizing: border-box; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 9px 11px; font-size: 13.5px; font-family: inherit; background: var(--surface); }
.login-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.login-submit { width: 100%; background: var(--ink); color: #fff; border: none; border-radius: var(--r-md); padding: 10px 14px; font-size: 13.5px; font-weight: 600; margin-top: 4px; }
.login-submit:hover { background: var(--ink-2); }
.login-submit:disabled { opacity: .6; }

/* ---------- admin usage dashboard ---------- */
.tb-title { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.adm-days { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 5px 8px; font-size: 12px; color: var(--ink-2); font-family: inherit; }
.admin-pane { max-width: 940px; margin: 0 auto; padding: 18px 22px 60px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 14px 0 4px; }
.stat-card { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 13px 15px; }
.stat-val { font-family: 'Newsreader', serif; font-size: 26px; font-weight: 500; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
/* "My usage" modal */
.usage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.usage-sub { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.usage-alltime { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; font-size: 12px; color: var(--ink-2); margin: 14px 0 4px; }
.usage-note { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 12px 0 0; }
.usage-limits { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
/* Vague rate-limit usage meters (blue → red, no numbers) */
.umeters { display: flex; flex-direction: column; gap: 8px; }
.umeter-rows { display: flex; flex-direction: column; gap: 7px; }
.umeter { display: grid; grid-template-columns: 64px 1fr; gap: 9px; align-items: center; }
.umeter-lbl { font-size: 11px; color: var(--muted); }
.umeter-track { height: 7px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.umeter-fill { display: block; height: 100%; border-radius: 99px; transition: width .4s ease, background .4s ease; }
.umeter-exempt { font-size: 11.5px; color: var(--muted); }
.umeter-nudge { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; padding: 2px 0; color: var(--blue); font-size: 11.5px; font-weight: 500; cursor: pointer; }
.umeter-nudge svg { width: 13px; height: 13px; }
.account .umeters { margin-bottom: 8px; }
/* Full SANYU name on the landing screen */
.landing-full { font-size: 12.5px; letter-spacing: .02em; color: var(--muted); margin: -2px 0 16px; font-style: italic; }
.adm-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.adm-block { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 13px 15px; margin-top: 18px; }
.adm-cols .adm-block { margin-top: 0; }
.adm-h { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 11px; }
.adm-h svg { vertical-align: middle; color: var(--blue); }
.adm-bars { display: flex; flex-direction: column; gap: 7px; }
.adm-bar-row { display: grid; grid-template-columns: 120px 1fr 46px; gap: 10px; align-items: center; font-size: 12px; }
.adm-bar-lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adm-bar-track { background: var(--surface-3); height: 14px; border-radius: 4px; overflow: hidden; }
.adm-bar-fill { display: block; height: 100%; background: var(--blue); border-radius: 4px; }
.adm-bar-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .adm-cols { grid-template-columns: 1fr; } }
/* Rate-limit editor */
.rl-note { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 0 0 12px; }
.rl-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; cursor: pointer; }
.rl-table th { text-align: center; }
.rl-table th:first-child, .rl-table td.rl-act { text-align: left; text-transform: capitalize; font-weight: 500; color: var(--ink-2); }
.rl-table td { text-align: center; }
.rl-num { width: 72px; padding: 5px 7px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.rl-num:focus { outline: none; border-color: var(--blue); }
.rl-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.rl-msg { font-size: 12px; color: var(--muted); }
/* Admin: publication source switches */
.src-adm-row { border-bottom: 1px solid var(--line); padding: 2px 0; }
.src-adm-row:last-of-type { border-bottom: none; }
.src-adm-row .src-toggle { padding: 8px 4px; font-size: 13px; }
.src-adm-row .src-toggle:disabled { opacity: .6; }
.src-adm-tables { flex: none; font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.src-adm-note { display: block; width: 100%; margin: 0 0 10px; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-2); font-size: 12px; line-height: 1.5; font-family: inherit; resize: vertical; }
.src-adm-note:focus { outline: none; border-color: var(--blue); }
.rl-top { margin-top: 18px; }
.rl-sub { font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 16px 0 7px; }
.rl-iprow { display: flex; gap: 18px; flex-wrap: wrap; }
.rl-iprow label { font-size: 12.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; }

/* ───────── Admin: section nav + WhatsApp bridge ───────── */
/* The dashboard grew from one page into four distinct jobs (usage, WhatsApp,
   sources, limits), so it carries its own nav rail beside the content. */
.admin-main .adm-body { display: grid; grid-template-columns: 190px 1fr; flex: 1; min-height: 0; }
.adm-nav { border-right: 1px solid var(--line); background: var(--surface-2); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.adm-nav-h { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 0 8px 8px; }
.adm-nav-item { display: block; width: 100%; text-align: left; border: none; background: none; border-radius: var(--r-sm); padding: 8px 10px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.adm-nav-item:hover { background: rgba(28,26,22,0.05); }
.adm-nav-item.on { background: var(--blue-tint); color: var(--blue-2); }
.adm-nav-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.adm-nav-item.back { color: var(--muted); font-weight: 400; }
.adm-scroll { min-height: 0; }

/* Status pills across the top of the WhatsApp panel. */
.wa-pills { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 2px; }
.wa-pill { font-size: 11.5px; font-weight: 500; padding: 4px 10px; border-radius: 100px; border: 1px solid var(--line); }
.wa-pill.ok { background: #eaf5ef; border-color: #cfe6da; color: var(--green); }
.wa-pill.off { background: var(--terra-tint); border-color: #f2d3ce; color: var(--terra); }
.wa-pill.warn { background: #fdf4e1; border-color: #f0e0b8; color: #96700f; }

/* Setup checklist — which of the prerequisites is actually missing. */
.wa-steps { list-style: none; margin: 0; padding: 0; }
.wa-steps li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.wa-steps li:first-child { border-top: none; }
.wa-step-mark { flex: none; width: 18px; height: 18px; border-radius: 100px; display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.wa-steps li.done .wa-step-mark { background: #eaf5ef; color: var(--green); }
.wa-steps li.todo .wa-step-mark { background: var(--surface-3); color: var(--muted); }
.wa-steps li.done strong { color: var(--muted); font-weight: 500; }
.wa-step-detail { font-size: 12px; color: var(--muted); line-height: 1.55; margin-top: 2px; word-break: break-word; }
.wa-note { font-size: 12px; color: var(--ink-2); line-height: 1.6; background: var(--blue-tint); border-radius: var(--r-sm); padding: 10px 12px; margin: 14px 0 0; }

/* Controls */
.wa-switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 18px; margin-bottom: 6px; }
.wa-check { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; align-items: start; font-size: 12.5px; padding: 5px 0; }
.wa-check input { margin-top: 2px; }
.wa-check span { font-weight: 500; color: var(--ink-2); }
.wa-check em { grid-column: 2; font-style: normal; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.wa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 18px; margin-top: 12px; }
.wa-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 18px; }
.wa-field { display: flex; flex-direction: column; gap: 4px; }
.wa-lbl { font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.wa-hint { font-style: normal; font-size: 11px; color: var(--muted); line-height: 1.5; }
.wa-inp { border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); padding: 7px 9px; font: inherit; font-size: 12.5px; color: var(--ink); width: 100%; }
.wa-inp:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-tint); }
.wa-area { resize: vertical; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; }
.wa-num { max-width: 130px; }
.wa-sub { font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 18px 0 8px; }

/* Simulator + test send */
.wa-simrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wa-simrow .wa-inp { flex: 1; min-width: 180px; }
.wa-simout { margin-top: 12px; }
.wa-simmeta { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
/* Deliberately shaped like a chat bubble: the point of the simulator is to see
   what the message will actually look like on a phone. */
.wa-bubble { background: #e7fbd6; border: 1px solid #d3f0bd; border-radius: 10px 10px 10px 2px; padding: 9px 12px; margin-bottom: 7px; max-width: 460px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.wa-bubble.media { background: var(--surface-3); border-color: var(--line); font-family: 'JetBrains Mono', monospace; font-size: 11.5px; }
.wa-bubble-note { font-size: 10.5px; color: var(--muted); margin-top: 5px; }
.wa-skip { font-size: 12.5px; color: var(--terra); background: var(--terra-tint); border-radius: var(--r-sm); padding: 9px 12px; }

/* Activity tables */
.wa-badge { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 100px; text-transform: capitalize; }
.wa-badge.done { background: #eaf5ef; color: var(--green); }
.wa-badge.queued { background: var(--blue-tint); color: var(--blue-2); }
.wa-badge.running { background: #fdf4e1; color: #96700f; }
.wa-badge.failed { background: var(--terra-tint); color: var(--terra); }
.wa-badge.cancelled { background: var(--surface-3); color: var(--muted); }
.wa-skiptag { font-size: 10.5px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.wa-err { font-size: 11px; color: var(--terra); margin-top: 3px; line-height: 1.45; }
.wa-q { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-blocked td { opacity: 0.55; }
.ghost-btn.tiny { padding: 3px 8px; font-size: 11px; }

@media (max-width: 900px) {
  /* The nav rail becomes a horizontal strip rather than eating half the width. */
  .admin-main .adm-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .adm-nav { flex-direction: row; border-right: none; border-bottom: 1px solid var(--line); overflow-x: auto; padding: 8px 10px; align-items: center; }
  .adm-nav-h, .adm-nav-foot { display: none; }
  .adm-nav-item { width: auto; white-space: nowrap; }
  .wa-q { max-width: 180px; }
}
