/* ==========================================================================
   EarthLens — Earth Time Machine (time_machine.css)
   Plataforma Científica de Observación Terrestre (NASA Space Apps 2026)
   - Tema oscuro azul marino, negro y gris con acentos celestes discretos.
   - Header compacto con los 4 selectores alineados en una única fila horizontal.
   - Timeline inferior flotante centrado (~70% viewport) de baja altura.
   - Rieles laterales flotantes minimalistas y protagonismo total del mapa.
   ========================================================================== */

:root {
  --tm-bg-deep: #080c14;
  --tm-panel-bg: rgba(10, 15, 26, 0.80);
  --tm-panel-solid: rgba(12, 18, 30, 0.94);
  --tm-panel-elevated: rgba(19, 28, 46, 0.90);
  --tm-border-subtle: rgba(148, 163, 184, 0.18);
  --tm-border-active: rgba(56, 189, 248, 0.55);
  --tm-text-primary: #e2e8f0;
  --tm-text-muted: #94a3b8;
  --tm-accent-steel: #2563eb;
  --tm-accent-cyan: #38bdf8;
  --tm-accent-highlight: #7dd3fc;
  --tm-radius-sm: 6px;
  --tm-radius-md: 10px;
  --tm-radius-lg: 12px;
  --tm-control-height: 32px;

  /* Dimensiones fluidas para controles laterales */
  --tm-btn-size: clamp(30px, 3.8vmin, 34px);
  --tm-icon-size: clamp(14px, 2vmin, 16px);
  --tm-rail-gap: 4px;
  --tm-edge-offset: clamp(8px, 1.1vmin, 12px);
}

/* Cuerpo e inmersión a pantalla completa (corrige min-height: 100vh en Chrome móvil iOS/Android) */
html,
.tm-viewport-body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: 0 !important;
  max-height: var(--app-height, 100dvh);
  margin: 0;
  padding: 0;
  background: var(--tm-bg-deep);
  color: var(--tm-text-primary);
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
}

/* Logo discreto en esquina inferior izquierda (fondo 100% transparente, solo icono y letras) */
.tm-brand-watermark {
  position: absolute;
  bottom: 12px;
  left: 14px;
  z-index: 20;
  pointer-events: none;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: none;
  box-shadow: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

.tm-brand-watermark svg {
  color: var(--tm-accent-cyan);
  opacity: 0.9;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.85));
}

.tm-brand-watermark-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: rgba(248, 250, 252, 0.92);
}

.tm-brand-watermark-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7dd3fc;
  background: transparent;
  border: none;
  padding: 0;
}

@media (max-width: 1100px) {
  .tm-brand-watermark {
    display: none;
  }
}

/* Escenario principal con el mapa como protagonista absoluto */
.tm-stage-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--tm-bg-deep);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--tm-edge-offset);
  padding: calc(var(--tm-edge-offset) + env(safe-area-inset-top, 0px))
    calc(var(--tm-edge-offset) + env(safe-area-inset-right, 0px))
    calc(var(--tm-edge-offset) + env(safe-area-inset-bottom, 0px))
    calc(var(--tm-edge-offset) + env(safe-area-inset-left, 0px));
}

/* Mapa satelital ocupando todo el lienzo */
#timeMachineMap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: var(--tm-bg-deep);
}

/* Capa de interpolación espectral sobre el mapa satelital */
.leaflet-satellite-weather-pane {
  filter: blur(20px) saturate(1.3) contrast(1.06);
  mix-blend-mode: screen;
  pointer-events: none;
}

/* Integración visual de controles nativos de Leaflet al tema oscuro */
.leaflet-control-zoom,
.leaflet-control-layers {
  border: 1px solid var(--tm-border-subtle) !important;
  border-radius: var(--tm-radius-sm) !important;
  background: var(--tm-panel-bg) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4) !important;
  color: var(--tm-text-primary) !important;
}

