@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600&family=Source+Sans+3:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* OBSERVATORY — cold mission-control telemetry console that inverts to a warm ivory answer surface. */

:root {
  color-scheme: dark;
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-ui: 'Source Sans 3', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  /* cold ground */
  --ink-base: #0a0e14; --ink-panel: #101620; --ink-card: #161e2b; --ink-card-hi: #1d2838;
  --hairline: #222d3d; --hairline-lit: #34465d;
  /* warm ivory inversion (answer only, on .complete) */
  --ivory-base: #f4efe6; --ivory-card: #fbf8f1; --ivory-line: #e3d9c8; --ivory-ink: #1c1b18;
  /* signal channels */
  --sig-violet: #8b9dde;  /* plan */
  --sig-amber: #e8b04b;   /* lexical / search-sparse */
  --sig-cyan: #4fd6c9;    /* semantic / search-dense */
  --sig-green: #7bd88f;   /* hybrid / search-hybrid */
  --sig-orange: #f08a3c;  /* source */
  --coral: #d97757;       /* compose / CTA — the one keg color kept */
  --sig-red: #e2574c;     /* error */
  --text: #ecebe4; --text-2: #b0aea5; --text-3: #87867f;
  --shadow: 0 0 0 1px var(--hairline), 0 4px 24px rgba(0, 0, 0, .45);
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
}

* { box-sizing: border-box; }
html { overflow-y: scroll; scrollbar-gutter: stable; scrollbar-color: var(--hairline-lit) var(--ink-base); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--ink-base); }
::-webkit-scrollbar-thumb { background: var(--hairline-lit); border: 3px solid var(--ink-base); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
body {
  margin: 0; min-height: 100vh; color: var(--text); font-family: var(--font-ui); font-size: 15px;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 700px at 18% -10%, rgba(139, 157, 222, .07), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(217, 119, 87, .05), transparent 55%),
    var(--ink-base);
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: url('/ucg/static/cqust-logo-watermark.png') center 48% / min(34vw, 520px) no-repeat;
  opacity: .16;
}
button, textarea, input { font: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }

/* ---- layout: answer-centric 2-column workspace (Direction B) ---- */
.workspace {
  position: relative; z-index: 1; min-height: 100vh; padding: 18px; display: grid; gap: 1px; align-items: start;
  grid-template-columns: minmax(0, 1fr) 400px;
  grid-template-areas:
    "mast mast"
    "main evidence";
  background: transparent;
}
.masthead {
  grid-area: mast; min-width: 0; margin: 0 0 12px; padding: 18px 26px;
  border: 1px solid var(--hairline); border-radius: var(--r-lg); box-shadow: var(--shadow);
  background:
    linear-gradient(90deg, rgba(217, 119, 87, .16), rgba(79, 214, 201, .07), transparent),
    var(--ink-panel);
}
.masthead h1 {
  margin: 0; color: var(--text); font-family: var(--font-ui); font-size: 34px;
  font-weight: 760; line-height: 1.18; letter-spacing: .02em;
}
.main-stack, .evidence-stack {
  display: flex; min-width: 0; flex-direction: column; gap: 18px; padding: 0 9px;
}
.main-stack { grid-area: main; padding-left: 0; }
.evidence-stack { grid-area: evidence; padding-right: 0; }
.evidence-panel { position: sticky; top: 18px; }
.evidence-close {
  border: 1px solid var(--hairline-lit); background: transparent; color: var(--text-2);
  border-radius: var(--r-sm); width: 26px; height: 26px; cursor: pointer; line-height: 1;
  display: none;  /* drawer-only affordance; shown in the narrow drawer media query */
}
.evidence-close:hover { color: var(--text); border-color: var(--coral); }
.panel {
  min-width: 0; background: var(--ink-panel); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
}
.panel-header {
  padding: 13px 16px; border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-header h1, .panel-header h2 {
  margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 17px;
  line-height: 1.2; letter-spacing: .005em;
}
.panel-body { padding: 14px 16px; }
/* collapsible panel — 检索工具 / 检索过程 start collapsed in the reading column; clicking the header toggles. */
.ph-right { display: inline-flex; align-items: center; gap: 8px; }
.panel.collapsible > .panel-header { cursor: pointer; user-select: none; }
.panel-chev { color: var(--text-3); font-size: 11px; transition: transform .2s ease; }
.panel.collapsed > .panel-header { border-bottom-color: transparent; }
.panel.collapsed .panel-chev { transform: rotate(-90deg); }
.panel.collapsed > .panel-body { display: none; }
.section-label {
  margin: 0 0 9px; color: var(--text-3); font-size: 10.5px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
}
.section-label:has(+ .lane-spectrum), .lane-spectrum, .readiness-gate { display: none !important; }

/* ---- badges & pills ---- */
.badge {
  display: inline-flex; align-items: center; max-width: 100%; min-height: 22px; padding: 2px 9px;
  border-radius: 999px; border: 1px solid var(--hairline-lit); background: var(--ink-card);
  color: var(--text-2); font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 11px; white-space: normal;
}
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--hairline-lit); font-family: var(--font-mono);
  font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-2);
}
.pill.ok { color: var(--sig-green); border-color: rgba(123, 216, 143, .5); }
.pill.running { color: var(--sig-cyan); border-color: rgba(79, 214, 201, .5); }
.pill.error { color: var(--sig-red); border-color: rgba(226, 87, 76, .5); }
.pill.skipped { color: var(--sig-amber); border-color: rgba(232, 176, 75, .5); }
.pill.degraded { color: var(--sig-amber); border-color: rgba(232, 176, 75, .6); background: color-mix(in srgb, var(--sig-amber) 12%, transparent); }
.pill.degraded::before { content: "⚠"; font-size: 10px; }
.pill[hidden] { display: none; }

