/* ==============================================
   Mini Vietnam 3D — Premium Dark Theme
   Inspired by Mini Tokyo 3D
   ============================================== */

/* Design Tokens */
:root {
  --bg-dark: #0d1117;
  --bg-surface: #161b22;
  --bg-surface2: #1c2129;
  --bg-glass: rgba(22, 27, 34, 0.85);
  --bg-glass-light: rgba(22, 27, 34, 0.6);
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.04);
  --accent: #00cc66;
  --accent-glow: rgba(0, 204, 102, 0.3);
  --metro-green: #009900;
  --metro-green-light: #00cc00;
  --underground: #3b82f6;
  --elevated: #10b981;
  --train-color: #fbbf24;
  --danger: #ef4444;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  --topbar-h: 52px;
  --sidebar-w: 320px;
}

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

html,
body {
  font-family: var(--font);
  background: var(--bg-dark);
  color: var(--text-primary);
  height: 100%;
  width: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Loading Screen ---- */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-logo {
  font-size: 3.5rem;
  animation: pulse 1.5s ease-in-out infinite;
  margin-bottom: 16px;
}

.loading-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.loading-content p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 24px;
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: var(--bg-surface2);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto;
}

.loading-bar-fill {
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--metro-green-light));
  border-radius: 3px;
  animation: loading-slide 1.2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1)
  }

  50% {
    transform: scale(1.1)
  }
}

@keyframes loading-slide {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(350%);
  }
}

/* ---- App Container ---- */
#app {
  position: relative;
  width: 100%;
  height: 100vh;
}

/* ---- Map ---- */
#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.mapboxgl-map {
  font-family: var(--font);
}

.mapboxgl-ctrl-group {
  background: var(--bg-glass) !important;
  border: 1px solid var(--border) !important;
  backdrop-filter: blur(12px);
}

.mapboxgl-ctrl-group button {
  color: var(--text-primary) !important;
}

.mapboxgl-ctrl-group button:hover {
  background: var(--bg-surface2) !important;
}

.mapboxgl-ctrl-group button+button {
  border-top-color: var(--border) !important;
}

.mapboxgl-ctrl-attrib {
  background: var(--bg-glass) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}

.mapboxgl-ctrl-attrib a {
  color: var(--text-secondary) !important;
}

.mapboxgl-ctrl-scale {
  background: var(--bg-glass) !important;
  color: var(--text-secondary) !important;
  border-color: var(--text-muted) !important;
}

.mapboxgl-popup {
  z-index: 200;
}

.mapboxgl-popup-content {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 0 !important;
  overflow: hidden;
}

.mapboxgl-popup-tip {
  border-top-color: var(--bg-surface) !important;
}

.mapboxgl-popup-close-button {
  color: var(--text-secondary) !important;
  font-size: 18px;
  padding: 4px 8px;
}

.mapboxgl-popup-close-button:hover {
  background: var(--bg-surface2) !important;
}

/* Hide default nav controls — we have our own toolbar */
.mapboxgl-ctrl-top-right .mapboxgl-ctrl-group {
  display: none;
}

/* ---- Top Bar ---- */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  font-size: 1.25rem;
}

.brand-text {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  white-space: nowrap;
}

/* Icon Button */
.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-surface2);
  color: var(--text-primary);
}

.icon-btn.small {
  width: 28px;
  height: 28px;
}

.icon-btn.text-btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.8rem;
  width: auto;
  padding: 0 8px;
}

/* ---- Search Box ---- */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  width: 100%;
  max-width: 360px;
  position: relative;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
}

