:root {
  --font: "Helvetica Neue", Helvetica, "Inter", "Segoe UI", Arial, sans-serif;
  --radius: 20px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --panel-w: 372px;
  --gap: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b14;
  --glass: rgba(14, 20, 34, .72);
  --glass-border: rgba(255, 255, 255, .09);
  --glass-shadow: 0 20px 60px rgba(0, 0, 0, .55);
  --text: #eef2fb;
  --muted: #8d99b3;
  --faint: rgba(255, 255, 255, .07);
  --accent: #5ee6a8;
  --warn: #ffb547;
  --bad: #ff6b6b;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #dfe7ee;
  --glass: rgba(255, 255, 255, .78);
  --glass-border: rgba(16, 24, 40, .1);
  --glass-shadow: 0 18px 50px rgba(30, 45, 70, .18);
  --text: #121826;
  --muted: #5d6779;
  --faint: rgba(16, 24, 40, .06);
  --accent: #0a9d63;
  --warn: #b76a00;
  --bad: #d43b3b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
h1, h2, h3, p { margin: 0; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#map.dragging { cursor: grabbing; }
#map.pointing { cursor: pointer; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
}

/* ---------- brand ---------- */
.brand {
  position: fixed; top: calc(var(--gap) + var(--safe-t)); left: var(--gap); z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px 10px 10px; border-radius: 999px;
  animation: drop .8s var(--ease) both .15s;
}
.mark { width: 40px; height: 40px; border-radius: 50%; position: relative; flex: none; background: conic-gradient(from 210deg, #0062CF, #009952, #F6BC26, #EB6800, #D82233, #9A38A1, #0062CF); animation: spin 14s linear infinite; }
.mark span { position: absolute; inset: 5px; border-radius: 50%; background: var(--bg); }
.mark span::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--text); animation: breathe 2.4s ease-in-out infinite; }
.brand h1 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand h1 em { font-style: normal; color: var(--accent); }
.brand p { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: 2px; }
.brand p i { font-style: normal; margin: 0 6px; opacity: .5; }
.pulse { position: relative; width: 28px; height: 28px; flex: none; margin-left: 2px; }
.pulse svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.pulse circle { fill: none; stroke: var(--faint); stroke-width: 3; }
.pulse #pulse-ring { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 94.25; }
.pulse b { position: absolute; inset: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.pulse.flash b { animation: flash .7s var(--ease); }
.pulse.stale #pulse-ring, .pulse.stale b { stroke: var(--bad); background: var(--bad); box-shadow: 0 0 12px var(--bad); }

/* ---------- controls ---------- */
.controls { position: fixed; left: var(--gap); bottom: calc(var(--gap) + var(--safe-b)); z-index: 5; display: flex; flex-direction: column; gap: 8px; animation: rise .8s var(--ease) both .3s; }
.controls button { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; transition: transform .2s var(--ease), background .2s; }
.controls button:hover { transform: translateY(-1px) scale(1.05); }
.controls button:active { transform: scale(.94); }
.controls svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .moon, :root[data-theme="light"] .sun { display: none; }

.controls button.on { color: var(--accent); box-shadow: var(--glass-shadow), inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent); }
.controls button.on svg path { fill: currentColor; }

/* ---------- auto tour ---------- */
.spot { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 1.6s ease;
  background: radial-gradient(circle at var(--sx, 40%) var(--sy, 50%), transparent 0, transparent 24vmin, var(--spot) 78vmin); }
.spot.on { opacity: 1; }
:root[data-theme="dark"] { --spot: rgba(2, 4, 10, .62); }
:root[data-theme="light"] { --spot: rgba(40, 55, 80, .26); }

.tour-chip {
  position: fixed; z-index: 5; bottom: calc(var(--gap) + var(--safe-b)); left: calc((100vw - var(--panel-w) - var(--gap) * 2) / 2);
  transform: translateX(-50%); max-width: min(520px, calc(100vw - var(--panel-w) - 150px));
  display: flex; align-items: center; gap: 12px; padding: 11px 14px 13px 12px; border-radius: 18px; overflow: hidden; text-align: left;
  animation: chipin .7s var(--ease) both;
}
.tour-chip[hidden] { display: none; }
.tc-lines { display: flex; gap: 4px; flex: none; }
.tc-lines .bullet { font-size: 15px; }
.tc-lines .bullet.wide { font-size: 10.5px; }
.tc-lines .bullet + .bullet { margin-left: -9px; box-shadow: 0 0 0 2px var(--bg); }
.tc-text { min-width: 0; }
.tc-tag { display: inline-block; font-style: normal; font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.tc-tag[hidden] { display: none; }
.tc-text b { display: block; font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.tc-text small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-next { flex: none; margin-left: 2px; width: 26px; height: 26px; border-radius: 50%; background: var(--faint); display: grid; place-items: center; font-size: 17px; line-height: 1; color: var(--muted); transition: transform .2s var(--ease), color .2s; }
.tour-chip:hover .tc-next { color: var(--text); transform: translateX(2px); }
.tc-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--faint); }
.tc-bar span { display: block; height: 100%; width: 0; background: var(--accent); }
.tour-chip.run .tc-bar span { animation: chipbar var(--hold, 13s) linear both; }
.tour-chip.paused .tc-bar, .tour-chip.paused .tc-lines { display: none; }
.tour-chip.paused .tc-next { transform: none; }
@keyframes chipin { from { opacity: 0; transform: translate(-50%, 14px) scale(.96); } }
@keyframes chipbar { to { width: 100%; } }

/* ---------- panel ---------- */
.panel {
  position: fixed; z-index: 6; top: calc(var(--gap) + var(--safe-t)); right: var(--gap); bottom: calc(var(--gap) + var(--safe-b));
  width: var(--panel-w); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
  animation: slide .9s var(--ease) both .25s;
}
.handle { display: none; }
.dock { display: flex; flex-wrap: wrap; gap: 7px; padding: 16px 16px 14px; border-bottom: 1px solid var(--faint); flex: none; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; overscroll-behavior: contain; }

.bullet {
  --c: #777; --t: #fff;
  display: inline-grid; place-items: center; flex: none;
  width: 1.75em; height: 1.75em; border-radius: 50%;
  background: var(--c); color: var(--t);
  font-weight: 700; font-size: 13px; line-height: 1; letter-spacing: -.02em;
  vertical-align: middle;
}
.bullet.sm { font-size: 11px; }
.bullet.lg { font-size: 26px; }
.bullet.wide { font-size: 9.5px; }
.bullet.lg.wide { font-size: 17px; }

.dock button { position: relative; border-radius: 50%; transition: transform .25s var(--ease), opacity .25s, box-shadow .25s; }
.dock button .bullet { font-size: 15px; width: 30px; height: 30px; }
.dock button .bullet.wide { font-size: 11px; }
.dock button:hover { transform: translateY(-2px) scale(1.1); }
.dock.filtered button:not(.on) { opacity: .28; }
.dock button.on { transform: scale(1.14); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c), 0 6px 22px color-mix(in srgb, var(--c) 60%, transparent); }
.dock button.idle .bullet { filter: grayscale(.85) opacity(.5); }
.dock button i { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--bg); }
.dock button i.bad { background: var(--bad); animation: breathe 1.4s ease-in-out infinite; }

