/* ═══════════════════════════════════════════════════════════════
   Com-Mute — styles.css
   Material 3 Design System
   ═══════════════════════════════════════════════════════════════ */

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { cursor: pointer; border: none; background: none; font: inherit; -webkit-tap-highlight-color: transparent; }
a { text-decoration: none; color: inherit; -webkit-tap-highlight-color: transparent; }
input, select { font: inherit; }

/* ── M3 DESIGN TOKENS — LIGHT ── */
:root {
  --md-primary:              #006874;
  --md-on-primary:           #ffffff;
  --md-primary-container:    #97f0ff;
  --md-on-primary-container: #001f24;

  --md-background:                #f6fafb;
  --md-surface:                   #f6fafb;
  --md-surface-1:                 #edf5f7;
  --md-surface-2:                 #e3f0f3;
  --md-surface-container:         #e3eef0;
  --md-surface-container-high:    #d8e9ec;
  --md-on-surface:                #191c1d;
  --md-on-surface-variant:   #3f4849;
  --md-outline:              #6f797a;
  --md-outline-variant:      #bec8ca;

  --clr-ok:       #1a7f4e;
  --clr-ok-bg:    #d2f4e4;
  --clr-warn:     #8b5000;
  --clr-warn-bg:  #ffe0b2;
  --clr-err:      #ba1a1a;
  --clr-err-bg:   #ffdad6;

  --font: 'Plus Jakarta Sans', system-ui, sans-serif;

  --elev-1: 0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.07);
  --elev-2: 0 3px 8px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.06);
  --elev-3: 0 6px 18px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);

  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 9999px;

  --nav-h: 72px;
  --top-h: 68px;
}

/* ── M3 TOKENS — DARK (controlled entirely by JS via data-theme attribute) ── */
[data-theme="dark"] {
  --md-primary:              #4fd8eb;
  --md-on-primary:           #003640;
  --md-primary-container:    #004e5b;
  --md-on-primary-container: #97f0ff;
  --md-background:                #191c1d;
  --md-surface:                   #191c1d;
  --md-surface-1:                 #1e2829;
  --md-surface-2:                 #222f30;
  --md-surface-container:         #252f30;
  --md-surface-container-high:    #2c3839;
  --md-on-surface:                #e1e3e3;
  --md-on-surface-variant:   #bec8ca;
  --md-outline:              #899394;
  --md-outline-variant:      #3f4849;
  --clr-ok:       #6ddb9d;
  --clr-ok-bg:    #003921;
  --clr-warn:     #ffb95c;
  --clr-warn-bg:  #4c2800;
  --clr-err:      #ffb4ab;
  --clr-err-bg:   #690005;
  --elev-1: 0 1px 3px rgba(0,0,0,.35);
  --elev-2: 0 3px 8px rgba(0,0,0,.30);
  --elev-3: 0 6px 18px rgba(0,0,0,.30);
}

/* ── BASE ── */
html {
  overflow-x: hidden;
  overscroll-behavior-x: none;
  -webkit-text-size-adjust: 100%;
}
html, body {
  min-height: 100%;
  background: var(--md-background);
  color: var(--md-on-surface);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
input, textarea { user-select: text; }

/* Material Symbols */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── SCREEN SYSTEM ── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

/* Monitor and Arrival sit full-screen without nav padding */
#screen-monitor,
#screen-arrival { padding-bottom: 0; }

/* ── TOP BAR ── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--md-background);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  min-height: var(--top-h);
  border-bottom: 1px solid var(--md-outline-variant);
}

/* ── WORDMARK ── */
.wordmark {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}
.wordmark-logo {
  height: 36px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.wordmark-tagline {
  font-size: 13px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  letter-spacing: .3px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
@media (max-width: 360px) {
  .wordmark-tagline { display: none; }
}
.screen-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--md-on-surface);
}

/* ── ICON BUTTON ── */
.icon-btn {
  width: 48px; height: 48px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-on-surface-variant);
  transition: background .15s;
}
.icon-btn:hover  { background: rgba(127,127,127,.12); }
.icon-btn:active { background: rgba(127,127,127,.22); }