.leaflet-control-zoom a {
  background: transparent !important;
  color: var(--tm-text-primary) !important;
  border-bottom-color: var(--tm-border-subtle) !important;
  width: 28px !important;
  height: 28px !important;
  line-height: 28px !important;
  font-size: 14px !important;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.leaflet-control-zoom a:hover {
  background: rgba(56, 189, 248, 0.16) !important;
  color: var(--tm-accent-highlight) !important;
}

.leaflet-control-layers-expanded {
  padding: 6px 10px !important;
  background: var(--tm-panel-solid) !important;
  color: var(--tm-text-primary) !important;
  font-size: 0.74rem !important;
}

.leaflet-control-attribution {
  background: rgba(8, 12, 20, 0.65) !important;
  color: var(--tm-text-muted) !important;
  font-size: 0.62rem !important;
  border-radius: 4px 0 0 0;
  padding: 1px 6px !important;
}

.leaflet-control-attribution a {
  color: var(--tm-accent-highlight) !important;
}

/* Iconos vectoriales limpios */
.tm-svg-icon {
  width: var(--tm-icon-size);
  height: var(--tm-icon-size);
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

.tm-svg-icon-sm {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

/* ==========================================================================
   1. PANEL SUPERIOR: Texto de telemetría arriba + 4 Selectores en fila abajo
   ========================================================================== */
.tm-hud-top {
  position: relative;
  z-index: 530;
  flex-shrink: 0;
  width: 100%;
  pointer-events: none;
}

.tm-hud-panel {
  pointer-events: auto;
  background: var(--tm-panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-md);
  padding: 0.38rem 0.75rem;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.38);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.tm-hud-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

.tm-telemetry-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
}

.tm-location-heading {
  font-size: 0.84rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.tm-meta-divider {
  color: rgba(148, 163, 184, 0.35);
  font-size: 0.75rem;
}

.tm-telemetry-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.32);
  color: var(--tm-accent-highlight);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.14rem 0.42rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.tm-telemetry-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tm-accent-cyan);
  box-shadow: 0 0 6px var(--tm-accent-cyan);
}

.tm-meta-subline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.68rem;
  color: var(--tm-text-muted);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.25;
}

.tm-meta-highlight {
  color: #cbd5e1;
  font-weight: 500;
}

.tm-meta-sep {
  margin: 0 0.32rem;
  color: rgba(148, 163, 184, 0.45);
}

/* Fila inferior del header: los 4 selectores en una única fila horizontal */
.tm-top-filters-collapse {
  display: flex;
  align-items: center;
  width: 100%;
}

.tm-selectors-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

