/* Johannas bil – light, map-first. Light is the default; dark is an option
   in the settings (the second token block below). */

:root {
  color-scheme: light;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #0e1726;
  --ink-2: #4b5768;
  --ink-3: #7c8798;
  --line: #e4e8ef;
  --brand: #2456e6;
  --brand-ink: #ffffff;
  --brand-soft: #e8eefd;
  --brand-hover: #1d49cc;

  /* status: tint, strong colour, text on tint */
  --ok-tint: #e7f6ed;      --ok: #159a4c;      --ok-ink: #0d4f29;
  --soon-tint: #fff3d6;    --soon: #d98a00;    --soon-ink: #6b4300;
  --now-tint: #fde8e6;     --now: #dc3626;     --now-ink: #7d1a10;
  --calm-tint: #eaf0fb;    --calm: #4a6cc4;    --calm-ink: #26397a;

  /* surfaces that differ between the themes */
  --glass: rgba(255, 255, 255, .93);
  --fade: rgba(244, 246, 250, .85);
  --fade-0: rgba(244, 246, 250, 0);
  --inset: rgba(255, 255, 255, .6);
  --field: #f9fafc;
  --hover: #f7f9fc;
  --switch-off: #d5dbe5;
  --dial-line: #dbe3f3;
  --dial-tick: #c3cde2;
  --map-bg: #e9edf3;
  --glow: #dfe8ff;
  --placeholder: #a3adbb;

  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 12px;
  --shadow-1: 0 1px 2px rgba(14, 23, 38, .06), 0 4px 14px rgba(14, 23, 38, .06);
  --shadow-2: 0 2px 6px rgba(14, 23, 38, .10), 0 10px 28px rgba(14, 23, 38, .12);
  --map-h: clamp(250px, 44dvh, 430px);
  --overlap: 26px;
}

/* Dark, when chosen in the settings (js/theme.js sets data-theme). */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d1320;
  --surface: #171f30;
  --ink: #eef2f8;
  --ink-2: #b4becd;
  --ink-3: #8591a4;
  --line: #28324a;
  --brand: #6f97ff;
  --brand-ink: #0b1220;
  --brand-soft: #1c2b50;
  --brand-hover: #88a9ff;

  --ok-tint: #11301f;      --ok: #2fbf6b;      --ok-ink: #b9f0cd;
  --soon-tint: #3a2c08;    --soon: #f0a92a;    --soon-ink: #ffe3a6;
  --now-tint: #421715;     --now: #f25a4d;     --now-ink: #ffc8c1;
  --calm-tint: #18233e;    --calm: #7a98e6;    --calm-ink: #ccd8f6;

  --glass: rgba(23, 31, 48, .9);
  --fade: rgba(13, 19, 32, .85);
  --fade-0: rgba(13, 19, 32, 0);
  --inset: rgba(255, 255, 255, .07);
  --field: #111828;
  --hover: #1e283c;
  --switch-off: #3a465e;
  --dial-line: #2c3a5c;
  --dial-tick: #44547a;
  --map-bg: #141b29;
  --glow: #17264d;
  --placeholder: #66728a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .28);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .4), 0 12px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul { margin: 0; }
button, input { font: inherit; color: inherit; }
svg { display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Line icons share one look. */
.fab svg, .btn svg, .status-icon svg, .dial-car svg {
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

/* ------------------------------------------------------------------ app */

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }

.map-wrap { position: relative; height: var(--map-h); background: var(--map-bg); isolation: isolate; }
#map { position: absolute; inset: 0; z-index: 0; }
/* A soft fade so the floating header always reads against the map. */
.map-wrap::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 96px; z-index: 1; pointer-events: none;
  background: linear-gradient(var(--fade), var(--fade-0));
}

.top {
  position: absolute; z-index: 2; inset: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 0;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 9px;
  height: 44px; padding: 0 16px 0 9px;
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 22px; box-shadow: var(--shadow-1);
}
.brand img { border-radius: 8px; }
.brand h1 { font-size: 1rem; font-weight: 650; letter-spacing: -.01em; }

.fab {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--ink); box-shadow: var(--shadow-1); cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.fab svg { width: 22px; height: 22px; }
.fab:active { transform: scale(.94); }
.fab.flat { background: var(--bg); box-shadow: none; backdrop-filter: none; }
.recenter { position: absolute; z-index: 2; right: 14px; bottom: calc(var(--overlap) + 14px); color: var(--brand); }