/* ── SCROLL CONTAINERS ── */
.home-scroll,
.screen-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── FIELD CARD (M3 outlined text field) ── */
.field-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--md-surface-1);
  border: 1.5px solid var(--md-outline-variant);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  transition: border-color .15s, box-shadow .15s;
  position: relative;
}
.field-card:focus-within {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-primary) 14%, transparent);
}
.field-icon { color: var(--md-on-surface-variant); }
.field-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
}
.field-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-size: 16px;
  font-weight: 500;
  color: var(--md-on-surface);
  padding: 0;
  line-height: 1.4;
}
.field-input::placeholder { color: var(--md-outline); font-weight: 400; }
input[type="time"].time-input { color-scheme: light dark; }

.field-clear-btn {
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-on-surface-variant);
  transition: background .15s;
}
.field-clear-btn:hover  { background: rgba(127,127,127,.12); }
.field-clear-btn:active { background: rgba(127,127,127,.22); }

.field-map-btn {
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-primary);
  transition: background .15s;
  flex-shrink: 0;
}
.field-map-btn:hover  { background: color-mix(in srgb, var(--md-primary) 12%, transparent); }
.field-map-btn:active { background: color-mix(in srgb, var(--md-primary) 20%, transparent); }
.field-map-btn .material-symbols-outlined { font-size: 22px; }

/* ── PIN PICKER ── */
#pin-picker {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
}
#pin-picker-map {
  position: absolute;
  inset: 0;
}
#pin-picker-crosshair {
  transition: opacity .3s ease;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  z-index: 1;
  pointer-events: none;
  color: var(--md-primary);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}
#pin-picker-crosshair .material-symbols-outlined {
  font-size: 48px;
}
#pin-picker-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px;
  margin-top: calc(12px + env(safe-area-inset-top));
  background: var(--md-surface);
  border-radius: var(--r-lg);
  padding: 10px 16px 10px 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.pin-picker-close {
  width: 48px; height: 48px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-on-surface);
  flex-shrink: 0;
}
.pin-picker-close:hover  { background: rgba(127,127,127,.12); }
.pin-picker-close:active { background: rgba(127,127,127,.22); }
#pin-picker-address {
  font-size: 14px;
  color: var(--md-on-surface);
  line-height: 1.3;
  flex: 1;
}
#pin-picker-footer {
  position: absolute;
  z-index: 2;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  display: flex;
  justify-content: center;
}
#pin-picker-footer .filled-btn {
  padding: 16px 40px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--r-full);
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

/* ── CUSTOM TIME PICKER ── */
.time-picker-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.time-sel {
  background: var(--md-surface-2);
  border: 1.5px solid var(--md-outline-variant);
  border-radius: var(--r-sm);
  outline: none;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  color: var(--md-on-surface);
  cursor: pointer;
  padding: 4px 6px;
  min-width: 52px;
}
.time-sel:focus { border-color: var(--md-primary); }
.time-sep {
  font-size: 20px;
  font-weight: 700;
  color: var(--md-on-surface);
  line-height: 1;
  margin-bottom: 2px;
}
.ampm-toggle {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}
.ampm-btn {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 5px 10px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--md-outline-variant);
  color: var(--md-on-surface-variant);
  background: none;
  transition: all .15s;
}
.ampm-btn.active {
  background: var(--md-primary);
  border-color: var(--md-primary);
  color: var(--md-on-primary);
}

/* ── ARRIVAL HINT ── */
.arrival-hint {
  font-size: 11px;
  color: var(--md-primary);
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── QUICK ROW ── */
.quick-row { display: flex; gap: 8px; min-height: 24px; }

/* ── TEXT CHIP ── */
.text-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-primary);
  padding: 5px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--md-primary);
  transition: background .15s;
}
.text-chip:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.text-chip .material-symbols-outlined { font-size: 16px; }

