/* A calm chat workspace: a light-blue canvas, a slim sidebar, white surfaces with soft shadows, one ink-blue
   accent (the blue of the Excel headers). Light and dark themes from the same tokens: the system's choice, or
   the one picked in the sidebar (html[data-theme]). */
:root {
  --bg: #dce9f5; --side: #e9f1f9; --top: #fafcfe; --surface: #ffffff; --surface-2: #f3f7fb; --field: #ffffff;
  --ink: #172233; --ink-2: #384759; --muted: #536276; --rule: #d3dfeb; --rule-2: #b7c7d9;
  --accent: #1d5c96; --accent-2: #164a7a; --accent-ink: #ffffff; --accent-wash: #e3eef8; --bubble: #cadff2;
  --select: #d2e4f5; --hover: rgba(29, 92, 150, .07); --chip: #d6e3ef;
  --mark: #fff0a3; --mark-edge: #c9a400; --red: #b42318; --red-wash: #fdeceb; --green: #2f7a45; --amber: #b7791f;
  --zebra: #f6f9fc; --ro: #f2f5f9;
  --shadow-sm: 0 1px 2px rgba(23, 34, 51, .05), 0 2px 10px rgba(23, 34, 51, .05);
  --shadow-md: 0 6px 24px rgba(23, 34, 51, .10);
  --shadow: 0 22px 60px rgba(23, 34, 51, .24);
  --sans: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --col: 840px; /* width of the conversation */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1621; --side: #131b27; --top: #141d2a; --surface: #1a2432; --surface-2: #17202c; --field: #121a25;
    --ink: #e6edf5; --ink-2: #c0cad6; --muted: #93a0b0; --rule: #263244; --rule-2: #36455c;
    --accent: #6aa6e0; --accent-2: #8bbbe8; --accent-ink: #0b1624; --accent-wash: #1b2c41; --bubble: #223a57;
    --select: #1f324a; --hover: rgba(106, 166, 224, .09); --chip: #1f2c3d;
    --mark: #4a3f0f; --mark-edge: #c9a400; --red: #f0857c; --red-wash: #3a1d1b; --green: #79c08a; --amber: #e0b25a;
    --zebra: #1d2735; --ro: #1c2532;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow-md: 0 8px 28px rgba(0, 0, 0, .4); --shadow: 0 22px 60px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1621; --side: #131b27; --top: #141d2a; --surface: #1a2432; --surface-2: #17202c; --field: #121a25;
  --ink: #e6edf5; --ink-2: #c0cad6; --muted: #93a0b0; --rule: #263244; --rule-2: #36455c;
  --accent: #6aa6e0; --accent-2: #8bbbe8; --accent-ink: #0b1624; --accent-wash: #1b2c41; --bubble: #223a57;
  --select: #1f324a; --hover: rgba(106, 166, 224, .09); --chip: #1f2c3d;
  --mark: #4a3f0f; --mark-edge: #c9a400; --red: #f0857c; --red-wash: #3a1d1b; --green: #79c08a; --amber: #e0b25a;
  --zebra: #1d2735; --ro: #1c2532;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow-md: 0 8px 28px rgba(0, 0, 0, .4); --shadow: 0 22px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* An application page: only the thread, the lists and the tables scroll, never the page itself. */
body { margin: 0; font: 14px/1.55 var(--sans); color: var(--ink); background: var(--bg); overflow: hidden;
  -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1 { font-size: 14.5px; font-weight: 600; line-height: 1.3; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h2 { font-size: 17px; font-weight: 650; line-height: 1.3; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 14.5px; font-weight: 600; line-height: 1.35; margin: 0; }
h4 { font-size: 13.5px; font-weight: 600; line-height: 1.35; margin: 0; }
a { color: var(--accent); }
.icon { width: 18px; height: 18px; flex: none; display: block; }
.label { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; }

input[type=text], input[type=search], input[type=number], textarea, select {
  border: 1px solid var(--rule-2); border-radius: 8px; background: var(--field); padding: 7px 10px; }
input[type=text]:focus, input[type=search]:focus, input[type=number]:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--hover); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--rule-2);
  background: var(--surface); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--ink-2); background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--hover); border-color: transparent; }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer; padding: 0; text-decoration: none; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.danger:hover { color: var(--red); background: var(--red-wash); }
