:root {
  /* Palette - Increased Transparency */
  --surface: rgba(255, 255, 255, 0.65);
  /* More transparent sidebar */
  --card-bg: rgba(255, 255, 255, 0.5);
  /* More transparent cards */
  --glass: blur(20px);
  --border: 1px solid rgba(255, 255, 255, 0.4);

  --primary: #1a73e8;
  --text-main: #202124;
  --text-muted: #5f6368;
  --text-light: #80868b;
  --error: #d93025;
  --positive: #188038;

  --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.1);
  --radius-lg: 20px;
  --radius-md: 12px;
}

/* Dark mode UI theme */
[data-theme="dark"] {
  --surface: rgba(30, 32, 38, 0.88);
  --card-bg: rgba(40, 42, 50, 0.75);
  --border: 1px solid rgba(255, 255, 255, 0.08);
  --text-main: #e8eaed;
  --text-muted: #9aa0a6;
  --text-light: #80868b;
  --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] body,
[data-theme="dark"] {
  background: #121216;
  color: #e8eaed;
}

[data-theme="dark"] .sidebar,
[data-theme="dark"] .control-panel,
[data-theme="dark"] .info-card,
[data-theme="dark"] .legend-box {
  color: #e8eaed;
}

/* Panel buttons inherit dark text color */
[data-theme="dark"] .control-panel button:not(.toolbar-btn):not(.btn-station-active) {
  color: #e8eaed;
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
}

