/* ==========================================================================
   Taiwan 3D Topography & Bathymetry Visualizer
   Zero-Build High-Contrast Touch-Friendly Stylesheet
   ========================================================================== */

:root {
  --font-main: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Color Palette */
  --bg-dark: #070b14;
  --bg-surface: rgba(14, 22, 38, 0.85);
  --bg-surface-elevated: rgba(22, 34, 58, 0.92);
  --bg-surface-glass: rgba(10, 18, 32, 0.75);
  --border-color: rgba(255, 255, 255, 0.12);
  --border-active: rgba(0, 180, 216, 0.5);

  --text-main: #f0f4fc;
  --text-muted: #8fa0be;
  --text-dim: #5c6b84;

  --accent-cyan: #00b4d8;
  --accent-blue: #0077b6;
  --accent-deep: #03045e;
  --accent-teal: #2ec4b6;
  --accent-green: #38b000;
  --accent-amber: #ffb703;
  --accent-red: #e63946;

  /* Elevation Color Ramp Preview */
  --trench-color: #03071e;
  --ocean-color: #034078;
  --shelf-color: #48cae4;
  --coast-color: #52b788;
  --mountain-color: #bc6c25;
  --peak-color: #f1faee;

  /* Layout Constants */
  --header-height: 58px;
  --sidebar-width: 380px;
  --profile-height: 290px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.55), 0 0 1px rgba(255, 255, 255, 0.15);
  --shadow-glow: 0 0 20px rgba(0, 180, 216, 0.35);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
}

/* ==========================================================================
   Main Application Layout
   ========================================================================== */

#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 3D WebGL Canvas Layer */
#canvas-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none; /* Crucial for Three.js touch gestures */
}

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   Header Navigation Bar
   ========================================================================== */

#main-header {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  max-width: calc(100vw - 28px);
}

.header-branding {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  box-shadow: 0 2px 8px rgba(0, 180, 216, 0.4);
}

.header-titles h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #ffffff;
  white-space: nowrap;
}

.header-titles .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ==========================================================================
   Floating Bars & Action Controls
   ========================================================================== */

.floating-bar {
  position: absolute;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  padding: 6px 8px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}

/* Camera Bar (Top Right) */
#camera-bar {
  top: 14px;
  right: 14px;
}

/* Action Mode Bar (Profile Tool & Animation Quick Toggle) */
#mode-bar {
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  gap: 10px;
  padding: 8px 12px;
}

/* Compass & Orientation Tool */
#compass-widget {
  position: absolute;
  top: 80px;
  left: 20px;
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: transform var(--transition-fast);
}

#compass-widget:hover {
  transform: scale(1.08);
  border-color: var(--accent-cyan);
}

#compass-needle {
  width: 4px;
  height: 24px;
  background: linear-gradient(to bottom, #e63946 50%, #ffffff 50%);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(230, 57, 70, 0.5);
  transition: transform 0.1s linear;
}

.compass-label {
  position: absolute;
  top: 3px;
  font-size: 8px;
  font-weight: 700;
  color: #e63946;
  font-family: var(--font-mono);
}

/* Coordinate HUD (Bottom Left) */
#coord-hud {
  position: absolute;
  bottom: 24px;
  left: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}

.hud-label {
  color: var(--text-dim);
}

.hud-sep {
  color: var(--border-color);
}

.hud-value {
  color: var(--accent-cyan);
  font-weight: 600;
}

.hud-tag {
  background: rgba(0, 180, 216, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 180, 216, 0.4);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
}

/* Header Title Row & Exaggeration Pill */
.title-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-exag-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(0, 180, 216, 0.18);
  border: 1px solid rgba(0, 180, 216, 0.4);
  color: var(--text-main);
  padding: 1px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.header-exag-pill strong {
  color: var(--accent-cyan);
}

/* Permanent On-Screen Attribution & Exaggeration HUD (Bottom Right) */
#canvas-attribution-hud {
  position: absolute;
  bottom: 24px;
  right: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: none;
}

.attr-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  color: var(--text-muted);
}

