:root {
  --surface-0: #f1f5f9;
  --surface-1: #fbfcfe;
  --border: #dfe6ed;
  --text-primary: #10233a;
  --accent: #17395c;      /* deep glacier navy: selected states, buttons, route */
  --accent-soft: #e3edf6;
  --text-secondary: #4a5d70;
  --text-muted: #8696a7;
  /* category: violet / amber / teal, validated all-pairs and kept off the red–grey–blue snow scale */
  --cat-resort: #9085e9;
  --cat-freeride: #eda100;
  --cat-touring: #199e70;
  /* compare series slots 1-6 (fixed order) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;
  /* diverging snow: red (below) — grey — blue (above) */
  --d-low2: #c43c3b; --d-low1: #ee9a99; --d-mid: #c9c8c3; --d-high1: #86b6ef; --d-high2: #1c5cab;
  --radius: 10px;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  color: var(--text-primary);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--surface-0); }
button, select, input { font: inherit; }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }

#app { display: grid; grid-template-columns: 330px 1fr; grid-template-rows: 1fr auto; height: 100vh; }
#sidebar { grid-row: 1 / 3; overflow-y: auto; background: linear-gradient(180deg, #eef4fa 0, var(--surface-1) 140px); border-right: 1px solid var(--border); padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 4px; }
#mapWrap { position: relative; grid-column: 2; grid-row: 1; }
#map { position: absolute; inset: 0; }

.brand h1 { font-size: 21px; margin: 0; letter-spacing: -0.02em; color: var(--accent); }
.brand p { margin: 2px 0 6px; font-size: 12px; }
.block { padding: 10px 0; border-top: 1px solid var(--border); }
.block.grow { flex: 1; display: flex; flex-direction: column; min-height: 220px; }
.block h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin: 0 0 8px; font-weight: 600; }

.cat-toggles { display: flex; flex-direction: column; gap: 6px; }
.cat-row { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.cat-row .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.cat-row.off { opacity: .4; }
.subs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 4px 20px; }
.chip { border: 1px solid var(--border); background: var(--surface-1); border-radius: 999px; padding: 2px 9px; font-size: 12px; cursor: pointer; color: var(--text-secondary); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 8px; }
.months button { border: 1px solid var(--border); background: var(--surface-1); border-radius: 6px; padding: 4px 0; font-size: 12px; cursor: pointer; }
.months button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.months button.any { grid-column: span 6; }
.check { font-size: 13px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; }

