:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --fg: #16181d;
  --muted: #5b6270;
  --border: #dfe3e8;
  --accent: #2f5bd3;
  --accent-soft: #e8eefc;
  --talk: #146c43;
  --talk-bg: #e3f4ea;
  --watch: #8a5a00;
  --watch-bg: #fbf0d9;
  --notyet: #555c68;
  --notyet-bg: #eceef1;
  --held: #8b2f4a;
  --held-bg: #f8e6ec;
  --code-bg: #f3f4f7;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #181b21;
    --surface-2: #20242c;
    --fg: #e8eaee;
    --muted: #a0a7b4;
    --border: #2d323b;
    --accent: #8ea8ff;
    --accent-soft: #232b45;
    --talk: #7fd6a4;
    --talk-bg: #183326;
    --watch: #f0c46a;
    --watch-bg: #3a2e14;
    --notyet: #b3b9c4;
    --notyet-bg: #262a31;
    --held: #f19ab3;
    --held-bg: #3b1f29;
    --code-bg: #1d2027;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317;
  --surface: #181b21;
  --surface-2: #20242c;
  --fg: #e8eaee;
  --muted: #a0a7b4;
  --border: #2d323b;
  --accent: #8ea8ff;
  --accent-soft: #232b45;
  --talk: #7fd6a4;
  --talk-bg: #183326;
  --watch: #f0c46a;
  --watch-bg: #3a2e14;
  --notyet: #b3b9c4;
  --notyet-bg: #262a31;
  --held: #f19ab3;
  --held-bg: #3b1f29;
  --code-bg: #1d2027;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 16px; }
@media (min-width: 700px) { .wrap { padding-inline: 28px; } }

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin-bottom: 0.4rem; }
h3 { font-size: 1rem; }
p { margin: 0.4rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; }
code { background: var(--code-bg); padding: 0.05em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 0.5rem 0; border: 1px solid var(--border); }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top .wrap { padding-block: 22px 18px; }
.badge {
  display: inline-block; margin: 0 0 10px; padding: 3px 10px; border-radius: 999px;
  background: var(--watch-bg); color: var(--watch); font-weight: 600; font-size: 0.8rem; letter-spacing: 0.02em;
}
.lede { color: var(--muted); max-width: 70ch; margin-top: 6px; }
.result { font-size: 1.15rem; font-weight: 600; margin-top: 14px; max-width: 70ch; }
.breakdown { color: var(--muted); font-size: 0.9rem; max-width: 80ch; }
.pagenav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pagenav a {
  text-decoration: none; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  color: var(--fg); font-size: 0.9rem; background: var(--surface);
}
.pagenav a[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Sections */
main.wrap { padding-block: 8px 24px; }
section { margin-top: 28px; }
.section-intro { color: var(--muted); max-width: 75ch; margin-bottom: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }

/* Chips and pills */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 12px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--fg);
  padding: 5px 12px; border-radius: 999px; font: inherit; font-size: 0.88rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.static { cursor: default; }
.chip .n { color: var(--muted); margin-left: 4px; font-weight: 400; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.tier-talk { background: var(--talk-bg); color: var(--talk); }
.tier-watch { background: var(--watch-bg); color: var(--watch); }
.tier-notyet { background: var(--notyet-bg); color: var(--notyet); }
.pill-held { background: var(--held-bg); color: var(--held); }
.pill-plain { background: var(--surface-2); color: var(--muted); font-weight: 500; }

/* Account table + detail */
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1000px) { .grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
td.num, th.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.selected td { background: var(--accent-soft); }
.linklike { all: unset; cursor: pointer; font-weight: 600; color: var(--fg); }
.linklike:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.domain { color: var(--muted); font-size: 0.82rem; }

.detail { position: relative; }
@media (min-width: 1000px) { .detail { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); max-height: calc(100vh - 24px); overflow-y: auto; } }
.detail-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; justify-content: space-between; }
.score-big { font-size: 1.6rem; font-weight: 700; }
.score-big span { font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.signal-list { list-style: none; padding: 0; margin: 10px 0; }
.signal-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.signal-list li:last-child { border-bottom: 0; }
.signal-list .pts { font-weight: 700; text-align: right; }
.signal-list .zero .pts, .signal-list .zero .sig-label { color: var(--muted); font-weight: 500; }
.signal-list .ev { grid-column: 1 / -1; color: var(--muted); font-size: 0.86rem; }
.kv { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 6px 12px; margin: 12px 0; }
.kv dt { color: var(--muted); font-size: 0.86rem; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.opener { background: var(--surface-2); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 6px; margin: 6px 0; }
.mini-wrap { overflow-x: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; }
.mini-wrap table { font-size: 0.82rem; }
.mini-wrap th, .mini-wrap td { padding: 6px 8px; }
.tag { display: inline-block; font-size: 0.74rem; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); margin-left: 4px; }
.tag-agent { background: var(--held-bg); color: var(--held); }

/* Held list */
.held-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.held-item h3 { font-size: 0.98rem; margin: 8px 0 4px; overflow-wrap: anywhere; }
.held-item .next { font-size: 0.88rem; margin-top: 8px; }
.held-item ul { margin: 6px 0 0; padding-left: 18px; font-size: 0.86rem; color: var(--muted); }

/* Rules */
.rules { counter-reset: rule; list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rules li { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px 10px 50px; position: relative; }
.rules li::before {
  counter-increment: rule; content: counter(rule);
  position: absolute; left: 14px; top: 10px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.rules .count { float: right; color: var(--muted); font-size: 0.86rem; margin-left: 8px; }

/* Assumptions */
.two-col { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.weights td { white-space: normal; }
.weights td:last-child { width: 1%; }
.weights code { background: none; padding: 0; }
.weights input {
  width: 5.5em; font: inherit; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--fg);
}
.weights input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  font: inherit; font-size: 0.88rem; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.callout { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
ul.plain { padding-left: 18px; margin: 6px 0; }
ul.plain li { margin: 3px 0; }
.questions li { margin: 6px 0; font-weight: 500; }

/* Lookalikes */
.toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: 6px 0 12px; flex-wrap: wrap; }
.toggle button { font: inherit; font-size: 0.88rem; border: 0; background: var(--surface); color: var(--fg); padding: 6px 14px; cursor: pointer; }
.toggle button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.prospects { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.prospect-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.rank { color: var(--muted); font-weight: 600; margin-right: 4px; }
.reason-list { list-style: none; padding: 0; margin: 8px 0; font-size: 0.86rem; }
.reason-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.reason-list li:last-child { border-bottom: 0; }
.reason-list .why { grid-column: 1 / -1; color: var(--muted); font-size: 0.82rem; }
.reason-list .pts { font-weight: 700; }
.signal-line { font-size: 0.88rem; color: var(--muted); }
.role { font-size: 0.86rem; margin-top: 8px; }
.alt { font-size: 0.82rem; color: var(--muted); margin-top: 6px; }

.foot { padding-block: 20px 32px; color: var(--muted); font-size: 0.86rem; border-top: 1px solid var(--border); margin-top: 32px; }
