/* TradingAgents Desk — an editorial research desk.
   Paper & ink by day, a night edition after dark. One signal colour; ratings carry their own. */

:root {
  --paper: #f3eee4;
  --paper-2: #ebe4d5;
  --card: #fbf8f1;
  --ink: #17140f;
  --ink-2: #4a443a;
  --ink-3: #857c6c;
  --rule: #d8cfbd;
  --rule-strong: #b9ad97;
  --accent: #c2410c;
  --accent-soft: #f6dccb;
  --focus: #c2410c;
  --buy: #1f6f43;
  --overweight: #4f8a35;
  --hold: #a0650a;
  --underweight: #c2510c;
  --sell: #b4231b;
  --review: #5f5596;
  --ok: #1f6f43;
  --bad: #b4231b;
  --shadow: 0 1px 0 rgba(23, 20, 15, .04), 0 10px 30px -18px rgba(23, 20, 15, .35);
  --grain-opacity: .05;

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

  --rail: 236px;
  --radius: 4px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1216; --paper-2: #151a20; --card: #1a1f26;
    --ink: #efe9dd; --ink-2: #bdb4a4; --ink-3: #847d70;
    --rule: #2a3039; --rule-strong: #3d4550;
    --accent: #f0874a; --accent-soft: #3a2418; --focus: #f0874a;
    --buy: #4cc38a; --overweight: #8bc56a; --hold: #e3a94b; --underweight: #f0874a;
    --sell: #ff6b5e; --review: #a99bf0; --ok: #4cc38a; --bad: #ff6b5e;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 14px 34px -20px rgba(0,0,0,.8);
    --grain-opacity: .035;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1216; --paper-2: #151a20; --card: #1a1f26;
  --ink: #efe9dd; --ink-2: #bdb4a4; --ink-3: #847d70;
  --rule: #2a3039; --rule-strong: #3d4550;
  --accent: #f0874a; --accent-soft: #3a2418; --focus: #f0874a;
  --buy: #4cc38a; --overweight: #8bc56a; --hold: #e3a94b; --underweight: #f0874a;
  --sell: #ff6b5e; --review: #a99bf0; --ok: #4cc38a; --bad: #ff6b5e;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 14px 34px -20px rgba(0,0,0,.8);
  --grain-opacity: .035;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Newsprint grain */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
::selection { background: var(--accent); color: var(--paper); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--rule); padding: 22px 18px 18px; background: var(--paper);
}
.wordmark { display: block; text-decoration: none; margin-bottom: 30px; }
.wordmark .w1 { font: italic 600 24px/1 var(--serif); letter-spacing: -.01em; font-variation-settings: "opsz" 72, "SOFT" 50; }
.wordmark .w2 {
  display: block; margin-top: 6px; font: 600 10.5px/1 var(--sans); letter-spacing: .32em; text-transform: uppercase; color: var(--ink-3);
}
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius);
  text-decoration: none; color: var(--ink-2); font-weight: 500; position: relative;
}
.nav a svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; }
.nav a:hover { color: var(--ink); background: var(--paper-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--card); box-shadow: inset 2px 0 0 var(--accent); }
.nav .pulse { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: none; }
.nav .pulse.on { display: block; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }

