/* ════════════════════════════════════════════════════════
   MELA · Orenda Network — Hamilton 2092
   Dashboard futurism, not chapter parchment.
   Tokens: designskill2092 MELA namespace.
   ════════════════════════════════════════════════════════ */

:root {
  --bg: #0f1419;
  --bg-2: #171d26;
  --panel: rgba(22, 28, 38, 0.82);
  --panel-solid: #171d26;

  --orenda: #00d4aa;
  --orenda-2: #3df2c8;
  --orenda-soft: rgba(0, 212, 170, 0.14);
  --orenda-med:  rgba(0, 212, 170, 0.28);
  --thermal: #ff6b35;
  --hub: #ffd700;

  --ink:    #e9f3ef;
  --ink-2:  #b9c7c2;
  --muted:  #7a8a85;
  --muted-2:#4a564f;

  --line:     rgba(0, 212, 170, 0.35);
  --line-soft:rgba(0, 212, 170, 0.18);
  --hairline: rgba(255, 255, 255, 0.06);

  --glow:     0 0 12px rgba(0, 212, 170, 0.55);
  --glow-soft:0 0 6px  rgba(0, 212, 170, 0.35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, 0.55);

  --radius:    12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --font-ui:   -apple-system, BlinkMacSystemFont, ui-sans-serif, system-ui, "SF Pro Text", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", Consolas, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* Legacy aliases (kept so existing app.js selectors still render) */
  --accent: var(--orenda);
  --accent-soft: var(--orenda-soft);
  --accent-med: var(--orenda-med);
  --text: var(--ink);
  --text-2: var(--ink-2);
  --text-3: var(--muted);
  --border: var(--hairline);
  --border-hover: rgba(255,255,255,0.12);
  --white: #ffffff;
  --surface: var(--panel);
  --surface-solid: var(--panel-solid);
  --glass-bg: var(--panel);
  --glass-border: 1px solid var(--line);
  --glass-shadow: 0 0 0 1px rgba(0, 212, 170, 0.10), inset 0 1px 0 rgba(255,255,255,0.04);
  --glass-blur: blur(14px) saturate(1.15);
  --font: var(--font-ui);
  --red: var(--thermal);
  --green: var(--orenda);
  --amber: var(--hub);
  --go-green: #2E7D32;
  --lrt-purple: #9C27B0;
  --brt-orange: #FF6F00;
  --shadow-diffuse: var(--shadow-md);
  --shadow-glow: var(--glow-soft);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible { outline: 1.5px solid var(--orenda); outline-offset: 2px; }

.label-caps {
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.skip-nav {
  position: fixed; top: -100px; left: 50%; transform: translateX(-50%);
  padding: 8px 20px; background: var(--orenda); color: #001511;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font: 600 12px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase;
  text-decoration: none; z-index: 1000; transition: top 0.2s;
}
.skip-nav:focus { top: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  overflow: hidden;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Author-mode gate: hide edit UI unless ?edit=1 or localhost */
body:not(.author-mode) .mode-switch,
body:not(.author-mode) #edit-bar,
body:not(.author-mode) #draw-hud,
body:not(.author-mode) #btn-export-canonical { display: none !important; }

/* ─── Loader ─── */
#loader {
  position: fixed; inset: 0; z-index: 999;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 45%, #0d1a18 0%, var(--bg) 60%);
  transition: opacity 0.6s var(--ease), visibility 0.6s;
}
#loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-card { text-align: center; }
.loader-spinner {
  width: 32px; height: 32px; margin: 0 auto 16px;
  border: 1.5px solid var(--line-soft);
  border-top-color: var(--orenda);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  box-shadow: var(--glow-soft);
}
.loader-card h2 {
  font: 600 14px/1 var(--font-ui);
  letter-spacing: 0.04em;
  color: var(--ink);
}
.loader-card p { margin-top: 6px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Map + Overlay ─── */
#map { width: 100vw; height: 100vh; background: var(--bg); }
#overlay {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 5;
}
#map .maplibregl-canvas { filter: saturate(0.95) hue-rotate(-2deg); }

/* ═════════════ CANONICAL MASTHEAD (.ms-bar) — unified across all labs ═════════════ */
.ms-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 64px; z-index: 1000;
  display: flex; align-items: center; gap: 18px;
  padding: 0 24px;
  background: rgba(15,22,24,0.85);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.ms-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.ms-brand-mark { font: 500 15px/1 'Orbitron', ui-monospace, monospace; color: var(--amber, #e2a65b); letter-spacing: 0.06em; text-shadow: 0 0 10px rgba(226,166,91,0.35); }
.ms-brand-wm { font: italic 400 17px/1 'Augify', Georgia, serif; color: var(--ink-0, #fbf6ee); }
.ms-sep { color: rgba(255,255,255,0.3); font: 300 12px/1 'Orbitron', ui-monospace, monospace; }
.ms-lab-name { font: 500 10px/1 'Orbitron', ui-monospace, monospace; color: var(--amber, #e2a65b); letter-spacing: 0.18em; text-transform: uppercase; }
.ms-chapters-wrap { position: relative; margin-left: 14px; }
.ms-chapters { background: transparent; border: 1px solid rgba(255,255,255,0.08); color: var(--ink-0, #fbf6ee); padding: 8px 14px; border-radius: 999px; font: 500 10px/1 'Orbitron', ui-monospace, monospace; letter-spacing: 0.18em; text-transform: uppercase; cursor: pointer; transition: border-color 200ms ease, color 200ms ease; }
.ms-chapters:hover, .ms-chapters[aria-expanded="true"] { border-color: rgba(226,166,91,0.35); color: var(--amber, #e2a65b); }
.ms-chapters-menu { position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%); background: rgba(15,22,24,0.95); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid rgba(255,255,255,0.08); padding: 12px; border-radius: 12px; display: flex; flex-direction: column; gap: 4px; min-width: 220px; box-shadow: 0 14px 36px rgba(0,0,0,0.45); z-index: 1001; }
.ms-chapters-menu[hidden] { display: none; }
.ms-chapters-menu a { color: var(--ink-1, #e2d9c4); text-decoration: none; padding: 8px 12px; border-radius: 6px; font: 400 13px/1.3 'Founders Grotesk', sans-serif; transition: background 180ms ease, color 180ms ease; }
.ms-chapters-menu a:hover { background: rgba(226,166,91,0.08); color: var(--amber, #e2a65b); }
.ms-labs { margin-left: auto; display: flex; gap: 6px; }
.ms-lab-pill { padding: 7px 13px; border-radius: 999px; text-decoration: none; color: var(--ink-1, #e2d9c4); font: 500 10px/1 'Orbitron', ui-monospace, monospace; letter-spacing: 0.14em; text-transform: uppercase; border: 1px solid transparent; transition: color 180ms ease, border-color 180ms ease, background 180ms ease; }
.ms-lab-pill:hover { color: var(--amber, #e2a65b); border-color: rgba(226,166,91,0.2); }
.ms-lab-pill[aria-current="page"] { color: var(--amber, #e2a65b); border-color: rgba(226,166,91,0.35); background: rgba(226,166,91,0.08); }
@media (max-width: 900px) {
  .ms-bar { gap: 10px; padding: 0 14px; }
  .ms-brand-wm { font-size: 15px; }
  .ms-lab-pill { padding: 6px 10px; font-size: 9px; letter-spacing: 0.1em; }
  .ms-chapters-menu { min-width: 180px; }
}
@media (max-width: 768px) {
  .ms-sep, .ms-lab-name { display: none; }
}

/* ─── Header (MELA app controls — sits BELOW the canonical .ms-bar) ─── */
#header {
  position: fixed; top: 76px; left: 12px; right: 12px;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 0 16px;
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.05), inset 0 0 0 1px rgba(0,212,170,0.08);
  z-index: 10;
}
#header::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(0,212,170,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.header-left, .header-center, .header-right {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 10px;
}
.header-center { flex: 1; justify-content: center; }

/* ─── Cross-lab nav (sister labs) ─── */
#header .site-nav {
  display: flex; align-items: center; gap: 16px;
  padding-left: 14px; margin-left: 6px;
  border-left: 1px solid var(--line);
  min-width: 0;
}
#header .site-nav a {
  font: 500 10px/1 var(--font-mono, ui-monospace, monospace);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim, rgba(255,255,255,0.55));
  text-decoration: none;
  white-space: nowrap;
  padding: 3px 0;
  border-bottom: 1px solid transparent;
  transition: color 200ms cubic-bezier(0.16, 1, 0.3, 1), border-color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
#header .site-nav a:hover { color: var(--ink, #fff); border-bottom-color: rgba(0,212,170,0.4); }
#header .site-nav a.is-active { color: var(--ink, #fff); border-bottom-color: var(--orenda); }
@media (max-width: 980px) {
  #header .site-nav { display: none; }
}

.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
  transition: color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.brand:hover { color: var(--orenda); }
.brand:hover .brand-mark { transform: rotate(45deg); color: var(--orenda); opacity: 1; }
.brand-icon { color: var(--orenda); filter: drop-shadow(0 0 4px rgba(0,212,170,0.7)); }
.brand-name {
  font: 600 13px/1 var(--font-ui);
  letter-spacing: 0.04em;
  color: var(--ink);
}
.brand-sep { color: var(--orenda); margin: 0 2px; }

/* Universal Hamilton 2092 ✤ mark — shared with Orgobot Lab + chapter pages
   per /2092 skill §XV. Rotates 45° on hover. In MELA's dashboard register
   it reads as "back to the 2092 umbrella brand". */
.brand-mark {
  font-size: 13px;
  color: var(--orenda);
  opacity: 0.72;
  display: inline-block;
  transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1), color 200ms ease, opacity 200ms ease;
  margin-left: 4px;
}

/* Year slider */
.year-slider-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  height: 34px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(0, 212, 170, 0.04);
}
.year-label { color: var(--orenda); }
#year-slider {
  -webkit-appearance: none; appearance: none;
  width: 220px; height: 4px;
  background: linear-gradient(90deg, rgba(92,107,133,0.5) 0%, var(--orenda) 100%);
  border-radius: 2px;
  outline: none;
}
#year-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--orenda);
  box-shadow: 0 0 10px var(--orenda), 0 0 0 3px rgba(0,212,170,0.18);
  border: none; cursor: pointer;
  transition: transform 0.15s var(--ease);
}
#year-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--orenda);
  box-shadow: 0 0 10px var(--orenda), 0 0 0 3px rgba(0,212,170,0.18);
  border: none; cursor: pointer;
}
#year-slider:hover::-webkit-slider-thumb { transform: scale(1.15); }
.year-readout {
  font: 700 13px/1 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--orenda);
  min-width: 42px;
  text-shadow: 0 0 6px rgba(0,212,170,0.6);
}

/* Header buttons */
.header-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(0, 212, 170, 0.04);
  color: var(--ink-2);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.header-btn:hover {
  background: rgba(0, 212, 170, 0.12);
  color: var(--orenda);
  border-color: var(--line);
  box-shadow: var(--glow-soft);
}

/* Crosslink back to Hamilton 2092 guidebook — distinct from the other
   header buttons. Uses text-decoration:none since it's an <a>, with a
   doorway-like hover: ✤ rotates and the arrow nudges up-right. */
a.header-btn--crosslink {
  text-decoration: none;
  gap: 7px;
  padding-left: 10px;
  padding-right: 10px;
}
a.header-btn--crosslink .brand-mark {
  margin: 0;
  font-size: 11px;
  line-height: 1;
}
a.header-btn--crosslink .crosslink-arrow {
  opacity: 0.55;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms ease;
}
a.header-btn--crosslink:hover .brand-mark {
  transform: rotate(45deg);
  opacity: 1;
}
a.header-btn--crosslink:hover .crosslink-arrow {
  transform: translate(1.5px, -1.5px);
  opacity: 1;
}

/* Mode switch (author only) */
.mode-switch {
  position: relative;
  display: flex; gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 3px;
}
.mode-btn {
  position: relative; z-index: 1;
  padding: 5px 14px;
  border: none; border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s;
}
.mode-btn.active { color: var(--orenda); text-shadow: 0 0 6px rgba(0,212,170,0.6); }
.mode-indicator {
  position: absolute;
  top: 3px; left: 3px;
  width: calc(50% - 4px); height: calc(100% - 6px);
  background: rgba(0, 212, 170, 0.14);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: transform 0.3s var(--ease);
}
.mode-switch[data-active="edit"] .mode-indicator { transform: translateX(calc(100% + 2px)); }

/* Live badge */
.live-badge {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(0, 212, 170, 0.04);
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--orenda);
}
.live-badge.offline { color: var(--muted); border-color: var(--hairline); }
.live-badge.offline .live-dot { background: var(--muted); box-shadow: none; }
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--orenda);
  box-shadow: 0 0 6px var(--orenda);
  animation: pulse-dot 2s ease infinite;
}
@keyframes pulse-dot { 0%,100% { opacity: 1 } 50% { opacity: 0.35 } }

/* ─── Side Panel ─── */
#panel {
  position: fixed;
  top: 76px; left: 12px;
  width: 300px;
  max-height: calc(100vh - 94px);
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.05), inset 0 0 0 1px rgba(0,212,170,0.08);
  z-index: 10;
  overflow: hidden;
  display: flex; flex-direction: column;
}
#panel::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(0,212,170,0.05) 0%, transparent 40%);
  pointer-events: none;
}
.panel-scroll { overflow-y: auto; flex: 1; padding: 14px; position: relative; z-index: 1; }
.panel-scroll::-webkit-scrollbar { width: 4px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--line-soft); border-radius: 4px; }

.panel-lede {
  border-left: 1px solid var(--line);
  padding: 2px 0 2px 10px;
  margin-bottom: 14px;
}
.lede-small {
  font: 400 11px/1.55 var(--font-ui);
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

/* Search */
.search-wrap { position: relative; margin-bottom: 14px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
input#search {
  width: 100%; padding: 8px 12px 8px 30px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  font: 500 12px/1 var(--font-ui);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
input#search:focus {
  border-color: var(--orenda);
  box-shadow: 0 0 0 2px rgba(0,212,170,0.15), var(--glow-soft);
  background: rgba(0, 0, 0, 0.4);
}
input#search::placeholder { color: var(--muted); }

.panel-section { margin-bottom: 10px; }
.section-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; padding: 0 2px; }
.section-top h3 {
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--orenda);
}
.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 18px; padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 212, 170, 0.08);
  border: 1px solid var(--line-soft);
  font: 600 10px/1 var(--font-mono); color: var(--orenda);
  margin-left: 6px;
}