/* Keep station buttons always blue-active regardless of theme */
[data-theme="dark"] .btn-station-active {
  background: #1a73e8;
  color: white;
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .sidebar-view-btn.active {
  background: #2d2f36 !important;
  color: #8ab4f8 !important;
}

[data-theme="dark"] .sidebar-view-toggle {
  background: rgba(255,255,255,0.08);
}

[data-theme="dark"] #bottomToolbar,
[data-theme="dark"] .timeline-container {
  background: rgba(30, 32, 38, 0.92);
  border-color: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  background: #f8f9fa;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* --- MAP --- */
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #eef2f6;
  /* GPU acceleration for smoother performance on mobile */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* --- SIDEBAR --- */
.ui-layer {
  position: absolute;
  z-index: 100;
  pointer-events: none;
  top: 24px;
  left: calc(420px + 48px + 24px);
  /* sidebar width + gap + padding */
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.top-controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  pointer-events: none;
}

.control-panel {
  background: var(--surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  padding: 16px;
  pointer-events: auto;
  border: var(--border);
  min-width: 200px;
}

.sidebar {
  width: 420px;
  max-width: 100%;
  background: var(--surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  padding: 24px;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border: var(--border);
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

/* Inputs */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

select,
button {
  appearance: none;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
}

select:hover,
button:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Active button state for zoom rectangle */
button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(26, 115, 232, 0.3);
}

/* Info Card */
.info-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.metric-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.metric-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Ranking List */
.ranking-list {
  margin-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 12px;
}

.ranking-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

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

.rank-num {
  font-weight: 700;
  color: var(--primary);
  margin-right: 8px;
  width: 24px;
}

.rank-name {
  flex: 1;
  font-weight: 500;
}

.rank-val {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
}

.rank-trend {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  margin-right: 2px;
}

.rank-trend.up   { color: #d32f2f; }
.rank-trend.down { color: #188038; }
.rank-trend.flat { color: #9aa0a6; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-val {
  font-size: 16px;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  transition: opacity 0.15s ease;
}

@keyframes statFlicker {
  0%   { opacity: 1; }
  20%  { opacity: 0.12; }
  100% { opacity: 1; }
}

.stat-val.stat-flicker,
.metric-value.stat-flicker {
  animation: statFlicker 0.38s ease-out;
}

.stat-val.pos {
  color: var(--error);
}

.stat-val.neg {
  color: var(--positive);
}

/* Chart Section */
.chart-section {
  margin-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 12px;
  padding-bottom: 4px;
  display: block;
}

/* Legend */
.legend-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.legend-bar {
  height: 8px;
  border-radius: 4px;
  margin-top: 8px;
  background: linear-gradient(to right, #e0f3ff, #b8e1ff, #7ac5ff, #4fb8ff, #ffbf9b, #ff8a66, #e24774);
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
}

.bottom-ui {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 220;
  flex-wrap: nowrap;
  justify-content: center;
  pointer-events: none;
}

.bottom-ui>* {
  pointer-events: auto;
}

.timeline-container {
  width: 520px;
  max-width: 50vw;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 100px;
  padding: 14px 28px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition: background 0.4s ease, border-color 0.4s ease;
}

.timeline-container.timeline-prediction {
  background: rgba(227, 116, 0, 0.14);
  border-color: rgba(227, 116, 0, 0.38);
}

[data-theme="dark"] .timeline-container.timeline-prediction {
  background: rgba(245, 139, 0, 0.18);
  border-color: rgba(245, 139, 0, 0.4);
}

#bottomToolbar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 100px;
  padding: 10px 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: 18px;
}

.toolbar-btn {
  background: var(--primary);
  color: white;
  border: none;
  min-width: 52px;
  padding: 7px 10px 5px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-shadow: 0 4px 16px rgba(26, 115, 232, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.toolbar-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.toolbar-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(26, 115, 232, 0.4);
}

/* Prevent slider/toolbar overlap on narrower screens */
@media (max-width: 1280px) {
  .bottom-ui {
    flex-direction: column;
    gap: 12px;
    bottom: 20px;
  }

  .timeline-container {
    flex: 1;
    max-width: 90vw;
  }

  #bottomToolbar {
    width: 90vw;
    max-width: 90vw;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  #bottomToolbar .toolbar-btn {
    flex: 0 0 auto;
    min-width: 48px;
    padding: 6px 8px 4px;
  }

  #bottomToolbar .toolbar-label {
    font-size: 8px;
  }
}

.toolbar-btn.active {
  background: #1557b0;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 4px 18px rgba(21, 87, 176, 0.5);
}

.toolbar-btn.active:hover {
  background: #0d47a1;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 6px 22px rgba(13, 71, 161, 0.6);
}

/* Sidebar view toggle pill */
.sidebar-view-toggle {
  display: flex;
  background: rgba(0,0,0,0.06);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
  margin-top: 14px;
  margin-bottom: 10px;
}

.sidebar-view-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-view-btn.active {
  background: white !important;
  color: var(--primary) !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* Chart expand button */
.chart-expand-btn {
  background: rgba(26, 115, 232, 0.12);
  border: 1px solid rgba(26, 115, 232, 0.3);
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 6px;
  line-height: 1;
  font-weight: 600;
  transition: color 0.15s, background 0.15s;
}

.chart-expand-btn:hover {
  background: rgba(26, 115, 232, 0.22);
  color: var(--primary);
}

/* Map Tooltip Card */
.map-tooltip-card {
  min-width: 185px;
  font-family: "Inter", -apple-system, sans-serif;
}

.map-tooltip-header {
  margin-bottom: 6px;
}

.map-tooltip-header strong {
  display: block;
  font-size: 13px;
  color: #202124;
  line-height: 1.3;
}

.map-tooltip-prov {
  font-size: 10px;
  color: #5f6368;
  font-weight: 500;
}

.map-tooltip-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
  margin: 6px 0;
}

.map-tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 2px 0;
}

.map-tooltip-label {
  font-size: 11px;
  color: #5f6368;
  font-weight: 500;
  white-space: nowrap;
}

.map-tooltip-value {
  font-size: 12px;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  color: #202124;
  text-align: right;
}

#chatOpenBtn:hover {
  transform: none;
  box-shadow: 0 6px 20px rgba(26, 115, 232, 0.35);
}

.floating-panel {
  position: fixed !important;
  bottom: 120px !important;
  left: 50% !important;
  top: auto !important;
  right: auto !important;
  transform: translateX(-50%) !important;
  width: min(640px, 90vw) !important;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px !important;
  padding: 20px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.8) !important;
  z-index: 260 !important;
  pointer-events: auto !important;
}

.panel-overlay-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.floating-panel .panel-overlay-header {
  display: flex;
}

.panel-overlay-header button {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #666;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: background 0.2s;
}

.panel-overlay-header button:hover {
  background: rgba(0, 0, 0, 0.05);
}

.floating-panel>label:first-of-type {
  display: none;
}

.panel-placeholder {
  display: none;
}

/* Panel animations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Ground Data Modals */
.ground-data-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.ground-data-modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

.ground-data-modal-content>div:first-child {
  position: relative;
  height: 0;
  z-index: 15;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ground-data-close {
  position: fixed;
  top: 26px;
  right: 26px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  z-index: 810;
  transition: all 0.2s;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.ground-data-close span {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  height: 100%;
  width: 100%;
}

.ground-data-close:hover {
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Transparent marker container for Leaflet divIcon */
.pulsating-dot-marker,
.ground-data-pin-marker,
.leaflet-div-icon {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.ground-data-mini-map {
  width: 140px;
  height: 140px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  background: white;
  flex-shrink: 0;
}

.ground-data-header {
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
  color: white;
  padding: 20px 24px;
  border-bottom: 1px solid #e8f0fe;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.ground-data-header-text {
  flex: 1;
}

.ground-data-header h2 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.ground-data-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: #e8f0fe;
  margin: 8px 0 0 0;
}

.ground-data-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ground-data-info {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
}

.ground-data-info h4 {
  color: #333;
}

.ground-data-chart-container {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
  height: 300px;
  position: relative;
}

.ground-data-chart-container canvas {
  max-height: 100%;
}

.ground-data-boxplot-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.boxplot-section {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
  min-height: 320px;
}

.boxplot-section canvas {
  max-height: 280px;
}

.ground-data-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.ground-data-stat-box {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #e0e0e0;
}

.ground-data-stat-box .label {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 4px;
}

.ground-data-stat-box .value {
  font-size: 16px;
  font-weight: 700;
  color: #1a73e8;
}

.ground-data-stat-box .unit {
  font-size: 10px;
  color: #999;
  margin-left: 2px;
}

/* Pulsating dot */
.pulsating-dot {
  width: 14px;
  height: 14px;
  background-color: #ff0000;
  border-radius: 50%;
  border: 3px solid rgba(255, 0, 0, 0.5);
  animation: pulse 1.5s infinite;
  box-shadow: 0 0 10px rgba(255, 0, 0, 0.6);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.6), 0 0 20px rgba(255, 0, 0, 0.3);
  }

  50% {
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8), 0 0 40px rgba(255, 0, 0, 0.4);
  }

  100% {
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.6), 0 0 20px rgba(255, 0, 0, 0.3);
  }
}

/* Genie appear animation - emerges from button position */
@keyframes genieAppear {
  0% {
    opacity: 0;
    transform: translate(calc(var(--genie-origin-x, 0px) - 50%),
        var(--genie-origin-y, 0px)) scale(0.1);
    transform-origin: center;
  }

  60% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
    transform-origin: center;
  }
}

