/* ==========================================================================
   RainViewer 3D Japan - Premium Dark Glassmorphism Design System
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-deep: #070a12;
  --panel-bg: rgba(15, 23, 42, 0.78);
  --panel-bg-hover: rgba(30, 41, 59, 0.85);
  --panel-border: rgba(255, 255, 255, 0.12);
  --panel-border-bright: rgba(255, 255, 255, 0.25);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #00d2ff;
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(0, 210, 255, 0.35);
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  /* Fonts */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --shadow-panel: 0 16px 36px -8px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-glow: 0 0 20px rgba(0, 210, 255, 0.45);
  --shadow-btn: 0 4px 14px rgba(0, 0, 0, 0.35);

  /* Transitions */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* ==========================================================================
   CesiumJS 3D Globe Container & Overrides
   ========================================================================== */
#globeContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: var(--bg-deep);
  overflow: hidden;
}

#globeContainer .cesium-viewer,
#globeContainer .cesium-widget,
#globeContainer .cesium-widget canvas {
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

/* Cesium Credits subtle positioning */
.cesium-widget-credits {
  font-size: 10px !important;
  color: rgba(255, 255, 255, 0.4) !important;
  background: rgba(5, 8, 17, 0.6) !important;
  backdrop-filter: blur(8px);
  padding: 2px 8px !important;
  border-radius: var(--radius-sm);
  z-index: 2 !important;
  bottom: 6px !important;
  right: 12px !important;
  left: auto !important;
}
.cesium-widget-credits a {
  color: var(--accent-cyan) !important;
  text-decoration: none;
}
.cesium-widget-credits a:hover {
  text-decoration: underline;
}

/* Header Observation Time */
.header-obs-time {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* ==========================================================================
   Shared Glassmorphism Panel
   ========================================================================== */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-panel);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
}

/* ==========================================================================
   App Header
   ========================================================================== */
.app-header {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  height: 60px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-radius: var(--radius-md);
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.logo-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 210, 255, 0.4);
}

.logo-icon {
  font-size: 18px;
  color: #fff;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(90deg, #ffffff 40%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.app-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Region Navigation Pills */
.region-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  scrollbar-width: none;
}
.region-nav::-webkit-scrollbar {
  display: none;
}

.region-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.region-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.region-btn.active {
  background: linear-gradient(135deg, var(--accent-blue) 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.45);
}

/* Header Right Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 5px 11px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-emerald);
  font-family: var(--font-display);
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.live-indicator:hover {
  background: rgba(16, 185, 129, 0.25);
  transform: translateY(-1px);
}

.live-indicator.archive-mode {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.live-indicator.archive-mode .live-dot {
  background-color: #fbbf24;
  box-shadow: 0 0 8px #fbbf24;
  animation: none;
}

.icon-btn.active-mode {
  background: rgba(245, 158, 11, 0.22);
  border-color: #fbbf24;
  color: #fbbf24;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-live 1.8s infinite;
}

@keyframes pulse-live {
  0% { transform: scale(0.9); opacity: 0.8; box-shadow: 0 0 4px var(--accent-emerald); }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px var(--accent-emerald); }
  100% { transform: scale(0.9); opacity: 0.8; box-shadow: 0 0 4px var(--accent-emerald); }
}

/* Icon Buttons */
.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 14px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--panel-border-bright);
  transform: translateY(-1px);
}

.icon-btn.small {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

/* ==========================================================================
   Weather Layer Floating Navigation (Top Sub-bar)
   ========================================================================== */
.weather-layer-nav {
  position: absolute;
  top: 84px;
  left: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  max-width: calc(100vw - 32px);
  overflow-x: auto;
  scrollbar-width: none;
  animation: fade-down 0.3s ease-out;
}
.weather-layer-nav::-webkit-scrollbar {
  display: none;
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.layer-nav-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-right: 6px;
  border-right: 1px solid var(--panel-border);
  white-space: nowrap;
}

.layer-nav-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.layer-pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.layer-pill-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: var(--panel-border-bright);
}

