/* =========================================================================
   Larnaca coast - Patsias Developments
   Brand from the company profile: Montserrat, navy #103050, brand blue
   #1848a0, light blue #5080c8, sand #b8a898. Rendered as a dark control-room
   treatment so the map is the light source and the chrome recedes.
   The palette here is the pre-load fallback; app.js syncs the live values
   from map-style.json into these same custom properties.
   ========================================================================= */

@font-face {
  font-family: 'Montserrat';
  src: url('../assets/fonts/montserrat-variable.woff2') format('woff2-variations');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- LIGHT (default) ----------
   The app opens light over satellite imagery, so surfaces are near-opaque
   white: translucent panels over aerial photography are unreadable. */
:root {
  --primary: #1848a0;
  --primary-deep: #103050;
  --accent: #1848a0;
  --accent-bright: #1848a0;
  /* The profile's sand is a rule-and-caption colour on paper; on white UI it
     needs darkening to clear 4.5:1 for the small uppercase labels. */
  --sand: #75634f;
  --sand-light: #e0d8c8;

  --ink: #0e2139;
  --ink-dim: #3d5573;
  --ink-mute: #63799a;

  --surface: rgba(255, 255, 255, 0.93);
  --surface-solid: #ffffff;
  --surface-strong: rgba(255, 255, 255, 0.96);
  --fill-soft: rgba(16, 48, 80, 0.045);
  --fill-inset: rgba(16, 48, 80, 0.06);
  --line: rgba(16, 48, 80, 0.13);
  --line-strong: rgba(16, 48, 80, 0.24);

  /* The one colour reserved for things you can press. Nothing decorative
     may use it - that is what makes it mean "clickable". */
  --interactive: #1848a0;
  --interactive-strong: #123a80;
  --interactive-tint: rgba(24, 72, 160, 0.09);
  --interactive-tint-strong: rgba(24, 72, 160, 0.16);
  --on-interactive: #ffffff;

  --shadow: 0 14px 40px rgba(16, 40, 70, 0.18);
  --shadow-sm: 0 4px 14px rgba(16, 40, 70, 0.16);
  --vignette: rgba(20, 40, 65, 0.16);
  --topbar-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86));
  --modal-bar-bg: linear-gradient(180deg, #ffffff, #f3f6fa);
  --loading-bg: radial-gradient(120% 90% at 50% 40%, #e8eef6, #ffffff 70%);
  --page-bg: #e9eef4;

  --radius: 14px;
  --radius-sm: 10px;
  --blur: saturate(150%) blur(18px);
  --topbar-h: 58px;
  --panel-w: 344px;
}

/* ---------- DARK ---------- */
:root[data-theme="dark"] {
  --accent: #5080c8;
  --accent-bright: #63a4ff;
  --sand: #b8a898;

  --ink: #eaf1fa;
  --ink-dim: #a8bdd6;
  --ink-mute: #7590b1;

  --surface: rgba(9, 27, 48, 0.86);
  --surface-solid: #0a1d33;
  --surface-strong: rgba(6, 20, 36, 0.9);
  --fill-soft: rgba(255, 255, 255, 0.05);
  --fill-inset: rgba(4, 14, 26, 0.5);
  --line: rgba(120, 165, 220, 0.16);
  --line-strong: rgba(120, 165, 220, 0.3);

  --interactive: #63a4ff;
  --interactive-strong: #8bbcff;
  --interactive-tint: rgba(99, 164, 255, 0.14);
  --interactive-tint-strong: rgba(99, 164, 255, 0.24);
  --on-interactive: #06182c;

  --shadow: 0 18px 48px rgba(2, 10, 20, 0.55);
  --shadow-sm: 0 6px 18px rgba(2, 10, 20, 0.4);
  --vignette: rgba(4, 14, 26, 0.55);
  --topbar-bg: linear-gradient(180deg, rgba(6, 18, 32, 0.94), rgba(6, 18, 32, 0.72));
  --modal-bar-bg: linear-gradient(180deg, #0d2744, #0a1d33);
  --loading-bg: radial-gradient(120% 90% at 50% 40%, #10365e, #050f1c 70%);
  --page-bg: #061525;
}

/* Every control shares one hover/press language, so "pressable" is learned
   once and then recognised everywhere. */
button, select, a, [role="button"] { cursor: pointer; }
.tb-icon, .rail-btn, .md-eye, .seg-btn, .chip-time, .cat-chip,
.proj-open, .proj-main, .time-row, .drive-row, .kpi-cta,
.panel-foot button, .route-actions button, .tb-tab { color: var(--ink); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
html { overscroll-behavior: none; }
body {
  font-family: 'Montserrat', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
}
button, select, input { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; border-radius: 6px; }

#map { position: absolute; inset: 0; }
/* A cool vignette pins the eye to the coast and hides the tile edge. */
#map::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 55% 45%, transparent 45%, var(--vignette) 100%);
}

.glass {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line);
}

/* ============================ top bar ============================ */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--topbar-h);
  z-index: 60;
  display: flex; align-items: center; gap: 16px; padding: 0 14px 0 12px;
  background: var(--topbar-bg);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; flex: 1 1 0; min-width: 0; }