@keyframes genieAppearModal {
  0% {
    opacity: 0;
    transform: translate(var(--genie-origin-x, 0px),
        var(--genie-origin-y, 0px)) scale(0.1);
  }

  60% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.chat-panel-show {
  animation: genieAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes genieAppearPanel {
  0% {
    opacity: 0;
    transform: translate(var(--genie-origin-x, 0px),
        var(--genie-origin-y, 0px)) scale(0.1);
  }

  60% {
    opacity: 1;
  }

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

.floating-panel {
  animation: genieAppearPanel 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes panelExit {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to   { opacity: 0; transform: scale(0.93) translateY(10px); }
}

.panel-closing {
  animation: panelExit 0.18s ease-in forwards !important;
  pointer-events: none !important;
}

/* Keep Search panel anchored near top when floated */
#searchPanel.floating-panel {
  top: 32px !important;
  bottom: auto !important;
  transform: translate(-50%, 0) !important;
}

/* Position Help panel at top same as Search panel */
#helpPanel.floating-panel {
  top: 32px !important;
  bottom: auto !important;
  transform: translate(-50%, 0) !important;
}

.genie-modal-show {
  animation: genieAppearModal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Methods Tab Styling */
.methods-tab-btn {
  position: relative;
}

.methods-tab-btn.active {
  background: white !important;
  color: #1a73e8 !important;
  border-bottom-color: #1a73e8 !important;
}

.methods-tab-content {
  animation: fadeIn 0.3s ease-in;
}

.timeline-date {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 16px;
  min-width: 120px;
}

input[type="range"] {
  flex: 1;
  height: 6px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
  appearance: none;
  -webkit-appearance: none;
  min-width: 0;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.12);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.12);
}

/* Slider: dark-mode track */
[data-theme="dark"] input[type="range"] {
  background: rgba(255, 255, 255, 0.3);
}
[data-theme="dark"] input[type="range"]::-webkit-slider-runnable-track,
[data-theme="dark"] input[type="range"]::-webkit-slider-container {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

[data-theme="dark"] input[type="range"]::-moz-range-track {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  height: 6px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px; /* center 20px thumb on 6px track: (6 - 20) / 2 */
  background: var(--primary);
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.1s;
}

[data-theme="dark"] input[type="range"]::-webkit-slider-thumb {
  border-color: #2d2f36;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] input[type="range"]::-moz-range-thumb {
  border-color: #2d2f36;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

/* Chat typing indicator (global) */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(26, 115, 232, 0.1);
  border-radius: 12px;
  align-items: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1a73e8;
  animation: typingBlink 1.2s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBlink {
  0% {
    opacity: 0.2;
  }

  20% {
    opacity: 1;
  }

  100% {
    opacity: 0.2;
  }
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {

  /* Prevent text selection on interactive elements */
  button,
  select,
  .timeline-container,
  .toolbar-btn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* Optimize animations for mobile */
  * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* GPU acceleration for better mobile performance */
  .sidebar,
  #chatPanel,
  .floating-panel,
  .timeline-container,
  #bottomToolbar {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
  }

  /* Reduce animation complexity on mobile */
  @media (prefers-reduced-motion: reduce) {

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

  /* Safe area support for notched devices */
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* Hide sidebar on mobile - make it toggleable */
  .sidebar {
    width: 90vw;
    max-width: 360px;
    left: calc(-100% - env(safe-area-inset-left));
    top: max(16px, env(safe-area-inset-top));
    transition: left 0.3s ease;
    max-height: calc(100vh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    z-index: 300;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.mobile-open {
    left: max(16px, env(safe-area-inset-left));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  }

  /* Show mobile menu button */
  #mobileMenuBtn {
    display: flex !important;
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
  }

  /* Move top controls to top-left on mobile */
  .ui-layer {
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    top: max(76px, calc(76px + env(safe-area-inset-top)));
  }

  /* Stack control panels vertically with smaller padding */
  .control-panel {
    padding: 12px;
    min-width: unset;
    width: 100%;
  }

  .top-controls {
    gap: 8px;
  }

  /* Smaller fonts for mobile */
  .metric-value {
    font-size: 28px;
  }

  .control-group label,
  label {
    font-size: 10px;
  }

  select,
  button {
    padding: 10px;
    font-size: 12px;
  }

  /* Timeline + toolbar stack */
  .bottom-ui {
    flex-direction: column;
    gap: 12px;
  }

  .timeline-container {
    flex: 1;
    max-width: calc(100vw - 32px);
    padding: 12px 20px;
  }

  .timeline-date {
    font-size: 14px;
    min-width: 100px;
  }

  #bottomToolbar {
    width: calc(100vw - 32px);
    justify-content: space-between;
  }

  #bottomToolbar .toolbar-btn {
    flex: 1 1 0;
    width: auto;
    border-radius: 12px;
    min-height: 44px;
    height: auto;
    padding: 6px 8px 4px;
  }

  /* Chat button adjustments for mobile */
  #chatOpenBtn {
    bottom: calc(90px + env(safe-area-inset-bottom)) !important;
    right: max(16px, env(safe-area-inset-right)) !important;
  }

  /* Chat panel adjustments */
  #chatPanel {
    width: calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-width: calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
    bottom: calc(90px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    padding: 12px;
    max-height: 50vh;
  }

  .floating-panel {
    width: calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
    bottom: calc(150px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    max-height: calc(100vh - 200px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #chatMessages {
    height: 200px;
    max-height: 200px;
    font-size: 11px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #chatInput {
    font-size: 16px;
    /* Prevents zoom on iOS */
  }

  /* Chat typing indicator */
  .typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(26, 115, 232, 0.08);
    border-radius: 12px;
    align-items: center;
  }

  .typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #1a73e8;
    animation: typingBlink 1.2s infinite;
  }

  .typing-dot:nth-child(2) {
    animation-delay: 0.2s;
  }

  .typing-dot:nth-child(3) {
    animation-delay: 0.4s;
  }

  @keyframes typingBlink {
    0% {
      opacity: 0.2;
    }

    20% {
      opacity: 1;
    }

    100% {
      opacity: 0.2;
    }
  }

  /* Smaller info cards */
  .info-card {
    padding: 16px;
  }

  .stats-grid {
    gap: 12px;
  }

  .ranking-item {
    font-size: 12px;
  }

  /* Search panel full width */
  #searchPanel {
    max-width: 100% !important;
    left: max(16px, env(safe-area-inset-left)) !important;
    right: max(16px, env(safe-area-inset-right)) !important;
  }

  #searchInput {
    min-width: unset !important;
    width: 100% !important;
    font-size: 16px;
    /* Prevents zoom on iOS */
  }

  /* Help panel adjustments */
  #helpPanel {
    max-width: 100% !important;
    left: max(16px, env(safe-area-inset-left)) !important;
    right: max(16px, env(safe-area-inset-right)) !important;
  }

  /* Modal adjustments for mobile */
  .faq-modal-content,
  .methods-modal-content,
  .forecast-modal-content {
    width: calc(95% - env(safe-area-inset-left) - env(safe-area-inset-right)) !important;
    max-width: calc(95% - env(safe-area-inset-left) - env(safe-area-inset-right)) !important;
    max-height: calc(90vh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .faq-modal-content>div:last-child,
  .methods-modal-content>div:last-child {
    padding: 16px !important;
  }

  .faq-modal-content h2,
  .methods-modal-content h2 {
    font-size: 20px !important;
  }

  .faq-modal-content h3,
  .methods-modal-content h3 {
    font-size: 14px !important;
  }

  .faq-modal-content h4,
  .methods-modal-content h4 {
    font-size: 13px !important;
  }

  .faq-modal-content p,
  .methods-modal-content p {
    font-size: 12px !important;
  }

  /* Forecast modal map adjustments */
  #forecastMap {
    height: 40vh !important;
    min-height: 250px !important;
  }

  /* Better touch targets for map controls */
  .leaflet-control-zoom a,
  .leaflet-bar a {
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    font-size: 20px !important;
  }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar {
    width: 80vw;
    max-width: 320px;
  }

  #chatPanel,
  .floating-panel {
    max-height: calc(70vh - env(safe-area-inset-bottom));
  }

  .faq-modal-content,
  .methods-modal-content,
  .forecast-modal-content {
    max-height: calc(85vh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
  }

  /* Smaller timeline in landscape */
  .timeline-container {
    padding: 8px 12px;
  }

  .timeline-date {
    font-size: 12px;
  }

  #bottomToolbar {
    gap: 6px;
  }

  #bottomToolbar .toolbar-btn {
    height: 38px;
    border-radius: 12px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

  /* Larger touch targets */
  button {
    min-height: 44px;
    min-width: 44px;
  }

  select {
    min-height: 44px;
  }

  #chatOpenBtn,
  #mobileMenuBtn {
    width: 48px;
    height: 48px;
  }

  /* Prevent double-tap zoom */
  * {
    touch-action: manipulation;
  }

  /* Allow pinch zoom on map only */
  #map {
    touch-action: pan-x pan-y pinch-zoom;
  }

  /* Better touch feedback */
  button:active,
  .toolbar-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
  }

  /* Larger slider thumb for touch */
  input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }
}