/* ─── Collapsible Panel Sections (accordion) ─── */
.panel-section-toggle {
  width: 100%;
  height: 30px;
  padding: 0 10px 0 12px;
  display: flex; align-items: center; justify-content: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 1px 2px rgba(0,0,0,0.25);
}
.panel-section-toggle:hover {
  background: rgba(0, 212, 170, 0.05);
  border-color: rgba(0, 212, 170, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 1px 3px rgba(0,0,0,0.32);
  color: #c6f4e7;
}
.panel-section-label {
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--orenda);
  flex: 0 0 auto;
}
.panel-section-toggle .count {
  margin-left: 0;
  flex: 0 0 auto;
}
.panel-section-chevron {
  margin-left: auto;
  color: var(--orenda);
  opacity: 0.7;
  transform: rotate(var(--chevron-rot, 0deg));
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s var(--ease);
  flex: 0 0 auto;
}
.panel-section-toggle:hover .panel-section-chevron { opacity: 1; }
.panel-section-toggle.is-open { --chevron-rot: 180deg; }

.panel-section-body {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height 280ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity   220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.panel-section-body.is-open {
  max-height: var(--section-max, 1600px);
  opacity: 1;
}

.route-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.route-chip {
  display: flex; align-items: center;
  height: 30px; padding: 0 10px;
  border-radius: 999px;
  font: 700 10px/1 var(--font-mono); letter-spacing: 0.08em;
  color: #001511;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease),
              color 0.2s var(--ease), transform 0.2s var(--ease),
              box-shadow 0.2s var(--ease), opacity 0.2s var(--ease);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 1px 2px rgba(0,0,0,0.3);
}
.route-chip:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), 0 2px 6px rgba(0,0,0,0.45);
  border-color: rgba(255,255,255,0.2);
}
.chip-num { white-space: nowrap; flex-shrink: 0; }
.chip-name {
  max-width: 0; overflow: hidden; white-space: nowrap;
  font-weight: 500; font-size: 10px; opacity: 0;
  transition: max-width 0.3s var(--ease), opacity 0.25s, margin-left 0.3s;
  margin-left: 0;
}
.route-chip.active {
  border-color: rgba(255,255,255,0.45);
  transform: scale(1.04);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 2px 8px rgba(0,0,0,0.5);
}
.route-chip.active .chip-name { max-width: 130px; opacity: 1; margin-left: 6px; }

