/* Investment Agent demo. Every colour is a token; dark mode redefines the tokens. */
:root {
  --bg: #ffffff;
  --panel: #f4f8f6;
  --card: #ffffff;
  --line: #e3eae6;
  --line-2: #c9d6cf;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --green: #1d5c45;
  --green-soft: #e3f0ea;
  --btn: #1d5c45;
  --btn-hover: #174a37;
  --on-btn: #ffffff;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b42318;
  --red-soft: #fee4e2;
  --grey-soft: #f2f4f5;
  --ai-line: #98a39e;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 6px 20px rgba(17, 24, 39, 0.05);
  --r: 12px;
  --font: "Inter", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "PingFang SC", monospace;
  --serif: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1210;
    --panel: #121b17;
    --card: #101815;
    --line: #22302a;
    --line-2: #35463e;
    --ink: #e7eeea;
    --ink-2: #c3cec8;
    --muted: #95a39c;
    --green: #74cfa4;
    --green-soft: #15342a;
    --btn: #3f9d75;
    --btn-hover: #4fb287;
    --on-btn: #04110b;
    --amber: #f2b45a;
    --amber-soft: #382a0f;
    --red: #f4877c;
    --red-soft: #3b1915;
    --grey-soft: #18221e;
    --ai-line: #5f6f68;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1210;
  --panel: #121b17;
  --card: #101815;
  --line: #22302a;
  --line-2: #35463e;
  --ink: #e7eeea;
  --ink-2: #c3cec8;
  --muted: #95a39c;
  --green: #74cfa4;
  --green-soft: #15342a;
  --btn: #3f9d75;
  --btn-hover: #4fb287;
  --on-btn: #04110b;
  --amber: #f2b45a;
  --amber-soft: #382a0f;
  --red: #f4877c;
  --red-soft: #3b1915;
  --grey-soft: #18221e;
  --ai-line: #5f6f68;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4, p, dl, dd, ol, ul, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--green); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 6px; }
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 32px; }
.muted { color: var(--muted); font-weight: 400; }
.mono { font-family: var(--mono); font-size: 0.86em; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.neg { color: var(--red); font-weight: 600; font-size: 0.8em; }
.eyebrow {
  font: 500 11.5px/1.4 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.skip { position: absolute; left: -9999px; top: 8px; background: var(--btn); color: var(--on-btn); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* ── Header ─────────────────────────────────────────────── */
.top { border-bottom: 1px solid var(--line); background: var(--bg); }
.top-in { display: flex; align-items: center; gap: 16px; min-height: 68px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); grid-area: brand; }
.brand-d { font: 400 42px/0.9 var(--serif); letter-spacing: -0.02em; }
.brand-txt { display: flex; flex-direction: column; gap: 3px; }
.brand-name { font: 600 15px/1 var(--font); letter-spacing: 0.32em; }
.brand-tag { font: 500 7.5px/1 var(--mono); letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; }
.brand-sep { width: 1px; height: 28px; background: var(--line-2); }
.project { font-weight: 600; font-size: 16px; grid-area: project; }
.pill {
  grid-area: pill;
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 12px/1 var(--font);
  color: var(--green); background: var(--green-soft);
  padding: 6px 10px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.controls { margin-left: auto; display: flex; align-items: center; gap: 8px; grid-area: controls; }
.lang { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 2px; }
.lang button { border: 0; background: none; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted); }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: none; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn .i-sun { display: none; }
.iconbtn[data-mode="dark"] .i-sun { display: block; }
.iconbtn[data-mode="dark"] .i-moon { display: none; }

/* ── Hero ───────────────────────────────────────────────── */
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px 48px; padding-top: 36px; padding-bottom: 28px; align-items: start; }
.hero h1 { font-size: 46px; line-height: 1.08; letter-spacing: -0.025em; font-weight: 700; margin-top: 8px; }
.hero-line { font-size: 19px; line-height: 1.5; color: var(--ink-2); margin-top: 12px; max-width: 36em; }
.hero-cta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 22px; }
.case-note { margin-top: 16px; font-size: 14px; color: var(--muted); max-width: 40em; }
.case-note b { color: var(--ink); }
.io { display: grid; gap: 10px; counter-reset: io; }
.io li { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px 12px 52px; }
.io li::before {
  counter-increment: io; content: counter(io);
  position: absolute; left: 14px; top: 13px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font: 600 12px/1 var(--mono); background: var(--card); border: 1px solid var(--line-2); color: var(--muted);
}
.io .io-dec { background: var(--green-soft); border-color: transparent; }
.io .io-dec::before { content: "D"; font: 400 17px/1 var(--serif); background: var(--btn); color: var(--on-btn); border-color: transparent; }
.io-k { font-weight: 600; display: block; }
.io p { font-size: 14.5px; color: var(--ink-2); }
.legend { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; font-size: 13.5px; color: var(--muted); padding-top: 4px; }
.lg { display: inline-flex; align-items: center; gap: 8px; }
.lg b { color: var(--ink); font-weight: 600; }
.lg i { width: 28px; height: 16px; border-radius: 5px; display: inline-block; }
.lg-ai i { border: 1.5px dashed var(--ai-line); background: var(--card); }
.lg-d i { border-left: 4px solid var(--green); background: var(--green-soft); }
.lg-you { font-weight: 600; color: var(--green); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 18px; border-radius: 10px; border: 1px solid var(--btn);
  background: var(--btn); color: var(--on-btn); font-weight: 600; font-size: 15px; line-height: 1.25;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.btn:disabled { opacity: 0.75; cursor: progress; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--panel); border-color: var(--line-2); }