/* Leaflet, restyled to match. */
.leaflet-container { font: inherit; background: var(--map-bg); }
.leaflet-bottom { bottom: var(--overlap); }
/* The standard OSM style is busy; mute it so it sits behind the content. */
.leaflet-tile-pane { filter: saturate(.5) contrast(.9) brightness(1.07); }
/* No dark OSM tiles without an account, so invert the light ones: streets
   stay readable and the hue is turned back so parks are still green. */
[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) saturate(.45) brightness(.92) contrast(.88); }
.leaflet-control-attribution {
  background: var(--glass) !important; color: var(--ink-3);
  font-size: 10px; padding: 1px 7px !important; border-radius: 8px 0 0 0;
}
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content-wrapper { border-radius: var(--r-sm); box-shadow: var(--shadow-2); }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-3); }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--surface); color: var(--ink); border-bottom-color: var(--line); }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow-1) !important; }
.leaflet-popup-content { margin: 10px 14px; font-size: .9rem; color: var(--ink); }

.pin-car {
  position: relative; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand); color: #fff; border: 3px solid #fff;
  box-shadow: 0 3px 10px rgba(14, 23, 38, .35);
}
.pin-car svg { width: 22px; height: 22px; fill: currentColor; }
.pin-car::after {
  content: ""; position: absolute; inset: -11px; border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 22%, transparent); z-index: -1;
  animation: halo 2.6s ease-out infinite;
}
.pin-car[data-level="soon"] { background: var(--soon); }
.pin-car[data-level="soon"]::after { background: color-mix(in srgb, var(--soon) 26%, transparent); }
.pin-car[data-level="now"] { background: var(--now); }
.pin-car[data-level="now"]::after { background: color-mix(in srgb, var(--now) 26%, transparent); }
.pin-car[data-level="ok"], .pin-car[data-level="none"] { background: var(--ok); }
.pin-car[data-level="ok"]::after, .pin-car[data-level="none"]::after { background: color-mix(in srgb, var(--ok) 22%, transparent); }
@keyframes halo { 0% { transform: scale(.72); opacity: .9; } 70%, 100% { transform: scale(1.25); opacity: 0; } }

.pin-me {
  width: 18px; height: 18px; border-radius: 50%;
  background: #1a8cff; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(26, 140, 255, .2), 0 2px 6px rgba(14, 23, 38, .3);
}

/* ---------------------------------------------------------------- panel */

.panel {
  position: relative; z-index: 3;
  margin-top: calc(var(--overlap) * -1);
  padding: 16px 14px calc(env(safe-area-inset-bottom) + 26px);
  background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -8px 24px rgba(14, 23, 38, .08);
  display: grid; gap: 12px;
}

.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-1); padding: 16px; }
.muted { color: var(--ink-3); font-size: .9rem; }
.hint { color: var(--ink-2); font-size: .88rem; }
.notice {
  background: var(--calm-tint); color: var(--calm-ink);
  border-radius: var(--r-sm); padding: 10px 14px; font-size: .9rem;
}
.error { color: var(--now); font-size: .92rem; font-weight: 550; }

/* ---- parking status ---- */
.status {
  --tint: var(--calm-tint); --tone: var(--calm); --text: var(--calm-ink);
  background: var(--tint); color: var(--text);
  border-radius: var(--r-md); padding: 16px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 16%, transparent);
  transition: background-color .25s ease;
}
.status[data-level="ok"], .status[data-level="none"] { --tint: var(--ok-tint); --tone: var(--ok); --text: var(--ok-ink); }
.status[data-level="soon"] { --tint: var(--soon-tint); --tone: var(--soon); --text: var(--soon-ink); }
.status[data-level="now"] { --tint: var(--now-tint); --tone: var(--now); --text: var(--now-ink); }