.icon-btn.xs { width: 28px; height: 28px; }
.icon-btn.xs .icon { width: 15px; height: 15px; }
.icon-btn.done { color: var(--green); }
.x { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.x:hover { color: var(--ink); background: var(--hover); }
.linklike { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12.5px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; align-self: flex-start; text-align: left; }
.qhead-actions .linklike { color: var(--red); }

/* ------------------------------------------------------------------ layout: sidebar + chat */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); height: 100vh; }
body.side-collapsed .app { grid-template-columns: minmax(0, 1fr); }
body.side-collapsed .sidebar { display: none; }
.sidebar { display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 8px; border-right: 1px solid var(--rule);
  background: var(--side); min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 6px 6px; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand b { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: var(--accent); color: var(--accent-ink); }
.logo .icon { width: 17px; height: 17px; }
.new-chat { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; border-radius: 10px; padding: 9px 12px;
  background: var(--chip); color: var(--ink); font-weight: 500; cursor: pointer; text-align: left; }
.new-chat:hover { background: var(--select); }
.new-chat .icon { width: 17px; height: 17px; }
.history { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 1px; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.side-label { padding: 14px 10px 4px; }
.empty-history { padding: 14px 10px; }
.conv { display: flex; align-items: center; border-radius: 8px; }
.conv:hover { background: var(--hover); }
.conv.on { background: var(--select); }
.conv-open { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 7px 10px; cursor: pointer;
  display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-2); }
.conv.on .conv-open { color: var(--ink); font-weight: 500; }
.conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 9px; opacity: 0; font-size: 16px; line-height: 30px; border-radius: 6px; }
.conv:hover .conv-x, .conv.on .conv-x, .conv-x:focus-visible { opacity: 1; }
.conv-x:hover { color: var(--red); }
.side-foot { display: flex; align-items: center; gap: 2px; border-top: 1px solid var(--rule); padding: 8px 2px 0 6px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rule-2); flex: none; }
.status[data-state="online"] .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(47, 122, 69, .15); }
.status[data-state="degraded"] .dot { background: var(--amber); }
.status[data-state="offline"] .dot { background: var(--red); }
.status[data-state="offline"] { color: var(--red); }
.scrim { display: none; }

/* Every row has its place: a hidden alert must not move the thread into an auto-height row. */
.chat { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0; min-height: 0; height: 100vh; }
.chat-head { grid-row: 1; }
.chat > .alert { grid-row: 2; }
.thread { grid-row: 3; }
.composer { grid-row: 4; }
.chat-head { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 16px 0 22px; border-bottom: 1px solid var(--rule);
  background: var(--top); min-width: 0; }
.chat-head h1 { flex: 1; min-width: 0; }
#menu { display: none; margin-left: -8px; }
body.side-collapsed #menu { display: inline-grid; }
.model-pill { display: inline-flex; align-items: center; gap: 7px; max-width: 280px; border: 1px solid var(--rule); border-radius: 9px;
  background: var(--surface); padding: 6px 10px 6px 11px; font-size: 13px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow-sm); }
.model-pill:hover { border-color: var(--rule-2); }
.model-pill .icon { width: 15px; height: 15px; color: var(--accent); }
.model-pill .icon:last-child { color: var(--muted); width: 14px; height: 14px; }
.model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.alert { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin: 12px auto 0; width: min(var(--col), calc(100% - 48px));
  border: 1px solid var(--red); background: var(--red-wash); padding: 10px 14px; white-space: pre-line; border-radius: 10px; }
