:root {
  --primary: #03a9f4;
  --primary-dark: #0277bd;
  --primary-light: #b3e5fc;
  --primary-rgb: 3, 169, 244;
  --secondary: #00bcd4;
  --secondary-hover: #00acc1;
  --on-primary: #fff;
  --bg: #fafafa;
  --paper: #fff;
  --text: rgba(0, 0, 0, 0.87);
  --text-secondary: rgba(0, 0, 0, 0.6);
  --text-disabled: rgba(0, 0, 0, 0.26);
  --disabled-bg: rgba(0, 0, 0, 0.12);
  --divider: rgba(0, 0, 0, 0.12);
  --hover: rgba(0, 0, 0, 0.04);
  --selected: rgba(var(--primary-rgb), 0.08);
  --scrollbar: #ccc;
  --backdrop: rgba(0, 0, 0, 0.5);
  --tooltip-bg: #fff;
  --tooltip-text: #333;
  --tooltip-border: #eee;
  --alert-info-bg: #e5f6fd;  --alert-info-fg: #014361;  --alert-info-icon: #03a9f4;
  --alert-success-bg: #edf7ed; --alert-success-fg: #1e4620; --alert-success-icon: #2e7d32;
  --alert-error-bg: #fdeded; --alert-error-fg: #5f2120; --alert-error-icon: #d32f2f;
  --error: #d32f2f;
  --font: "Maven Pro", sans-serif;
  --shadow-rgb: 80, 80, 80;
  --shadow-1: 0px 1px 3px 0px rgba(var(--shadow-rgb),0.2), 0px 1px 1px 0px rgba(var(--shadow-rgb),0.14), 0px 2px 1px -1px rgba(var(--shadow-rgb),0.12);
  --shadow-2: 0px 1px 5px 0px rgba(var(--shadow-rgb),0.2), 0px 2px 2px 0px rgba(var(--shadow-rgb),0.14), 0px 3px 1px -2px rgba(var(--shadow-rgb),0.12);
  --shadow-3: 0px 1px 8px 0px rgba(var(--shadow-rgb),0.2), 0px 3px 4px 0px rgba(var(--shadow-rgb),0.14), 0px 3px 3px -2px rgba(var(--shadow-rgb),0.12);
  --shadow-6: 0px 3px 5px -1px rgba(var(--shadow-rgb),0.2), 0px 6px 10px 0px rgba(var(--shadow-rgb),0.14), 0px 1px 18px 0px rgba(var(--shadow-rgb),0.12);
  --shadow-24: 0px 11px 15px -7px rgba(var(--shadow-rgb),0.2), 0px 24px 38px 3px rgba(var(--shadow-rgb),0.14), 0px 9px 46px 8px rgba(var(--shadow-rgb),0.12);
  --sidebar-w: 300px;
  --header-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --primary: #29b6f6;
  --primary-dark: #0288d1;
  --primary-light: #4fc3f7;
  --primary-rgb: 41, 182, 246;
  --secondary: #26c6da;
  --secondary-hover: #00bcd4;
  --bg: #303030;
  --paper: #424242;
  --text: rgba(255, 255, 255, 0.87);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-disabled: rgba(255, 255, 255, 0.3);
  --disabled-bg: rgba(255, 255, 255, 0.12);
  --divider: rgba(255, 255, 255, 0.12);
  --hover: rgba(255, 255, 255, 0.08);
  --selected: rgba(var(--primary-rgb), 0.16);
  --scrollbar: #666;
  --backdrop: rgba(0, 0, 0, 0.7);
  --tooltip-bg: #424242;
  --tooltip-text: rgba(255, 255, 255, 0.87);
  --tooltip-border: rgba(255, 255, 255, 0.12);
  --alert-info-bg: #071318;  --alert-info-fg: #b8e7fb;  --alert-info-icon: #29b6f6;
  --alert-success-bg: #0c130d; --alert-success-fg: #cce8cd; --alert-success-icon: #66bb6a;
  --alert-error-bg: #160b0b; --alert-error-fg: #f4c7c7; --alert-error-icon: #f44336;
  --error: #f44336;
  --shadow-rgb: 0, 0, 0;
  color-scheme: dark;
}

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

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background-color: var(--scrollbar); border-radius: 4px; }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.icon { width: 1em; height: 1em; font-size: 1.5rem; fill: currentColor; flex-shrink: 0; display: block; }