.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.eyebrow:first-child { margin-top: 0; }
.eyebrow span { letter-spacing: 0; text-transform: none; font-weight: 500; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { background: var(--faint); border-radius: 14px; padding: 12px 14px; }
.tile b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.good b { color: var(--accent); }
.tile.warn b { color: var(--warn); }

.bars { display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: 26px 1fr 26px; align-items: center; gap: 10px; padding: 3px 4px; border-radius: 10px; width: 100%; text-align: left; transition: background .2s; }
.bar:hover { background: var(--faint); }
.bar .track { display: block; height: 8px; border-radius: 4px; background: var(--faint); overflow: hidden; }
.bar .fill { display: block; height: 100%; border-radius: 4px; background: var(--c); width: 0; transition: width .9s var(--ease); }
:root[data-theme="dark"] .bar .fill { box-shadow: 0 0 10px var(--c); }
.bar em { font-style: normal; font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.alert { padding: 11px 12px; border-radius: 14px; background: var(--faint); margin-bottom: 8px; font-size: 13px; line-height: 1.45; }
.alert .bullet { font-size: 10px; margin: 0 1px; position: relative; top: -1px; }
.alert .bullet.wide { font-size: 7.5px; }
.chip { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); margin-bottom: 6px; }
.chip.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.chip.calm { background: var(--faint); color: var(--muted); }
.chip.good { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.more { width: 100%; padding: 10px; border-radius: 12px; background: var(--faint); font-size: 12.5px; color: var(--muted); font-weight: 600; }
.more:hover { color: var(--text); }
.empty { font-size: 13px; color: var(--muted); padding: 6px 0 2px; }

.hero { display: flex; align-items: center; gap: 14px; }
.fresh > * { animation: fadeup .45s var(--ease) both; }
.hero h2 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.hero p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.hero .close { margin-left: auto; align-self: flex-start; width: 32px; height: 32px; border-radius: 50%; background: var(--faint); display: grid; place-items: center; flex: none; font-size: 18px; line-height: 1; color: var(--muted); transition: transform .2s var(--ease), color .2s; }
.hero .close:hover { color: var(--text); transform: rotate(90deg); }
.served { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.now { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.now::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent)); box-shadow: 0 0 0 0 var(--c, var(--accent)); animation: ping 1.6s ease-out infinite; flex: none; }

.rows { display: grid; gap: 2px; }
.row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 12px; width: 100%; text-align: left; font-size: 14px; transition: background .2s; }
button.row:hover { background: var(--faint); }
.row small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.row time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; white-space: nowrap; }
.row time.soon { color: var(--accent); }