.rail-foot { margin-top: auto; display: grid; gap: 12px; }
.desk-card { border-top: 1px solid var(--rule); padding-top: 14px; font-size: 12.5px; color: var(--ink-2); }
.desk-card .label { font: 600 10px/1 var(--sans); letter-spacing: .24em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.desk-card .row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.desk-card .row span:last-child { font-family: var(--mono); font-size: 11.5px; color: var(--ink); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.theme-toggle { justify-self: start; background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--ink-2); cursor: pointer; }

.main { min-width: 0; padding: 0 clamp(16px, 4vw, 56px) 120px; }
.masthead {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap;
  padding: 16px 0 12px; border-bottom: 3px double var(--rule-strong); margin-bottom: 34px;
  font: 600 10.5px/1.2 var(--sans); letter-spacing: .26em; text-transform: uppercase; color: var(--ink-3);
}

/* ---------- Type ---------- */
.kicker { font: 600 11px/1 var(--sans); letter-spacing: .28em; text-transform: uppercase; color: var(--accent); margin: 0 0 14px; }
.headline { font: 400 clamp(34px, 5vw, 60px)/1.04 var(--serif); letter-spacing: -.02em; margin: 0; font-variation-settings: "opsz" 144, "SOFT" 30; }
.headline em { font-style: italic; }
.dek { font: 400 18px/1.5 var(--serif); color: var(--ink-2); max-width: 62ch; margin: 14px 0 0; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 44px 0 16px; }
.section-title h2 { font: 500 22px/1.2 var(--serif); margin: 0; letter-spacing: -.01em; }
.section-title .num { font: 500 13px/1 var(--mono); color: var(--ink-3); }
.section-title .hint { color: var(--ink-3); font-size: 13px; margin-left: auto; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }

/* ---------- Composer ---------- */
.composer { font: 400 clamp(30px, 4.4vw, 54px)/1.25 var(--serif); letter-spacing: -.015em; font-variation-settings: "opsz" 144; }
.composer .blank {
  display: inline-block; vertical-align: baseline; border: 0; border-bottom: 2px solid var(--ink);
  background: transparent; font: inherit; letter-spacing: inherit; padding: 0 4px; margin: 0 2px; border-radius: 0;
}
.composer .blank:focus { outline: none; border-bottom-color: var(--accent); background: var(--accent-soft); }
.composer .blank.ticker { width: 6.2ch; text-transform: uppercase; font-style: italic; }
.composer .blank.date { width: 13ch; font-size: .62em; font-family: var(--mono); letter-spacing: 0; vertical-align: .25em; }
.composer-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; min-height: 28px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule-strong); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; color: var(--ink-2); background: var(--card);
}
.tag.warn { border-color: var(--hold); color: var(--hold); }
.chip-btn { cursor: pointer; font-family: var(--mono); font-size: 12px; }
.chip-btn:hover { border-color: var(--ink); color: var(--ink); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.pick {
  position: relative; text-align: left; cursor: pointer; padding: 16px 16px 18px; border-radius: var(--radius);
  border: 1px solid var(--rule); background: var(--card); transition: border-color .15s, transform .15s, box-shadow .15s;
}
.pick:hover:not(:disabled) { border-color: var(--rule-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.pick .t { font: 500 17px/1.25 var(--serif); margin-bottom: 6px; display: block; padding-right: 26px; }
.pick .d { font-size: 13px; color: var(--ink-2); display: block; }
.pick .tick {
  position: absolute; top: 14px; right: 14px; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--rule-strong); display: grid; place-items: center;
}
.pick[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.pick[aria-pressed="true"] .tick { background: var(--ink); border-color: var(--ink); }
.pick[aria-pressed="true"] .tick::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--paper); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.pick:disabled { opacity: .45; cursor: not-allowed; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.segmented button { border: 0; background: none; padding: 14px 16px; text-align: left; cursor: pointer; border-right: 1px solid var(--rule); }
.segmented button:last-child { border-right: 0; }
.segmented button .t { font: 500 16px/1.2 var(--serif); display: block; }
.segmented button .d { font-size: 12.5px; color: var(--ink-3); display: block; margin-top: 3px; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.segmented button[aria-pressed="true"] .d { color: color-mix(in srgb, var(--paper) 70%, transparent); }

details.drawer { border-top: 1px solid var(--rule); }
details.drawer:last-of-type { border-bottom: 1px solid var(--rule); }
details.drawer > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 14px; padding: 16px 2px;
}
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary .t { font: 500 18px/1.2 var(--serif); }
details.drawer > summary .s { color: var(--ink-3); font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.drawer > summary::after { content: "+"; font: 300 22px/1 var(--sans); color: var(--ink-3); transition: transform .2s; }
details.drawer[open] > summary::after { transform: rotate(45deg); }
details.drawer .body { padding: 2px 2px 22px; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }
.field label, .field .label { display: block; font: 600 10.5px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 7px; }
.field .help { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--card);
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.mono { font-family: var(--mono); font-size: 13px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); }

table.positions { width: 100%; border-collapse: collapse; margin-top: 10px; }
table.positions th { font: 600 10px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); text-align: left; padding: 6px 6px 8px; }
table.positions td { padding: 4px 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: var(--radius); padding: 10px 16px; cursor: pointer;
  border: 1px solid var(--rule-strong); background: var(--card); font-weight: 500; text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.btn.big { padding: 14px 22px; font-size: 16px; }
.btn.quiet { border-color: transparent; background: none; color: var(--ink-2); }
.btn.quiet:hover:not(:disabled) { color: var(--ink); border-color: var(--rule); }
.btn.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
.btn .arrow { transition: transform .2s; }
.btn:hover .arrow { transform: translateX(3px); }

.actionbar {
  position: sticky; bottom: 0; z-index: 5; margin-top: 40px; padding: 14px 0 16px;
  background: var(--paper); border-top: 1px solid var(--rule);
  box-shadow: 0 -18px 18px -14px var(--paper);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.actionbar .summary { flex: 1; min-width: 220px; color: var(--ink-2); font-size: 13.5px; }
.actionbar .summary b { color: var(--ink); font-weight: 600; }

.notice { border: 1px solid var(--rule-strong); border-left: 3px solid var(--accent); background: var(--card); padding: 12px 14px; border-radius: var(--radius); font-size: 14px; }
.notice.bad { border-left-color: var(--bad); }
.notice.ok { border-left-color: var(--ok); }
.error-text { color: var(--bad); font-size: 13px; margin-top: 6px; }

/* ---------- Live ---------- */
.live-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.stats { display: flex; gap: 26px; flex-wrap: wrap; }
.stat .v { font: 500 22px/1 var(--mono); letter-spacing: -.02em; }
.stat .k { font: 600 10px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-3); margin-top: 6px; }

.pipeline { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin: 34px 0 30px; border-top: 1px solid var(--rule); }
.stage { padding: 16px 14px 18px; border-right: 1px solid var(--rule); position: relative; }
.stage:last-child { border-right: 0; }
.stage::before {
  content: ""; position: absolute; top: -1px; left: 0; height: 3px; width: 0; background: var(--ink); transition: width .6s ease;
}
.stage.active::before { width: 50%; background: var(--accent); animation: sweep 2.2s ease-in-out infinite; }
.stage.done::before { width: 100%; background: var(--ink); }
@keyframes sweep { 0% { left: 0; width: 15%; } 50% { left: 40%; width: 45%; } 100% { left: 85%; width: 15%; } }
.stage .roman { font: 500 12px/1 var(--mono); color: var(--ink-3); }
.stage h3 { font: 500 16px/1.2 var(--serif); margin: 6px 0 12px; }
.agent { display: flex; align-items: center; gap: 9px; font-size: 13px; padding: 3px 0; color: var(--ink-3); }
.agent .dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--rule-strong); flex: none; }
.agent.in_progress { color: var(--ink); font-weight: 500; }
.agent.in_progress .dot { border-color: var(--accent); background: var(--accent); animation: pulse 1.4s ease-out infinite; }
.agent.completed { color: var(--ink-2); }
.agent.completed .dot { background: var(--ink); border-color: var(--ink); }

.now { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin-top: 8px; font-size: 13.5px; min-height: 22px; }
.now .call { display: inline-flex; align-items: center; gap: 6px; }
.now .call .dot, .writing .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-out infinite; }
.now .heartbeat { font-size: 12.5px; }
.conn { font: 600 10px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; padding: 3px 7px; border-radius: 999px; border: 1px solid currentColor; }
.conn.ok { color: var(--ok); } .conn.bad { color: var(--bad); }
.writing { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; padding: 8px 12px; border: 1px dashed var(--rule-strong); border-radius: var(--radius); font-size: 13px; color: var(--ink-2); }
.agent.halted { color: var(--hold); font-weight: 500; }
.agent.halted .dot { border-radius: 2px; border-color: var(--hold); background: var(--hold); }
.agent .halt-note { font-size: 11px; color: var(--hold); margin-left: auto; white-space: nowrap; }
.stage.halted::before { width: 100%; background: var(--hold); }
.tabs button.floor { font-style: italic; }
.wire .ty.Model { color: var(--review); }
.wire .ty.Error { color: var(--bad); }
.wire .item:has(.ty.Error) .tx { color: var(--bad); }
.live-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 28px; align-items: start; }
.panel { border: 1px solid var(--rule); background: var(--card); border-radius: var(--radius); }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.panel > header h3 { margin: 0; font: 600 11px/1 var(--sans); letter-spacing: .24em; text-transform: uppercase; color: var(--ink-2); }
.wire { max-height: 68vh; overflow: auto; font: 12.5px/1.5 var(--mono); }
.wire .item { display: grid; grid-template-columns: 58px 52px minmax(0, 1fr); gap: 8px; padding: 8px 16px; border-bottom: 1px dashed var(--rule); animation: drop .35s ease; }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.wire .ts { color: var(--ink-3); }
.wire .ty { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); padding-top: 2px; }
.wire .ty.Agent { color: var(--accent); }
.wire .ty.Tool { color: var(--buy); }
.wire .tx { overflow-wrap: anywhere; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.wire .tx.open { -webkit-line-clamp: unset; }
.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 10px; border-bottom: 1px solid var(--rule); }
.tabs button { border: 0; background: none; padding: 11px 10px 10px; font-size: 13px; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button .s { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--rule-strong); margin-right: 6px; vertical-align: 1px; }
.tabs button.done .s { background: var(--ink); }
.tabs button.writing .s { background: var(--accent); }
.report-pane { padding: 20px 24px 28px; max-height: 68vh; overflow: auto; }
.empty { padding: 34px 20px; text-align: center; color: var(--ink-3); font: italic 400 17px/1.5 var(--serif); }