/* ---- current question + trace ---- */
.query-card {
  min-height: 70px; padding: 12px; border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--ink-card); color: var(--text-2); line-height: 1.55; overflow-wrap: anywhere;
}
.trace-link { margin-top: 9px; font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
.trace-link a { color: var(--sig-cyan); text-decoration: none; }
.trace-link a:hover { text-decoration: underline; }

/* ============ LEFT SPINE — current action focus (#lane-board) ============ */
.lane-board { display: grid; gap: 8px; }
.phase-focus {
  --chan: var(--sig-cyan);
  position: relative; overflow: hidden; border: 1px solid var(--hairline); border-radius: var(--r-md);
  padding: 12px; background: var(--ink-card);
}
.phase-focus.plan { --chan: var(--sig-violet); }
.phase-focus.locate { --chan: var(--sig-cyan); }
.phase-focus.source { --chan: var(--sig-orange); }
.phase-focus.compose { --chan: var(--coral); }
.phase-focus[data-state="running"] {
  border-color: color-mix(in srgb, var(--chan) 55%, var(--hairline));
}
/* Determinate phase progress bar — the BAR advances (plan/locate/source/compose); the card background
   no longer sweeps. This is the original "条动不是背景动" fix. */
.phase-progress {
  margin-top: 12px; height: 4px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--hairline) 70%, transparent);
}
.phase-progress-fill {
  height: 100%; width: var(--progress, 0%); border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--chan) 50%, transparent), var(--chan));
  transition: width .5s cubic-bezier(.2, .7, .2, 1);
}
.phase-focus[data-state="running"] .phase-progress-fill { box-shadow: 0 0 8px color-mix(in srgb, var(--chan) 45%, transparent); }
.phase-focus-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.phase-kicker {
  color: var(--chan); font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em;
}
.phase-status { color: var(--text-3); font-size: 11px; }
.phase-focus-title { margin-top: 8px; color: var(--text); font-size: 15px; font-weight: 650; }
.phase-focus-meta { margin-top: 5px; color: var(--text-2); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.phase-crumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 12px; }
.phase-crumb {
  position: relative; padding: 5px 4px 5px 14px; border: 1px solid var(--hairline); border-radius: var(--r-sm);
  color: var(--text-3); font-size: 10px; text-align: center; background: rgba(255,255,255,.02);
}
.phase-crumb::before {
  content: ""; position: absolute; left: 5px; top: 50%; width: 5px; height: 5px; border-radius: 50%;
  transform: translateY(-50%); background: var(--hairline-lit);
}
.phase-crumb[data-state="done"]::before { background: var(--sig-green); }
.phase-crumb[data-state="error"]::before { background: var(--sig-red); }
.phase-crumb.is-current { color: var(--text); border-color: color-mix(in srgb, var(--chan) 45%, var(--hairline)); }
.phase-crumb.is-current::before { background: var(--chan); animation: pulseDot 1.4s ease-in-out infinite; }

