:root {
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --paper: #f6f5f0;
  --surface: #ffffff;
  --surface-deep: #ebe9e0;
  --text: #17181c;
  --text-soft: #3b3d45;
  --text-muted: #43464f;
  --rule: #d6d3c8;
  --rule-strong: #aaa697;
  --accent: #9a4408;
  --focus: #1c4f86;
  --tv-fill: #e8f0f7;
  --tv-line: #1c4f86;
  --tv-back: #f6e3d3;
  --tv-back-line: #9a4408;
  --shadow: 0 16px 36px -22px rgba(23, 24, 28, .4);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121318; --surface: #1a1c22; --surface-deep: #252830;
    --text: #f1f0ea; --text-soft: #d2d0c8; --text-muted: #bcbab1;
    --rule: #34373f; --rule-strong: #4f535e; --accent: #f2a35c; --focus: #8fc0ee;
    --tv-fill: #18242f; --tv-line: #8fc0ee; --tv-back: #33241a; --tv-back-line: #f2a35c;
    --shadow: 0 16px 36px -22px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121318; --surface: #1a1c22; --surface-deep: #252830;
  --text: #f1f0ea; --text-soft: #d2d0c8; --text-muted: #bcbab1;
  --rule: #34373f; --rule-strong: #4f535e; --accent: #f2a35c; --focus: #8fc0ee;
  --tv-fill: #18242f; --tv-line: #8fc0ee; --tv-back: #33241a; --tv-back-line: #f2a35c;
  --shadow: 0 16px 36px -22px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body { margin: 0; background: var(--paper); color: var(--text); font-family: var(--sans); font-size: 1.0625rem; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: .14em; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); color: var(--text); padding: .5rem .8rem; z-index: 50; }
.skip:focus { left: .5rem; top: .5rem; }
.wrap { width: min(100% - 2rem, 44rem); margin: 0 auto; }
.wrap.wide { width: min(100% - 2rem, 62rem); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem; height: 3rem; padding: 0 1rem; background: var(--surface); border-bottom: 1px solid var(--rule); font-size: .875rem; }
.topbar .home { font-weight: 650; text-decoration: none; color: var(--text-soft); flex: none; }
.topbar .spacer { flex: 1; }
.topnav { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--text-muted); text-decoration: none; padding: .3rem .55rem; border-radius: .4rem; white-space: nowrap; }
.topnav a:hover { color: var(--text); }
.icon-btn { width: 2rem; height: 2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); background: var(--surface); border: 1px solid var(--rule-strong); cursor: pointer; flex: none; padding: 0; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }
section { scroll-margin-top: 3.4rem; }
.hero { padding: 2.4rem 0 1.2rem; }
.kicker { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 .6rem; font-weight: 650; }
h1 { font-family: var(--serif); font-size: clamp(2.2rem, 6.5vw, 3.6rem); line-height: 1.05; margin: 0 0 .9rem; letter-spacing: -.01em; }
.deck { font-size: 1.2rem; line-height: 1.45; color: var(--text-soft); margin: 0 0 .8rem; max-width: 38rem; }
.byline { font-size: .8rem; color: var(--text-muted); margin: 0; }
h2 { font-family: var(--serif); font-size: clamp(1.5rem, 3.6vw, 1.9rem); line-height: 1.15; margin: 0 0 .9rem; }
p { margin: 0 0 1rem; }
.lede { font-size: 1.1rem; color: var(--text-soft); }
section { padding: 2rem 0; border-top: 1px solid var(--rule); }
section.share { border-top: 0; padding: 1.2rem 0 .4rem; }
.share h2 { font-family: var(--sans); font-size: 1.05rem; margin: 0 0 .35rem; }
.share-summary { color: var(--text-soft); margin: 0 0 .15rem; max-width: 38rem; }
.share-checked { font-size: .8rem; color: var(--text-muted); margin: 0 0 .7rem; }
.share-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.share-row .btn { min-height: 3rem; }
.share-status { font-size: .85rem; margin: .5rem 0 0; min-height: 1.2em; }
.share-status:empty { display: none; }