.tb-right { justify-content: flex-end; }

.tb-icon {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px; border: 1px solid transparent;
  background: var(--fill-soft); color: var(--ink-dim);
  cursor: pointer; transition: color .15s, background .15s, border-color .15s;
}
.tb-icon:hover { color: var(--ink); background: rgba(99, 164, 255, 0.14); border-color: var(--line-strong); }

.tb-crumbs {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink); min-width: 0;
  white-space: nowrap; overflow: hidden;
}
.tb-crumbs svg { color: var(--accent); flex: none; }
.crumb-dim { color: var(--ink-mute); }
.crumb-sep { color: rgba(120, 165, 220, 0.35); }

.tb-tabs { display: flex; align-items: center; gap: 4px; flex: none; }
.tb-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid transparent; background: none;
  color: var(--ink-mute); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: color .15s, background .15s, border-color .15s;
}
.tb-tab svg { opacity: .8; }
.tb-tab:hover { color: var(--ink); }
.tb-tab.is-active {
  color: #fff; background: var(--primary);
  border-color: rgba(99, 164, 255, 0.5);
  box-shadow: 0 4px 14px rgba(24, 72, 160, 0.5);
}
.tb-tab.is-active svg { opacity: 1; }

.tb-brand {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; color: var(--ink);
  padding: 4px 4px 4px 10px; border-left: 1px solid var(--line); margin-left: 4px;
}
.tb-brand img { display: block; height: 28px; width: auto; }
.tb-brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.tb-brand-text b { font-size: 13px; font-weight: 700; letter-spacing: .13em; }
.tb-brand-text i {
  font-style: normal; font-size: 8.5px; font-weight: 500;
  letter-spacing: .215em; color: var(--sand);
}

/* ============================ left panel ============================ */
#panel {
  position: absolute; z-index: 40;
  top: calc(var(--topbar-h) + 14px); left: 14px; bottom: 14px;
  width: var(--panel-w); max-width: calc(100vw - 28px);
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.panel-head { padding: 16px 18px 14px; border-bottom: 1px solid var(--line); }
.eyebrow {
  margin: 0 0 4px; font-size: 10px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--sand);
}
#panel-title { margin: 0 0 12px; font-size: 21px; font-weight: 600; letter-spacing: -.01em; }

.seg--sm .seg-btn { padding: 5px 12px; font-size: 11.5px; }
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--fill-inset); border: 1px solid var(--line); border-radius: 999px;
}
.seg-btn {
  border: 0; background: none; cursor: pointer;
  padding: 6px 15px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--ink-mute);
  transition: color .15s, background .15s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: var(--primary); color: #fff; }

.panel-context {
  display: flex; align-items: center; gap: 7px;
  margin: 12px 0 0; font-size: 11.5px; color: var(--ink-mute);
}
.panel-context svg { color: var(--accent); flex: none; }

