html, body { margin: 0; height: 100%; background: var(--stage, #f1efe9); overflow: hidden; touch-action: none; font-family: var(--f-ui, Inter, system-ui, sans-serif); }
#map { position: fixed; inset: 0; background: var(--stage, #f1efe9); }
#map canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
/* controles sobre el mapa: superficie sólida, 44 px, icono Lucide (web/ui/DESIGN.md) */
#zoom { position: fixed; right: calc(12px + env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 5; display: flex; flex-direction: row; gap: 6px; transition: opacity .2s var(--ease); }
#zoom button {
  width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  color: var(--fg); background: var(--raised); -webkit-tap-highlight-color: transparent;
}
#zoom button:active { background: var(--surface); }

/* ── MAP-01: mini-mapa ─────────────────────────────────────────────────────
   Superficie sólida, sin sombra, esquinas pequeñas. Abajo a la derecha,
   encima de los botones de zoom (que van en pareja horizontal). */
.tv-minimap {
  position: fixed; right: calc(12px + env(safe-area-inset-right)); bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 5;
  width: 112px; height: 112px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: var(--r-ctl, 8px);
  background: var(--raised); overflow: hidden; cursor: crosshair;
  touch-action: none; transition: opacity .2s var(--ease);
}
.tv-minimap img { width: 100%; height: 100%; display: block; object-fit: fill; image-rendering: pixelated; pointer-events: none; }
.tv-minimap-view {
  position: absolute; box-sizing: border-box; border: 2px solid var(--acc-line, #d8a13a);
  background: color-mix(in srgb, var(--acc-line, #d8a13a) 18%, transparent);
  pointer-events: none;
}
@media (max-width: 700px) { .tv-minimap { width: 88px; height: 88px; right: calc(8px + env(safe-area-inset-right)); bottom: calc(56px + env(safe-area-inset-bottom)); } }

/* ── MAP-01: panel de capas ─────────────────────────────────────────────── */
.tv-layers { position: fixed; z-index: 9; top: 64px; right: 12px; }
.tv-layers-btn {
  width: var(--tap, 44px); height: var(--tap, 44px); display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r-ctl, 8px);
  background: var(--raised); color: var(--fg); cursor: pointer;
}
.tv-layers-pop {
  display: none; position: fixed; z-index: 11; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(400px, calc(100vw - 24px)); max-height: 74vh; overflow-y: auto;
  padding: var(--sp-4); box-sizing: border-box; overscroll-behavior: contain;
  border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-panel, 12px) var(--r-panel, 12px) 0 0;
  background: var(--raised); color: var(--fg); flex-direction: column; gap: 2px;
  font: var(--w-400, 400) var(--fs-label, 14px)/1.4 var(--f-ui, sans-serif);
  padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
}
.tv-layers-pop.is-open { display: flex; }
.tv-layers-pop h2 { margin: 0 0 var(--sp-3); padding-right: var(--tap); font-size: var(--fs-title); font-weight: var(--w-600); }
.tv-layers-close { position: absolute; top: 10px; right: 10px; width: var(--tap); height: var(--tap); display: grid; place-items: center; border: 0; border-radius: var(--r-ctl); background: none; color: var(--fg-2); cursor: pointer; }
.tv-layers-close:hover { background: var(--surface); color: var(--fg); }
.tv-layer {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 52px; width: 100%;
  padding: var(--sp-1) var(--sp-2); border: 0; border-radius: var(--r-ctl);
  background: transparent; color: var(--fg);
  font: var(--w-500, 500) var(--fs-label, 14px)/1.3 var(--f-ui, sans-serif);
  cursor: pointer; text-align: left;
}
.tv-layer:hover { background: var(--surface); }
.tv-layer .lu { color: var(--fg-2); }
.tv-layer-label { flex: 1; min-width: 0; }
.tv-layer-switch { position: relative; flex: none; width: 44px; height: 28px; border: 0; border-radius: 14px; background: var(--sunk); }
.tv-layer-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--raised); transition: transform .2s var(--ease); }
.tv-layer.is-on .tv-layer-switch { background: var(--acc-line); }
.tv-layer.is-on .tv-layer-switch::after { transform: translateX(16px); background: var(--raised); }