/* ── HOME SAVED PILLS ── */
#home-saved-section { width: 100%; padding: 12px 0; }
#home-saved-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.home-saved-empty-hint {
  font-size: 13px;
  color: var(--md-on-surface-variant);
  text-align: center;
  padding: 8px 0 4px;
}
.home-saved-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline-variant);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--md-on-surface);
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.home-saved-pill .material-symbols-outlined { font-size: 16px; color: var(--md-primary); }
.home-saved-pill:hover  { background: var(--md-surface-container-high); border-color: var(--md-primary); }
.home-saved-pill:active { background: color-mix(in srgb, var(--md-primary) 16%, var(--md-surface-container)); border-color: var(--md-primary); }

/* ── SAVED EDIT LIST (Saved screen) ── */
.saved-edit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--md-outline) 20%, transparent);
}
.saved-edit-item:last-child { border-bottom: none; }
.saved-edit-icon { font-size: 22px; color: var(--md-primary); flex-shrink: 0; }
.saved-edit-info { flex: 1; min-width: 0; cursor: pointer; }
.saved-edit-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--md-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-edit-addr {
  font-size: 13px;
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.saved-edit-time {
  font-size: 12px;
  color: var(--md-primary);
  margin-top: 2px;
}
.saved-edit-btn {
  width: 48px; height: 48px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-on-surface-variant);
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.saved-edit-btn:hover  { background: color-mix(in srgb, var(--md-on-surface) 10%, transparent); }
.saved-edit-btn:active { background: color-mix(in srgb, var(--md-on-surface) 18%, transparent); }
.saved-del-btn:hover  { color: #ef4444; background: color-mix(in srgb, #ef4444 12%, transparent); }
.saved-del-btn:active { color: #ef4444; background: color-mix(in srgb, #ef4444 22%, transparent); }

/* ── FAB EXTENDED (primary action button) ── */
.fab-extended {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--md-primary);
  color: var(--md-on-primary);
  border-radius: var(--r-xl);
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  width: 100%;
  box-shadow: var(--elev-2);
  transition: filter .15s, box-shadow .15s, transform .1s;
  min-height: 56px;
}
.fab-extended:hover { filter: brightness(1.07); box-shadow: var(--elev-3); }
.fab-extended:active {
  transform: scale(.95);
  box-shadow: var(--elev-1);
  transition: transform .08s cubic-bezier(.34,1.56,.64,1), box-shadow .08s;
}
.fab-extended:not(:active) {
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), filter .15s, box-shadow .15s;
}
.fab-extended .material-symbols-outlined { font-size: 22px; }

/* ── SECTION TITLE ── */
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--md-on-surface);
  margin-bottom: 10px;
}

/* ── EMPTY HINT ── */
.empty-hint {
  font-size: 14px;
  color: var(--md-outline);
  text-align: center;
  line-height: 1.8;
  padding: 24px 0;
}

/* ══════════════════════════════════════════════════════
   MONITOR SCREEN
══════════════════════════════════════════════════════ */
#screen-monitor {
  background: var(--md-background);
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* Background map layer */
#monitor-map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Gradient scrim so text stays readable over the map */
#monitor-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0) 42%),
    radial-gradient(ellipse 80% 60% at 50% 40%,
      color-mix(in srgb, var(--md-background) 25%, transparent) 0%,
      color-mix(in srgb, var(--md-background) 50%, transparent) 100%);
  pointer-events: none;
}

.monitor-layout {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 100dvh;
  min-height: 100vh;
  padding: calc(20px + env(safe-area-inset-top)) 24px calc(32px + env(safe-area-inset-bottom));
}

