/* Väderdashboard – layout och tema.
 * Mobilen först: träffytor på minst 44 px, säkra zoner för lurar med hack
 * och rundade hörn, och 16 px i sökfältet så att iOS inte zoomar vid fokus. */

:root {
  color-scheme: light;
  --surface-0: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #dedcd6;
  --border-strong: #c6c3ba;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #78766f;
  --series-smhi: #2a78d6;
  --series-yr: #eb6834;
  --series-klart: #1baf7a;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 10px 30px rgba(0, 0, 0, .06);
  --radius: 16px;
  --tap: 44px;
  --tint: rgba(42, 120, 214, .07);      /* svag himmelston i hjältekortet */
  --bar-bg: rgba(244, 243, 240, .82);   /* topplisten släpper igenom innehållet bakom */
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --border: #33332f;
    --border-strong: #4a4a45;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #93918a;
    --series-smhi: #3987e5;
    --series-yr: #d95926;
    --series-klart: #199e70;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    --tint: rgba(57, 135, 229, .09);
    --bar-bg: rgba(18, 18, 17, .78);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --border: #33332f;
  --border-strong: #4a4a45;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #93918a;
  --series-smhi: #3987e5;
  --series-yr: #d95926;
  --series-klart: #199e70;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --tint: rgba(57, 135, 229, .09);
  --bar-bg: rgba(18, 18, 17, .78);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button, summary, .chip, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- Topprad ---------- *
 * Telefon: en enda rad – platsknapp till vänster, verktyg till höger. Sök,
 * position och favoriter bor i en panel som fälls ut från platsknappen, så
 * att listan inte äter tre rader av förstaskärmen.
 * Från 720 px breddas den till varumärke, sökfält och verktyg på en rad. */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  margin-bottom: 12px;
  background: var(--surface-0);
}
/* Innehållet skymtar igenom topplisten när sidan rullar, som i systemets
   egna appar. Webbläsare utan blur får den heltäckande bakgrunden ovan. */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar {
    background: var(--bar-bg);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
  }
}
.topbar::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: var(--border);
  opacity: 0;
  transition: opacity .15s;
}
.topbar.scrolled::after { opacity: 1; }

.brand { display: none; font-weight: 620; letter-spacing: -.01em; font-size: 17px; }
.brand span { color: var(--text-muted); font-weight: 400; }

/* ---------- Platsknapp ---------- */

.place-btn {
  display: inline-flex; align-items: center; gap: 7px;
  flex: 1 1 auto; min-width: 0; min-height: var(--tap);
  padding: 0 8px; margin-left: -8px;
  border: 0; border-radius: 12px; background: none;
  color: var(--text-primary); font: inherit; font-size: 16.5px;
  font-weight: 620; letter-spacing: -.01em; cursor: pointer; text-align: left;
}
@media (hover: hover) { .place-btn:hover { background: var(--surface-2); } }
.place-btn:active { background: var(--surface-2); }
.place-btn .pin { width: 17px; height: 17px; flex: none; color: var(--text-muted); }
.place-btn .chev { width: 17px; height: 17px; flex: none; color: var(--text-muted); transition: transform .15s; }
.topbar.panel-open .place-btn .chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .place-btn .chev { transition: none; } }