/* marcadores de capa sobre el isométrico */
.tv-lmark {
  width: 22px; height: 22px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--raised); color: var(--fg); cursor: pointer;
  transform: translateY(-50%);
}
.tv-lmark.is-bus { border-color: #3d6a96; color: #3d6a96; }
.tv-lmark.is-train { border-color: #6b4d8a; color: #6b4d8a; }
.tv-lmark.is-park { border-color: #2f7d4f; color: #2f7d4f; }
.tv-lmark.is-cam { border-color: #9a5b2d; color: #9a5b2d; }
.tv-lmark.is-event { border-color: var(--acc, #d8a13a); color: #8a6414; }
.tv-ltoast {
  position: fixed; z-index: 30; left: 50%; bottom: 96px; transform: translate(-50%, 12px);
  max-width: min(420px, calc(100vw - 32px)); padding: 10px 14px;
  border-radius: var(--r-ctl, 8px); background: var(--fg); color: var(--raised);
  font: var(--w-500, 500) var(--fs-label, 14px)/1.35 var(--f-ui, sans-serif);
  opacity: 0; pointer-events: none; transition: opacity .2s var(--ease, ease), transform .2s var(--ease, ease);
  white-space: pre-line;
}
.tv-ltoast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── MAP-01: ortofoto real (PNOA) ───────────────────────────────────────── */
.tv-layers-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.tv-layer-sat.is-on::after { background: #3d6a96; }
.tv-sat { position: fixed; inset: 0; z-index: 7; display: none; background: var(--bg); }
.tv-sat-map { position: absolute; inset: 0; }
.tv-sat-close {
  position: absolute; z-index: 1000; top: 12px; left: 12px; width: var(--tap, 44px); height: var(--tap, 44px);
  display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r-ctl, 8px);
  background: var(--raised); color: var(--fg); cursor: pointer;
}
.tv-sat .leaflet-control-attribution { font: 11px/1.3 var(--f-ui, sans-serif); }
body.is-sat #zoom, body.is-sat .tv-minimap { display: none; }
body.is-sat .tv-settings-open, body.is-sat .tv-time-quick, body.is-sat .tv-tour-open,
body.is-sat .tv-today-open, body.is-sat .tv-view, body.is-sat #about-open { display: none; }

/* HUD v5: centered dock, live event chip, and a clear bottom-right corner. */
.tv-dock {
  position: fixed; z-index: 6; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; padding: 4px;
  border: 1px solid var(--line); border-radius: var(--r-panel, 12px); background: var(--raised);
}
.tv-dock button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap, 44px); width: 150px; padding: 0 var(--sp-4, 16px);
  border: 0; border-radius: var(--r-ctl, 8px); background: none; color: var(--fg);
  font: var(--w-600) var(--fs-label, 14px)/1 var(--f-ui); cursor: pointer; white-space: nowrap;
}
.tv-dock button:hover { background: var(--surface); }
.tv-dock button .lu { display: block; flex: none; }
.tv-dock .tv-dock-sep { width: 1px; height: 28px; background: var(--line); }
.tv-dock-label-short { display: none; }
.tv-event-chip {
  position: fixed; z-index: 6; left: calc(12px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap, 44px); max-width: 300px; padding: 0 var(--sp-3, 12px);
  border: 1px solid var(--line); border-radius: var(--r-panel, 12px); background: var(--raised); color: var(--fg);
  font: var(--w-500) var(--fs-label, 14px)/1 var(--f-ui); cursor: pointer; text-align: left;
}
.tv-event-chip .lu { color: var(--accent-5); flex: none; }
#tv-event-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* The dock activates these existing controls without displaying a duplicate. */
body .tv-tour-open, body .tv-today-open { display: none; }
.tv-dock, .tv-event-chip { transition: opacity .2s var(--ease), transform .2s var(--ease); }
body.is-sat .tv-dock, body.is-sat .tv-event-chip { display: none; }
.tv-dock button:focus-visible, .tv-event-chip:focus-visible, .tv-layers-btn:focus-visible,
.tv-layer:focus-visible, .tv-layers-close:focus-visible, #zoom button:focus-visible { outline: 2px solid var(--accent-5); outline-offset: 2px; }
@media (max-width: 1000px) and (min-width: 701px) {
  .tv-dock button { width: 120px; padding: 0 var(--sp-3); }
  .tv-event-chip { max-width: 190px; }
}
@media (max-width: 700px) {
  .tv-dock { bottom: calc(10px + env(safe-area-inset-bottom)); }
  .tv-dock button { width: 96px; padding: 0 var(--sp-2, 8px); gap: 6px; }
  .tv-dock-label { display: none; }
  .tv-dock-label-short { display: inline; }
  .tv-event-chip { left: calc(8px + env(safe-area-inset-left)); bottom: calc(10px + env(safe-area-inset-bottom)); max-width: calc(50vw - 122px); }
  .tv-layers-pop { width: 100vw; max-width: none; max-height: calc(100dvh - 72px - env(safe-area-inset-top)); }
}
@media (max-width: 480px) {
  .tv-dock button { width: 56px; padding: 0; }
  .tv-dock-label-short { display: none; }
  .tv-event-chip { width: var(--tap); justify-content: center; padding: 0; }
  #tv-event-label { display: none; }
}