.alert.inline { display: block; margin: 8px 0 0; width: auto; }
.banner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-left: 3px solid var(--mark-edge);
  background: var(--accent-wash); padding: 8px 12px; font-size: 13px; margin: 8px 0; border-radius: 0 8px 8px 0; }

/* ------------------------------------------------------------------ thread */
.thread { overflow-y: auto; padding: 28px 24px 16px; display: flex; flex-direction: column; gap: 26px; scroll-behavior: auto; }
.msg { display: flex; gap: 14px; max-width: var(--col); width: 100%; margin: 0 auto; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { max-width: min(640px, 82%); background: var(--bubble); border-radius: 18px 18px 6px 18px; padding: 9px 15px; }
.msg .text { overflow-wrap: anywhere; }
.msg.user .text { white-space: pre-wrap; }
.msg .text.collapsed { max-height: 9.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.msg .files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg.user .chip { background: var(--surface); border-color: transparent; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--accent);
  background: var(--surface); box-shadow: var(--shadow-sm); margin-top: 1px; }
.avatar .icon { width: 17px; height: 17px; }
.msg.assistant .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.msg.assistant .text { font-size: 14.5px; line-height: 1.65; }
.skill-tag { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: -4px; }
.rich p { margin: 0 0 .65em; }
.rich p:last-child, .rich ul:last-child, .rich ol:last-child { margin-bottom: 0; }
.rich ul, .rich ol { margin: 0 0 .65em; padding-left: 22px; }
.rich li { margin: .2em 0; }
.rich li::marker { color: var(--muted); }
.rich .rich-title { font-weight: 650; margin-top: .4em; }
.rich code { font: 12.5px var(--mono); background: var(--surface); border: 1px solid var(--rule); border-radius: 5px; padding: 0 5px; }
.msg.kind-question .text { border-left: 3px solid var(--accent); padding-left: 12px; }
.msg.kind-error .text { color: var(--red); }
.msg.kind-error .avatar { color: var(--red); }
.msg.working .body { color: var(--ink-2); }
.msg.working progress { width: min(360px, 100%); }
.msg.working .avatar .icon { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.85); } }
.msg-cta { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-cta .btn { padding: 6px 12px; font-size: 13px; }
.msg-cta .icon { width: 15px; height: 15px; color: var(--accent); }
.msg-foot { display: flex; align-items: center; gap: 4px; margin-top: -4px; min-height: 28px; }
.msg-foot .icon-btn { opacity: .7; }
.msg-foot .icon-btn:hover, .msg-foot .icon-btn:focus-visible { opacity: 1; }
ul.notes, ul.caveats { margin: 0; padding-left: 20px; font-size: 12.5px; color: var(--muted); }
.lastrun { font-size: 12px; color: var(--muted); }
.lastrun.warn { color: var(--amber); }
.progress { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: 13px; }
.progress .elapsed { font: 600 12px var(--mono); color: var(--accent); }
.spinner { width: 13px; height: 13px; border: 2px solid var(--rule-2); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Welcome: what the assistant does, with example requests. */
.welcome { max-width: var(--col); width: 100%; margin: auto; padding: 4vh 0 2vh; display: flex; flex-direction: column; gap: 18px; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.hero .logo { width: 44px; height: 44px; border-radius: 13px; box-shadow: var(--shadow-md); }
.hero .logo .icon { width: 25px; height: 25px; }
.welcome h2 { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.hero p { margin: 0; max-width: 560px; }
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.skill { background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; padding: 14px 16px; display: flex;
  flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm); }
.skill:hover { border-color: var(--rule-2); box-shadow: var(--shadow-md); }
.skill-head { display: flex; align-items: center; gap: 10px; }
.skill-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent-wash); color: var(--accent); flex: none; }
.skill p { margin: 0; font-size: 13px; color: var(--muted); }
.examples { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.example { text-align: left; border: 1px solid var(--rule); background: var(--surface-2); border-radius: 9px; padding: 6px 10px;
  font-size: 12.5px; cursor: pointer; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.example:hover { border-color: var(--accent); color: var(--ink); }
.privacy { margin: 0; text-align: center; }

/* ------------------------------------------------------------------ cards (results) */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
.card.removed { opacity: .6; }
.card-empty { padding: 12px 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.card-titles { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.badge { font: 600 10.5px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); background: var(--accent-wash);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.version { font: 12px var(--mono); color: var(--muted); background: var(--surface-2); border: 1px solid var(--rule); border-radius: 999px; padding: 1px 8px; }
.card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card-body > div { display: flex; flex-direction: column; gap: 10px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--rule); background: var(--surface-2); }
.card-status:empty { display: none; }
.card-status { padding: 0 16px 12px; }
.lead { margin: 0; font-size: 14.5px; }
.meta { font-size: 12.5px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); background: var(--surface-2); border-radius: 999px;
  padding: 3px 10px; font-size: 12.5px; max-width: 100%; }
.chip.file.on { border-color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); }
.chip.error { border-color: var(--red); color: var(--red); background: var(--red-wash); }
.chip-name { border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.chip-info { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 15px; line-height: 1; }
.chip-x:hover { color: var(--red); }
.chip progress { width: 70px; height: 6px; }
.steps { margin: 0; padding-left: 20px; }
.findings { margin: 0; padding-left: 20px; }
.result { border-top: 1px solid var(--rule); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.more { padding: 4px 0; }

.table-scroll { overflow: auto; max-height: 420px; border: 1px solid var(--rule); border-radius: 10px; background: var(--field); }
.data-table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; width: max-content; min-width: 100%; }
.data-table th { position: sticky; top: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-align: left; padding: 7px 10px; white-space: nowrap; }
.data-table td { padding: 6px 10px; border-bottom: 1px solid var(--rule); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table tbody tr:nth-child(even) td { background: var(--zebra); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.st-estimated { background: var(--mark) !important; }
.data-table.compact td { max-width: 240px; }
.sheet-grid td { white-space: nowrap; }

.sheets { display: flex; flex-direction: column; }
.sheet-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.sheet-tab { border: 1px solid var(--rule); background: var(--surface-2); padding: 5px 12px; font-size: 12.5px; cursor: pointer;
  border-radius: 999px; color: var(--muted); }
.sheet-tab:hover { color: var(--ink); border-color: var(--rule-2); }
.sheet-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.sheets.big .table-scroll { max-height: 70vh; }

.chart-box { margin: 0; display: flex; flex-direction: column; gap: 4px; max-width: 720px; }
.chart { width: 100%; height: auto; }
.chart-label { font-size: 11px; fill: var(--muted); }
.chart-value { font-size: 11px; fill: var(--ink-2); }
.chart-bar { fill: var(--accent); }
.chart-bar.negative { fill: var(--red); }
.chart-grid { stroke: var(--rule); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.25; }
.chart-dot { fill: var(--accent); }

/* ------------------------------------------------------------------ composer */
.composer { padding: 4px 24px 12px; background: var(--bg); }
.composer-inner { position: relative; max-width: var(--col); margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.composer-box { border: 1px solid var(--rule); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-md); }
.composer-box:focus-within { border-color: var(--rule-2); box-shadow: var(--shadow-md), 0 0 0 3px var(--hover); }
#input { display: block; width: 100%; border: 0; border-radius: 22px 22px 0 0; resize: none; padding: 14px 18px 4px; background: transparent;
  font-size: 14.5px; line-height: 1.55; max-height: 40vh; box-shadow: none; }
#input:focus { outline: none; box-shadow: none; }
#input::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px 8px 8px; }
.pill { position: relative; display: inline-flex; align-items: center; gap: 4px; height: 32px; border: 1px solid var(--rule); border-radius: 999px;
  padding: 0 10px; font-size: 12.5px; color: var(--ink-2); background: var(--surface); cursor: pointer; white-space: nowrap; }
.pill:hover { border-color: var(--rule-2); }
.pill.on { border-color: var(--accent); background: var(--accent-wash); color: var(--accent); }
.pill > span > .icon { width: 15px; height: 15px; }
.pill select { appearance: none; -webkit-appearance: none; field-sizing: content; border: 0; background: transparent; padding: 0 16px 0 2px;
  font-size: 12.5px; font-weight: 500; color: inherit; cursor: pointer; max-width: 190px; text-overflow: ellipsis; }
.pill select:focus { box-shadow: none; }
.pill .chev { position: absolute; right: 9px; pointer-events: none; color: var(--muted); }
.pill .chev .icon { width: 13px; height: 13px; }
#idStart { width: 72px; padding: 2px 6px; border-radius: 6px; margin-left: 4px; }
#charCount { font-size: 11.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#charCount.over { color: var(--red); font-weight: 600; }
.send { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); }
.send:hover:not(:disabled) { background: var(--accent-2); }
.send:disabled { opacity: .45; cursor: not-allowed; }
.composer.empty .send:not(.stop) { background: var(--chip); color: var(--muted); }
.send .icon { width: 17px; height: 17px; stroke-width: 2.2; }
.send.stop { background: var(--ink); color: var(--surface); }
.send.stop .icon path { fill: currentColor; }
.composer-note { text-align: center; font-size: 11.5px; color: var(--muted); }
.follow-up { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--rule);
  border-left: 3px solid var(--accent); background: var(--surface); padding: 5px 10px; font-size: 12.5px; border-radius: 10px; }
.to-bottom { position: absolute; top: -46px; left: 50%; transform: translateX(-50%); width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--rule); border-radius: 50%; background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow-md); cursor: pointer; z-index: 2; }
.to-bottom:hover { color: var(--ink); border-color: var(--rule-2); }
.to-bottom .icon { width: 16px; height: 16px; }