.attr-pill.attr-exag {
  border-color: rgba(0, 180, 216, 0.4);
  background: rgba(14, 28, 48, 0.85);
}

.attr-icon {
  width: 14px;
  height: 14px;
  stroke: var(--accent-cyan);
  stroke-width: 2;
  fill: none;
  flex-shrink: 0;
}

.attr-label {
  color: var(--text-dim);
  font-size: 11px;
}

.attr-highlight {
  color: var(--accent-cyan);
  font-weight: 700;
  font-size: 12px;
}

.attr-text {
  color: var(--text-main);
  font-weight: 500;
  font-size: 11px;
}

/* ==========================================================================
   Button System
   ========================================================================== */

button {
  font-family: var(--font-main);
  border: none;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-muted);
  flex-direction: column;
  padding: 4px;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.btn-icon .btn-label {
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-icon.active {
  background: rgba(0, 180, 216, 0.25);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 180, 216, 0.4);
}

.btn-pill {
  padding: 8px 16px;
  min-height: 42px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-pill svg {
  width: 17px;
  height: 17px;
  stroke: var(--accent-cyan);
  stroke-width: 2.2;
  fill: none;
}

.btn-pill:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-pill.active {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 18px rgba(0, 180, 216, 0.6);
}

.btn-pill.active svg {
  stroke: #ffffff;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 180, 216, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-primary svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.btn-ghost {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-main);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-icon-sm {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.btn-icon-sm svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.btn-icon-sm:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--accent-cyan);
}

.btn-pill-sm {
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: rgba(0, 180, 216, 0.15);
  border: 1px solid rgba(0, 180, 216, 0.3);
  font-size: 11px;
  color: var(--accent-cyan);
  font-weight: 500;
}

.btn-pill-sm svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.btn-pill-sm:hover {
  background: rgba(0, 180, 216, 0.3);
}

/* ==========================================================================
   Sidebar / Drawer Control Deck
   ========================================================================== */

#control-panel {
  position: absolute;
  top: 74px;
  right: 14px;
  bottom: 24px;
  width: var(--sidebar-width);
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: visible;
  transition: transform var(--transition-normal);
  pointer-events: auto;
}

#control-panel:not(.open) {
  transform: translateX(calc(100% + 14px));
}

/* Docked Toggle Tab (Directly attached to the control panel's left edge) */
.panel-dock-btn {
  position: absolute;
  top: 14px;
  left: -46px;
  width: 46px;
  height: 52px;
  background: var(--bg-surface-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  box-shadow: -8px 8px 24px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  z-index: 25;
  color: var(--accent-cyan);
  transition: all var(--transition-fast);
  pointer-events: auto;
}

.panel-dock-btn:hover {
  background: rgba(0, 180, 216, 0.22);
  color: #ffffff;
  box-shadow: -10px 10px 28px rgba(0, 180, 216, 0.5);
}

.panel-dock-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
}

.dock-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* Panel Header Bar */
.panel-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title-icon {
  width: 16px;
  height: 16px;
  stroke: var(--accent-cyan);
  stroke-width: 2.2;
  fill: none;
}

.panel-header-bar h2 {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
}

/* Panel Tabs */
.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  padding: 12px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  flex-direction: column;
  gap: 4px;
}

.tab-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(0, 180, 216, 0.08);
}

/* Panel Scrollable Body */
.panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.panel-body::-webkit-scrollbar {
  width: 6px;
}

.panel-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.tab-pane.active {
  display: flex;
}

/* Control Groups */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.group-title {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.highlight-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Water Level Numeric Input Box */
.water-input-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-color);
  padding: 3px 6px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.water-input-control:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 180, 216, 0.35);
  background: rgba(0, 0, 0, 0.65);
}

.btn-step {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-step:hover {
  background: var(--accent-cyan);
  color: #070b14;
}

.btn-step:active {
  transform: scale(0.92);
}

.input-unit-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}

#input-water-level {
  width: 66px;
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  outline: none;
  padding: 2px 4px;
  -moz-appearance: textfield;
}