.status-head { display: flex; gap: 14px; align-items: flex-start; }
.status-icon {
  flex: none; display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--tone); color: #fff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--tone) 38%, transparent);
}
.status-icon svg { width: 26px; height: 26px; stroke-width: 2.2; display: none; }
.status[data-level="ok"] .i-ok, .status[data-level="none"] .i-ok,
.status[data-level="soon"] .i-soon,
.status[data-level="now"] .i-now,
.status[data-level="driving"] .i-driving,
.status[data-level="unknown"] .i-info, .status[data-level="outside"] .i-info { display: block; }
.status[data-level="now"] .status-icon { animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

.status-text { min-width: 0; padding-top: 1px; }
.status h2 { font-size: 1.22rem; line-height: 1.22; font-weight: 700; letter-spacing: -.015em; text-wrap: balance; }
.status-text p { margin-top: 4px; font-size: .96rem; opacity: .92; }

.windows { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; }
.windows:empty { display: none; }
.windows li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  background: var(--inset); border-radius: 10px; padding: 8px 12px; font-size: .92rem;
}
.windows .when { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.status-note { margin-top: 12px; font-size: .88rem; background: var(--inset); border-radius: 10px; padding: 9px 12px; }
.status-foot { margin-top: 12px; font-size: .8rem; opacity: .72; }

/* ---- where ---- */
.where { display: grid; gap: 16px; }
.where-main { display: flex; align-items: center; gap: 16px; }
.where-text { min-width: 0; flex: 1; }

.dial { flex: none; width: 92px; height: 92px; border-radius: 50%; background: var(--brand-soft); }
.dial svg { width: 100%; height: 100%; overflow: visible; }
.dial svg g { transform-box: view-box; transform-origin: 50% 50%; transition: transform .22s ease-out; }
.dial-track { fill: var(--surface); stroke: var(--dial-line); stroke-width: 2; }
.dial-tick { fill: none; stroke: var(--dial-tick); stroke-width: 2; stroke-linecap: round; }
.dial-north { fill: none; stroke: var(--now); stroke-width: 3; stroke-linecap: round; }
.dial-arrow { fill: var(--brand); filter: drop-shadow(0 2px 3px rgba(36, 86, 230, .35)); }
.dial-car { display: grid; place-items: center; width: 60px; height: 60px; color: var(--brand); }
.dial-car svg { width: 30px; height: 30px; }

.distance { font-size: 2rem; line-height: 1.05; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.direction { margin-top: 1px; font-size: 1rem; font-weight: 600; color: var(--brand); }
.address { font-size: 1.08rem; font-weight: 650; letter-spacing: -.01em; overflow-wrap: anywhere; }
.distance:not([hidden]) ~ .address { margin-top: 8px; font-size: .95rem; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.where .muted { margin-top: 2px; }

.where-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.where-actions:not(:has(.btn:not([hidden]))) { display: none; }
.where-actions .btn { flex: 1 1 150px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: .98rem; text-decoration: none; cursor: pointer;
  transition: transform .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: scale(.98); }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: var(--brand-ink);
  box-shadow: 0 6px 16px rgba(36, 86, 230, .28);
}
.btn.block { width: 100%; }
.btn.link { min-height: 44px; border: 0; background: none; color: var(--ink-3); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: .55; cursor: default; }
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--hover); }
  .btn.primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
  .btn.link:hover { background: none; color: var(--ink); }
  .fab:hover { box-shadow: var(--shadow-2); }
}
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

.footer { text-align: center; color: var(--ink-3); font-size: .8rem; padding: 4px 8px 0; text-wrap: balance; }
.footer:empty { display: none; }

/* ---------------------------------------------------------------- login */

.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 480px at 50% -10%, var(--glow) 0%, transparent 70%),
    var(--bg);
}
.login-card {
  width: min(100%, 360px); padding: 32px 24px 26px; text-align: center;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
}
.login-card img { border-radius: 18px; box-shadow: 0 8px 20px rgba(36, 86, 230, .3); margin: 0 auto; }
.login-card h1 { margin-top: 18px; font-size: 1.5rem; font-weight: 750; letter-spacing: -.02em; }
.login-lead { margin-top: 6px; color: var(--ink-2); }
.login form { display: grid; gap: 12px; margin-top: 22px; }

input[type="password"], input[type="tel"] {
  width: 100%; min-height: 52px; padding: 0 16px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--field); color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}
input[type="password"]:focus, input[type="tel"]:focus {
  outline: 0; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-soft);
}
input::placeholder { color: var(--placeholder); }
.login input { text-align: center; font-size: 1.35rem; letter-spacing: .28em; font-weight: 600; }
.login input::placeholder { letter-spacing: 0; font-weight: 400; font-size: 1.05rem; }