/* "/" in the composer: choose a skill with the keyboard. */
.slash-menu { position: absolute; bottom: calc(100% + 8px); left: 0; width: min(440px, 100%); z-index: 5; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.slash-head { padding: 4px 10px 6px; }
.slash-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 10px; align-items: center; border: 0; background: none;
  text-align: left; padding: 7px 10px; border-radius: 9px; cursor: pointer; }
.slash-item .skill-icon { grid-row: span 2; width: 30px; height: 30px; }
.slash-item .skill-icon .icon { width: 16px; height: 16px; }
.slash-item b { font-weight: 600; font-size: 13px; }
.slash-item span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slash-item.on, .slash-item:hover { background: var(--hover); }
.slash-empty { padding: 10px; }

.drop-overlay { display: none; position: fixed; inset: 0; z-index: 60; background: rgba(29, 92, 150, .14); place-items: center; pointer-events: none;
  backdrop-filter: blur(2px); }
.drop-overlay div { display: flex; align-items: center; gap: 10px; border: 2px dashed var(--accent); background: var(--surface); padding: 24px 32px;
  border-radius: 16px; font-weight: 600; box-shadow: var(--shadow); }
.drop-overlay .icon { color: var(--accent); }
body.dropping .drop-overlay { display: grid; }

/* ------------------------------------------------------------------ workspace (full width over the chat) */
.workspace { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: grid; grid-template-rows: auto minmax(0, 1fr); }
.workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 52px; padding: 0 24px;
  border-bottom: 1px solid var(--rule); background: var(--top); }
