:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6e69;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6;   /* series 1: blue   -- account / rules */
  --s2: #eb6834;   /* series 2: orange -- S&P 500 / LLM   */
  --s3: #1baf7a;   /* series 3: aqua   -- exit rules      */
  --up: #006300;
  --down: #d03b3b;
  --accent-wash: #eaf2fc;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #9b9a93;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --up: #0ca30c; --down: #e66767;
    --accent-wash: #16263a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #9b9a93;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --up: #0ca30c; --down: #e66767;
  --accent-wash: #16263a; --shadow: none;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); line-height: 1.5; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.05; margin: 10px 0 12px; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.demo-banner { background: #fab219; color: #0b0b0b; text-align: center; font-weight: 600; padding: 6px 16px; font-size: 0.9rem; }

.hero { padding: 52px 0 26px; background:
  radial-gradient(1200px 380px at 12% -10%, var(--accent-wash), transparent 70%),
  radial-gradient(900px 320px at 95% 0%, rgba(235,104,52,.08), transparent 70%); }
.hero-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lede { font-size: 1.1rem; color: var(--ink-2); max-width: 70ch; margin: 0 0 6px; }
.badge { font-size: 0.78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--accent-wash); color: var(--s1); }
.status { font-size: 0.82rem; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.on .dot { background: #0ca30c; box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }
@media (prefers-reduced-motion: reduce) { .status.on .dot { animation: none; } .funnel .bar i, .tile { transition: none !important; } }

main { display: flex; flex-direction: column; gap: 18px; padding-bottom: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 820px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 0.8rem; color: var(--ink-2); }
.tile .value { font-size: clamp(1.4rem, 3.2vw, 1.9rem); font-weight: 650; letter-spacing: -0.01em; margin: 2px 0; }
.tile .sub { font-size: 0.82rem; color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.seg button { font: inherit; font-size: 0.82rem; border: 0; background: transparent; color: var(--ink-2); padding: 4px 10px; border-radius: 8px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--accent-wash); color: var(--ink); font-weight: 600; }

/* charts */
.chart { position: relative; margin-top: 10px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text, .chart .lbl { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .baseline { stroke: var(--axis); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--ink-2); margin-top: 6px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--c); vertical-align: -1px; }
.empty { color: var(--muted); font-size: 0.9rem; padding: 26px 0; text-align: center; }
.tooltip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 0.8rem; box-shadow: 0 6px 24px rgba(0,0,0,.14); max-width: 260px; }
.tooltip b { font-weight: 600; }
.tooltip .k { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tooltip .k span:first-child::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--c, transparent); }

/* tables */
table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 0.88rem; margin-top: 8px; }
th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 0.78rem; padding: 6px 6px; border-bottom: 1px solid var(--grid); }
td { padding: 7px 6px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }

/* feed */
.feed { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
@media (max-width: 820px) { .feed { grid-template-columns: minmax(0, 1fr); } }
.item { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--page); }
.item .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .tk { font-weight: 700; letter-spacing: 0.02em; }
.chip { font-size: 0.72rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); }
.act { font-size: 0.72rem; font-weight: 700; padding: 1px 8px; border-radius: 6px; letter-spacing: 0.04em; }
.act.buy { background: rgba(12,163,12,.12); color: var(--up); }
.act.sell { background: rgba(208,59,59,.12); color: var(--down); }
.act.hold { background: var(--accent-wash); color: var(--ink-2); }
.item .when { margin-left: auto; font-size: 0.75rem; color: var(--muted); }
.item .headline { font-size: 0.92rem; }
.item .why { font-size: 0.86rem; color: var(--ink-2); }
.item .trail { font-size: 0.76rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.src { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--ink-2); }
.src::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.more { margin-top: 10px; }
.more button { font: inherit; font-size: 0.85rem; border: 1px solid var(--border); background: transparent; color: var(--ink); border-radius: 10px; padding: 6px 12px; cursor: pointer; }

.footer { padding: 18px 16px 40px; }
.footer p { margin: 2px 0; }

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 560px) {
  .hide-sm { display: none; }
  table { font-size: 0.82rem; }
  td, th { padding: 6px 4px; }
}

/* today line */
.today { font-size: 1rem; color: var(--ink); max-width: 72ch; margin: 14px 0 0; padding: 10px 14px; border-left: 3px solid var(--s1); background: var(--surface); border-radius: 0 10px 10px 0; box-shadow: var(--shadow); }
.today:empty { display: none; }
.today b { font-weight: 650; }
.analysis { max-width: 72ch; margin: 12px 0 0; padding: 12px 14px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); }
.analysis[hidden] { display: none; }
.analysis-label { font-size: .75rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--s1); margin-bottom: 4px; }
.analysis p { margin: 0; font-size: .98rem; line-height: 1.55; color: var(--ink); }

/* tiles: sparkline */
.tile { position: relative; overflow: hidden; }
.tile .spark { position: absolute; right: 10px; bottom: 10px; width: 38%; height: 34px; opacity: .9; }
.tile .spark path.line { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.tile .spark path.area { opacity: .12; }
.tile .sub { position: relative; max-width: 62%; }

/* live flow */
.flow { margin-top: 14px; }
.flow svg { display: block; width: 100%; height: auto; }
.flow .link { fill: none; stroke: var(--grid); stroke-linecap: round; }
.flow .station { fill: var(--surface); stroke-width: 2.5; }
.flow .node.code .station { stroke: var(--s1); } .flow .node.model .station { stroke: var(--s2); }
.flow .node.code .hub { fill: var(--s1); } .flow .node.model .hub { fill: var(--s2); }
.flow .node .n { font-size: 22px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.flow .node .t { font-size: 13px; fill: var(--ink-2); }
.flow .node .k { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.flow .node.code .k { fill: var(--s1); } .flow .node.model .k { fill: var(--s2); }
.flow .dot { pointer-events: none; }

/* calendar heatmap */
.calendar { margin-top: 12px; }
.calendar svg { display: block; max-width: 100%; height: auto; }
.calendar .cell { rx: 4; stroke: var(--surface); stroke-width: 2; }
.calendar .lbl { fill: var(--muted); font-size: 11px; }
.cal-legend { display: flex; align-items: center; gap: 4px; font-size: 0.76rem; color: var(--muted); margin-top: 6px; }
.cal-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* feed: expandable trail */
.item { cursor: pointer; transition: border-color .2s, transform .2s; }
.item:hover { border-color: var(--axis); }
.item:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }
.item .steps { display: none; list-style: none; margin: 6px 0 0; padding: 0; }
.item.open .steps { display: block; }
.item .steps li { position: relative; padding: 0 0 10px 22px; font-size: 0.82rem; color: var(--ink-2); }
.item .steps li::before { content: ""; position: absolute; left: 4px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--s1); }
.item .steps li.model::before { background: var(--s2); }
.item .steps li::after { content: ""; position: absolute; left: 8px; top: 16px; bottom: 0; width: 1px; background: var(--grid); }
.item .steps li:last-child::after { display: none; }
.item .steps b { color: var(--ink); font-weight: 600; }
.item .hint { font-size: 0.74rem; color: var(--muted); }
.item.open .hint { display: none; }