.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.seg button { flex: 1; border: 0; background: var(--surface-1); padding: 5px 4px; font-size: 12px; cursor: pointer; color: var(--text-secondary); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: #fff; }
.range-label { font-size: 13px; color: var(--text-secondary); display: block; }
.range-label input { width: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.list-head { display: flex; justify-content: space-between; align-items: baseline; }
.list-head select { font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); }
#search { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.dest-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.dest-list li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 6px 4px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.dest-list li:hover { background: var(--surface-0); }
.dest-list li.dim { opacity: .45; }
.dest-list .dot { width: 10px; height: 10px; border-radius: 50%; }
.dest-list .sub { font-size: 11px; color: var(--text-muted); }
.pill { font-size: 11px; padding: 1px 6px; border-radius: 999px; color: var(--text-primary); background: var(--surface-0); border: 1px solid var(--border); white-space: nowrap; }

/* detail panel */
#detail { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 400px; z-index: 5; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.12); overflow-y: auto; padding: 16px 18px 20px; }
#detail .close { position: absolute; top: 10px; right: 12px; }
.close { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--text-secondary); line-height: 1; }
.d-type { font-size: 12px; display: flex; gap: 6px; align-items: center; color: var(--text-secondary); flex-wrap: wrap; }
.d-type .dot { width: 9px; height: 9px; border-radius: 50%; }
#detail h3 { margin: 6px 30px 2px 0; font-size: 20px; letter-spacing: -0.01em; }
.pitch { font-size: 14px; line-height: 1.45; margin: 8px 0 12px; }
.actions { display: flex; gap: 6px; margin: 8px 0 14px; }
.btn { border: 1px solid var(--accent); color: var(--accent); background: var(--surface-1); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; }
.btn:disabled { opacity: .4; cursor: default; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin: 16px 0 6px; font-weight: 600; }
.snowcard { background: var(--surface-0); border-radius: var(--radius); padding: 12px; }
.snow-head { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.hero { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1; }
.hero-sub { font-size: 12px; color: var(--text-secondary); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat b { display: block; font-size: 15px; }
.stat span { font-size: 11px; color: var(--text-secondary); }
.note { font-size: 11px; color: var(--text-muted); margin-top: 8px; line-height: 1.4; }
.badge { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-1); border: 1px solid var(--border); }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; margin: 0; }
.facts dt { color: var(--text-secondary); }
.facts dd { margin: 0; }
.meter { display: inline-flex; gap: 2px; vertical-align: middle; }
.meter i { width: 8px; height: 8px; border-radius: 2px; background: var(--border); }
.meter i.f { background: var(--text-secondary); }
.children { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.children li { padding: 5px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.children li b { font-weight: 600; }
.season-bar { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; margin-top: 4px; }
.season-bar div { height: 18px; border-radius: 3px; background: var(--surface-0); font-size: 10px; text-align: center; line-height: 18px; color: var(--text-muted); }
.season-bar div.in { background: var(--accent-soft); color: var(--text-secondary); }
.season-bar div.best { background: var(--accent); color: #fff; }
.season-bar div.sel { outline: 2px solid #eda100; outline-offset: -1px; }

/* charts */
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { font-size: 10px; fill: var(--text-muted); }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin: 4px 0; }
.chart-legend span { display: inline-flex; gap: 5px; align-items: center; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: #10233a; color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 6px; max-width: 260px; line-height: 1.4; }

/* map popup */
.maplibregl-popup-content { border-radius: 10px; padding: 10px 12px; box-shadow: 0 6px 20px rgba(0,0,0,.15); font-family: inherit; }
.pop h4 { margin: 0 0 2px; font-size: 14px; }
.pop .row { font-size: 12px; color: var(--text-secondary); }
.pop .big { font-size: 13px; color: var(--text-primary); margin-top: 4px; }

/* tray */
#tray { grid-column: 2; grid-row: 2; background: var(--surface-1); border-top: 1px solid var(--border); padding: 8px 14px 10px; }
.tray-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.tray-tabs button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.tray-tabs button.active { background: var(--surface-0); color: var(--text-primary); font-weight: 600; }
.tray-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; background: var(--surface-1); }
.tchip i { width: 10px; height: 10px; border-radius: 50%; }
.tchip button { border: 0; background: none; cursor: pointer; color: var(--text-muted); font-size: 15px; padding: 0 4px; }
.trip-stops { display: flex; gap: 0; align-items: stretch; overflow-x: auto; padding-bottom: 4px; }
.stop { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: 12px; min-width: 150px; background: var(--surface-1); }
.stop b { font-size: 13px; display: block; }
.stop .ctl { display: flex; gap: 2px; margin-top: 4px; }
.stop .ctl button { border: 1px solid var(--border); background: var(--surface-1); border-radius: 4px; cursor: pointer; font-size: 11px; padding: 0 5px; }
.leg { display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 11px; color: var(--text-secondary); padding: 0 8px; min-width: 90px; text-align: center; }
.leg::before { content: ""; width: 100%; border-top: 1px dashed var(--text-muted); margin-bottom: 4px; }
.fit-good { color: #006300; } .fit-ok { color: var(--text-secondary); } .fit-bad { color: #c43c3b; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(10,10,10,.35); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-card { background: var(--surface-1); border-radius: 14px; width: min(1200px, 100%); max-height: 100%; overflow: auto; padding: 20px 24px 28px; position: relative; }
.modal-card .close { position: absolute; top: 12px; right: 16px; }
.modal-card h2 { margin: 0 0 4px; font-size: 20px; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.cmp-table th, .cmp-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cmp-table th { color: var(--text-secondary); font-weight: 500; width: 150px; }
.cmp-table thead td { font-weight: 650; font-size: 14px; }
.cmp-table thead td i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 12px; }
.small-multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.sm h5 { margin: 0 0 2px; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.sm h5 i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.fab { display: none; }

/* mobile / narrow */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #sidebar { position: fixed; inset: 0 20% 0 0; z-index: 30; transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  #sidebar.open { transform: none; }
  #mapWrap, #tray { grid-column: 1; }
  #detail { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 62vh; }
  .fab { display: block; position: absolute; top: 12px; left: 12px; z-index: 6; border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 6px 10px; }
  .cmp-grid { grid-template-columns: 1fr; }
}

/* (i) definition hovers */
.info { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--text-muted); color: var(--text-muted); font: italic 600 9px/1 Georgia, serif; text-transform: none; letter-spacing: 0; cursor: help; vertical-align: 1px; margin-left: 3px; flex: none; }
.info:hover, .info:focus { border-color: var(--text-primary); color: var(--text-primary); outline: none; }
.tooltip { max-width: 300px; }
.map-btn { position: absolute; top: 10px; right: 50px; z-index: 4; border: 1px solid var(--border); background: var(--surface-1); border-radius: 6px; padding: 5px 10px; font-size: 12px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* world-view region pills */
#zoneLayer { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
#zoneLines { position: absolute; inset: 0; width: 100%; height: 100%; }
#zoneLines line { stroke: #6e86a0; stroke-width: 1; }
#zoneLines circle { fill: var(--accent); }
.zpill { position: absolute; left: 0; top: 0; pointer-events: auto; background: rgba(251,252,254,.96); border: 1px solid var(--border); border-radius: 8px; padding: 4px 7px 5px; box-shadow: 0 1px 6px rgba(23,57,92,.14); max-width: 150px; cursor: pointer; }
.zpill:hover { border-color: var(--text-secondary); z-index: 3; }
.zname { font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--text-primary); }
.zname span { color: var(--text-muted); font-weight: 500; margin-left: 2px; }
.zdots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; max-width: 136px; }
.zdots i { width: 9px; height: 9px; border-radius: 50%; display: block; cursor: pointer; }
.zdots i.out { opacity: .25; }
.zdots i.best { width: 11px; height: 11px; margin: -1px; box-shadow: 0 0 0 1.5px var(--accent); }
.zdots i:hover { transform: scale(1.4); }
.dest-list li.group { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); padding: 10px 4px 4px; cursor: default; border-bottom: 1px solid var(--border); border-radius: 0; }
.dest-list li.group:hover { background: none; }
.dest-list li.group span { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-muted); }
.callout { background: #fff7e6; border: 1px solid #f3dca8; border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.4; margin: -4px 0 10px; }
.hidden-note { font-size: 12px; color: #9a5b00; margin: -2px 0 6px; }
.hidden-note:empty { display: none; }
.callout.warn { background: #fdf0ed; border-color: #f0c4b8; color: #5c1d10; }
.kid-link { font-size: 11px; margin-left: 4px; }
#detail a { color: var(--accent); }
.modal-card a { color: var(--accent); }
.tagline { margin: 0 0 2px; font-size: 13px; color: var(--text-secondary); font-style: italic; }
.credits { font-size: 11px; color: var(--text-muted); line-height: 1.45; padding: 10px 0 6px; border-top: 1px solid var(--border); margin-top: 6px; }
.credits a { color: var(--text-secondary); }