.search-result-item:hover {
  background: var(--bg-surface2);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item .result-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-result-item .result-name {
  font-weight: 500;
}

.search-result-item .result-sub {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: auto;
}

/* ---- Clock Widget ---- */
.clock-widget {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: var(--font-mono);
}

.clock-time {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.clock-speed {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ---- Sidebar ---- */
.sidebar {
  position: absolute;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  z-index: 900;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-section h4 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Route */
.route-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 14px;
}

.route-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.route-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  background: var(--bg-surface2);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}

.stat-val {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Station list */
.station-list {
  list-style: none;
}

.station-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
  border-radius: var(--radius-sm);
  padding-left: 4px;
  position: relative;
}

.station-list li:hover {
  background: var(--bg-surface2);
}

.station-list li.active {
  background: var(--bg-surface2);
  color: var(--accent);
}

.station-list li .s-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  flex-shrink: 0;
  position: relative;
}

.station-list li .s-dot.underground {
  background: var(--underground);
  border-color: var(--underground);
}

.station-list li .s-dot.elevated {
  background: var(--elevated);
  border-color: var(--elevated);
}

.station-list li .s-line {
  position: absolute;
  left: 8px;
  top: 30px;
  width: 2px;
  height: calc(100% - 10px);
  background: var(--metro-green);
}

.station-list li:last-child .s-line {
  display: none;
}

.station-list li .s-name {
  font-weight: 500;
}

.station-list li .s-id {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Schedule info */
.schedule-info {}

.sched-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-light);
}

.sched-row:last-child {
  border-bottom: none;
}

.sched-row span:first-child {
  color: var(--text-secondary);
}

.sched-row span:last-child {
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- Toolbar (right side) ---- */
.toolbar {
  position: absolute;
  top: calc(var(--topbar-h) + 12px);
  right: 12px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toolbar-group {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
}

.toolbar-btn:hover {
  background: var(--bg-surface2);
  color: var(--text-primary);
}

.toolbar-btn.active {
  color: var(--accent);
}

.toolbar-btn+.toolbar-btn {
  border-top: 1px solid var(--border);
}

.toolbar-btn.text-btn {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
}

/* ---- Layer Panel ---- */
.layer-panel {
  position: absolute;
  top: calc(var(--topbar-h) + 12px);
  right: 62px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  z-index: 800;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
}

.layer-panel.hidden {
  display: none;
}

.layer-panel h4 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.layer-toggle:hover {
  color: var(--text-primary);
}

.layer-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-muted);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}

.layer-toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.layer-toggle input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: -1px;
  left: 1px;
  font-size: 11px;
  color: var(--bg-dark);
  font-weight: 700;
}

/* ---- Legend ---- */
.legend {
  position: absolute;
  bottom: 36px;
  left: 12px;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  display: flex;
  gap: 14px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.legend-item,
.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.underground {
  background: var(--underground);
}

.dot.elevated {
  background: var(--elevated);
}

.dot.train-dot {
  background: var(--train-color);
}

.line-sample {
  width: 18px;
  height: 3px;
  background: var(--metro-green);
  border-radius: 2px;
}

/* ---- Info Panel ---- */
/* ---- Station Detail Panel ---- */
.station-detail-panel {
  position: absolute;
  top: calc(var(--topbar-h) + 12px);
  right: 62px;
  width: 340px;
  max-height: calc(100vh - var(--topbar-h) - 40px);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 850;
  overflow-y: auto;
  transition: var(--transition);
}

.station-detail-panel.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateX(20px);
  pointer-events: none;
}

.sdp-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.sdp-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sdp-title-row h2 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

.sdp-title-row .close-btn {
  border: none;
  background: var(--bg-surface2);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.sdp-title-row .close-btn:hover {
  background: var(--danger);
  color: white;
}

.sdp-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 4px 0 10px;
}

.sdp-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: white;
  text-transform: uppercase;
}

.sdp-type-badge.underground {
  background: var(--underground);
}

.sdp-type-badge.elevated {
  background: var(--elevated);
}

.sdp-description {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}

.sdp-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}

.sdp-section:last-child {
  border-bottom: none;
}