.monitor-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ── Traffic severity alert card ── */
.traffic-alert {
  background: color-mix(in srgb, #ef4444 14%, var(--md-surface-container));
  border: 1.5px solid color-mix(in srgb, #ef4444 40%, transparent);
  border-radius: var(--r-lg);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  animation: slideUpFade .3s ease;
}
@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.traffic-alert-msg {
  font-size: 15px;
  font-weight: 500;
  color: var(--md-on-surface);
  line-height: 1.4;
}
.traffic-alert-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.traffic-alert-btn {
  padding: 10px 20px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  transition: background .15s;
}
.traffic-alert-no  {
  color: var(--md-on-surface-variant);
  background: transparent;
}
.traffic-alert-no:hover, .traffic-alert-no:active {
  background: rgba(127,127,127,.14);
}
.traffic-alert-yes {
  color: #ef4444;
  background: color-mix(in srgb, #ef4444 14%, transparent);
}
.traffic-alert-yes:hover, .traffic-alert-yes:active {
  background: color-mix(in srgb, #ef4444 24%, transparent);
}

.monitor-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.pip-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.pip-btn:active { background: rgba(255,255,255,0.22); }


/* Small destination label */
.monitor-dest-label {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
  text-align: center;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ★ HERO TIMER — THE MAIN EVENT ★
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.timer-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

/* "LEAVE IN" label above the digits */
.timer-prefix {
  font-size: clamp(13px, 3.5vw, 20px);
  font-weight: 600;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
  transition: color .4s, font-size .3s;
}

/* The big clock — readable across a room */
.timer-digits {
  font-size: clamp(108px, 30vw, 220px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -6px;
  color: var(--md-on-surface);
  transition: color .4s;
  font-variant-numeric: tabular-nums;
}

/* ETA subtext */
.timer-subtext {
  font-size: clamp(13px, 3vw, 17px);
  color: var(--md-on-surface-variant);
  letter-spacing: .3px;
  min-height: 1.4em;
}

/* ── Timer states ── */
/* OK: green — plenty of time */
.timer-hero.state-ok .timer-prefix { color: var(--clr-ok); }
.timer-hero.state-ok .timer-digits { color: var(--clr-ok); }

/* WARN: amber — getting close */
.timer-hero.state-warn .timer-prefix { color: var(--clr-warn); }
.timer-hero.state-warn .timer-digits { color: var(--clr-warn); }

/* TRANSIT: colour is set dynamically via JS (_updateTrafficColors) based on ETA vs target */
.timer-hero.state-transit .timer-prefix { color: var(--md-primary); }

/* GO: amber — time to leave, digits hidden, prefix becomes the hero */
.timer-hero.state-go .timer-digits { display: none; }
.timer-hero.state-go .timer-prefix {
  font-size: clamp(36px, 10vw, 76px);
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--clr-warn);
  animation: pulse-text 1.1s ease-in-out infinite;
}

/* LATE: red */
.timer-hero.state-late .timer-digits { display: none; }
.timer-hero.state-late .timer-prefix {
  font-size: clamp(32px, 9vw, 68px);
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--clr-err);
}

/* ── INFO CHIPS ── */
.info-chips {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.info-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--md-surface-1);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--r-full);
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface);
}
.info-chip .material-symbols-outlined { font-size: 17px; color: var(--md-primary); }
.chip-traffic-badge { font-size: 14px; line-height: 1; }

/* Travel time chip — 125% larger */
.info-chip.travel-chip {
  font-size: clamp(17px, 4.5vw, 22px);
  font-weight: 700;
  padding: 10px 24px;
}
.info-chip.travel-chip .material-symbols-outlined {
  font-size: clamp(18px, 4.5vw, 22px);
}

/* Arrive-by chip — same size as travel chip */
.info-chip.arrive-chip {
  font-size: clamp(17px, 4.5vw, 22px);
  font-weight: 700;
  padding: 10px 24px;
}
.info-chip.arrive-chip .material-symbols-outlined {
  font-size: clamp(18px, 4.5vw, 22px);
}

/* ── STATUS LINE ── */
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--md-on-surface-variant);
}
.status-pip {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--md-outline);
  flex-shrink: 0;
  transition: background .4s;
}
.status-pip.ok   { background: var(--clr-ok);   animation: pulse-dot 2s infinite; }
.status-pip.warn { background: var(--clr-warn);  animation: pulse-dot 1.2s infinite; }
.status-pip.late { background: var(--clr-err); }