.panel-kpi { padding: 14px 18px 16px; border-bottom: 1px solid var(--line); }
.kpi-label { display: block; font-size: 11px; color: var(--ink-mute); }
.kpi-value {
  display: block; font-size: 44px; font-weight: 700; line-height: 1.05;
  letter-spacing: -.02em; color: var(--ink); margin: 2px 0 3px;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { display: block; font-size: 11.5px; color: var(--ink-dim); }
.kpi-cta {
  margin-top: 13px; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(99, 164, 255, 0.45);
  background: linear-gradient(180deg, rgba(24, 72, 160, 0.9), rgba(16, 48, 80, 0.9));
  color: #fff; font-size: 13px; font-weight: 600;
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.kpi-cta:hover { border-color: var(--accent-bright); box-shadow: 0 8px 22px rgba(24, 72, 160, 0.45); }
.kpi-cta:active { transform: translateY(1px); }
.cta-plus {
  width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; font-weight: 600;
  background: rgba(255, 255, 255, 0.16);
}

.panel-sec { padding: 14px 18px; }
.panel-sec[hidden] { display: none; }
.panel-sec--grow { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.panel-sec h2 {
  margin: 0 0 10px; font-size: 10px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-mute);
}
.sec-note { margin: 10px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-mute); }

/* scroll affordance so a clipped list does not look like the end of the list */
.panel-sec--grow { position: relative; }
.panel-foot { position: relative; }
.panel-foot::before {
  content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 32px;
  pointer-events: none; opacity: 0; transition: opacity .2s;
  background: linear-gradient(180deg, transparent, var(--surface));
}
#panel.has-overflow .panel-foot::before { opacity: 1; }

/* ---- project cards ---- */
#project-list, #drive-list { list-style: none; margin: 0; padding: 0; }
#project-list li, #drive-list li { margin-bottom: 8px; }
.proj-item {
  border-radius: var(--radius-sm); padding: 10px 11px 11px;
  background: var(--fill-soft);
  border: 1px solid var(--line);
  transition: border-color .15s, background .15s;
}
.proj-item:hover { border-color: var(--line-strong); background: rgba(99, 164, 255, 0.08); }
.proj-top { display: flex; align-items: center; gap: 9px; }
.proj-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  border: 0; background: none; cursor: pointer; padding: 2px 0;
  color: var(--ink); text-align: left;
}
.proj-dot {
  width: 11px; height: 11px; border-radius: 3px; flex: none;
  background: linear-gradient(135deg, var(--accent-bright), var(--primary));
  box-shadow: 0 0 10px rgba(99, 164, 255, 0.7);
}
.proj-name { font-size: 14px; font-weight: 600; letter-spacing: .01em; }
.proj-open {
  flex: none; border: 1px solid rgba(99, 164, 255, 0.4); cursor: pointer;
  background: var(--primary); color: #fff;
  border-radius: 8px; padding: 6px 12px; font-size: 11.5px; font-weight: 600;
  transition: background .15s, border-color .15s;
}
.proj-open:hover { background: var(--primary); border-color: var(--accent-bright); }

.proj-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.chip-time {
  border: 1px solid var(--interactive-tint-strong); background: var(--fill-inset);
  border-radius: 999px; padding: 5px 10px; cursor: pointer;
  font-size: 11px; color: var(--ink-dim); line-height: 1.4;
  transition: border-color .12s, color .12s, background .12s;
}
.chip-time b { color: var(--interactive-strong); font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-time:hover { border-color: var(--interactive); color: var(--interactive-strong); background: var(--interactive-tint); }
.chip-time--all {
  border-color: rgba(99, 164, 255, 0.45); color: var(--accent-bright); font-weight: 600;
}
.chip-time--all:hover { background: var(--primary); color: #fff; border-color: var(--accent-bright); }

/* ---- drive rows ---- */
.drive-row {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 12px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--fill-soft); border: 1px solid var(--interactive-tint-strong);
  color: var(--ink); text-align: left;
  transition: border-color .15s, background .15s;
}
.drive-row:hover { border-color: var(--accent); background: rgba(80, 128, 200, 0.14); }
.drive-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
.drive-go {
  flex: none; font-size: 11px; font-weight: 600; color: var(--accent-bright);
  border: 1px solid rgba(99, 164, 255, 0.4); border-radius: 999px; padding: 4px 10px;
}

/* ---- category chips ---- */
#cat-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-chip {
  border: 1px solid var(--line); background: var(--fill-soft);
  border-radius: 999px; padding: 6px 12px 6px 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--ink-dim);
  transition: opacity .15s, border-color .15s, color .15s;
}
.cat-chip .cat-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c, #888); box-shadow: 0 0 8px var(--c, #888);
}
.cat-chip.off { opacity: .4; }
.cat-chip.off .cat-dot { box-shadow: none; }
.cat-chip:hover { border-color: var(--c, var(--accent)); color: var(--ink); }