/* ---------- Prose (reports) ---------- */
.prose { font: 400 16px/1.68 var(--sans); max-width: 72ch; color: var(--ink); }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; line-height: 1.25; margin: 1.6em 0 .5em; }
.prose h1 { font-size: 28px; } .prose h2 { font-size: 23px; } .prose h3 { font-size: 19px; } .prose h4 { font-size: 16px; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin: .25em 0; }
.prose strong { font-weight: 600; }
.prose blockquote { margin: 1em 0; padding: 2px 16px; border-left: 2px solid var(--accent); color: var(--ink-2); font-family: var(--serif); font-style: italic; }
.prose code { font: 13px var(--mono); background: var(--paper-2); padding: 1px 5px; border-radius: 3px; }
.prose pre { background: var(--paper-2); padding: 12px 14px; overflow: auto; border-radius: var(--radius); }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0 1.4em; font-size: 14px; display: block; overflow-x: auto; }
.prose th { text-align: left; font: 600 10.5px/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1.5px solid var(--ink); padding: 8px 10px; }
.prose td { border-bottom: 1px solid var(--rule); padding: 8px 10px; font-variant-numeric: tabular-nums; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }

/* ---------- The stamp ---------- */
.stamp {
  --c: var(--ink);
  display: inline-grid; place-items: center; padding: 10px 22px 9px; transform: rotate(-4deg);
  border: 3px solid var(--c); outline: 1.5px solid var(--c); outline-offset: 3px; border-radius: 3px; color: var(--c);
  font: 800 30px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
  font-stretch: 85%; mix-blend-mode: multiply; animation: stamp .5s cubic-bezier(.2, 1.6, .4, 1) both;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='60'><filter id='r'><feTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -2.2 2.05'/></filter><rect width='100%' height='100%' filter='url(%23r)'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='60'><filter id='r'><feTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -2.2 2.05'/></filter><rect width='100%' height='100%' filter='url(%23r)'/></svg>");
}
:root[data-theme="dark"] .stamp { mix-blend-mode: normal; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stamp { mix-blend-mode: normal; } }
.stamp small { font: 600 9px/1 var(--sans); letter-spacing: .3em; margin-top: 5px; opacity: .85; }
.stamp.sm { font-size: 13px; padding: 4px 9px 4px; border-width: 2px; outline-width: 1px; outline-offset: 2px; transform: rotate(-3deg); animation: none; }
.stamp.Buy { --c: var(--buy); } .stamp.Overweight { --c: var(--overweight); } .stamp.Hold { --c: var(--hold); }
.stamp.Underweight { --c: var(--underweight); } .stamp.Sell { --c: var(--sell); } .stamp.REVIEW { --c: var(--review); }
@keyframes stamp { 0% { transform: rotate(-4deg) scale(1.6); opacity: 0; } 60% { opacity: 1; } 100% { transform: rotate(-4deg) scale(1); } }