.pb-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Temperaturen dyker upp först när hjältekortet rullat förbi */
.pb-temp { display: none; font-weight: 500; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.topbar.scrolled .pb-temp { display: inline; }

.tools { display: flex; gap: 8px; margin-left: auto; flex: none; }

/* ---------- Panelen ---------- */

.panel {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  display: none; gap: 10px;
  padding: 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-height: min(70vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.topbar.panel-open .panel { display: grid; }

.search { position: relative; }
.search input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 16px; /* under 16 px zoomar iOS in vid fokus */
}
.search input:focus-visible { outline: 2px solid var(--series-smhi); outline-offset: 1px; }

.results {
  position: static; margin-top: 8px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden auto; max-height: 46vh; display: none;
}
.results.open { display: block; }
.results button {
  display: block; width: 100%; min-height: var(--tap); text-align: left;
  padding: 10px 14px; background: none; border: 0; border-bottom: 1px solid var(--border);
  color: var(--text-primary); font: inherit; font-size: 15px; cursor: pointer;
}
.results button:last-child { border-bottom: 0; }
@media (hover: hover) { .results button:hover, .results button:focus { background: var(--surface-2); } }
.results small { color: var(--text-muted); display: block; margin-top: 1px; }
.r-top { display: flex; align-items: baseline; gap: 8px; }
.r-name { font-weight: 550; }
.r-typ {
  margin-left: auto; flex: none;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--text-muted); background: var(--surface-2);
  border-radius: 999px; padding: 2px 8px;
}

.panel .btn.geo { width: 100%; justify-content: flex-start; }

/* ---------- Knappar ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface-1); color: var(--text-primary);
  font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 19px; height: 19px; flex: none; }
@media (hover: hover) { .btn:hover { background: var(--surface-2); } }
.btn:active { transform: scale(.97); }
.btn.icon { width: var(--tap); padding: 0; }
.btn.wide { width: 100%; margin-top: 12px; font-size: 14.5px; border-radius: 999px; background: var(--surface-2); border-color: transparent; }
.btn[aria-busy="true"] svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn[aria-busy="true"] svg { animation: none; opacity: .5; }
  .btn:active { transform: none; }
}

/* ---------- Favoriter ---------- */

.favs { display: flex; gap: 8px; margin-bottom: 14px; }
.favs:empty { display: none; }
@media (max-width: 719px) {
  /* Kant till kant, och en rad även med många sparade orter */
  .favs {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin: 0 -16px 14px; padding: 0 16px 2px;
    overscroll-behavior-x: contain;
  }
  .favs::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}
.chip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-1); overflow: hidden;
}
.chip:has(.chip-go[aria-current="true"]) { border-color: var(--text-primary); }
.chip-go {
  min-height: 38px; padding: 0 8px 0 14px; border: 0; background: none;
  color: var(--text-secondary); font: inherit; font-size: 14px; cursor: pointer;
}
.chip-go[aria-current="true"] { color: var(--text-primary); font-weight: 560; }
.chip-go:active, .chip-del:active { background: var(--surface-2); }
.chip-del {
  min-height: 38px; width: 30px; padding: 0; border: 0; background: none;
  color: var(--text-muted); font-size: 17px; line-height: 1; cursor: pointer;
}
@media (hover: hover) { .chip-del:hover { color: var(--critical); } }
.chip.add .chip-go { padding-right: 14px; }

/* ---------- Bred skärm ---------- */

@media (min-width: 720px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(200px, 340px) auto auto;
    grid-template-areas: "brand search geo tools";
    gap: 12px;
    padding-top: 16px;
  }
  .place-btn { display: none; }
  .brand { display: block; grid-area: brand; align-self: center; }
  /* Panelen upplöses och lägger sina delar direkt i rutnätet */
  .panel {
    display: contents;
    position: static; max-height: none; overflow: visible;
    background: none; border: 0; box-shadow: none; padding: 0;
  }
  .search { grid-area: search; align-self: center; }
  .panel .btn.geo { grid-area: geo; width: auto; justify-content: center; }
  .tools { grid-area: tools; margin-left: 0; }
  .results {
    position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
    margin-top: 0; box-shadow: var(--shadow);
  }
}

@media (max-width: 460px) {
  .panel .btn.geo .lbl { font-size: 14px; }
}

/* ---------- Kort ---------- */

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.card .sub { margin: 0 0 16px; color: var(--text-muted); font-size: 13px; }

@media (max-width: 560px) {
  .card { padding: 16px 15px; border-radius: 18px; }
  .card .sub { margin-bottom: 12px; }
}

/* ---------- Hero ---------- */

.hero {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px;
  background: linear-gradient(180deg, var(--tint), transparent 62%), var(--surface-1);
}
@media (max-width: 780px) { .hero { grid-template-columns: 1fr; gap: 20px; } }

/* Platsen står redan i topplisten på telefon – upprepa den inte i kortet */
@media (max-width: 719px) {
  .hero .place { display: none; }
  .hero .now { margin-top: 2px; }
}
.place { font-size: 22px; font-weight: 640; letter-spacing: -.02em; }
.place small { display: block; font-size: 13px; font-weight: 400; color: var(--text-muted); letter-spacing: 0; }

