/* WOLF AI — the Workspace layout. Loaded after style.css; every rule that reaches into the
   classic screens is gated on :root[data-ui="chat"], so the classic layout is untouched.

   How it works: the classic screens are built from design tokens (--ink, --paper, --line…), so
   this file re-points those tokens at a zinc palette with one emerald accent and the evidence,
   review, search and activity screens re-skin themselves inside the new shell. Only the sidebar,
   the project page, the thread and Settings are new markup (.cw-*, built in chatui.js).

   Semantic colours are kept: --held (amber) still means "held", --danger still means an error. */

:root[data-ui="chat"] {
  --ink: #18181b; --ink-soft: #3f3f46; --muted: #63636b; --faint: #6b6b74;
  --paper: #fafafa; --surface: #ffffff; --sunk: #f4f4f5;
  --line: #e4e4e7; --line-strong: #d1d1d6;
  --primary: #18181b; --primary-text: #fafafa; --primary-hover: #2c2c31; --primary-active: #101012;
  --accent: #167352; --accent-hover: #0f5e42; --accent-soft: #e6f3ee;
  --highlight: #f1f1f3;
  --r: 12px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 12px 32px -14px rgba(24, 24, 27, .18);
  --cw-on-accent: #ffffff;
  --cw-side: #f4f4f5; --cw-bubble: #ececee; --cw-hover: rgba(24, 24, 27, .055); --cw-sel: rgba(24, 24, 27, .085);
  --cw-ease: cubic-bezier(.16, 1, .3, 1);
  --cw-shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 14px 36px -14px rgba(24, 24, 27, .16), 0 0 0 1px var(--line);
}
@media (prefers-color-scheme: dark) {
  :root[data-ui="chat"]:not([data-theme="light"]) {
    --ink: #f4f4f5; --ink-soft: #d4d4d8; --muted: #a1a1aa; --faint: #8f8f99;
    --paper: #111113; --surface: #1b1b1e; --sunk: #17171a;
    --line: #2a2a2f; --line-strong: #3b3b42;
    --primary: #f4f4f5; --primary-text: #18181b; --primary-hover: #ffffff; --primary-active: #d4d4d8;
    --accent: #5cc8a0; --accent-hover: #7ad6b4; --accent-soft: #12261f;
    --highlight: #222226; --scrim: rgba(0, 0, 0, .62);
    --shadow: 0 18px 44px -16px rgba(0, 0, 0, .7);
    --cw-on-accent: #0b0b0d; --cw-side: #0b0b0d; --cw-bubble: #26262a; --cw-hover: rgba(255, 255, 255, .06); --cw-sel: rgba(255, 255, 255, .09);
    --cw-shadow: 0 18px 44px -16px rgba(0, 0, 0, .7), 0 0 0 1px var(--line);
  }
}
:root[data-ui="chat"][data-theme="dark"] {
  --ink: #f4f4f5; --ink-soft: #d4d4d8; --muted: #a1a1aa; --faint: #8f8f99;
  --paper: #111113; --surface: #1b1b1e; --sunk: #17171a;
  --line: #2a2a2f; --line-strong: #3b3b42;
  --primary: #f4f4f5; --primary-text: #18181b; --primary-hover: #ffffff; --primary-active: #d4d4d8;
  --accent: #5cc8a0; --accent-hover: #7ad6b4; --accent-soft: #12261f;
  --highlight: #222226; --scrim: rgba(0, 0, 0, .62);
  --shadow: 0 18px 44px -16px rgba(0, 0, 0, .7);
  --cw-on-accent: #0b0b0d; --cw-side: #0b0b0d; --cw-bubble: #26262a; --cw-hover: rgba(255, 255, 255, .06); --cw-sel: rgba(255, 255, 255, .09);
  --cw-shadow: 0 18px 44px -16px rgba(0, 0, 0, .7), 0 0 0 1px var(--line);
}

:root[data-ui="chat"], :root[data-ui="chat"] body { height: 100%; overflow: hidden; }
:root[data-ui="chat"] #app { height: 100%; }

/* ---------------------------------------------------------------- classic screens, re-skinned */

