:root {
  --ink: #c8c2ba;
  --muted: #a89d94;
  --paper: #121110;
  --stage: #0c0b0a;
  --card: #1a1816;
  --line: #2e2a26;
  --accent: #e7a08c;
  --blue: #54c4ec;
  --sea: var(--blue);
  --sun: #e7a08c;
  --uva: #fcc41c;
  --cloud: #e4ecec;
  --uvb: #e4531b;
  --danger: #e07a70;
  --track: #3a342e;
  --hover: #241f1c;
  --selected: #332822;
  --faint: #7a726b;
  --rain: var(--blue);
  --display: Barlow, Outfit, sans-serif;
  --title: Barlow, Outfit, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-family: Outfit, "Segoe UI", sans-serif;
  font-weight: 300;
  line-height: 1.45;
}

/* Text scales up on large screens: 16px up to ~1180px wide, ~20px on a
   1920px monitor. Nearly all sizes are in rem, so everything follows. */
html { font-size: clamp(16px, 0.55vw + 9.5px, 21px); }

* { box-sizing: border-box; }

body { margin: 0; }

button, input { font: inherit; }

button:focus-visible, input:focus-visible, .side-resize:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app {
  --side: clamp(216px, 14vw, 290px);
  display: grid;
  /* --side-fit is set by fitSide() so place names stay on one line. */
  grid-template-columns: max(var(--side, 216px), var(--side-fit, 0px)) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  background: var(--paper);
}

.side {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 28px 14px 20px 18px;
  background: transparent;
  border-right: 1px solid var(--line);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.side-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 6px 0 0;
  font-family: var(--title);
  font-size: 1.7rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.side-note {
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

#place-list {
  display: grid;
  gap: 2px;
  align-content: start;
}

.place-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: 0;
  border-radius: 16px;
}

#place-list.reordering .place-row { transition: transform 140ms ease; }

.place-row.lifting {
  position: relative;
  z-index: 3;
  border-radius: 16px;
  background: #2c2420;
  transition: none;
}

.place-row:hover { background: var(--hover); }
.place-row.selected,
.place-row.selected:hover { background: var(--selected); }

.place {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: flex-start;
  gap: 6px;
  align-items: baseline;
  border: 0;
  border-radius: 16px;
  padding: 10px 8px 10px 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  user-select: none;
  -webkit-touch-callout: none;
}

.place-hold {
  position: absolute;
  left: 12px;
  top: 10px;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 300;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
}

.place.holding .place-name,
.place.holding .place-time,
.place.holding .place-temp {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.place.holding .place-hold {
  opacity: 1;
  transition: opacity 0.4s ease;
}

.place-row:has(.place.holding) { background: #2c2420; }

.place-row.selected .place-hold { left: 26px; }

.place-name {
  flex: 0 1 auto;
  min-width: 0;
  font-weight: 300;
  font-size: 0.88rem;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-row.selected .place-name::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-1px);
}

.place-time,
.place-temp {
  flex: none;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  line-height: 1.25;
  color: var(--muted);
  white-space: nowrap;
}

.place-time { margin-left: auto; }

.place-temp { margin-left: 8px; }

.place-row.selected .place-time,
.place-row.selected .place-temp { color: var(--ink); }

.search {
  padding-top: 22px;
  display: grid;
  gap: 8px;
}

.search label {
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 400;
}

/* The town box, Search and Refresh share one size. */
input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 400;
}

input[type="search"]::placeholder { color: var(--faint); }

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.search button[type="submit"], .retry {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: #2a2724;
  color: var(--ink);
  font-weight: 400;
  cursor: pointer;
}

.search button[type="submit"] { font-size: 0.88rem; padding: 8px 14px; }

.head-actions {
  display: flex;
  flex: none;
  margin-left: auto;
  gap: 8px;
  align-items: center;
}

.head-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 400;
  cursor: pointer;
}

.results { display: grid; gap: 6px; }

.result {
  width: 100%;
  text-align: left;
  white-space: normal;
  overflow-wrap: break-word;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 12px;
  background: var(--card);
  color: var(--ink);
  font-weight: 300;
  font-size: 0.88rem;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
}

.hint { margin: 0; color: var(--muted); font-size: 0.88rem; font-weight: 400; }

.stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  /* On very wide screens the content stops at 1440px and sits centred. */
  padding: 28px max(28px, calc((100% - 1440px) / 2)) 36px;
  background: var(--stage);
  container-type: inline-size;
  container-name: stage;
}

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

.stage-head > div { min-width: 0; flex: 1; }

.stage-head > .head-actions { flex: none; }