/* OFF state — per-chip visibility toggle (see toggleRouteVisibility in app.js) */
.route-chip.route-chip--off {
  background: transparent !important;
  color: var(--chip-off-color, rgba(255,255,255,0.55)) !important;
  border-color: var(--chip-off-border, rgba(255,255,255,0.25)) !important;
  box-shadow: none;
  opacity: 0.85;
}
.route-chip.route-chip--off:hover {
  transform: translateY(-1px);
  box-shadow: none;
  opacity: 1;
}
.route-chip.route-chip--off .chip-name { color: inherit; }

.stop-card {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.2s, transform 0.2s;
  color: var(--ink-2);
}
.stop-card:hover { background: var(--orenda-soft); transform: translateX(2px); color: var(--ink); }
.stop-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--orenda);
  box-shadow: var(--glow-soft);
  flex-shrink: 0;
}
.stop-card-name { font: 500 12px/1.3 var(--font-ui); }

/* ─── MELA panel skeleton loader ─── */
.mela-skeleton {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 2px;
}
.mela-skeleton-row {
  height: 38px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(0,212,170,0.07) 40%,
    rgba(255,255,255,0.04) 80%
  );
  background-size: 200% 100%;
  animation: mela-shimmer 1.6s ease-in-out infinite;
}
@keyframes mela-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
/* Stagger skeleton rows */
.mela-skeleton-row:nth-child(2) { animation-delay: 0.15s; }
.mela-skeleton-row:nth-child(3) { animation-delay: 0.30s; }
.mela-skeleton-row:nth-child(4) { animation-delay: 0.45s; }

/* ─── MELA Network Section ─── */
.panel-section--mela {
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(0,212,170,0.10);
}

/* Section toggle glow for MELA */
.panel-section-toggle--mela {
  background: rgba(0,212,170,0.05);
  border-color: rgba(0,212,170,0.14);
}
.panel-section-toggle--mela:hover {
  background: rgba(0,212,170,0.09);
  border-color: rgba(0,212,170,0.22);
}
.panel-section-toggle--mela.is-open {
  background: rgba(0,212,170,0.07);
}

/* Pulsing dot in the MELA section header */
.mela-net-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--orenda);
  box-shadow: 0 0 5px var(--orenda);
  flex-shrink: 0;
  animation: mela-net-pulse 2.4s ease-in-out infinite;
}
@keyframes mela-net-pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 5px var(--orenda); }
  50%      { opacity: 0.45; box-shadow: 0 0 2px var(--orenda); }
}

/* Route list container */
.mela-route-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 6px;
}

/* Individual route card */
.mela-line-card {
  display: flex;
  align-items: center;
  gap: 0;
  height: 38px;
  border-radius: 4px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  overflow: hidden;
  transition: background 160ms var(--ease), border-color 160ms var(--ease), transform 160ms var(--ease);
}
.mela-line-card:hover {
  background: rgba(0,212,170,0.07);
  border-color: rgba(0,212,170,0.18);
  transform: translateX(2px);
}
.mela-line-card:focus-visible {
  outline: 2px solid rgba(0,212,170,0.5);
  outline-offset: 1px;
}
.mela-line-card.is-active {
  background: rgba(0,212,170,0.10);
  border-color: rgba(0,212,170,0.35);
  transform: translateX(3px);
}
.mela-line-card.is-active .mela-line-name {
  color: #c6f4e7;
}

/* Left color stripe */
.mela-line-stripe {
  display: block;
  width: 3px;
  align-self: stretch;
  flex-shrink: 0;
  border-radius: 0 2px 2px 0;
}

/* Card text body */
.mela-line-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 9px;
  min-width: 0;
}
.mela-line-name {
  font: 500 11px/1.2 var(--font-mono);
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.mela-line-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  margin-left: 6px;
}
.mela-line-year {
  font: 600 9px/1 var(--font-mono);
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.32);
}
.mela-line-tier {
  font: 700 8px/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 3px;
}
.mela-line-tier--trunk {
  background: rgba(0,212,170,0.14);
  color: #7fe0c8;
  border: 1px solid rgba(0,212,170,0.22);
}
.mela-line-tier--pod {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.38);
  border: 1px solid rgba(255,255,255,0.09);
}

/* Upload row beneath the route list */
.mela-upload-row {
  padding: 4px 0 2px;
  display: flex;
  justify-content: flex-start;
}
.mela-upload-btn {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: rgba(0,212,170,0.65);
  border-color: rgba(0,212,170,0.14);
  gap: 5px;
}
.mela-upload-btn:hover {
  color: #00d4aa;
  border-color: rgba(0,212,170,0.32);
  background: rgba(0,212,170,0.06);
}
.mela-upload-btn svg { opacity: 0.75; }

/* ─── Layers Section (native, flows inside #panel) ─── */
.panel-section--layers {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.layer-toggles {
  display: flex; flex-direction: column;
  gap: 1px;
  padding: 2px 0 0;
}
.layer-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.layer-toggle:hover { background: rgba(0, 212, 170, 0.06); }
.layer-icon { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.layer-name { font: 500 11px/1 var(--font-ui); color: var(--ink-2); flex: 1; }

/* ─── Timeline Panel ─── */
.timeline-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 50;
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.timeline-overlay.open { opacity: 1; visibility: visible; }
.timeline-panel {
  position: fixed;
  top: 12px; right: -420px;
  width: 400px;
  max-height: calc(100vh - 24px);
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(0,212,170,0.08);
  z-index: 60;
  display: flex; flex-direction: column;
  transition: right 0.4s var(--ease);
  overflow: hidden;
}
.timeline-panel::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(0,212,170,0.06) 0%, transparent 30%);
  pointer-events: none;
}
.timeline-panel.open { right: 12px; }
.timeline-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--hairline);
  position: relative; z-index: 1;
}
.timeline-header h2 {
  font: 600 13px/1 var(--font-mono);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--orenda);
}
.timeline-close {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.15s;
}
.timeline-close:hover { background: rgba(0,212,170,0.08); color: var(--orenda); border-color: var(--line); }
.timeline-scroll {
  flex: 1; overflow-y: auto;
  padding: 22px 18px 22px 26px;
  position: relative; z-index: 1;
}
.timeline-scroll::-webkit-scrollbar { width: 4px; }
.timeline-scroll::-webkit-scrollbar-thumb { background: var(--line-soft); border-radius: 4px; }

.timeline-track { position: relative; padding-left: 28px; }
.timeline-track::before {
  content: '';
  position: absolute;
  left: 8px; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--muted) 0%, var(--orenda) 45%, var(--hub) 85%);
  border-radius: 1px;
}
.timeline-node {
  position: relative;
  margin-bottom: 24px;
  opacity: 0;
  transform: translateY(12px);
  animation: timeline-fade-in 0.4s var(--ease) forwards;
}
.timeline-node:last-child { margin-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -24px; top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: var(--bg);
  z-index: 1;
  box-shadow: 0 0 8px currentColor;
}
.timeline-year {
  font: 700 11px/1 var(--font-mono);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.timeline-title {
  font: 600 13px/1.3 var(--font-ui);
  color: var(--ink);
  margin-bottom: 4px;
}
.timeline-desc {
  font: 400 11px/1.5 var(--font-ui);
  color: var(--ink-2);
}
@keyframes timeline-fade-in {
  to { opacity: 1; transform: translateY(0); }
}
.timeline-node[data-type="hsr"] .timeline-year, .timeline-node[data-type="hsr"] .timeline-dot { color: var(--muted); }
.timeline-node[data-type="lrt"] .timeline-year, .timeline-node[data-type="lrt"] .timeline-dot { color: var(--lrt-purple); }
.timeline-node[data-type="brt"] .timeline-year, .timeline-node[data-type="brt"] .timeline-dot { color: var(--brt-orange); }
.timeline-node[data-type="go"]  .timeline-year, .timeline-node[data-type="go"]  .timeline-dot { color: var(--go-green); }
.timeline-node[data-type="future"] .timeline-year, .timeline-node[data-type="future"] .timeline-dot { color: var(--orenda); }

/* ─── Edit Bar (author only) ─── */
#edit-bar {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 10;
}
#edit-bar.hidden { display: none; }
.edit-bar-inner {
  display: flex; align-items: center; gap: 4px;
  padding: 5px;
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(0,212,170,0.08);
}
.edit-tool {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 13px;
  border: none; border-radius: 10px;
  background: transparent; color: var(--ink-2);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.edit-tool:hover { background: rgba(0,212,170,0.08); color: var(--orenda); }
.edit-tool.active { background: rgba(0,212,170,0.16); color: var(--orenda); box-shadow: inset 0 0 0 1px var(--line); }
.edit-tool[data-tool="erase"].active { background: rgba(255,107,53,0.14); color: var(--thermal); box-shadow: inset 0 0 0 1px rgba(255,107,53,0.35); }
.edit-sep { width: 1px; height: 20px; background: var(--hairline); margin: 0 2px; }
.edit-export { color: var(--hub) !important; }
.edit-export:hover { background: rgba(255,215,0,0.1) !important; }

/* Tier pill */
.tier-pill {
  display: flex; align-items: center; gap: 2px;
  padding: 2px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--hairline);
  border-radius: 999px;
}
.tier-opt { position: relative; }
.tier-opt input { position: absolute; opacity: 0; pointer-events: none; }
.tier-opt span {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.tier-opt input:checked + span {
  background: rgba(0,212,170,0.18);
  color: var(--orenda);
  box-shadow: 0 0 0 1px var(--line), var(--glow-soft);
}

/* ─── Draw HUD ─── */
#draw-hud {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 15;
  font: 500 11px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--orenda);
  backdrop-filter: var(--glass-blur);
}
#draw-hud.hidden { display: none; }
.pill-btn {
  padding: 6px 14px;
  border: 1px solid var(--orenda);
  border-radius: 999px;
  background: var(--orenda);
  color: #001511;
  font: 700 10px/1 var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s;
}
.pill-btn:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: var(--glow-soft); }
.pill-btn.ghost { background: transparent; color: var(--orenda); }
.pill-btn.ghost:hover { background: var(--orenda-soft); }