/* ------------------------------------------------------------- settings */

dialog {
  width: min(100%, 560px); max-height: 92dvh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--bg); color: var(--ink);
  box-shadow: 0 -10px 40px rgba(14, 23, 38, .2);
}
dialog[open] { animation: rise .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
dialog::backdrop { background: rgba(14, 23, 38, .38); backdrop-filter: blur(2px); }
@media (min-width: 620px) { dialog { margin: auto; border-radius: var(--r-lg); } }

.sheet { display: grid; gap: 12px; padding: 14px 14px calc(env(safe-area-inset-bottom) + 18px); }
.sheet > header { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 0 4px; }
.sheet h2 { font-size: 1.3rem; font-weight: 750; letter-spacing: -.02em; }

.group { display: grid; gap: 10px; background: var(--surface); border-radius: var(--r-md); padding: 14px 16px 16px; box-shadow: var(--shadow-1); }
.group h3 { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.field-label { font-size: .88rem; font-weight: 600; color: var(--ink-2); margin-bottom: -4px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row:not(:has(.btn:not([hidden]))) { display: none; }

/* A checkbox drawn as a switch. */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 44px; cursor: pointer; }
.switch + .switch { border-top: 1px solid var(--line); padding-top: 10px; }
.switch span { font-weight: 550; }
.switch small { display: block; font-weight: 400; font-size: .84rem; color: var(--ink-3); }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
  width: 50px; height: 30px; border-radius: 15px; background: var(--switch-off); cursor: pointer;
  transition: background-color .18s ease;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(14, 23, 38, .3); transition: transform .18s ease;
}
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(20px); }

/* Radio buttons drawn as one segmented control. */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--bg); border-radius: 14px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: grid; place-items: center; min-height: 40px; padding: 0 8px; border-radius: 10px;
  font-size: .92rem; font-weight: 600; color: var(--ink-2); text-align: center;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 1px; }

#settings-message { min-height: 1.3em; text-align: center; }

/* ---- "slå på varningar": the card and the guide ---- */
.nudge {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--brand-soft); border-radius: var(--r-md); padding: 16px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 14%, transparent);
}
.nudge-icon {
  flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 35%, transparent);
}
.nudge-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nudge-text { min-width: 0; flex: 1; }
.nudge h2 { font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em; }
.nudge p { margin-top: 2px; font-size: .94rem; color: var(--ink-2); }
.nudge-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 12px; }
.btn.start { justify-self: start; padding: 0; min-height: 36px; }