/* ---------- Buttons (MUI contained / text) ---------- */
.btn {
  font-family: inherit;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.75;
  letter-spacing: 0.02857em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 0;
  border-radius: 4px;
  padding: 6px 16px;
  min-width: 64px;
  min-height: 36px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--primary);
  background: transparent;
  text-decoration: none;
  transition: background-color 250ms, box-shadow 250ms;
  -webkit-tap-highlight-color: transparent;
}
.btn .icon, .btn .btn-icon-slot { font-size: 1.25rem; }
.btn .btn-icon-slot { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; }
.btn .btn-icon-slot .icon { font-size: inherit; }
.btn:hover { background: rgba(var(--primary-rgb), 0.08); }
.btn:disabled { cursor: default; pointer-events: none; }
.btn-contained { color: var(--on-primary); background: var(--primary); box-shadow: var(--shadow-2); }
.btn-contained:hover { background: var(--primary-dark); box-shadow: var(--shadow-6); }
.btn-contained:disabled { color: var(--text-disabled); background: var(--disabled-bg); box-shadow: none; }
.btn-text-secondary { color: var(--secondary); }
.btn-text-secondary:hover { background: rgba(0, 188, 212, 0.08); }
.btn-text-muted { color: var(--text-secondary); }
.btn-text-muted:hover { background: var(--hover); }
.btn-small { padding: 4px 10px; font-size: 0.8125rem; min-height: 30px; }