/* Tablet adjustments (between mobile and desktop) */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 340px;
  }

  .ui-layer {
    left: calc(340px + 32px + 16px);
  }

  .control-panel {
    min-width: 180px;
  }

  .timeline-container {
    width: 450px;
  }

  /* Tablet-friendly panels */
  #chatPanel {
    width: 500px;
    max-width: calc(100vw - 64px);
  }

  .floating-panel {
    max-width: 400px;
  }

  /* Better touch targets on tablet */
  button {
    min-height: 40px;
  }

  .toolbar-btn {
    min-width: 48px;
    min-height: 44px;
    height: auto;\n  }
}

/* Small tablets in portrait */
@media (min-width: 600px) and (max-width: 768px) {
  .sidebar {
    width: 280px;
    left: -100%;
    transition: left 0.3s ease;
  }

  .sidebar.mobile-open {
    left: 16px;
  }

  #mobileMenuBtn {
    display: flex !important;
  }

  .ui-layer {
    left: 16px;
    right: 16px;
  }

  #chatPanel,
  .floating-panel {
    width: calc(100vw - 64px);
    max-width: 500px;
  }
}

/* Forecast Popup Modal */
#forecastModal {
  display: none;
  position: fixed;
  z-index: 500;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.forecast-modal-overlay {
  display: none;
  position: fixed;
  z-index: 500;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
}