h2 {
  margin: 0;
  font-family: var(--title);
  font-size: clamp(1.45rem, 2.6vw, 2.15rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.where { margin: 6px 0 0; color: var(--muted); font-size: 0.92rem; font-weight: 400; }

.map-frame {
  position: relative;
  height: 16.25rem;
  border-radius: 22px;
  overflow: hidden;
  background: #141311;
  border: 1px solid var(--line);
  cursor: pointer;
}

.map-frame:hover { border-color: var(--muted); }

.map-frame canvas { width: 100%; height: 100%; display: block; pointer-events: none; }

.map-flow {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-pop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(8 7 6 / 74%);
}

.map-stage {
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  height: min(720px, 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: #141311;
}

.map-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.map-name {
  margin: 0;
  font-family: var(--title);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.map-tools .where { margin: 4px 0 0; font-size: 0.82rem; }

.map-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

.map-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

.map-zoom {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  gap: 6px;
}

.map-zoom button,
.map-close {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #2a2724;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
  cursor: pointer;
}

.map-zoom button {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.map-zoom button:disabled { opacity: 0.35; cursor: default; }

.map-close { padding: 6px 12px; }

.chart-unit {
  margin-left: 8px;
  color: var(--faint);
  font-family: var(--display);
  letter-spacing: 0;
  text-transform: none;
}

.map-credit {
  position: absolute;
  right: 8px;
  bottom: 5px;
  z-index: 2;
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--ink);
  opacity: 0.55;
  text-shadow: 0 0 3px #000;
}

.map-credit:hover, .map-credit:focus-within { opacity: 1; }

.map-credit a { color: inherit; text-decoration: none; }

/* Sizes .light-times to the panel width; the dial panel itself can't be a
   container because that would stop it joining the .dials subgrid. */
.light-box { container-type: inline-size; }

.light-times {
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(0.78rem, 5.5cqi, 1.45rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1.15;
  white-space: nowrap;
}

.light-times .uva { color: var(--uva); }
.light-times .uvb { color: var(--uvb); }
.light-times .missing { color: var(--muted); }
.light-times .dot { margin: 0 0.32em; color: var(--faint); }

.dials {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 10px;
  margin-top: 10px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px 14px 12px;
  min-width: 0;
  container-type: inline-size;
}

/* Each dial spans four shared rows (title, reading, circle, footer), so the
   circles start at the same height in every panel across a row. */
.dial {
  container-type: normal;
  display: grid;
  grid-row: span 4;
  grid-template-rows: subgrid;
  row-gap: 0;
  align-items: start;
  margin-bottom: 10px;
  padding: 10px 8px 8px;
  text-align: center;
}

.panel h3, .block h3 {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dial h3 {
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.dial-read { margin: 0; }

.dial-value {
  display: block;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.55rem;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.dial-unit {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.2;
}

.gauge, .compass, .spark {
  width: min(100%, 148px);
  height: auto;
  margin: 2px auto 0;
  display: block;
}

.spark { margin-top: 0; }

/* Breathing room between the circles and the text above and below them. */
.dial .gauge, .dial .compass { margin-top: 10px; }
.dial-foot { padding-top: 5px; }

.caption {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.3;
}

.caption.sun-edge { margin: 0 0 2px; }
.caption.light-note { color: var(--faint); text-wrap: balance; }

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
  align-items: stretch;
}

.chart-row .block { margin-top: 0; }

.block { margin-top: 10px; }

.fine {
  margin: 14px 0 0;
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 400;
}

.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
}

.week-day {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 1px;
  min-width: 0;
  width: 100%;
  padding: 6px 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.week-day:hover { background: var(--hover); }

.week-day.picked,
.week-day.picked:hover {
  background: var(--selected);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.week-day.today .week-k { color: var(--accent); }

.week-k, .week-lo, .week-rain {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* Day names match the panel titles (This week, Temperature, Wind…). */
.week-k { font-size: 0.78rem; }

.week-lo, .week-rain { font-family: var(--display); }

.week-sky { font-size: 0.95rem; line-height: 1.2; }

.week-hi {
  font-family: var(--display);
  font-weight: 500;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.week-rain:empty { min-height: 0.9em; }

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 64px;
}

.bars.labeled {
  height: auto;
  margin-top: 8px; /* same gap under the title as the This week days */
  align-items: stretch;
}

.bars.labeled .bar-col { height: auto; }

.bars.labeled .bar-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 56px;
}

.temp-n {
  display: block;
  height: 13px;
  margin-bottom: 3px;
  color: var(--faint);
  font-family: var(--display);
  font-size: 0.62rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  line-height: 13px;
  text-align: center;
  white-space: nowrap;
}

.temp-n.now { color: var(--ink); }

.bar-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.bar {
  width: 6px;
  min-height: 2px;
  border-radius: 99px;
  background: var(--rain);
}

.bar.temp.sun { background: var(--uva); }
.bar.temp.cloud { background: var(--cloud); }
.bar.temp.rain { background: var(--rain); }
.bar.now:not(.temp) { background: var(--accent); }
.bar.quiet { opacity: 0.28; }

.bar-col .hour-tick {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
}

.bar-col .hour-tick.on { background: var(--accent); }

.bar-col .hour.now { color: var(--accent); }

.bar-col span {
  height: 14px;
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.68rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.track {
  position: relative;
  height: 10px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
}

.band { position: absolute; top: 0; bottom: 0; }
.band.uva { background: var(--uva); }
.band.uvb { background: var(--uvb); }

.now-mark {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  border-radius: 99px;
  background: var(--ink);
}

.sun-times {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.chip-k {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chip-v {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

@container (max-width: 460px) {
  .sun-times { grid-template-columns: 1fr 1fr; }
}

.muted { color: var(--muted); }
.error { color: var(--danger); }

@media (max-width: 860px) {
  .app { --side: 184px; }
  .side { padding: 16px 10px; }
  h1 { font-size: 1.15rem; }
  h2 { font-size: 1.25rem; }
  .place { padding: 8px 4px 8px 8px; gap: 4px; }
  .place-hold { left: 8px; top: 8px; font-size: 0.8rem; }
  .place-row.selected .place-hold { left: 22px; }
  .place-name, .place-time, .place-temp { font-size: 0.8rem; }
  .result { font-size: 0.8rem; }
  input[type="search"] { font-size: 0.88rem; padding: 9px 12px; }
  .stage { padding: 14px 10px 20px; }
  .dials { column-gap: 6px; }
  .dial { padding: 8px 4px 6px; margin-bottom: 6px; }
  .dial-value { font-size: 1.35rem; }
  .dial h3, .caption { font-size: 0.78rem; }
  .dial-unit { font-size: 0.72rem; }
  .gauge, .compass { width: min(100%, 96px); }
  .map-frame { height: 240px; border-radius: 16px; }
  .panel { border-radius: 16px; }
  .week-hi { font-size: 0.8rem; }
  .week-lo, .week-rain { font-size: 0.6rem; }
  .week-sky { font-size: 0.8rem; }
  .week-day { padding: 4px 0; }
  .search { margin-top: 16px; }
  .chip-v { font-size: 1rem; }
}

@media (max-width: 700px) {
  .chart-row { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .app { --side: 160px; }
  .side { padding: 12px 8px; }
  .side-note { font-size: 0.62rem; }
  .stage { padding: 12px 8px 18px; }
  .panel { padding: 8px 6px; }
  .dials { column-gap: 4px; }
  .dial { margin-bottom: 4px; }
  .gauge, .compass { width: min(100%, 8rem); }
  .dial-value { font-size: 1.2rem; }
  .week { gap: 0; }
  .map-frame { height: 240px; }
  .head-actions button { padding: 6px 10px; }
}

@container stage (min-width: 560px) {
  .dials {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 8px;
  }
  .dial { padding: 8px 4px 6px; margin-bottom: 0; }
  .dial-value { font-size: 1.35rem; }
  .dial h3, .caption { font-size: 0.78rem; }
  .dial-unit { font-size: 0.72rem; }
  .gauge, .compass { width: min(100%, 7rem); }
  .light-times { font-size: clamp(0.88rem, 10cqi, 1.15rem); }
}

/* Places menu: below 700px the sidebar becomes a slide-in panel opened from
   the ☰ button in the page header, so the weather gets the full width. */
.menu-toggle, .side-scrim { display: none; }

@media (max-width: 700px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .app .side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(84vw, 320px);
    padding: 20px 16px;
    background: var(--paper);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }

  .app.menu-open .side {
    transform: none;
    visibility: visible;
    box-shadow: 8px 0 24px rgb(0 0 0 / 45%);
    transition: transform 0.25s ease;
  }

  .side-resize { display: none; }

  .side-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgb(0 0 0 / 55%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .app.menu-open .side-scrim { opacity: 1; pointer-events: auto; }

  .menu-toggle {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin: -4px 0 0 -4px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
  }

  .menu-toggle svg { width: 20px; height: 20px; }

  .app .side-note { font-size: 0.72rem; }

  .app .place-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
    overflow-wrap: break-word;
  }
}

@media (max-width: 700px) and (prefers-reduced-motion: reduce) {
  .app .side, .side-scrim { transition: none; }
}