.icon-btn {
  border: 0; background: transparent; color: var(--text-secondary); cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; flex-shrink: 0; -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn .icon { font-size: 1.5rem; }

.fab {
  width: 36px; height: 36px; min-width: 36px; border-radius: 50%; border: 0; cursor: pointer; padding: 0;
  background: var(--secondary); color: var(--on-primary);
  box-shadow: var(--shadow-6);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { background: var(--secondary-hover); }
.fab .icon { font-size: 1.375rem; }

/* theme toggle: show the icon for the *other* mode */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Spinner (CircularProgress) ---------- */
.spinner { width: 40px; height: 40px; color: var(--primary); animation: spin 1.4s linear infinite; display: block; }
.spinner circle {
  fill: none; stroke: currentColor; stroke-width: 3.6; stroke-linecap: round;
  stroke-dasharray: 80px, 200px; stroke-dashoffset: 0;
  animation: dash 1.4s ease-in-out infinite;
}
.spinner-sm { width: 24px; height: 24px; }
.spinner-xs { width: 1em; height: 1em; color: inherit; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dash {
  0% { stroke-dasharray: 1px, 200px; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 100px, 200px; stroke-dashoffset: -15px; }
  100% { stroke-dasharray: 100px, 200px; stroke-dashoffset: -125px; }
}

/* ---------- Header (full mode) ---------- */
.header {
  height: var(--header-h); width: 100%; background: var(--paper);
  box-shadow: var(--shadow-2); z-index: 10; flex-shrink: 0; position: relative;
}
.header-content { display: flex; justify-content: space-between; align-items: center; height: 100%; padding: 0 16px; gap: 16px; }
.logo-container { display: flex; align-items: center; height: 100%; min-width: 0; }
.logo { max-height: 40px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.logo.logo-hidden { position: absolute; opacity: 0; pointer-events: none; }
.logo-3d { position: relative; height: 56px; width: 250px; max-width: 100%; display: none; margin: 0 -14px; }
.logo-3d.ready { display: block; }
.logo-canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
:root[data-theme="dark"] .logo { filter: drop-shadow(0 0 1px rgba(255,255,255,0.6)); }
.header-controls { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* ---------- Map area ---------- */
.map-container { position: relative; display: flex; flex-grow: 1; overflow: hidden; min-height: 0; }
.map-wrapper { position: relative; width: 100%; height: 100%; }
#map { width: 100%; height: 100%; background: var(--bg); }
.map-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 16px;
  font-size: 0.875rem; color: var(--text-secondary); padding: 16px; text-align: center;
}
.map-status.error { color: var(--error); font-size: 1rem; }

/* floating controls (embed mode) */
.float-controls {
  position: absolute; top: 16px; left: 16px; z-index: 2; display: flex; align-items: center; gap: 8px;
  transition: left 0.3s ease-in-out;
}
body.sidebar-open .float-controls { left: calc(var(--sidebar-w) + 16px); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: absolute; top: 0; left: 0; z-index: 3; width: var(--sidebar-w); height: 100%;
  background: var(--paper); box-shadow: var(--shadow-3); overflow: hidden;
  transform: translateX(-100%);
  transition: transform 0.3s ease-in-out;
  display: flex; flex-direction: column;
}
body.sidebar-open .sidebar { transform: translateX(0); }
.brand-header {
  background: var(--primary); color: var(--on-primary); padding: 16px; flex-shrink: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.brand-header h2 { margin: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.6; letter-spacing: 0.0075em; }
.brand-header p { margin: 0; font-size: 0.875rem; font-weight: 700; line-height: 1.57; letter-spacing: 0.00714em; }
.sidebar-close { color: var(--on-primary); margin: -6px -8px 0 0; display: none; }
.sidebar-close:hover { background: rgba(255,255,255,0.15); }

.search-container { padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--divider); flex-shrink: 0; }
.search-input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--text); padding: 6px 0; min-width: 0;
}
.search-input::placeholder { color: var(--text-secondary); opacity: 1; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-container .icon-btn { pointer-events: none; }

.linear-progress { position: relative; height: 4px; width: 100%; overflow: hidden; background: rgba(var(--primary-rgb), 0.3); flex-shrink: 0; }
.linear-progress::before, .linear-progress::after {
  content: ""; position: absolute; top: 0; left: 0; bottom: 0; background: var(--primary);
}
.linear-progress::before { animation: lp1 2.1s cubic-bezier(0.65,0.815,0.735,0.395) infinite; }
.linear-progress::after { animation: lp2 2.1s cubic-bezier(0.165,0.84,0.44,1) 1.15s infinite; }
@keyframes lp1 { 0% { left: -35%; right: 100%; } 60%, 100% { left: 100%; right: -90%; } }
@keyframes lp2 { 0% { left: -200%; right: 100%; } 60%, 100% { left: 107%; right: -8%; } }

.list-container { overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.outlet-list { list-style: none; margin: 0; padding: 8px 0; }
.outlet-list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 16px; cursor: pointer; border-bottom: 1px solid var(--divider);
  transition: background-color 150ms; -webkit-tap-highlight-color: transparent;
}
.outlet-list-item > div { min-width: 0; }
.outlet-list-item:hover { background: var(--hover); }
.outlet-list-item.selected { background: var(--selected); }
.outlet-list-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.outlet-list-item .primary { font-size: 1rem; line-height: 1.5; letter-spacing: 0.00938em; margin: 4px 0 0; overflow-wrap: anywhere; }
.outlet-list-item .secondary { font-size: 0.875rem; line-height: 1.43; letter-spacing: 0.01071em; color: var(--text-secondary); margin: 0 0 4px; }
.outlet-list-item .secondary .distance { color: var(--primary); display: block; }
.outlet-list-item .secondary .wa { display: block; }
.outlet-list-item .icon { color: var(--secondary); }
.empty-state { padding: 24px 16px; text-align: center; color: var(--text-secondary); font-size: 0.875rem; }

/* ---------- InfoWindow card ---------- */
.info-window { width: 280px; max-width: 100%; font-family: var(--font); color: var(--text); }
.hero-wrap { position: relative; border-radius: 6px; overflow: hidden; aspect-ratio: 2 / 1; background: var(--bg); }
.hero { display: block; width: 100%; height: 100%; }
.hero .sky-top { stop-color: #dcecf7; } .hero .sky-bottom { stop-color: #f5f8fa; }
.hero .shed { fill: #c7d1d9; } .hero .shed-roof { fill: #8e9aa4; } .hero .shed-door { fill: #6b7a86; } .hero .shed-stripes { fill: #58666f; }
.hero .rail { fill: #55636d; } .hero .ground { fill: #b0bcc6; } .hero .coil-core { fill: #e8edf0; }
:root[data-theme="dark"] .hero .sky-top { stop-color: #1d2a38; } :root[data-theme="dark"] .hero .sky-bottom { stop-color: #2b3744; }
:root[data-theme="dark"] .hero .shed { fill: #4d5a66; } :root[data-theme="dark"] .hero .shed-roof { fill: #6b7883; }
:root[data-theme="dark"] .hero .shed-door { fill: #3b4752; } :root[data-theme="dark"] .hero .shed-stripes { fill: #2d3741; }
:root[data-theme="dark"] .hero .ground { fill: #3a4650; } :root[data-theme="dark"] .hero .coil-core { fill: #263038; }
.hero .hook { animation: hero-hook 6s ease-in-out infinite; }
.hero .coil { animation: hero-coil 10s linear infinite; transform-box: view-box; transform-origin: 238px 92px; }
.hero .shine { animation: hero-shine 3.5s ease-in-out infinite; }
.hero .spark { opacity: 0; animation: hero-spark 1.6s ease-out infinite; }
.hero .s2 { animation-delay: .4s; } .hero .s3 { animation-delay: .9s; }
@keyframes hero-hook { 0%, 100% { transform: translate(84px, 74px); } 50% { transform: translate(176px, 74px); } }
@keyframes hero-coil { to { transform: rotate(360deg); } }
@keyframes hero-shine { 0% { transform: translateX(20px); } 100% { transform: translateX(60px); } }
@keyframes hero-spark { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-6px, -14px) scale(1); } }
@media (prefers-reduced-motion: reduce) { .hero .hook, .hero .coil, .hero .shine, .hero .spark { animation: none; } .hero .spark { opacity: .8; } }

.chip {
  position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 8px 2px 4px; border-radius: 16px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em;
  background: rgba(255,255,255,0.92); color: var(--primary-dark); box-shadow: var(--shadow-1);
}
:root[data-theme="dark"] .chip { background: rgba(33,43,54,0.9); color: var(--primary-light); }
.chip-icon { font-size: 1rem; }

.card-body { padding: 10px 2px 2px; }
.info-window h2 { margin: 0 0 4px; font-size: 1.0625rem; font-weight: 700; line-height: 1.35; letter-spacing: 0.005em; overflow-wrap: anywhere; }
.info-window .address { margin: 0 0 8px; font-size: 0.875rem; line-height: 1.43; color: var(--text-secondary); }
.meta { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.meta li { display: flex; align-items: center; gap: 8px; font-size: 0.8125rem; line-height: 1.4; color: var(--text-secondary); min-width: 0; }
.meta li span, .meta li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta li a { color: inherit; text-decoration: none; }
.meta li a:hover { color: var(--primary); text-decoration: underline; }
.meta-icon { font-size: 1.125rem; color: var(--primary); flex-shrink: 0; }
.info-window .actions { display: flex; gap: 8px; }
.info-window .action-btn {
  flex: 1; min-width: 0; min-height: 40px; padding: 6px 10px; color: #fff; gap: 6px; text-transform: none;
  font-size: 0.8125rem; font-weight: 700; box-shadow: none; border-radius: 8px;
}
.info-window .action-btn .icon { font-size: 1.125rem; }
.info-window .action-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-window .action-wa { background: #25d366; }
.info-window .action-wa:hover { background: #1ebe5b; }
.info-window .action-map { background: var(--primary); }
.info-window .action-map:hover { background: var(--primary-dark); }
.gm-style .gm-style-iw-c { padding: 10px !important; border-radius: 12px !important; background: var(--paper) !important; box-shadow: var(--shadow-6) !important; max-width: 320px !important; }
.gm-style .gm-style-iw-d { overflow: hidden !important; max-width: none !important; }
.gm-style .gm-style-iw-tc::after { background: var(--paper) !important; }
.gm-style .gm-ui-hover-effect { top: 2px !important; right: 2px !important; width: 32px !important; height: 32px !important; border-radius: 50%; background: var(--paper) !important; opacity: .9 !important; }
.gm-style .gm-ui-hover-effect > span { background-color: var(--text-secondary) !important; margin: 0 !important; width: 20px !important; height: 20px !important; }

/* ---------- Pulse highlights on the map for the compass' nearest outlets ---------- */
.pulse-layer { position: absolute; left: 0; top: 0; }
.pulse { position: absolute; left: 0; top: 0; width: 0; height: 0; cursor: pointer; }
.pulse-ring {
  position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%;
  border: 4px solid var(--c); box-sizing: border-box; opacity: 0; pointer-events: none;
  background: color-mix(in srgb, var(--c) 28%, transparent);
  box-shadow: 0 0 12px 2px color-mix(in srgb, var(--c) 55%, transparent);
  animation: pulse-ring 1.8s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}
.pulse-ring-2 { animation-delay: 0.9s; }
.pulse-core {
  position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid var(--c); box-sizing: border-box; pointer-events: none; opacity: 0.95;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent), 0 0 10px color-mix(in srgb, var(--c) 60%, transparent);
  animation: pulse-core 1.8s ease-in-out infinite;
}
.pulse-badge {
  position: absolute; left: 12px; top: -34px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--c); color: #fff; font-size: 0.8125rem; font-weight: 700; line-height: 24px; text-align: center;
  box-shadow: 0 0 0 2.5px #fff, 0 2px 6px rgba(0,0,0,0.35);
  animation: pulse-badge 1.6s ease-in-out infinite;
}
@keyframes pulse-ring { 0% { transform: scale(0.5); opacity: 1; } 60% { opacity: 0.45; } 100% { transform: scale(2.1); opacity: 0; } }
@keyframes pulse-core { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes pulse-badge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .pulse-ring { animation: none; opacity: 0.6; transform: scale(0.8); } .pulse-core, .pulse-badge { animation: none; } }

/* ---------- Map-centre reference pin (shown while the compass uses the map centre) ---------- */
.center-pin {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  opacity: 0; transition: opacity 0.2s;
}
body.ref-map .center-pin { opacity: 1; }
.center-pin-icon { width: 48px; height: 48px; fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35)); }
.center-pin-icon .dot { fill: var(--primary); stroke: none; }
.center-pin-label {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--paper); color: var(--primary); padding: 2px 8px; border-radius: 10px; box-shadow: var(--shadow-1);
}

/* ---------- Showcase pane (three.js, desktop) ---------- */
.showcase {
  position: absolute; top: 16px; right: 16px; z-index: 2; width: 280px;
  background: var(--paper); color: var(--text); border-radius: 12px; box-shadow: var(--shadow-6);
  overflow: hidden; transition: opacity 0.25s, transform 0.25s;
  display: none;
}
@media (min-width: 1024px) { .showcase { display: block; } }
body.card-open .showcase { opacity: 0; transform: translateY(-6px); pointer-events: none; }
.showcase-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 6px 8px 14px; border-bottom: 1px solid var(--divider); }
.showcase-kicker { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }
.showcase-toggle .icon { transition: transform 0.25s; }
.showcase.collapsed .showcase-toggle .icon { transform: rotate(180deg); }
.showcase.collapsed .showcase-head { border-bottom: 0; }
.showcase.collapsed .showcase-body { display: none; }
.showcase-stage {
  position: relative; height: 210px; cursor: grab; touch-action: none; user-select: none;
  background: radial-gradient(120% 90% at 50% 110%, #c9d3dc 0%, #e9eef2 55%, #f7f9fb 100%);
}
.showcase-stage:active { cursor: grabbing; }
:root[data-theme="dark"] .showcase-stage { background: radial-gradient(120% 90% at 50% 110%, #2a3540 0%, #1f2932 55%, #1a222a 100%); }
.showcase-canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.showcase-caption { padding: 12px 14px 4px; min-height: 74px; }
.showcase-title { margin: 0 0 2px; font-size: 1.0625rem; font-weight: 700; line-height: 1.3; }
.showcase-desc { margin: 0; font-size: 0.8125rem; line-height: 1.45; color: var(--text-secondary); }
.showcase-nav { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 8px; }
.showcase-dots { display: flex; gap: 6px; }
.showcase-dot { width: 8px; height: 8px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: var(--divider); transition: background 0.2s, transform 0.2s; }
.showcase-dot.active { background: var(--primary); transform: scale(1.25); }

/* ---------- Compass widget (three.js) ---------- */
.compass {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2;
  width: min(480px, calc(100vw - 32px));
  background: var(--paper); color: var(--text); border-radius: 14px; box-shadow: var(--shadow-6);
  padding: 12px 14px 12px 12px;
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 1fr auto auto;
  grid-template-areas: "dial mode" "dial list" "dial back" "dial enable";
  column-gap: 14px; row-gap: 8px; align-items: center;
  transition: opacity 0.25s;
}
body.card-open .compass { opacity: 0; pointer-events: none; }
.compass-toggle {
  grid-area: mode; justify-self: end; align-self: center; z-index: 1;
  width: 34px; height: 34px; background: var(--hover); color: var(--text-secondary);
  margin: -4px 0 -4px 12px;
}
.compass-toggle:hover { background: var(--divider); color: var(--text); }
.compass-toggle .icon { transition: transform 0.25s; }
.compass-restore { display: none; width: 48px; height: 48px; min-width: 48px; background: var(--paper); color: var(--primary); }
.compass-restore:hover { background: var(--hover); }
.compass-restore .icon { font-size: 1.625rem; }
.compass.collapsed { display: block; width: auto; padding: 0; background: transparent; box-shadow: none; border-radius: 50%; }
.compass.collapsed > :not(.compass-restore) { display: none; }
.compass.collapsed .compass-restore { display: inline-flex; }
.compass-stage { grid-area: dial; position: relative; width: 170px; height: 170px; align-self: center; }
.compass-canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.compass-list { grid-area: list; list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; align-self: start; }
.compass-list li + li { border-top: 1px solid var(--divider); }
.compass-list button {
  width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--text);
  font: inherit; padding: 5px 2px 5px 4px; border-radius: 8px; cursor: pointer; text-align: left; min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.compass-list button:hover { background: var(--hover); }
.compass-list button[aria-current="true"] { background: var(--selected); }
.compass-list button .icon:last-child { color: var(--text-secondary); font-size: 1.25rem; flex-shrink: 0; opacity: 0.7; }
.compass-rank {
  width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff; font-size: 0.8125rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent);
}
.compass-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.compass-name { font-size: 0.9375rem; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.compass-sub { display: flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--text-secondary); line-height: 1.3; }
.compass-km { color: var(--c); font-weight: 700; }
.compass-dot { opacity: 0.5; }
.compass-dir { display: inline-flex; align-items: center; gap: 2px; }
.compass-dir .icon { font-size: 0.9375rem; transform: rotate(calc(var(--a) - 90deg)); color: var(--text-secondary); }
.compass-mode { grid-area: mode; align-self: center; margin: 0 46px 0 4px; padding: 6px 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); }
.compass.mode-map .compass-mode { color: var(--primary); }
.compass-back { grid-area: back; width: 100%; margin-top: 2px; text-transform: none; font-weight: 700; border-radius: 8px; box-shadow: none; }
.compass-enable { grid-area: enable; margin-top: 2px; justify-self: start; }
.compass.has-heading .compass-enable { display: none; }

/* ---------- Dialog ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 1300; display: flex; align-items: center; justify-content: center;
  background: var(--backdrop); padding: 24px;
}
.dialog {
  background: var(--paper); border-radius: 4px; box-shadow: var(--shadow-24);
  width: 100%; max-width: 444px; display: flex; flex-direction: column; color: var(--text);
}
.dialog-title {
  position: relative; margin: 0 0 32px; padding: 16px 24px;
  font-size: 1.25rem; font-weight: 500; line-height: 1.6; letter-spacing: 0.0075em; color: var(--primary-dark);
}
:root[data-theme="dark"] .dialog-title { color: var(--primary-light); }
.dialog-title::after {
  content: ""; position: absolute; width: 60px; height: 4px; background: var(--primary); bottom: 0; left: 26px;
}
.dialog-content { padding: 0 24px 20px; color: var(--text-secondary); font-size: 1rem; line-height: 1.5; }
.dialog-content p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; padding: 8px; min-height: 52px; }
.dialog-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Snackbar / Alert ---------- */
.snackbar {
  position: fixed; left: 24px; bottom: 24px; z-index: 1400;
  transform: translateY(150%); opacity: 0; transition: transform 225ms cubic-bezier(0,0,0.2,1), opacity 225ms;
  pointer-events: none;
}
.snackbar.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.alert {
  display: flex; align-items: center; gap: 12px; padding: 6px 16px; border-radius: 4px; box-shadow: var(--shadow-6);
  font-size: 0.875rem; line-height: 1.43; letter-spacing: 0.01071em; font-weight: 500; min-width: 288px; max-width: calc(100vw - 48px);
}
.alert .alert-icon { font-size: 1.375rem; opacity: 0.9; }
.alert .alert-msg { flex: 1; padding: 8px 0; }
.alert .icon-btn { color: inherit; width: 28px; height: 28px; margin-right: -8px; }
.alert .icon-btn:hover { background: rgba(127,127,127,0.15); }
.alert .icon-btn .icon { font-size: 1.25rem; }
.alert-info { color: var(--alert-info-fg); background: var(--alert-info-bg); }
.alert-info .alert-icon { color: var(--alert-info-icon); }
.alert-success { color: var(--alert-success-fg); background: var(--alert-success-bg); }
.alert-success .alert-icon { color: var(--alert-success-icon); }
.alert-error { color: var(--alert-error-fg); background: var(--alert-error-bg); }
.alert-error .alert-icon { color: var(--alert-error-icon); }

/* ---------- Tour ---------- */
.tour-overlay { position: fixed; inset: 0; z-index: 10000; }
.tour-spotlight {
  position: fixed; z-index: 10001; border-radius: 4px; pointer-events: none;
  box-shadow: 0 0 0 9999px var(--backdrop);
  transition: top 0.25s, left 0.25s, width 0.25s, height 0.25s;
}
.tour-tooltip {
  position: fixed; z-index: 10002; background: var(--tooltip-bg); border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2); color: var(--tooltip-text); padding: 16px;
  width: 350px; max-width: calc(100vw - 32px); font-size: 14px; text-align: left;
}
.tour-tooltip::before {
  content: ""; position: absolute; width: 0; height: 0; border: 8px solid transparent;
}
.tour-tooltip[data-placement="bottom"]::before { top: -16px; left: var(--arrow-x, 50%); margin-left: -8px; border-bottom-color: var(--tooltip-bg); }
.tour-tooltip[data-placement="right"]::before { left: -16px; top: 20px; border-right-color: var(--tooltip-bg); }
.tour-tooltip[data-placement="top"]::before { bottom: -16px; left: var(--arrow-x, 50%); margin-left: -8px; border-top-color: var(--tooltip-bg); }
.tour-content { margin-bottom: 16px; font-size: 1rem; line-height: 1.5; }
.tour-progress { margin-bottom: 12px; font-size: 0.75rem; line-height: 1.66; letter-spacing: 0.03333em; color: var(--text-secondary); }
.tour-footer { display: flex; flex-direction: column; border-top: 1px solid var(--tooltip-border); padding-top: 8px; }
.tour-buttons { display: flex; justify-content: space-between; margin-bottom: 8px; }
.tour-buttons > div { display: flex; gap: 8px; }
.tour-dismiss { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text-secondary); cursor: pointer; user-select: none; }
.tour-dismiss input { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
  :root { --sidebar-w: min(320px, 85vw); --header-h: 56px; }
  .header-content { padding: 0 8px 0 12px; gap: 8px; }
  .logo { max-height: 32px; }
  .logo-3d { height: 48px; width: 190px; margin: 0 -10px; }
  .header-controls { gap: 8px; }
  .header-controls .btn-label { display: none; }
  .header-controls .btn { min-width: 40px; width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; gap: 0; }
  .header-controls .btn .icon, .header-controls .btn .btn-icon-slot { font-size: 1.375rem; }
  .header-controls .fab { width: 40px; height: 40px; min-width: 40px; }
  .sidebar-close { display: inline-flex; }
  .float-controls { left: 12px; top: 12px; }
  body.sidebar-open .float-controls { opacity: 0; pointer-events: none; }
  .float-controls .btn { padding: 6px 12px; }
  .info-window { width: min(280px, calc(100vw - 80px)); }
  .snackbar { left: 8px; right: 8px; bottom: 8px; z-index: 1400; }
  .alert { min-width: 0; width: 100%; }
  .dialog-backdrop { padding: 16px; }
  .dialog-title { padding: 16px 20px; margin-bottom: 28px; }
  .dialog-title::after { left: 22px; }
  .dialog-content { padding: 0 20px 16px; }
  .tour-tooltip { padding: 14px; }
  .compass { bottom: 10px; width: calc(100vw - 16px); padding: 8px 10px 8px 8px; column-gap: 10px; row-gap: 6px; }
  .compass-toggle { width: 32px; height: 32px; }
  .compass-mode { margin-right: 40px; padding: 4px 0; }
  .compass-stage { width: 118px; height: 118px; }
  .compass-list button { padding: 3px 0 3px 2px; gap: 8px; min-height: 38px; }
  .compass-name { font-size: 0.875rem; }
  .compass-sub { font-size: 0.75rem; }
  .compass-rank { width: 22px; height: 22px; font-size: 0.6875rem; }
  body.sidebar-open .compass { opacity: 0; pointer-events: none; }
}

@media (max-width: 380px) {
  .header-controls { gap: 4px; }
  .logo { max-height: 28px; }
  .logo-3d { height: 44px; width: 160px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .float-controls, .snackbar, .tour-spotlight, .btn { transition: none; }
}

[hidden] { display: none !important; }