.panel-foot { margin-top: auto; padding: 12px 18px 14px; border-top: 1px solid var(--line); display: grid; gap: 7px; }
.foot-ghost {
  border: 0 !important; background: none !important;
  color: var(--ink-mute) !important; font-weight: 500 !important; font-size: 11.5px !important;
  padding: 4px !important; cursor: pointer;
}
.foot-ghost:hover { color: var(--ink) !important; }
.panel-foot button {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--interactive-tint-strong); background: var(--fill-soft);
  border-radius: 10px; padding: 10px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  transition: border-color .15s, background .15s;
}
.panel-foot button:hover { border-color: var(--accent); background: rgba(80, 128, 200, 0.16); }

#panel-toggle {
  display: none;
  position: absolute; right: 14px; bottom: 22px; z-index: 55;
  width: 50px; height: 50px; border-radius: 50%;
  border: 1px solid rgba(99, 164, 255, 0.45); cursor: pointer;
  background: var(--primary); color: #fff; box-shadow: var(--shadow);
  align-items: center; justify-content: center;
}

/* ============================ right rail ============================ */
#rail {
  position: absolute; z-index: 40;
  right: 14px; top: calc(var(--topbar-h) + 14px);
  display: flex; flex-direction: column; gap: 8px;
}
.rail-group { display: flex; flex-direction: column; border-radius: var(--radius-sm); overflow: hidden; }
.rail-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); cursor: pointer;
  background: var(--surface);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  color: var(--ink-dim); border-radius: var(--radius-sm);
  transition: color .15s, background .15s, border-color .15s;
}
.rail-btn:hover { color: var(--on-interactive); background: var(--primary); border-color: var(--primary); }
.rail-group .rail-btn { border-radius: 0; margin-bottom: -1px; }
.rail-group .rail-btn:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.rail-group .rail-btn:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-bottom: 0; }
.rail-btn.is-on { color: var(--on-interactive); background: var(--primary); border-color: var(--primary); }

/* ============================ map data ============================ */
#mapdata {
  position: absolute; z-index: 40; right: 14px; bottom: 14px; width: 264px;
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.md-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 12px 11px 14px; border-bottom: 1px solid var(--line);
}
.md-head h2 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .04em; }
#md-collapse {
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; background: none; color: var(--ink-mute); cursor: pointer;
  border-radius: 7px; transition: color .15s, transform .2s;
}
#md-collapse:hover { color: var(--ink); }
#mapdata.is-collapsed .md-body { display: none; }
#mapdata.is-collapsed #md-collapse { transform: rotate(180deg); }
#mapdata.is-collapsed .md-head { border-bottom: 0; }

