:root {
  --bg: #f4f5f2;
  --card: #ffffff;
  --ink: #1b211e;
  --muted: #5d6963;
  --line: #dfe3de;
  --accent: #0f6b52;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ec;
  --warn: #8a4b00;
  --warn-soft: #fdf1dc;
  --bar: #9db8ae;
  --field: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --card: #1a201d;
    --ink: #e9eeeb;
    --muted: #a0aca6;
    --line: #2d3632;
    --accent: #5fd0ac;
    --accent-ink: #06231a;
    --accent-soft: #17332a;
    --warn: #f3c37a;
    --warn-soft: #33270f;
    --bar: #46665b;
    --field: #121715;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 8px 0 8px; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h2:not(:first-child) { margin-top: 24px; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0 0 10px; }
.lede { color: var(--muted); max-width: 60ch; }
.sub, .hint { color: var(--muted); font-size: 0.9rem; }
.hint { display: block; font-size: 0.82rem; line-height: 1.35; }
.eyebrow { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 16px;
  margin-top: 16px;
}

.headline { border-color: var(--accent); background: var(--accent-soft); }
.headline .eyebrow { color: var(--accent); }
.big { font-size: 2.6rem; font-weight: 700; line-height: 1.1; margin: 4px 0; font-variant-numeric: tabular-nums; }
.mid { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.suggest { display: grid; gap: 2px; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 16px; }
.field { display: block; margin-bottom: 14px; }
.grid .field { margin-bottom: 0; }
.label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.inp {
  display: flex; align-items: center;
  border: 1px solid var(--line); border-radius: 9px; background: var(--field);
  padding: 0 10px; margin-bottom: 4px;
}
.inp:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.inp i { font-style: normal; color: var(--muted); }
.inp input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: inherit;
  font: inherit; font-variant-numeric: tabular-nums; padding: 10px 6px; outline: none;
}

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--field); }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 9px 14px; font-size: 0.95rem; }
.seg.small span { padding: 5px 10px; font-size: 0.85rem; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: -3px; }

details { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
details[open] summary { margin-bottom: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 0.95rem; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

.scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
th, td { text-align: right; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
thead th { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; vertical-align: bottom; white-space: normal; }
tfoot td { font-weight: 700; border-bottom: 0; }

#cmp td:first-child { white-space: normal; min-width: 104px; }
#cmp tbody tr { cursor: pointer; }
#cmp tbody tr.sel { background: var(--accent-soft); }
#cmp tbody tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); padding-left: 8px; }
#cmp button { all: unset; cursor: pointer; font-weight: 600; display: block; }
#cmp button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
#cmp .tag { display: inline-block; font-size: 0.7rem; font-weight: 700; background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 1px 7px; margin-left: 4px; vertical-align: 1px; }
#cmp small { display: block; color: var(--muted); font-weight: 400; font-size: 0.78rem; }
.neg { color: var(--warn); }

#years input {
  width: 92px; text-align: right; font: inherit; font-variant-numeric: tabular-nums; color: inherit;
  background: var(--field); border: 1px solid var(--line); border-radius: 7px; padding: 6px 6px;
}
#years input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.explain { margin-top: 14px; }
.explain p { margin-bottom: 8px; }
.note { font-size: 0.93rem; margin-top: 12px; }
.note:empty { display: none; }
.callout { border-radius: 10px; padding: 12px 14px; background: var(--accent-soft); }
.callout.warn { background: var(--warn-soft); }
.callout.warn strong:first-child { color: var(--warn); }
.callout p:last-child { margin-bottom: 0; }

.charthead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 22px 0 10px; flex-wrap: wrap; }
.chart { display: grid; gap: 8px; }
.barrow { display: grid; grid-template-columns: 118px 1fr; gap: 10px; align-items: center; font-size: 0.88rem; }
.bartrack { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar { height: 22px; border-radius: 0 5px 5px 0; background: var(--bar); min-width: 2px; }
.barrow.best .bar { background: var(--accent); }
.barval { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.plain { margin: 0; padding-left: 20px; }
.plain li { margin-bottom: 8px; }

footer { color: var(--muted); font-size: 0.85rem; margin-top: 22px; padding: 0 2px; }

@media (max-width: 480px) {
  .big { font-size: 2.2rem; }
  table { font-size: 0.86rem; }
  th, td { padding: 8px 4px; }
  table { font-size: 0.82rem; }
  #years input { width: 76px; }
  thead th { font-size: 0.68rem; letter-spacing: 0; }
  #cmp small { display: none; }
  #cmp td:first-child { min-width: 92px; }
  .barrow { grid-template-columns: 96px 1fr; }
}

@media (max-width: 400px) {
  table { font-size: 0.78rem; }
  th, td { padding: 8px 3px; }
  #years input { width: 66px; padding: 5px 4px; }
  #cmp td:first-child { min-width: 84px; }
}