/* Tamaño, altura y estética uniforme para los 4 controles superiores */
.tm-hud-select,
.tm-hud-control-uniform {
  height: 30px;
  min-height: 30px;
  background-color: var(--tm-panel-elevated);
  color: var(--tm-text-primary);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.2;
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.tm-hud-select {
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 0.55rem;
  padding-right: 1.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.tm-select-city {
  flex: 0 1 235px;
  min-width: 140px;
}

.tm-select-var {
  flex: 0 1 235px;
  min-width: 140px;
}

.tm-select-mode {
  flex: 0 1 210px;
  min-width: 130px;
}

.tm-period-dropdown {
  flex-shrink: 0;
}

.tm-hud-control-uniform {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.tm-hud-select:hover,
.tm-hud-control-uniform:hover {
  background-color: rgba(28, 41, 66, 0.95);
  border-color: rgba(56, 189, 248, 0.42);
  color: #ffffff;
}

.tm-hud-select:focus,
.tm-hud-control-uniform:focus {
  background-color: #162136;
  color: #ffffff;
  border-color: var(--tm-accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
  outline: none;
}

/* Botón general HUD */
.tm-hud-btn {
  background: var(--tm-panel-elevated);
  color: var(--tm-text-primary);
  border: 1px solid var(--tm-border-subtle);
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--tm-radius-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tm-hud-btn:hover {
  background: rgba(30, 45, 72, 0.95);
  color: #ffffff;
  border-color: var(--tm-border-active);
}

/* Botón toggle en móvil */
.tm-bar-toggle {
  width: var(--tm-control-height);
  height: var(--tm-control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--tm-panel-elevated);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
  color: var(--tm-text-primary);
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tm-bar-toggle.is-active,
.tm-bar-toggle:hover {
  background: rgba(37, 99, 235, 0.35);
  border-color: var(--tm-accent-cyan);
  color: #ffffff;
}

.tm-dropdown-panel {
  background: var(--tm-panel-solid);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-md);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}

.tm-input-dark {
  background: var(--tm-panel-elevated);
  color: var(--tm-text-primary);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
}

.tm-input-dark:focus {
  background: #162136;
  color: #ffffff;
  border-color: var(--tm-accent-cyan);
  box-shadow: none;
}

.tm-action-btn {
  background: rgba(37, 99, 235, 0.85);
  color: #ffffff;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--tm-radius-sm);
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.tm-action-btn:hover {
  background: #2563eb;
  color: #ffffff;
}

/* Adaptación responsive del panel superior */
@media (max-width: 1099.98px) and (min-width: 768px) {
  .tm-hud-panel {
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  .tm-hud-info-row {
    width: 100%;
  }
  .tm-top-filters-collapse {
    width: 100%;
  }
  .tm-selectors-row {
    width: 100%;
    flex-wrap: nowrap;
  }
  .tm-select-city,
  .tm-select-var,
  .tm-select-mode {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
  }
}

@media (max-width: 767.98px) {
  .tm-hud-panel {
    flex-wrap: wrap;
    padding: 0.38rem 0.6rem;
  }
  .tm-hud-info-row {
    width: 100%;
  }
  .tm-top-filters-collapse {
    display: none;
    width: 100%;
    padding-top: 0.45rem;
    margin-top: 0.3rem;
    border-top: 1px solid var(--tm-border-subtle);
  }
  .tm-top-filters-collapse.is-open {
    display: block;
  }
  .tm-selectors-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
  }
  .tm-select-city,
  .tm-select-var,
  .tm-select-mode,
  .tm-period-dropdown,
  .tm-period-dropdown .tm-hud-control-uniform {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 420px) {
  .tm-selectors-row {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   2. ÁREA CENTRAL Y CONTROLES LATERALES INTEGRADOS
   ========================================================================== */
.tm-hud-middle {
  position: relative;
  z-index: 510;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tm-edge-offset);
  pointer-events: none;
}

/* Docks laterales flotantes, compactos y semitransparentes */
.tm-icon-rail {
  position: relative;
  z-index: 520;
  display: flex;
  flex-direction: column;
  gap: var(--tm-rail-gap);
  max-height: 100%;
  min-height: 0;
  flex-shrink: 0;
  pointer-events: auto;
  background: var(--tm-panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-md);
  padding: 4px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.38);
}

.tm-rail-left {
  align-items: center;
}

.tm-rail-right {
  align-items: center;
}

/* Botón cabecera para plegar/desplegar el riel */
.tm-rail-handle {
  pointer-events: auto;
  position: relative;
  width: var(--tm-btn-size);
  height: 20px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 5px;
  color: var(--tm-accent-highlight);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tm-rail-handle:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: var(--tm-accent-cyan);
  color: #ffffff;
}

.tm-chevron-icon {
  transition: transform 0.2s ease;
}

.tm-icon-rail.is-Expanded .tm-chevron-icon,
.tm-icon-rail.is-expanded .tm-chevron-icon {
  transform: rotate(180deg);
}

.tm-rail-items {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: var(--tm-rail-gap);
  min-height: 0;
  max-height: calc(100% - 24px);
  align-content: flex-start;
}

.tm-rail-right .tm-rail-items {
  align-content: flex-end;
}

.tm-icon-rail:not(.is-expanded) .tm-rail-items {
  display: none !important;
}

.tm-rail-divider {
  height: 1px;
  width: calc(var(--tm-btn-size) - 6px);
  background: var(--tm-border-subtle);
  margin: 2px auto;
  flex-shrink: 0;
}

.tm-icon-btn {
  pointer-events: auto;
  position: relative;
  width: var(--tm-btn-size);
  height: var(--tm-btn-size);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--tm-radius-sm);
  color: var(--tm-text-primary);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.tm-icon-btn:hover {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--tm-accent-highlight);
}

.tm-icon-btn.is-active {
  background: rgba(37, 99, 235, 0.32);
  border-color: var(--tm-accent-cyan);
  color: #ffffff;
}

/* Contador discreto sobre el icono de anomalías */
.tm-icon-counter {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 13px;
  height: 13px;
  padding: 0 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.52rem;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
  background: #0284c7;
  color: #ffffff;
  border-radius: 6px;
}

/* Tooltips discretos para los botones laterales */
.tm-icon-btn::after,
.tm-rail-handle::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: var(--tm-panel-solid);
  color: #f1f5f9;
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
  padding: 0.25rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 500;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.14s ease;
  z-index: 950;
}

.tm-icon-btn[data-tooltip-pos="left"]::after,
.tm-rail-handle[data-tooltip-pos="left"]::after {
  left: auto;
  right: calc(100% + 10px);
}

.tm-icon-btn:hover::after,
.tm-icon-btn:focus-visible::after,
.tm-rail-handle:hover::after,
.tm-rail-handle:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

/* Manijas de vértice con alta visibilidad para el cuadrante editable */
.tm-resize-handle {
  width: 12px !important;
  height: 12px !important;
  background: var(--tm-accent-cyan);
  border: 2px solid #080c14;
  border-radius: 3px;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.38), 0 2px 6px rgba(0, 0, 0, 0.75);
  cursor: nwse-resize;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.tm-resize-handle:hover {
  background: #bae6fd;
  transform: scale(1.22);
}

/* Contenedor central para ventanitas emergentes */
.tm-hud-center {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.tm-popup-window {
  pointer-events: auto;
  position: relative;
  width: min(720px, 100%);
  max-height: 100%;
  z-index: 650;
  background: var(--tm-panel-solid);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--tm-radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tmWindowPop 0.16s ease-out;
}

@keyframes tmWindowPop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tm-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: rgba(19, 28, 46, 0.85);
  border-bottom: 1px solid var(--tm-border-subtle);
  font-size: 0.82rem;
  flex-shrink: 0;
}

.tm-window-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--tm-accent-highlight);
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.1rem 0.38rem;
  border-radius: 4px;
  margin-right: 0.35rem;
}

.tm-stat-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.66rem;
  color: var(--tm-text-primary);
  background: rgba(25, 37, 58, 0.9);
  border: 1px solid var(--tm-border-subtle);
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
}

.tm-popup-body {
  padding: 0.7rem 0.85rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.tm-popup-desc {
  font-size: 0.73rem;
  color: var(--tm-text-muted);
}

.tm-chart-box {
  position: relative;
  height: clamp(165px, 31dvh, 265px);
  width: 100%;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--tm-radius-sm);
  padding: 0.4rem;
}

.tm-section-caption {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tm-accent-highlight);
}

.tm-subpanel {
  background: rgba(19, 28, 46, 0.75);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
  padding: 0.45rem 0.65rem;
}

.tm-border-left-cool {
  border-left: 3px solid var(--tm-accent-cyan);
}

.tm-border-left-warm {
  border-left: 3px solid #d97757;
}

.tm-micro-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  color: var(--tm-text-muted);
  letter-spacing: 0.05em;
}