#input-water-level::-webkit-outer-spin-button,
#input-water-level::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.unit-suffix {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding-right: 2px;
}

.card-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px;
}

.helper-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Sliders */
.slider-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 180, 216, 0.8), 0 2px 4px rgba(0,0,0,0.5);
  cursor: grab;
  border: 2px solid #ffffff;
  transition: transform var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  padding: 0 4px;
}

.slider-ticks span {
  text-align: center;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.slider-ticks span:hover, .slider-ticks span.tick-zero {
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Preset Chips */
.preset-chips, .landmark-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.chip:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.15);
}

.chip.active {
  background: var(--accent-cyan);
  color: #070b14;
  font-weight: 700;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 180, 216, 0.5);
}

/* Water Preset Grid */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.water-preset-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.water-preset-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.water-preset-card.active {
  background: rgba(0, 180, 216, 0.15);
  border-color: var(--accent-cyan);
  box-shadow: inset 0 0 12px rgba(0, 180, 216, 0.2);
}

.preset-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preset-card-title {
  font-weight: 600;
  font-size: 13px;
  color: #ffffff;
}

.preset-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 180, 216, 0.2);
  color: var(--accent-cyan);
}

.preset-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Animation Controls */
.anim-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.badge.playing {
  background: rgba(56, 176, 0, 0.25);
  color: #70e000;
  border: 1px solid rgba(112, 224, 0, 0.4);
}

.anim-speed-selector, .anim-mode-selector, .control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

select:focus {
  border-color: var(--accent-cyan);
}

.scenario-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  font-style: italic;
  border-left: 2px solid var(--accent-cyan);
  padding-left: 8px;
}

/* Environmental Stats Strip */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

.stat-label {
  font-size: 10px;
  color: var(--text-dim);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
}

.text-blue { color: #00b4d8 !important; }
.text-cyan { color: #48cae4 !important; }
.text-green { color: #52b788 !important; }

/* Theme Selector Cards */
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-card {
  padding: 8px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.theme-card:hover {
  background: rgba(255, 255, 255, 0.1);
}

.theme-card.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 180, 216, 0.12);
  box-shadow: 0 0 10px rgba(0, 180, 216, 0.3);
}

.theme-preview {
  height: 24px;
  border-radius: var(--radius-sm);
  width: 100%;
}

.theme-hypsometric {
  background: linear-gradient(to right, #372a20, #8c6d46, #dfc187, #52b788, #bc6c25, #ffffff);
}

.theme-natural {
  background: linear-gradient(to right, #2c221a, #6d5843, #d8c39d, #2d6a4f, #8d6e63, #ffffff);
}

.theme-scifi {
  background: linear-gradient(to right, #05051a, #0d1b4c, #00f0ff, #7928ca, #ff007f);
}

.theme-hillshade {
  background: linear-gradient(to right, #111111, #444444, #888888, #cccccc, #ffffff);
}

.theme-info strong {
  font-size: 11px;
  display: block;
}

.theme-info span {
  font-size: 9px;
  color: var(--text-dim);
}

/* Toggle Switches */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-label-wrap {
  display: flex;
  flex-direction: column;
}

.subtext {
  font-size: 11px;
  color: var(--text-dim);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 24px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
}

input:checked + .slider-round {
  background-color: var(--accent-cyan);
}

input:checked + .slider-round:before {
  transform: translateX(20px);
}

.sub-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Landmark List Cards */
.landmark-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.landmark-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.landmark-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-cyan);
  transform: translateX(2px);
}

.landmark-card.active {
  background: rgba(0, 180, 216, 0.15);
  border-color: var(--accent-cyan);
}

.lm-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lm-name {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
}

.lm-en {
  font-size: 10px;
  color: var(--text-dim);
}

.lm-alt {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Panel Footer */
.panel-footer {
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid var(--border-color);
}

.citation-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--text-dim);
}

/* ==========================================================================
   2D Cross-Section Elevation Profile Floating Drawer
   ========================================================================== */

.profile-drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--profile-height);
  z-index: 25;
  background: var(--bg-surface-elevated);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal);
  pointer-events: auto;
}