.layer-pill-btn.active {
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.22) 0%, rgba(37, 99, 235, 0.35) 100%);
  border-color: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(0, 210, 255, 0.35);
}

.layer-pill-btn.active i {
  color: var(--accent-cyan);
}

/* Badges on layer buttons */
.provider-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  letter-spacing: 0.2px;
}
.provider-tag.free {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.provider-tag.owm {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.provider-tag.nasa {
  background: rgba(59, 130, 246, 0.28);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.48);
}

/* ==========================================================================
   Settings Panel (Drawer)
   ========================================================================== */
.settings-panel {
  position: absolute;
  top: 86px;
  right: 16px;
  width: 350px;
  max-height: calc(100vh - 100px - 90px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
  transform: translateX(390px);
  opacity: 0;
  pointer-events: none;
}

.settings-panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

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

.panel-header h2 {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
}

.panel-content {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.panel-content::-webkit-scrollbar {
  width: 6px;
}
.panel-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.setting-title-with-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

/* Weather Selector Grid in Settings */
.weather-selector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.weather-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-secondary);
}

.weather-card i {
  font-size: 16px;
  color: var(--accent-cyan);
}

.weather-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--panel-border-bright);
  color: #fff;
}

.weather-card.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 210, 255, 0.12);
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.25);
}

.weather-card-name {
  font-size: 12px;
  font-weight: 600;
}

.weather-card-sub {
  font-size: 10px;
  color: var(--text-muted);
}

/* OpenWeatherMap API Settings Box */
.owm-config-group {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.api-status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.api-status-badge.unconfigured {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.4);
}
.api-status-badge.configured {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.api-input-wrap {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.input-with-icon {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.custom-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 8px 32px 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: monospace;
  outline: none;
  transition: border-color var(--transition-fast);
}
.custom-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.3);
}

.icon-btn-tiny {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 11px;
  transition: color var(--transition-fast);
}
.icon-btn-tiny:hover {
  color: #fff;
}

.btn-primary-small {
  background: linear-gradient(135deg, var(--accent-blue) 0%, #2563eb 100%);
  border: none;
  color: #fff;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.btn-primary-small:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4);
}

.api-links-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 11px;
}

.api-link {
  color: var(--accent-cyan);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: text-decoration var(--transition-fast);
}
.api-link:hover {
  text-decoration: underline;
}

.text-link-danger {
  background: transparent;
  border: none;
  color: var(--accent-rose);
  cursor: pointer;
  font-size: 11px;
  text-decoration: underline;
}
.text-link-danger.hidden {
  display: none;
}


/* Basemap Cards Grid */
.basemap-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.basemap-card {
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.basemap-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--panel-border-bright);
}

.basemap-card.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 210, 255, 0.12);
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.25);
}

.basemap-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--accent-emerald);
  color: #fff;
}
.basemap-badge.dark {
  background: #6366f1;
}