.forecast-modal-content {
  position: fixed;
  bottom: 50%;
  left: 50%;
  transform: translate(-50%, 50%);
  background-color: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
  width: 98%;
  max-width: 1300px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  z-index: 501;
}

.forecast-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
  color: white;
  border-radius: 16px 16px 0 0;
}

.modal-title-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.forecast-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.forecast-modal-header .modal-subtitle {
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.4;
}

.forecast-modal-header .close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.forecast-modal-header .close-btn:hover {
  color: #333;
}

.forecast-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 16px;
  padding: 16px;
  min-height: 500px;
}

.forecast-map-container {
  flex: 1.8;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

#forecastMap {
  width: 100%;
  height: 100%;
}

#mipFluxesMap {
  width: 100%;
  height: 100%;
}

.forecast-controls {
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.forecast-controls::-webkit-scrollbar {
  width: 4px;
}

.forecast-controls::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

.control-group-forecast {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group-forecast label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #5f6368;
  letter-spacing: 0.5px;
}

.control-group-forecast select,
.control-group-forecast input {
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  font-size: 13px;
  background: #ffffff;
  color: #202124;
}

.control-group-forecast input[type="range"] {
  padding: 0;
  height: 6px;
}

.control-group-forecast span {
  color: #5f6368 !important;
}

.forecast-info-box {
  background: rgba(26, 115, 232, 0.07);
  padding: 12px;
  border-radius: 8px;
  border-left: 3px solid rgba(26, 115, 232, 0.3);
  font-size: 12px;
  line-height: 1.6;
  color: #202124;
}

.forecast-info-box strong {
  font-weight: 700;
  color: #202124;
}

.forecast-legend {
  background: #ffffff;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 12px;
  color: #202124;
}

.forecast-legend strong {
  color: #202124;
}

.forecast-legend-labels span {
  color: #5f6368 !important;
}

.forecast-controls #forecastStatus,
.forecast-controls #mipFluxesStatus {
  color: #5f6368 !important;
}