/* ── OUTLINED BUTTON ── */
.outlined-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px solid var(--md-outline-variant);
  border-radius: var(--r-full);
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 600;
  color: var(--md-on-surface);
  transition: background .15s, border-color .15s;
  min-height: 48px;
}
.outlined-btn:hover { background: rgba(127,127,127,.09); }
.outlined-btn .material-symbols-outlined { font-size: 20px; }

/* ══════════════════════════════════════════════════════
   ARRIVAL SCREEN
══════════════════════════════════════════════════════ */
#screen-arrival {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--md-background);
  justify-content: center;
  align-items: center;
}
#screen-arrival.active {
  display: flex;
}
#confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.arrival-message {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.arrival-emoji {
  font-size: 80px;
  line-height: 1;
  animation: bounceIn .6s cubic-bezier(.36,.07,.19,.97) both;
}
.arrival-title {
  font-size: clamp(28px, 8vw, 52px);
  font-weight: 800;
  color: var(--md-on-surface);
  letter-spacing: -1px;
  animation: fadeUp .5s .2s both;
}
.arrival-savings {
  font-size: 15px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  animation: fadeUp .5s .6s both;
  opacity: 0;
  animation-fill-mode: forwards;
}
.arrival-bmc-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFDD00;
  color: #000;
  border: none;
  border-radius: 24px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  animation: fadeUp .5s .9s both;
  opacity: 0;
  animation-fill-mode: forwards;
}
.arrival-bmc-btn:active { filter: brightness(.92); }

/* ── Help — cost transparency card ── */
.help-cost-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.help-cost-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.help-cost-icon { font-size: 18px; flex-shrink: 0; }
.help-cost-label { flex: 1; color: var(--md-on-surface); }
.help-cost-amt {
  font-size: 13px;
  font-weight: 600;
  color: var(--md-primary);
  white-space: nowrap;
}
.help-cost-note {
  font-size: 13px;
  color: var(--md-on-surface-variant);
  margin: 0 0 16px;
  font-style: italic;
}
.help-bmc-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #FFDD00;
  color: #000 !important;
  border-radius: 24px;
  font-weight: 700;
}
.help-bmc-btn:hover { filter: brightness(.95); }

/* ══════════════════════════════════════════════════════
   SETTINGS
══════════════════════════════════════════════════════ */
.settings-group {
  background: var(--md-surface-1);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.settings-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--md-primary);
  padding: 12px 16px 6px;
}
.settings-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-top: 1px solid var(--md-outline-variant);
}
.settings-item:first-of-type { border-top: none; }
.settings-item-info { flex: 1; }
.settings-item-title { font-size: 16px; font-weight: 500; color: var(--md-on-surface); }
.settings-item-desc  { font-size: 13px; color: var(--md-on-surface-variant); margin-top: 2px; }

/* ── Preview button ── */
.preview-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--md-primary);
  font-size: 13px;
  font-weight: 600;
  color: var(--md-primary);
  background: none;
  transition: background .15s;
  white-space: nowrap;
}
.preview-btn:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.preview-btn:active { background: color-mix(in srgb, var(--md-primary) 16%, transparent); }

/* ── Stepper ── */
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper-btn {
  width: 48px; height: 48px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--md-outline-variant);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--md-on-surface);
  transition: background .15s;
}
.stepper-btn:hover  { background: rgba(127,127,127,.10); }
.stepper-btn:active { background: rgba(127,127,127,.20); }
.stepper-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--md-primary);
  min-width: 28px;
  text-align: center;
}

/* ── Select ── */
.md-select {
  background: var(--md-surface-2);
  border: 1.5px solid var(--md-outline-variant);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--md-on-surface);
  outline: none;
  cursor: pointer;
}
.md-select:focus { border-color: var(--md-primary); }

/* ── MD Switch ── */
.md-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 0;
}
.md-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.md-switch-track {
  width: 52px; height: 32px;
  border-radius: 16px;
  background: var(--md-outline);
  position: relative;
  display: block;
  transition: background .2s;
}
.md-switch-track::after {
  content: '';
  position: absolute;
  top: 4px; left: 4px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--md-surface);
  transition: transform .2s, background .2s;
  box-shadow: var(--elev-1);
}
.md-switch input:checked + .md-switch-track { background: var(--md-primary); }
.md-switch input:checked + .md-switch-track::after {
  transform: translateX(20px);
  background: var(--md-on-primary);
}

