:root {
  color-scheme: light;
  --plane:#f6f3ec; --surface-1:#fffdf8;
  --text-primary:#1c2833; --text-secondary:#4a5765; --muted:#7f8c9b;
  --border:#e2dac9; --hair:#ece4d6; --grid:#ece4d6; --axis:#d9d0be;
  --gold:#9a8535; --navy:#1a2a5e; --coral:#b2544a;
  --accent-wash:#efe6d2;
  --mast-a:#214a72; --mast-b:#16314e; --mast-text:#cdd8e2;
  --shadow:0 1px 2px rgba(27,58,92,.06), 0 2px 10px rgba(27,58,92,.07);
  --display:"Space Grotesk",Inter,-apple-system,sans-serif;
  --body:Inter,-apple-system,system-ui,"Segoe UI",sans-serif;
  --serif:"Newsreader","Iowan Old Style",Palatino,Georgia,serif;
  --mono:"JetBrains Mono",ui-monospace,"SF Mono",Menlo,monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:#14161a; --surface-1:#1b1e24;
  --text-primary:#e7e3da; --text-secondary:#b3aea3; --muted:#8b8579;
  --border:#2c3037; --hair:#24272d; --grid:#2a2e35; --axis:#3a3f47;
  --gold:#c2a54e; --navy:#7ea3d8; --coral:#d1786c;
  --accent-wash:#2b3a4a;
  --mast-a:#18273a; --mast-b:#10161f; --mast-text:#b9c4d0;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 2px 10px rgba(0,0,0,.25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:#14161a; --surface-1:#1b1e24;
    --text-primary:#e7e3da; --text-secondary:#b3aea3; --muted:#8b8579;
    --border:#2c3037; --hair:#24272d; --grid:#2a2e35; --axis:#3a3f47;
    --gold:#c2a54e; --navy:#7ea3d8; --coral:#d1786c; --accent-wash:#2b3a4a;
    --mast-a:#18273a; --mast-b:#10161f; --mast-text:#b9c4d0;
  }
}

* { box-sizing: border-box; }
body { margin:0; background:var(--plane); color:var(--text-primary); font-family:var(--body);
  font-size:15px; line-height:1.55; }
a { color:var(--navy); }
a:hover { color:var(--coral); }
.wrap { max-width:1180px; margin:0 auto; padding:0 20px; }

/* masthead */
.masthead { background:linear-gradient(135deg,var(--mast-a) 0%,var(--mast-b) 100%); color:#fff;
  padding:26px 0 22px; }
