:root {
  --bg: #ffffff; --fg: #1d2330; --muted: #5f6b7a; --line: #e3e7ee; --accent: #1f5fbf; --card: #f7f9fc;
  --own-municipal: #1f77b4; --own-network: #2ca02c; --own-private: #d62728; --own-international: #9467bd;
  --own-special_ed: #ff7f0e; --own-unknown: #7f7f7f;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151b; --fg: #e8ebf0; --muted: #9aa5b4; --line: #2a303b; --accent: #7fb0ff; --card: #1a1f27; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }
a { color: var(--accent); }
.top { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.top nav { display: flex; gap: 14px; }
.langs { margin-inline-start: auto; display: flex; gap: 8px; }
.langs a { text-decoration: none; padding: 2px 6px; border-radius: 4px; }
.langs a.on { background: var(--accent); color: var(--bg); }
main { padding: 0 16px 24px; max-width: 1100px; margin: 0 auto; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 12px 0; align-items: center; }
.filters select { margin-inline-start: 6px; padding: 4px; }
.map { height: 60vh; min-height: 320px; border: 1px solid var(--line); border-radius: 8px; }
.schools { list-style: none; padding: 0; }
.schools li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.schools li.hidden { display: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.own-municipal { background: var(--own-municipal); } .own-network { background: var(--own-network); }
.own-private { background: var(--own-private); } .own-international { background: var(--own-international); }
.own-special_ed { background: var(--own-special_ed); } .own-unknown { background: var(--own-unknown); }
.muted { color: var(--muted); font-size: 0.92em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-top: 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.facts dt { color: var(--muted); }
.events { list-style: none; padding: 0; }
.events li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.events.past { opacity: 0.75; }
.src { font-size: 0.85em; overflow-wrap: anywhere; }
.cal { width: 100%; border-collapse: collapse; }
.cal td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.nowrap { white-space: nowrap; }
.foot { padding: 16px; color: var(--muted); font-size: 0.85em; border-top: 1px solid var(--line); text-align: center; }
@media (max-width: 640px) { .map { height: 55vh; } }
.rule { border-top: 1px solid var(--line); padding-top: 8px; }
.rule ul { padding-inline-start: 20px; }
blockquote { margin: 6px 0; padding: 6px 10px; border-inline-start: 3px solid var(--line); color: var(--muted); }
.warn { background: #fff3cd; color: #664d03; padding: 8px; border-radius: 6px; }
details.src summary { cursor: pointer; color: var(--muted); font-size: 0.9em; }
.idline { font-size: 1.05em; }
.btn { display: inline-block; padding: 4px 10px; margin: 2px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; }
.metrics td:first-child { min-width: 180px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; }
.tabs button { border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 18px; padding: 5px 12px; cursor: pointer; font: inherit; }
.tabs button.on { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.tabs .cnt { opacity: 0.7; font-size: 0.85em; }
#f-q, #f-addr { min-width: 220px; padding: 6px 8px; font: inherit; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.filters button { padding: 6px 10px; font: inherit; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); cursor: pointer; }
.dist { min-width: 52px; font-variant-numeric: tabular-nums; color: var(--accent); }
.small { font-size: 0.82em; margin: 0 0 8px; }
@media (max-width: 640px) { #f-q, #f-addr { min-width: 0; width: 100%; } }
.ses { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.facts-row { display: flex; flex-wrap: wrap; gap: 10px; }
.fact { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 110px; }
.fact b { display: block; font-size: 1.4em; }
.fact span { color: var(--muted); font-size: 0.88em; }
.mcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 14px; }
.mcard { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; border-inline-start-width: 4px; }
.mcard.tone-good { border-inline-start-color: #2ca02c; }
.mcard.tone-bad { border-inline-start-color: #d62728; }
.mcard.tone-neutral { border-inline-start-color: var(--line); }
.mtitle { font-weight: 600; }
.mvalue { font-size: 2em; font-weight: 700; line-height: 1.2; }
.mverdict { margin: 2px 0 8px; }
.bars { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: 96px 1fr 64px; gap: 6px; align-items: center; font-size: 0.85em; color: var(--muted); }
.bar .bt { background: var(--line); height: 8px; border-radius: 4px; overflow: hidden; }
.bar .bt i { display: block; height: 100%; background: var(--muted); }
.bar.me { color: var(--fg); font-weight: 600; }
.bar.me .bt i { background: var(--accent); }
.mhint { font-size: 0.8em; margin-top: 8px; }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin: 8px 0 16px; }
.spark span { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; flex: 1; max-width: 42px; }
.spark i { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; }
.spark em { font-style: normal; font-size: 11px; }
.spark small { font-size: 10px; color: var(--muted); }

/* ---------- responsive / mobile ---------- */
html { -webkit-text-size-adjust: 100%; }
body { overflow-wrap: anywhere; }
main, .card, .mcard, .filters, .schools li { min-width: 0; }
img, svg, video { max-width: 100%; height: auto; }
.tscroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.top nav { flex-wrap: wrap; }
a, button, select, input { touch-action: manipulation; }

@media (max-width: 640px) {
  body { font-size: 15px; }
  main { padding: 0 12px 20px; }
  .top { padding: 8px 12px; gap: 6px 14px; }
  .top nav { gap: 12px; }
  .langs { margin-inline-start: 0; width: 100%; justify-content: flex-end; }
  h1 { font-size: 1.45em; line-height: 1.25; }
  h2 { font-size: 1.2em; }
  .card { padding: 12px; margin-top: 10px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; white-space: nowrap; }
  .filters { flex-direction: column; align-items: stretch; gap: 8px; }
  .filters label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .filters label.check { justify-content: flex-start; }
  .filters select { flex: 1; margin: 0; min-height: 40px; }
  .filters input[type=search] { min-height: 42px; }
  .filters button { min-height: 42px; }
  #addr-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #addr-form #f-addr { grid-column: 1 / -1; }
  #addr-form #addr-msg { grid-column: 1 / -1; }
  .map { height: 50vh; min-height: 280px; }
  .schools li { padding: 10px 0; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dt { margin-top: 6px; }
  .facts dd { margin: 0; font-weight: 600; }
  .nav-buttons .btn { padding: 8px 12px; }
  .mcards { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 78px 1fr 56px; }
  .facts-row .fact { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .spark { gap: 3px; height: 110px; }
  .spark em { font-size: 9px; }
  /* calendar rows become cards */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.stack td { border: 0; padding: 1px 0; }
  table.stack td.when { font-weight: 700; }
}

/* picks: compare & favourites */
.fav, .cmpb, .link { border: 0; background: none; cursor: pointer; font: inherit; color: var(--accent); padding: 2px 4px; }
.fav { font-size: 1.15em; color: #e0a800; }
.cmpb { border: 1px solid var(--line); border-radius: 12px; font-size: 0.85em; padding: 1px 8px; }
.cmpb.on { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.cmpb:disabled { opacity: 0.4; cursor: default; }
#cmp-bar { position: fixed; inset-inline-end: 16px; bottom: 16px; z-index: 1000; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 6px 10px; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.calbtns { font-size: 0.85em; margin-top: 2px; }
table.compare th { text-align: start; vertical-align: top; padding: 6px 8px; }
table.compare tbody th { position: sticky; inset-inline-start: 0; background: var(--bg); min-width: 130px; font-weight: 600; color: var(--muted); }
table.compare td { min-width: 150px; }