/* ============ PLANNER LANES (#lane-spectrum) ============ */
.lane-spectrum {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(58px, 1fr); gap: 8px; height: 96px; align-items: end;
}
.spectrum-bar {
  position: relative; height: 100%; border: 1px solid var(--hairline); border-radius: var(--r-sm);
  display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .03) 0 1px, transparent 1px 7px), var(--ink-card);
}
.spectrum-fill {
  height: var(--fill, 6%); transition: height .45s cubic-bezier(.2, .7, .2, 1);
  background: linear-gradient(180deg, var(--chan), color-mix(in srgb, var(--chan) 25%, transparent));
  box-shadow: 0 0 14px color-mix(in srgb, var(--chan) 45%, transparent);
}
.spectrum-bar.bloom { animation: citePulse .7s ease-out; }
.spectrum-bar.pulse .spectrum-fill { animation: lane-breathe 1.3s ease-in-out infinite; }
.spectrum-bar.lexical { --chan: var(--sig-amber); }
.spectrum-bar.semantic { --chan: var(--sig-cyan); }
.spectrum-bar.hybrid { --chan: var(--sig-green); }
.spectrum-bar.planner-lane { min-width: 0; }
.spectrum-bar.scan { --chan: var(--sig-cyan); }
.spectrum-bar.scan .spectrum-fill {
  height: 100%; box-shadow: none; animation: spectrum-scan 2.2s ease-in-out infinite;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--chan) 22%, transparent));
}
.spectrum-cap {
  position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; z-index: 1; pointer-events: none;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 10px; color: var(--text-2);
}
.spectrum-name {
  position: absolute; top: 6px; left: 0; right: 0; text-align: center; font-size: 9.5px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
}

/* ============ TOOL SIGNALS (#capability-rail) ============ */
.capability-rail { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 5px 6px; }
.cap-empty {
  grid-column: 1 / -1; padding: 8px 10px; border: 1px dashed var(--hairline-lit);
  border-radius: var(--r-sm); color: var(--text-3); font-size: 12px;
}
.cap-group-label {
  grid-column: 1 / -1; margin: 8px 0 2px; color: var(--text-3); font-size: 9.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
}
.cap-group-label:first-child { margin-top: 0; }
.cap-row {
  position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; padding: 6px 7px;
  border-radius: var(--r-sm); color: var(--text-3); opacity: .75; cursor: default;
  transition: opacity .25s ease, color .25s ease, background .25s ease;
}
.cap-row::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--hairline-lit);
  flex: 0 0 auto; transition: background .25s ease, box-shadow .25s ease;
}
.cap-row.lit { opacity: 1; color: var(--text); background: var(--ink-card); }
.cap-row.lit::before { background: var(--chan, var(--sig-cyan)); box-shadow: 0 0 8px var(--chan, var(--sig-cyan)); animation: pulseDot 1.8s ease-in-out infinite; }
.cap-row.lit[data-status="error"]::before { background: var(--sig-red); box-shadow: 0 0 8px var(--sig-red); }
.cap-row.lit[data-status="skipped"]::before { background: var(--sig-amber); box-shadow: none; }
.cap-name { min-width: 0; overflow: visible; white-space: normal; line-height: 1.25; font-size: 11px; }
.cap-count { margin-left: auto; color: var(--text-3); font-size: 10px; }
.cap-name { flex: 1 1 auto; }
.cap-count { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.cap-row.lex { --chan: var(--sig-amber); }
.cap-row.dense { --chan: var(--sig-cyan); }
.cap-row.hyb { --chan: var(--sig-green); }
.cap-row.plan { --chan: var(--sig-violet); }
.cap-row.compose { --chan: var(--coral); }
.cap-row.source { --chan: var(--sig-orange); }
/* tooltip — routing-only, hardcoded */
.cap-row[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; left: 12px; top: calc(100% - 2px); z-index: 20;
  max-width: 240px; padding: 6px 9px; border-radius: var(--r-sm); border: 1px solid var(--hairline-lit);
  background: var(--ink-card-hi); color: var(--text-2); font-size: 11px; line-height: 1.4;
  box-shadow: var(--shadow); white-space: normal;
}

/* ---- readiness gate chip (#readiness-gate) ---- */
.readiness-gate {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--hairline-lit); background: var(--ink-card); color: var(--text-2);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px;
}
.readiness-gate::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--hairline-lit); }
.readiness-gate.pass { color: var(--sig-green); border-color: rgba(123, 216, 143, .5); }
.readiness-gate.pass::before { background: var(--sig-green); box-shadow: 0 0 8px var(--sig-green); }
.readiness-gate.fail { color: var(--sig-red); border-color: rgba(226, 87, 76, .5); }
.readiness-gate.fail::before { background: var(--sig-red); box-shadow: 0 0 8px var(--sig-red); }

