:root {
  --ui-bg: rgba(255, 255, 255, 0.78);
  --ui-fg: #1c1f26;
  --ui-muted: #6b7280;
  --ui-line: rgba(28, 31, 38, 0.10);
  --ui-shadow: 0 8px 30px rgba(20, 30, 50, 0.14);
  --accent: #2b6fe0;
  --label-fg: #1c1f26;
  --label-halo: rgba(255, 255, 255, 0.92);
  --page-bg: #dfe8f3;
}
html[data-phase="night"] {
  --ui-bg: rgba(22, 25, 34, 0.74);
  --ui-fg: #f1f3f8;
  --ui-muted: #9aa3b5;
  --ui-line: rgba(255, 255, 255, 0.10);
  --ui-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --accent: #8fb6ff;
  --label-fg: #f4f6fb;
  --label-halo: rgba(10, 12, 20, 0.85);
  --page-bg: #0b0e16;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--page-bg); }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ui-fg);
  -webkit-font-smoothing: antialiased;
  transition: background 1.2s ease;
}
#map { position: fixed; inset: 0; touch-action: none; }
#map canvas { display: block; }
#labels { position: fixed; inset: 0; pointer-events: none; }

.label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--label-fg);
  text-shadow:
    0 0 2px var(--label-halo), 0 0 2px var(--label-halo), 0 0 3px var(--label-halo),
    0 1px 2px var(--label-halo), 0 -1px 2px var(--label-halo), 1px 0 2px var(--label-halo), -1px 0 2px var(--label-halo);
  white-space: nowrap;
  transform: translate(-50%, -100%) translateY(-6px);
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.label.minor { font-size: 11px; font-weight: 500; }

.hud { position: fixed; z-index: 2; display: flex; gap: 8px; align-items: center; }
.hud.top-left { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); }
.hud.top-right { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
.hud.bottom { bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); max-width: calc(100vw - 24px); }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--ui-line);
  background: var(--ui-bg); color: var(--ui-fg);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: var(--ui-shadow);
  font: inherit; font-size: 13px; font-weight: 500; letter-spacing: 0.01em;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background 0.6s ease, color 0.6s ease, border-color 0.6s ease, transform 0.15s ease;
}
.pill:hover { transform: translateY(-1px); }
.pill:active { transform: translateY(0); }
.pill.icon { width: 36px; padding: 0; justify-content: center; }
.pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.title { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.title small { color: var(--ui-muted); font-weight: 500; font-size: 11px; margin-left: 6px; letter-spacing: 0.08em; text-transform: uppercase; }

.switch { position: relative; width: 86px; height: 36px; padding: 0; justify-content: flex-start; }
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%;
  background: #ffd36b; box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  transition: left 0.5s cubic-bezier(.4,0,.2,1), background 0.6s ease;
}
html[data-phase="night"] .switch .knob { left: 55px; background: #cfd8ea; }
.switch .sun, .switch .moon { position: absolute; top: 9px; width: 18px; height: 18px; opacity: 0.55; transition: opacity 0.5s ease; }
.switch .sun { left: 10px; } .switch .moon { right: 10px; }
.switch .sun svg, .switch .moon svg { width: 18px; height: 18px; }
html[data-phase="day"] .switch .moon { opacity: 0.6; }
html[data-phase="day"] .switch .sun { opacity: 0; }
html[data-phase="night"] .switch .sun { opacity: 0.7; }
html[data-phase="night"] .switch .moon { opacity: 0; }

.clock { font-size: 12px; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.clock b { color: var(--ui-fg); font-weight: 600; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips .pill { height: 32px; padding: 0 12px; font-size: 12px; flex: 0 0 auto; }
.chips .pill.active { background: var(--accent); color: #fff; border-color: transparent; }

.attrib {
  position: fixed; z-index: 2; left: max(12px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom));
  font-size: 10px; color: var(--ui-muted); letter-spacing: 0.02em; pointer-events: auto;
}
.attrib a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }

#loading {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center;
  background: var(--page-bg); color: var(--ui-fg);
  transition: opacity 0.8s ease; font-size: 13px; letter-spacing: 0.02em;
}
#loading.hidden { opacity: 0; pointer-events: none; }
#loading .ring {
  width: 22px; height: 22px; border-radius: 50%; margin: 0 auto 14px;
  border: 2px solid var(--ui-line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading .msg { text-align: center; color: var(--ui-muted); }

@media (max-width: 760px) {
  .title small { display: none; }
  .hud.top-left .pill .t { display: none; }
  .hud.top-left .pill:first-child { width: 36px; padding: 0; justify-content: center; }
  .clock { display: none; }
  .attrib { bottom: max(58px, calc(env(safe-area-inset-bottom) + 44px)); }
  .hud.bottom { left: 12px; right: 12px; transform: none; max-width: none; }
  .chips { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .pill, .switch .knob, #loading { transition: none; }
}

/* ---- bike to work ---- */
html[data-ride="on"] .hud, html[data-ride="on"] .attrib { display: none; }
html[data-ride="on"] #map { cursor: crosshair; }
.ride-btn .t { margin-left: 2px; }
.ride-hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; display: none; }
.ride-hud.on { display: block; }
.ride-hud .pill { pointer-events: auto; }
.ride-top { position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; align-items: center; }
.ride-street { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ride-speed { font-variant-numeric: tabular-nums; }
.ride-progress { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(22px, env(safe-area-inset-bottom)); width: min(560px, calc(100vw - 32px)); }
.ride-progress .bar { height: 6px; border-radius: 999px; background: var(--ui-line); overflow: hidden; box-shadow: var(--ui-shadow); }
.ride-progress .fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.2s linear; }
.ride-progress .marks { position: relative; height: 10px; }
.ride-progress .mark { position: absolute; top: 2px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--ui-fg); opacity: 0.55; }
.ride-hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(46px, calc(env(safe-area-inset-bottom) + 34px)); font-size: 12px; color: var(--ui-muted); text-shadow: 0 1px 2px var(--label-halo); transition: opacity 0.8s ease; white-space: nowrap; }
.ride-choice, .ride-done { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 18px 20px; border-radius: 22px; background: var(--ui-bg); border: 1px solid var(--ui-line); box-shadow: var(--ui-shadow); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3); pointer-events: auto; max-width: calc(100vw - 32px); }
.ride-choice.hidden, .ride-done.hidden { display: none; }
.ride-choice .q, .ride-done .big { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; text-align: center; }
.ride-done .big { font-size: 18px; }
.ride-done .stats { font-size: 12px; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.ride-choice .pill, .ride-done .pill { height: 40px; }
@media (max-width: 760px) {
  .ride-btn .t { display: none; }
  .ride-btn { width: 36px; padding: 0; justify-content: center; }
  .ride-hint { display: none; }
}
