/* LoudVector's family look (as in its transit apps): navy ink, violet-grey greys, Outfit,
   violet for actions and the |title⟩ brackets, a navy dark theme. On top of that, two weather
   hues: amber for sun and warmth, blue for rain. */
:root {
  color-scheme: light dark;
  --violet: #5b3df5;
  --on-violet: #ffffff;
  --bg: #f5f4fa;
  --surface: #ffffff;
  --surface-2: #eeecf6;
  --ink: #16132e;
  --muted: #5e5a78;
  --line: #e8e6f1;
  --sun: #e08a00;
  --moon: #5b3df5;
  --rain: #1f6fd6;
  --rain-soft: #dbe8fb;
  --snow: #6a86b8;
  --cold: #4a8fe0;
  --warm: #f0a020;
  --alert-bg: #1f6fd6;
  --alert-ink: #ffffff;
  --radius: 16px;
  --gutter: 16px;
  --shadow: 0 1px 2px rgb(22 19 46 / 0.06), 0 2px 10px rgb(22 19 46 / 0.05);
  --font: Outfit, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --violet: #9c8cff;
    --on-violet: #16132e;
    --bg: #16132e;
    --surface: #1e1a3c;
    --surface-2: #2a2550;
    --ink: #f3f2fa;
    --muted: #ada9cb;
    --line: #2e2950;
    --sun: #ffbf47;
    --moon: #b9adff;
    --rain: #6aaeff;
    --rain-soft: #243a63;
    --snow: #a9bde3;
    --cold: #6aaeff;
    --warm: #ffbf47;
    --alert-bg: #2f6fd0;
    --alert-ink: #ffffff;
    --shadow: none;
  }
}

