:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --surface-2: #f1f0ed;
  --border: #e3e2de;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7974;
  --accent: #2a78d6;
  --sun: #eda100;
  --possible: #b9b7b0;
  --normal: #52514e;
  --temp: #eb6834;
  --rain: #2a78d6;
  --rad: #e87ba4;
  --up: #0b7a3e;
  --up-bg: #e3f4ea;
  --down: #b8322f;
  --down-bg: #fbe7e6;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 4px 16px rgb(0 0 0 / 0.08);
  --radius: 14px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.muted { color: var(--text-3); }
.logo { width: 24px; height: 24px; flex: none; }
/* the logo (and on the start card the name) leads back to the start view */
.home { display: flex; align-items: center; border: 0; background: none; padding: 0; font: inherit; color: inherit; }

#map { position: fixed; inset: 0; background: #fff; } /* matches the grey map's blank tiles beyond its extent */
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { font-size: 10px; }

/* ---------- search ---------- */
.searchbox {
  position: fixed; z-index: 1001; top: 12px; left: 12px; width: 384px;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
}
/* the search box's icons are chrome, not text: no selecting or long-press callout */
.searchbox { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#q { -webkit-user-select: text; user-select: text; }
.search-row { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; }
#q { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--text); }
#q::placeholder { color: var(--text-3); }
#q::-webkit-search-cancel-button { display: none; }
.icon-btn { display: grid; place-items: center; border: 0; background: none; padding: 4px; border-radius: 50%; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn[hidden] { display: none; }
#results { list-style: none; margin: 0; padding: 6px 0 8px; border-top: 1px solid var(--border); max-height: 60vh; overflow: auto; }
#results li { display: flex; align-items: center; gap: 12px; padding: 9px 18px; cursor: pointer; color: var(--text-2); }
#results li b { color: var(--text); font-weight: 600; }
#results li .ico { color: var(--text-3); width: 18px; height: 18px; }
#results li:hover, #results li.active { background: var(--surface-2); }
#results li.empty { cursor: default; }

/* ---------- panel ---------- */
#panel {
  position: fixed; z-index: 1000; top: 0; left: 0; bottom: 0; width: 408px;
  background: var(--surface); box-shadow: var(--shadow);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 76px 16px 32px;
}
/* start screen: welcome card top left (as in Google Maps), Switzerland fitted beside it */
#panel.intro {
  top: 16px; bottom: auto; left: 16px; width: 400px; height: auto; max-height: calc(100vh - 32px);
  border-radius: 20px; padding: 28px 28px 22px; overflow: visible;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.08), 0 20px 56px rgb(0 0 0 / 0.18);
}