/* ============ CENTER STAGE — console + thought ticker ============ */
.ask-form { display: grid; gap: 12px; }
.ask-input {
  width: 100%; min-height: 84px; padding: 12px; border: 1px solid var(--hairline-lit);
  border-radius: var(--r-md); resize: vertical; color: var(--text); background: var(--ink-card); line-height: 1.55;
}
.ask-input::placeholder { color: var(--text-3); }
.ask-input:focus {
  outline: none; border-color: var(--coral);
  box-shadow: 0 0 0 1px var(--coral), 0 0 18px rgba(217, 119, 87, .18);
}
.submit-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.primary-button, .ghost-button { border-radius: var(--r-md); padding: 9px 16px; cursor: pointer; font-weight: 600; }
.primary-button { border: 1px solid var(--coral); background: var(--coral); color: #1a120e; }
.primary-button:hover { box-shadow: 0 0 18px rgba(217, 119, 87, .35); }
.primary-button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.ghost-button { border: 1px solid var(--hairline-lit); background: transparent; color: var(--text-2); }
.ghost-button:hover { color: var(--text); border-color: var(--coral); }
.status-text { color: var(--text-3); font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
.thought-ticker {
  margin-top: 12px; min-height: 22px; padding: 8px 12px; border-left: 2px solid var(--sig-cyan);
  background: var(--ink-card); border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--text-2);
  font-size: 13px; line-height: 1.4; overflow-wrap: anywhere;
}
.thought-ticker:empty { display: none; }
.thought-ticker.swap { animation: fadeSlide .28s ease-out; }
.thought-ticker .tt-tag {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; color: var(--sig-cyan);
  margin-right: 8px; text-transform: uppercase;
}

/* ============ PROCESS BOARD (#timeline) — disclosure instrument rows ============ */
.timeline { max-height: none; overflow: visible; display: grid; gap: 10px; align-content: start; }
.round-group { display: grid; gap: 8px; }
.round-tag {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 10.5px;
  letter-spacing: .08em; color: var(--text-3); text-transform: uppercase;
}
.parallel-batch { position: relative; display: grid; gap: 7px; padding-left: 16px; }
.parallel-batch::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--hairline-lit);
}
.parallel-head {
  display: flex; align-items: center; gap: 8px; color: var(--sig-cyan);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11px;
}
.disclosure {
  position: relative; border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--ink-card); overflow: hidden; animation: card-in .22s ease-out;
}
.disclosure::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--hairline-lit);
  transition: background .25s ease;
}
.disclosure[data-state="running"]::before { background: var(--sig-cyan); }
.disclosure[data-state="ok"]::before { background: var(--sig-green); }
.disclosure[data-state="error"]::before { background: var(--sig-red); }
.disclosure[data-state="skipped"]::before { background: var(--sig-amber); }
.disclosure.is-decision::before { background: var(--sig-violet); width: 4px; }
.disclosure[data-state="running"] { box-shadow: 0 0 0 1px var(--sig-cyan), 0 0 18px rgba(79, 214, 201, .18); }
.disclosure.flash { animation: settle-flash .5s ease-out; }
.disc-summary {
  list-style: none; display: flex; align-items: center; gap: 9px; padding: 10px 12px;
  cursor: pointer; user-select: none;
}
.disc-summary::-webkit-details-marker { display: none; }
.disc-glyph {
  flex: 0 0 auto; width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--r-sm);
  border: 1px solid var(--hairline-lit); background: var(--ink-panel); font-family: var(--font-mono);
  font-size: 13px; color: var(--text-2);
}
.disclosure[data-chan]:not([data-chan=""]) .disc-glyph {
  color: var(--chan, var(--text-2)); border-color: color-mix(in srgb, var(--chan) 45%, var(--hairline-lit));
}
.disc-label { flex: 1 1 auto; min-width: 0; }
.disc-tool { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.disc-meta {
  margin-top: 2px; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 11px; color: var(--text-3); overflow-wrap: anywhere;
}
.disclosure[data-chan="plan"] { --chan: var(--sig-violet); }
.disclosure[data-chan="lexical"] { --chan: var(--sig-amber); }
.disclosure[data-chan="semantic"] { --chan: var(--sig-cyan); }
.disclosure[data-chan="hybrid"] { --chan: var(--sig-green); }
.disclosure[data-chan="source"] { --chan: var(--sig-orange); }
.disclosure[data-chan="compose"] { --chan: var(--coral); }
.disc-body { padding: 0 12px 12px; display: grid; gap: 10px; animation: disclosureReveal .26s ease-out; }
.disclosure:not([open]) .disc-body { display: none; }
.reason-group { display: grid; gap: 4px; }
.reason-group .rg-label {
  font-size: 9.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3);
}
.reason-group .rg-label.decision { color: var(--sig-violet); }
.reason-group .rg-label.observation { color: var(--sig-cyan); }
.reason-group .rg-label.scope { color: var(--sig-orange); }
.step-line { color: var(--text-2); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
.step-line .lead { color: var(--text-3); font-family: var(--font-mono); font-size: 11px; margin-right: 4px; }
.step-query { color: var(--text); font-size: 12.5px; overflow-wrap: anywhere; }
.step-query .lead { color: var(--text-3); font-family: var(--font-mono); font-size: 11px; margin-right: 4px; }
.chip-row { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; max-width: 100%; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--hairline-lit); background: var(--ink-panel); color: var(--text-2);
  font-family: var(--font-mono); font-size: 11px; animation: chip-pop .26s ease-out backwards;
}
.chip.new { color: var(--sig-cyan); border-color: rgba(79, 214, 201, .5); }
.chip:nth-child(1) { animation-delay: 0ms; }
.chip:nth-child(2) { animation-delay: 30ms; }
.chip:nth-child(3) { animation-delay: 60ms; }
.chip:nth-child(4) { animation-delay: 90ms; }
.chip:nth-child(5) { animation-delay: 120ms; }
.chip:nth-child(6) { animation-delay: 150ms; }
.chip:nth-child(7) { animation-delay: 180ms; }
.chip:nth-child(8) { animation-delay: 210ms; }
.chip:nth-child(n+9) { animation-delay: 240ms; }
.count-bump { animation: count-bump .4s ease-out; }