/* Calculator */
.calc { display: grid; gap: 1.2rem; }
@media (min-width: 52rem) { .calc { grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); } .result { grid-column: 1 / -1; } }
.controls { display: grid; gap: .9rem; align-content: start; background: var(--surface); border: 1px solid var(--rule); border-radius: 1rem; box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { font: inherit; font-size: .95rem; font-weight: 650; padding: .45rem .8rem; border-radius: 999px; border: 1.5px solid var(--rule-strong); background: var(--paper); color: var(--text-soft); cursor: pointer; min-height: 2.9rem; }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--paper); border-color: var(--text); }
.field { display: grid; gap: .3rem; }
.field > label, .lbl { font-size: .8rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.inputrow { display: flex; gap: .6rem; align-items: center; }
input[type="range"] { flex: 1; min-width: 0; min-height: 2.9rem; accent-color: var(--accent); }
input[type="number"] { font: inherit; font-size: 1.05rem; color: var(--text); background: var(--paper); border: 1.5px solid var(--rule-strong); border-radius: .55rem; padding: .55rem .7rem; width: 5.5rem; min-height: 2.9rem; }
.btn { font: inherit; font-size: .95rem; font-weight: 650; padding: .55rem .9rem; border-radius: .55rem; border: 1.5px solid currentColor; background: transparent; color: inherit; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.9rem; }
.btn:hover { background: rgba(127, 127, 127, .12); }
.comparebox { display: grid; gap: .4rem; border-top: 1px dashed var(--rule-strong); padding-top: .8rem; }
.comparebox[hidden] { display: none; }
.comparebox .lbl { margin: 0; }
.visual { margin: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 1rem; box-shadow: var(--shadow); padding: 1rem 1rem .6rem; }
.visual svg { display: block; width: 100%; height: auto; }
.visual figcaption { font-size: .82rem; color: var(--text-muted); margin: .4rem 0 .4rem; }
.tv-main { fill: var(--tv-fill); stroke: var(--tv-line); stroke-width: 2.5; }
.tv-back { fill: var(--tv-back); stroke: var(--tv-back-line); stroke-width: 2; stroke-dasharray: 7 4; }
.dim { font-family: var(--sans); font-size: 13px; font-weight: 650; fill: var(--text-soft); }
.diag { font-family: var(--sans); font-size: 20px; font-weight: 800; fill: var(--tv-line); }
.result { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); background: var(--surface-deep); border: 1px solid var(--rule); border-radius: 1rem; padding: 1rem 1.2rem; }
.stat { display: grid; gap: .1rem; }
.stat span { font-size: .8rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); font-weight: 650; }
.stat strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.delta { grid-column: 1 / -1; margin: .2rem 0 0; font-size: 1.05rem; background: var(--surface); border-left: .35rem solid var(--accent); border-radius: 0 .6rem .6rem 0; padding: .6rem .9rem; }
.delta[hidden] { display: none; }
.nojs { grid-column: 1 / -1; font-size: .85rem; color: var(--text-muted); margin: 0; }

/* Table */
.tablewrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: .8rem; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; font-variant-numeric: tabular-nums; }
caption { text-align: left; padding: .8rem 1rem .4rem; font-size: .85rem; color: var(--text-muted); caption-side: top; }
th, td { text-align: left; padding: .6rem .8rem; border-top: 1px solid var(--rule); }
thead th { border-top: 0; font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); background: var(--surface-deep); }
tbody tr.me td, tbody tr.me th { background: var(--surface-deep); font-weight: 650; }
.note { border-left: .35rem solid var(--accent); background: var(--surface); padding: .8rem 1rem; border-radius: 0 .6rem .6rem 0; margin: 1.2rem 0 0; }
.note p:last-child { margin: 0; }
details { border-bottom: 1px solid var(--rule); padding: .9rem 0; }
details:first-of-type { border-top: 1px solid var(--rule); }
summary { cursor: pointer; font-weight: 650; min-height: 2.9rem; }
summary:hover { color: var(--accent); }
details p { margin: .5rem 0 0; color: var(--text-soft); }
.sources ol li { margin: .45rem 0; word-break: break-word; }
footer { border-top: 1px solid var(--rule); padding: 1.6rem 0 2.4rem; font-size: .875rem; color: var(--text-muted); }
footer p { margin: .3rem 0; }
@media (max-width: 40rem) { .hero { padding-top: 1.6rem; } .deck { font-size: 1.08rem; } .controls { padding: .9rem; } }
