:root {
  --fondo: #0b1d2a; --panel: #10283a; --panel-2: #163349; --borde: #23445c;
  --texto: #e8f1f5; --tenue: #8fb0c2; --rosa: #ff4f9a; --cian: #2de1d8; --amarillo: #ffc845;
  --radio: 12px; --top: 56px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fondo); color: var(--texto); }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--cian); }
[hidden] { display: none !important; }
.tenue { color: var(--tenue); }

/* Barra superior */
.topbar {
  height: calc(var(--top) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, #0d2233, #1a1036); border-bottom: 1px solid var(--borde);
  position: relative; z-index: 1000;
}
.marca { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--texto); font-size: 18px; white-space: nowrap; }
.marca b { background: linear-gradient(90deg, var(--rosa), var(--amarillo)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.buscar { flex: 1 1 auto; min-width: 0; max-width: 460px; display: flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--borde); border-radius: 999px; padding: 0 12px; }
.buscar input { flex: 1; background: none; border: 0; color: var(--texto); height: 36px; outline: none; font-size: 15px; min-width: 0; }
.acciones { display: flex; gap: 8px; margin-left: auto; }

.btn { border: 1px solid var(--borde); background: var(--panel-2); border-radius: 999px; padding: 8px 14px; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--cian); }
.btn.primario { background: linear-gradient(90deg, var(--rosa), #ff7a59); border-color: transparent; color: #fff; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.ok { background: #14532d; border-color: #22c55e; }
.btn.fav { background: #4a3a0b; border-color: var(--amarillo); }
.btn:disabled { opacity: .6; cursor: wait; }
.link { background: none; border: 0; padding: 0; color: var(--cian); text-decoration: underline; font-size: inherit; }
.cerrar { background: none; border: 0; font-size: 18px; color: var(--tenue); padding: 4px 8px; }

/* Layout */
.layout { position: relative; height: calc(100% - var(--top) - env(safe-area-inset-top)); display: flex; }
.panel { width: 340px; flex-shrink: 0; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--borde); padding: 12px; }
.mapa-wrap { position: relative; flex: 1; }
#map { position: absolute; inset: 0; background: #0d2f47; }
body.agregando #map, body.agregando .leaflet-interactive { cursor: crosshair; }

.bloque { margin-bottom: 14px; }
.bloque-cab { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 14px; }
.campo { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--tenue); margin-bottom: 10px; }
.campo input, .campo select, .campo textarea {
  background: var(--panel-2); color: var(--texto); border: 1px solid var(--borde); border-radius: 8px; padding: 9px 10px; font: inherit; font-size: 15px;
}
.campo textarea { resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--cian); outline-offset: 0; }
.contador { align-self: flex-end; }
.fila-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.grupo { margin-bottom: 8px; }
.grupo-nombre { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--tenue); margin: 6px 0 4px; }
.chip {
  --c: var(--cian);
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 10px; font-size: 13px;
  background: transparent; border: 1px solid var(--borde); color: var(--tenue); opacity: .65;
}
.chip.on { opacity: 1; color: var(--texto); border-color: var(--c); background: color-mix(in srgb, var(--c) 22%, transparent); }
.chip em { font-style: normal; font-size: 11px; color: var(--tenue); }
.chip.mini { font-size: 12px; padding: 4px 9px; }