/* ─── Info Dock ─── */
.info-dock {
  position: fixed;
  bottom: 18px; left: 330px;
  width: 320px; max-width: calc(100vw - 350px);
  padding: 16px 18px 18px;
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.05), inset 0 0 0 1px rgba(0,212,170,0.10);
  color: var(--ink);
  z-index: 10;
  opacity: 0; transform: translateY(8px);
  visibility: hidden;
  transition: all 0.25s var(--ease);
}
.info-dock[aria-hidden="false"] { opacity: 1; transform: translateY(0); visibility: visible; }
.info-dock-close {
  position: absolute; top: 8px; right: 10px;
  background: transparent; border: none;
  color: var(--muted); font-size: 20px; line-height: 1;
  cursor: pointer; padding: 4px 8px;
}
.info-dock-close:hover { color: var(--orenda); }
.info-dock h3 {
  font: 600 12px/1 var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--orenda); margin-bottom: 8px;
}
.info-dock p { font: 400 12px/1.55 var(--font-ui); color: var(--ink-2); }
.info-dock .stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.info-dock .stat-k { font: 500 9px/1 var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.info-dock .stat-v { font: 600 13px/1 var(--font-mono); color: var(--orenda); text-shadow: var(--glow-soft); }

/* ─── Toast ─── */
#toasts {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  z-index: 100;
}
.toast {
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--orenda);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.12em; text-transform: uppercase;
  box-shadow: var(--shadow-md);
  backdrop-filter: var(--glass-blur);
  animation: toast-in 0.25s var(--ease);
  white-space: nowrap;
}
.toast.out { animation: toast-out 0.25s var(--ease) forwards; }
@keyframes toast-in  { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }
@keyframes toast-out { from { opacity:1; transform: translateY(0); } to { opacity:0; transform: translateY(-8px); } }

/* ─── Popup ─── */
.maplibregl-popup-content {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  padding: 14px !important;
  box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(0,212,170,0.08) !important;
  color: var(--ink) !important;
  max-width: 240px;
  font-family: var(--font-ui) !important;
  backdrop-filter: blur(10px);
}
.maplibregl-popup-tip { border-top-color: var(--panel-solid) !important; }
.maplibregl-popup-close-button { color: var(--muted) !important; font-size: 16px !important; }
.popup-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; color: var(--orenda); }
.popup-sub { font-size: 11px; color: var(--muted); }
.popup-stat { display: flex; justify-content: space-between; font-size: 11px; padding: 3px 0; }
.popup-stat-k { color: var(--muted); }
.popup-stat-v { font-weight: 600; color: var(--orenda); }

/* Cursor */
.cursor-crosshair .maplibregl-canvas { cursor: crosshair !important; }
.cursor-not-allowed .maplibregl-canvas { cursor: not-allowed !important; }

/* Bus marker */
.bus-marker { cursor: pointer; transition: transform 0.8s ease-out, filter 0.2s; }
.bus-marker:hover { filter: brightness(1.3) drop-shadow(0 0 8px rgba(0,212,170,0.6)); z-index: 10 !important; }
.buses-hidden .bus-marker { display: none !important; }

/* Attribution */
.maplibregl-ctrl-attrib,
.maplibregl-ctrl-attrib a,
.maplibregl-ctrl-attrib-button {
  background: rgba(10, 10, 15, 0.7) !important;
  color: var(--muted) !important;
}

/* ════════════════════════════════════════════════════════
   shadcn-port components (vanilla CSS, MELA-tinted)
   1) .mela-switch  — minimal toggle (orenda / hub / thermal variants)
   2) .glass-btn    — frosted pill button (sm / default / lg / icon)
   3) .aurora-btn   — primary CTA with blurred gradient-border aurora
   ════════════════════════════════════════════════════════ */

/* ─── 1. mela-switch ─── */
.mela-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  width: 40px; height: 22px;
  cursor: pointer;
  user-select: none;
}
.mela-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 100%; height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.mela-switch-track {
  position: relative;
  display: block;
  width: 40px; height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--hairline);
  transition: background 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
}
.mela-switch-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 1px 2px rgba(0,0,0,0.45);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), background 0.25s, box-shadow 0.25s;
}
.mela-switch input:checked + .mela-switch-track .mela-switch-thumb {
  transform: translateX(18px);
}
.mela-switch input:focus-visible + .mela-switch-track {
  outline: 2px solid rgba(0, 212, 170, 0.35);
  outline-offset: 2px;
}
.mela-switch--hub input:focus-visible + .mela-switch-track {
  outline-color: rgba(255, 215, 0, 0.35);
}
.mela-switch--thermal input:focus-visible + .mela-switch-track {
  outline-color: rgba(255, 107, 53, 0.35);
}
/* Variants */
.mela-switch--orenda input:checked + .mela-switch-track {
  background: #00d4aa;
  border-color: rgba(0, 212, 170, 0.55);
  box-shadow: 0 0 8px rgba(0, 212, 170, 0.45);
}
.mela-switch--orenda input:checked + .mela-switch-track .mela-switch-thumb {
  background: #001511; box-shadow: 0 0 4px rgba(0,0,0,0.4);
}
.mela-switch--hub input:checked + .mela-switch-track {
  background: #ffd700;
  border-color: rgba(255, 215, 0, 0.55);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}
.mela-switch--hub input:checked + .mela-switch-track .mela-switch-thumb {
  background: #1a1400; box-shadow: 0 0 4px rgba(0,0,0,0.4);
}
.mela-switch--thermal input:checked + .mela-switch-track {
  background: #ff6b35;
  border-color: rgba(255, 107, 53, 0.55);
  box-shadow: 0 0 8px rgba(255, 107, 53, 0.4);
}
.mela-switch--thermal input:checked + .mela-switch-track .mela-switch-thumb {
  background: #1a0a05; box-shadow: 0 0 4px rgba(0,0,0,0.4);
}

/* ─── 2. glass-btn ─── */
.glass-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  height: 34px;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  color: #e5e7eb;
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 0 0 1px rgba(0, 212, 170, 0.06),
    0 1px 2px rgba(0,0,0,0.35),
    0 0 10px rgba(0, 212, 170, 0.08);
  transition: background 0.22s var(--ease), border-color 0.22s, box-shadow 0.22s, color 0.22s, transform 0.12s var(--ease);
}
.glass-btn::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 140% at 50% 0%, rgba(0,212,170,0.10) 0%, transparent 55%);
  pointer-events: none;
}
.glass-btn:hover {
  background: rgba(0, 212, 170, 0.06);
  border-color: rgba(0, 212, 170, 0.35);
  color: #c6f4e7;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 0 0 1px rgba(0, 212, 170, 0.12),
    0 2px 6px rgba(0,0,0,0.4),
    0 0 14px rgba(0, 212, 170, 0.14);
}
.glass-btn:active {
  transform: translateY(0.5px) scale(0.985);
}
.glass-btn:focus-visible {
  outline: 2px solid rgba(0, 212, 170, 0.35);
  outline-offset: 2px;
}
/* sizes */
.glass-btn--sm  { height: 28px; padding: 6px 12px; font-size: 10px; letter-spacing: 0.14em; }
.glass-btn--lg  { height: 42px; padding: 10px 22px; font-size: 12px; }
.glass-btn--icon{ width: 34px; height: 34px; padding: 0; }
.glass-btn--sm.glass-btn--icon  { width: 28px; height: 28px; }
.glass-btn--lg.glass-btn--icon  { width: 42px; height: 42px; }
.glass-btn svg { display: block; }