.now { display: flex; align-items: center; gap: clamp(10px, 3vw, 18px); margin: 14px 0 6px; }
.now .temp {
  font-size: clamp(46px, 15vw, 60px); font-weight: 300;
  letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums;
}
.now .glyph { width: clamp(52px, 15vw, 62px); height: clamp(52px, 15vw, 62px); flex: none; }
.now .desc { font-size: 15px; min-width: 0; }
.now .desc small { display: block; color: var(--text-muted); font-size: 13px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; margin-top: 16px; }
.metric { background: var(--surface-2); border-radius: 14px; padding: 11px 12px; }
.metric b { display: block; font-size: 17px; font-weight: 580; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric span { font-size: 12px; color: var(--text-muted); }
@media (max-width: 400px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric { padding: 9px 10px; }
  .metric b { font-size: 15.5px; }
}

/* ---------- Sol och måne ---------- */

.sunmoon { display: grid; gap: 8px; margin-top: 8px; }
.sunmoon:empty { display: none; }
@media (min-width: 560px) { .sunmoon { grid-template-columns: 1fr 1fr; } }
.sm {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface-2); border-radius: 14px; padding: 9px 12px; min-width: 0;
}
.sm > div { min-width: 0; }
.sm b { display: block; font-size: 14.5px; font-weight: 580; font-variant-numeric: tabular-nums; }
.sm span { display: block; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sm-ic { width: 28px; height: 28px; flex: none; }
.moon-dark { fill: var(--border-strong); }
.moon-lit { fill: #edc44a; }
.moon-rim { stroke: var(--text-muted); stroke-width: 1; opacity: .6; }
:root[data-theme="dark"] .moon-dark { fill: #3a3a36; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .moon-dark { fill: #3a3a36; } }

/* ---------- Källkort ---------- */

.sources { display: grid; gap: 8px; align-content: start; }
.srow {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  padding: 12px; border-radius: 14px; background: var(--surface-2);
}
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.srow .nm { font-weight: 560; font-size: 14px; }
.srow .nm small { display: block; font-weight: 400; color: var(--text-muted); font-size: 12px; }
.srow .val { font-variant-numeric: tabular-nums; font-size: 17px; }
.srow .dev { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }

.agree { margin-top: 10px; }
.agree .bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 7px; }
.agree .bar i { display: block; height: 100%; border-radius: 999px; background: var(--good); transition: width .3s; }
.agree .lbl { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--text-muted); }

/* ---------- Diagramkort ---------- */

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head .sub { margin-bottom: 14px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; flex: none; }
.seg button {
  min-height: 38px; padding: 0 13px; border: 0; border-radius: 8px;
  background: none; color: var(--text-secondary);
  font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface-1); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* Avläsningsruta – svaret hamnar här i stället för under fingret */
.readout {
  background: var(--surface-2); border-radius: 14px;
  padding: 11px 13px; margin-bottom: 12px;
}
.ro-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ro-time { font-size: 13px; font-weight: 560; text-transform: capitalize; }
.ro-badge {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--surface-1); background: var(--text-primary);
  border-radius: 999px; padding: 2px 7px;
}
.ro-now {
  margin-left: auto; min-height: 30px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-1); color: var(--text-secondary); font: inherit; font-size: 12.5px; cursor: pointer;
}
.ro-body { display: flex; align-items: center; gap: 12px; }
.ro-glyph { width: 40px; height: 40px; flex: none; }
.ro-temp { font-size: 30px; font-weight: 400; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ro-desc { font-size: 13.5px; min-width: 0; }
.ro-desc small { display: block; color: var(--text-muted); font-size: 12px; }
.ro-agree {
  margin-left: auto; text-align: right; font-size: 15px;
  font-weight: 560; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ro-agree small { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); }
.ro-srcs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 9px; font-size: 12.5px; color: var(--text-secondary); }
.ro-src { display: inline-flex; align-items: center; gap: 6px; }
.ro-src i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.ro-src b { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

@media (max-width: 430px) {
  .ro-desc { font-size: 13px; }
  .ro-temp { font-size: 26px; }
  .ro-glyph { width: 34px; height: 34px; }
  .ro-srcs { gap: 4px 12px; }
}

/* ---------- Själva diagrammet ---------- */

.chart-wrap { position: relative; }
svg.chart {
  display: block; width: 100%; height: auto;
  touch-action: pan-y;                 /* lodrätt svep rullar sidan, vågrätt läser av */
  cursor: crosshair; user-select: none; -webkit-user-select: none;
}
svg.chart.scrubbing { cursor: grabbing; }
/* Diagrammet är tabbbart för tangentbord, men ett fingertryck ska inte lämna
   webbläsarens egen fokusring kvar runt hela ytan. */
svg.chart:focus { outline: none; }
svg.chart:focus-visible { outline: 2px solid var(--series-smhi); outline-offset: 3px; border-radius: 4px; }
svg.chart text { fill: var(--text-muted); }
svg.chart .ylab, svg.chart .xlab { font-size: 11px; }
svg.chart .unit { font-size: 9.5px; }
svg.chart .dlab { font-size: 11px; font-weight: 600; fill: var(--text-secondary); text-transform: capitalize; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .axis { stroke: var(--border); stroke-width: 1; }
svg.chart .daysep { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 2 3; }
svg.chart .night { fill: var(--text-primary); opacity: .045; }
svg.chart .band { fill: var(--text-primary); opacity: .13; }
svg.chart .area { fill: url(#fadeTop); }
svg.chart .line { fill: none; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .line.src { stroke-width: 1.6; opacity: .8; }
svg.chart .line.consensus { stroke: var(--text-primary); stroke-width: 2.6; }
svg.chart .bar { fill: var(--series-smhi); }
svg.chart .nowline { stroke: var(--text-primary); stroke-width: 1; opacity: .3; stroke-dasharray: 3 3; }
svg.chart .cursor line { stroke: var(--text-primary); stroke-width: 1.5; opacity: .5; }
svg.chart .cursor .halo { fill: var(--surface-1); stroke: var(--text-primary); stroke-width: 1.5; }
svg.chart .cursor .dot { fill: var(--text-primary); }

/* ---------- Timraden ---------- */

.hours-wrap {
  margin: 14px -14px 0; padding: 0 14px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.hours-wrap::-webkit-scrollbar { display: none; }
.hours { display: flex; gap: 4px; }

.hcell {
  flex: none; width: 58px;
  display: grid; justify-items: center; gap: 3px;
  padding: 7px 3px; border-radius: 11px;
  /* Genomskinlig ram från början: markeringen ändrar bara färg, aldrig mått.
     En riktig ram i stället för inre skugga – skuggan lämnade spökbilder
     kvar när raden rullade i sidled på telefon. */
  border: 2px solid transparent;
  background: none; color: var(--text-primary);
  font: inherit; cursor: pointer;
}
.hcell.night { background: var(--surface-2); }
.hcell.on { border-color: var(--text-primary); background: var(--surface-2); }
.hcell:active { background: var(--surface-2); }
.hcell:focus { outline: none; }
.hcell:focus-visible { outline: 2px solid var(--series-smhi); outline-offset: 2px; }
.hcell .ht { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }
.hcell.on .ht { color: var(--text-primary); font-weight: 600; }
.hcell .hg { width: 30px; height: 30px; }
.hcell .hv { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hcell .hp { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-height: 15px; }
.hcell .hp.wet { color: var(--series-smhi); font-weight: 600; }
.hcell .hw { display: flex; align-items: center; gap: 2px; font-size: 11.5px; color: var(--text-muted); }
.hcell .hw b { font-weight: 500; font-variant-numeric: tabular-nums; }
.hcell .arr { width: 13px; height: 13px; color: var(--text-secondary); }

@media (max-width: 400px) { .hcell { width: 54px; } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-secondary); margin-top: 10px; }
.legend b { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.legend i { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.legend i.thick { height: 3px; }
.legend i.band { height: 10px; border-radius: 3px; opacity: .22; }

/* ---------- Dygnslista ---------- */

.days { display: grid; gap: 8px; }
.day { border: 1px solid var(--border); border-radius: 14px; background: var(--surface-1); overflow: hidden; }
.day > summary {
  display: grid;
  grid-template-columns: 74px 32px minmax(0, 1fr) 62px 18px;
  gap: 10px; align-items: center;
  min-height: 58px; padding: 8px 12px; cursor: pointer; list-style: none;
}
.day > summary::-webkit-details-marker { display: none; }
.day[open] > summary { background: var(--surface-2); }
.day > summary:active { background: var(--surface-2); }
.day .dname { font-weight: 570; font-size: 14px; text-transform: capitalize; }
.day .dname small { display: block; color: var(--text-muted); font-weight: 400; font-size: 12px; text-transform: none; }
.day .dsym { width: 32px; height: 32px; }

.day .range { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.day .range b { font-size: 14px; font-weight: 600; min-width: 30px; }
.day .range b.cold { color: var(--text-secondary); text-align: right; }
.day .range b.warm { text-align: left; }
.day .track {
  position: relative; flex: 1; min-width: 40px; height: 6px;
  border-radius: 999px; background: var(--surface-2);
}
.day[open] .track { background: var(--surface-1); }
.day .track i {
  position: absolute; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #4f9ae8, #f0a33a);
}

.day .pr {
  display: inline-flex; align-items: center; justify-content: flex-end; gap: 3px;
  font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.day .pr.wet { color: var(--series-smhi); font-weight: 560; }
.day .pr.dry { color: var(--text-muted); }
.day .pr .drop { width: 13px; height: 13px; fill: currentColor; }
.day .chev { width: 18px; height: 18px; color: var(--text-muted); transition: transform .15s; }
.day[open] .chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .day .chev { transition: none; } }

/* ---------- Utfällt dygn ---------- */

.day .detail { border-top: 1px solid var(--border); padding: 12px; background: var(--surface-2); }
.d-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px;
}
.d-head > span:first-child { margin-right: auto; }
.d-sun { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.d-sun .sm-ic { width: 14px; height: 14px; }
.d-agree { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.mini {
  display: inline-block; width: 34px; height: 5px; border-radius: 999px;
  background: var(--border); overflow: hidden; vertical-align: middle;
}
.mini i { display: block; height: 100%; border-radius: 999px; }

svg.spark { display: block; width: 100%; height: auto; margin-bottom: 8px; }
svg.spark text { fill: var(--text-muted); }
svg.spark .sp-night { fill: var(--text-primary); opacity: .05; }
svg.spark .sp-night-lab { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
svg.spark .sp-tick { stroke: var(--border-strong); stroke-width: 1; opacity: .5; }
svg.spark .sp-time { font-size: 10.5px; }
svg.spark .sp-base { stroke: var(--border); stroke-width: 1; }
svg.spark .sp-line {
  fill: none; stroke: var(--text-primary); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round;
}
svg.spark .sp-area { fill: var(--text-primary); opacity: .07; }
svg.spark .sp-bar { fill: var(--series-smhi); opacity: .6; }
svg.spark .sp-dot { stroke: var(--surface-2); stroke-width: 1.5; }
svg.spark .sp-dot.warm { fill: #e8862f; }
svg.spark .sp-dot.cold { fill: #4f9ae8; }
/* Gradtalen får en tunn kontur i bakgrundsfärgen så att de går att läsa
 * även när de hamnar över kurvan eller en nederbördsstapel */
svg.spark .sp-lab {
  font-size: 11.5px; font-weight: 700;
  paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px;
}
svg.spark .sp-lab.warm { fill: #e8862f; }
svg.spark .sp-lab.cold { fill: #4f9ae8; }

.d-srcs { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.d-srcs li {
  display: grid; align-items: baseline; gap: 4px 10px;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  grid-template-areas: "dot nm t" ". desc extra";
  padding: 7px 8px; border-radius: 8px; font-size: 13px;
}
.d-srcs li + li { border-top: 1px solid var(--border); }
.d-srcs li.best { background: var(--surface-1); font-weight: 560; border-radius: 8px; margin-top: 4px; border-top: 0; }
.d-srcs i { grid-area: dot; width: 10px; height: 10px; border-radius: 3px; align-self: center; }
.d-srcs .nm { grid-area: nm; }
.d-srcs .t { grid-area: t; font-variant-numeric: tabular-nums; white-space: nowrap; }
.d-srcs .desc { grid-area: desc; color: var(--text-muted); font-size: 12px; font-weight: 400; }
.d-srcs .extra { grid-area: extra; color: var(--text-muted); font-size: 12px; font-weight: 400; text-align: right; white-space: nowrap; }

@media (min-width: 720px) {
  /* Bredare skärm rymmer allt på en rad per källa */
  .d-srcs li {
    grid-template-columns: 10px 104px 96px minmax(0, 1fr) auto;
    grid-template-areas: "dot nm t desc extra";
    align-items: center;
  }
  .d-srcs .desc { font-size: 12.5px; }
}

@media (max-width: 400px) {
  .day > summary { grid-template-columns: 64px 28px minmax(0, 1fr) 54px 16px; gap: 8px; padding: 8px 10px; }
  .day .dsym { width: 28px; height: 28px; }
  .day .range b { min-width: 28px; font-size: 13.5px; }
}

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--border); }
table.grid th:first-child, table.grid td:first-child { text-align: left; }
table.grid th { color: var(--text-muted); font-weight: 500; }
table.grid td { font-variant-numeric: tabular-nums; }
table.grid tr:last-child td { border-bottom: 0; }

/* ---------- Timtabellen i helskärm ---------- *
 * Ett kort ger tabellen för lite plats på en telefon, så den öppnas i en egen
 * vy som får hela skärmen. Samma sida, samma data – inget nytt flikbyte. */

.sheet {
  width: 100%; max-width: none;
  height: 100vh; height: 100dvh; max-height: none;
  margin: 0; padding: 0; border: 0; border-radius: 0;
  background: var(--surface-0); color: var(--text-primary);
  overflow: hidden;
}
.sheet::backdrop { background: rgba(0, 0, 0, .55); }
.sheet[open] { display: flex; flex-direction: column; }

.sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-left)) 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  flex: none;
}
.sheet-head > div { flex: 1; min-width: 0; }
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 620; letter-spacing: -.01em; }
.sheet-head .sub { margin: 1px 0 0; color: var(--text-muted); font-size: 12.5px; }

.seg-toggle {
  min-height: 38px; padding: 0 13px; flex: none;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface-1); color: var(--text-secondary);
  font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
}
.seg-toggle[aria-pressed="true"] {
  background: var(--text-primary); border-color: var(--text-primary); color: var(--surface-1);
}

.sheet-body {
  flex: 1; min-height: 0; overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom);
}

#hourTable { min-width: 560px; font-size: 13px; }
.sheet.hide-src #hourTable { min-width: 0; }
.sheet.hide-src .col-src { display: none; }

#hourTable th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--text-secondary);
  font-weight: 550; white-space: nowrap; padding: 10px;
  box-shadow: inset 0 -1px 0 var(--border);
  border-bottom: 0;
}
#hourTable td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
#hourTable .th-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

#hourTable .col-time, #hourTable th.col-time {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface-0); font-variant-numeric: tabular-nums;
  box-shadow: 1px 0 0 var(--border);
}
#hourTable th.col-time { z-index: 3; background: var(--surface-2); }
#hourTable .col-main { font-weight: 620; font-size: 14.5px; }

#hourTable tr.daysep td {
  position: sticky; left: 0;
  background: var(--surface-2); color: var(--text-secondary);
  font-weight: 600; font-size: 12px; letter-spacing: .02em;
  text-align: left; padding: 7px 10px;
  box-shadow: none;
}
#hourTable tr.daysep .wd { text-transform: capitalize; }

#hourTable th .sm { display: none; }
@media (max-width: 560px) {
  #hourTable th .lg { display: none; }
  #hourTable th .sm { display: inline; }
}
#hourTable .col-agree { white-space: nowrap; color: var(--text-secondary); }
#hourTable .mini { margin-right: 7px; }

/* Smal skärm: knappa in kolumnerna så att tabellen ryms utan sidled-rullning */
@media (max-width: 560px) {
  #hourTable { font-size: 12.5px; }
  #hourTable th, #hourTable td { padding: 8px 6px; }
  #hourTable .mini { display: none; }
  #hourTable .col-main { font-size: 13.5px; }
}

@media (min-width: 720px) {
  .sheet {
    width: min(1080px, 94vw); height: min(88vh, 920px);
    margin: auto; border-radius: 18px; border: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
}

.note { font-size: 12.5px; color: var(--text-muted); }
.err { color: var(--critical); font-size: 12.5px; }
footer { color: var(--text-muted); font-size: 12.5px; padding-top: 4px; }
footer a { color: var(--text-secondary); }
footer p { margin: 6px 0; }
.linkbtn {
  min-height: var(--tap); padding: 0; border: 0; background: none;
  color: var(--text-secondary); font: inherit; font-size: 12.5px;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
@media (hover: hover) { .linkbtn:hover { color: var(--text-primary); } }

#hourTable .dir { color: var(--text-muted); font-size: 11.5px; margin-left: 2px; }

.skeleton { color: var(--text-muted); padding: 26px 0; text-align: center; }