.forecast-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.forecast-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

@media (max-width: 1024px) {
  .forecast-modal-body {
    flex-direction: column;
    min-height: auto;
  }

  .forecast-controls {
    width: 100%;
    max-height: 200px;
  }

  .forecast-map-container {
    height: 350px;
  }
}

/* OCO2 MIP Fluxes Modal */
#mipFluxesModal {
  display: none;
  position: fixed;
  z-index: 500;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.3s ease-in;
}

/* Notification */
.notification {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(32, 33, 36, 0.9);
  color: white;
  padding: 12px 16px 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.notif-close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  padding: 0;
}

.notif-close-btn:hover {
  background: rgba(255,255,255,0.3);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Viz, Tools, Location, Modeling panel buttons — blue style */
#vizPanel button,
#toolsPanel button,
#locationPanel button,
#modelingPanel button:not([disabled]) {
  background: #1a73e8;
  color: white;
  border: 1px solid #1557b0;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s, box-shadow 0.2s;
}

#vizPanel button:hover,
#toolsPanel button:hover,
#locationPanel button:hover,
#modelingPanel button:not([disabled]):hover {
  background: #1557b0;
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

#modelingPanel button[disabled] {
  background: #e4e8ed;
  color: #5f6368;
  border: 1px solid #c8cdd4;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  width: 100%;
  text-transform: uppercase;
  cursor: not-allowed;
  opacity: 1;
}

[data-theme="dark"] #modelingPanel button[disabled] {
  background: rgba(255, 255, 255, 0.08);
  color: #9aa0a6;
  border-color: rgba(255, 255, 255, 0.12);
}

/* Location panel selects */
#locationPanel select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1.5px solid #c5cad3 !important;
  background: #ffffff !important;
  color: #202124 !important;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235f6368' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  padding-right: 32px;
}

[data-theme="dark"] #locationPanel select {
  background: rgba(50, 54, 65, 0.95) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23e8eaed' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  color: #e8eaed !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
}

/* Ground Data Panel Button Styling */
#groundPanel button {
  background: #1a73e8;
  color: white;
  font-weight: 600;
  border: 1px solid #1557b0;
  transition: all 0.2s ease;
}

#groundPanel button:hover {
  background: #1557b0;
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

/* --- PEATLAND LAYER STYLING --- */
/* Peatland SVG paths - allow pointer events to pass through for CO2 tooltips */
.peatland-layer path {
  pointer-events: none;
}

/* Peatland layer pane - ensure it stays above CO2 layer */
.leaflet-pane.peatland-pane {
  z-index: 450 !important;
}

/* --- LOADING SPINNER --- */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(26, 115, 232, 0.2);
  border-top: 3px solid #1a73e8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Chat Action Button (Zoom, Export) */
.chat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  margin-top: 8px;
  margin-right: 6px;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-action-btn:hover {
  background: #f0f7ff;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.chat-action-btn svg {
  width: 14px;
  height: 14px;
}