/* ══════════════════════════════════════════════════════
   MODAL (bottom sheet)
══════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  animation: fadeIn .2s;
}
.modal-sheet {
  background: var(--md-surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: slideUp .3s cubic-bezier(.16,1,.3,1);
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--md-outline-variant);
  align-self: center;
  margin-bottom: 4px;
}
.modal-title { font-size: 20px; font-weight: 700; color: var(--md-on-surface); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}
.text-btn {
  padding: 10px 20px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 600;
  color: var(--md-primary);
  min-height: 40px;
  transition: background .15s;
}
.text-btn:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.filled-btn {
  padding: 10px 24px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 700;
  background: var(--md-primary);
  color: var(--md-on-primary);
  min-height: 40px;
  transition: filter .15s;
}
.filled-btn:hover { filter: brightness(1.1); }

/* ══════════════════════════════════════════════════════
   BOTTOM NAVIGATION BAR (M3)
══════════════════════════════════════════════════════ */
.nav-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--md-surface);
  border-top: 1px solid var(--md-outline-variant);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  isolation: isolate;
}
.nav-bar.hidden { display: none; }

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  color: var(--md-on-surface-variant);
  transition: color .15s;
  text-decoration: none;
  border-radius: 0;
}
.nav-icon { font-size: 24px; line-height: 1; }
.coffee-nav-icon { font-size: 22px; }
.nav-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .4px;
}
.nav-item.active { color: var(--md-primary); }
.nav-item.active .nav-icon {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  border-radius: var(--r-full);
  padding: 4px 20px;
}