.tm-accent-warm {
  color: #e08263;
  font-weight: 600;
}

.tm-accent-cool {
  color: var(--tm-accent-highlight);
  font-weight: 600;
}

.tm-anomaly-card {
  background: rgba(19, 28, 46, 0.75);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
  padding: 0.45rem 0.65rem;
  color: var(--tm-text-primary);
  transition: border-color 0.15s ease;
}

.tm-anomaly-card.is-selected {
  border-color: var(--tm-accent-cyan);
}

/* ==========================================================================
   3. TIMELINE INFERIOR: Panel flotante compacto (~70% viewport) y centrado
   ========================================================================== */
.tm-bottom-bar {
  position: relative;
  z-index: 520;
  flex-shrink: 0;
  width: min(70vw, 940px);
  margin: 0 auto 2px auto;
  align-self: center;
  pointer-events: none;
  transition: width 0.2s ease;
}

.tm-bottom-panel {
  pointer-events: auto;
  background: var(--tm-panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-lg);
  padding: 0.35rem 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
}

/* Micro-fila superior de leyenda espectral */
.tm-bottom-topstrip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.22rem;
  margin-bottom: 0.26rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.tm-inline-scale {
  width: auto;
  flex-shrink: 0;
}

.tm-legend-title {
  font-size: 0.64rem;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
}

