:root {
  --bg: #f4f3ee;
  --card: #ffffff;
  --ink: #15191c;
  --muted: #5e666e;
  --line: #dedbd2;
  --verde: #0f5c4a;       /* color de la app */
  --verde-2: #13785f;
  --chip: #ecebe4;
  --peligro: #c0392b;
  --sombra: 0 2px 6px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181b; --card: #1f252a; --ink: #eef1f3; --muted: #9aa4ad; --line: #313a41;
    --chip: #2a3238; --verde: #1d8f72; --verde-2: #26a584; --peligro: #e0604f;
    --sombra: 0 2px 8px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--ink); font: 17px/1.4 "Atkinson Hyperlegible", system-ui, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h2, h3 { font-family: "Barlow Condensed", system-ui, sans-serif; font-weight: 800; letter-spacing: .01em; margin: 0; }

#mapa { position: fixed; inset: 0; background: #e8e4da; }
.leaflet-control-attribution { font-size: 10px; opacity: .75; }
.leaflet-bottom { bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ---- arriba */
.arriba { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; padding: calc(8px + env(safe-area-inset-top)) 10px 0; pointer-events: none; }
.arriba > * { pointer-events: auto; }
.fila1 { display: flex; gap: 8px; align-items: center; }
.buscador { flex: 1; min-width: 0; height: 48px; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; background: var(--card);
  box-shadow: var(--sombra); padding: 0 16px; font-size: 16px; text-align: left; }
.buscador span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#b-filtros { position: relative; font-size: 22px; width: 48px; height: 48px; }
#b-filtros b { position: absolute; top: -3px; right: -3px; background: #e11d48; color: #fff; font: 700 11px/1 system-ui, sans-serif; padding: 3px 6px; border-radius: 99px; }
#b-ajustes { width: 48px; height: 48px; }
.vacio.peq { margin: 8px 0 14px; font-size: 15px; }
.ciudades { flex: 1; display: flex; background: var(--card); border-radius: 999px; padding: 4px; box-shadow: var(--sombra); overflow-x: auto; scrollbar-width: none; }
.ciudades::-webkit-scrollbar { display: none; }
.ciudades button { flex: 1; border: 0; background: none; padding: 9px 10px; border-radius: 999px; font-weight: 700; font-size: 15px; color: var(--muted); white-space: nowrap; }
.ciudades button.on { background: var(--verde); color: #fff; }

.filtros { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 6px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 5px; border: 2px solid transparent; background: var(--card); color: var(--muted);
  padding: 6px 11px; border-radius: 999px; font-size: 14px; font-weight: 700; box-shadow: var(--sombra); white-space: nowrap; opacity: .72; }
.chip small { font-weight: 400; font-size: 12px; }
.chip.on { opacity: 1; color: var(--ink); border-color: var(--c, var(--verde)); }
.filtros.fijos .chip { box-shadow: none; background: var(--chip); }

.redondo { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--sombra); font-size: 20px; display: grid; place-items: center; }
.redondo.grande { width: 52px; height: 52px; font-size: 24px; }
.redondo.peq { width: 38px; height: 38px; font-size: 16px; box-shadow: none; background: var(--chip); }

/* banda de la línea que se está viendo */
.banda-linea { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 16px; padding: 10px 10px 10px 12px; box-shadow: var(--sombra); margin-top: 2px; }
.bl-txt { flex: 1; min-width: 0; font-size: 15px; }
.bl-txt b { display: block; line-height: 1.2; }
.bl-cabs { display: flex; gap: 6px; overflow-x: auto; margin-top: 6px; scrollbar-width: none; }
.bl-cabs button { flex: none; border: 0; background: var(--chip); border-radius: 10px; padding: 6px 9px; font-size: 13px; font-weight: 700; }

/* modo elegir sitio */
.aviso-elegir { background: var(--card); border-radius: 16px; padding: 10px; box-shadow: var(--sombra); margin-top: 8px; }
.aviso-elegir input { width: 100%; font: inherit; font-size: 17px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.aviso-elegir small { display: block; text-align: center; color: var(--muted); margin-top: 6px; font-size: 13px; }
.r-dir { display: flex; flex-direction: column; max-height: 40vh; overflow-y: auto; }
.r-item { text-align: left; border: 0; background: none; padding: 11px 6px; border-bottom: 1px solid var(--line); font-size: 15px; }
body.eligiendo .fila1, body.eligiendo .filtros, body.eligiendo .banda-linea { display: none; }
.cruz { position: fixed; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; z-index: 900; pointer-events: none; }
.cruz::before, .cruz::after { content: ""; position: absolute; background: #e11d48; box-shadow: 0 0 0 2px #fff; border-radius: 2px; }
.cruz::before { left: 26px; top: 0; width: 4px; height: 56px; }
.cruz::after { top: 26px; left: 0; height: 4px; width: 56px; }

/* ---- abajo */
.flotantes { position: fixed; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.capa { width: 64px; height: 60px; border: 0; border-radius: 16px; background: var(--card); box-shadow: var(--sombra);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 22px; line-height: 1; }
.capa span { font-size: 12px; font-weight: 700; }
body.con-ficha .flotantes, body.eligiendo .flotantes { display: none; }
.abajo { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; gap: 6px; align-items: stretch;
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 55%, transparent); }
.accion { flex: 1; min-width: 0; min-height: 60px; border: 0; border-radius: 16px; background: var(--card); box-shadow: var(--sombra);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 22px; line-height: 1; padding: 0 2px; }
.accion span { font-size: 12px; font-weight: 700; white-space: nowrap; }
.accion.principal { flex: 1.5; background: var(--verde); color: #fff; }
.accion.principal span { font-size: 15px; }
body.con-ficha #abajo { display: none; }

/* ---- pines */
.pin { width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 3px solid var(--c); display: grid; place-items: center;
  font-size: 17px; box-shadow: 0 2px 5px rgba(0,0,0,.35); position: relative; }
.pin.cerca { --c: #0f5c4a; width: 34px; height: 34px; border-radius: 10px 10px 10px 2px; font-size: 16px; }
.pin.cerca.cerrado { opacity: .55; filter: grayscale(.6); }
.punto { width: 24px; height: 24px; display: grid; place-items: center; }

/* ---- cerca de mí */
.cats-g { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.cat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 86px; padding: 8px 6px;
  border: 0; border-radius: 16px; background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-size: 13px; font-weight: 700; text-align: center; line-height: 1.15; }
.cat em { font-style: normal; font-size: 28px; line-height: 1; }
.cat:active { transform: scale(.97); }
.volver-cats { margin: 4px 0 2px; }
.sec small { font: 400 14px/1 "Atkinson Hyperlegible", sans-serif; color: var(--muted); }
.abierto { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 99px; margin-top: 2px; width: max-content; }
.abierto.si { background: #d8f3e3; color: #13703f; }
.abierto.no { background: #fbe0dc; color: #a8321f; }
@media (prefers-color-scheme: dark) { .abierto.si { background: #173d29; color: #6fdc9d; } .abierto.no { background: #45201b; color: #ff9c8c; } }
.banda-linea .sub { margin-top: 2px; }
#banda-cerca { margin-top: 6px; }
.punto::after { content: ""; width: 13px; height: 13px; border-radius: 50%; background: var(--c); border: 2.5px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.45); }
.pin.mio { border-radius: 10px; border-width: 3px; }
.pin b { position: absolute; top: -7px; right: -9px; background: var(--c); color: #fff; font: 700 11px/1 system-ui, sans-serif; padding: 3px 5px; border-radius: 99px; border: 2px solid #fff; }
.yo { width: 22px; height: 22px; border-radius: 50%; background: #1a73e8; border: 4px solid #fff; box-shadow: 0 0 0 2px rgba(26,115,232,.35), 0 2px 6px rgba(0,0,0,.35); }

/* ---- líneas */
.ln { display: inline-flex; align-items: center; gap: 4px; min-width: 36px; justify-content: center; border: 0; background: var(--c); color: var(--t);
  font: 800 16px/1 "Barlow Condensed", system-ui, sans-serif; padding: 7px 8px; border-radius: 8px; }
.ln i { font: 400 11px/1 "Atkinson Hyperlegible", sans-serif; opacity: .9; }
.ln.grande { min-width: 48px; font-size: 21px; padding: 8px 9px; border-radius: 10px; flex: none; }
.ln.sel { opacity: .35; }
.ln.sel.on { opacity: 1; box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--c); }
.lns { display: flex; flex-wrap: wrap; gap: 6px; }
.lns.mini .ln { min-width: 26px; font-size: 13px; padding: 4px 5px; border-radius: 6px; }

/* ---- ficha */
.hoja { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -4px 24px rgba(0,0,0,.18);
  padding: 6px 16px calc(14px + env(safe-area-inset-bottom)); max-height: 72vh; overflow-y: auto; animation: sube .18s ease-out; }
@keyframes sube { from { transform: translateY(30px); opacity: .4; } }
.asa { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.ficha-cab { display: flex; gap: 12px; align-items: flex-start; }
.ficha-ico { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: color-mix(in srgb, var(--c) 16%, transparent); }
.ficha-tit { flex: 1; min-width: 0; }
.ficha-tit h3 { font-size: 26px; line-height: 1.05; }
.sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.bloque { margin-top: 14px; }
.etq { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.nota { margin-top: 14px; background: var(--chip); border-radius: 12px; padding: 10px 12px; white-space: pre-wrap; }
.ir { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.casa { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.casa .ir { margin-top: 8px; }
.casa-nom { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 19px; }
.casa-nom span { color: var(--muted); font-size: 15px; font-weight: 700; }
.ficha-pie, .form-pie { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ficha-pie .btn, .form-pie .btn { flex: 1; }
.buscando { text-align: center; padding-top: 18px; }
.buscando b { display: block; font-size: 19px; }
.buscando span { color: var(--muted); font-size: 15px; }
.fila-btn { display: flex; gap: 10px; margin-top: 14px; }
.fila-btn .btn { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 52px; padding: 10px 14px; border-radius: 14px;
  border: 0; font-weight: 700; font-size: 16px; text-decoration: none; }
.btn.gmaps { background: #1a73e8; color: #fff; }
.btn.waze { background: #33ccff; color: #0b2a3a; }
.btn.claro { background: var(--chip); color: var(--ink); min-height: 46px; font-size: 15px; }
.btn.principal { background: var(--verde); color: #fff; }
.btn.ancho { width: 100%; font-size: 18px; min-height: 56px; margin-top: 6px; }
.btn.peligro { color: var(--peligro); }
.btn:disabled { opacity: .45; }

/* ---- paneles */
.panel { position: fixed; inset: 0; z-index: 1200; background: var(--bg); display: flex; flex-direction: column; }
.panel-cab { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: var(--card); box-shadow: 0 1px 0 var(--line); }
.panel-cab h2 { font-size: 26px; }
.panel-cab input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.panel .filtros.fijos { padding: 10px 12px 4px; flex: none; flex-wrap: wrap; overflow: visible; }
.panel-cuerpo { flex: 1; overflow-y: auto; padding: 8px 12px calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.fila { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: var(--card); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; min-height: 60px; }
.fila-ico { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--c) 16%, transparent); }
.fila-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.fila-txt b { line-height: 1.2; }
.fila-txt small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-d { flex: none; color: var(--muted); font-size: 14px; font-weight: 700; }
.vacio { text-align: center; color: var(--muted); margin-top: 40px; }
.sec { font-size: 22px; margin: 14px 2px 8px; }
.ciudad { margin: 8px 0 12px; }
.ciudad > summary { list-style: none; display: flex; align-items: baseline; gap: 10px; background: var(--card); border-radius: 16px;
  padding: 16px 16px; font: 800 26px/1 "Barlow Condensed", system-ui, sans-serif; cursor: pointer; box-shadow: var(--sombra); }
.ciudad > summary::-webkit-details-marker { display: none; }
.ciudad > summary small { font: 400 15px/1 "Atkinson Hyperlegible", sans-serif; color: var(--muted); flex: 1; }
.ciudad > summary::after { content: "▾"; font-size: 22px; color: var(--muted); transition: transform .15s; }
.ciudad[open] > summary::after { transform: rotate(180deg); }
.ciudad[open] > summary { margin-bottom: 8px; }
.grupo { background: var(--card); border-radius: 14px; margin-bottom: 8px; padding: 0 10px; }
.grupo summary { padding: 14px 4px; font-weight: 700; cursor: pointer; }
.grupo summary small { color: var(--muted); font-weight: 400; }
.grupo .fila { background: var(--bg); }
.campo .grupo { background: var(--chip); margin-top: 8px; }
.campo .grupo .lns { padding-bottom: 12px; }

/* formulario */
.campo { display: block; margin: 8px 0 18px; }
.campo > span { display: block; font-weight: 700; margin-bottom: 8px; }
.campo > span small { font-weight: 400; color: var(--muted); }
.campo input, .campo textarea { width: 100%; font: inherit; font-size: 18px; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.campo textarea { resize: vertical; }
.tipos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.tipo { display: flex; align-items: center; gap: 8px; text-align: left; border: 2px solid transparent; background: var(--card); border-radius: 14px; padding: 10px; font-size: 15px; font-weight: 700; min-height: 54px; }
.tipo em { font-style: normal; font-size: 22px; }
.tipo.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--card)); }

/* ajustes */
.tarjeta { background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; }
.tarjeta h3 { font-size: 21px; margin-bottom: 6px; }
.tarjeta p { margin: 6px 0 10px; }
.enlace { background: var(--chip); border-radius: 10px; padding: 10px; font-size: 13px; word-break: break-all; margin-bottom: 10px; user-select: all; }

.tostada { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1500;
  background: #15191c; color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 700; box-shadow: var(--sombra); max-width: 90vw; text-align: center; }

@media (min-width: 700px) {
  .abajo { max-width: 620px; margin: 0 auto; }
  .hoja { max-width: 520px; left: 16px; right: auto; bottom: 16px; border-radius: 22px; }
  .panel { left: auto; width: 460px; box-shadow: var(--sombra); }
}

/* «Estoy aquí»: mantener pulsado para guardar (se va rellenando mientras lo mantiene) */
#b-aqui { position: relative; overflow: hidden; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#b-aqui small { font-size: 11px; opacity: .8; font-weight: 400; }
#b-aqui::before { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.28); transform: scaleX(0); transform-origin: left; }
#b-aqui.cargando::before { transform: scaleX(1); transition: transform .6s linear; }
.sub.centro { text-align: center; margin-top: 10px; }