/* ─── 3. aurora-btn ─── */
.aurora-btn-wrap {
  position: relative;
  display: inline-flex;
  isolation: isolate;
}
.aurora-btn-wrap::before {
  content: '';
  position: absolute;
  inset: -3px;
  z-index: -1;
  border-radius: 999px;
  background: linear-gradient(135deg, #00d4aa 0%, #ffd700 50%, #ff6b35 100%);
  opacity: 0.55;
  filter: blur(10px);
  transition: opacity 260ms cubic-bezier(0.16, 1, 0.3, 1), filter 260ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.aurora-btn-wrap:hover::before {
  opacity: 0.85;
  filter: blur(14px);
}
.aurora-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  height: 34px;
  border: 1px solid rgba(30, 42, 60, 0.8);
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.85);
  color: #e5e7eb;
  font: 600 11px/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.12s var(--ease);
}
.aurora-btn:hover {
  color: #ffffff;
  background: rgba(10, 14, 20, 0.78);
  border-color: rgba(0, 212, 170, 0.35);
}
.aurora-btn:active { transform: translateY(0.5px) scale(0.985); }
.aurora-btn:focus-visible {
  outline: 2px solid rgba(0, 212, 170, 0.35);
  outline-offset: 2px;
}
.aurora-btn svg { display: block; }
.aurora-btn--sm { height: 28px; padding: 6px 14px; font-size: 10px; }

/* Combinators: when .edit-tool carries .glass-btn, let glass styling win */
.glass-btn.edit-tool {
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255, 255, 255, 0.03);
  color: #e5e7eb;
}
.glass-btn.edit-tool:hover {
  background: rgba(255, 255, 255, 0.055);
  color: #c6f4e7;
}
.glass-btn.edit-tool.active {
  background: rgba(0, 212, 170, 0.14);
  border-color: rgba(0, 212, 170, 0.35);
  color: var(--orenda);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 0 0 1px rgba(0, 212, 170, 0.3),
    0 0 16px rgba(0, 212, 170, 0.18);
}
.glass-btn.edit-tool[data-tool="erase"].active {
  background: rgba(255, 107, 53, 0.14);
  border-color: rgba(255, 107, 53, 0.35);
  color: var(--thermal);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 0 0 1px rgba(255, 107, 53, 0.35),
    0 0 16px rgba(255, 107, 53, 0.18);
}

/* ─── Panel collapse ─── */
#panel {
  transition: transform 0.36s var(--ease), box-shadow 0.36s var(--ease);
}
#panel.collapsed {
  transform: translateX(calc(-100% + 36px));
  box-shadow: var(--shadow-lg);
}
.panel-collapse-btn {
  position: absolute;
  top: 12px; right: 10px;
  z-index: 3;
}
.panel-collapse-btn svg {
  transition: transform 0.36s var(--ease);
}
#panel.collapsed .panel-collapse-btn {
  right: 4px;
}
#panel.collapsed .panel-collapse-btn svg {
  transform: rotate(180deg);
}
#panel.collapsed .panel-scroll {
  opacity: 0;
  pointer-events: none;
}
.panel-scroll { transition: opacity 0.22s var(--ease) 0.12s; }

/* Responsive */
@media (max-width: 860px) {
  .year-slider-wrap { padding: 0 8px; height: 30px; gap: 6px; }
  #year-slider { width: 140px; }
  .year-label { display: none; }
}
@media (max-width: 700px) {
  #panel { width: 260px; left: 8px; top: 72px; }
  .edit-tool span { display: none; }
  .edit-tool { padding: 8px; }
  .timeline-panel { width: calc(100vw - 24px); }
  .header-btn span { display: none; }
  #header { padding: 0 6px; }
  .info-dock { left: 8px; right: 8px; width: auto; bottom: 70px; }
  .tier-pill { display: none; }
}

/* ════════════════════════════════════════════════════════
   Era keyframes — three snap-to buttons next to the year slider
   Built on the .glass-btn foundation; each era gets its own tint.
   ════════════════════════════════════════════════════════ */
.era-keyframes {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--hairline);
}
.era-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px 12px;
  height: 34px;
  min-width: 70px;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 1px 2px rgba(0,0,0,0.3);
  transition: background 0.22s var(--ease), border-color 0.22s,
              box-shadow 0.22s, color 0.22s, transform 0.12s var(--ease);
}
.era-btn-year {
  font: 600 12px/1 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--ink);
}
.era-btn-name {
  font: 600 9px/1 var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.era-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255,255,255,0.14);
  color: var(--ink);
}
.era-btn:hover .era-btn-name { color: var(--ink-2); }
.era-btn:active { transform: translateY(0.5px) scale(0.985); }
.era-btn:focus-visible {
  outline: 1.5px solid rgba(0, 212, 170, 0.55);
  outline-offset: 2px;
}

/* 2053 — Hurricane Mera: thermal tint */
.era-btn--mera {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    inset 0 0 0 1px rgba(255, 107, 53, 0.10),
    0 1px 2px rgba(0,0,0,0.3);
}
.era-btn--mera:hover {
  border-color: rgba(255, 107, 53, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 0 0 1px rgba(255, 107, 53, 0.18),
    0 0 12px rgba(255, 107, 53, 0.14);
}

/* 2092 — Full network: orenda tint */
.era-btn--full {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    inset 0 0 0 1px rgba(0, 212, 170, 0.10),
    0 1px 2px rgba(0,0,0,0.3);
}
.era-btn--full:hover {
  border-color: rgba(0, 212, 170, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 0 0 1px rgba(0, 212, 170, 0.20),
    0 0 12px rgba(0, 212, 170, 0.16);
}

/* Active states — slider sits exactly on that era year */
.era-btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--ink);
}
.era-btn[aria-pressed="true"] .era-btn-name { color: var(--ink); }