.workspace-body { overflow: auto; padding: 16px 24px 32px; display: flex; flex-direction: column; gap: 12px; }
.workspace-foot { padding-top: 6px; }

/* ------------------------------------------------------------------ use cases (questions, review grid) */
.uc { display: flex; flex-direction: column; gap: 10px; }
.uc-questions { display: flex; flex-direction: column; gap: 12px; }
.uc-qhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.uc-row { border: 1px solid var(--rule); border-radius: 12px; background: var(--field); overflow: hidden; }
.uc-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 9px 14px;
  border-bottom: 1px solid var(--rule); background: var(--surface-2); }
.qhead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.qhead-actions { display: flex; align-items: baseline; gap: 12px; }
.tag { font: 600 11.5px var(--mono); color: var(--accent); background: var(--accent-wash); padding: 1px 7px; border-radius: 6px; }
.q { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(260px, 1.25fr); gap: 8px 24px; padding: 12px 14px; border-top: 1px solid var(--rule); }
.uc-row-head + .q { border-top: 0; }
.q-text { margin-top: 2px; }
.problem { margin-top: 6px; color: var(--red); font-size: 12.5px; }
.q-ctrl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.q-ctrl textarea { width: 100%; }
.q-ctrl input.value { width: 120px; }
.opt { border: 1px solid var(--rule-2); background: var(--field); border-radius: 999px; padding: 5px 13px; cursor: pointer; display: inline-flex;
  align-items: center; gap: 7px; }
