:root {
  --bg: #0a0b0e;
  --surface: #12151c;
  --surface-2: #1a1f28;
  --text: #f0f2f5;
  --muted: #8b939e;
  --border: rgba(255, 255, 255, 0.07);
  --plex-red: #ff2e2e;
  --plex-red-dim: #c41e1e;
  --plex-amber: #ffb020;
  --plex-glow: rgba(255, 46, 46, 0.35);
  --v1: #6eb2e8;
  --v2: #2ecc71;
  --v3: #e8c547;
  --header-h: auto;
  --video-frame-max: min(102vh, 1440px);
  --video-panel-width: min(624px, 58vw);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

/* ——— Cabecera corporativa PLEX ——— */
.plex-header {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.7rem;
  padding: 0.85rem 1.25rem 0.85rem;
  color: var(--text);
  background: linear-gradient(180deg, var(--surface) 0%, #0e1118 100%);
  border-bottom: 3px solid var(--plex-red);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

/* Imagen en HTML (ruta respecto a index.html): evita fallos de url() en CSS con file:// */
.plex-header__decor {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Velo uniforme al 85 % sobre el mapa (color cabecera --surface) + brillo suave arriba */
.plex-header__decor::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, transparent 12%),
    rgba(18, 21, 28, 0.85);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.plex-header__decor-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  display: block;
}

.plex-header__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  width: 100%;
  position: relative;
  z-index: 1;
}

.plex-header__left,
.plex-header__right {
  position: relative;
}

.plex-wordmark {
  display: inline-flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  line-height: 1;
}

.plex-wordmark__main {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(1.35rem, 3.8vw, 2.35rem);
  letter-spacing: 0.06em;
  line-height: 1.05;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75), 0 0 1px rgba(0, 0, 0, 0.9);
}

.plex-wordmark__sub {
  font-family: "Bebas Neue", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--plex-amber);
  margin-top: 0.2rem;
}

.plex-tagline {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  max-width: 22rem;
  line-height: 1.4;
}

.plex-header__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.plex-header__filters-block {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.plex-header__filters-block .plex-header-credit {
  align-self: flex-end;
  margin: 0;
}

.plex-header-credit {
  margin: 0;
  padding: 0;
  max-width: min(24rem, 100%);
  font-size: 0.65rem;
  line-height: 1.35;
  text-align: right;
}

.plex-header-credit__inner {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem 0.45rem;
}

.plex-header-credit__sep {
  opacity: 0.45;
  user-select: none;
}

.plex-header-credit__ig {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.plex-header-credit__ig-icon {
  width: 0.8rem;
  height: 0.8rem;
  flex-shrink: 0;
  opacity: 0.88;
}

.plex-header-credit__ip {
  color: var(--muted);
}

.plex-header-credit__ip a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 147, 158, 0.35);
  transition: color 0.12s ease, border-color 0.12s ease;
}

.plex-header-credit__ip a:hover {
  color: var(--v1);
  border-bottom-color: rgba(110, 178, 232, 0.55);
}

.plex-header-credit a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 147, 158, 0.35);
  transition: color 0.12s ease, border-color 0.12s ease;
}

