/* Diario — moderno y limpio; las fotos mandan. */
:root {
  --fondo: #ffffff;
  --superficie: #f4f4f6;
  --superficie-2: #ebebef;
  --texto: #111114;
  --suave: #6c6c76;
  --borde: #e7e7ec;
  --acento: #f0395a;
  --acento-suave: #ffe9ed;
  --acento-texto: #ffffff;
  --jan: #3a6ff0;
  --david: #f0395a;
  --sombra: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.08);
  --radio: 18px;
  --barra: 64px;
  --arriba: env(safe-area-inset-top, 0px);
  --abajo: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #0c0c0e; --superficie: #18181c; --superficie-2: #222228; --texto: #f3f3f6; --suave: #9b9ba6;
    --borde: #26262c; --acento: #ff5575; --acento-suave: #3a1820; --jan: #6f97ff; --david: #ff5575;
    --sombra: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #0c0c0e; --superficie: #18181c; --superficie-2: #222228; --texto: #f3f3f6; --suave: #9b9ba6;
  --borde: #26262c; --acento: #ff5575; --acento-suave: #3a1820; --jan: #6f97ff; --david: #ff5575;
  --sombra: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
svg.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.lleno { fill: currentColor; }

/* --- armazón --------------------------------------------------------------- */
.pagina { max-width: 640px; margin: 0 auto; padding: calc(var(--arriba) + 8px) 16px calc(var(--barra) + var(--abajo) + 24px); }
.cabeza { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 14px; }
.cabeza h1 { margin: 0; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.pareja { display: flex; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; color: #fff; background: var(--jan); border: 2px solid var(--fondo); flex: none;
}
.avatar.david { background: var(--david); margin-left: -8px; }
.avatar.peq { width: 26px; height: 26px; font-size: .72rem; border: 0; margin: 0; }

.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: color-mix(in srgb, var(--fondo) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--borde);
  padding-bottom: var(--abajo);
}
.barra nav { max-width: 640px; margin: 0 auto; height: var(--barra); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.barra button {
  border: 0; background: none; color: var(--suave); height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .68rem; font-weight: 600; position: relative;
}
.barra button[aria-current="page"] { color: var(--texto); }
.barra .mas span {
  width: 48px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  background: var(--acento); color: var(--acento-texto); box-shadow: 0 4px 14px color-mix(in srgb, var(--acento) 40%, transparent);
}
.barra .punto::after { content: ""; position: absolute; top: 12px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--acento); }