.stops { position: relative; margin-left: 6px; padding-left: 22px; }
.stops::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: 12px; width: 4px; border-radius: 2px; background: var(--c); opacity: .85; }
.stop { position: relative; display: flex; justify-content: space-between; gap: 10px; padding: 7px 6px; font-size: 13.5px; border-radius: 10px; width: 100%; text-align: left; }
.stop:hover { background: var(--faint); }
.stop::before { content: ""; position: absolute; left: -21px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--bg); border: 2.5px solid var(--c); box-sizing: border-box; }
.stop:first-child { font-weight: 700; }
.stop:first-child::before { background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent); }
.stop time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.foot { font-size: 11px; color: var(--muted); margin-top: 22px; line-height: 1.5; opacity: .85; }

/* ---------- tooltip ---------- */
.tip { position: fixed; z-index: 8; pointer-events: none; padding: 8px 12px; border-radius: 12px; font-size: 12.5px; background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); white-space: nowrap; transform: translate(-50%, calc(-100% - 16px)); display: flex; align-items: center; gap: 8px; }
.tip small { color: var(--muted); display: block; }

/* ---------- loader ---------- */
.loader { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 22px; transition: opacity .7s ease, visibility .7s; }
.loader.done { opacity: 0; visibility: hidden; }
.loader p { font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.loader-mark { display: flex; gap: 10px; }
.loader-mark i { width: 16px; height: 16px; border-radius: 50%; background: var(--c); animation: hop 1s ease-in-out infinite; box-shadow: 0 0 18px var(--c); }
.loader-mark i:nth-child(2) { animation-delay: .1s; } .loader-mark i:nth-child(3) { animation-delay: .2s; } .loader-mark i:nth-child(4) { animation-delay: .3s; } .loader-mark i:nth-child(5) { animation-delay: .4s; }

/* ---------- theme wipe ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: wipe .75s cubic-bezier(.6, 0, .2, 1) both; }
@keyframes wipe { from { clip-path: circle(0 at var(--wx, 50%) var(--wy, 50%)); } to { clip-path: circle(150vmax at var(--wx, 50%) var(--wy, 50%)); } }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(.72); opacity: .7; } }
@keyframes flash { 0% { transform: scale(2.4); opacity: .3; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 var(--c, var(--accent)); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes hop { 50% { transform: translateY(-12px) scale(1.15); } }
@keyframes drop { from { opacity: 0; transform: translateY(-18px); } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes slide { from { opacity: 0; transform: translateX(30px); } }
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } }

/* ---------- mobile: panel becomes a bottom sheet ---------- */
@media (max-width: 820px) {
  :root { --gap: 10px; }
  .brand { padding: 7px 10px 7px 7px; gap: 9px; }
  .mark { width: 34px; height: 34px; }
  .brand h1 { font-size: 14px; }
  .brand p { font-size: 11px; }
  .pulse { width: 24px; height: 24px; } .pulse b { inset: 8.5px; }
  .controls { top: calc(var(--gap) + var(--safe-t) + 60px); bottom: auto; left: auto; right: var(--gap); }
  .controls button { width: 40px; height: 40px; border-radius: 13px; }
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(74dvh, 640px);
    border-radius: 24px 24px 0 0; border-bottom: 0;
    transform: translateY(calc(100% - var(--peek, 138px) - var(--safe-b)));
    transition: transform .5s var(--ease);
    animation: none; will-change: transform;
  }
  .panel[data-state="half"] { transform: translateY(calc(100% - 46dvh)); }
  .panel[data-state="open"] { transform: none; }
  .panel.dragging { transition: none; }
  .handle { display: block; width: 100%; padding: 9px 0 3px; flex: none; touch-action: none; }
  .handle span { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--muted); opacity: .45; margin: 0 auto; }
  .dock { flex-wrap: nowrap; overflow-x: auto; padding: 8px 14px 12px; scrollbar-width: none; gap: 9px; }
  .dock::-webkit-scrollbar { display: none; }
  .panel-body { padding: 14px 14px calc(20px + var(--safe-b)); }
  .tip { display: none !important; }
  .tour-chip { bottom: auto; top: calc(var(--gap) + var(--safe-t) + 60px); left: var(--gap); transform: none; max-width: calc(100vw - var(--gap) * 2 - 50px); padding: 9px 12px 11px 10px; gap: 10px; animation-name: chipin-m; }
  .tc-text b { font-size: 13.5px; }
  @keyframes chipin-m { from { opacity: 0; transform: translateY(-10px) scale(.96); } }
}

@media (prefers-reduced-motion: reduce) {
  *, ::view-transition-new(root) { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