:root[data-ui="chat"] .btn { border-radius: 999px; min-height: 38px; font-weight: 500; }
:root[data-ui="chat"] .btn.sm { min-height: 34px; }
:root[data-ui="chat"] .btn:hover { border-color: var(--line-strong); }
:root[data-ui="chat"] .btn.pri:hover { border-color: var(--primary-hover); }
:root[data-ui="chat"] .btn.link { border-radius: 0; }
:root[data-ui="chat"] .card, :root[data-ui="chat"] .modal .box { border-radius: 18px; }
:root[data-ui="chat"] .modal .box { box-shadow: var(--shadow); }
:root[data-ui="chat"] h1 { font-weight: 500; letter-spacing: -.035em; }
:root[data-ui="chat"] .page-heading { margin-bottom: 24px; }
:root[data-ui="chat"] .cw-page .wrap { padding: 24px 32px 96px; }
:root[data-ui="chat"] .cw-page .wrap.wide { max-width: 1280px; }
:root[data-ui="chat"] .matter-list { display: grid; gap: 8px; }
:root[data-ui="chat"] .matter-row, :root[data-ui="chat"] .matter-row:first-child, :root[data-ui="chat"] .matter-row:last-child {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
}
:root[data-ui="chat"] .matter-row:has(.mrow:hover) { background: var(--sunk); }
:root[data-ui="chat"] .mrow, :root[data-ui="chat"] .mrow:first-of-type, :root[data-ui="chat"] .mrow:last-of-type { border: 0; border-radius: inherit; }
:root[data-ui="chat"] .matter-icon, :root[data-ui="chat"] .msel { border-radius: 12px; }
:root[data-ui="chat"] .stepper { border-bottom-color: var(--line); }
:root[data-ui="chat"] .evidence-nav { border-bottom-color: var(--line); }

/* ---------------------------------------------------------------- shell */

.cw { display: flex; height: 100dvh; background: var(--paper); color: var(--ink); font-size: 15px; }
.cw .i { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:where(.cw) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:where(.cw) button:disabled { cursor: default; opacity: .4; }
.cw-spacer { flex: 1; }
.cw-label { white-space: nowrap; }
.cw-cap { color: var(--muted); font-size: 13px; line-height: 1.5; }
.cw-fine { margin: 0; padding: 8px 0 12px; text-align: center; font-size: 12px; color: var(--muted); }
.cw-when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cw-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; font-weight: 500; }
.cw-link:hover { color: var(--accent-hover); }
.cw-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.cw-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--muted); flex: none; transition: background-color .2s var(--cw-ease), color .2s var(--cw-ease); }
.cw-icon:hover:not(:disabled) { background: var(--cw-hover); color: var(--ink); }
.cw-icon-sm { width: 28px; height: 28px; border-radius: 8px; }
.cw-icon-sm .i { width: 16px; height: 16px; }
.cw-only-mobile { display: none; }