/* Chat Sparkline */
.chat-sparkline {
  display: block;
  margin-top: 8px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.5);
  padding: 4px;
}

.chat-sparkline path {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== EXTRACTED INLINE STYLES ===== */

/* Loading overlay */
.page-loading-overlay {
  transition: opacity 0.4s ease;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.page-loading-overlay .loading-inner {
  text-align: center;
}

.page-loading-overlay .logo-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-loading-overlay .logo-spinner {
  position: absolute;
  width: 120px;
  height: 120px;
  border-width: 4px;
}

.page-loading-overlay .logo-img {
  width: 65px;
  height: 80px;
  position: relative;
  z-index: 1;
}

.page-loading-overlay .loading-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a73e8;
  margin-bottom: 8px;
}

.page-loading-overlay .loading-subtitle {
  font-size: 12px;
  color: #5f6368;
}

.loading-progress-bar {
  width: 200px;
  height: 4px;
  background: rgba(26, 115, 232, 0.15);
  border-radius: 2px;
  margin: 14px auto 0;
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s ease;
}

/* Ground station buttons */
.btn-station-active {
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
  padding: 12px;
  font-size: 13px;
  width: 100%;
}

.btn-station-active:hover {
  background: #1557b0;
  color: white;
}

.mobile-menu-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 400;
  display: none;
  background: var(--primary);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(26, 115, 232, 0.3);
  align-items: center;
  justify-content: center;
}

.forecast-play-btn {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #1557b0;
  background: #1a73e8;
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  width: 100%;
  transition: background 0.2s;
}

.forecast-play-btn:hover {
  background: #1557b0;
}

/* Modal overlay base */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content-base {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

/* Modal header */
.modal-header-gradient {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
  color: white;
  padding: 24px;
  border-radius: 16px 16px 0 0;
  z-index: 10;
}

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

.modal-header-gradient h2 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 700;
}

.modal-header-gradient .modal-subtitle {
  margin: 8px 0 0 0;
  font-size: 13px;
  opacity: 0.9;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  min-height: auto;
  min-width: auto;
  padding: 0;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* FAQ modal */
.faq-modal-wrapper {
  width: 95%;
  max-width: 1100px;
  max-height: 90vh;
}

.faq-section {
  margin-top: 28px;
}

.faq-section h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #1a73e8;
  margin: 0 0 16px 0;
  border-bottom: 2px solid #e8f0fe;
  padding-bottom: 8px;
}

.faq-item {
  margin-bottom: 20px;
}

.faq-item h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: #202124;
}

.faq-item p {
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  color: #5f6368;
}

.faq-item ul {
  font-size: 13px;
  line-height: 1.8;
  margin: 8px 0 0 20px;
  color: #5f6368;
}

/* Methods modal */
.methods-modal-wrapper {
  width: 95%;
  max-width: 1100px;
  max-height: 90vh;
}

.methods-section {
  margin-bottom: 28px;
}

.methods-section h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #1a73e8;
  margin: 0 0 16px 0;
  border-bottom: 2px solid #e8f5e9;
  padding-bottom: 8px;
}

.methods-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: #202124;
}

.methods-section p {
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  color: #5f6368;
}

.methods-tab-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #f5f5f5;
  border-bottom: 2px solid #e0e0e0;
  gap: 0;
}

.methods-tab-btn {
  padding: 16px 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  border-bottom: 3px solid transparent;
  transition: all 0.3s;
  white-space: normal;
  text-align: center;
  min-height: auto;
}

.methods-content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Trend analysis modal */
.trend-modal-wrapper {
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  overflow-y: auto;
}

.trend-modal-body {
  padding: 24px;
  color: #202124;
}

.trend-chart-container {
  height: 500px;
  width: 100%;
  margin-bottom: 16px;
}

.trend-chart-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #666;
}

/* Data source badge */
.data-source-badge {
  display: none;
  background: rgba(227, 116, 0, 0.9);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

/* Chat panel */
.chat-panel {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  max-width: 90vw;
  display: none;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.8);
  z-index: 250;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.chat-header-label {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.chat-messages {
  height: 250px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 8px;
  font-size: 12px;
}

.chat-welcome {
  color: var(--text-muted);
  padding: 8px;
}

.chat-welcome-title {
  margin-bottom: 8px;
  font-weight: 600;
}

.chat-welcome-subtitle {
  margin-bottom: 10px;
  font-size: 11px;
}

.chat-welcome-examples {
  font-size: 11px;
  line-height: 1.5;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 8px;
}

.chat-quick-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 4px 0;
}

.chat-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  font-size: 12px;
}