/* --- cuenta atrás ------------------------------------------------------------ */
.cuenta {
  position: relative; overflow: hidden;
  border-radius: var(--radio); padding: 18px 20px;
  background: linear-gradient(135deg, #ff5a78, #f0395a 45%, #b62c86);
  color: #fff; margin-bottom: 16px; border: 0; width: 100%; text-align: left; display: block;
}
.cuenta::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.cuenta .num { font-size: 2.6rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.cuenta .num small { font-size: 1rem; font-weight: 600; margin-left: 6px; letter-spacing: 0; }
.cuenta .que { font-weight: 600; margin-top: 6px; }
.cuenta .cuando { font-size: .85rem; opacity: .85; margin-top: 2px; }
.cuenta.vacia { background: var(--superficie); color: var(--texto); }
.cuenta.vacia::after { display: none; }
.cuenta .otras { font-size: .8rem; opacity: .85; margin-top: 10px; }

/* --- cuadrícula ------------------------------------------------------------------ */
.rejilla { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin: 0 -16px; }
@media (min-width: 640px) { .rejilla { margin: 0; gap: 4px; border-radius: 10px; overflow: hidden; } }
.celda {
  position: relative; aspect-ratio: 1; border: 0; padding: 0; overflow: hidden;
  background: var(--superficie); color: var(--texto);
}
.celda img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.celda:active img { transform: scale(.97); }
.celda .varias { position: absolute; top: 7px; right: 7px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.celda .varias svg { width: 18px; height: 18px; }
.celda.texto {
  display: flex; align-items: center; justify-content: center; padding: 12px;
  background: var(--acento-suave); text-align: center;
}
.celda.texto.jan { background: color-mix(in srgb, var(--jan) 14%, var(--fondo)); }
.celda.texto p {
  margin: 0; font-weight: 600; font-size: .85rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.celda .nuevo { position: absolute; top: 8px; left: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--acento); box-shadow: 0 0 0 2px #fff; }
.vacio { text-align: center; color: var(--suave); padding: 48px 16px; }
.vacio svg { width: 44px; height: 44px; stroke-width: 1.5; margin-bottom: 8px; }
.vacio h3 { color: var(--texto); margin: 0 0 4px; font-size: 1.1rem; }

/* --- botones y campos -------------------------------------------------------------- */
.boton {
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600;
  background: var(--acento); color: var(--acento-texto);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.boton.gris { background: var(--superficie); color: var(--texto); }
.boton.ancho { width: 100%; }
.boton:disabled { opacity: .5; }
.icono { border: 0; background: none; padding: 8px; border-radius: 50%; display: grid; place-items: center; color: var(--texto); }
.icono:active { background: var(--superficie); }
.enlace { border: 0; background: none; padding: 0; color: var(--acento); font-weight: 600; }
.campo {
  width: 100%; border: 1px solid var(--borde); background: var(--superficie); border-radius: 12px;
  padding: 12px 14px; font-size: 1rem; outline: none;
}
.campo:focus { border-color: var(--acento); background: var(--fondo); }
textarea.campo { resize: none; min-height: 120px; line-height: 1.5; }
.etiqueta { display: block; font-size: .85rem; font-weight: 600; color: var(--suave); margin: 16px 0 6px; }

/* --- capas a pantalla completa ------------------------------------------------------ */
.capa {
  position: fixed; inset: 0; z-index: 10; background: var(--fondo);
  display: flex; flex-direction: column;
  animation: entra .22s ease-out;
}
@keyframes entra { from { transform: translateY(24px); opacity: 0; } }
.capa .barra-capa {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--arriba) + 6px) 8px 6px; border-bottom: 1px solid var(--borde); min-height: 56px;
}
.capa .barra-capa h2 { margin: 0; font-size: 1rem; font-weight: 700; flex: 1; text-align: center; }
.capa .barra-capa .lado { min-width: 72px; display: flex; }
.capa .barra-capa .lado:last-child { justify-content: flex-end; }
.capa .cuerpo { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.capa .cuerpo > .dentro { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(var(--abajo) + 24px); }
.capa .pie-capa { border-top: 1px solid var(--borde); padding: 10px 12px calc(var(--abajo) + 10px); background: var(--fondo); }
.capa .pie-capa > div { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }

/* --- publicación abierta ------------------------------------------------------------ */
.autor { display: flex; align-items: center; gap: 10px; }
.autor b { font-weight: 700; }
.autor small { color: var(--suave); display: block; font-size: .78rem; line-height: 1.2; }
.carrusel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; background: #000; }
.carrusel::-webkit-scrollbar { display: none; }
.carrusel img { flex: none; width: 100%; max-height: 72vh; object-fit: contain; scroll-snap-align: center; }
.puntos { display: flex; justify-content: center; gap: 5px; padding: 10px 0 0; }
.puntos i { width: 6px; height: 6px; border-radius: 50%; background: var(--superficie-2); }
.puntos i.on { background: var(--acento); }
.acciones { display: flex; align-items: center; gap: 4px; margin: 6px -8px 0; }
.acciones .icono.puesto { color: var(--acento); }
.acciones .cuantos { font-weight: 600; font-size: .9rem; margin-right: 8px; }
.texto-pub { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; }
.sitio { display: inline-flex; align-items: center; gap: 4px; color: var(--suave); font-size: .85rem; margin-top: 8px; border: 0; background: none; padding: 0; }
.sitio svg { width: 16px; height: 16px; }
.comentarios { margin-top: 18px; border-top: 1px solid var(--borde); padding-top: 12px; }
.comentario { display: flex; gap: 10px; padding: 8px 0; }
.comentario .burbuja { background: var(--superficie); border-radius: 4px 16px 16px 16px; padding: 8px 12px; max-width: 85%; }
.comentario .burbuja b { font-size: .8rem; display: block; }
.comentario .burbuja p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comentario small { color: var(--suave); font-size: .72rem; display: block; margin-top: 2px; }
.comentario.mio { flex-direction: row-reverse; }
.comentario.mio .burbuja { background: var(--acento-suave); border-radius: 16px 4px 16px 16px; }
.comentario.mio small { text-align: right; }
.caja-comentario { flex: 1; border: 1px solid var(--borde); background: var(--superficie); border-radius: 20px; padding: 10px 14px; max-height: 120px; resize: none; outline: none; }

/* --- editor --------------------------------------------------------------------------- */
.previas { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.previa { position: relative; flex: none; width: 104px; height: 104px; border-radius: 12px; overflow: hidden; background: var(--superficie); }
.previa img { width: 100%; height: 100%; object-fit: cover; }
.previa.subiendo img { opacity: .4; }
.previa .quitar {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; padding: 0;
}
.previa .quitar svg { width: 14px; height: 14px; }
.previa.anadir { border: 1.5px dashed var(--borde); display: grid; place-items: center; color: var(--suave); background: none; }
.fila-opcion {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 0; border: 0; background: none;
  border-top: 1px solid var(--borde); text-align: left;
}
.fila-opcion .txt { flex: 1; }
.fila-opcion small { color: var(--suave); }

/* --- hoja inferior (menú del +) ------------------------------------------------------------ */
.velo { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.4); animation: aparece .2s; }
@keyframes aparece { from { opacity: 0; } }
.hoja-abajo {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 16;
  background: var(--fondo); border-radius: 22px 22px 0 0; padding: 8px 16px calc(var(--abajo) + 16px);
  max-width: 640px; margin: 0 auto; animation: sube .25s ease-out;
}
@keyframes sube { from { transform: translateY(100%); } }
.hoja-abajo .asa { width: 36px; height: 5px; border-radius: 3px; background: var(--superficie-2); margin: 4px auto 12px; }
.opcion {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; border: 0; border-radius: 14px;
  background: none; text-align: left;
}
.opcion:active { background: var(--superficie); }
.opcion .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--superficie); }
.opcion.principal .ic { background: var(--acento); color: #fff; }
.opcion b { display: block; }
.opcion small { color: var(--suave); }
.opcion.peligro { color: var(--acento); }

/* --- mapa ----------------------------------------------------------------------------------- */
.mapa-completo { position: fixed; left: 0; right: 0; top: 0; bottom: calc(var(--barra) + var(--abajo)); z-index: 0; }
.mapa-cabeza {
  position: fixed; top: calc(var(--arriba) + 12px); left: 16px; right: 16px; z-index: 2; pointer-events: none;
  display: flex; justify-content: center;
}
.mapa-cabeza span { pointer-events: auto; background: var(--fondo); box-shadow: var(--sombra); border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: .9rem; }
.marca-foto { width: 52px; height: 52px; border-radius: 14px; border: 3px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.35); overflow: hidden; background: #fff; }
.marca-foto img { width: 100%; height: 100%; object-fit: cover; }
.marca-punto { width: 22px; height: 22px; border-radius: 50%; background: var(--acento); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.mapa-elegir { flex: 1; min-height: 300px; }
.leaflet-container { font-family: inherit; background: var(--superficie); }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); } }
.leaflet-tile-pane { filter: saturate(.7); }

/* --- cartas --------------------------------------------------------------------------------- */
.seccion { font-size: .8rem; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .06em; margin: 22px 0 10px; }
.carta-fila {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  border: 1px solid var(--borde); background: var(--fondo); border-radius: var(--radio); padding: 14px; margin-bottom: 10px;
}
.carta-fila .ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--superficie); flex: none; }
.carta-fila.sellada .ic { background: var(--acento-suave); color: var(--acento); }
.carta-fila.nueva { border-color: var(--acento); box-shadow: 0 0 0 1px var(--acento); }
.carta-fila .txt { flex: 1; min-width: 0; }
.carta-fila b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.carta-fila small { color: var(--suave); }
.carta-fila .faltan { font-weight: 700; color: var(--acento); font-size: .85rem; white-space: nowrap; }
.carta-leer { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.05rem; line-height: 1.7; }