/* rewrite small-cards (DECISION) — new query highlighted + term chips + why + lineage */
.rewrite-card {
  display: grid; gap: 5px; padding: 8px 10px; border: 1px solid var(--hairline);
  border-left: 2px solid var(--sig-violet); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: color-mix(in srgb, var(--sig-violet) 6%, var(--ink-card));
  animation: reveal-up .22s ease-out;
}
.rw-query {
  color: var(--sig-violet); font-weight: 600; font-size: 12.5px; line-height: 1.45; overflow-wrap: anywhere;
}
.rw-why { color: var(--text-2); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.rw-basis {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 10.5px;
  color: var(--text-3); letter-spacing: .02em;
}

/* per-lane mini-pills (OBSERVATION) — channel-colored arrival readout */
.lane-pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.lane-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--hairline-lit); background: var(--ink-panel); color: var(--text-2);
  font-size: 11px;
}
.lane-pill.lex { border-color: color-mix(in srgb, var(--sig-amber) 45%, var(--hairline-lit)); --chan: var(--sig-amber); }
.lane-pill.dense { border-color: color-mix(in srgb, var(--sig-cyan) 45%, var(--hairline-lit)); --chan: var(--sig-cyan); }
.lane-pill.hyb { border-color: color-mix(in srgb, var(--sig-green) 45%, var(--hairline-lit)); --chan: var(--sig-green); }
.lane-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--chan, var(--text-3)); flex: 0 0 auto; }
.lane-pill-dot.error { background: var(--sig-red); }
.lane-pill-dot.skipped { background: var(--text-3); }
.lane-pill-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.lane-pill-count {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 10.5px; color: var(--text-3);
}