.plex-header-credit a:hover {
  color: var(--v1);
  border-bottom-color: rgba(110, 178, 232, 0.55);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot--v1 {
  background: var(--v1);
  box-shadow: 0 0 10px rgba(110, 178, 232, 0.55);
}

.legend-dot--v2 {
  background: var(--v2);
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

.legend-dot--v3 {
  background: var(--v3);
  box-shadow: 0 0 10px rgba(232, 197, 71, 0.55);
}

.plex-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.48rem 0.95rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 6px;
  text-decoration: none;
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

/* Botón enlazado al canal: rojo YouTube + icono */
.plex-cta--youtube {
  color: #fff;
  background: linear-gradient(180deg, #ff0303 0%, #c90000 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 2px 14px rgba(255, 0, 0, 0.32);
}

.plex-cta__icon {
  flex-shrink: 0;
  display: block;
  opacity: 0.98;
}

.plex-cta__label {
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.plex-cta__handle {
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Mini wordmark estilo YouTube (aprox. visual; no es el logo oficial) */
.plex-cta__yt-mark {
  display: inline-flex;
  align-items: center;
  font-size: 0.62em;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
}

.plex-cta__yt-you {
  color: #fff;
}

.plex-cta__yt-tube {
  margin-left: 1px;
  padding: 0.14em 0.32em 0.12em;
  background: #fff;
  color: #ff0000;
  border-radius: 2px;
}

.plex-cta:hover {
  filter: brightness(1.08);
}

.plex-cta:active {
  transform: scale(0.98);
}

/* ——— Mapa + panel ——— */
.app-shell {
  flex: 1;
  display: flex;
  min-height: 0;
  width: 100%;
}

.map-column {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.map-filters--header {
  width: 100%;
  max-width: none;
}

.map-filters__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.65rem;
  padding: 0.55rem 0.7rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.map-filters__field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.map-filters__field--grow {
  flex: 1 1 160px;
}

.map-filters__label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.map-filters__select {
  min-width: 8rem;
  max-width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.map-filters__select:focus {
  outline: 2px solid var(--plex-red);
  outline-offset: 1px;
}

.map-filters__btn {
  padding: 0.42rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.map-filters__btn:hover {
  background: rgba(255, 46, 46, 0.12);
  border-color: rgba(255, 46, 46, 0.35);
}

.map-legend-float {
  position: absolute;
  left: 12px;
  bottom: 28px;
  z-index: 1000;
  padding: 0.5rem 0.65rem;
  background: rgba(18, 21, 28, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.map-legend-float__title {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.map-legend-float__list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.7rem;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.map-legend-float__list li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.video-panel {
  width: var(--video-panel-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
  overflow-y: auto;
}

.video-panel__top {
  padding: 1.1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface) 100%);
}

.video-panel__label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--plex-red);
  margin-bottom: 0.35rem;
}

.video-panel__title {
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.45rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
  font-weight: 400;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.video-panel__meta {
  margin: 0.55rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

.video-panel__frame {
  flex: 1;
  min-height: 240px;
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  max-height: var(--video-frame-max);
  width: 100%;
}

.video-panel__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text);
  background-color: #0a0b0e;
  background-image: linear-gradient(
      to bottom,
      rgba(10, 11, 14, 0.45) 0%,
      rgba(10, 11, 14, 0.72) 100%
    ),
    url("video-placeholder-bg.png");
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.video-panel__placeholder p {
  margin: 0;
  max-width: 16rem;
  font-weight: 600;
  line-height: 1.35;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85), 0 0 1px rgba(0, 0, 0, 0.95);
}

.video-panel__placeholder.is-hidden {
  display: none;
}

.video-panel__placeholder-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--plex-red), var(--plex-red-dim));
  color: var(--text);
  box-shadow: 0 0 24px var(--plex-glow);
}

.video-panel__placeholder-icon svg {
  margin-left: 3px;
}

.video-panel__iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-panel__iframe.is-hidden {
  display: none;
}

.video-panel__actions {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--border);
}

#video-panel-actions[hidden] {
  display: none !important;
}

.plex-btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: 0.65rem 1rem;
  font-size: 0.8125rem;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.plex-btn--primary {
  color: var(--bg);
  background: linear-gradient(180deg, #fff 0%, #e2e4e8 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.plex-btn--primary:hover {
  filter: brightness(1.05);
}

.plex-btn--primary:active {
  transform: scale(0.99);
}

.video-panel__footer {
  margin-top: auto;
  padding: 0.75rem 1.15rem;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

.plex-footer-note-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.4rem;
  width: 100%;
  min-width: 0;
}

.plex-footer-note {
  flex: 1;
  min-width: 0;
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.35;
  text-align: left;
}

.plex-info-tip {
  position: relative;
  flex-shrink: 0;
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.05rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.plex-info-tip:hover,
.plex-info-tip:focus-visible {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.35);
  outline: none;
}

.plex-info-tip:focus-visible {
  box-shadow: 0 0 0 2px var(--plex-red);
}

.plex-info-tip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: min(15.5rem, calc(100vw - 2.5rem));
  padding: 0.5rem 0.65rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 500;
  font-style: normal;
  font-family: inherit;
  line-height: 1.4;
  color: var(--text);
  text-align: left;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.plex-info-tip::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 4px);
  right: 0.28rem;
  border: 6px solid transparent;
  border-top-color: var(--surface-2);
  filter: drop-shadow(0 1px 0 var(--border));
  opacity: 0;
  visibility: hidden;
  z-index: 6;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.plex-info-tip:hover::after,
.plex-info-tip:focus-visible::after,
.plex-info-tip:hover::before,
.plex-info-tip:focus-visible::before {
  opacity: 1;
  visibility: visible;
}

.leaflet-container {
  background: var(--bg);
  font-family: inherit;
}

.leaflet-control-attribution {
  font-size: 9px;
  line-height: 1.35;
  opacity: 0.55;
  background: rgba(10, 14, 18, 0.75) !important;
  color: #6b7280 !important;
  border-radius: 4px 0 0 0;
}

.leaflet-control-attribution a {
  color: #8b939e !important;
}

.leaflet-control-attribution a:hover {
  color: var(--text) !important;
}

.leaflet-tooltip.plex-map-tooltip {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.leaflet-tooltip.plex-map-tooltip::before {
  border-top-color: var(--surface-2);
}

@media (max-width: 900px) {
  html {
    -webkit-text-size-adjust: 100%;
    height: auto;
    min-height: 100%;
  }

  body {
    overflow: auto;
    overflow-x: hidden;
    height: auto;
    min-height: 100dvh;
    min-height: 100svh;
  }

  .app-shell {
    flex-direction: column;
    flex: 1 0 auto;
    min-height: 0;
  }

  /* El #map / Cesium son position:absolute: sin min-height la columna colapsa y el mapa desaparece */
  .map-column {
    flex: 1 1 auto;
    min-height: max(220px, 42vh);
    width: 100%;
  }

  .video-panel {
    width: 100%;
    flex: 0 1 auto;
    border-left: none;
    border-top: 2px solid var(--plex-red);
    box-shadow: none;
  }

  .video-panel__frame {
    max-height: min(58vh, var(--video-frame-max));
    aspect-ratio: 16 / 9;
  }

  .plex-header__right {
    align-items: flex-start;
    width: 100%;
  }

  .plex-header-credit {
    text-align: left;
    max-width: none;
  }

  .plex-header-credit__inner {
    justify-content: flex-start;
  }

  .plex-header__filters-block .plex-header-credit {
    align-self: flex-start;
  }

  .legend {
    justify-content: flex-start;
  }

  .map-filters__select {
    min-width: 0;
  }

  .plex-cta--youtube {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Móvil estrecho + landscape: más mapa, vídeo más bajo */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .map-column {
    min-height: max(200px, 58vh);
  }

  .video-panel__frame {
    max-height: min(43vh, 288px);
  }
}

@media (max-width: 640px) {
  .plex-header {
    padding: max(0.65rem, env(safe-area-inset-top, 0px)) max(0.85rem, env(safe-area-inset-right, 0px))
      0.75rem max(0.85rem, env(safe-area-inset-left, 0px));
    gap: 0.55rem;
  }

  .plex-header__decor-img {
    object-position: center 35%;
  }

  .plex-header__top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .plex-wordmark__main {
    font-size: clamp(1.2rem, 6.5vw, 2rem);
  }

  .plex-tagline {
    max-width: none;
  }

  .plex-cta--youtube {
    width: 100%;
    justify-content: center;
    padding: 0.55rem 0.85rem;
    font-size: 0.68rem;
  }

  .map-filters__row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 0.45rem 0.5rem;
    padding: 0.5rem 0.55rem;
  }

  .map-filters__field--grow {
    grid-column: 1 / -1;
    flex: none;
  }

  .map-filters__btn {
    grid-column: 1 / -1;
    width: 100%;
    padding: 0.5rem 0.65rem;
  }

  .map-filters__select {
    width: 100%;
  }

  .map-legend-float {
    left: 8px;
    bottom: 10px;
    padding: 0.4rem 0.5rem;
    max-width: min(11rem, calc(100vw - 20px));
  }

  .map-legend-float__list {
    font-size: 0.62rem;
    gap: 0.2rem;
  }

  .video-panel__top {
    padding: 0.85rem 0.9rem 0.65rem;
  }

  .video-panel__title {
    font-size: 1.2rem;
  }

  .video-panel__meta {
    font-size: 0.78rem;
  }

  .video-panel__actions,
  .video-panel__footer {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }
}