.md-body { padding: 6px 6px 12px; }
.md-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px; border-radius: 9px;
}
.md-row:hover { background: var(--fill-soft); }
.md-row-label {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 12px; color: var(--ink-dim); min-width: 0;
}
.md-row-label svg { color: var(--ink-mute); flex: none; }
.md-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.md-swatch--project { background: linear-gradient(135deg, var(--accent-bright), var(--primary)); box-shadow: 0 0 8px rgba(99,164,255,.6); }
.md-swatch--poi { background: linear-gradient(135deg, #5fd48a, #38c0b0); box-shadow: 0 0 8px rgba(56,192,176,.5); }

.md-select select {
  border: 1px solid var(--interactive-tint-strong); background: var(--fill-inset);
  color: var(--ink); border-radius: 8px; padding: 5px 8px; font-size: 11.5px;
  cursor: pointer;
}
.md-select select:hover { border-color: var(--accent); }

.md-eye {
  width: 28px; height: 26px; display: grid; place-items: center; flex: none;
  border: 0; background: none; color: var(--accent-bright); cursor: pointer;
  border-radius: 7px; transition: color .15s, opacity .15s;
}
.md-eye[aria-pressed="false"] { color: var(--ink-mute); opacity: .55; }

.md-legend { padding: 10px 8px 2px; }
.md-legend[hidden] { display: none; }
.md-legend-title { display: block; font-size: 10.5px; color: var(--ink-mute); margin-bottom: 7px; }
.md-scale {
  height: 7px; border-radius: 4px;
  background: linear-gradient(90deg, #63a4ff, #4a7fd0, #2d5596, #16305c);
}
.md-scale-ends {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--ink-mute); margin-top: 5px;
}

/* ============================ project pins ============================ */
/* No position property here: MapLibre's .maplibregl-marker sets
   position:absolute and a same-specificity override would put markers back in
   normal flow (they then stack, offsetting every pin by the height of the
   ones before it). */
.pin { background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.pin-head {
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(160deg, #2f6bc4, var(--primary));
  border: 1.5px solid rgba(150, 200, 255, 0.65);
  color: #fff; font-weight: 700; font-size: 14px;
  display: grid; place-items: center;
  box-shadow: 0 4px 16px rgba(4, 14, 26, 0.7), 0 0 18px rgba(48, 110, 200, 0.55);
  transition: transform .15s, box-shadow .15s;
}
.pin-stem { width: 2px; height: 12px; background: linear-gradient(180deg, rgba(150,200,255,.8), transparent); }
.pin-label {
  position: absolute; left: calc(100% - 2px); top: 6px;
  background: var(--surface-strong);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  color: var(--ink); font-size: 11.5px; font-weight: 600; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px;
  box-shadow: var(--shadow-sm); pointer-events: none;
}
.pin--left .pin-label { left: auto; right: calc(100% - 2px); }
.pin:hover .pin-head, .pin:focus-visible .pin-head {
  transform: scale(1.12);
  box-shadow: 0 6px 22px rgba(4, 14, 26, 0.8), 0 0 26px rgba(99, 164, 255, 0.8);
}
.pin--todo .pin-head { background: rgba(90, 110, 135, 0.75); border-style: dashed; }
.pin--todo .pin-stem { background: rgba(140, 160, 185, 0.6); }

/* ============================ POI markers ============================ */
.poi { background: none; border: 0; padding: 0; cursor: pointer; }
.poi-icon {
  position: relative;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-strong);
  border: 1.5px solid var(--c, #888); color: var(--c, #888);
  display: grid; place-items: center;
  box-shadow: 0 3px 12px rgba(4, 14, 26, 0.6), 0 0 12px color-mix(in srgb, var(--c, #888) 45%, transparent);
  transition: transform .15s;
}
.poi:hover .poi-icon { transform: scale(1.16); }
.poi--planned .poi-icon { border-style: dashed; }
.poi--routed .poi-icon { border-color: var(--accent-bright); color: var(--accent-bright); }
.poi--ping .poi-icon::after {
  content: ''; position: absolute; inset: -3px;
  border-radius: 50%; border: 2px solid var(--accent-bright);
  animation: poi-ping 1.1s ease-out 1 both;
}
@keyframes poi-ping {
  from { opacity: .9; transform: scale(1); }
  to { opacity: 0; transform: scale(2.6); }
}
.poi-badge {
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 5px 9px; border-radius: 999px; white-space: nowrap;
  border: 1px solid rgba(150, 200, 255, 0.45);
  box-shadow: 0 4px 14px rgba(4, 14, 26, 0.7);
  pointer-events: none;
  animation: badge-in .32s cubic-bezier(.2, 1.3, .4, 1) both;
}
@keyframes badge-in {
  from { opacity: 0; transform: translateX(-50%) translateY(5px) scale(.85); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ============================ POI popup ============================ */
.maplibregl-popup-content {
  border-radius: var(--radius); padding: 15px 16px 13px;
  background: var(--surface);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { color: var(--ink-mute); font-size: 19px; padding: 4px 9px; }
.maplibregl-popup-close-button:hover { color: var(--ink); background: none; }
.poi-pop { min-width: 200px; }
.poi-pop-cat {
  font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--c, #888); font-weight: 700;
}
.poi-pop h3 { margin: 5px 0 7px; font-size: 15.5px; font-weight: 600; color: var(--ink); }
.planned-note { margin: 0 0 7px; font-size: 11.5px; line-height: 1.5; color: var(--ink-mute); }
.drive-head {
  margin: 11px 0 5px; font-size: 9.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-mute); font-weight: 600;
}
.times { list-style: none; margin: 0 -6px -4px; padding: 0; }
.times li { margin: 1px 0; }
.time-row {
  width: 100%; display: flex; align-items: center; gap: 10px;
  border: 0; background: none; cursor: pointer;
  border-radius: 8px; padding: 6px; text-align: left;
  font-size: 12.5px; color: var(--ink-dim);
  transition: background .12s, color .12s;
}
.time-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time-row b { font-variant-numeric: tabular-nums; }
.time-row .time-go { flex: none; color: var(--ink-mute); transition: transform .12s, color .12s; }
.time-row:hover { background: rgba(99, 164, 255, 0.16); color: var(--ink); }
.time-row:hover .time-go { color: var(--accent-bright); transform: translateX(2px); }

/* ============================ modal ============================ */
#modal { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; background: var(--page-bg); }
#modal[hidden] { display: none; }
.modal-bar {
  height: 54px; flex: none;
  background: var(--modal-bar-bg);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 0 18px; padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
.modal-bar h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .02em; color: var(--ink); }
.modal-actions { display: flex; align-items: center; gap: 6px; }
.modal-actions a {
  color: var(--ink-dim); font-size: 12.5px; text-decoration: none;
  padding: 8px 11px; border-radius: 8px;
}
.modal-actions a:hover { background: var(--interactive-tint); color: var(--interactive-strong); }
#modal-close {
  border: 1px solid rgba(99, 164, 255, 0.45); cursor: pointer;
  background: var(--primary); color: #fff;
  border-radius: 9px; padding: 9px 14px;
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
}
#modal-close:hover { border-color: var(--accent-bright); }
.modal-body { flex: 1; position: relative; }
#modal-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
#modal-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: var(--surface-solid); color: var(--ink); text-align: center; padding: 24px;
}
#modal-fallback[hidden] { display: none; }
#modal-fallback a {
  background: var(--primary); color: #fff; font-weight: 600;
  padding: 11px 20px; border-radius: 10px; text-decoration: none;
  border: 1px solid rgba(99, 164, 255, 0.45);
}

/* ============================ route bar ============================ */
#route-bar {
  position: absolute; z-index: 45;
  left: calc(var(--panel-w) + 34px); right: 294px; bottom: 30px;
  margin: 0 auto; max-width: 620px;
  display: flex; align-items: center; gap: 15px;
  padding: 11px 12px 11px 15px;
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: bar-in .28s ease both;
}
#route-bar[hidden] { display: none; }
@keyframes bar-in { from { opacity: 0; transform: translateY(12px); } }
.route-mark {
  width: 32px; height: 32px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  background: rgba(99, 164, 255, 0.16); color: var(--accent-bright);
}
.route-text { min-width: 0; }
.route-pair { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.route-pair b { font-weight: 600; white-space: nowrap; }
.route-pair b:first-of-type { flex: none; }
.route-pair b:last-of-type { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.route-arrow { color: var(--accent-bright); flex: none; }
.route-meta { display: block; font-size: 11.5px; color: var(--ink-mute); margin-top: 3px; }
.route-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: none; }
.route-actions button {
  border-radius: 9px; cursor: pointer; font-size: 12px; font-weight: 600;
  padding: 9px 14px; border: 1px solid var(--line);
}
.route-secondary { background: var(--fill-soft); color: var(--interactive); border-color: var(--interactive-tint-strong); }
.route-secondary:hover { border-color: var(--accent); background: rgba(80, 128, 200, 0.2); }
.route-secondary[hidden] { display: none; }
.route-primary { background: var(--primary); color: #fff; border-color: rgba(99, 164, 255, 0.45); }
.route-primary:hover { border-color: var(--accent-bright); }

/* ============================ help ============================ */
#help {
  position: fixed; inset: 0; z-index: 110;
  display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--page-bg) 72%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#help[hidden] { display: none; }
.help-card {
  width: min(520px, 100%); max-height: 82vh; overflow-y: auto;
  border-radius: var(--radius); padding: 20px 22px 22px;
  background: var(--surface-solid); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}
.help-card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.help-card h2 { margin: 0; font-size: 18px; font-weight: 600; }
#help-close {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--line); background: none; color: var(--ink-dim);
  border-radius: 9px; cursor: pointer;
}
#help-close:hover { color: var(--interactive-strong); border-color: var(--interactive); }
.help-card dl { margin: 0; display: grid; gap: 12px; }
.help-card dt { font-size: 12.5px; font-weight: 600; color: var(--accent-bright); }
.help-card dd { margin: 3px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--ink-dim); }
.help-card dd b { color: var(--ink); font-weight: 600; }

/* ============================ loading ============================ */
#loading {
  position: fixed; inset: 0; z-index: 200;
  background: var(--loading-bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .6s; color: var(--ink);
}
#loading.done { opacity: 0; pointer-events: none; }
.load-mark { text-align: center; }
.load-mark img { display: block; margin: 0 auto 18px; opacity: .95; }
.load-mark p { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-mute); margin: 14px 0 0; }
.load-bar {
  width: 150px; height: 2px; margin: 0 auto; border-radius: 2px;
  background: rgba(120, 165, 220, 0.2); overflow: hidden;
}
.load-bar span {
  display: block; width: 40%; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-bright), transparent);
  animation: load-sweep 1.25s ease-in-out infinite;
}
@keyframes load-sweep { from { transform: translateX(-110%); } to { transform: translateX(310%); } }