.lista { list-style: none; margin: 0; padding: 0; }
.lista button { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; border-radius: 8px; padding: 7px 6px; text-align: left; }
.lista button:hover, .lista button.sel { background: var(--panel-2); }
.lista .ico { --c: #999; width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 35%, #0b1d2a); border: 2px solid var(--c); font-size: 15px; }
.lista .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lista .txt b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista .txt small { color: var(--tenue); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista .marcas { font-size: 12px; color: var(--amarillo); white-space: nowrap; }
.lista .vacio { color: var(--tenue); font-size: 13px; padding: 10px 4px; }
.aviso { font-size: 11px; color: var(--tenue); line-height: 1.5; border-top: 1px solid var(--borde); padding-top: 10px; }

/* Marcadores */
.pin {
  --c: #999; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 40%, #0b1d2a); border: 2.5px solid var(--c);
  box-shadow: 0 2px 8px rgba(0,0,0,.55); font-size: 15px; transition: transform .15s;
}
.pin span { filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); line-height: 1; }
#map[data-z=lejos] .pin { transform: scale(.55); }
#map[data-z=medio] .pin { transform: scale(.78); }
#map[data-z] .pin.sel { transform: scale(1.35); }
.rotulo { pointer-events: none; }
.rotulo span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font: 700 11px/1 'Arial Narrow', Arial, sans-serif;
  letter-spacing: .06em; text-transform: uppercase; color: #fff; text-shadow: 0 0 3px #000, 0 0 6px #000; opacity: 0; transition: opacity .2s; }
#map.ver-rotulos .rotulo span { opacity: .85; }
.pin.rumor { border-style: dashed; }
.pin.comunidad { box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 2px 8px rgba(0,0,0,.55); }
.pin.hecho { opacity: .45; }
.pin.sel { transform: scale(1.35); box-shadow: 0 0 0 4px var(--amarillo), 0 4px 14px rgba(0,0,0,.6); z-index: 9; }
.pin.nuevo { --c: var(--rosa); animation: latido 1s infinite; }
@keyframes latido { 50% { transform: scale(1.2); } }
.leaflet-tooltip { background: #0d2233; color: var(--texto); border: 1px solid var(--borde); font-weight: 600; }
.leaflet-tooltip-top:before { border-top-color: #0d2233; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { background: rgba(11,29,42,.75) !important; color: var(--tenue) !important; font-size: 10px; }
.leaflet-bar a { background: var(--panel); color: var(--texto); border-color: var(--borde); }

.banda {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 800;
  background: var(--rosa); color: #fff; border-radius: 999px; padding: 6px 6px 6px 16px; display: flex; gap: 10px; align-items: center;
  font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: calc(100% - 24px); font-size: 14px;
}
.banda .btn { color: #fff; border-color: rgba(255,255,255,.6); }
.leyenda-precision { position: absolute; left: 10px; bottom: 22px; z-index: 700; font-size: 11px; background: rgba(11,29,42,.8); padding: 4px 10px; border-radius: 999px; color: var(--tenue); }

/* Ficha */
.ficha { width: 380px; flex-shrink: 0; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--borde); padding: 14px 16px 24px; }
.ficha-cab { display: flex; justify-content: space-between; align-items: center; }
.badge { --c: #999; display: inline-block; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 25%, transparent); border: 1px solid var(--c); }
.ficha h2 { margin: 10px 0 4px; font-size: 21px; line-height: 1.2; }
.ficha h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--tenue); }
.zona { margin: 0 0 6px; color: var(--tenue); font-size: 14px; }
.estado { display: inline-block; font-size: 12px; margin: 2px 0 6px; padding: 3px 8px; border-radius: 6px; background: var(--panel-2); }
.e-rumor { color: var(--amarillo); } .e-confirmado { color: #4ade80; } .e-comunidad { color: var(--cian); }
.etiqueta { display: inline-block; font-size: 11px; background: #3b1d4a; color: #f0c4ff; border-radius: 6px; padding: 2px 7px; margin: 0 4px 4px 0; }
.desc { font-size: 15px; line-height: 1.5; }
.dato { font-size: 14px; margin: 6px 0; }
.pasos { padding-left: 22px; margin: 0; font-size: 14px; line-height: 1.5; }
.pasos li { margin-bottom: 5px; }
.ficha-acciones { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.fuentes { font-size: 12px; color: var(--tenue); margin-top: 14px; }
.en-wiki { font-size: 13px; background: var(--panel-2); border-radius: 8px; padding: 7px 10px; }
.nav-principal { display: flex; gap: 4px; }
.nav-principal a { color: var(--tenue); text-decoration: none; padding: 7px 12px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.nav-principal a:hover { color: var(--texto); background: var(--panel-2); }
.nav-principal a[aria-current] { color: var(--texto); background: color-mix(in srgb, var(--rosa) 22%, transparent); border: 1px solid var(--rosa); }
@media (max-width: 820px) { .nav-principal { gap: 2px; flex-shrink: 0; } .nav-principal a span { display: none; } .nav-principal a { padding: 6px 7px; } }

.video { margin: 0 0 10px; }
.video-thumb { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 10px; background: #000 center/cover; position: relative; display: grid; place-items: center; }
.video-thumb.tiktok { aspect-ratio: 9/10; background: linear-gradient(135deg, #111, #25f4ee33, #fe2c5533); gap: 6px; }
.play { width: 58px; height: 58px; border-radius: 50%; background: rgba(255,0,60,.9); display: grid; place-items: center; font-size: 22px; color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.5); }
.video iframe { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 10px; }
.video iframe.tiktok { aspect-ratio: 9/16; max-height: 640px; }
.video figcaption { font-size: 12px; margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; }
.btn-red { display: inline-block; margin: 4px 0 10px; padding: 9px 14px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--cian); text-decoration: none; color: var(--texto); font-weight: 600; }

/* Diálogos */
.dialogo { background: var(--panel); color: var(--texto); border: 1px solid var(--borde); border-radius: 16px; padding: 16px 18px; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); }
.dialogo::backdrop { background: rgba(3,10,16,.7); backdrop-filter: blur(2px); }
.dlg-cab { display: flex; justify-content: space-between; align-items: center; }
.dlg-cab h2 { margin: 0; font-size: 19px; }
.dlg-pie { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--tenue); margin: 4px 0 8px; }
.check input { margin-top: 3px; width: 18px; height: 18px; }
.error { background: #4c0d1f; border: 1px solid var(--rosa); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.ayuda { padding-left: 20px; line-height: 1.6; font-size: 15px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3000; background: #0d2233; border: 1px solid var(--cian); padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: calc(100vw - 24px); font-size: 14px; }

.solo-movil { display: none; }
.panel-cab { justify-content: space-between; align-items: center; margin-bottom: 8px; }

/* Celular */
@media (max-width: 820px) {
  :root { --top: 54px; }
  .solo-movil { display: inline-flex; }
  .panel-cab.solo-movil { display: flex; }
  .marca span { display: none; }
  .topbar { gap: 8px; padding-left: 8px; padding-right: 8px; }
  .acciones { gap: 6px; }
  .acciones .btn { padding: 7px 10px; font-size: 13px; }
  #btn-agregar { font-size: 0; padding: 0; width: 38px; height: 38px; }
  #btn-agregar::before { content: '＋'; font-size: 20px; }
  #btn-filtros { font-size: 0; padding: 0; width: 38px; height: 38px; }
  #btn-filtros::before { content: '☰'; font-size: 18px; }
  #btn-instalar { font-size: 0; padding: 0; width: 38px; height: 38px; }
  #btn-instalar::before { content: '📲'; font-size: 16px; }
  .panel, .ficha {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto; z-index: 1500; max-height: 72dvh;
    border: 0; border-top: 1px solid var(--borde); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.5);
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .panel { transform: translateY(105%); transition: transform .25s ease; }
  .panel.abierto { transform: none; }
  .ficha { max-height: 66dvh; }
  .ficha::before, .panel::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--borde); margin: -4px auto 8px; }
  .leyenda-precision { bottom: 18px; }
}

.codigo-caja { display: flex; align-items: center; gap: 10px; margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: linear-gradient(90deg, #3a300c, #24301a); border: 1px solid #b8962b; }
.codigo-caja span { font-size: 13px; color: #ffe8a3; }
.codigo-caja b { font: 800 26px/1 ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: .12em; color: #fff; flex: 1; }
.codigo-caja .btn { padding: 5px 12px; font-size: 13px; }

.e-secreto { color: #f0c4ff; }
.confeti { position: fixed; inset: 0; pointer-events: none; z-index: 4000; overflow: hidden; }
.confeti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: caer linear forwards; }
@keyframes caer { to { top: 105%; transform: translateX(40px) rotate(720deg); } }

.nav-principal a.nav-apoyo { color: #ffe1a8; border: 1px solid #b8962b; background: color-mix(in srgb, #ffc845 14%, transparent); }
.nav-principal a.nav-apoyo:hover { background: color-mix(in srgb, #ffc845 26%, transparent); }

/* Nada de la página se sale del ancho de la pantalla */
html, body { max-width: 100%; overflow-x: hidden; }
.topbar > * { flex-shrink: 0; }
.topbar > .buscar { flex-shrink: 1; }
/* Página del mapa: solo el mapa hace zoom; la página no se mueve ni se acerca */
html.sin-zoom, html.sin-zoom body { overflow: hidden; overscroll-behavior: none; touch-action: pan-x pan-y; height: 100%; }
@media (max-width: 420px) {
  .topbar { gap: 6px; }
  .marca img { width: 26px; height: 26px; }
  .buscar { padding: 0 9px; }
  .buscar input { font-size: 14px; }
  #btn-agregar, #btn-filtros { width: 36px; height: 36px; }
}