/* ---------- Result ---------- */
.result-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 30px; align-items: center; padding-bottom: 28px; border-bottom: 1px solid var(--rule); }
.byline { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 16px; font-size: 13px; color: var(--ink-2); }
.byline b { font: 600 10px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); margin-right: 6px; }
.outcome { font-family: var(--mono); font-weight: 600; }
.outcome.up { color: var(--ok); } .outcome.down { color: var(--bad); }
.doc { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 44px; margin-top: 32px; align-items: start; }
.toc { position: sticky; top: 20px; font-size: 13px; display: grid; gap: 1px; }
.toc .grp { font: 600 10px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-3); margin: 16px 0 6px; }
.toc .grp:first-child { margin-top: 0; }
.toc a { text-decoration: none; color: var(--ink-2); padding: 4px 8px; border-left: 1px solid var(--rule); }
.toc a:hover, .toc a.on { color: var(--ink); border-left-color: var(--accent); }
.doc-section { padding-bottom: 34px; margin-bottom: 34px; border-bottom: 1px solid var(--rule); scroll-margin-top: 24px; }
.doc-section > .kicker { margin-bottom: 8px; }
.doc-section > h2 { font: 400 32px/1.15 var(--serif); letter-spacing: -.015em; margin: 0 0 20px; }
.debate { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.voice { border-top: 3px solid var(--c, var(--ink)); padding-top: 12px; }
.voice > .who { font: 600 10.5px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--c, var(--ink)); margin-bottom: 12px; }
.voice.bull { --c: var(--buy); } .voice.bear { --c: var(--sell); }
.voice.aggressive { --c: var(--accent); } .voice.conservative { --c: var(--review); } .voice.neutral { --c: var(--ink-3); }
.debate.three { grid-template-columns: repeat(3, 1fr); }
.voice .prose { font-size: 14.5px; }

