/* The one place for colours, type and spacing. Change tokens here first. */
:root {
  color-scheme: dark;
  --bg: #0a0d11;
  --surface: #141920;
  --raised: #1d242d;
  --line: #2a333f;
  --text: #f3f6f9;
  --text2: #b3bdc9;
  --accent: #62b3ff;
  --on-accent: #06121f;
  --rain: #ff8a7a;
  --fam-local: #62b3ff;
  --fam-regional: #f3b941;
  --fam-global: #45d093;
  --fam-ai: #ff8a52;
  --fam-service: #bda2ff;
  --danger-1: #b7e35a;
  --danger-2: #f7e03c;
  --danger-3: #ff9f2e;
  --danger-4: #ff4d4d;
  --danger-5: #c2185b;
  --font: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --size: 17px;
  --small: 14.5px;
  --big: 34px;
  --radius: 16px;
  --gap: 16px;
  --tap: 46px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f2f4f7;
    --surface: #ffffff;
    --raised: #eef1f5;
    --line: #d4dae2;
    --text: #0e141b;
    --text2: #4a5563;
    --accent: #0a66c2;
    --on-accent: #ffffff;
    --rain: #c0392b;
    --fam-local: #0a66c2;
    --fam-regional: #9a6a00;
    --fam-global: #0b7d4f;
    --fam-ai: #c2501a;
    --fam-service: #6a45c9;
    --danger-1: #5d8a00;
    --danger-2: #8a7a00;
    --danger-3: #c26a00;
    --danger-4: #c81e1e;
    --danger-5: #8e0f42;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--size)/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
h1 { font-size: 30px; line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 21px; line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 10px; }
.soft { color: var(--text2); }
.small { font-size: var(--small); }

.bar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.bar-in, main { max-width: 1040px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.bar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; }
.bar-in select { flex: 0 1 auto; min-width: 0; max-width: 58%; }
.brand { flex: none; font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; letter-spacing: -0.01em; padding: 10px 0; }
main { padding-top: 22px; padding-bottom: 72px; display: flex; flex-direction: column; gap: var(--gap); }

select, .seg button, .chip, .sort button {
  font: inherit; color: var(--text); min-height: var(--tap);
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}
select:active, .seg button:active, .chip:active, .sort button:active, .resort:active { transform: scale(0.97); }
select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; max-width: 62vw;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.seg, .sort { display: flex; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.seg button, .sort button {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0 16px; cursor: pointer; white-space: nowrap;
}
.seg button small, .sort button small { color: var(--text2); margin-left: 4px; font-size: var(--small); }
.seg button[aria-pressed="true"], .sort button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 650; }
.seg button[aria-pressed="true"] small { color: inherit; opacity: 0.8; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card > h2 { margin-bottom: 4px; }
.card > .soft { margin-bottom: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.tile .k { color: var(--text2); font-size: var(--small); }
.tile .v { font-size: var(--big); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; margin: 2px 0; }
.tile .v small { font-size: 17px; font-weight: 500; color: var(--text2); letter-spacing: 0; }

.pill { display: inline-block; font-size: 13.5px; font-weight: 600; border-radius: 999px; padding: 2px 10px; background: var(--raised); color: var(--text2); white-space: nowrap; }
.pill.agree { color: var(--fam-global); }
.pill.split { color: var(--fam-ai); }
.pill.some { color: var(--fam-regional); }
.pill.danger { color: var(--bg); font-weight: 700; }

/* comparison list */
.resorts { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.resort { display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; transition: transform 0.08s ease, border-color 0.15s ease; }
.resort:hover { border-color: var(--accent); }
.resort .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.resort .name { font-size: 20px; font-weight: 700; line-height: 1.2; }
.resort .num { font-size: 40px; font-weight: 750; line-height: 1; letter-spacing: -0.03em; text-align: right; white-space: nowrap; }
.resort .num small { font-size: 16px; font-weight: 500; color: var(--text2); letter-spacing: 0; }
.resort .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text2); font-size: var(--small); }
.resort .facts b { color: var(--text); font-weight: 600; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; align-items: end; height: 74px; }
.strip div { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; height: 100%; font-size: 12.5px; color: var(--text2); }
.strip i { display: block; width: 100%; min-height: 2px; border-radius: 4px 4px 2px 2px; background: var(--accent); }
.strip i.none { background: var(--line); }

/* day rows */
.days { display: flex; flex-direction: column; }
.day { display: grid; grid-template-columns: 92px 1fr auto; gap: 2px 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: center; }
.day:first-child { border-top: 0; }
.day .when { font-weight: 600; }
.day.weekend .when { color: var(--accent); }
.day .snow { display: flex; align-items: center; gap: 10px; min-width: 0; }
.day .snow b { font-size: 22px; min-width: 2.2ch; text-align: right; }
.day .track { flex: 1; height: 10px; border-radius: 5px; background: var(--raised); position: relative; overflow: hidden; }
.day .track i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.day .track .range { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.day .track .mid { background: var(--accent); left: 0; }
.day .temps { white-space: nowrap; text-align: right; }
.day .more { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--text2); font-size: var(--small); }
.rainy { color: var(--rain); }

/* tables */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -6px; padding: 0 6px; }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--text2); font-size: 13.5px; font-weight: 600; vertical-align: bottom; }
th:first-child, td:first-child, .l { text-align: left; }
tr:last-child td { border-bottom: 0; }
.ladder td.cell { text-align: center; font-weight: 600; min-width: 66px; line-height: 1.25; }
.ladder td:first-child, .ladder th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.ladder th { text-align: center; cursor: pointer; }
.ladder th.on { color: var(--accent); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; }

/* charts */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 0 14px; font-size: var(--small); cursor: pointer; min-height: 40px; }
.chip i { width: 16px; height: 4px; border-radius: 2px; }
.chip[aria-pressed="false"] { opacity: 0.4; }
.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text2); font-size: 12.5px; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: var(--small); line-height: 1.45; min-width: 200px; max-width: 280px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35); }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .r span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.readings { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.reading { background: var(--raised); border-radius: 12px; padding: 12px 14px; }
.reading .t { font-size: 26px; font-weight: 700; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dt { font-weight: 600; }
dd { margin: 0; color: var(--text2); }
@media (max-width: 620px) {
  dl { grid-template-columns: 1fr; gap: 2px; } dd { margin-bottom: 10px; }
  h1 { font-size: 26px; }
  .card { padding: 16px 14px; }
  .day { grid-template-columns: 74px 1fr auto; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -14px; padding-right: 14px; }
  .chip { flex: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