.brand-line { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--text-2); margin-bottom: 12px; }
.welcome h1 { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 10px; text-wrap: balance; }
/* the second sentence always starts on its own line */
.h1-line { display: block; }
/* "sun" in the sunshine legend's colours, orange to red (the darker end keeps it readable) */
.h1-sun { background: linear-gradient(90deg, #e08a00, #d9480f 55%, #c81e14); -webkit-background-clip: text; background-clip: text; color: transparent; }
.welcome p { margin: 0 0 14px; color: var(--text-2); }
.welcome .lede { font-size: 15px; margin-bottom: 20px; text-wrap: pretty; }
.brand-line .logo { width: 30px; height: 30px; }
.search-slot { margin-bottom: 12px; }
.searchbox.in-hero { position: relative; inset: auto; width: auto; z-index: 5; box-shadow: 0 0 0 1px var(--border), 0 4px 14px rgb(0 0 0 / 0.08); }
.searchbox.in-hero .search-row { height: 52px; }
.searchbox.in-hero #q { font-size: 16px; }
.searchbox.in-hero #results { position: absolute; top: 100%; left: 0; right: 0; margin-top: 6px; background: var(--surface); border: 0; border-radius: 16px; box-shadow: var(--shadow); max-height: 50vh; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--text-2); }
.chip:hover { background: var(--surface-2); color: var(--text); }

.place h1 { font-size: 22px; line-height: 1.25; margin: 4px 0 4px; letter-spacing: -0.015em; font-weight: 600; }
.place .sub { margin: 0 0 16px; color: var(--text-3); font-size: 13px; }
.link { border: 0; background: none; padding: 0 0 0 6px; color: var(--accent); font-size: 13px; }

.hero { padding: 18px; border-radius: var(--radius); background: linear-gradient(135deg, color-mix(in oklab, var(--sun) 18%, var(--surface)), var(--surface-2)); margin-bottom: 10px; }
.hero-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.hero-value { font-size: 48px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.hero-value span { font-size: 16px; font-weight: 500; letter-spacing: 0; color: var(--text-2); }
.hero-sub { font-size: 13px; color: var(--text-2); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 10px 11px; min-width: 0; }
.tile-label { font-size: 12px; color: var(--text-2); }
.tile-value { font-size: 17px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-sub { font-size: 11.5px; color: var(--text-3); }

#panel-cap { position: fixed; z-index: 1000; top: 0; left: 0; width: 408px; height: 72px; background: var(--surface); }
body:has(#panel.intro) #panel-cap { display: none; }
#panel { z-index: 999; }
.tabs { position: sticky; top: -4px; z-index: 5; display: flex; gap: 4px; margin: 0 -16px 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: none; padding: 12px 10px 10px; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; }
.tabs button[aria-selected='true'] { color: var(--accent); border-bottom-color: var(--accent); }

.card { padding: 14px 0 16px; border-bottom: 1px solid var(--border); }
.card:last-child { border-bottom: 0; }
.card h2 { font-size: 15px; margin: 0 0 2px; font-weight: 600; }
.card h2 .station-name { font-weight: 400; color: var(--text-3); }
.card h2 .station-name::before { content: '· '; }
.card-sub { margin: 0 0 8px; color: var(--text-2); font-size: 13px; }
.card-sub:empty { display: none; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin: 4px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key.box { width: 10px; height: 10px; border-radius: 2px; }
.key.line { width: 14px; height: 2px; border-radius: 1px; }
.key.sun { background: var(--sun); }
.key.possible { background: var(--possible); }
.key.normal { background: var(--normal); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; margin: 2px 0 6px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; font-size: 12.5px; color: var(--text-2); }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); font-weight: 500; }

.badge { display: inline-block; padding: 0 6px; border-radius: 6px; font-weight: 600; font-size: 12px; font-variant-numeric: tabular-nums; }
.badge.up { color: var(--up); background: var(--up-bg); }
.badge.down { color: var(--down); background: var(--down-bg); }
.badge.flat { color: var(--text-2); background: var(--surface-2); }

.station-chip { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin: 14px 0 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); line-height: 1.35; }
.station-chip:hover { background: var(--surface-2); }
.station-chip .ico { color: var(--accent); }
.station-chip small { color: var(--text-3); }
.station-chip > span:nth-child(2) { flex: 1; min-width: 0; }
.chip-action { color: var(--accent); font-size: 13px; font-weight: 500; }

.note { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 13px; margin-bottom: 12px; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .axis text { font-size: 10.5px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .axis line.grid { stroke: var(--border); stroke-width: 1; }
.chart .axis line.zero { stroke: var(--text-3); stroke-width: 1; }
.chart .bar.faded { opacity: 0.4; }
.chart .ref-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ref-line.possible { stroke: var(--possible); }
.chart .ref-line.normal { stroke: var(--normal); stroke-width: 1.5; opacity: 0.85; }
.chart .ref-line.mean { stroke: var(--normal); stroke-width: 1; }
.chart .ref-label { font-size: 11px; fill: var(--text-2); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.chart .dot { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
.chart .hover-band { fill: var(--text); fill-opacity: 0.06; pointer-events: none; }
.chart .tip {
  display: none; position: absolute; z-index: 10; pointer-events: none; white-space: nowrap;
  background: var(--text); color: var(--surface); font-size: 12px; line-height: 1.45;
  padding: 7px 10px; border-radius: 8px; box-shadow: var(--shadow);
}
.chart .tip b { font-weight: 600; }

.skeleton, .skeleton-line { background: linear-gradient(90deg, var(--surface-2), color-mix(in oklab, var(--surface-2) 60%, var(--surface)), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: 10px; }
.skeleton-line { height: 14px; width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- tables & facts ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 5px 6px; text-align: right; }
thead th { font-weight: 500; color: var(--text-2); font-size: 12px; }
thead tr.subhead th { color: var(--text-3); font-weight: 400; border-bottom: 1px solid var(--border); padding-top: 0; }
tbody th { text-align: left; font-weight: 500; color: var(--text-2); }
tbody tr:nth-child(odd) { background: color-mix(in oklab, var(--surface-2) 55%, transparent); }
tr.total { font-weight: 600; background: none !important; border-top: 1px solid var(--border); }
td small { color: var(--text-3); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; margin: 4px 0 0; }
.facts div { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--border); }
.facts dt { color: var(--text-2); font-size: 13px; }
.facts dt small { display: block; color: var(--text-3); font-size: 11px; }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.stations { list-style: none; margin: 0 0 10px; padding: 0; }
.stations button { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 8px; text-align: left; }
.stations button:hover { background: var(--surface-2); }
.stations button[aria-pressed='true'] { background: color-mix(in oklab, var(--accent) 12%, var(--surface)); }
.st-name small { color: var(--text-3); margin-left: 4px; }
.st-meta { color: var(--text-2); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sources ul { margin: 6px 0 10px; padding-left: 18px; color: var(--text-2); font-size: 13px; }
.sources li { margin-bottom: 6px; }

/* ---------- map ---------- */
.sun-tiles { mix-blend-mode: multiply; }
/* legend bottom left, zoom buttons bottom right (as in Google Maps); on desktop in place
   view the legend sits right of the panel, on phones both float above the sheet */
.map-tools { position: fixed; z-index: 1000; bottom: 28px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
body:not(:has(#panel.intro)) .map-tools { left: 420px; }
/* the column is wider than the zoom buttons: let the empty part pass touches to the map */
.map-tools { pointer-events: none; }
.map-tools > * { pointer-events: auto; }
.map-tools .leaflet-control-zoom { float: none; margin: 0; border: 0; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.map-tools .leaflet-control-zoom a { width: 36px; height: 36px; line-height: 36px; font-size: 20px; background: var(--surface); color: var(--text); border-color: var(--border); }
.map-tools .leaflet-control-zoom a:hover { background: var(--surface-2); }
.map-tools .leaflet-control-zoom a, .map-tools .leaflet-control-zoom a:hover { text-decoration: none; }
.map-tools .leaflet-control-zoom a.leaflet-disabled { color: var(--text-3); background: var(--surface); }
.legend-bar { width: 232px; padding: 9px 12px 8px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); font-size: 11.5px; color: var(--text-3); }
.legend-title { font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.legend-scale { display: flex; height: 8px; border-radius: 4px; overflow: hidden; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.1); }
.legend-scale i { flex: 1; }
.legend-labels { display: flex; justify-content: space-between; margin-top: 3px; font-variant-numeric: tabular-nums; }
.legend-credit { display: none; margin-top: 4px; font-size: 10.5px; } /* phones; desktop credits sit in the map corner */
/* desktop credits; on phones the start card and the place card credit the data */
.leaflet-control-attribution { font-size: 10.5px; }
.pin span { display: block; width: 30px; height: 40px; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 40'%3E%3Cpath d='M15 39s13-13.5 13-24A13 13 0 0 0 2 15c0 10.5 13 24 13 24z' fill='%23e34948' stroke='%23a3201f' stroke-width='1.5'/%3E%3Ccircle cx='15' cy='15' r='5' fill='%23fff'/%3E%3C/svg%3E"); filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.3)); }
.st-marker { fill: #2a78d6; fill-opacity: 1; stroke: #fff; stroke-width: 2; }
.st-marker.sel { fill: #eda100; stroke-width: 2.5; }
.st-link { stroke: #2a78d6; stroke-width: 2; stroke-dasharray: 4 6; fill: none; opacity: 0.8; }
.leaflet-tooltip { font-family: inherit; font-size: 12px; }


/* ---------- phones and portrait windows (tablets): bottom sheet ----------
   keep this query in sync with PHONE in app.js */
@media (max-width: 720px), (orientation: portrait) and (pointer: coarse) {
  .searchbox { left: 16px; right: 16px; width: auto; top: 10px; }
  /* Place view: the panel is a full-screen scroller, transparent at the top, and the
     card starts 38% down. Scrolling slides the card over the map until it fills the
     screen; scrolling back to the top shows the map again. Touches on the map area
     fall through to the map. */
  #panel:not(.intro) { inset: 0; width: auto; padding: 0; background: none; box-shadow: none; pointer-events: none; scrollbar-width: none; }
  #panel:not(.intro)::-webkit-scrollbar { display: none; }
  #panel:not(.intro) #panel-body {
    position: relative; pointer-events: auto; min-height: 100vh; min-height: 100dvh;
    /* scrolled all the way down only the peek shows: name, coordinates, sunshine hours
       (--peek, set by app.js); app.js scrolls it to rest 38% down */
    margin-top: calc(100vh - var(--peek, 240px)); margin-top: calc(100dvh - var(--peek, 240px));
    padding: 26px 16px calc(24px + env(safe-area-inset-bottom));
    background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -2px 16px rgb(0 0 0 / 0.12);
  }
  #panel:not(.intro) #panel-body::before { content: ''; position: absolute; top: 10px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--border); }
  /* as the card rises: map tools fade out, then a cap appears behind the search box */
  .map-tools, #panel-cap { transition: opacity 0.15s; }
  #panel-cap { display: block; left: 0; right: 0; width: auto; height: 68px; opacity: 0; pointer-events: none; }
  body.sheet-high .map-tools { opacity: 0; pointer-events: none; } /* hidden once the card moves up from rest */
  body.sheet-full #panel-cap { opacity: 1; }
  .tabs { top: 68px; }
  .hero-value { font-size: 40px; }
  .tile-value { font-size: 15px; }
  .leaflet-control-attribution { display: none; }
  /* legend and zoom float just above the sheet (--sheet: its height, set by app.js) */
  .map-tools, body:not(:has(#panel.intro)) .map-tools { left: 10px; right: 10px; bottom: calc(var(--sheet, 0px) + 10px); }
  .legend-bar { width: 190px; padding: 7px 10px 6px; }
  .legend-title { font-size: 12px; margin-bottom: 4px; }
  .legend-credit { display: block; }
  /* start card: edge to edge at the top, search box inside (as on desktop) */
  #panel.intro {
    inset: 0 0 auto; margin: 0; width: auto; height: auto; max-height: calc(100vh - 160px); overflow: visible;
    border-radius: 0 0 18px 18px; padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
    box-shadow: 0 2px 16px rgb(0 0 0 / 0.12);
  }
  #panel.intro { z-index: 1001; }
  .brand-line { font-size: 14px; margin-bottom: 6px; }
  .brand-line .logo { width: 26px; height: 26px; }
  .welcome h1 { font-size: 22px; margin-bottom: 6px; }
  .welcome .lede { font-size: 14px; margin-bottom: 10px; }
  .search-slot { margin-bottom: 10px; }
  .searchbox.in-hero .search-row { height: 48px; }
  .welcome .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; }
  .welcome .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}