/* ============================ toast ============================ */
#toast {
  position: fixed; z-index: 300;
  left: 50%; transform: translateX(-50%); bottom: 96px;
  background: var(--surface-solid); color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 11px 18px; border-radius: 999px; font-size: 12.5px;
  box-shadow: var(--shadow);
}
#toast[hidden] { display: none; }

/* ============================ attribution ============================ */
/* OSM/OpenFreeMap credit is a licence requirement, so it is pushed clear of
   the panel rather than left to sit behind it. */
.maplibregl-ctrl-bottom-left {
  z-index: 30;
  left: calc(var(--panel-w) + 28px);
  transition: left .2s;
}
.maplibregl-ctrl-attrib {
  font-size: 10px;
  background: var(--surface) !important;
  color: var(--ink-mute); border-radius: 8px 8px 0 0;
}
.maplibregl-ctrl-attrib a { color: var(--ink-dim); }
.maplibregl-ctrl-bottom-right { display: none; } /* the rail replaces the default controls */

/* =========================================================================
   CLICKABLE AFFORDANCE
   One rule for the whole app: if it is pressable it carries --interactive;
   if it is not, it never does. Decorative icons and static values stay in
   the ink greys so the blue always means "you can press this".
   ========================================================================= */

/* decorative marks must give the interactive colour back */
.tb-crumbs svg, .panel-context svg, .route-arrow, .md-row-label svg { color: var(--ink-mute); }