.era-btn--mera[aria-pressed="true"] {
  background: rgba(255, 107, 53, 0.10);
  border-color: var(--thermal);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 0 0 1px rgba(255, 107, 53, 0.35),
    0 0 16px rgba(255, 107, 53, 0.22);
}
.era-btn--mera[aria-pressed="true"] .era-btn-year { color: var(--thermal); }
.era-btn--mera[aria-pressed="true"] .era-btn-name { color: #ffb59a; }

.era-btn--full[aria-pressed="true"] {
  background: rgba(0, 212, 170, 0.10);
  border-color: var(--orenda);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 0 0 1px rgba(0, 212, 170, 0.35),
    0 0 16px rgba(0, 212, 170, 0.22);
}
.era-btn--full[aria-pressed="true"] .era-btn-year { color: var(--orenda); }
.era-btn--full[aria-pressed="true"] .era-btn-name { color: #7ee7ce; }

@media (max-width: 780px) {
  .header-center { flex-wrap: wrap; gap: 6px; }
  .era-keyframes { order: 2; width: 100%; justify-content: center; }
  .era-btn { min-width: 0; padding: 4px 10px; height: 30px; }
  .era-btn-name { font-size: 8px; letter-spacing: 0.12em; }
}

/* ════════════════════════════════════════════════════════
   Era narrative card — liquid glass, top-left of map
   ════════════════════════════════════════════════════════ */
.era-card {
  position: fixed;
  top: 84px;
  left: 332px; /* clears the 300px panel + 12px gutters */
  width: min(320px, calc(100vw - 344px));
  padding: 16px 38px 16px 18px;
  border-radius: 14px;
  background: rgba(22, 28, 38, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 9;
  opacity: 0;
  transform: translateX(-120%);
  pointer-events: none;
  transition: opacity 0.36s var(--ease), transform 0.36s var(--ease);
}
.era-card::before {
  content: '';
  position: absolute;
  top: 0; left: 12px; right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);
  pointer-events: none;
}
.era-card.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.era-card--mera { border-color: rgba(255, 107, 53, 0.28); }
.era-card--mera .era-card-year { color: var(--thermal); text-shadow: 0 0 8px rgba(255,107,53,0.45); }
.era-card--full { border-color: rgba(0, 212, 170, 0.28); }
.era-card--full .era-card-year { color: var(--orenda); text-shadow: 0 0 8px rgba(0,212,170,0.45); }

.era-card-year {
  display: block;
  font: 700 11px/1 var(--font-mono);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 6px;
  opacity: 0.9;
}
.era-card-name {
  font: 600 18px/1.15 var(--font-ui);
  letter-spacing: 0.01em;
  color: var(--ink);
  margin-bottom: 8px;
}
.era-card-caption {
  font: 400 12px/1.55 var(--font-ui);
  color: var(--ink-2);
  letter-spacing: 0.005em;
}
.era-card-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.era-card-close:hover { background: rgba(255,255,255,0.07); color: var(--ink); }
.era-card-close:focus-visible { outline: 1.5px solid rgba(0, 212, 170, 0.55); outline-offset: 2px; }

@media (max-width: 780px) {
  .era-card {
    top: 120px;
    left: 12px;
    width: calc(100vw - 24px);
  }
}
@media (max-width: 700px) {
  #panel.collapsed ~ .era-card,
  .era-card { left: 12px; width: min(320px, calc(100vw - 24px)); }
}

/* ─── export-toolbar ───
   Floating stack of export actions, top-right of the map, sitting below the
   header. Uses the .glass-btn foundation. Shown in both view and author modes.
*/
.export-toolbar {
  position: fixed;
  top: 84px;
  right: 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}
.export-toolbar .glass-btn {
  justify-content: flex-start;
  min-width: 104px;
  gap: 8px;
}
@media (max-width: 780px) {
  .export-toolbar {
    top: auto;
    bottom: 84px;
    right: 12px;
    flex-direction: row;
  }
  .export-toolbar .glass-btn { min-width: 0; }
}

/* ─── era-export ZIP buttons ───
   Divider hairline above, then 3 tinted era buttons (neutral / thermal / orenda)
   sharing the .glass-btn--sm base. */
.export-toolbar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 0;
  border: 0;
}
.era-export-btn {
  /* inherits .glass-btn base; add a subtle inner tint per era */
}
.era-export-btn--mera {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 0 1px rgba(255, 107, 53, 0.18);
}
.era-export-btn--full {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 0 1px rgba(0, 212, 170, 0.22);
}
.era-export-btn--mera:hover { box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 0 0 1px rgba(255,107,53,0.38); }
.era-export-btn--full:hover { box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 0 0 1px rgba(0,212,170,0.44); }

/* ─── SVG re-import drop zone ───
   Full-viewport overlay, author-mode only. Liquid-glass backdrop with a
   dashed orenda border on the centered card. Hidden by default; opacity
   flipped by .is-active via js/editor.js drop handlers. */
.svg-dropzone {
  position: fixed;
  inset: 0;
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease, cubic-bezier(.4,.0,.2,1));
  background: rgba(15, 20, 25, 0.65);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.svg-dropzone.is-active {
  opacity: 1;
  pointer-events: auto;
}
.svg-dropzone-card {
  max-width: 480px;
  padding: 40px;
  border-radius: 16px;
  border: 2px dashed rgba(0, 212, 170, 0.4);
  background: rgba(15, 17, 22, 0.72);
  text-align: center;
  color: #eaeef2;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.svg-dropzone-card h3 {
  margin: 12px 0 8px;
  font-size: 18px;
  letter-spacing: 0.01em;
  font-weight: 500;
}
.svg-dropzone-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(234, 238, 242, 0.7);
}
.svg-dropzone-icon {
  font-size: 64px;
  line-height: 1;
  color: var(--orenda, #00d4aa);
  text-shadow: 0 0 24px rgba(0, 212, 170, 0.45);
  margin-bottom: 4px;
}

/* ══════════════════════════════════════════════════════════
   Node Editor + Map Customize — 2026-04-15
   Illustrator-style pen tool overlay UI.
   ══════════════════════════════════════════════════════════ */

/* 1 · Edit-bar tool button — nodes variant active tint */
.edit-tool[data-tool="nodes"].active {
  box-shadow: inset 0 0 0 1px rgba(0, 212, 170, 0.55),
              inset 0 0 18px rgba(0, 212, 170, 0.22),
              0 0 0 1px rgba(0, 212, 170, 0.18);
}

/* 2 · Floating HUD — Illustrator-style context bar above the year slider */
.node-edit-hud {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(0, 212, 170, 0.25);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: var(--ink);
  z-index: 40;
  transition: opacity 240ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
.node-edit-hud[aria-hidden="true"] {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
}
.node-edit-hud[aria-hidden="false"] {
  animation: nodeHudIn 320ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes nodeHudIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.node-edit-hud__chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orenda);
  padding: 4px 8px;
  border: 1px solid rgba(0, 212, 170, 0.28);
  border-radius: 8px;
  background: rgba(0, 212, 170, 0.08);
  transition: color 180ms, border-color 180ms, background 180ms;
}
/* Source-aware tints: MELA green (default), HSR thermal, GO hub */
.node-edit-hud[data-source="hsr"] .node-edit-hud__chip {
  color: var(--thermal);
  border-color: rgba(255, 107, 53, 0.4);
  background: rgba(255, 107, 53, 0.10);
}
.node-edit-hud[data-source="go"] .node-edit-hud__chip {
  color: var(--hub);
  border-color: rgba(255, 215, 0, 0.4);
  background: rgba(255, 215, 0, 0.10);
}
.node-edit-hud[data-source="hsr"] {
  border-color: rgba(255, 107, 53, 0.3);
}
.node-edit-hud[data-source="go"] {
  border-color: rgba(255, 215, 0, 0.28);
}
.node-edit-hud__count {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.node-edit-hud__action {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orenda);
  padding: 6px 12px;
  border: 1px solid rgba(0, 212, 170, 0.4);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1),
              background 180ms cubic-bezier(0.16, 1, 0.3, 1),
              color 180ms cubic-bezier(0.16, 1, 0.3, 1),
              border-color 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
.node-edit-hud__action:hover {
  transform: translateY(-1px);
  background: rgba(0, 212, 170, 0.14);
  border-color: rgba(0, 212, 170, 0.65);
  color: var(--orenda-2);
}
.node-edit-hud__action:active { transform: translateY(0); }
.node-edit-hud__action--danger {
  color: var(--thermal);
  border-color: rgba(255, 107, 53, 0.45);
}
.node-edit-hud__action--danger:hover {
  background: rgba(255, 107, 53, 0.14);
  border-color: rgba(255, 107, 53, 0.7);
  color: #ff8a5c;
}
.node-edit-hud__action--reset {
  color: var(--hub);
  border-color: rgba(255, 215, 0, 0.4);
}
.node-edit-hud__action--reset:hover {
  background: rgba(255, 215, 0, 0.12);
  border-color: rgba(255, 215, 0, 0.7);
  color: #ffe066;
}
.node-edit-hud__action[disabled] {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.4);
}

/* 3 · Cursor feedback for node-editor mode */
body.mode-nodes .maplibregl-canvas { cursor: crosshair; }
body.mode-nodes.handle-hover .maplibregl-canvas { cursor: grab; }
body.mode-nodes.handle-dragging .maplibregl-canvas { cursor: grabbing !important; }

/* 4 · Map customize — collapsible side-panel, top-right */
#map-customize-panel {
  position: absolute;
  top: 84px;
  right: 16px;
  z-index: 30;
}
.map-customize {
  width: 220px;
  padding: 14px;
  background: var(--panel);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(0, 212, 170, 0.22);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: var(--ink);
  overflow: hidden;
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1),
              padding 280ms cubic-bezier(0.16, 1, 0.3, 1),
              opacity 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
#btn-map-customize[aria-expanded="false"] + .map-customize,
.map-customize[aria-expanded="false"],
#map-customize-panel[aria-expanded="false"] .map-customize {
  width: 44px;
  padding: 10px;
}
#map-customize-panel[aria-expanded="false"] .map-customize__body {
  opacity: 0;
  pointer-events: none;
  max-height: 0;
  overflow: hidden;
  margin: 0;
}
.map-customize__header {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--orenda);
  margin-bottom: 10px;
}
.map-customize__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.map-customize__option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: background 200ms cubic-bezier(0.16, 1, 0.3, 1),
              border-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
              color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.map-customize__option:hover {
  background: rgba(0, 212, 170, 0.08);
  border-color: rgba(0, 212, 170, 0.28);
  color: var(--ink);
}
.map-customize__option--active {
  border: 1px solid rgba(0, 212, 170, 0.45);
  background: rgba(0, 212, 170, 0.14);
  color: var(--orenda);
}
.map-customize__footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.map-customize__recenter {
  width: 100%;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--orenda);
  background: transparent;
  border: 1px solid rgba(0, 212, 170, 0.45);
  border-radius: 10px;
  cursor: pointer;
  transition: background 200ms cubic-bezier(0.16, 1, 0.3, 1),
              color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.map-customize__recenter:hover {
  background: var(--orenda);
  color: var(--bg);
}