/* ---------- History ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .input { max-width: 260px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { border: 1px solid var(--rule); background: var(--card); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
table.ledger { width: 100%; border-collapse: collapse; }
table.ledger th { font: 600 10px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-3); text-align: left; padding: 10px 12px; border-bottom: 1.5px solid var(--ink); }
table.ledger td { padding: 14px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.ledger tbody tr { cursor: pointer; transition: background .12s; }
table.ledger tbody tr:hover { background: var(--card); }
table.ledger .tk { font: 500 20px/1 var(--serif); }
table.ledger .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lesson { border-left: 2px solid var(--rule-strong); padding: 4px 0 4px 16px; margin: 0 0 22px; }
.lesson .meta { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.runlog { font: 12px/1.55 var(--mono); color: var(--ink-2); background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 12px 14px; max-height: 60vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

/* ---------- Backtest ---------- */
.bar { height: 6px; background: var(--paper-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }

/* ---------- Settings (section cards) ---------- */
.s-card { border: 1px solid var(--rule); background: var(--card); border-radius: var(--radius); margin-bottom: 18px; scroll-margin-top: 20px; }
.s-card > .head { padding: 16px 18px 8px; }
.s-card h2 { font: 500 18px/1.25 var(--serif); margin: 0; }
.s-card .desc { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.s-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) auto; gap: 12px; align-items: start; padding: 11px 18px; border-top: 1px solid var(--rule); }
.s-row.dirty { background: color-mix(in srgb, var(--hold) 9%, transparent); box-shadow: inset 3px 0 var(--hold); }
.s-row.deleting { background: color-mix(in srgb, var(--bad) 8%, transparent); box-shadow: inset 3px 0 var(--bad); }
.s-row.deleting .control { opacity: .5; }
.s-row.hidden { display: none; }
.s-key { font: 12.5px var(--mono); overflow-wrap: anywhere; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--paper-2); color: var(--ink-3); }
.chip.set { color: var(--ok); }
.chip.envwins { color: var(--hold); }
.fnote { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.s-foot { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 11px 18px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.s-foot .status { margin-right: auto; font-size: 13px; color: var(--ink-3); }
.s-foot .status.ok { color: var(--ok); } .s-foot .status.error { color: var(--bad); }
.s-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) auto; gap: 12px; padding: 11px 18px; border-top: 1px dashed var(--rule); }
.link-btn { border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: 6px 4px; font-size: 13px; }
.link-btn:hover:not(:disabled) { color: var(--bad); }
.link-btn:disabled { opacity: .4; cursor: default; }

/* ---------- Page entrance ---------- */
.view > * { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
.view > *:nth-child(2) { animation-delay: .05s; } .view > *:nth-child(3) { animation-delay: .1s; }
.view > *:nth-child(4) { animation-delay: .15s; } .view > *:nth-child(5) { animation-delay: .2s; }
.view > *:nth-child(n+6) { animation-delay: .25s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .live-grid { grid-template-columns: minmax(0, 1fr); }
  .doc { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .toc .grp { display: none; }
  .toc a { border: 1px solid var(--rule); border-radius: 999px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--rule); overflow-x: auto; }
  .wordmark { margin: 0; flex: none; } .wordmark .w2 { display: none; }
  .nav { display: flex; gap: 2px; } .nav a { padding: 7px 9px; } .nav a .lbl { display: none; }
  .rail-foot { display: none; }
  .pipeline { grid-template-columns: 1fr 1fr; } .stage { border-bottom: 1px solid var(--rule); }
  .debate, .debate.three { grid-template-columns: minmax(0, 1fr); }
  .segmented { grid-template-columns: 1fr; } .segmented button { border-right: 0; border-bottom: 1px solid var(--rule); }
  .result-head { grid-template-columns: 1fr; }
  .actionbar .summary .mono { display: none; }
  .actionbar .btn { width: 100%; justify-content: center; }
  .s-row, .s-add { grid-template-columns: 1fr; }
  table.ledger .hide-sm { display: none; }
}