.basemap-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.basemap-sub {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Control Row & Sliders */
.control-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-with-val {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.value-badge {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.custom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Custom Select Dropdowns */
.custom-select {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.custom-select:focus {
  border-color: var(--accent-cyan);
}
.custom-select option {
  background: #1e293b;
  color: #fff;
}

/* Toggle Switches */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-slider {
  width: 38px;
  height: 20px;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  position: relative;
  transition: background-color var(--transition-fast);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  left: 2px;
  top: 2px;
  background-color: #fff;
  transition: transform var(--transition-fast);
}

.toggle-item input:checked + .toggle-slider {
  background-color: var(--accent-blue);
}

.toggle-item input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* Segmented Buttons */
.btn-segmented {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 4px;
}

.seg-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.seg-btn:hover {
  color: #fff;
}

.seg-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ==========================================================================
   Legend Panel
   ========================================================================== */
.legend-panel {
  position: absolute;
  bottom: 185px;
  right: 16px;
  width: 260px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 11px;
  transition: all var(--transition-normal);
}

.legend-panel.collapsed .legend-content {
  display: none;
}

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

.legend-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
  transition: color var(--transition-fast);
}
.mini-btn:hover {
  color: #fff;
}

.legend-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.legend-bar-wrapper {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-gradient-bar {
  width: 100%;
  height: 100%;
  /* Default Universal Blue gradient */
  background: linear-gradient(to right, 
    rgba(0, 180, 255, 0.5) 0%,
    rgba(0, 130, 255, 0.8) 25%,
    rgba(0, 220, 80, 0.9) 50%,
    rgba(255, 215, 0, 1) 75%,
    rgba(255, 30, 0, 1) 90%,
    rgba(200, 0, 255, 1) 100%
  );
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 600;
}

.snow-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 5px;
  margin-top: 2px;
}

.snow-chip {
  width: 12px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(to right, #00ffff, #a855f7);
}

/* ==========================================================================
   Bottom Floating Time & Archive Control Panel
   ========================================================================== */
.status-floating-panel {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 860px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-panel), 0 0 28px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all var(--transition-normal);
}

.status-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 260px;
}

.pulse-status-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0, 210, 255, 0.12);
  border: 1px solid rgba(0, 210, 255, 0.35);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.pulse-status-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse-glow 2s infinite ease-in-out;
}

.pulse-status-badge.archive-badge {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.45);
}

.pulse-status-badge.archive-badge .status-dot {
  background-color: #fbbf24;
  box-shadow: 0 0 8px #fbbf24;
}

.pulse-status-badge .status-region-label {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-display);
}

.status-text-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-time-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
}

.status-obs-title {
  color: var(--text-secondary);
  font-size: 12px;
}

.status-timestamp {
  font-family: var(--font-display);
  color: #fff;
  font-weight: 700;
}

.status-relative {
  font-size: 11px;
  color: var(--accent-cyan);
  font-weight: 600;
}

.status-relative.archive-tag {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

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

.status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mode Switcher Segmented Tabs */
.time-mode-tabs {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 3px;
}

.mode-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.mode-tab-btn:hover {
  color: #fff;
}

.mode-tab-btn.active[data-mode="live"] {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.32) 0%, rgba(5, 150, 105, 0.48) 100%);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.28);
}

.mode-tab-btn.active[data-mode="archive"] {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.3) 0%, rgba(217, 119, 6, 0.45) 100%);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.28);
}

.refresh-pill-btn {
  background: linear-gradient(135deg, #00d2ff 0%, #2563eb 100%);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 210, 255, 0.35);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.refresh-pill-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 210, 255, 0.55);
}

.refresh-pill-btn:active {
  transform: translateY(1px);
}

/* Sub-bar A: LIVE Recent 2h Timeline */
.timeline-subbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.timeline-subbar.hidden,
.archive-subbar.hidden {
  display: none !important;
}

.timeline-controls-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tl-icon-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  transition: all var(--transition-fast);
}

.tl-icon-btn.small {
  width: 26px;
  height: 26px;
  font-size: 10px;
}

.tl-icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: var(--panel-border-bright);
}

.tl-play-btn {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, #2563eb 100%);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  box-shadow: 0 2px 10px rgba(0, 210, 255, 0.4);
  transition: all var(--transition-fast);
}

.tl-play-btn.archive-play {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4);
}

.tl-play-btn:hover {
  transform: scale(1.06);
}

.timeline-slider-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-labels-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
}

.tl-bound-label {
  color: var(--text-muted);
  font-weight: 600;
  font-family: var(--font-display);
}

.tl-frame-badge {
  color: var(--accent-cyan);
  font-weight: 700;
  background: rgba(0, 210, 255, 0.12);
  border: 1px solid rgba(0, 210, 255, 0.28);
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
}

.tl-frame-badge.nowcast {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
}