.tm-legend-meta {
  font-size: 0.6rem;
  color: var(--tm-text-muted);
  white-space: nowrap;
}

.tm-legend-bound {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  color: var(--tm-text-muted);
}

.tm-color-scale-bar {
  width: 68px;
  min-width: 56px;
  flex: 0 0 68px;
  height: 6px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

/* Rampas espectrales */
.tm-scale-thermal {
  background: linear-gradient(90deg, #1b2a4a 0%, #2b5c8f 22%, #3d8c95 42%, #7ca968 60%, #d4a349 78%, #c86432 90%, #9e2a2b 100%);
}

.tm-scale-precip {
  background: linear-gradient(90deg, #6b4c35 0%, #a67c52 24%, #b8a868 44%, #4f9d89 64%, #2e779d 82%, #244b7a 100%);
}

.tm-scale-humidity {
  background: linear-gradient(90deg, #7c5836 0%, #b58952 28%, #9fb398 50%, #3b8ea5 76%, #1f4e78 100%);
}

.tm-scale-wind {
  background: linear-gradient(90deg, #162234 0%, #2a5679 28%, #3c829e 52%, #7b6b9e 78%, #a84a6c 100%);
}

.tm-bottom-handle {
  background: transparent;
  border: 1px solid var(--tm-border-subtle);
  color: var(--tm-text-muted);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.tm-bottom-handle:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--tm-accent-cyan);
  color: #ffffff;
}

.tm-bottom-bar:not(.is-expanded) #tmClimateStripes,
.tm-bottom-bar:not(.is-expanded) .tm-slider-caption,
.tm-bottom-bar:not(.is-expanded) #tmCellHudInfo {
  display: none !important;
}

.tm-bottom-bar.is-expanded .tm-bottom-handle .tm-chevron-icon {
  transform: rotate(180deg);
}

/* Fila principal del timeline compacto */
.tm-timeline-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
}

.tm-readout-block {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  min-width: 0;
}

.tm-readout-details {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
  min-width: 0;
}

.tm-year-readout {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.1rem, 1.8vw, 1.38rem);
  font-weight: 700;
  line-height: 1;
  color: #f8fafc;
  letter-spacing: -0.02em;
}

.tm-active-val {
  font-size: clamp(0.75rem, 1.15vw, 0.88rem);
  white-space: nowrap;
}

.tm-anom-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.06rem 0.32rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  white-space: nowrap;
}

.tm-condition-label {
  font-size: 0.62rem;
  color: var(--tm-text-muted);
  white-space: nowrap;
}

.tm-v-divider {
  width: 1px;
  height: 26px;
  background: var(--tm-border-subtle);
  flex-shrink: 0;
}

.tm-transport-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.tm-transport-btn {
  width: 27px;
  height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--tm-panel-elevated);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
  color: var(--tm-text-primary);
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tm-transport-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--tm-border-active);
  color: #ffffff;
}