/* pressable text and icons */
.tb-tab:not(.is-active) { color: var(--interactive); }
.tb-tab:not(.is-active):hover { background: var(--interactive-tint); }
.tb-icon { color: var(--interactive); }
.tb-icon:hover { background: var(--interactive-tint); border-color: var(--interactive-tint-strong); }
.rail-btn { color: var(--interactive); }
.md-eye[aria-pressed="true"] { color: var(--interactive); }
.seg-btn:not(.is-active) { color: var(--interactive); }
.md-select select { color: var(--interactive); font-weight: 600; }

/* pressable rows and chips: an interactive-tinted edge marks the hit area */
.chip-time { border-color: var(--interactive-tint-strong); color: var(--interactive); }
.chip-time b { color: var(--interactive-strong); }
.chip-time:hover { background: var(--interactive-tint); border-color: var(--interactive); color: var(--interactive-strong); }
.cat-chip { border-color: var(--interactive-tint-strong); }
.time-row b, .time-row .time-go { color: var(--interactive); }
.time-row:hover { background: var(--interactive-tint); }
.time-row:hover b, .time-row:hover .time-go { color: var(--interactive-strong); }
.drive-row .drive-go { color: var(--interactive); border-color: var(--interactive-tint-strong); }
.drive-row:hover { border-color: var(--interactive); background: var(--interactive-tint); }
.proj-item:hover { border-color: var(--interactive-tint-strong); }
.proj-main:hover .proj-name { color: var(--interactive); text-decoration: underline; text-underline-offset: 3px; }
.panel-foot button { color: var(--interactive); }
.panel-foot button:hover { background: var(--interactive-tint); border-color: var(--interactive); }
.route-secondary:hover { background: var(--interactive-tint); border-color: var(--interactive); }
.modal-actions a { color: var(--interactive); }
.help-card dt { color: var(--interactive); }
#help-close { color: var(--interactive); }
.maplibregl-ctrl-attrib a { color: var(--interactive); }