/* Sidebar */
.cw-side { width: 260px; flex: none; display: flex; flex-direction: column; gap: 1px; padding: 8px 6px; background: var(--cw-side); border-right: 1px solid var(--line); overflow: hidden; transition: width .3s var(--cw-ease); }
.cw-side-head { display: flex; align-items: center; gap: 4px; height: 44px; padding: 0 3px; flex: none; }
.cw-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; letter-spacing: -.03em; }
.cw-mark { display: inline-block; width: 22px; height: 22px; color: var(--ink); }
.cw-mark svg { width: 100%; height: 100%; display: block; }
.cw-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: 14px; text-align: left; flex: none; overflow: hidden; transition: background-color .2s var(--cw-ease); }
.cw-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-item:hover { background: var(--cw-hover); }
.cw-item.active { background: var(--cw-sel); font-weight: 500; }
.cw-quiet { color: var(--muted); }
.cw-quiet:hover { color: var(--ink); }
.cw-matter .i { color: var(--muted); }
.cw-matter.active .i { color: var(--accent); }
.cw-matter .fl { fill: color-mix(in srgb, var(--accent) 16%, var(--cw-sel)); }
.cw-opening .cw-matter .pg { animation: cw-peek .45s var(--cw-ease) both; }
@keyframes cw-peek { from { transform: translateY(4px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cw-opening .cw-matter .pg { animation: none; } }
.cw-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -2px; padding: 0 2px; display: flex; flex-direction: column; gap: 1px; scrollbar-width: thin; }
.cw-section { display: flex; align-items: center; justify-content: space-between; padding: 16px 4px 4px 10px; font-size: 12px; font-weight: 500; color: var(--muted); }
.cw-empty, .cw-empty-sub { margin: 2px 4px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.cw-empty-sub { border: 0; padding: 4px 10px; }
.cw-nest { display: flex; flex-direction: column; gap: 1px; margin: 0 0 4px 17px; padding-left: 8px; border-left: 1px solid var(--line-strong); }
.cw-sub { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 0 10px; border-radius: 8px; font-size: 13.5px; text-align: left; overflow: hidden; }
.cw-sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-sub:hover { background: var(--cw-hover); }
.cw-sub.active { background: var(--cw-sel); font-weight: 500; }
.cw-sub-quiet { color: var(--muted); }
.cw-sub-quiet .i { width: 15px; height: 15px; }
/* A sidebar row with a ⋯ menu: the button shows on hover, on keyboard focus and while its menu is open. */
.cw-row { position: relative; flex: none; }
.cw-row > .cw-item, .cw-row > .cw-sub { padding-right: 34px; }
.cw-more { position: absolute; right: 4px; top: 4px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--muted); opacity: 0; }
.cw-row > .cw-sub ~ .cw-more { top: 2px; }
.cw-row:hover .cw-more, .cw-more:focus-visible, .cw-row.open .cw-more { opacity: 1; }
.cw-more:hover, .cw-row.open .cw-more { background: var(--cw-hover); color: var(--ink); }
@media (hover: none) { .cw-more { opacity: 1; } }
.cw-menu { margin: 2px 4px 6px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 8px 24px rgba(0,0,0,.08); display: flex; flex-direction: column; }
.cw-menu-item { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 10px; border-radius: 8px; font-size: 13.5px; text-align: left; }
.cw-menu-item:hover, .cw-menu-item:focus-visible { background: var(--cw-hover); }
.cw-menu-item .i { width: 16px; height: 16px; }
.cw-menu-item.danger { color: var(--danger, #c0392b); }
.cw-row[draggable="true"] { cursor: grab; }
.cw-row.cw-drop { box-shadow: inset 0 2px 0 var(--accent); border-radius: 8px; }
.cw-foot { display: flex; flex-direction: column; gap: 1px; padding-top: 6px; border-top: 1px solid var(--line); flex: none; }
.cw-user { display: flex; align-items: center; gap: 10px; padding: 6px 4px 2px 8px; min-height: 44px; }
.cw-avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 11px; font-weight: 600; flex: none; }
.cw-user-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.cw-item span, .cw-label { transition: opacity .2s var(--cw-ease); }
.cw-rail-only { display: none; }
/* Collapsed, nothing is taken out of the layout. Labels fade and are clipped by the narrower rail,
   the middle keeps its flex space (hidden, so it is out of the tab order), and the footer, which
   follows it, stays pinned to the bottom exactly as when the sidebar is open. */
.cw-collapsed .cw-side { width: 56px; }
.cw-collapsed .cw-item span, .cw-collapsed .cw-label { opacity: 0; pointer-events: none; }
.cw-collapsed .cw-scroll, .cw-collapsed .cw-logout { visibility: hidden; }
.cw-collapsed .cw-rail-only { display: flex; }
.cw-collapsed .cw-user { gap: 0; }
.cw-scrim { display: none; }

/* Main column */
.cw-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cw-top { display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 12px; flex: none; }
.cw-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 15px; }
.cw-crumb { display: inline-flex; align-items: center; gap: 8px; max-width: 34ch; padding: 6px 10px; border-radius: 10px; font-weight: 500; color: var(--ink); }
.cw-crumb:hover { background: var(--cw-hover); }
.cw-crumb span, .cw-crumb-now { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-crumb .i { color: var(--muted); width: 17px; height: 17px; }
.cw-crumb-now { font-weight: 500; padding: 6px 4px; max-width: 40ch; }
.cw-sep { color: var(--line-strong); }
.cw-pill-btn { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; height: 36px; padding: 0 12px; border-radius: 999px; font-size: 14px; color: var(--muted); transition: background-color .2s var(--cw-ease), color .2s var(--cw-ease); }
.cw-pill-btn:hover, .cw-pill-btn.on { background: var(--cw-hover); color: var(--ink); }
.cw-pill-btn .i { width: 17px; height: 17px; }
.cw-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cw-page { overflow-y: auto; }
.cw-chat { overflow: hidden; }

/* ---------------------------------------------------------------- project page */

.cw-feed { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable both-edges; }
.cw-home { max-width: 800px; margin: 0 auto; padding: 6vh 16px 56px; }
.cw-hero { margin-bottom: 22px; padding: 0 8px; animation: cw-rise .6s var(--cw-ease) backwards; }
.cw-hero-title { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; min-width: 0; }
.cw-hero h1 { margin: 0; font-size: clamp(26px, 1.6vw + 16px, 34px); font-weight: 500; letter-spacing: -.035em; line-height: 1.1; overflow-wrap: anywhere; }
.cw-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.cw-pill { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 14px; transition: background-color .2s var(--cw-ease), border-color .2s var(--cw-ease), scale .3s var(--cw-ease); }
.cw-pill .i { width: 16px; height: 16px; color: var(--muted); }
.cw-pill:hover { background: var(--cw-hover); }
.cw-pill:active { scale: .97; }
.cw-pill.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.cw-hero .cw-cap { margin-top: 12px; max-width: 60ch; }
.cw-notices { display: grid; gap: 8px; margin: 16px 0 0; }
.cw-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; font-size: 13.5px; color: var(--muted); background: var(--surface); }
.cw-note b { font-weight: 500; color: var(--ink); }
.cw-note.held { background: var(--held-bg); border-color: var(--held-line); color: var(--held); }
.cw-note.held b { color: var(--held); }
.cw-starters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 22px; }
.cw-starter { grid-column: span 2; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); text-align: left; font-size: 14px; line-height: 1.45; color: var(--muted); animation: cw-rise .6s var(--cw-ease) backwards; animation-delay: calc(var(--i, 0) * 70ms + 180ms); transition: color .2s var(--cw-ease), box-shadow .3s var(--cw-ease), border-color .2s var(--cw-ease), translate .3s var(--cw-ease); }
.cw-starter b { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.cw-starter:nth-child(4n+1), .cw-starter:nth-child(4n) { grid-column: span 3; }
.cw-starter:hover { color: var(--ink); border-color: transparent; box-shadow: var(--cw-shadow); }
.cw-starter:active { translate: 0 1px; }
.cw-below { margin-top: 28px; padding: 0 8px; }
.cw-below h3 { margin: 0 0 6px; font-size: 14px; font-weight: 500; color: var(--muted); }
.cw-proj-chat { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.cw-proj-chat button { flex: 1; min-width: 0; padding: 12px 6px; text-align: left; }
.cw-proj-chat button:hover b { text-decoration: underline; }
.cw-proj-chat b { display: block; font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-proj-chat small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- composer */

.cw-composer { display: flex; flex-direction: column; margin-top: 18px; background: var(--surface); border-radius: 28px; box-shadow: var(--cw-shadow); padding: 10px 10px 8px; cursor: text; transition: box-shadow .3s var(--cw-ease); }
.cw-dock .cw-composer { margin-top: 0; }
.cw-composer:focus-within { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent), var(--cw-shadow); }
.cw-composer textarea { width: 100%; min-height: 40px; max-height: 240px; padding: 8px 10px 2px; border: 0; outline: 0; resize: none; background: transparent; box-shadow: none; border-radius: 0; line-height: 24px; font: inherit; color: var(--ink); }
.cw-composer .ask-frame { order: 2; margin: 0; padding: 2px 10px 6px; }
.cw-composer .ask-frame .cap { font-size: 12.5px; color: var(--muted); }
.cw-composer .cw-composer-row { order: 3; }
.ask-frame { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 8px 0 0; }
.ask-frame .fr-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; width: 100%; padding: 8px 0 4px; font-size: 13px; }
.ask-frame .fr-kinds { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.ask-frame .fr-controls input[type=date] { min-height: 32px; padding: 2px 6px; }
.coverage-list { margin: 2px 0 12px 18px; font-size: 13px; line-height: 1.7; }
.cw-composer textarea::placeholder { color: var(--muted); }
.cw-composer-row { display: flex; align-items: center; gap: 6px; }
.cw-chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; font-size: 14px; color: var(--muted); border: 1px solid transparent; transition: background-color .2s var(--cw-ease), color .2s var(--cw-ease); }
.cw-chip .i { width: 16px; height: 16px; }
.cw-chip:hover { background: var(--cw-hover); color: var(--ink); }
.cw-chip.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 500; }
.cw-send { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--cw-on-accent); flex: none; transition: background-color .2s var(--cw-ease), scale .3s var(--cw-ease), opacity .2s; }
.cw-send .i { stroke-width: 2.2; }
.cw-send:hover:not(:disabled) { background: var(--accent-hover); }
.cw-send:active:not(:disabled) { scale: .94; }
.cw-send:disabled { opacity: .3; }