.tm-play-btn {
  width: 31px;
  height: 31px;
  border-radius: var(--tm-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 99, 235, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.42);
  color: #ffffff;
  flex-shrink: 0;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.tm-play-btn:hover {
  background: #2563eb;
  color: #ffffff;
}

/* Barra deslizante temporal */
.tm-slider-wrapper {
  flex: 1 1 auto;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tm-slider-caption {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  color: var(--tm-text-muted);
  letter-spacing: 0.03em;
  line-height: 1;
  margin-bottom: 2px;
}

.tm-slider-title {
  color: rgba(148, 163, 184, 0.7);
  font-size: 0.55rem;
}

.tm-year-slider {
  width: 100%;
  height: 5px;
  accent-color: var(--tm-accent-cyan);
  cursor: pointer;
  margin: 2px 0;
}

.tm-stripes-bar {
  display: flex;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.2);
  margin-top: 2px;
}

.tm-stripe-item {
  flex: 1;
  height: 100%;
  cursor: pointer;
}

.tm-stripe-item:hover {
  filter: brightness(1.2);
}

.tm-stripe-item.is-active {
  box-shadow: inset 0 0 0 1.5px #ffffff;
}

/* Controles de velocidad 0.5x, 1x y 2x */
.tm-speed-group {
  flex-shrink: 0;
  display: inline-flex;
}

.tm-speed-btn {
  background: var(--tm-panel-elevated);
  color: var(--tm-text-muted);
  border: 1px solid var(--tm-border-subtle);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.64rem;
  line-height: 1;
  padding: 0.26rem 0.4rem;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.tm-speed-btn:first-child {
  border-top-left-radius: var(--tm-radius-sm) !important;
  border-bottom-left-radius: var(--tm-radius-sm) !important;
}

.tm-speed-btn:last-child {
  border-top-right-radius: var(--tm-radius-sm) !important;
  border-bottom-right-radius: var(--tm-radius-sm) !important;
}

.tm-speed-btn.active,
.tm-speed-btn:hover {
  background: rgba(37, 99, 235, 0.45);
  color: #ffffff;
  border-color: var(--tm-accent-cyan);
}

.tm-sat-city-tooltip {
  background: var(--tm-panel-solid) !important;
  border: 1px solid rgba(56, 189, 248, 0.45) !important;
  color: #f8fafc !important;
  border-radius: var(--tm-radius-sm) !important;
  padding: 0.24rem 0.5rem !important;
  font-size: 0.72rem !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5) !important;
}

/* Responsividad del Timeline Inferior */
@media (max-width: 1199.98px) and (min-width: 768px) {
  .tm-bottom-bar {
    width: min(86vw, 860px);
  }
}

@media (max-width: 767.98px) {
  .tm-stage-wrapper {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .tm-bottom-bar {
    width: 100%;
    margin-bottom: 2px;
  }
  .tm-bottom-panel {
    padding: 0.32rem 0.5rem;
    border-radius: var(--tm-radius-md);
  }
  .tm-bottom-topstrip {
    padding-bottom: 0.16rem;
    margin-bottom: 0.2rem;
  }
  .tm-timeline-main {
    flex-wrap: wrap;
    gap: 0.32rem;
  }
  .tm-year-readout {
    font-size: 1.05rem;
  }
  .tm-readout-block {
    order: 1;
    gap: 0.4rem;
  }
  .tm-transport-group {
    order: 2;
    margin-left: auto;
    gap: 0.22rem;
  }
  .tm-speed-group {
    order: 3;
  }
  .tm-slider-wrapper {
    order: 4;
    flex: 1 1 100%;
    width: 100%;
    margin-top: 2px;
  }
  /* Elevar controles de capas/zoom de Leaflet en móvil para que no queden tapados por el timeline inferior */
  .leaflet-bottom.leaflet-right {
    bottom: 112px !important;
  }
  .leaflet-control-attribution {
    display: none !important;
  }
  .tm-icon-btn::after,
  .tm-rail-handle::after {
    font-size: 0.64rem;
    padding: 0.18rem 0.42rem;
  }
}
/* Estado científico visible sin reemplazar la interfaz recibida de main. */
.tm-data-notice{position:fixed;bottom:150px;left:16px;max-width:min(650px,calc(100vw - 32px));z-index:1100;background:#fff;color:#17334a;padding:8px 12px;border:1px solid #cbd5e1;border-radius:8px;font-size:12px;box-shadow:0 2px 8px #0002}
.tm-data-notice[data-error=true]{color:#9b1c1c;border-color:#dc2626}
.tm-source-link{position:fixed;left:16px;bottom:225px;z-index:1101;background:#fff;padding:6px 10px;border-radius:6px}




/* ============================================================================
   Módulo 05: Proyección, Probabilidades de Anomalías y Conclusiones
   ============================================================================ */
.tm-popup-window-wide {
  width: min(920px, 100%);
}

.tm-counter-danger {
  background: #dc2626;
  color: #ffffff;
}

.tm-stat-pill.is-success {
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}
.tm-stat-pill.is-warning {
  border-color: rgba(245, 158, 11, 0.55);
  color: #fcd34d;
}
.tm-stat-pill.is-danger {
  border-color: rgba(239, 68, 68, 0.55);
  color: #fca5a5;
}

.tm-fc-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: flex-end;
  background: rgba(19, 28, 46, 0.72);
  border: 1px solid var(--tm-border-subtle);
  border-radius: var(--tm-radius-sm);
  padding: 0.45rem 0.65rem;
}

.tm-fc-ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tm-fc-year-in {
  width: 74px;
}

.tm-fc-thr-in {
  width: 78px;
}

.tm-fc-dir-sel {
  width: auto;
  min-width: 118px;
}

.tm-fc-quick.active {
  background: rgba(56, 189, 248, 0.22);
  border-color: rgba(56, 189, 248, 0.6);
  color: #ffffff;
}

.tm-fc-status {
  font-size: 0.74rem;
  padding: 0.3rem 0.55rem;
  border-radius: var(--tm-radius-sm);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}
.tm-fc-status.is-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.tm-fc-chart-box {
  height: clamp(150px, 24dvh, 220px);
}

.tm-fc-prob-table {
  font-size: 0.72rem;
}
.tm-fc-prob-table th {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tm-text-muted);
  border-bottom-color: var(--tm-border-subtle);
}
.tm-fc-prob-table td {
  border-bottom-color: rgba(148, 163, 184, 0.12);
  padding: 0.32rem 0.4rem;
}

.tm-fc-event-name {
  font-weight: 600;
  color: var(--tm-text-primary);
  line-height: 1.2;
}

.tm-fc-event-thr {
  font-size: 0.64rem;
  color: var(--tm-text-muted);
}

.tm-fc-prob-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.72rem;
}

.tm-fc-bar {
  width: 64px;
  height: 5px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}

.tm-fc-bar-fill {
  height: 100%;
  border-radius: 3px;
}
.tm-fc-bar-fill.is-warm {
  background: linear-gradient(90deg, #f59e0b, #dc2626);
}
.tm-fc-bar-fill.is-cool {
  background: linear-gradient(90deg, #38bdf8, #2563eb);
}
.tm-fc-bar-fill.is-neutral {
  background: linear-gradient(90deg, #64748b, #38bdf8);
}

.tm-fc-rr {
  display: inline-block;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.14);
  font-size: 0.68rem;
}
.tm-fc-rr.is-danger {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
}
.tm-fc-rr.is-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}
.tm-fc-rr.is-success {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

.tm-fc-conclusions-list {
  max-height: 270px;
  overflow-y: auto;
}

.tm-fc-conclusion {
  background: rgba(19, 28, 46, 0.78);
  border: 1px solid var(--tm-border-subtle);
  border-left: 3px solid var(--tm-accent-cyan);
  border-radius: var(--tm-radius-sm);
  padding: 0.4rem 0.55rem;
}
.tm-fc-conclusion.is-danger {
  border-left-color: #ef4444;
  background: rgba(127, 29, 29, 0.2);
}
.tm-fc-conclusion.is-warning {
  border-left-color: #f59e0b;
  background: rgba(120, 53, 15, 0.18);
}
.tm-fc-conclusion.is-success {
  border-left-color: #10b981;
}

.tm-fc-conclusion-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--tm-text-primary);
  margin-bottom: 0.12rem;
}

.tm-fc-conclusion-text {
  font-size: 0.7rem;
  color: var(--tm-text-muted);
  line-height: 1.35;
}