/* ============ ANSWER (#answer) + ivory inversion on .complete ============ */
.answer-panel { transition: background .5s ease, border-color .5s ease; }
.answer {
  line-height: 1.78; font-size: 16px; color: var(--text); white-space: normal; overflow-wrap: anywhere;
  /* the ANSWER scrolls within its own pane (its own slide bar) — a long answer no longer grows the page */
  max-height: 62vh; overflow-y: auto; padding-right: 6px;
}
.answer.muted { max-height: none; }  /* empty/placeholder state needs no inner scroll */
.answer p { margin: 0 0 .75em; }
.answer p:last-child { margin-bottom: 0; }
.answer ol { margin: 0; padding-left: 1.35em; }
.answer ul { margin: .25em 0 .35em; padding-left: 1.25em; }
.answer li { margin: .25em 0; padding-left: .15em; }
.answer li > ul { margin-top: .3em; }
.answer strong { font-weight: 700; }
.answer.muted { color: var(--text-3); }
#workspace.complete .answer-panel { background: var(--ivory-base); border-color: var(--ivory-line); }
#workspace.complete .answer-panel .panel-header { border-bottom-color: var(--ivory-line); }
#workspace.complete .answer-panel .panel-header h2 { color: var(--ivory-ink); }
#workspace.complete .answer-panel .badge { background: var(--ivory-card); border-color: var(--ivory-line); color: #6b5e4a; }
#workspace.complete .answer {
  color: var(--ivory-ink); font-family: var(--font-display); font-weight: 400; font-size: 18px;
  line-height: 1.7; animation: answer-arrive .55s cubic-bezier(.2, .7, .2, 1);
}
#workspace.complete .answer.muted { color: #6f6450; }

/* ============ RIGHT EVIDENCE — source cards + page image viewer ============ */
.source-list { display: grid; gap: 10px; }
.source-card {
  position: relative; padding: 11px 12px 11px 15px; border: 1px solid var(--hairline);
  border-radius: var(--r-md); background: var(--ink-card); animation: reveal-up .22s ease-out;
}
.source-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; border-radius: var(--r-md) 0 0 var(--r-md);
}
/* citations = exact snippet (solid coral rail); fallback = page-level (dashed muted rail) */
.source-card.exact::before { background: var(--coral); }
.source-card.exact { box-shadow: 0 0 0 1px rgba(217, 119, 87, .12); }
.source-card.fallback::before { background: repeating-linear-gradient(0deg, var(--hairline-lit) 0 4px, transparent 4px 8px); }
/* guidance = trace source_summary_cards demoted below real sources (faint dotted rail, dimmed) */
.source-card.guidance::before { background: repeating-linear-gradient(0deg, var(--hairline-lit) 0 2px, transparent 2px 6px); }
.source-card.guidance { opacity: .7; }
.source-card.exact.cite-pulse::before { animation: citePulse .8s ease-out; }
.source-top { display: flex; align-items: center; gap: 8px; }
.source-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-3); }
.source-kind-pill {
  margin-left: auto; padding: 1px 8px; border-radius: 999px; font-family: var(--font-mono);
  font-size: 10px; white-space: nowrap;
}
.source-card.exact .source-kind-pill { background: var(--coral); color: #1a120e; }
.source-card.fallback .source-kind-pill { background: transparent; border: 1px dashed var(--hairline-lit); color: var(--text-3); }
.source-card.guidance .source-kind-pill { background: transparent; border: 1px dotted var(--hairline-lit); color: var(--text-3); }
.source-title { margin-top: 4px; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.source-preview { margin-top: 6px; color: var(--text-2); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
.source-actions { margin-top: 9px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.source-actions button {
  color: var(--sig-cyan); background: transparent; border: 1px solid var(--hairline-lit);
  border-radius: var(--r-sm); padding: 3px 9px; cursor: pointer; font-size: 12px;
}
.source-actions button:hover { border-color: var(--sig-cyan); }
.source-actions .source-trace { color: var(--text-3); font-family: var(--font-mono); font-size: 10.5px; }
.preview-frame {
  min-height: 220px; display: grid; place-items: center; padding: 12px;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .015) 0 10px, transparent 10px 20px), var(--ink-base);
}
.preview-frame img {
  max-width: 100%; max-height: 58vh; display: block; border-radius: var(--r-sm);
  border: 1px solid var(--hairline); animation: answer-arrive .35s ease-out;
}
.preview-skeleton {
  width: 80%; height: 200px; border-radius: var(--r-sm); background-size: 220% 100%;
  background: linear-gradient(100deg, var(--ink-card) 30%, var(--ink-card-hi) 50%, var(--ink-card) 70%);
  animation: shimmer 1.4s linear infinite;
}
.snippet-band {
  margin-top: 10px; padding: 9px 12px; border-left: 2px solid var(--sig-orange); background: var(--ink-card);
  border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--text-2); font-size: 12.5px;
  line-height: 1.5; overflow-wrap: anywhere;
}
.snippet-band .sb-label {
  display: block; margin-bottom: 3px; font-size: 9.5px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--sig-orange);
}
.empty-state { color: var(--text-3); line-height: 1.6; font-size: 13px; }