/* --- ajustes ---------------------------------------------------------------------------------- */
.grupo { background: var(--superficie); border-radius: var(--radio); overflow: hidden; }
.grupo > * + * { border-top: 1px solid var(--borde); }
.grupo .item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 0; background: none; text-align: left; }
.grupo .item .txt { flex: 1; min-width: 0; }
.grupo .item small { color: var(--suave); display: block; }
.grupo .item.peligro { color: var(--acento); font-weight: 600; }
.segmentos { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--superficie); border-radius: 12px; padding: 3px; }
.segmentos button { border: 0; background: none; padding: 9px; border-radius: 10px; font-weight: 600; font-size: .9rem; color: var(--suave); }
.segmentos button[aria-pressed="true"] { background: var(--fondo); color: var(--texto); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* --- entrada ------------------------------------------------------------------------------------ */
.entrar { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px; }
.entrar form { width: min(360px, 100%); text-align: center; }
.entrar img { width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 20px; box-shadow: var(--sombra); }
.entrar h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
.entrar p { color: var(--suave); margin: 0 0 24px; }
.entrar .campo { margin-bottom: 10px; }
.entrar .error { color: var(--acento); font-size: .9rem; min-height: 1.4em; margin: 4px 0 10px; }

/* --- aviso ---------------------------------------------------------------------------------------- */
.aviso {
  position: fixed; left: 50%; bottom: calc(var(--barra) + var(--abajo) + 16px); transform: translate(-50%, 20px);
  background: var(--texto); color: var(--fondo); padding: 10px 18px; border-radius: 999px; font-size: .9rem; font-weight: 500;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 30; max-width: calc(100vw - 32px); text-align: center;
}
.aviso.visible { opacity: 1; transform: translate(-50%, 0); }