.opt:hover { border-color: var(--accent); }
.opt.on { border-color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.skip { display: inline-flex; gap: 7px; align-items: center; margin-top: 8px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.skip input { accent-color: var(--accent); }
.q.skipped .q-ctrl { opacity: .35; }
.q.missing { background: var(--red-wash); }
.actionbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.lvl { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.bars { display: inline-flex; gap: 2px; }
.bars i { width: 4px; height: 11px; background: var(--rule-2); border-radius: 1px; }
.lvl-0 .bars i:nth-child(1), .lvl-1 .bars i:nth-child(-n+2), .lvl-2 .bars i { background: var(--accent); }

.statusline { display: flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: 10px; font-size: 13px; background: var(--field); overflow: hidden; }
.statusline span { padding: 6px 14px; border-right: 1px solid var(--rule); }
.statusline b { font-weight: 600; }
.sq { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border: 1px solid var(--rule-2); vertical-align: 0; border-radius: 2px; }
.sq.est { background: var(--mark); border-color: var(--mark-edge); }
.sq.err { background: var(--red-wash); border-color: var(--red); }
.sq.ok { background: var(--green); border-color: var(--green); }
.sq.ro { background: var(--ro); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.toolbar .filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.toolbar input[type=search] { width: 260px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); border: 1px solid var(--rule); border-radius: 10px; background: var(--field); }
.grid-table { border-collapse: separate; border-spacing: 0; font-size: 13px; width: max-content; min-width: 100%; }
.grid-table th { position: sticky; top: 0; z-index: 2; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-align: left;
  padding: 8px 12px; white-space: nowrap; border-right: 1px solid rgba(255, 255, 255, .2); }
.grid-table td { position: relative; padding: 8px 12px; vertical-align: top; background: var(--field); border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule); }
.grid-table tbody tr:nth-child(even) td { background: var(--zebra); }
.grid-table tbody tr:hover td { background: var(--accent-wash); }
.grid-table tbody tr td.st-estimated { background: var(--mark); }
.grid-table tbody tr td.st-estimated::after { content: "IA"; position: absolute; top: 3px; right: 4px; font: 700 8.5px var(--mono); color: var(--mark-edge); }
.grid-table tbody tr td.invalid { background: var(--red-wash); box-shadow: inset 0 0 0 2px var(--red); }
.grid-table td.ro { color: var(--muted); background: var(--ro); }
.grid-table tbody tr td.row-id { color: var(--ink); font: 600 12.5px var(--mono); }
.cell { overflow-wrap: anywhere; }
.w-xs .cell { width: 20px; }
.w-s .cell { width: 100px; }
.w-m .cell { width: 160px; }
.w-l .cell { width: 260px; }
.w-xl .cell { width: 360px; }
.grid-table .num .cell { text-align: right; font-variant-numeric: tabular-nums; }
.gain-pos { color: var(--green) !important; font-weight: 700; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.empty { color: var(--muted); }
td.editable { cursor: pointer; }
.grid-table .c0, .grid-table .c1, .grid-table .c2 { position: sticky; z-index: 1; }
.grid-table th.c0, .grid-table th.c1, .grid-table th.c2 { z-index: 3; }
.c0 { left: 0; text-align: center; }
.grid-table td.c0 { color: var(--muted); font: 11.5px var(--mono); background: var(--ro); }
.c1 { left: 45px; }   /* after # (20 + 25) */
.c2 { left: 230px; }  /* after ID (160 + 25) */
.grid-table td.c2:not(.invalid) { box-shadow: 2px 0 0 var(--rule-2); }
.row-del { display: block; margin: 4px auto 0; border: 0; background: none; padding: 0 3px; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; border-radius: 4px; }
.row-del:hover, .row-del:focus-visible { color: var(--red); background: var(--red-wash); }

/* ------------------------------------------------------------------ dialogs */
dialog { border: 1px solid var(--rule); border-radius: 16px; padding: 0; width: min(680px, calc(100vw - 32px)); background: var(--surface);
  color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15, 22, 33, .45); backdrop-filter: blur(2px); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid var(--rule); }
.dlg-body { padding: 14px 20px; display: grid; gap: 12px; }
.dlg-body .facts { margin: 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 10px; }
.dlg-body .facts dd.err { color: var(--red); }
.dlg-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--rule); background: var(--surface-2); }
#editorValue { width: 100%; min-height: 150px; resize: vertical; font-size: 14px; line-height: 1.55; }
#editorValue.size-s { min-height: 40px; height: 40px; }
#editorValue.size-m { min-height: 80px; height: 80px; }
#editorChoices { display: flex; flex-wrap: wrap; gap: 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; font-size: 12.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts code { font: 11.5px var(--mono); color: var(--ink-2); }
.picker-tools { display: flex; gap: 8px; }
#modelSearch { flex: 1; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--rule-2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font-size: 12.5px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule-2); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.model-list { max-height: 320px; overflow: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--field); }
.group-label { position: sticky; top: 0; z-index: 1; padding: 6px 12px; background: var(--surface-2); border-bottom: 1px solid var(--rule); }
.mrow { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; column-gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.mrow:last-child { border-bottom: 0; }
.mrow:hover { background: var(--hover); }
.mrow.on { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); }
.mrow input { grid-row: span 2; margin: 3px 0 0; accent-color: var(--accent); }
.mname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mname em { font-style: normal; font-weight: 600; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-left: 6px; }
.mspeed { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-2); text-align: right; white-space: nowrap; }
.msub { grid-column: 2 / 4; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { padding: 14px 10px; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ small screens: the sidebar slides in */
@media (max-width: 900px) {
  .app, body.side-collapsed .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar, body.side-collapsed .sidebar { display: flex; position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(300px, 86vw);
    transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .35); }
  #menu, body.side-collapsed #menu { display: inline-grid; }
  .chat-head { padding: 0 10px 0 16px; }
  .thread, .composer, .workspace-head, .workspace-body { padding-left: 12px; padding-right: 12px; }
  .thread { gap: 20px; padding-top: 18px; }
  .alert { width: calc(100% - 24px); }
  .q { grid-template-columns: 1fr; }
  .model-pill { max-width: 150px; }
  .msg { gap: 10px; }
  .msg.user .bubble { max-width: 90%; }
  .msg .avatar { width: 26px; height: 26px; }
  .skills { grid-template-columns: minmax(0, 1fr); }
  .welcome h2 { font-size: 22px; }
  .toolbar input[type=search] { width: 100%; }
}
@media (max-width: 600px) {
  .composer-note { display: none; }
  .pill select { max-width: 120px; }
  .composer { padding-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { }
  .spinner, .msg.working .avatar .icon { animation: none; }
}