/* ═════════════════════════════════════════
   3D view — full-viewport canvas overlaid on map.
   Toggled by body[data-view="3d"].
   ═════════════════════════════════════════ */
#canvas-3d-main {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  display: none;
  background: var(--bg);
  pointer-events: auto;
  touch-action: none;
}
body[data-view="3d"] #canvas-3d-main { display: block; }
/* Hide map + its overlays when 3D is active, but keep header/panels live */
body[data-view="3d"] #map {
  visibility: hidden;
  pointer-events: none;
}
body[data-view="3d"] #overlay {
  display: none;
}
/* The custom-map panel relates to MapLibre — close it when entering 3D */
body[data-view="3d"] #map-customize-panel {
  pointer-events: none;
  opacity: 0.4;
}

/* ═════════════════════════════════════════
   2D / 3D view switch — pill segmented control,
   same family as .mode-switch (view/edit).
   ═════════════════════════════════════════ */
.view-switch {
  position: relative;
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 3px;
}
.view-switch-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 999px;
  cursor: pointer;
  transition: color 180ms var(--ease), background 180ms var(--ease);
}
.view-switch-btn svg {
  stroke-opacity: 0.85;
  transition: stroke-opacity 180ms var(--ease), transform 260ms var(--ease);
}
.view-switch-btn:hover {
  color: var(--orenda);
}
.view-switch-btn.is-active {
  background: rgba(0, 212, 170, 0.14);
  color: var(--orenda);
  box-shadow: inset 0 0 0 1px rgba(0, 212, 170, 0.35),
              0 0 10px rgba(0, 212, 170, 0.18);
}
.view-switch-btn.is-active svg {
  stroke-opacity: 1;
}
.view-switch-btn[data-view-mode="3d"].is-active svg {
  transform: rotate(-6deg);
}

/* Narrow header: collapse labels like other header pills do */
@media (max-width: 1180px) {
  .view-switch-btn span { display: none; }
  .view-switch-btn { padding: 5px 8px; }
}

/* ════════════════════════════════════════════════════════
   UI Friendliness polish — April 2026
   Custom tooltip, help overlay, edit-state badge, active-
   tool glow reinforcement, 3D view caption.
   Uses existing MELA tokens only. No new colors, no new fonts.
   ════════════════════════════════════════════════════════ */

/* ─── 1 · Global custom tooltip ─── */
.mela-tip {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
  padding: 6px 10px;
  max-width: 260px;
  background: rgba(12, 16, 22, 0.94);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border: 1px solid rgba(0, 212, 170, 0.32);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.3);
  color: var(--ink);
  font: 500 11px/1.4 var(--font-ui);
  letter-spacing: 0.02em;
  text-align: left;
  white-space: normal;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 140ms var(--ease), transform 140ms var(--ease);
}
.mela-tip.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.mela-tip::before {
  content: "";
  position: absolute;
  width: 6px; height: 6px;
  background: inherit;
  border-left: 1px solid rgba(0, 212, 170, 0.32);
  border-top: 1px solid rgba(0, 212, 170, 0.32);
  transform: rotate(45deg);
}
.mela-tip[data-side="top"]::before    { bottom: -4px; left: 50%; margin-left: -3px; transform: rotate(225deg); }
.mela-tip[data-side="bottom"]::before { top: -4px; left: 50%; margin-left: -3px; }
.mela-tip[data-side="left"]::before   { right: -4px; top: 50%; margin-top: -3px; transform: rotate(135deg); }
.mela-tip[data-side="right"]::before  { left: -4px; top: 50%; margin-top: -3px; transform: rotate(315deg); }
.mela-tip kbd {
  font: 600 10px/1 var(--font-mono);
  padding: 1px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: rgba(0, 212, 170, 0.08);
  color: var(--orenda);
}

/* ─── 2 · Help button (header) ─── */
.header-btn--help {
  width: 34px;
  padding: 7px 0;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
}
.header-btn--help span {
  font-size: 12px;
  letter-spacing: 0;
  color: var(--orenda);
  opacity: 0.7;
  transition: opacity 180ms var(--ease);
}
.header-btn--help:hover span { opacity: 1; }
.header-btn--help[aria-expanded="true"] {
  background: rgba(0, 212, 170, 0.18);
  color: var(--orenda);
  border-color: var(--orenda-med);
  box-shadow: var(--glow-soft);
}
@media (max-width: 1180px) {
  .header-btn--help { width: 30px; }
  .header-btn--help svg { display: none; }
}

/* ─── 3 · Help overlay ─── */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease);
}
.help-overlay[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}
.help-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(0, 212, 170, 0.08), transparent 60%),
              rgba(6, 9, 13, 0.62);
  backdrop-filter: blur(6px) saturate(1.05);
  -webkit-backdrop-filter: blur(6px) saturate(1.05);
  cursor: pointer;
}
.help-overlay__panel {
  position: relative;
  width: min(620px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg),
              inset 0 1px 0 rgba(255, 255, 255, 0.05),
              inset 0 0 0 1px rgba(0, 212, 170, 0.10),
              0 0 0 1px rgba(0, 0, 0, 0.4);
  color: var(--ink);
  transform: translateY(12px) scale(0.98);
  transition: transform 260ms var(--ease);
}
.help-overlay[aria-hidden="false"] .help-overlay__panel {
  transform: translateY(0) scale(1);
}
.help-overlay__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
}
.help-overlay__mark {
  font-size: 14px;
  color: var(--orenda);
  text-shadow: 0 0 8px rgba(0, 212, 170, 0.45);
}
.help-overlay__title {
  flex: 1;
  font: 600 14px/1.2 var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
}
.help-overlay__kbd {
  font: 600 10px/1 var(--font-mono);
  padding: 3px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: rgba(0, 212, 170, 0.08);
  color: var(--orenda);
  letter-spacing: 0.05em;
}
.help-overlay__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: all 180ms var(--ease);
}
.help-overlay__close:hover {
  color: var(--orenda);
  border-color: var(--orenda-med);
  background: rgba(0, 212, 170, 0.08);
}
.help-overlay__scroll {
  padding: 18px 22px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-soft) transparent;
}
.help-overlay__scroll::-webkit-scrollbar { width: 6px; }
.help-overlay__scroll::-webkit-scrollbar-thumb { background: var(--line-soft); border-radius: 999px; }

.help-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.help-section__title {
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--orenda);
  margin: 0;
}
.help-section--dim { opacity: 0.7; border-top: 1px solid var(--hairline); padding-top: 14px; }

.help-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
}
.help-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font: 400 13px/1.55 var(--font-ui);
  color: var(--ink-2);
}
.help-steps li strong { color: var(--ink); font-weight: 600; }
.help-steps li em { color: var(--orenda); font-style: normal; font-weight: 500; }
.help-steps__num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 212, 170, 0.1);
  color: var(--orenda);
  font: 600 11px/1 var(--font-mono);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.help-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
}
.help-legend li {
  display: flex;
  gap: 12px;
  align-items: center;
  font: 400 12px/1.4 var(--font-ui);
  color: var(--ink-2);
}
.help-legend li strong { color: var(--ink); font-weight: 600; }
.help-legend__swatch {
  flex-shrink: 0;
  width: 36px; height: 10px;
  position: relative;
  border-radius: 2px;
}
.help-legend__swatch--solid { background: var(--sw); box-shadow: 0 0 8px color-mix(in srgb, var(--sw) 55%, transparent); }
.help-legend__swatch--dashed {
  background: repeating-linear-gradient(90deg, var(--sw) 0 5px, transparent 5px 9px);
}
.help-legend__swatch--dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--sw);
  box-shadow: 0 0 8px color-mix(in srgb, var(--sw) 60%, transparent),
              inset 0 0 0 2px rgba(0,0,0,0.25);
  margin-left: 11px; margin-right: 11px;
}