.mast-top { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.eyebrow-mast { font-family:var(--mono); font-size:11.5px; letter-spacing:.11em; text-transform:uppercase;
  color:#c9b36a; border-bottom:2px solid #c9b36a; padding-bottom:4px; }
.masthead h1 { font-family:var(--display); font-size:2.05em; margin:12px 0 6px; letter-spacing:-.01em; }
.masthead h1 a { color:#fff; text-decoration:none; }
.mast-sub { font-family:var(--serif); font-size:1.12em; color:var(--mast-text); max-width:720px; margin:0 0 8px; }
.byline { font-size:13px; color:var(--mast-text); margin:0; }
.byline a { color:#fff; }
.icons { display:flex; gap:6px; }
.icon { background:transparent; border:1px solid rgba(255,255,255,.25); color:#fff; border-radius:6px;
  width:32px; height:30px; cursor:pointer; font-size:14px; }
.icon:hover { border-color:#c9b36a; }

.statline { font-family:var(--mono); font-size:12.5px; color:var(--muted); margin:16px 0 4px;
  font-variant-numeric:tabular-nums; }
.statline strong { color:var(--text-primary); font-weight:500; }

.about { max-width:820px; }
.about p { margin:10px 0; }
.eyebrow { font-family:var(--display); font-size:11px; font-weight:600; letter-spacing:.09em;
  text-transform:uppercase; color:var(--gold); margin:0 0 6px; }
.caveat { border-left:3px solid var(--gold); background:var(--surface-1); padding:10px 16px; margin:14px 0 6px;
  box-shadow:var(--shadow); border-radius:0 6px 6px 0; }
.caveat p { margin:4px 0; font-size:14px; }

/* tabs */
.tabs { display:flex; flex-wrap:wrap; gap:4px; border-bottom:1px solid var(--border); margin:22px 0 18px; }
.tabs button { font-family:var(--display); font-size:14px; font-weight:600; background:none; border:0;
  padding:9px 14px; color:var(--text-secondary); cursor:pointer; border-bottom:3px solid transparent;
  margin-bottom:-1px; }
.tabs button.active { color:var(--text-primary); border-bottom-color:var(--gold); }
.tabs button:hover { color:var(--navy); }

.card { background:var(--surface-1); border:1px solid var(--hair); border-radius:8px; padding:14px 16px;
  box-shadow:var(--shadow); margin-bottom:14px; }
.lede { max-width:820px; margin:0 0 14px; color:var(--text-secondary); }

/* graph layout */
.graph-grid { display:grid; grid-template-columns:340px minmax(0,1fr); gap:16px; align-items:start; }
.picker { position:sticky; top:10px; }
.chiprow { display:flex; flex-wrap:wrap; gap:5px; margin-bottom:7px; }
.chip { font-family:var(--display); font-size:12.5px; padding:3px 10px; border-radius:14px;
  border:1px solid var(--border); background:var(--plane); color:var(--text-secondary); cursor:pointer; }
.chip.active { background:var(--navy); border-color:var(--navy); color:var(--surface-1); }
#f-q { width:100%; padding:7px 10px; border:1px solid var(--border); border-radius:6px; font:inherit;
  font-size:14px; background:var(--plane); color:var(--text-primary); margin:2px 0 8px; }
.series-list { max-height:62vh; overflow-y:auto; border-top:1px solid var(--hair); }
.grp { font-family:var(--display); font-size:12px; font-weight:600; color:var(--gold); text-transform:uppercase;
  letter-spacing:.06em; margin:12px 0 4px; }
.sitem { display:flex; gap:8px; align-items:flex-start; padding:5px 4px; border-radius:5px; cursor:pointer;
  font-size:13.5px; line-height:1.35; }
.sitem:hover { background:var(--accent-wash); }
.sitem input { margin-top:3px; accent-color:var(--navy); }
.sitem .yrs { display:block; font-family:var(--mono); font-size:11px; color:var(--muted); margin-top:1px; }
.src { font-family:var(--mono); font-size:10.5px; color:var(--muted); border:1px solid var(--border);
  border-radius:3px; padding:0 4px; margin-right:4px; }

.controls { padding:12px 16px; }
.selected { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px; min-height:26px; }
.selected .empty { color:var(--muted); font-size:13.5px; }
.pill { display:inline-flex; align-items:center; gap:6px; font-size:12.5px; padding:3px 6px 3px 9px;
  border:1px solid var(--border); border-radius:14px; background:var(--plane); max-width:100%; }
.pill .sw { width:10px; height:10px; border-radius:50%; flex:none; }
.pill .tx { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:330px; }
.pill button { border:0; background:none; color:var(--muted); cursor:pointer; font-size:14px; padding:0 2px; }
.ctlrow { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.ctl-label { font-family:var(--display); font-size:12px; font-weight:600; color:var(--text-secondary);
  text-transform:uppercase; letter-spacing:.06em; margin-right:2px; }
.sep { width:14px; }
.seg, .act { font-family:var(--display); font-size:13px; padding:5px 11px; border-radius:6px; cursor:pointer;
  border:1px solid var(--border); background:var(--surface-1); color:var(--text-primary); }
.seg.active { background:var(--navy); border-color:var(--navy); color:var(--surface-1); }
.seg:disabled { opacity:.45; cursor:not-allowed; }
.act:hover, .seg:hover:not(.active) { border-color:var(--coral); }
.hint { font-size:13px; color:var(--muted); margin:8px 0 0; }
.chart-card { padding:8px 8px 4px; }
.chart-card h3 { font-family:var(--display); font-size:14px; margin:6px 10px 0; color:var(--text-secondary); font-weight:600; }
.chart { width:100%; height:420px; }

.values-head { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; }
.table-scroll { overflow-x:auto; }
.table-scroll.tall { max-height:70vh; overflow-y:auto; }
table { border-collapse:collapse; font-size:13px; }
table th, table td { border-bottom:1px solid var(--hair); padding:5px 9px; text-align:right; vertical-align:top; }
table th { font-family:var(--display); font-weight:600; color:var(--text-secondary); background:var(--surface-1);
  position:sticky; top:0; z-index:1; }
table td.num, table.values td, table.printed td.v { font-family:var(--mono); font-variant-numeric:tabular-nums; }
table .lab { text-align:left; position:sticky; left:0; background:var(--surface-1); z-index:2; }
table th.lab { z-index:3; }
table.values th { max-width:200px; white-space:normal; text-align:right; font-size:12px; }
.mk { color:var(--gold); font-size:11px; }
.note { font-size:12.5px; color:var(--muted); margin:8px 0 0; }

/* printed tables */
.sel { display:flex; flex-direction:column; font-size:12px; color:var(--text-secondary); gap:3px;
  font-family:var(--display); font-weight:600; text-transform:uppercase; letter-spacing:.05em; }
.sel select { font:inherit; text-transform:none; letter-spacing:0; font-weight:400; font-size:14px;
  padding:6px 8px; border:1px solid var(--border); border-radius:6px; background:var(--plane);
  color:var(--text-primary); max-width:440px; }
.wrap-row { gap:14px; align-items:flex-end; }
blockquote.title { border-left:3px solid var(--gold); padding:2px 0 2px 16px; margin:4px 0 8px;
  font-family:var(--serif); font-size:16.5px; line-height:1.5; }
.tmeta { font-family:var(--mono); font-size:12px; color:var(--muted); margin:0 0 12px; }
table.printed td.lab { min-width:240px; max-width:420px; white-space:normal; font-size:13px; }
table.printed th { font-size:12px; max-width:160px; white-space:normal; text-align:right; }
table.printed tr.total td { font-weight:600; border-top:1px solid var(--axis); }
.pair { color:var(--muted); font-size:12px; white-space:nowrap; }

/* coverage */
table.coverage td, table.coverage th { padding:2px; border:0; }
table.coverage th.yr { font-family:var(--mono); font-size:10px; color:var(--muted); writing-mode:vertical-rl;
  transform:rotate(180deg); height:42px; text-align:left; font-weight:400; }
table.coverage td.lab { font-size:12.5px; padding:2px 10px 2px 0; white-space:nowrap; cursor:pointer; max-width:420px;
  overflow:hidden; text-overflow:ellipsis; }
table.coverage tr:hover td.lab { color:var(--coral); }
.sq { width:14px; height:14px; border-radius:2px; background:var(--hair); margin:auto; }
.sq.on { background:var(--navy); }
.sq.on.caveat1 { background:var(--gold); }
.sq.on.caveat2, .sq.on.caveat3 { background:var(--coral); }
.legend-row { display:flex; gap:14px; flex-wrap:wrap; font-size:12.5px; color:var(--text-secondary); margin:10px 0 0; }
.legend-row span { display:inline-flex; align-items:center; gap:5px; }
.legend-row .sq { margin:0; }

/* breaks */
.brk { border-left:3px solid var(--gold); }
.brk h3 { font-family:var(--display); font-size:15px; margin:0 0 4px; }
.brk .bm { font-family:var(--mono); font-size:12px; color:var(--muted); margin:0 0 6px; }
.brk p { margin:4px 0; font-size:14px; }

/* downloads */
.files { list-style:none; padding:0; margin:0; }
.files li { padding:7px 0; border-bottom:1px solid var(--hair); display:flex; gap:12px; flex-wrap:wrap; align-items:baseline; }
.files a { font-family:var(--mono); font-size:13.5px; }
.files .sz { font-family:var(--mono); font-size:12px; color:var(--muted); }
.files .d { font-size:13.5px; color:var(--text-secondary); flex-basis:100%; }
.terminal { background:#10141a; border:1px solid #222a35; border-radius:10px; padding:10px 14px; color:#cdd6e3; }
.term-tabs button { background:none; border:0; color:#8a96a8; font-family:var(--mono); font-size:12.5px; cursor:pointer;
  padding:4px 10px; border-bottom:2px solid transparent; }
.term-tabs button.active { color:#7ee08a; border-bottom-color:#7ee08a; }
.terminal pre { font-family:var(--mono); font-size:12.5px; white-space:pre-wrap; overflow-wrap:anywhere; margin:8px 0 2px; }

.credit { border-top:1px solid var(--border); margin-top:40px; padding:18px 0 40px; font-size:13px; color:var(--text-secondary); }
.rule-top::before { content:""; display:block; width:46px; height:3px; background:var(--gold); margin-bottom:11px; border-radius:1px; }

/* zip download, R console look */
.zipline { margin:2px 0 0; }
.zip-mini { font-family:var(--mono); font-size:12.5px; text-decoration:none; color:var(--text-primary);
  background:var(--surface-1); border:1px solid var(--hair); border-radius:5px; padding:3px 9px; display:inline-block; }
.zip-mini:hover { border-color:#3fb950; color:var(--text-primary); }
.zip-mini .prompt, .zipterm .prompt { color:#3fb950; font-weight:500; }
.zip-mini .cm { color:var(--muted); }
.zipterm { display:block; text-decoration:none; background:#0d1117; border:1px solid #2a3240; border-radius:10px;
  padding:0 0 14px; margin:0 0 16px; color:#d6deeb; font-family:var(--mono); font-size:13.5px; box-shadow:var(--shadow);
  overflow:hidden; transition:border-color .15s, box-shadow .15s; }
.zipterm:hover { border-color:#3fb950; box-shadow:0 0 0 3px rgba(63,185,80,.18); color:#d6deeb; }
.zt-bar { display:flex; align-items:center; gap:6px; background:#161b22; padding:8px 12px; margin-bottom:10px;
  border-bottom:1px solid #2a3240; }
.zt-bar .dot { width:10px; height:10px; border-radius:50%; }
.dot.r { background:#ff5f57; } .dot.y { background:#febc2e; } .dot.g { background:#28c840; }
.zt-title { margin-left:8px; color:#8b949e; font-size:12px; }
.zt-line { display:block; padding:1px 16px; white-space:pre-wrap; overflow-wrap:anywhere; }
.zt-line.out { color:#8b949e; }
.zipterm .str { color:#a5d6ff; }
.cursor { color:#3fb950; animation:blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity:0; } }
.zt-btn { display:inline-block; margin:10px 16px 0; background:#238636; color:#fff; font-family:var(--display);
  font-weight:600; font-size:14px; padding:7px 14px; border-radius:6px; }
.zipterm:hover .zt-btn { background:#2ea043; }

/* map */
.map-wrap { position:relative; padding:0; overflow:hidden; }
#map { height:600px; background:var(--surface-1); }
.leaflet-container { font-family:var(--body); }
.map-legend { position:absolute; right:10px; bottom:10px; z-index:500; background:var(--surface-1); border:1px solid var(--hair);
  border-radius:6px; padding:8px 10px; font-size:12px; box-shadow:var(--shadow); color:var(--text-secondary); max-width:260px; }
.map-legend .lg { display:flex; align-items:center; gap:7px; margin:2px 0; }
.map-legend .c { display:inline-block; border-radius:50%; border:1.5px solid; flex:none; }
.ct-label { background:none; border:0; box-shadow:none; font-family:var(--mono); font-weight:500; font-size:11.5px;
  color:var(--text-primary); padding:0; text-shadow:0 0 3px var(--surface-1), 0 0 3px var(--surface-1); }
.ct-label::before { display:none; }
.ct-label.in { color:#fff; text-shadow:none; }
.leaflet-popup-content { font-size:13px; line-height:1.45; }
.leaflet-popup-content .pk { font-family:var(--display); font-size:11px; text-transform:uppercase; letter-spacing:.07em; color:#9a8535; font-weight:600; }
.leaflet-popup-content .pm { font-family:var(--mono); font-size:11.5px; color:#7f8c9b; }
.map-text { max-width:820px; }
.map-text p { margin:8px 0; }
table.values td.l, table.values th.l { text-align:left; }

/* mobile last */
@media (max-width: 860px) {
  .graph-grid { grid-template-columns:minmax(0,1fr); }
  .picker { position:static; }
  .series-list { max-height:40vh; }
  .masthead h1 { font-size:1.6em; }
  .chart { height:340px; }
  .pill .tx { max-width:230px; }
  .sel { width:100%; min-width:0; }
  #map { height:440px; }
  .map-legend { position:static; max-width:none; border-radius:0; border:0; border-top:1px solid var(--hair); }
  .sel select { max-width:100%; width:100%; }
  .files a { overflow-wrap:anywhere; }
  table.printed td.lab { min-width:160px; }
}