/* filled controls: the interactive colour becomes the background instead */
.kpi-cta, .proj-open, .route-primary, #modal-close, #modal-fallback a, .tb-tab.is-active, .seg-btn.is-active {
  background: var(--primary); color: #fff; border-color: transparent;
}
.kpi-cta { background: linear-gradient(180deg, #1d55bd, var(--primary)); }
.kpi-cta:hover, .proj-open:hover, .route-primary:hover, #modal-close:hover { background: var(--interactive-strong); }
:root[data-theme="dark"] .kpi-cta:hover,
:root[data-theme="dark"] .proj-open:hover,
:root[data-theme="dark"] .route-primary:hover,
:root[data-theme="dark"] #modal-close:hover { background: #2059c4; }

/* map markers are pressable too, and say so on hover */
.pin:hover .pin-head, .pin:focus-visible .pin-head { outline: 2px solid var(--interactive); outline-offset: 3px; }
.poi:hover .poi-icon, .poi:focus-visible .poi-icon { outline: 2px solid var(--interactive); outline-offset: 2px; }

/* the theme button shows the mode you would switch TO */
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

/* Light chrome over aerial imagery needs a harder edge than over a drawn map. */
:root[data-basemap="satellite"] #panel,
:root[data-basemap="satellite"] #mapdata,
:root[data-basemap="satellite"] #route-bar,
:root[data-basemap="satellite"] .rail-btn,
:root[data-basemap="satellite"] .maplibregl-popup-content {
  border-color: var(--line-strong);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.35);
}
:root[data-theme="dark"][data-basemap="satellite"] #panel,
:root[data-theme="dark"][data-basemap="satellite"] #mapdata,
:root[data-theme="dark"][data-basemap="satellite"] #route-bar,
:root[data-theme="dark"][data-basemap="satellite"] .rail-btn,
:root[data-theme="dark"][data-basemap="satellite"] .maplibregl-popup-content {
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.45);
}

/* ============================ responsive ============================ */
/* Tablets keep the desktop chrome but need the panel and the bar to stop
   fighting for the same pixels. */
@media (max-width: 1180px) {
  #route-bar { left: calc(var(--panel-w) + 28px); right: 20px; }
}
/* Mid widths drop the tab icons and keep the words; the narrowest widths do
   the opposite, because three words will not fit beside the brand. */
@media (max-width: 1024px) {
  :root { --panel-w: 300px; }
  .tb-tab { padding: 8px 11px; }
  .tb-tab svg { display: none; }
  #mapdata { width: 232px; }
}
@media (max-width: 900px) {
  .tb-crumbs { display: none; }
  #route-bar { left: calc(var(--panel-w) + 24px); right: 16px; bottom: 14px; }
  #mapdata { display: none; }
}

@media (max-width: 760px) {
  :root { --topbar-h: 52px; }
  .tb-brand-text { display: none; }
  .tb-tab { font-size: 12px; padding: 7px 10px; }
  #topbar { gap: 8px; padding: 0 10px; }
  .tb-brand { padding-left: 8px; margin-left: 0; }
}

/* Phone: the panel becomes a bottom sheet. These rules MUST stay inside the
   760px query - loose at top level they turn every desktop into a phone. */
@media (max-width: 760px) {
  #panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; max-width: none; height: min(66vh, 560px);
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(calc(100% + 12px));
    transition: transform .3s cubic-bezier(.32, .72, 0, 1);
  }
  #panel.open { transform: translateY(0); }
  #panel-toggle { display: flex; }
  #rail { top: calc(var(--topbar-h) + 10px); right: 10px; }
  .maplibregl-ctrl-bottom-left { left: 0; }
  .pin-label { display: none; }
  .modal-bar h2 { font-size: 13px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Above the sheet button, never under it. */
  #route-bar {
    left: 12px; right: 12px; bottom: 82px; max-width: none;
    flex-wrap: wrap; gap: 10px; padding: 12px 14px;
  }
  .route-actions { width: 100%; margin-left: 0; }
  .route-actions button { flex: 1; }
  #toast { bottom: 148px; }
}

@media (max-width: 620px) {
  #topbar { gap: 4px; padding: 0 8px; }
  .tb-tab svg { display: block; }
  .tb-tab-text { display: none; }
  .tb-tab { padding: 8px 12px; }
  .tb-left { flex: 0 0 auto; }
  .tb-right { gap: 4px; }
  .seg--sm { display: none; } /* the Ground select in Map data covers this */
  #help-btn { display: none; } /* the help sheet stays reachable from the panel */
}

@media (prefers-reduced-motion: reduce) {
  #route-bar, .poi-badge, .load-bar span { animation: none; }
  .poi--ping .poi-icon::after { display: none; }
  * { transition-duration: .01ms !important; }
}