/* ── BMC BUTTON ── */
.bmc-nav {
  color: #fff !important;
  transform-origin: bottom center;
}
.bmc-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFDD00;
  border-radius: 10px;
  padding: 3px 16px;
  transition: background .15s;
}
.bmc-nav:hover .bmc-nav-icon { background: #f5d200; }

/* Wiggle keyframes — 4 escalation levels */
@keyframes bmc-wiggle-0 {
  0%,100% { transform: rotate(0deg); }
  20%      { transform: rotate(-4deg); }
  40%      { transform: rotate(4deg); }
  60%      { transform: rotate(-3deg); }
  80%      { transform: rotate(3deg); }
}
@keyframes bmc-wiggle-1 {
  0%,100% { transform: rotate(0deg); }
  15%     { transform: rotate(-8deg); }
  35%     { transform: rotate(8deg); }
  55%     { transform: rotate(-6deg); }
  75%     { transform: rotate(6deg); }
  90%     { transform: rotate(-4deg); }
}
@keyframes bmc-wiggle-2 {
  0%,100% { transform: rotate(0deg) scale(1); }
  10%     { transform: rotate(-12deg) scale(1.08); }
  25%     { transform: rotate(12deg) scale(1.08); }
  40%     { transform: rotate(-10deg) scale(1.05); }
  55%     { transform: rotate(10deg) scale(1.05); }
  70%     { transform: rotate(-8deg) scale(1.03); }
  85%     { transform: rotate(8deg) scale(1.03); }
}
@keyframes bmc-wiggle-3 {
  0%,100% { transform: rotate(0deg) scale(1) translate(0,0); }
  8%      { transform: rotate(-18deg) scale(1.15) translate(-3px,-4px); }
  18%     { transform: rotate(18deg) scale(1.18) translate(3px,-2px); }
  28%     { transform: rotate(-15deg) scale(1.12) translate(-4px,2px); }
  38%     { transform: rotate(15deg) scale(1.15) translate(4px,-3px); }
  48%     { transform: rotate(-20deg) scale(1.2) translate(-2px,-5px); }
  58%     { transform: rotate(20deg) scale(1.2) translate(2px,2px); }
  68%     { transform: rotate(-14deg) scale(1.1) translate(-3px,-2px); }
  78%     { transform: rotate(14deg) scale(1.12) translate(3px,3px); }
  88%     { transform: rotate(-10deg) scale(1.05) translate(0,0); }
}
.bmc-wiggle-0 { animation: bmc-wiggle-0 .55s ease-in-out; }
.bmc-wiggle-1 { animation: bmc-wiggle-1 .65s ease-in-out; }
.bmc-wiggle-2 { animation: bmc-wiggle-2 .75s ease-in-out; }
.bmc-wiggle-3 { animation: bmc-wiggle-3 .9s ease-in-out; }

/* ── HELP SCREEN ── */
.help-section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--md-primary);
  padding: 20px 16px 8px;
}
.help-card {
  background: var(--md-surface-container);
  border-radius: 16px;
  margin: 0 12px 10px;
  padding: 0;
  overflow: hidden;
}
.help-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--md-outline) 30%, transparent);
}
.help-card-icon {
  font-size: 22px;
  color: var(--md-primary);
  background: var(--md-primary-container);
  border-radius: 10px;
  padding: 8px;
  line-height: 1;
}
.help-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--md-on-surface);
  line-height: 1.2;
}
.help-card-sub {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-top: 1px;
}
.help-steps {
  margin: 0;
  padding: 12px 16px 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.help-steps li {
  font-size: 14px;
  color: var(--md-on-surface-variant);
  line-height: 1.45;
}
.help-steps strong {
  color: var(--md-on-surface);
  font-weight: 600;
}
.help-chip {
  margin: 0 14px 14px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}
.help-chip-warn {
  background: color-mix(in srgb, #f59e0b 15%, transparent);
  color: color-mix(in srgb, #f59e0b 90%, var(--md-on-surface));
}

/* ── PWA INSTALL BANNER ── */
#install-banner {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  left: 16px; right: 16px;
  background: var(--md-surface-2);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 9000;
  box-shadow: var(--elev-3);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .25s ease, transform .25s ease;
}
#install-banner.install-banner-show { opacity: 1; transform: translateY(0); }
.install-banner-text { flex: 1; font-size: 13px; color: var(--md-on-surface); line-height: 1.4; }
.install-banner-btn {
  background: var(--md-primary); color: var(--md-on-primary);
  border: none; border-radius: var(--r-sm);
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.install-banner-dismiss {
  background: none; border: none; color: var(--md-on-surface-variant);
  font-size: 16px; cursor: pointer; padding: 4px; line-height: 1;
}

#update-banner {
  position: fixed;
  bottom: calc(var(--nav-h) + 72px + env(safe-area-inset-bottom));
  left: 16px; right: 16px;
  background: var(--md-surface-2);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 9001;
  box-shadow: var(--elev-3);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .25s ease, transform .25s ease;
}
#update-banner.update-banner-show { opacity: 1; transform: translateY(0); }
.update-banner-text { flex: 1; font-size: 13px; color: var(--md-on-surface); line-height: 1.4; }
.update-banner-btn,
.update-banner-secondary {
  border: none;
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.update-banner-btn {
  background: var(--md-primary);
  color: var(--md-on-primary);
}
.update-banner-secondary {
  background: color-mix(in srgb, var(--md-primary) 12%, transparent);
  color: var(--md-primary);
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: color-mix(in srgb, var(--md-on-surface) 90%, transparent);
  color: var(--md-surface);
  padding: 12px 24px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity .25s, transform .25s;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Nominatim fallback dropdown ── */
.nom-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--md-surface);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--r-md);
  box-shadow: var(--elev-3);
  z-index: 200;
  overflow: hidden;
  max-height: 240px;
  overflow-y: auto;
}
.nom-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--md-outline-variant);
  transition: background .12s;
}
.nom-item:last-child { border-bottom: none; }
.nom-item:hover { background: var(--md-surface-1); }
.nom-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--md-on-surface);
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.nom-item-dist {
  font-size: 11px;
  font-weight: 500;
  color: var(--md-primary);
  background: color-mix(in srgb, var(--md-primary) 10%, transparent);
  border-radius: var(--r-full);
  padding: 1px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}