/* ---------------------------------------------------------------- thread */

.cw-col { width: 100%; max-width: 800px; margin: 0 auto; padding: 8px 16px 24px; }
.cw-thread-head { display: flex; justify-content: flex-end; gap: 8px; margin: 0 0 12px; }
.cw-home > .cw-row { margin-top: 16px; }
.cw-dock { flex: none; background: var(--paper); padding: 0 16px; }
.cw-dock .cw-col { padding: 0; }
.cw-dock .ok, .cw-dock .err { margin: 0 0 10px; }
.cw-turn { margin-bottom: 36px; }
.cw-turn-new { animation: cw-rise .4s var(--cw-ease) backwards; }
.cw-msg { margin: 0 0 14px; }
.cw-me { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.cw-bubble { max-width: 80%; padding: 10px 18px; border-radius: 22px 22px 8px 22px; background: var(--cw-bubble); white-space: pre-wrap; overflow-wrap: anywhere; }
.cw-asst { line-height: 1.65; }
.cw-prose { margin: 0; }
.cw-answer p { margin: 0 0 12px; }
.cw-answer p:last-child { margin-bottom: 0; }
.cw-answer .cite { display: inline-block; padding: 0 7px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font: 600 12px/20px var(--font-mono, ui-monospace, "Geist Mono", Consolas, monospace); letter-spacing: 0; text-decoration: none; cursor: pointer; vertical-align: 1px; transition: background-color .2s var(--cw-ease); }
.cw-answer .cite:hover { background: color-mix(in srgb, var(--accent) 14%, var(--accent-soft)); color: var(--accent-hover); }
.cw-trust { margin: 12px 0 0; padding: 10px 14px; border-left: 3px solid var(--line-strong); font-size: 13.5px; color: var(--muted); }
.cw-trust b { display: block; color: var(--ink); font-weight: 500; margin-bottom: 2px; }
.cw-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.cw-source { max-width: 280px; padding: 4px 11px; border-radius: 999px; background: var(--cw-bubble); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background-color .2s var(--cw-ease); }
.cw-source b { font-weight: 600; color: var(--accent); }
.cw-source:hover { background: var(--cw-sel); }
.cw-auth { font-style: normal; font-size: 11px; color: var(--muted); margin-right: 6px; text-transform: uppercase; letter-spacing: .03em; }
.cw-psgs { margin-top: 12px; font-size: 14px; color: var(--muted); }
.cw-psgs summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; padding: 2px 0; }
.cw-psgs summary::-webkit-details-marker { display: none; }
.cw-psgs summary::after { content: ""; width: 7px; height: 7px; border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; rotate: -45deg; margin-left: 2px; transition: rotate .3s var(--cw-ease); }
.cw-psgs[open] summary::after { rotate: 45deg; }
.cw-psgs summary:hover { color: var(--ink); }
.cw-psg { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); transition: box-shadow .3s var(--cw-ease), border-color .3s; }
.cw-psg.lit { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cw-psg-h { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }
.cw-psg-name { flex: 1 1 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.cw-cite { padding: 0 7px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font: 600 12px/20px ui-monospace, "Geist Mono", Consolas, monospace; }
.cw-psg-q { margin: 8px 0; font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.cw-psg-q mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.cw-saved { font-size: 12.5px; color: var(--accent); font-weight: 500; }
.cw-scope { margin-top: 10px; }
.cw-actions { display: flex; flex-wrap: wrap; gap: 2px 4px; margin-top: 8px; margin-left: -8px; }
.cw-act { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px; font-size: 13px; color: var(--muted); transition: background-color .2s var(--cw-ease), color .2s var(--cw-ease); }
.cw-act .i { width: 16px; height: 16px; }
.cw-act:hover { background: var(--cw-hover); color: var(--ink); }
.cw-act[aria-pressed="true"] { color: var(--accent); }
.cw-act[aria-pressed="true"] .i { fill: currentColor; }
.cw-error { padding: 10px 14px; border-radius: 12px; background: var(--danger-bg); color: var(--danger); font-size: 14px; }
.cw-asst .skel { margin-top: 10px; }

/* ---------------------------------------------------------------- settings */

.settings-sec { max-width: 760px; padding: 24px 0; border-top: 1px solid var(--line); }
.settings-sec:first-of-type { border-top: 0; padding-top: 0; }
.settings-sec h2 { margin-bottom: 6px; }
.ui-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.ui-opt { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--surface); text-align: left; cursor: pointer; color: var(--ink); transition: border-color .2s, box-shadow .3s, background-color .2s; }
.ui-opt:hover { border-color: var(--ink); }
.ui-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ui-prev { width: 100%; height: auto; display: block; }
.ui-opt-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.ui-opt-title i { font-style: normal; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
.ui-opt-text { font-size: 13px; line-height: 1.5; color: var(--muted); }

/* ---------------------------------------------------------------- evidence panel, beside the chat */

.cw-panel { width: clamp(380px, 34vw, 520px); flex: none; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); }
.cw-panel-new { animation: cw-panel-in .35s var(--cw-ease); }
@keyframes cw-panel-in { from { opacity: 0; translate: 28px 0; } }
.cw-panel-head { display: flex; align-items: center; gap: 2px; height: 52px; padding: 0 8px 0 18px; flex: none; border-bottom: 1px solid var(--line); }
.cw-panel-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.cw-panel-title b { font-weight: 600; font-size: 15px; }
.cw-panel-title small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.cw-panel-tabs { display: flex; gap: 6px; padding: 10px 14px; flex: none; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.cw-tab { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; color: var(--muted); white-space: nowrap; transition: background-color .2s var(--cw-ease), color .2s var(--cw-ease); }
.cw-tab span { font-size: 12px; font-variant-numeric: tabular-nums; opacity: .8; }
.cw-tab:hover { background: var(--cw-hover); color: var(--ink); }
.cw-tab[aria-pressed="true"] { background: var(--cw-sel); color: var(--ink); font-weight: 500; }
.cw-panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 28px; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.cw-docs { display: flex; flex-direction: column; gap: 2px; }
.cw-doc { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 12px; text-align: left; transition: background-color .2s var(--cw-ease); }
.cw-doc:hover { background: var(--cw-hover); }
.cw-doc-ext { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--sunk); border: 1px solid var(--line); font: 600 10px ui-monospace, "Geist Mono", Consolas, monospace; color: var(--muted); }
.cw-doc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cw-doc-main strong { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-doc-main span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-doc-main .cw-doc-why { color: var(--held); }
.cw-panel-more { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cw-panel-empty { padding: 18px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); font-size: 14px; }
.cw-panel-empty b { color: var(--ink); font-weight: 500; }
.cw-panel-empty p { margin-top: 4px; }
.cw-panel-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.cw-back { align-self: flex-start; }
.cw-panel-integrity .overview { margin: 0; }
.cw-panel .evidence-detail { position: static; max-height: none; border: 0; padding: 0; background: transparent; box-shadow: none; }
.cw-panel .evidence-detail .btn { margin: 0 6px 6px 0; }
.cw-panel-scrim { display: none; }

/* ---------------------------------------------------------------- sources and the document reader (in the panel) */

.cw-panel-refs, .cw-panel-reader { width: clamp(400px, 38vw, 620px); }
.cw-panel-head:has(> .cw-icon:first-child) { padding-left: 8px; }
.cw-panel-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-panel-title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-allsrc { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; padding: 4px 4px 4px 0; font-size: 13.5px; color: var(--muted); }
.cw-allsrc .i { width: 15px; height: 15px; transition: translate .25s var(--cw-ease); }
.cw-allsrc:hover { color: var(--ink); }
.cw-allsrc:hover .i { translate: 3px 0; }
.cw-read { align-self: flex-start; }

.cw-claim { margin: 0; padding: 12px 14px; border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0; background: var(--accent-soft); font-size: 15px; line-height: 1.55; }
.cw-claim-label { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.cw-claim small { display: block; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.cw-refgroup { display: flex; flex-direction: column; gap: 8px; }
.cw-refgroup > header { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding-top: 4px; }
.cw-refgroup-name { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14px; }
.cw-ref { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); transition: border-color .3s, box-shadow .3s; }
.cw-ref-meta { display: flex; gap: 10px; margin-bottom: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cw-ref-text { font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.cw-ref-text p { margin: 0 0 8px; }
.cw-ref-text p:last-child { margin: 0; }
.cw-ref-text mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.cw-ref-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.cw-more { margin-top: 2px; }
.cw-more summary { cursor: pointer; list-style: none; padding: 4px 0; font-size: 13px; color: var(--muted); }
.cw-more summary::-webkit-details-marker { display: none; }
.cw-more summary:hover { color: var(--ink); }
.cw-more[open] summary { margin-bottom: 8px; }
.cw-more > .cw-ref { margin-bottom: 8px; }

/* markdown, as it reads */
.cw-md { font-size: 14.5px; line-height: 1.65; overflow-wrap: anywhere; }
.cw-md > :first-child { margin-top: 0; }
.cw-md > :last-child { margin-bottom: 0; }
.cw-md p, .cw-md ul, .cw-md ol, .cw-md pre, .cw-md blockquote, .cw-md .cw-md-table { margin: 0 0 12px; }
.cw-md h3, .cw-md h4, .cw-md h5, .cw-md h6 { margin: 18px 0 8px; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; }
.cw-md h3 { font-size: 1.25em; } .cw-md h4 { font-size: 1.12em; } .cw-md h5, .cw-md h6 { font-size: 1em; }
.cw-md ul, .cw-md ol { padding-left: 1.5em; }
.cw-md li { margin: 3px 0; }
.cw-md a { color: var(--accent); }
.cw-md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.cw-md blockquote { padding: 2px 0 2px 14px; border-left: 3px solid var(--line-strong); color: var(--muted); }
.cw-md code { font: .88em ui-monospace, "Geist Mono", Consolas, monospace; background: var(--sunk); padding: 1px 5px; border-radius: 5px; }
.cw-md pre { padding: 12px 14px; border-radius: 12px; background: var(--sunk); border: 1px solid var(--line); overflow-x: auto; }
.cw-md pre code { background: none; padding: 0; }
.cw-md-table { overflow-x: auto; }
.cw-md-table table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.cw-md-table th, .cw-md-table td { padding: 7px 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.cw-md-table th { background: var(--sunk); font-weight: 600; white-space: nowrap; }

/* the document reader */
.cw-reader-body { gap: 14px; }
.cw-pagesec > h4 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cw-ai { font-weight: 500; letter-spacing: 0; text-transform: none; padding: 1px 8px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); }
.cw-chunk { position: relative; margin: 0 0 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid transparent; }
.cw-chunk.hit { background: color-mix(in srgb, var(--mark) 38%, transparent); border-color: color-mix(in srgb, var(--mark) 70%, var(--line)); }
.cw-chunk.primary { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mark) 55%, transparent); }
.cw-hit-tag { display: inline-block; margin-bottom: 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }

/* spreadsheets as real grids, cited cells highlighted */
.cw-grid-wrap { max-height: 100%; overflow: auto; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.cw-grid { border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 100%; }
.cw-grid th, .cw-grid td { padding: 5px 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.cw-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--sunk); color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }
.cw-grid tbody th { position: sticky; left: 0; z-index: 1; background: var(--sunk); color: var(--muted); font-size: 12px; font-weight: 500; text-align: right; min-width: 38px; }
.cw-grid thead th.corner { left: 0; z-index: 3; }
.cw-grid td.hit { background: var(--mark); color: var(--ink); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ink) 55%, transparent); font-weight: 500; }
.cw-grid td.cited { background: color-mix(in srgb, var(--mark) 32%, transparent); }
.cw-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.cw-key { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line-strong); }
.cw-key.hit { background: var(--mark); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ink) 55%, transparent); margin-left: 4px; }
.cw-key.cited { background: color-mix(in srgb, var(--mark) 32%, transparent); margin-left: 8px; }
.cw-sheet-label { margin: 8px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cw-grid tr.hitrow > th { background: var(--mark); color: var(--ink); font-weight: 700; }
.cw-grid-mini { font-size: 12.5px; }
.cw-mini { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.cw-sheets { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.cw-sheet { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 8px 8px 0 0; font-size: 13px; white-space: nowrap; color: var(--muted); background: var(--sunk); }
.cw-sheet.on { background: var(--surface); color: var(--ink); font-weight: 500; border-bottom-color: var(--surface); }
.cw-sheet i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* key points quoted from the passages when no written answer could be verified */
.cw-points { margin-bottom: 10px; }
.cw-points-head { margin: 0 0 2px; font-size: 15px; }
.cw-points .cw-cap { margin: 0 0 10px; }
.cw-points-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cw-points-list li { padding: 10px 14px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 4px 12px 12px 4px; background: var(--surface); line-height: 1.6; overflow-wrap: anywhere; }
.cw-quote { color: var(--ink); }
.cw-pg { margin-left: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tools in the composer, public sources in the thread */

.cw-composer { position: relative; }
.cw-tool { display: flex; align-items: center; gap: 8px; margin: 2px 4px 0; padding: 7px 8px 7px 12px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-size: 13px; line-height: 1.4; }
.cw-tool .i { width: 16px; height: 16px; flex: none; }
.cw-tool span { flex: 1; min-width: 0; color: var(--ink-soft); }
.cw-tool b { color: var(--accent); font-weight: 600; }
.cw-mention { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 8px); z-index: 30; padding: 6px; border-radius: 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5); box-shadow: var(--cw-shadow); animation: cw-rise .2s var(--cw-ease); max-width: 420px; }
.cw-mention-head { margin: 0; padding: 6px 10px 4px; font-size: 12px; color: var(--muted); }
.cw-mention-opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: 10px; text-align: left; }
.cw-mention-opt .i { color: var(--muted); }
.cw-mention-opt span { display: flex; flex-direction: column; min-width: 0; }
.cw-mention-opt b { font-weight: 500; font-size: 14px; }
.cw-mention-opt small { font-size: 12px; color: var(--muted); }
.cw-mention-opt:hover, .cw-mention-opt.on { background: var(--cw-hover); }
.cw-pubtag { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 6px; padding: 2px 10px 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.cw-pubtag .i { width: 14px; height: 14px; }
.cw-ref-dates { margin: 6px 0 0; line-height: 1.5; }
.cw-ref-dates .source-dates { font-size: 12px; }
.cw-suggest:not(:empty) { margin-top: 18px; }
.cw-suggest .cw-starters { margin-top: 0; }

/* ---------------------------------------------------------------- dialogs (Fix, notes…) */

:root[data-ui="chat"] .btn { white-space: nowrap; }
:root[data-ui="chat"] .modal .box { overflow: hidden; }
:root[data-ui="chat"] .modal-x { border-radius: 50%; }
/* a file's name gets its own line; its actions wrap beneath instead of squeezing the name or each other */
:root[data-ui="chat"] .modal .filelist .r { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
:root[data-ui="chat"] .modal .filelist .r .nm { flex: 1 1 100%; min-width: 0; font-weight: 500; overflow-wrap: anywhere; white-space: normal; }
:root[data-ui="chat"] .modal .filelist .r input.sm { flex: 1 1 140px; width: auto !important; max-width: 240px; }

@keyframes cw-rise { from { opacity: 0; translate: 0 6px; } }

/* ---------------------------------------------------------------- phones and small tablets */

@media (max-width: 1500px) {
  /* With the panel open the chat is narrower: the top-bar buttons keep only their icons */
  .cw-has-panel .cw-pill-btn:not(.on) span { display: none; }
  .cw-has-panel .cw-pill-btn:not(.on) { width: 36px; padding: 0; justify-content: center; }
}
@media (max-width: 1100px) {
  .cw-panel-refs, .cw-panel-reader { width: min(520px, 100vw); }
  /* Too narrow to sit beside the chat: the panel slides over it, and the chat stays underneath. */
  .cw-panel { position: fixed; z-index: 50; inset: 0 0 0 auto; width: min(440px, 100vw); box-shadow: var(--shadow); }
  .cw-panel-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: var(--scrim, rgba(0, 0, 0, .35)); animation: cw-fade .25s; }
}
@keyframes cw-fade { from { opacity: 0; } }

/* The guided demo's cards clear the sidebar; on a phone the chat keeps the top of the screen. */
:root[data-ui="chat"] .tour-pop.dock { left: 276px; }
.tour-pop.invite.side::before { display: none; }
/* above the Guided demo button in an open sidebar: the pointer faces down */
.tour-pop.invite.above { overflow: visible; padding: 12px 14px; }
.tour-pop.invite.above::before { top: auto; bottom: -6px; transform: rotate(225deg); }
/* in a sidebar the card is short: the title and the button, not the paragraph */
.tour-pop.invite.above p { display: none; }
.tour-pop.invite.above h3 { font-size: 14px; line-height: 1.35; }

@media (max-width: 768px) {
  .cw-panel { width: 100vw; }
  :root[data-ui="chat"] .tour-pop.dock { left: 16px; }
  .cw-only-mobile { display: inline-grid; }
  /* Closed, the drawer is out of sight and out of the tab order; open, it slides in. */
  .cw-side { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(300px, 86vw); transform: translateX(-102%); visibility: hidden; transition: transform .3s var(--cw-ease), visibility 0s .3s; box-shadow: none; }
  .cw-side-open .cw-side { transform: none; visibility: visible; transition: transform .3s var(--cw-ease); box-shadow: var(--shadow); }
  .cw-scrim { position: fixed; inset: 0; z-index: 55; background: var(--scrim, rgba(0, 0, 0, .45)); display: block; opacity: 0; visibility: hidden; transition: opacity .3s; }
  .cw-side-open .cw-scrim { opacity: 1; visibility: visible; }
  .cw-collapsed .cw-side { width: min(300px, 86vw); }
  .cw-collapsed .cw-item span, .cw-collapsed .cw-label { opacity: 1; pointer-events: auto; }
  .cw-collapsed .cw-scroll, .cw-collapsed .cw-logout { visibility: inherit; }
  .cw-collapsed .cw-rail-only { display: none; }
  .cw-collapsed .cw-user { gap: 10px; }
  .cw-top { padding: 0 6px; }
  .cw-pill-btn span { display: none; }
  .cw-pill-btn { width: 36px; padding: 0; justify-content: center; }
  .cw-crumb { max-width: 22ch; }
  .cw-home { padding-top: 3vh; }
  .cw-starters { grid-template-columns: 1fr; }
  .cw-starter, .cw-starter:nth-child(4n+1), .cw-starter:nth-child(4n) { grid-column: auto; }
  .cw-bubble { max-width: 92%; }
  .ui-choice { grid-template-columns: 1fr; }
  :root[data-ui="chat"] .cw-page .wrap { padding: 16px 16px 96px; }
  .cw-chip span { display: none; }
  .cw-chip { width: 34px; padding: 0; justify-content: center; }
}

@media (max-width: 640px) {
  :root[data-ui="chat"] body.tour-active { padding-bottom: 0; }
  :root[data-ui="chat"] .tour-active [data-tour] { scroll-margin-top: 16px; }
  body.tour-active .cw-panel-body { padding-bottom: 58dvh; } /* room to scroll the target above the demo card */
  body.tour-active .cw { height: 45dvh; }
}

@media (prefers-reduced-motion: reduce) {
  .cw *, .cw-panel, .cw-panel-new, .cw-turn-new, .cw-hero, .cw-starter, .cw-turn { animation: none !important; transition: none !important; }
}