.btn-lg { min-height: 50px; padding: 12px 24px; font-size: 16.5px; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.linkbtn { border: 0; background: none; color: var(--green); font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Case workspace ─────────────────────────────────────── */
.case { padding-bottom: 56px; scroll-margin-top: 12px; }
.casebar {
  display: flex; align-items: center; gap: 12px 32px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 20px; margin-bottom: 20px;
}
.cb-name { font-weight: 700; font-size: 18px; }
.cb-sub { font-size: 13px; }
.cb-id { margin-right: auto; }
.cb-val { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.cb-reset { font-size: 13.5px; }
.ws { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 28px; align-items: start; }
.stepper { position: sticky; top: 16px; }
.stepper ol { display: grid; gap: 4px; }
.sp {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  border: 1px solid transparent; background: none; border-radius: 10px; padding: 9px 10px; cursor: pointer;
}
.sp:hover { background: var(--panel); }
.sp.cur { background: var(--green-soft); border-color: transparent; }
.sp-num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font: 600 12.5px/1 var(--mono); border: 1.5px solid var(--line-2); color: var(--muted); background: var(--card);
}
.sp-done .sp-num { background: var(--btn); border-color: var(--btn); color: var(--on-btn); }
.sp-needs .sp-num { border-color: var(--amber); color: var(--amber); border-style: dashed; }
.sp.cur .sp-num { box-shadow: 0 0 0 3px var(--bg); }
.sp-lbl { display: flex; flex-direction: column; font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.sp-lbl small { font-weight: 500; font-size: 12px; color: var(--muted); }
.sp-needs .sp-lbl small { color: var(--amber); }
.sp-done .sp-lbl small { color: var(--green); }
.panel { min-width: 0; display: grid; gap: 18px; }
.panel h3 { font-size: 17px; font-weight: 650; margin-bottom: 10px; }
.panel h4 { font-size: 14.5px; font-weight: 650; margin: 14px 0 8px; }
.panel h3.eyebrow { font: 500 11.5px/1.4 var(--mono); margin-bottom: 4px; }
.step-head { padding-bottom: 2px; }
.step-head h2 { font-size: 30px; line-height: 1.2; letter-spacing: -0.015em; margin-top: 4px; outline: none; }
.lead { font-size: 17.5px; color: var(--ink-2); margin-top: 6px; max-width: 46em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.callout { background: var(--panel); border-radius: var(--r); padding: 12px 16px; font-size: 14.5px; color: var(--ink-2); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.list { display: grid; gap: 6px; }
.list li { position: relative; padding-left: 18px; font-size: 15px; }
.list li::before { content: ""; position: absolute; left: 3px; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.list-x li::before { content: "✕"; width: auto; height: auto; background: none; top: 0; color: var(--red); font-size: 12px; left: 0; }

/* Brief */
.brief dl { display: grid; gap: 10px; margin-top: 10px; }
.brief dl div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
.brief dt { font-weight: 600; color: var(--muted); font-size: 14px; padding-top: 1px; }
.brief dd { font-size: 15.5px; }

/* Prerequisite */
.prereq { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; background: var(--amber-soft); color: var(--ink); border-radius: var(--r); padding: 12px 16px; font-size: 14.5px; }

/* Agent */
.agent { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 12px; justify-items: start; }
.agent-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.agent-desc { font-size: 15px; color: var(--ink-2); }
.agent-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); flex: none; }
.log { display: grid; gap: 6px; width: 100%; }
.log:empty { display: none; }
.log li { font: 400 13px/1.5 var(--mono); color: var(--ink-2); padding-left: 22px; position: relative; animation: rise 0.25s ease-out; }
.log li::before { content: "›"; position: absolute; left: 6px; color: var(--green); font-weight: 700; }
@keyframes rise { from { opacity: 0; transform: translateY(3px); } }
details.agent { padding: 10px 16px; display: block; }
details.agent summary { width: 100%; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); font-weight: 500; list-style: none; }
details.agent summary::-webkit-details-marker { display: none; }
details.agent summary::after { content: "▾"; margin-left: auto; font-size: 12px; }
details.agent[open] summary::after { content: "▴"; }
details.agent .log { margin-top: 10px; }
details.agent .ok { color: var(--green); font-weight: 700; }

/* AI draft vs Derek approved */
.ai { position: relative; border: 1.5px dashed var(--ai-line); border-radius: var(--r); padding: 18px 20px; background: var(--card); }
.tag { display: inline-flex; align-items: center; gap: 7px; font: 500 11.5px/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 9px; border-radius: 6px; }
.ai > .tag:first-child, .tcard > .tag:first-child, .rcard > .tag:first-child { margin-bottom: 12px; }
.tag-ai { color: var(--muted); border: 1px dashed var(--ai-line); background: var(--grey-soft); }
.spark { font-size: 11px; }
.tag-d { color: var(--green); background: var(--green-soft); }
.tag-edit { color: var(--amber); background: var(--amber-soft); text-transform: none; letter-spacing: 0; font-family: var(--font); font-size: 13px; }
.tag-kept { color: var(--muted); background: var(--grey-soft); border: 1px solid var(--line-2); margin-bottom: 8px; }
.avatar { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--btn); color: var(--on-btn); font: 400 12px/1 var(--serif); letter-spacing: 0; }
.avatar-lg { width: 34px; height: 34px; font-size: 20px; flex: none; }
.derek { border-left: 4px solid var(--green); background: var(--green-soft); border-radius: 4px var(--r) var(--r) 4px; padding: 14px 18px; display: grid; gap: 6px; justify-items: start; }
.derek-title { font-weight: 700; font-size: 16px; }
.derek-note { font-size: 15.5px; color: var(--ink); }
.gate { border: 1.5px solid var(--green); border-radius: var(--r); padding: 16px 18px; background: var(--card); display: grid; gap: 10px; box-shadow: var(--shadow); }
.gate-edit { border-color: var(--amber); }
.gate-head { display: flex; gap: 12px; align-items: center; }
.gate-title { font-weight: 700; font-size: 16px; }
.gate-sub { font-size: 13.5px; color: var(--muted); }
.note-lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px; resize: vertical; min-height: 64px;
}
.gate-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.gate-foot { font-size: 13px; color: var(--muted); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; line-height: 1.2; padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-sup, .st-pass, .tone-green.chip { color: var(--green); background: var(--green-soft); }
.st-qual, .st-unk { color: var(--amber); background: var(--amber-soft); }
.st-unres, .st-pend { color: var(--muted); background: var(--grey-soft); border: 1px dashed var(--ai-line); }
.st-fail, .st-review, .tone-red.chip { color: var(--red); background: var(--red-soft); }
.st-against { color: var(--red); background: transparent; border-color: var(--red-soft); }
.st-new { color: var(--on-btn); background: var(--btn); }
.st-new::before { display: none; }
.tone-muted.chip { color: var(--muted); background: var(--grey-soft); }
.tone-ai.chip { color: var(--muted); background: var(--grey-soft); border: 1px dashed var(--ai-line); }

/* Tables */
.tbl-wrap { width: 100%; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { text-align: left; font: 500 11px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .is-key td { background: var(--grey-soft); }
.tbl .is-broken td { background: var(--red-soft); }
.tbl .is-new td { background: var(--green-soft); }
.tbl .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tbl-claims td:nth-child(1) { white-space: nowrap; }
.tbl-claims td:nth-child(2) { min-width: 240px; }
.tbl-claims td:nth-child(6), .tbl-claims td:nth-child(3) { color: var(--ink-2); font-size: 13.5px; }
.tbl-fin td:not(:first-child), .tbl-fin th:not(:first-child), .tbl-ch td:not(:first-child), .tbl-ch th:not(:first-child), .tbl-memo td:not(:first-child), .tbl-memo th:not(:first-child) { text-align: right; }
.src { color: var(--ink-2); }
.th { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.ai > .tag + .th { margin-top: 0; }
.th::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--green); }
.th-valuation::before { background: var(--amber); }
.th-trading::before { background: var(--ink-2); }
.oos { margin-top: 14px; font-size: 14px; color: var(--muted); }
.oos b { color: var(--ink-2); }

/* Evidence filters */
.filters { display: grid; grid-template-columns: 0.6fr repeat(3, minmax(0, 1fr)); gap: 10px; }
.flt { text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: var(--r); padding: 10px 12px; cursor: pointer; display: grid; gap: 4px; align-content: start; }
.flt:hover { border-color: var(--line-2); }
.flt[aria-pressed="true"] { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.flt-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.flt-top b { font-size: 20px; font-variant-numeric: tabular-nums; }
.flt small { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.sources summary { cursor: pointer; font-weight: 650; }
.sources .tbl-wrap { margin-top: 10px; }
.srcmini { margin-top: 10px; display: grid; gap: 4px; font-size: 14px; }

/* Moat */
.lenses { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.lens { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 6px; align-content: start; justify-items: start; background: var(--card); }
.lens.is-key { border: 1.5px dashed var(--amber); }
.lens-name { font: 500 11px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.lens-read { font-weight: 700; font-size: 16px; line-height: 1.3; }
.lens-text { font-size: 13.5px; color: var(--ink-2); }
.verdict { margin: 16px 0; padding: 14px 16px; background: var(--panel); border-radius: 10px; }
.verdict-text { font-size: 17px; font-weight: 600; margin-top: 4px; }

/* Valuation */
.formula .f { font-size: 14.5px; color: var(--ink-2); margin-top: 6px; font-variant-numeric: tabular-nums; }
.formula .f-main { font-size: 16px; color: var(--ink); font-weight: 600; margin-top: 8px; }
.fixed .fx { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.fx div { background: var(--panel); border-radius: 10px; padding: 10px 12px; }
.fx dt { font-size: 12.5px; color: var(--muted); }
.fx dd b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.fx dd small { font-size: 12px; color: var(--muted); }
.valbox { border-radius: var(--r); padding: 18px 20px; display: grid; gap: 12px; background: var(--card); }
.valbox.mode-draft { border: 1.5px dashed var(--ai-line); }
.valbox.mode-ok { border: 1.5px solid var(--green); border-left-width: 5px; }
.valbox.mode-edited { border: 1.5px dashed var(--amber); }
.valbox-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.valbox-top h3 { margin: 0; }
.vgrid { display: grid; gap: 0; }
.vrow { display: grid; grid-template-columns: minmax(170px, 1.3fr) repeat(3, minmax(0, 1fr)); gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.vrow:last-child { border-bottom: 0; }
.vhead { padding: 0 0 6px; border-bottom: 1px solid var(--line-2); }
.vh { font: 600 12px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.vh-base { color: var(--green); }
.vlabel { display: grid; font-size: 14.5px; font-weight: 600; }
.vlabel small { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.unit { color: var(--muted); font-weight: 500; }
.vcol { display: none; }
.vcell input {
  width: 100%; font: 600 16px/1.2 var(--font); font-variant-numeric: tabular-nums;
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink);
}
.vcell input:focus { border-color: var(--green); outline: 2px solid var(--green-soft); outline-offset: 0; }
.vcell input:placeholder-shown { border-style: dashed; border-color: var(--amber); background: var(--amber-soft); }
.vcell input::placeholder { color: var(--amber); font-weight: 600; font-style: italic; }
.vcell input[aria-invalid="true"] { border-color: var(--red); }
.vc-base input { border-color: var(--green); }
.vout { font-variant-numeric: tabular-nums; font-size: 15px; }
.vout small { display: block; font-size: 12px; color: var(--amber); }
.vrow-key .vout b { font-size: 18px; }
.unk { color: var(--amber); font-style: italic; font-weight: 600; }
.hint:empty { display: none; }
.hint { font-size: 14px; color: var(--ink-2); background: var(--amber-soft); padding: 10px 12px; border-radius: 8px; }
.unknown-note { font-size: 13px; color: var(--muted); }
.math summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--green); }
.math .f { font: 400 13px/1.6 var(--mono); color: var(--ink-2); margin-top: 6px; overflow-wrap: anywhere; }
.reverse { font-size: 15px; background: var(--panel); padding: 10px 14px; border-radius: 10px; }

/* Chart */
.chart { border-top: 1px solid var(--line); padding-top: 12px; }
.chart figcaption { font-weight: 650; font-size: 14.5px; margin-bottom: 4px; }
.plot { position: relative; height: 112px; margin: 0 6px; }
.track { position: absolute; left: 0; right: 0; top: 64px; height: 2px; background: var(--line-2); border-radius: 2px; }
.ref { position: absolute; top: 18px; bottom: 30px; width: 0; }
.ref::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; border-left: 2px solid var(--ink); }
.ref-ceil::before { border-left: 2px dashed var(--green); }
.ref span { position: absolute; top: -18px; font-size: 12.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ref.lbl-l span { right: 5px; }
.ref.lbl-r span { left: 5px; }
.ref-ceil span { color: var(--green); }
.dot { position: absolute; top: 58px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--card); border: 2.5px solid var(--ink-2); }
.dot-base { background: var(--green); border-color: var(--card); box-shadow: 0 0 0 2px var(--green); }
.dot-lbl { position: absolute; left: 7px; transform: translateX(var(--a, -50%)); white-space: nowrap; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dot-bear .dot-lbl, .dot-bull .dot-lbl { bottom: 18px; }
.dot-base .dot-lbl { top: 20px; color: var(--ink); font-weight: 600; }
.dot-lbl b { font-weight: 700; color: var(--ink); }
.axis { position: relative; height: 18px; margin: 0 6px; border-top: 1px solid var(--line); }
.axis span { position: absolute; top: 2px; transform: translateX(var(--a, -50%)); font: 400 11px/1.2 var(--mono); color: var(--muted); }
.chart-unk { font-size: 12.5px; color: var(--amber); font-style: italic; margin-top: 4px; }

/* Thesis & rule cards */
.cards2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.tcard, .rcard { border-radius: var(--r); padding: 18px 20px; background: var(--card); display: grid; gap: 4px; align-content: start; justify-items: stretch; }
.tcard > .tag, .rcard > .tag { justify-self: start; }
.tcard.is-ai { border: 1.5px dashed var(--ai-line); }
.tcard.is-derek, .rcard.is-derek { border: 1.5px solid var(--green); border-left-width: 5px; }
.tcard.is-kept { border: 1px solid var(--line-2); background: var(--grey-soft); }
.theses { display: grid; gap: 10px; margin-top: 4px; }
.theses dt { font: 500 11px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--green); }
.theses dd { font-size: 15px; }
.theses.is-muted dd { color: var(--muted); }
.theses.is-muted dt { color: var(--muted); }
.breaks { font-size: 14px; color: var(--ink-2); margin: 10px 0 8px; }
.tcard .gate, .tcard .derek { margin-top: 10px; }
.rules { display: grid; gap: 0; margin-top: 8px; }
.rules div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.rules div:last-child { border-bottom: 0; }
.rules dt { color: var(--muted); font-size: 13.5px; }
.checks { display: grid; gap: 0; }
.chk { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.chk-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.is-pass .chk-ic { background: var(--green-soft); color: var(--green); }
.is-fail .chk-ic, .is-review .chk-ic { background: var(--red-soft); color: var(--red); }
.is-unk .chk-ic { background: var(--amber-soft); color: var(--amber); }
.is-pend .chk-ic { background: var(--grey-soft); color: var(--muted); }
.chk-v { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 14px; text-align: right; }
.chk-sum { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 15px; }
.chk-sum.tone-green { background: var(--green-soft); color: var(--green); }
.chk-sum.tone-amber { background: var(--amber-soft); color: var(--amber); }
.chk-sum.tone-red { background: var(--red-soft); color: var(--red); }
.chk-sum.tone-muted { background: var(--grey-soft); color: var(--muted); }

/* Alert */
.alert { border: 1.5px solid var(--red); background: var(--red-soft); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 6px; }
.alert-title { color: var(--red); font-weight: 750; font-size: 18px; }
.alert-price { font-weight: 600; font-variant-numeric: tabular-nums; }
.insight { margin-top: 10px; font-weight: 650; font-size: 15px; background: var(--amber-soft); padding: 10px 12px; border-radius: 8px; }
.exit { margin-top: 10px; font-size: 14.5px; color: var(--ink-2); }

/* Memo */
.memo { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); padding: 26px 28px; display: grid; gap: 18px; box-shadow: var(--shadow); }
.memo.is-signed { border-color: var(--green); }
.memo-head { display: grid; gap: 6px; justify-items: start; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.memo-head h3 { font-size: 22px; margin: 0; }
.memo h4 { font-size: 16px; margin: 0 0 8px; }
.mb { position: relative; padding: 8px 12px 8px 14px; margin-bottom: 8px; border-radius: 0 8px 8px 0; font-size: 15px; }
.mb-ai { border-left: 2px dashed var(--ai-line); }
.mb-derek { border-left: 4px solid var(--green); background: var(--green-soft); }
.mb-plain { border-left: 2px solid transparent; }
.mb ul { display: grid; gap: 4px; padding-left: 18px; list-style: disc; }
.mk { font-weight: 650; font-size: 13.5px; color: var(--ink-2); }
.mtag { float: right; margin-left: 10px; font: 500 10.5px/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; }
.mtag-ai { color: var(--muted); border: 1px dashed var(--ai-line); }
.mtag-d { color: var(--green); border: 1px solid var(--green); }
.memo-foot { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.exports { display: flex; flex-wrap: wrap; gap: 10px; }
.journal h3 { margin-bottom: 2px; }
.jlist { display: grid; gap: 0; margin-top: 12px; border-left: 2px solid var(--line-2); margin-left: 6px; }
.j { display: grid; grid-template-columns: 110px 64px minmax(0, 1fr); gap: 12px; padding: 10px 0 10px 18px; position: relative; font-size: 14.5px; }
.j::before { content: ""; position: absolute; left: -7px; top: 15px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2px solid var(--ai-line); }
.j-d::before { background: var(--btn); border-color: var(--btn); }
.j-date { color: var(--muted); padding-top: 2px; }
.j-who { justify-self: start; align-self: start; font: 500 10.5px/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; }
.j-who.tag-ai { border: 1px dashed var(--ai-line); }
.j-title { font-weight: 650; }
.j-note { color: var(--ink-2); }
.j-snap { color: var(--muted); font-size: 12px; margin-top: 2px; }
.done-card { background: var(--green-soft); border-radius: var(--r); padding: 20px; display: grid; gap: 6px; justify-items: start; }
.done-title { font-size: 20px; font-weight: 750; color: var(--green); }

.stepnav { display: flex; justify-content: space-between; gap: 12px; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 6px; }

/* ── Footer ─────────────────────────────────────────────── */
.foot { border-top: 1px solid var(--line); background: var(--panel); padding: 28px 0 36px; font-size: 14px; }
.foot-one { font-weight: 650; display: flex; align-items: center; gap: 10px; }
.foot-one::before { content: "D"; font: 400 22px/1 var(--serif); }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 12px 0; }
.foot-links a { text-decoration: none; font-weight: 500; }
.foot-links a:hover { text-decoration: underline; }
.foot-links .here { color: var(--muted); font-weight: 600; }
.foot-syn { color: var(--muted); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .lenses { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fixed .fx { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cards2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 920px) {
  .wrap { padding: 0 20px; }
  .hero { grid-template-columns: minmax(0, 1fr); padding-top: 24px; }
  .ws { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .stepper { position: static; margin: 0 -20px; }
  .stepper ol { display: flex; overflow-x: auto; gap: 6px; padding: 2px 20px 6px; scrollbar-width: thin; scroll-snap-type: x proximity; }
  .stepper li { flex: none; scroll-snap-align: start; }
  .sp { padding: 7px 12px 7px 8px; border: 1px solid var(--line); }
  .sp.cur { border-color: var(--green); }
  .sp-lbl { font-size: 13.5px; white-space: nowrap; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .wrap { padding: 0 16px; }
  .stepper { margin: 0 -16px; }
  .stepper ol { padding: 2px 16px 6px; }
  .top-in {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px;
    grid-template-areas: "brand controls" "project pill";
    padding-top: 10px; padding-bottom: 10px;
  }
  .brand-sep { display: none; }
  .brand-d { font-size: 36px; }
  .pill { justify-self: end; }
  .project { font-size: 15px; }
  .hero h1 { font-size: 34px; }
  .hero-line { font-size: 17px; }
  .hero-cta .btn { width: 100%; }
  .casebar { padding: 12px 14px; gap: 10px 20px; }
  .cb-id { flex: 1 1 100%; }
  .step-head h2 { font-size: 25px; }
  .lead { font-size: 16px; }
  .card, .ai, .valbox, .tcard, .rcard, .gate, .agent { padding: 14px; }
  .memo { padding: 18px 14px; }
  .brief dl div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .lenses { grid-template-columns: minmax(0, 1fr); }
  .fixed .fx { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .flt small { display: none; }
  .flt[aria-pressed="true"] small { display: block; }

  /* Tables become stacked cards */
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tbl tr:last-child { border-bottom: 0; }
  .tbl td { border: 0; padding: 2px 0; }
  .tbl td[data-l]:not([data-l=""])::before { content: attr(data-l); display: block; font: 500 10.5px/1.5 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
  .tbl-claims td:nth-child(1)::before, .tbl-claims td:nth-child(2)::before, .tbl-plan td:nth-child(1)::before, .tbl-cond td:nth-child(1)::before { display: none !important; }
  .tbl-claims td:nth-child(2) { min-width: 0; font-weight: 500; }
  .tbl .is-key td, .tbl .is-broken td, .tbl .is-new td { background: none; }
  .tbl .is-key, .tbl .is-broken, .tbl .is-new { border-radius: 8px; padding: 10px; margin: 4px 0; }
  .tbl .is-key { background: var(--grey-soft); }
  .tbl .is-broken { background: var(--red-soft); }
  .tbl .is-new { background: var(--green-soft); }
  .tbl-fin tr, .tbl-ch tr, .tbl-memo tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 8px; }
  .tbl-memo tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tbl-fin td:first-child, .tbl-ch td:first-child, .tbl-memo td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .tbl-fin td:first-child::before, .tbl-ch td:first-child::before, .tbl-memo td:first-child::before { display: none !important; }
  .tbl-fin td:not(:first-child), .tbl-ch td:not(:first-child), .tbl-memo td:not(:first-child) { text-align: left; }
  .tbl-fin tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* Valuation grid: label on its own line, three inputs below */
  .vrow { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 8px; }
  .vlabel { grid-column: 1 / -1; }
  .vhead { display: none; }
  .vcol { display: block; font: 600 10.5px/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
  .vc-base .vcol { color: var(--green); }
  .vcell input { font-size: 16px; padding: 7px 8px; }
  .vout { font-size: 14px; }
  .vrow-key .vout b { font-size: 15.5px; }
  .dot-lbl, .ref span { font-size: 11.5px; }

  .chk { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .chk-v { grid-column: 2 / 3; text-align: left; grid-row: 2; font-size: 13px; }
  .chk .chip { grid-row: 1 / span 2; grid-column: 3; }
  .rules div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .j { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
  .j-body { grid-column: 1 / -1; }
  .stepnav { flex-direction: column-reverse; }
  .stepnav .btn { width: 100%; }
  .stepnav > span:empty { display: none; }
  .gate-actions .btn { width: 100%; }
  .exports .btn { width: 100%; }
  .legend { gap: 6px 16px; }
}

@media (min-width: 1700px) {
  body { font-size: 17px; }
  .wrap { max-width: 1440px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ── Print: the memo only ───────────────────────────────── */
@media print {
  :root { --bg: #fff; --card: #fff; --panel: #f4f8f6; --ink: #111827; color-scheme: light; }
  body { background: #fff; }
  .top, .hero, .casebar, .stepper, .foot, .agent, .step-head, .prereq, .gate, .derek, .exports, .journal, .done-card, .stepnav, .skip { display: none !important; }
  .ws { display: block; }
  .memo { box-shadow: none; border: 0; padding: 0; }
  .mb-derek { background: #e3f0ea !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.ai.is-ok { border: 1.5px solid var(--green); border-left-width: 5px; }