.help-kbd-list {
  list-style: none;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  padding: 0;
  align-items: center;
}
.help-kbd-list li {
  display: contents;
}
.help-kbd-list li span {
  font: 400 12px/1.4 var(--font-ui);
  color: var(--ink-2);
}
.help-kbd-list li em {
  color: var(--muted);
  font-style: normal;
  margin: 0 2px;
}
.help-overlay kbd,
.help-kbd-list kbd {
  display: inline-block;
  padding: 3px 7px;
  min-width: 22px;
  text-align: center;
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--orenda);
  background: rgba(0, 212, 170, 0.08);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

.help-footnote {
  font: 400 11px/1.5 var(--font-ui);
  color: var(--muted);
  margin: 0;
}
.help-footnote a { color: var(--orenda); text-decoration: none; border-bottom: 1px dashed var(--line-soft); }
.help-footnote a:hover { color: var(--orenda-2); border-bottom-color: var(--orenda); }

@media (max-width: 700px) {
  .help-overlay__panel { width: calc(100vw - 16px); max-height: 88vh; }
  .help-overlay__head { padding: 12px 14px; }
  .help-overlay__scroll { padding: 14px 16px 18px; gap: 16px; }
}

/* ─── 4 · Edit-state badge (hovers over top-left map area) ─── */
.edit-badge {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translate(-50%, -4px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(0, 212, 170, 0.08);
  z-index: 25;
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.edit-badge[aria-hidden="false"] {
  opacity: 1;
  transform: translate(-50%, 0);
}
.edit-badge__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--orenda);
  box-shadow: 0 0 8px var(--orenda);
  animation: edit-badge-pulse 1.6s ease-in-out infinite;
}
.edit-badge__label { color: var(--muted); }
.edit-badge__name { color: var(--orenda); font-weight: 600; letter-spacing: 0.1em; }
.edit-badge__count { color: var(--ink-2); font-size: 9px; letter-spacing: 0.1em; }
.edit-badge[data-source="hsr"] { border-color: rgba(255, 107, 53, 0.35); }
.edit-badge[data-source="hsr"] .edit-badge__dot { background: var(--thermal); box-shadow: 0 0 8px var(--thermal); }
.edit-badge[data-source="hsr"] .edit-badge__name { color: var(--thermal); }
.edit-badge[data-source="go"] { border-color: rgba(255, 215, 0, 0.32); }
.edit-badge[data-source="go"] .edit-badge__dot { background: var(--hub); box-shadow: 0 0 8px var(--hub); }
.edit-badge[data-source="go"] .edit-badge__name { color: var(--hub); }
@keyframes edit-badge-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.82); }
}

/* Collapse to just the dot + name on narrow screens */
@media (max-width: 900px) {
  .edit-badge__label { display: none; }
  .edit-badge__count { display: none; }
}

/* ─── 5 · Reinforce active-tool glow ─── */
.edit-tool.active,
.glass-btn.edit-tool.active {
  background: rgba(0, 212, 170, 0.22);
  color: var(--orenda);
  box-shadow: inset 0 0 0 1px var(--orenda-med),
              0 0 0 1px rgba(0, 212, 170, 0.18),
              0 0 14px rgba(0, 212, 170, 0.28);
}
.edit-tool[data-tool="erase"].active,
.glass-btn.edit-tool[data-tool="erase"].active {
  background: rgba(255, 107, 53, 0.2);
  color: var(--thermal);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 53, 0.5),
              0 0 12px rgba(255, 107, 53, 0.28);
}

/* When node-editor is active, subtly glow the MapLibre canvas cursor area
   to remind user that lines are clickable. Cursor already handled by
   .mode-nodes / .handle-hover / .handle-dragging above. */
body.mode-nodes #edit-bar .edit-tool[data-tool="nodes"] {
  animation: edit-tool-breathe 2.4s ease-in-out infinite;
}
@keyframes edit-tool-breathe {
  0%, 100% { box-shadow: inset 0 0 0 1px var(--orenda-med),
                         0 0 0 1px rgba(0, 212, 170, 0.18),
                         0 0 14px rgba(0, 212, 170, 0.28); }
  50%      { box-shadow: inset 0 0 0 1px var(--orenda-med),
                         0 0 0 1px rgba(0, 212, 170, 0.28),
                         0 0 22px rgba(0, 212, 170, 0.45); }
}

/* ─── 6 · 3D view caption (overlay in corner when 3D is active) ─── */
.view-caption {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  background: var(--panel);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms var(--ease), transform 240ms var(--ease);
  transform: translateY(4px);
}
body[data-view="3d"] .view-caption {
  opacity: 1;
  transform: translateY(0);
}
.view-caption__pre { color: var(--orenda); font-weight: 600; }
.view-caption__sep { color: var(--muted-2); }
.view-caption__body strong { color: var(--orenda); font-weight: 600; margin-left: 2px; }
@media (max-width: 900px) {
  .view-caption { bottom: 14px; left: 10px; padding: 6px 10px; font-size: 9px; }
  .view-caption__pre, .view-caption__sep { display: none; }
}

/* When 3D is active, hide the edit-bar (editing is 2D only) — the toast
   already nudges the user. */
body[data-view="3d"] #edit-bar,
body[data-view="3d"] .edit-badge,
body[data-view="3d"] .node-edit-hud {
  opacity: 0;
  pointer-events: none;
}

/* ─── 7 · Narrow-screen header tightening ─── */
@media (max-width: 1060px) {
  .header-btn { padding: 7px 10px; }
  .header-btn span { display: none; }
  .header-btn--crosslink span { display: inline; }  /* keep the "2092" text */
}
@media (max-width: 900px) {
  .site-nav { display: none; }
  .era-keyframes { display: none; }
}

/* ─── 8 · Nudge the node-edit HUD down when the edit-bar is visible so
   they don't fight for the bottom strip. ─── */
body.author-mode .node-edit-hud { bottom: 78px; }

/* ─── 9 · iPad portrait 768 to 900px — narrower panel, map keeps aspect ─── */
@media (min-width: 768px) and (max-width: 900px) {
  #panel { width: 260px; max-height: calc(100vh - 94px); top: 72px; left: 10px; }
  .panel-scroll { padding: 12px; }
  .timeline-panel { width: 340px; max-height: calc(100vh - 24px); }
  .timeline-panel.open { right: 10px; }
  .header-center { flex-wrap: wrap; gap: 6px; justify-content: center; }
  .era-keyframes { order: 2; width: 100%; justify-content: center; gap: 4px; }
  .era-btn { min-width: 0; padding: 4px 8px; height: 32px; min-height: 32px; }
  .year-slider-wrap { padding: 0 6px; height: 30px; gap: 6px; }
  #year-slider { width: 160px; }
  .year-label { font-size: 10px; }
  .header-btn { padding: 8px 10px; min-height: 40px; min-width: 40px; }
  .edit-tool { padding: 8px 10px; min-height: 44px; min-width: 44px; }
}

/* ─── 10 · Phone 480 and below — panel collapses into bottom sheet ─── */
@media (max-width: 480px) {
  #panel {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%;
    max-height: 48vh;
    border-radius: 16px 16px 0 0;
    border-left: none; border-right: none; border-bottom: none;
  }
  .panel-scroll { padding: 12px 14px 20px; }
  #panel.collapsed { max-height: 56px; }
  .timeline-panel {
    top: auto; bottom: -90vh; right: 0; left: 0;
    width: 100%; max-height: 80vh;
    border-radius: 16px 16px 0 0;
    transition: bottom 0.4s var(--ease);
  }
  .timeline-panel.open { bottom: 0; right: 0; }
  /* Header tightens: collapse site-nav, keep primary controls */
  #header { padding: 0 10px; gap: 6px; }
  .header-left, .header-center, .header-right { gap: 6px; }
  .site-nav { display: none; }
  .era-keyframes { display: none; }
  .year-slider-wrap { padding: 0 4px; height: 30px; gap: 4px; flex: 1; }
  #year-slider { width: 100%; min-width: 0; flex: 1; }
  .year-label { display: none; }
  .brand-name { font-size: 12px; letter-spacing: 0.02em; }
  .header-btn { padding: 8px; min-height: 44px; min-width: 44px; }
  .header-btn span { display: none; }
  .edit-tool { padding: 10px; min-height: 44px; min-width: 44px; }
  .edit-tool span { display: none; }
  /* Map: full width, taller aspect so the city is readable */
  #map { width: 100vw; height: 100vh; }
}

/* ─── 11 · Phone 375 and below — tighten further ─── */
@media (max-width: 380px) {
  #panel { max-height: 46vh; }
  .brand-name { font-size: 11px; }
  .header-btn { padding: 7px; min-height: 44px; min-width: 40px; }
  .year-slider-wrap { gap: 2px; }
  #year-display { font-size: 11px; }
}