/* ============ LIFECYCLE STATES — empty | running | complete ============ */
.empty-only { display: none; }
#workspace.empty .empty-only { display: block; }
#workspace.empty .flow-only { display: none; }
#workspace.empty {
  grid-template-columns: minmax(0, 760px);
  grid-template-rows: auto 1fr;
  grid-template-areas: "mast" "main";
  justify-content: center;
}
#workspace.empty .main-stack { align-self: stretch; justify-content: center; gap: 18px; }
#workspace.empty .console-panel .panel-body { padding: 22px 22px 24px; }
#workspace.running .answer-panel { opacity: .92; }

/* masthead text + run badge + slim meta strip under the title */
.masthead {
  display: grid; align-items: center; gap: 8px 20px;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "mast-l mast-c mast-r";
}
.phase-panel { padding: 12px; }
.phase-panel .trace-link { margin-top: 10px; text-align: right; }
#current-question { display: none; }  /* hidden JS data-holder only; the question is shown in the input box */
.mast-text { grid-area: mast-c; min-width: 0; text-align: center; }
.run-badge { grid-area: mast-r; justify-self: end; }
.meta-strip {
  grid-area: meta; min-width: 0; margin-top: 10px; padding-top: 12px;
  border-top: 1px solid var(--hairline);
  display: grid; gap: 8px 18px; justify-items: end;  /* phase strip sits on the RIGHT, not centered */
  grid-template-columns: 1fr;
}
.meta-question { min-width: 0; }
.meta-q-label {
  display: block; margin-bottom: 4px; color: var(--text-3); font-family: var(--font-mono);
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
}
.meta-q-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--text); font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere;
}
.meta-lane { min-width: 0; width: min(440px, 100%); }
.meta-lane .phase-focus { padding: 9px 11px; }
.meta-lane .phase-focus-meta { display: none; }  /* keep the strip slim; full detail lives in the timeline */
.meta-lane .phase-crumbs { margin-top: 9px; }
.meta-lane .phase-progress { margin-top: 9px; }
.meta-strip .trace-link { grid-column: 1 / -1; margin-top: 0; }

/* console lede (empty) */
.console-lede { margin: 0 0 14px; color: var(--text-2); font-size: 14px; line-height: 1.6; }

/* answer scroll-to-bottom affordance (pinned in the answer panel) */
.answer-panel .panel-body { position: relative; }
.scroll-bottom-btn {
  position: absolute; right: 18px; bottom: 14px; z-index: 4;
  border: 1px solid var(--hairline-lit); background: var(--ink-card-hi); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; box-shadow: var(--shadow);
}
.scroll-bottom-btn:hover { border-color: var(--coral); }
.scroll-bottom-btn[hidden] { display: none; }
#workspace.complete .answer-panel .scroll-bottom-btn {
  background: var(--ivory-card); border-color: var(--ivory-line); color: #6b5e4a;
}

/* how-it-works pipeline (empty) */
.howto-steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.howto-step {
  --chan: var(--sig-cyan); display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 15px; border: 1px solid var(--hairline); border-left: 3px solid var(--chan);
  border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--ink-card);
}
.howto-step.plan { --chan: var(--sig-violet); }
.howto-step.locate { --chan: var(--sig-cyan); }
.howto-step.source { --chan: var(--sig-orange); }
.howto-step.compose { --chan: var(--coral); }
.howto-step .hs-no { font-family: var(--font-mono); font-size: 16px; font-weight: 600; color: var(--chan); flex: 0 0 auto; }
.howto-step .hs-text b { display: block; font-size: 13.5px; color: var(--text); }
.howto-step .hs-text p { margin: 4px 0 0; color: var(--text-2); font-size: 12px; line-height: 1.5; }
/* empty-state + masthead responsive handled in the RESPONSIVE section below */