.assistant-lead { color: var(--ink-2); padding: 0 4px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.steps > li {
  counter-increment: step; display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border-radius: var(--r-md); padding: 16px; box-shadow: var(--shadow-1);
  transition: opacity .2s ease;
}
.step-mark {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg); color: var(--ink-3); font-weight: 700; font-size: .95rem;
}
.step-mark::before { content: counter(step); }
.steps > li[data-state="current"] .step-mark { background: var(--brand); color: var(--brand-ink); }
.steps > li[data-state="done"] .step-mark { background: var(--ok); color: #fff; }
.steps > li[data-state="done"] .step-mark::before { content: "\2713"; }
.steps > li[data-state="blocked"] .step-mark { background: var(--soon); color: #fff; }
.steps > li[data-state="blocked"] .step-mark::before { content: "!"; }
.steps > li[data-state="todo"] { opacity: .62; }
.step-body { min-width: 0; flex: 1; display: grid; gap: 8px; justify-items: start; }
.step-body h3 { font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; }
.step-body > p { color: var(--ink-2); font-size: .94rem; }
.step-msg { font-size: .9rem; color: var(--ink-2); background: var(--bg); border-radius: 10px; padding: 9px 12px; justify-self: stretch; }
.howto { margin: 0; padding-left: 1.25em; display: grid; gap: 6px; font-size: .94rem; color: var(--ink-2); }
.howto b { color: var(--ink); }
.inline-icon { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -.28em; fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.assistant-done { display: grid; gap: 12px; background: var(--ok-tint); color: var(--ok-ink); border-radius: var(--r-md); padding: 16px; }
.assistant-done p { font-size: .96rem; }

/* ---- drive time ---- */
:root {
  /* Column colours, checked for colour blindness (green/orange and orange/red
     apart). Red is also striped, since red/green is not. */
  --bar-ok: #0f7a3b;
  --bar-warn: #e8a21a;
  --bar-bad: #d8392c;
  --bar-none: #9aa8be;
}
:root[data-theme="dark"] {
  --bar-ok: #1f9e57;
  --bar-warn: #f0a92a;
  --bar-bad: #ec5a4c;
  --bar-none: #55627d;
}
.commute { display: grid; gap: 14px; }
.commute-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.commute-heading { min-width: 0; }
.commute h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.commute-heading .muted { margin-top: 2px; font-size: .84rem; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: .9rem; border-radius: 12px; flex: none; }
.btn.small svg { width: 18px; height: 18px; }

.commute-now { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.commute-value { font-size: 2.4rem; line-height: 1; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.commute-value .unit { margin-left: 5px; font-size: 1rem; font-weight: 600; letter-spacing: 0; color: var(--ink-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px 5px 9px;
  border-radius: 999px; font-size: .88rem; font-weight: 600;
  background: var(--bg); color: var(--ink-2);
}
.chip svg { width: 17px; height: 17px; display: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chip[data-level="ok"] { background: var(--ok-tint); color: var(--ok-ink); }
.chip[data-level="warn"] { background: var(--soon-tint); color: var(--soon-ink); }
.chip[data-level="bad"] { background: var(--now-tint); color: var(--now-ink); }
.chip[data-level="ok"] .i-ok, .chip[data-level="warn"] .i-warn, .chip[data-level="bad"] .i-bad { display: block; }

.commute-figure { margin: 0; display: grid; gap: 10px; }
.chart-wrap { position: relative; }
.chart { min-height: 196px; touch-action: pan-y; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .grid line.baseline { stroke: var(--ink-3); }
.chart .grid text { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid text.unit { font-size: 10px; }
.chart .bar { transition: opacity .12s ease; }
.chart .bar-ok { fill: var(--bar-ok); }
.chart .bar-warn { fill: var(--bar-warn); }
.chart .bar-bad { fill: url(#commute-hatch); }
.chart .bar-none { fill: var(--bar-none); }
.chart .bar-missing { fill: var(--line); }
.chart .hatch-bg { fill: var(--bar-bad); }
.chart .hatch-line { fill: var(--surface); }
.chart .bars.has-hover .bar:not(.is-hover) { opacity: .4; }
.chart .normal-line { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-dasharray: 4 3; stroke-linejoin: round; opacity: .7; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none;
  display: grid; gap: 1px; padding: 7px 11px; border-radius: 10px;
  background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow-2);
  font-size: .82rem; white-space: nowrap;
}
.chart-tip strong { color: var(--ink); font-size: 1.02rem; font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; }
.key-ok { background: var(--bar-ok); }
.key-warn { background: var(--bar-warn); }
.key-bad { background: repeating-linear-gradient(135deg, var(--bar-bad) 0 2.4px, var(--surface) 2.4px 3.4px); }
.key-normal { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed var(--ink); opacity: .7; }

.commute-log summary { cursor: pointer; font-weight: 600; font-size: .92rem; padding: 2px 0; }
.commute-log summary span { color: var(--ink-3); font-weight: 500; }
.commute-log[open] summary { margin-bottom: 8px; }
.table-scroll { max-height: 280px; overflow: auto; border-radius: 10px; border: 1px solid var(--line); }
.commute-log table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.commute-log th {
  position: sticky; top: 0; background: var(--surface); text-align: left;
  font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3);
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.commute-log td { padding: 7px 10px; border-bottom: 1px solid var(--line); color: var(--ink); }
.commute-log tr:last-child td { border-bottom: 0; }
.commute-log td .key { margin-right: 7px; vertical-align: -1px; }
.commute-log td.note { color: var(--ink-3); font-size: .84rem; }
.commute-log .btn.start { margin-top: 6px; }

/* ----------------------------------------------------------------- wide */

@media (min-width: 620px) {
  body { padding: 24px 0; }
  .app { min-height: 0; background: var(--bg); border-radius: var(--r-lg); box-shadow: var(--shadow-2); overflow: hidden; }
  .panel { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