.sdp-section h4 {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.sdp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.sdp-tags .tag {
  background: var(--bg-surface2);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.sdp-tags .tag:hover {
  background: var(--accent);
  color: var(--bg-dark);
}

.sdp-coords code {
  background: var(--bg-surface2);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  display: inline-block;
}

/* ---- Timetable Grid ---- */
.timetable {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timetable-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface2);
  transition: var(--transition);
}

.timetable-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.timetable-row.next {
  border-left: 3px solid var(--accent);
  background: rgba(0, 204, 102, 0.08);
}

.timetable-time {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 48px;
}

.timetable-dir {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.timetable-dir.east {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.timetable-dir.west {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

.timetable-eta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

.timetable-eta.soon {
  color: var(--accent);
  font-weight: 600;
}

.timetable-empty {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.timetable-loading {
  text-align: center;
  padding: 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ---- Train Count Badge ---- */
.train-count-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 10px;
  cursor: default;
  transition: var(--transition);
}

.train-count-badge .train-icon {
  font-size: 0.75rem;
}

.train-count-badge .train-count {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 16px;
  text-align: center;
}

/* ---- Weather Widget ---- */
.weather-widget {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 10px;
  cursor: default;
  transition: var(--transition);
}

.weather-widget .weather-icon {
  font-size: 0.85rem;
}

.weather-widget .weather-temp {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: #fbbf24;
}

/* ---- Station Pulse Ring ---- */
@keyframes station-pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.8);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.custom-marker.selected::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--accent);
  transform: translate(-50%, -50%);
  animation: station-pulse 1.5s ease-out infinite;
  pointer-events: none;
}


/* Station Popup */
.station-popup {
  min-width: 200px;
}

.popup-header {
  padding: 10px 14px;
  color: white;
}

.popup-header.underground {
  background: var(--underground);
}

.popup-header.elevated {
  background: var(--elevated);
}

.popup-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.station-id {
  font-size: 0.7rem;
  opacity: 0.9;
}

.popup-content {
  padding: 10px 14px;
}

.station-type {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.station-description {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 10px;
}

.popup-facilities {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.facility-tag {
  background: var(--bg-surface2);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.popup-connections {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Custom markers */
.custom-marker {
  transition: transform 0.2s ease;
  cursor: pointer;
}

.custom-marker:hover,
.custom-marker.hover {
  transform: scale(1.3);
  z-index: 10;
}

.custom-marker.active {
  transform: scale(1.5);
  z-index: 20;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.25s, visibility 0.25s;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 440px;
  position: relative;
  animation: modal-in 0.3s ease;
}

@keyframes modal-in {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: var(--bg-surface2);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--danger);
  color: white;
}

.modal-body {
  padding: 32px 28px;
  text-align: center;
}

.modal-logo {
  font-size: 3rem;
  margin-bottom: 12px;
}

.modal-body h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
}

.modal-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 24px;
}

.modal-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-bottom: 24px;
}

.feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.feature span:first-child {
  font-size: 1.1rem;
}

.modal-credits {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.modal-credits a {
  color: var(--accent);
  text-decoration: none;
}

.modal-credits a:hover {
  text-decoration: underline;
}

/* Shortcuts */
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: left;
  margin-top: 16px;
}

.shortcut {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

kbd {
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 28px;
  text-align: center;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .topbar {
    padding: 0 8px;
    gap: 8px;
  }

  .brand-text {
    display: none;
  }

  .search-box {
    max-width: 200px;
  }

  .clock-widget {
    display: none;
  }

  .sidebar {
    width: 100%;
  }

  .info-panel {
    right: 10px;
    left: 10px;
    width: auto;
    top: auto;
    bottom: 60px;
    max-height: 50vh;
  }

  .layer-panel {
    right: 10px;
    top: auto;
    bottom: 60px;
  }

  .toolbar {
    right: 8px;
  }

  .legend {
    flex-wrap: wrap;
    gap: 10px 14px;
    bottom: 30px;
    left: 8px;
    right: 56px;
  }

  .shortcuts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .toolbar-btn {
    width: 36px;
    height: 36px;
  }

  .legend {
    font-size: 0.65rem;
  }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Focus */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print */
@media print {

  .topbar,
  .sidebar,
  .toolbar,
  .layer-panel,
  .info-panel,
  .legend,
  .loading-screen,
  .modal-overlay {
    display: none !important;
  }

  #map {
    position: static;
    height: 100vh;
  }
}