/* ============ R1-style "思考中" block + answer typewriter ============ */
.think-block {
  border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--ink-card);
  margin-bottom: 14px; overflow: hidden; animation: card-in .22s ease-out;
}
.think-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; color: var(--text-2); font-size: 12.5px; user-select: none; }
.think-head .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sig-cyan); flex: 0 0 auto; animation: pulseDot 1.4s ease-in-out infinite; }
.think-head .chev { margin-left: auto; color: var(--text-3); font-size: 11px; transition: transform .2s ease; }
.think-block.done .think-head { cursor: pointer; }
.think-block.done .think-head .dot { animation: none; background: var(--sig-green); }
.think-block.collapsed .think-head .chev { transform: rotate(-90deg); }
.think-block.collapsed .think-log { display: none; }
.think-log { padding: 0 12px 12px; display: grid; gap: 4px; max-height: 240px; overflow-y: auto; }
.think-line {
  color: var(--text-3); font-size: 12px; line-height: 1.5; font-family: var(--font-mono);
  overflow-wrap: anywhere; animation: reveal-up .2s ease-out;
}
.answer-body { display: contents; }
.type-cursor {
  display: inline-block; width: 2px; height: 1em; vertical-align: text-bottom;
  background: var(--sig-cyan); margin-left: 1px; animation: caret-blink 1s step-end infinite;
}
@media (prefers-reduced-motion: reduce) {
  .think-line { animation: none; }
  .type-cursor { animation: none; }
}

/* ============ @keyframes ============ */
@keyframes caret-blink { 50% { opacity: 0; } }
@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--chan, var(--sig-cyan)) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes lane-flow { 0% { background-position: -60% 0; } 100% { background-position: 160% 0; } }
@keyframes lane-breathe { 0%, 100% { opacity: .85; } 50% { opacity: 1; } }
@keyframes spectrum-scan {
  0%, 100% { opacity: .25; transform: translateY(40%); }
  50% { opacity: .7; transform: translateY(0); }
}
@keyframes citePulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--coral) 55%, transparent); }
  100% { box-shadow: 0 0 0 10px transparent; }
}
@keyframes settle-flash {
  0% { background: color-mix(in srgb, var(--sig-green) 14%, var(--ink-card)); }
  100% { background: var(--ink-card); }
}
@keyframes count-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.25); color: var(--sig-cyan); }
  100% { transform: scale(1); }
}
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes reveal-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes chip-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes disclosureReveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: 220% 0; } 100% { background-position: -220% 0; } }
@keyframes answer-arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ============ RESPONSIVE ============ */
/* wide (>1100px): persistent 2-column — main reading column + evidence column (default rules above). */
@media (max-width: 1100px) {
  /* evidence folds to an off-canvas drawer; the reading column goes full-width. */
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "mast" "main" "evidence";
  }
  #workspace.empty {
    grid-template-columns: minmax(0, 760px);
    grid-template-areas: "mast" "main";
  }
  .main-stack { padding: 0; }
  /* the phase strip (evidence-stack) stays in flow; only the page-image PANEL folds to a drawer */
  .evidence-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
    width: min(420px, 92vw); padding: 14px; overflow-y: auto;
    background: var(--ink-panel); border-left: 1px solid var(--hairline);
    box-shadow: -10px 0 40px rgba(0, 0, 0, .55);
    transform: translateX(100%); transition: transform .28s cubic-bezier(.2, .7, .2, 1);
  }
  #workspace.evidence-open .evidence-panel { transform: translateX(0); }
  .evidence-close { display: inline-flex; align-items: center; justify-content: center; }
  .meta-strip { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .workspace { padding: 10px; gap: 14px; }
  .masthead {
    margin-bottom: 0; padding: 14px 16px; gap: 8px 12px;
    grid-template-columns: 1fr auto;
    grid-template-areas: "mast-c mast-r" "meta meta";
  }
  .masthead h1 { font-size: 24px; text-align: left; }
  .mast-text { text-align: left; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .howto-steps { grid-template-columns: 1fr; }
}

/* ============ prefers-reduced-motion — clamp ALL motion ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
