/* Tokens dealt by taste-skill (palette white-mint-tiles, type reddit, radius sharp); series colours from the dataviz palette. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f3f3f3;
  --ink: #232323;
  --muted: #686868;
  --line: #e4e4e4;
  --accent: #a1ffcb;
  --accent-ink: #232323;
  --grid: #ededed;
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --bench-1: #d99500;
  --bench-2: #e0679a;
  --bench-3: #008a17;
  --bench-4: #0f8f8a;
  --bench-5: #7d7d0a;
  --bench-6: #9a5b2e;
  --ghost: #8c8c8c;
  --up: #0b7a35;
  --down: #c8302f;
  --up-bar: #33b06a;
  --down-bar: #e2605e;
  --warn: #9a6200;
  --radius: 4px;
  --font-display: "Reddit Sans", system-ui, sans-serif;
  --font-text: "Reddit Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1b1b1b;
    --surface: #232323;
    --ink: #ffffff;
    --muted: #a4a4a4;
    --line: #333333;
    --grid: #2c2c2c;
    --series-1: #338ced;
    --series-2: #e76624;
    --series-3: #00a888;
    --bench-1: #e3a520;
    --bench-2: #e2709f;
    --bench-3: #2fb64a;
    --bench-4: #26b3ad;
    --bench-5: #b5b532;
    --bench-6: #c08455;
    --ghost: #9a9a9a;
    --up: #5fd38a;
    --down: #f27b7a;
    --up-bar: #3aa964;
    --down-bar: #d65a59;
    --warn: #f0b44c;
  }
}

/* Self-hosted so a visit calls no third party (Google Fonts would see every visitor's IP). */
@font-face { font-family: "Reddit Sans"; src: url(/fonts/reddit-sans.woff2) format("woff2"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(/fonts/jetbrains-mono.woff2) format("woff2"); font-weight: 400 500; font-display: swap; }

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); font: 400 16px/1.5 var(--font-text); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
main { max-width: 1120px; margin: 0 auto; padding: 8px 20px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 500; line-height: 1.15; letter-spacing: -0.01em; }
a { color: inherit; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.82rem; margin: 8px 0 0; }
.status { color: var(--muted); text-align: center; padding: 64px 0; }
.ticker { font-family: var(--font-mono); font-weight: 500; font-size: 0.92em; letter-spacing: -0.01em; }
.dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 8px; }

/* header: page tabs on the left, year switcher on the right */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1120px; margin: 0 auto; padding: 0 20px; min-height: 60px; display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-weight: 600; text-decoration: none; letter-spacing: -0.02em; font-size: 1.1rem; }
.views { display: flex; gap: 20px; }
.views a { text-decoration: none; color: var(--muted); padding: 18px 0 16px; border-bottom: 2px solid transparent; font-size: 0.95rem; transition: color 0.15s; }
.views a:hover { color: var(--ink); }
.views a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.years { margin-left: auto; display: flex; gap: 2px; background: var(--surface); border-radius: var(--radius); padding: 3px; }
.years[hidden], .years:empty { display: none; }
.years a { text-decoration: none; padding: 5px 12px; border-radius: 3px; color: var(--muted); font-size: 0.92rem; transition: color 0.15s, background 0.15s; }
.years a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.years a[aria-current="page"] { background: var(--ink); color: var(--bg); }

/* hero */
.hero { padding: 36px 0 8px; }
.eyebrow { margin: 0 0 10px; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; }
.hero h1 { font-size: clamp(2rem, 5.4vw, 3.6rem); letter-spacing: -0.035em; max-width: 26ch; text-wrap: balance; }
.sub { margin: 12px 0 28px; color: var(--muted); font-size: 1.05rem; }
.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 16px; }
.score { background: var(--surface); border-radius: var(--radius); padding: 20px 22px; border-top: 3px solid var(--c); }
.score header { display: flex; align-items: center; font-weight: 500; }
.score .tag { margin-left: auto; background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; font-weight: 500; padding: 2px 8px; border-radius: 3px; }
.score .big { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.8rem, 4.4vw, 2.6rem); letter-spacing: -0.03em; margin: 10px 0 2px; }
.score .today { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 0.92rem; }
.score .today span:first-child { color: var(--muted); width: 100%; font-size: 0.82rem; }
.score .today b { font-weight: 500; font-size: 1.15rem; }