@font-face { font-family: Outfit; src: url("fonts/Outfit-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Outfit; src: url("fonts/Outfit-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: Outfit; src: url("fonts/Outfit-SemiBold.ttf") format("truetype"); font-weight: 600 900; font-display: swap; }

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100svh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--violet); }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
  min-height: 56px;
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.title { margin: 0 auto 0 0; font-size: 1.375rem; font-weight: 500; letter-spacing: 0.02em; }
.ket { color: var(--violet); font-weight: 400; }
.title .ket:first-child { margin-right: 0.06em; }
.title .ket:last-child { margin-left: 0.04em; }
.bar-title { margin: 0 auto 0 0; min-width: 0; font-size: 1.125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 22px;
  background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.text-btn {
  min-height: 40px; padding: 0 14px; border: 0; border-radius: 20px;
  background: var(--surface-2); color: var(--ink); font-weight: 500;
}

svg.ui { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Page ---------- */
.page {
  width: 100%; max-width: 640px; margin: 0 auto;
  padding: 4px max(var(--gutter), env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
.loading { color: var(--muted); text-align: center; padding: 48px 0; }
.stale { margin: 0 0 10px; color: var(--muted); font-size: 0.8125rem; text-align: center; }

/* ---------- Rain alert ---------- */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  margin: 0 0 12px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--alert-bg); color: var(--alert-ink);
  text-decoration: none;
}
.alert svg { flex: none; width: 36px; height: 36px; --wx-cloud: transparent; }
.alert .wx { --sun: #ffd27a; --rain: #ffffff; --snow: #ffffff; color: #ffffff; }
.alert strong { display: block; font-size: 1.0625rem; font-weight: 600; }
.alert p { margin: 2px 0 0; opacity: 0.92; font-size: 0.9375rem; }
.alert.new { animation: drop-in 0.35s ease-out; }
@keyframes drop-in { from { transform: translateY(-6px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .alert, .icon-btn.spin svg { animation: none; } }

/* ---------- Place cards ---------- */
.places { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.card {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 2px 12px; align-items: center;
  width: 100%; padding: 14px 16px; border: 0; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink);
  text-align: left; text-decoration: none;
}
a.card:hover { background: color-mix(in srgb, var(--surface) 92%, var(--violet)); }
.card .wx { grid-row: 1 / span 2; width: 48px; height: 48px; }
.card .name { min-width: 0; font-size: 1.0625rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .name .here-mark { width: 14px; height: 14px; margin-right: 4px; vertical-align: -1px; color: var(--violet); }
.card .sub { min-width: 0; color: var(--muted); font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .temp { grid-row: 1; grid-column: 3; justify-self: end; font-size: 1.75rem; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.card .hilo { grid-row: 2; grid-column: 3; justify-self: end; color: var(--muted); font-size: 0.8125rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.card .outlook {
  grid-column: 2 / span 2; margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
  font-size: 0.875rem; color: var(--muted);
}
.card .outlook.wet { color: var(--rain); font-weight: 500; }
.card .outlook svg { flex: none; width: 16px; height: 16px; }

/* Edit mode: move and remove buttons on each card. */
.card.editing { grid-template-columns: 1fr auto; padding: 8px 8px 8px 16px; }
.card.editing .name { grid-row: 1; }
.card.editing .sub { grid-row: 2; }
.card.editing .tools { grid-row: 1 / span 2; grid-column: 2; display: flex; }
.tools .icon-btn:disabled { opacity: 0.3; cursor: default; }
.tools .remove { color: #c0362c; }
@media (prefers-color-scheme: dark) { .tools .remove { color: #ff8a80; } }

.add-card {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; margin-top: 10px; border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: transparent; color: var(--violet); font-weight: 500; text-decoration: none;
}
.add-card svg { width: 20px; height: 20px; }

.offer {
  display: grid; gap: 10px; margin: 0 0 12px; padding: 16px;
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.offer h2 { margin: 0; font-size: 1.0625rem; font-weight: 600; }
.offer p { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.offer .row { display: flex; flex-wrap: wrap; gap: 8px; }
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border: 0; border-radius: 22px;
  background: var(--violet); color: var(--on-violet); font-weight: 500; text-decoration: none;
}
.primary svg { width: 18px; height: 18px; }
.ghost { min-height: 44px; padding: 0 16px; border: 0; border-radius: 22px; background: transparent; color: var(--muted); font-weight: 500; }
.note { margin: 0; color: var(--muted); font-size: 0.875rem; }
.note.warn { color: #b3261e; }
.note.center { margin-top: 8px; text-align: center; }
.note.pad { padding: 12px; }
.gap { height: 16px; }
@media (prefers-color-scheme: dark) { .note.warn { color: #ff8a80; } }

.welcome { padding: 32px 8px 8px; text-align: center; }
.welcome .wx { width: 88px; height: 88px; }
.welcome h2 { margin: 8px 0 4px; font-size: 1.375rem; font-weight: 600; }
.welcome p { margin: 0 auto 20px; max-width: 30ch; color: var(--muted); }

/* ---------- Search ---------- */
.search { position: relative; margin: 4px 0 12px; }
.search svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted); }
.search input {
  width: 100%; min-height: 50px; padding: 0 16px 0 44px;
  border: 1.5px solid var(--line); border-radius: 25px; background: var(--surface); font-size: 1.0625rem;
}
.search input:focus { outline: none; border-color: var(--violet); }
.results { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.results button {
  display: grid; gap: 0 12px; grid-template-columns: 28px 1fr auto; align-items: center;
  width: 100%; min-height: 56px; padding: 8px 12px; border: 0; border-radius: 12px;
  background: transparent; text-align: left;
}
.results button:hover { background: var(--surface); }
.results .flag { font-size: 1.25rem; text-align: center; }
.results .where { display: block; color: var(--muted); font-size: 0.875rem; }
.results .added { color: var(--muted); font-size: 0.8125rem; }

/* ---------- Detail ---------- */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 0 16px; align-items: center; padding: 8px 4px 16px; }
.hero .wx { width: 96px; height: 96px; grid-row: 1 / span 4; }
.hero .now { font-size: 3.5rem; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.hero .desc { font-size: 1.125rem; font-weight: 500; }
.hero .more { color: var(--muted); font-size: 0.9375rem; }
.hero .where-sub { grid-column: 2; margin-top: 6px; color: var(--muted); font-size: 0.875rem; }

.panel { margin: 0 0 12px; padding: 14px 16px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 10px; color: var(--muted); font-size: 0.8125rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.panel .lead { margin: -4px 0 12px; font-weight: 500; }
.panel .lead.wet { color: var(--rain); }

.nowcast { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; align-items: end; height: 64px; }
.nowcast i { display: block; min-height: 3px; border-radius: 4px 4px 2px 2px; background: var(--line); }
.nowcast i.wet { background: var(--rain); }
.nowcast i.maybe { background: color-mix(in srgb, var(--rain) 40%, var(--surface)); }
.panel .source { margin: 10px 0 0; color: var(--muted); font-size: 0.75rem; }
.nowcast-axis { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.hours { display: flex; gap: 4px; margin: 0 -16px; padding: 0 16px 2px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.hours::-webkit-scrollbar { display: none; }
.hour { flex: none; display: grid; justify-items: center; gap: 4px; width: 52px; padding: 6px 0; border-radius: 12px; scroll-snap-align: start; font-variant-numeric: tabular-nums; }
.hour.first { background: var(--surface-2); }
.hour .h { color: var(--muted); font-size: 0.8125rem; }
.hour .wx { width: 30px; height: 30px; }
.hour .t { font-weight: 600; }
.hour .p { min-height: 1.1em; color: var(--rain); font-size: 0.75rem; font-weight: 500; }

.days { display: grid; margin: 0; padding: 0; list-style: none; }
.day {
  display: grid; grid-template-columns: 4.6em 28px 3em 2.6em 1fr 2.6em; gap: 8px; align-items: center;
  min-height: 46px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.day:first-child { border-top: 0; }
.day .d { font-weight: 500; }
.day .wx { width: 28px; height: 28px; }
.day .p { color: var(--rain); font-size: 0.8125rem; font-weight: 500; }
.day .lo { color: var(--muted); text-align: right; }
.day .hi { font-weight: 600; }
.range { position: relative; height: 6px; border-radius: 3px; background: var(--surface-2); }
.range i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, var(--cold), var(--warm)); }

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 0 12px; }
.fact { padding: 12px 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.fact dt { color: var(--muted); font-size: 0.8125rem; }
.fact dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.fact dd small { color: var(--muted); font-size: 0.875rem; font-weight: 400; }
.fact .arrow { display: inline-block; width: 16px; height: 16px; margin-left: 4px; vertical-align: -2px; color: var(--muted); }

/* ---------- Settings ---------- */
.group { margin: 0 0 12px; padding: 4px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; }
.setting .label small { display: block; color: var(--muted); font-size: 0.8125rem; }
.seg { display: inline-flex; padding: 3px; border-radius: 20px; background: var(--surface-2); }
.seg button { min-width: 52px; min-height: 34px; padding: 0 12px; border: 0; border-radius: 17px; background: transparent; color: var(--muted); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed="true"] { background: var(--violet); color: var(--on-violet); } }
.switch { position: relative; flex: none; width: 52px; height: 32px; border: 0; border-radius: 16px; background: var(--line); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: transform 0.15s; }
.switch[aria-checked="true"] { background: var(--violet); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.prose { color: var(--muted); font-size: 0.9375rem; }
.prose h2 { margin: 20px 0 6px; color: var(--ink); font-size: 1rem; font-weight: 600; }
.prose p { margin: 0 0 10px; }

/* ---------- Footer ---------- */
.foot { display: grid; justify-items: center; gap: 2px; margin-top: 28px; text-align: center; }
.foot a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 8px; font-size: 0.8125rem; }
.foot .kofi { color: var(--muted); }
.foot .credit { margin: 0; color: var(--muted); font-size: 0.75rem; }
.foot .credit a { min-height: 0; padding: 0; font-size: inherit; color: inherit; }
.built-by { gap: 6px; color: var(--violet); font-weight: 500; text-decoration: none; }
.built-by:hover { text-decoration: underline; }
.built-by .lv-mark { width: 18px; height: 18px; flex: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 10;
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100% - 32px); padding: 8px 8px 8px 16px; border-radius: 24px;
  background: var(--ink); color: var(--bg); transform: translateX(-50%); box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}
.toast button { min-height: 36px; padding: 0 14px; border: 0; border-radius: 18px; background: transparent; color: var(--bg); font-weight: 600; text-decoration: underline; }

/* ---------- Weather icons ---------- */
svg.wx { fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.hero svg.wx, .welcome svg.wx { stroke-width: 1.2; }
.wx .sun { stroke: var(--sun); }
.wx .moon { stroke: var(--moon); }
.wx .cloud { stroke: currentColor; fill: var(--wx-cloud, var(--surface)); }
.wx .rain { stroke: var(--rain); }
.wx .snow { stroke: var(--snow); stroke-width: 2.4; }
.wx .bolt { stroke: var(--sun); }
.wx .fog { stroke: currentColor; opacity: 0.7; }
.hours .wx, .days .wx { color: var(--muted); }
.page > .welcome .wx, .hero .wx { --wx-cloud: var(--bg); }

/* Notifications row: a switch the browser can't use is shown but greyed out. */
.switch:disabled { opacity: 0.4; cursor: default; }
.group .note.pad { padding: 0 0 12px; }

/* stats.html: the running accuracy test */
.stat-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.stat { display: grid; align-content: start; gap: 6px; padding: 12px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); color: var(--muted); font-size: 0.8125rem; line-height: 1.3; }
.stat .big { color: var(--ink); font-size: 1.75rem; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.scores { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.9375rem; }
.scores th, .scores td { padding: 8px 4px; border-top: 1px solid var(--line); text-align: right; }
.scores thead th { border-top: 0; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.scores tbody th { text-align: left; font-weight: 500; }
.scores .muted { color: var(--muted); }
.chart { display: block; width: 100%; height: auto; font-size: 9px; fill: var(--muted); }
.chart .gridline { stroke: var(--line); }
.chart polyline { fill: none; stroke-width: 2; }
.chart .s-alert { stroke: var(--rain); fill: var(--rain); }
.chart polyline.s-alert, .chart polyline.s-radar, .chart polyline.s-persist { fill: none; }
.chart .s-radar { stroke: var(--violet); fill: var(--violet); }
.chart .s-persist { stroke: var(--muted); fill: var(--muted); stroke-dasharray: 3 3; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 8px 0 0; color: var(--muted); font-size: 0.75rem; }
.legend .key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend .key.s-alert { background: var(--rain); }
.legend .key.s-radar { background: var(--violet); }
.legend .key.s-persist { background: var(--muted); }