.nom-item-sub {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ── Legacy Google Places dropdown override ── */
.pac-container {
  z-index: 9999 !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--elev-3) !important;
  border: 1px solid var(--md-outline-variant) !important;
  font-family: var(--font) !important;
  margin-top: 4px;
}
.pac-item { padding: 8px 16px !important; cursor: pointer; }
.pac-item:hover { background: var(--md-surface-1) !important; }
.pac-item-query { font-size: 14px !important; color: var(--md-on-surface) !important; }

/* ── New Places API dropdown ── */
.pac-new-dropdown {
  position: fixed;
  z-index: 9999;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--r-md);
  box-shadow: var(--elev-3);
  font-family: var(--font);
  overflow-y: auto;
  max-height: 280px;
}
.pac-new-item {
  display: flex;
  flex-direction: column;
  padding: 8px 16px;
  cursor: pointer;
  gap: 1px;
  min-height: 44px;
  justify-content: center;
}
.pac-new-item:hover  { background: var(--md-surface-1); }
.pac-new-item:active { background: color-mix(in srgb, var(--md-primary) 12%, var(--md-surface-1)); }
.pac-new-main { font-size: 13px; font-weight: 500; color: var(--md-on-surface); line-height: 1.3; }
.pac-new-sub  { font-size: 11px; color: var(--md-on-surface-variant); line-height: 1.3; }

/* ══════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════ */
@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50%       { opacity: .55; }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .25; }
}
@keyframes bounceIn {
  0%   { transform: scale(0);   opacity: 0; }
  60%  { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes fadeIn  { from { opacity: 0; }           to { opacity: 1; } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { transform: translateY(100%); }             to { transform: none; } }

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */
/* Center content on wider screens */
@media (min-width: 600px) {
  .home-scroll,
  .screen-scroll {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
  }
  .monitor-layout { max-width: 640px; margin: 0 auto; }
}

/* Larger timer on big screens */
@media (min-width: 900px) {
  .timer-digits { font-size: clamp(180px, 16vw, 260px); }
}

/* Tiny phones */
@media (max-width: 360px) {
  .timer-digits { font-size: 92px; letter-spacing: -3px; }
}

/* ══════════════════════════════════════════════════════
   IN-APP NOTIFICATION OVERLAY
   Full-screen dimmed overlay with centered message card.
   Replaces browser Notification API for active tab.
══════════════════════════════════════════════════════ */
.notif-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .2s ease;
}

.notif-card {
  background: var(--md-surface);
  border-radius: var(--r-xl);
  padding: 36px 28px 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--elev-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  animation: notifScale .3s cubic-bezier(.16,1,.3,1);
  text-align: center;
}

.notif-message {
  font-size: clamp(17px, 5vw, 22px);
  font-weight: 700;
  color: var(--md-on-surface);
  line-height: 1.5;
  margin: 0;
}

.notif-dismiss {
  padding: 14px 44px;
  border-radius: var(--r-full);
  background: var(--md-primary);
  color: var(--md-on-primary);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  min-height: 52px;
  min-width: 160px;
  transition: filter .15s;
  border: none;
  cursor: pointer;
}
.notif-dismiss:hover { filter: brightness(1.08); }

@keyframes notifScale {
  from { opacity: 0; transform: scale(.9); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Saved sheet list items ── */
.saved-sheet-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 50dvh;
  overflow-y: auto;
}

.saved-sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .12s;
}
.saved-sheet-item:hover { background: var(--md-surface-1); }

.saved-sheet-item-info {
  flex: 1;
  min-width: 0;
}
.saved-sheet-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--md-on-surface);
}
.saved-sheet-item-addr {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-sheet-del {
  width: 44px; height: 44px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-outline);
  border: none;
  background: none;
  cursor: pointer;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.saved-sheet-del:hover  { background: var(--clr-err-bg); color: var(--clr-err); }
.saved-sheet-del:active { background: color-mix(in srgb, var(--clr-err) 22%, transparent); color: var(--clr-err); }