/* panels */
.panel { border-top: 1px solid var(--line); padding-top: 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h2 { font-size: 1.3rem; letter-spacing: -0.02em; }
.link { color: var(--muted); font-size: 0.9rem; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }
.segmented { display: inline-flex; background: var(--surface); border-radius: var(--radius); padding: 3px; }
.segmented button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.88rem; padding: 6px 12px; border-radius: 3px; cursor: pointer; transition: color 0.15s, background 0.15s, transform 0.1s; }
.segmented button:hover { color: var(--ink); }
.segmented button:active { transform: translateY(1px); }
.segmented button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.84rem; color: var(--muted); align-items: center; }
.legend span { display: inline-flex; align-items: center; }
.legend i { display: inline-block; margin-right: 7px; }
.lg-swap { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); background: var(--bg); }
.lg-split { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 6px solid var(--muted); }
.lg-base { width: 16px; border-top: 1.5px dashed var(--muted); }
.panel > .legend { margin-bottom: 8px; }
.lg-ghost { width: 16px; border-top: 2px dashed var(--ghost); opacity: 0.8; }

/* comparison chips: toggles, shared by the hero strip and the chart */
.pills, .indices { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pills { margin-bottom: 12px; }
.indices { margin-top: 16px; font-size: 0.88rem; }
.indices > .muted { margin-right: 6px; font-size: 0.82rem; }
.chip { display: inline-flex; align-items: center; gap: 0; font: inherit; font-size: 0.84rem; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px 4px 9px; cursor: pointer; transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.1s; }
.chip .dot { width: 8px; height: 8px; margin-right: 6px; opacity: 0.35; }
.chip b { font-weight: 500; margin-left: 6px; }
.chip i { display: inline-block; margin-right: 6px; }
.chip:hover { color: var(--ink); border-color: var(--muted); }
.chip:active { transform: translateY(1px); }
.chip[aria-pressed="true"] { color: var(--ink); background: var(--surface); border-color: var(--surface); }
.chip[aria-pressed="true"] .dot { opacity: 1; }
.score .beat { margin-top: 6px; font-size: 0.85rem; color: var(--muted); }

/* chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; overflow: visible; }
.chart .grid { stroke: var(--grid); }
.chart .base { stroke: var(--muted); stroke-dasharray: 4 4; opacity: 0.6; }
.chart .year-line { stroke: var(--line); }
.chart .after { fill: color-mix(in srgb, var(--ink) 3.5%, transparent); }
.chart .axis { fill: var(--muted); font-size: 12px; }
.chart .axis.year { fill: var(--ink); font-weight: 500; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .line.ghost { stroke-dasharray: 5 4; stroke-width: 1.75; opacity: 0.55; }
.chart .line.index { stroke-width: 1.5; opacity: 0.9; }
.chart .end-label { font-size: 11px; }
.chart .end-label.ghost { opacity: 0.8; }
.chart .swap { fill: var(--bg); stroke-width: 2.5; }
.chart .split { fill: var(--muted); opacity: 0.55; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .hover circle { stroke: var(--bg); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }
.tip { position: absolute; top: 4px; pointer-events: none; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; font-size: 0.85rem; box-shadow: 0 6px 20px rgb(0 0 0 / 0.12); min-width: 200px; max-width: 300px; }
.tip-date { color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 2px; }
.tip-row b { margin-left: auto; padding-left: 16px; font-weight: 500; }
.tip-ev { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); white-space: normal; }
.tip-ev.swap { color: var(--ink); }

/* rebalance */
.swap-grid, .checks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.swap-card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; }
.swap-card header { display: flex; align-items: center; gap: 0; margin-bottom: 12px; }
.swap-card header h3 { font-size: 1.05rem; margin-right: 10px; }
.swap-card header .muted { margin-left: auto; font-size: 0.88rem; }
.swap-cols { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; }
.swap-cols h4 { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; font-weight: 500; }
.swap-cols ul { list-style: none; margin: 0; padding: 0; }
.swap-cols li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 0.92rem; }
.swap-cols .arrow { color: var(--muted); padding-top: 26px; }
.effect { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.92rem; color: var(--muted); }
.effect b { font-weight: 500; }