.profile-drawer.collapsed {
  transform: translateY(100%);
  pointer-events: none;
}

.profile-header {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
}

.profile-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-badge {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.profile-title-area h3 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

#profile-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.profile-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

#profile-canvas-container {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(10, 20, 36, 0.7), rgba(4, 7, 14, 0.95));
  cursor: grab;
  touch-action: none; /* Crucial for independent pan & zoom */
}

#profile-canvas-container:active {
  cursor: grabbing;
}

#profile-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.profile-gesture-hint {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  pointer-events: none;
}

/* Tooltip on 2D Profile Canvas */
.profile-tooltip {
  position: absolute;
  z-index: 30;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #ffffff;
  pointer-events: none;
  transform: translate(-50%, -120%);
  white-space: nowrap;
}

.profile-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid var(--border-color);
  font-size: 11px;
}

.pstat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pstat-label {
  color: var(--text-dim);
}

.pstat-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #ffffff;
}

/* ==========================================================================
   3D Landmark Pin DOM Markers
   ========================================================================== */

.landmark-3d-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  pointer-events: auto;
  transition: transform var(--transition-fast), filter var(--transition-fast);
  z-index: 5;
}

.landmark-3d-pin:hover {
  transform: translate(-50%, -115%) scale(1.15);
  z-index: 8;
}

.pin-bubble {
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  white-space: nowrap;
}

.pin-bubble strong {
  font-size: 11px;
  color: #ffffff;
}

.pin-bubble span {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-cyan);
}

.pin-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
  margin-top: 2px;
}

.pin-ripple {
  position: absolute;
  bottom: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  animation: pulse-ring 2s infinite;
  opacity: 0;
}

@keyframes pulse-ring {
  0% { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ==========================================================================
   Toast Notification Banner
   ========================================================================== */

.toast {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--accent-cyan);
  box-shadow: var(--shadow-glow), var(--shadow-lg);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.toast.hidden {
  opacity: 0;
  transform: translate(-50%, -20px);
}

/* ==========================================================================
   Loading Overlay
   ========================================================================== */

#loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 999;
  background: radial-gradient(circle at 50% 50%, #0d1b2a, #040810);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}

#loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 32px;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 440px;
  margin: 20px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(0, 180, 216, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.loading-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.loading-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

#loading-bar-inner {
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 3px;
  transition: width 0.3s ease;
}

#loading-status-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
}

/* ==========================================================================
   Responsive Breakpoints & Touch Optimization
   ========================================================================== */

@media (max-width: 768px) {
  #main-header {
    top: 10px;
    left: 10px;
    right: 10px;
    padding: 6px 12px;
  }

  .header-titles .subtitle {
    display: none;
  }

  #camera-bar {
    top: 66px;
    right: 10px;
    padding: 4px;
    gap: 4px;
  }

  .btn-icon {
    width: 36px;
    height: 36px;
  }

  .btn-icon .btn-label {
    display: none;
  }

  #compass-widget {
    top: 66px;
    left: 10px;
    width: 38px;
    height: 38px;
  }

  #mode-bar {
    bottom: 16px;
    width: calc(100vw - 32px);
    justify-content: space-around;
  }

  #coord-hud {
    display: none; /* Hide coordinate HUD on mobile to save precious screen real estate */
  }

  #canvas-attribution-hud {
    bottom: 66px;
    left: 10px;
    right: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    max-width: calc(100vw - 20px);
  }

  .attr-pill {
    padding: 3px 8px;
    font-size: 10px;
  }

  #control-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 62dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(0);
    overflow: visible;
  }

  .panel-dock-btn {
    top: -44px;
    left: auto;
    right: 14px;
    width: auto;
    height: 38px;
    padding: 0 12px;
    flex-direction: row;
    gap: 6px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  }

  #control-panel:not(.open) {
    transform: translateY(100%);
  }

  #control-panel:not(.open) .panel-dock-btn {
    top: -54px;
  }

  .profile-drawer {
    height: 320px;
  }

  .profile-stats-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

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

.hidden {
  display: none !important;
}