.tl-pill-mini {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tl-pill-mini:hover {
  background: rgba(0, 210, 255, 0.18);
  color: #fff;
  border-color: var(--accent-cyan);
}

/* Sub-bar B: Archive Calendar & Time Picker */
.archive-subbar {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 9px;
  border-top: 1px solid rgba(245, 158, 11, 0.25);
}

.archive-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.archive-field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
}

.archive-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.archive-field label i {
  color: #fbbf24;
}

.archive-input {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  color-scheme: dark;
  transition: border-color var(--transition-fast);
}

.archive-input:focus,
.archive-input:hover {
  border-color: #fbbf24;
}

.archive-input option {
  background: #0f172a;
  color: #fff;
}

.preset-field {
  flex: 1;
  min-width: 210px;
}

.preset-select {
  width: 100%;
  text-overflow: ellipsis;
}

.utc-sub-badge {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.archive-scrubber-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.archive-step-btns {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tl-step-chip {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tl-step-chip:hover {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.5);
}

.archive-intraday-slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}

.intraday-bound {
  font-size: 10px;
  font-family: var(--font-display);
  color: var(--text-muted);
  font-weight: 600;
}

.archive-slider::-webkit-slider-thumb {
  background: #fbbf24;
  box-shadow: 0 0 10px #fbbf24;
}


/* ==========================================================================
   Modals & Overlays
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

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

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-body strong {
  color: #fff;
}

.modal-body h4 {
  font-size: 13px;
  color: #fff;
  font-weight: 700;
  margin-top: 4px;
}

.modal-body ul {
  padding-left: 18px;
}

.modal-body li {
  margin-bottom: 6px;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

kbd {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.credits-list a {
  color: var(--accent-cyan);
  text-decoration: none;
}
.credits-list a:hover {
  text-decoration: underline;
}

/* API Key Guide Box inside Modal */
.owm-guide-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 210, 255, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.owm-guide-box h4 {
  font-size: 13px;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
}

.guide-steps {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.guide-steps li {
  line-height: 1.5;
}

.highlight-link {
  color: var(--accent-cyan);
  font-weight: 600;
  text-decoration: underline;
}

.guide-notice {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}
.guide-notice i {
  color: var(--accent-amber);
  margin-top: 2px;
}

.modal-api-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.modal-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, #2563eb 100%);
  border: none;
  color: #fff;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 210, 255, 0.35);
  transition: all var(--transition-fast);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 210, 255, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 10, 18, 0.7);
  backdrop-filter: blur(8px);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-normal);
}

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

.loading-spinner-box {
  padding: 24px 32px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.spinner-pulse {
  color: var(--accent-cyan);
  animation: pulse-spin 1.5s ease-in-out infinite;
}

@keyframes pulse-spin {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

#loadingStatusText {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1100px) {
  .region-nav {
    max-width: 380px;
  }
  .app-subtitle {
    display: none;
  }
}

@media (max-width: 820px) {
  .region-nav {
    max-width: 260px;
  }
}

@media (max-width: 640px) {
  .region-nav {
    display: none;
  }
  .app-header {
    height: 52px;
    padding: 0 10px;
    top: 8px;
    left: 8px;
    right: 8px;
  }
  .app-title {
    font-size: 15px;
  }
  .app-subtitle {
    display: none;
  }
  .settings-panel {
    width: calc(100% - 16px);
    right: 8px;
    top: 68px;
  }
  .legend-panel {
    display: none; /* Auto hide legend on phone portrait */
  }
  .status-floating-panel {
    width: calc(100% - 16px);
    bottom: 8px;
    padding: 8px 12px;
  }
  .status-note {
    display: none;
  }
  .status-obs-title {
    display: none;
  }
  .shortcuts-grid {
    grid-template-columns: 1fr;
  }
  .weather-layer-nav {
    top: 66px;
    left: 8px;
    max-width: calc(100vw - 16px);
    padding: 4px 8px;
  }
  .layer-nav-label {
    display: none;
  }
  .layer-pill-btn {
    padding: 5px 10px;
    font-size: 11px;
  }
}