.chat-btn-small {
  padding: 4px;
  border-radius: 6px;
  font-size: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  min-height: auto;
  min-width: auto;
}

.chat-btn-lang {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #f5f5f5;
  color: #666;
  font-size: 11px;
  font-weight: 600;
  width: 35px;
}

.chat-btn-send {
  border: none;
  background: var(--primary);
  color: white;
}

.chat-btn-clear {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #f5f5f5;
  color: #666;
}

.chat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.chat-status {
  font-size: 10px;
  color: var(--text-muted);
}

.chat-disclaimer {
  font-size: 10px;
  color: #1565c0;
  font-weight: 600;
}

/* Ground station buttons */
.ground-btn-active {
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.ground-btn-active:hover {
  background: #1557b0;
}

.ground-btn-disabled {
  background: rgba(255, 255, 255, 0.7);
  color: rgba(0, 0, 0, 0.4);
  cursor: not-allowed;
  pointer-events: none;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-weight: 600;
}

/* Gas toggle buttons */
.gas-toggle-btn {
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.gas-btn-co2 { background: #4ecdc4; color: white; }
.gas-btn-co { background: #ff6b6b; color: white; }
.gas-btn-ch4 { background: #ffa502; color: white; }

/* Methods tech tags */
.tech-tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* Output product cards */
.output-card {
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.output-card .icon { font-size: 24px; margin-bottom: 4px; }
.output-card .name { font-size: 12px; font-weight: 600; }
.output-card .desc { font-size: 11px; color: #5f6368; }

/* Workflow step cards */
.workflow-card {
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.workflow-card .icon { font-size: 20px; margin-bottom: 4px; }
.workflow-card .name { font-size: 12px; font-weight: 600; }
.workflow-card .desc { font-size: 10px; color: #5f6368; }

/* Quick tips box */
.quick-tips-box {
  margin-top: 28px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #1a73e8;
}

/* Limitations/caveats box */
.caveats-box {
  padding: 16px;
  background: #fff8e1;
  border-radius: 8px;
  border-left: 4px solid #ffc107;
}

.interpretation-box {
  padding: 16px;
  background: #e3f2fd;
  border-radius: 8px;
  border-left: 4px solid #1565c0;
}

/* Model info box */
.model-info-box {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

/* Code formula display */
.formula-display {
  background: #f5f5f5;
  border-left: 3px solid #1a73e8;
  padding: 12px;
  margin: 8px 0;
  font-family: monospace;
  font-size: 12px;
  color: #333;
  overflow-x: auto;
}

/* Image grid */
.image-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.image-grid-2col .img-cell {
  text-align: center;
}

.image-grid-2col img {
  width: 100%;
  max-width: 400px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-grid-2col .img-caption {
  font-size: 11px;
  color: #888;
  margin-top: 8px;
}

/* Measurement spec table */
.spec-table {
  width: 100%;
  border-collapse: collapse;
}

.spec-table th {
  text-align: left;
  padding: 10px;
  border: 1px solid #ddd;
  font-size: 12px;
  font-weight: 600;
  color: #1a73e8;
  background: #f5f5f5;
}

.spec-table td {
  padding: 10px;
  border: 1px solid #ddd;
  font-size: 12px;
  color: #444;
}

.spec-table tr:nth-child(even) {
  background: #fafafa;
}

/* Boxplot section header row */
.boxplot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 12px 0;
}

.boxplot-header h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}

.boxplot-header .gas-toggles {
  display: flex;
  gap: 6px;
}

/* Station info text */
.station-info h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
}

.station-info p {
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  color: #555;
}

/* Modeling panel buttons */
.modeling-btn-group {
  gap: 10px;
}

.panel-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modeling-btn {
  padding: 12px;
  width: 100%;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  transition: background 0.2s;
}

.modeling-btn-primary {
  background: #1a73e8;
  color: white;
  border: 1px solid #1557b0;
}

.modeling-btn-primary:hover {
  background: #1557b0;
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

.modeling-btn-disabled {
  background: #e8e8e8;
  color: #333;
  opacity: 0.6;
  cursor: not-allowed;
}

/* Accessible focus styles */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Skip to content link (screen reader) */
.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;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  z-index: 10000;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  top: 0;
}

/* Live region for screen readers */
.sr-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}