:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7973;
  --line: #dddcd5;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0a7a3b;
  --bad: #b3261e;
  --warn-bg: #fff4d6;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9a998f;
    --line: #34332f;
    --accent: #3987e5;
    --good: #4cc27d;
    --bad: #ef6b63;
    --warn-bg: #3a3020;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --ink: #ffffff; --ink-2: #c3c2b7;
  --muted: #9a998f; --line: #34332f; --accent: #3987e5; --good: #4cc27d; --bad: #ef6b63; --warn-bg: #3a3020;
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.5; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; margin-top: 1.5rem; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.site-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem;
  padding: 1.25rem 1.5rem .75rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand h1 { font-size: 1.9rem; letter-spacing: -.01em; }
.tagline { margin: .1rem 0 0; color: var(--ink-2); font-size: 1.05rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; }
.tabs a { text-decoration: none; color: var(--ink-2); padding: .5rem .8rem; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.tabs a:hover { background: var(--surface-2); }
.tabs a.active { background: var(--ink); color: var(--surface); }

main { padding: 1.25rem 1.5rem 2rem; max-width: 1500px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.panel.wide { max-width: 1100px; margin: 0 auto; }
.lede { font-size: 1.1rem; color: var(--ink-2); max-width: 60ch; }
.hint { color: var(--muted); font-size: .85rem; margin: .25rem 0 .75rem; }

.map-layout { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 1.25rem; align-items: start; }
.side select, .controls select { font: inherit; padding: .5rem .6rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); width: 100%; }
.controls select { width: auto; }
.field-label { font-weight: 700; display: block; margin-bottom: .35rem; }
.lang-meta { color: var(--ink-2); font-size: .9rem; margin: .5rem 0 1rem; }
.panel-title { font-size: 1.2rem; margin-top: .5rem; }
.caveat { display: inline-block; background: var(--warn-bg); color: var(--ink); border-radius: 6px; padding: .1rem .45rem; font-size: .8rem; margin-top: .3rem; }

.neighbours { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.neighbours li { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; }
.nb-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.nb-name { font-weight: 700; display: flex; align-items: center; gap: .45rem; }
.nb-score { font-variant-numeric: tabular-nums; font-weight: 700; }
.nb-bar { height: 8px; background: var(--surface-2); border-radius: 4px; margin: .45rem 0 .4rem; overflow: hidden; }
.nb-bar span { display: block; height: 100%; border-radius: 4px; }
.nb-sub { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); }
.sib-tag { font-size: .72rem; font-weight: 700; color: var(--good); border: 1px solid var(--good); border-radius: 999px; padding: 0 .4rem; }
.swatch { width: 14px; height: 14px; display: inline-block; flex: none; }

.btn { font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: .5rem 1rem; cursor: pointer; }
.btn.small { padding: .25rem .7rem; font-size: .8rem; }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.big { font-size: 1.15rem; padding: .8rem 1.5rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .seg button:focus-visible, .tabs a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.play-row { margin-top: 1rem; }
.audio-note { font-size: .8rem; color: var(--muted); margin-top: .75rem; }

.controls { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .75rem; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg button { font: inherit; font-size: .88rem; font-weight: 600; border: 0; background: transparent; color: var(--ink-2);
  padding: .35rem .8rem; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.15); }

.map { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 72vh; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; touch-action: none; }
.map svg { display: block; width: 100%; height: 100%; cursor: grab; }
.map svg:active { cursor: grabbing; }
.map .pt { stroke: var(--surface); stroke-width: .6px; cursor: pointer; }
.map .pt.dim { opacity: .12; }
.map .pt.me { stroke: var(--ink); stroke-width: 2.5px; }
.map .zoom-btns { position: absolute; right: .6rem; top: .6rem; display: flex; flex-direction: column; gap: .3rem; }
.map .zoom-btns button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 1.1rem; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .6rem; font-size: .9rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend .lg-fam { gap: .6rem; }
.legend .lg-fam b { font-size: .8rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.legend .lg-note { color: var(--muted); flex-basis: 100%; }

/* World map */
.map.world { aspect-ratio: 16 / 9; }
.world .w-sphere { fill: var(--surface); }
.world .w-land { fill: var(--surface-2); }
.world .w-land.on { fill-opacity: .4; }
.world .w-borders { fill: none; stroke: var(--line); stroke-width: .6px; vector-effect: non-scaling-stroke; }
.world .w-land { stroke: var(--line); stroke-width: .6px; vector-effect: non-scaling-stroke; }
.world .w-arc { fill: none; stroke: var(--ink-2); stroke-dasharray: 5 4; stroke-linecap: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.world .w-dot { cursor: pointer; outline: none; }
.world .w-mark { stroke: var(--surface); stroke-width: 2px; }
.world .w-dot.sel .w-mark { stroke: var(--ink); stroke-width: 2.5px; }
.world .w-dot:focus-visible .w-mark { stroke: var(--accent); stroke-width: 3px; }
.world .w-leader { stroke: var(--muted); stroke-width: 1px; }
.world .w-label { font-size: 13px; font-weight: 600; fill: var(--ink-2); paint-order: stroke; stroke: var(--surface); stroke-width: 3.5px; stroke-linejoin: round; pointer-events: none; }
.world .w-dot.sel .w-label, .world .w-dot.nb .w-label { fill: var(--ink); font-weight: 700; }
.world-wrap { position: relative; }
.w-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--ink); color: var(--surface);
  padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; font-weight: 600; pointer-events: none; opacity: .92; }
.w-reset { position: absolute; right: .6rem; bottom: .6rem; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.w-card.right { left: auto; right: 3.4rem; }
.w-card { position: absolute; left: .6rem; top: .6rem; width: min(360px, calc(100% - 1.2rem)); max-height: calc(100% - 1.2rem); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem; box-shadow: 0 4px 16px rgba(0,0,0,.15); font-size: .88rem; }
.w-card svg.swatch { width: 16px; height: 16px; display: inline-block; cursor: auto; }
.w-card h3 { margin: 0; font-size: 1.15rem; display: flex; align-items: center; gap: .4rem; padding-right: 1.5rem; }
.w-card .w-fam { margin: .1rem 0 .5rem; color: var(--ink-2); font-size: .82rem; }
.w-card p { margin: 0 0 .6rem; }
.w-card dl { margin: 0 0 .6rem; display: grid; grid-template-columns: auto 1fr; gap: .25rem .7rem; }
.w-card dt { font-weight: 700; color: var(--ink-2); }
.w-card dd { margin: 0; }
.w-card .w-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.w-card .w-close { position: absolute; right: .4rem; top: .3rem; border: 0; background: none; color: var(--ink-2); font-size: 1.4rem; cursor: pointer; line-height: 1; }

.tooltip { position: fixed; pointer-events: none; background: var(--ink); color: var(--surface); padding: .35rem .6rem;
  border-radius: 8px; font-size: .85rem; z-index: 10; max-width: 260px; }
.now-playing { margin-top: .75rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.now-playing .contour { height: 110px; }

.contour { width: 100%; height: 260px; }
.contour svg { width: 100%; height: 100%; display: block; }
.bars { display: grid; gap: .5rem; margin-top: .5rem; }
.bar-row { display: grid; grid-template-columns: 220px 1fr 70px; gap: .75rem; align-items: center; font-size: .9rem; }
.bar-track { position: relative; height: 22px; background: var(--surface-2); border-radius: 4px; }
.bar-track .v { position: absolute; top: 3px; height: 16px; border-radius: 0 4px 4px 0; left: 0; }
.bar-track .avg { position: absolute; top: -3px; bottom: -3px; width: 3px; background: var(--ink); }
.bar-val { font-variant-numeric: tabular-nums; text-align: right; }

.privacy { border-left: 4px solid var(--good); background: var(--surface-2); padding: .75rem 1rem; border-radius: 6px; margin: 1rem 0; }
.status { color: var(--ink-2); }
.error { color: var(--bad); font-weight: 600; }

.prose { font-size: 1rem; }
.prose p, .prose li { max-width: 72ch; }
.prose img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin: .5rem 0 1rem; }
.prose table { border-collapse: collapse; width: 100%; margin: .5rem 0 1rem; font-size: .92rem; }
.prose th, .prose td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-size: .82rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.pass { color: var(--good); font-weight: 700; }
.fail { color: var(--bad); font-weight: 700; }
.callout { background: var(--warn-bg); border-radius: 10px; padding: .9rem 1.1rem; margin: 1rem 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin: 1rem 0; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: .75rem .9rem; }
.stat b { display: block; font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-2); font-size: .85rem; }
.table-wrap { overflow-x: auto; }

.site-footer { color: var(--muted); font-size: .8rem; text-align: center; padding: 1rem 1.5rem 2rem; }

@media (max-width: 900px) {
  html { font-size: 16px; }
  .map-layout { grid-template-columns: 1fr; }
  .map-area { order: -1; }
  .map { aspect-ratio: 1 / 1; }
  .map.world { aspect-ratio: 4 / 3; }
  .w-card, .w-card.right { position: relative; left: auto; right: auto; top: auto; width: auto; max-height: none; margin-top: .6rem; box-shadow: none; }
  main { padding: 1rem; }
  .site-header { padding: 1rem; }
  .bar-row { grid-template-columns: 1fr 70px; }
  .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
}

/* Reading pages (About, Validation): projector-friendly spacing */
.prose { font-size: 1.1rem; line-height: 1.65; }
.prose h2 { font-size: 1.9rem; margin-bottom: 1rem; }
.prose h3 { font-size: 1.35rem; margin-top: 2.5rem; margin-bottom: .6rem; }
.prose p { margin: 0 0 1rem; }
.prose .lede { font-size: 1.25rem; max-width: 64ch; }
.prose img { margin: 1.25rem 0 .5rem; }
.prose dl.items { margin: .5rem 0 0; max-width: 72ch; }
.prose dl.items dt { font-weight: 700; margin-top: 1.1rem; }
.prose dl.items dd { margin: .2rem 0 0; }
.prose .small-table { width: auto; min-width: 22rem; margin-top: 2.5rem; font-size: 1rem; }