/* holdings */
.holdings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 32px; }
.player-holdings h3 { display: flex; align-items: center; font-size: 1.05rem; margin-bottom: 4px; }
.player-holdings ul { list-style: none; margin: 0; padding: 0; }
.player-holdings li { display: grid; grid-template-columns: 14px minmax(0, 1fr) 84px 96px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.player-holdings li.group { display: block; border: 0; padding: 16px 0 4px; font-size: 0.76rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.player-holdings li.sold > :not(.mark) { opacity: 0.5; }
.mark, .legend [class^="mark-"] { width: 9px; height: 9px; border-radius: 50%; }
li.kept .mark, .mark-kept { background: var(--ink); }
li.added .mark, .mark-added { background: var(--accent); box-shadow: 0 0 0 1.5px var(--ink); }
li.sold .mark, .mark-sold { border: 1.5px solid var(--muted); }
.h-name { min-width: 0; }
.h-name > div { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.h-name .name { color: var(--muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-name small, .h-num small { display: block; color: var(--muted); font-size: 0.78rem; }
.h-name abbr { text-decoration: none; cursor: help; color: var(--warn); }
.h-num { text-align: right; font-weight: 500; }
.bar { position: relative; height: 8px; background: linear-gradient(var(--line), var(--line)) center / 1px 100% no-repeat; }
.bar span { position: absolute; top: 0; height: 100%; min-width: 2px; }
.bar span.up { background: var(--up-bar); border-radius: 0 3px 3px 0; }
.bar span.down { background: var(--down-bar); border-radius: 3px 0 0 3px; }

/* checks */
.checks-grid h3, .checks-grid h4 { display: flex; align-items: center; font-size: 1rem; margin-bottom: 8px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.9rem; }
.checks li { display: grid; grid-template-columns: 78px 1fr; gap: 10px; align-items: baseline; }
.badge { font-size: 0.72rem; font-weight: 500; padding: 2px 6px; border-radius: 3px; text-align: center; background: var(--surface); color: var(--muted); }
.checks li.rule .badge { background: color-mix(in srgb, var(--down) 14%, transparent); color: var(--down); }
.checks li.data .badge { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.checks li.split { color: var(--muted); }

/* history */
.table-wrap { overflow-x: auto; }
.history { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.history th { text-align: left; font-weight: 400; color: var(--muted); font-size: 0.8rem; padding: 8px 12px; white-space: nowrap; }
.history td { padding: 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.history td b { font-weight: 500; }
.history td span { font-size: 0.82rem; margin-left: 6px; }
.history th.kept, .history td:nth-child(5) { border-left: 1px solid var(--line); }
.history tbody tr { cursor: pointer; transition: background 0.15s; }
.history tbody tr:hover, .history tr[aria-current="true"] { background: var(--surface); }
.history td:first-child a { font-weight: 500; text-decoration: none; }
.winner { background: var(--accent); color: var(--accent-ink); padding: 2px 8px; border-radius: 3px; font-weight: 500; }


/* every stock */
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 12px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat > span { color: var(--muted); font-size: 0.82rem; display: flex; align-items: center; }
.stat b { font-family: var(--font-display); font-weight: 500; font-size: 1.45rem; letter-spacing: -0.02em; }
.stat small { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.positions { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.positions th { text-align: left; font-weight: 400; color: var(--muted); font-size: 0.8rem; padding: 0; white-space: nowrap; }
.positions th > button { all: unset; cursor: pointer; padding: 8px 10px; display: inline-flex; gap: 4px; border-radius: 3px; }
.positions th > button:hover { color: var(--ink); background: var(--surface); }
.positions th:not(:has(button)) { padding: 8px 10px; }
.positions th[aria-sort="ascending"], .positions th[aria-sort="descending"] { color: var(--ink); }
.positions th.num { text-align: right; }
.positions td { padding: 11px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
.positions td.num { text-align: right; font-weight: 500; }
.positions td .name { color: var(--muted); font-size: 0.85rem; margin-left: 8px; display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.positions tbody tr[data-pos] { cursor: pointer; transition: background 0.15s; }
.positions tbody tr[data-pos]:hover, .positions tr.open { background: var(--surface); }
.positions tr.detail td { white-space: normal; border-top: 0; background: var(--surface); padding: 4px 16px 18px; }
.pos-detail .facts { display: flex; flex-wrap: wrap; gap: 8px 32px; font-size: 0.9rem; margin-bottom: 8px; }
.pos-detail .facts span { display: block; color: var(--muted); font-size: 0.78rem; }
.pos-detail .facts b { font-weight: 500; margin-left: 4px; }

/* lock */
.lock { max-width: 320px; margin: 15vh auto 0; display: grid; gap: 12px; }
.lock h1 { font-size: 2rem; letter-spacing: -0.03em; }
.lock p { margin: 0; }
.lock input, .lock button { font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.lock button { background: var(--ink); color: var(--bg); border-color: var(--ink); cursor: pointer; }

/* rules page */
.rules { margin: 24px 0 0; padding: 0; list-style: none; counter-reset: rule; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.rules li { counter-increment: rule; background: var(--surface); border-radius: var(--radius); padding: 16px 18px; }
.rules li::before { content: counter(rule); display: block; font-family: var(--font-mono); color: var(--muted); font-size: 0.8rem; margin-bottom: 6px; }
.rule-year { padding: 16px 0; border-top: 1px solid var(--line); }
.rule-year:first-of-type { border-top: 0; padding-top: 0; }
.rule-year > h3 { font-size: 1.1rem; margin-bottom: 12px; }
.rule-year > h3 a { text-decoration: none; }
.notes ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.9rem; display: grid; gap: 4px; }

@media (max-width: 640px) {
  main { padding: 4px 16px 48px; }
  .top-inner { gap: 4px 20px; padding-top: 8px; }
  .years { margin-left: 0; width: 100%; overflow-x: auto; margin-bottom: 8px; }
  .views a { padding: 8px 0 10px; }
  .player-holdings li { grid-template-columns: 12px minmax(0, 1fr) 52px 84px; gap: 8px; }
  .h-name .name { display: none; }
  .swap-cols { grid-template-columns: 1fr; }
  .swap-cols .arrow { display: none; }
  .checks li { grid-template-columns: 1fr; gap: 2px; }
  .badge { justify-self: start; }
  .hide-sm { display: none; }
  .positions tr[data-pos] .ticker { display: none; }
  .positions tr[data-pos] td:first-child { white-space: normal; line-height: 1.25; }
  .positions td .name { display: inline; color: var(--ink); font-size: inherit; margin-left: 0; }
  .views { gap: 14px; }
  .years a { flex: 1; text-align: center; padding: 6px 0; }
  .history td span { display: block; margin-left: 0; }
  .history td, .history th { padding-left: 8px; padding-right: 8px; }
  .positions { font-size: 0.86rem; }
  .positions td { padding: 10px 5px; }
  .positions th > button, .positions th:not(:has(button)) { padding: 8px 6px; }
  .positions td .dot { margin-right: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
