:root {
  --bg: #14161a;
  --surface: #1d2026;
  --surface-2: #262a32;
  --line: #333844;
  --text: #f2f3f5;
  --muted: #b9bfc9; /* texto secundario: contraste ≥ 7:1 sobre fondo y tarjetas */
  --red: #e5322d;
  --red-deep: #a81d19;
  --red-soft: rgba(229, 50, 45, .14);
  --amber: #f2a93b;
  --green: #35b26b;
  --green-soft: rgba(53, 178, 107, .14);
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tabs-h: calc(3.6rem + 12px); /* alto de la barra inferior: crece con el tamaño de letra */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; } /* iPhone: que no agrande letras por su cuenta al girar */
/* Pantalla fija: el documento no se desplaza; solo se desplaza el contenido (#scroller), entre la barra de arriba y la de
   abajo. Así ninguna barra usa position: fixed, que en iPhone y iPad (PWA, Safari, Chrome) a veces quedaba a media
   pantalla o fuera de ella al desplazarse o al cerrar el teclado. Ver settleDocument en app.js. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
/* Pegado a los cuatro bordes del área de la página (el alto lo dan top y bottom, no 100dvh) */
body {
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  position: fixed; inset: 0; height: auto; display: flex; flex-direction: column;
}
.scroller {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  /* Al moverse con teclado o lector de pantalla, lo enfocado no queda pegado a los bordes */
  scroll-padding: 12px 0;
}
.scroller > main { padding-bottom: 24px; }
/* Con el teclado abierto (app.js: settleDocument) la app ocupa solo lo que se ve encima de él: sin la barra de pestañas,
   que quedaría pegada al teclado quitando espacio al campo donde se escribe */
body.keyboard .tabs { display: none; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
/* Solo para lector de pantalla */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* Foco visible con teclado o con control por interruptores; los títulos que reciben foco al cambiar de pantalla no lo marcan */
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

/* Barra superior */
.topbar {
  flex: none; position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) 10px calc(16px + var(--safe-l));
  gap: 10px;
  /* Fondo sólido: en la PWA de iPhone el desenfoque (backdrop-filter) difuminaba también el texto de la barra */
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; font-weight: 700; letter-spacing: .01em; }
.brand .dot, .brand .menu-btn { flex: none; }
/* Nombre de la comunidad y, sin sesión, la dirección de la página: al lado si cabe, si no, debajo */
.brand-text { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; min-width: 0; }
.brand .site { font-size: .8rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.brand .site[hidden], .reload[hidden] { display: none; }
/* Nombres largos de distrito: hasta dos líneas y luego "…", sin empujar los botones de la derecha */
#community {
  min-width: 0; font-size: 1rem; line-height: 1.2; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: inherit; text-decoration: none; /* lleva a la pantalla de Alerta */
}
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.top-actions { display: flex; flex: none; align-items: center; gap: 10px; }
.reload {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; cursor: pointer;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 50%;
}
.reload svg { width: 24px; height: 24px; fill: currentColor; }
.reload.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* 911: siempre a la vista arriba, relleno rojo para encontrarlo de inmediato (en Inicio no hay otro) */
.call911 {
  text-decoration: none; font-weight: 800; letter-spacing: .04em;
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  padding: 6px 16px; border-radius: 12px; border: 2px solid var(--red); background: var(--red); color: #fff;
}
.call911:active { background: var(--red-deep); }

main { padding: 16px calc(16px + var(--safe-r)) 16px calc(16px + var(--safe-l)); max-width: 560px; margin: 0 auto; }

/* Navegación inferior */
.tabs {
  flex: none; position: relative; z-index: 10; /* parte del diseño, no flotante: ver .scroller */
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; /* Alerta, Vecinos, Avisos y Ajustes; Administración y Sistema van en el menú ☰ */
  /* Abajo, el espacio de la barra de inicio del iPhone, un poco menos: los íconos no llegan a ella */
  padding: 6px calc(8px + var(--safe-r)) max(6px, calc(var(--safe-b) - 10px)) calc(8px + var(--safe-l));
  background: var(--surface); border-top: 1px solid var(--line);
}
/* App instalada en iPhone o iPad: la página llega al borde de abajo, donde está la barra de inicio del teléfono, pero sin
   viewport-fit=cover iOS informa 0 de margen (safe-area-inset-bottom). Se deja un espacio fijo para que no la toque. */
@media (display-mode: standalone) {
  @supports (-webkit-touch-callout: none) {
    .tabs { padding-bottom: max(16px, calc(var(--safe-b) - 10px)); }
  }
}
.tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 48px; justify-content: center; padding: 6px 0; font-size: .8rem; text-decoration: none; color: var(--muted);
}
.tabs a.active { color: var(--text); font-weight: 700; box-shadow: inset 0 3px 0 var(--red); } /* no solo por color */
.tabs svg { width: 24px; height: 24px; fill: currentColor; }
.badge {
  position: absolute; top: 2px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center;
}

/* Tarjetas y formularios */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.warn { border-color: var(--amber); background: rgba(242, 169, 59, .08); }
.card.danger { border-color: var(--red); background: var(--red-soft); }
.card.ok { border-color: var(--green); background: var(--green-soft); }
label { display: block; font-size: .875rem; color: var(--text); margin: 12px 0 4px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
input:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 1px; }
/* Fecha y hora: en iOS Safari el campo nativo tiene un ancho mínimo propio y se sale del formulario */
input[type="date"], input[type="time"], input[type="datetime-local"] {
  -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; min-height: 48px;
}
input::-webkit-date-and-time-value { text-align: left; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 10px 16px; margin-top: 12px;
  font: inherit; font-weight: 650; color: var(--text); text-decoration: none;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { background: transparent; }
.home-gps { margin-top: 14px; }
.home-gps .btn[hidden] { display: none; }
.btn.danger-text { color: var(--red); border-color: transparent; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
/* "Ya estamos bien" / "Fue falsa alarma": el mismo aire arriba (el margen de la tarjeta anterior) que abajo */
.close-row { margin-bottom: 12px; }
.close-row .btn { margin-top: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 12px; }
.seg button { font: inherit; min-height: 44px; padding: 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: inset 0 -3px 0 var(--red); }
.seg.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg.seg-3 button { min-height: 48px; line-height: 1.15; }

/* Escuchar en voz alta */
.btn.listen { width: auto; margin: 4px 0 12px; padding: 8px 18px; border-radius: 999px; }
.btn.listen .ico { font-size: 1.25rem; line-height: 1; }
.btn.listen.on { background: var(--text); border-color: var(--text); color: var(--bg); }

/* Tipos de alerta: los principales en cuadrícula de 3 columnas; las demás opciones, en una fila que se desliza de lado */
.types-title { font-size: 1rem; text-align: center; margin: 14px 0 8px; }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 76px; padding: 8px 4px; cursor: pointer;
  font: inherit; font-size: .875rem; line-height: 1.15; text-align: center; color: var(--text);
  background: var(--surface-2); border: 2px solid var(--line); border-radius: 12px;
}
.type .ico { font-size: 1.9rem; line-height: 1; }
.types .type:last-child:nth-child(3n+1) { grid-column: 2; } /* si sobra uno, va al centro de la última fila, del mismo tamaño */
.type { position: relative; }
.type .tick { display: none; position: absolute; top: 4px; right: 6px; font-size: .85rem; font-weight: 800; color: #fff;
  width: 1.3em; height: 1.3em; line-height: 1.3em; border-radius: 50%; background: var(--red); }
.type.on .tick { display: block; }
.type.on { background: var(--red-soft); border-color: var(--red); font-weight: 700; box-shadow: 0 0 0 1px var(--red); }
/* Páginas de tipos: se deslizan de lado y siempre muestran una página entera */
.types-pages {
  display: grid; grid-auto-flow: column; grid-auto-columns: 100%; align-items: start;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.types-pages::-webkit-scrollbar { display: none; }
.types-pages > .types { scroll-snap-align: start; padding: 2px; }
.types-pages.dragging { cursor: grabbing; scroll-snap-type: none; }
.types-pages.dragging .type { pointer-events: none; }
/* Menos urgentes: mismos botones, con menos peso visual */
.types.minor .type:not(.on) { background: transparent; border-style: dashed; }
.types-switch {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 44px; margin: 4px 0 0;
  font: inherit; font-size: .9rem; color: var(--muted); background: none; border: 0; cursor: pointer;
}
/* Qué se enviará: una sola línea justo debajo del botón */
.send-line { text-align: center; font-size: 1rem; margin: 2px 0 0; overflow-wrap: anywhere; }
.send-line .send-warn, .send-warn { display: block; margin-top: 6px; padding: 6px 10px; border-radius: 8px; font-size: .875rem;
  background: rgba(242, 169, 59, .12); border: 1px solid var(--amber); }
.place-seg { margin: 14px 0 0; }
.place-seg button { font-size: 1rem; }
/* Inicio: alertas activas resumidas en una línea, siempre del mismo alto (el botón de pánico no se mueve). Compacta, para
   no empujar el botón hacia abajo: come la mitad del margen superior de main */
.active-strip { min-height: 2.9rem; display: flex; align-items: center; margin: -8px 0 6px; border-radius: var(--radius); }
.active-strip.calm { padding: 4px 12px; border: 1.5px solid transparent; }
.active-strip a { flex: 1; align-self: stretch; display: flex; align-items: center; gap: 10px; padding: 4px 12px; color: var(--text);
  text-decoration: none; border-radius: var(--radius); background: var(--red-soft); border: 1.5px solid var(--red); }
.active-strip .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.active-strip .grow .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.active-strip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(229, 50, 45, .3); flex: none; }
#activeSection { margin-top: 20px; scroll-margin-top: 8px; }
.send-state { margin-bottom: 12px; }
.send-state h2 { margin-bottom: 6px; }

/* Botón de pánico */
.panic-card { padding: 4px 0 8px; }
.panic-wrap { display: grid; place-items: center; padding: 14px 0 10px; }
/* Tamaño adaptable: más chico que antes para que en un teléfono pequeño se vean también el tipo y el lugar, pero
   nunca menos de 9 rem (≈144 px), un área cómoda para mantener presionado. En horizontal se limita por el alto. */
.panic {
  position: relative; width: clamp(9rem, min(44vw, 28vh), 12.5rem); aspect-ratio: 1; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; /* iPhone: sin menú de copiar ni lupa al mantenerlo presionado */
  background: radial-gradient(circle at 50% 35%, #ff5a52, var(--red) 55%, var(--red-deep));
  box-shadow: 0 0 0 10px var(--red-soft), 0 12px 40px rgba(229, 50, 45, .35);
  color: #fff; font: inherit;
}
.panic svg.ring { position: absolute; inset: -10px; width: calc(100% + 20px); height: calc(100% + 20px); transform: rotate(-90deg); pointer-events: none; }
.panic svg.ring circle { fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; opacity: 0; }
.panic.holding svg.ring circle { opacity: 1; }
.panic .label { display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.panic .big { font-size: 1.6rem; font-weight: 850; letter-spacing: .06em; }
.panic .hint { font-size: .8rem; opacity: .9; }
.panic.holding { transform: scale(.97); }
.panic.busy { filter: saturate(.7); }
.panic.sent { background: radial-gradient(circle at 50% 35%, #5fd394, var(--green) 60%, #1f7a47); box-shadow: 0 0 0 10px var(--green-soft); }

/* Volver: en la barra superior fija, siempre visible al desplazarse */
.top-back {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 8px 18px 8px 10px;
  font-size: 1.05rem; font-weight: 700; text-decoration: none; color: var(--bg);
  background: var(--text); border-radius: 999px;
}
.top-back svg { width: 24px; height: 24px; fill: currentColor; }
.top-back[hidden], .brand[hidden] { display: none; }

/* Aviso de no llamar a la víctima */
.no-call { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(242, 169, 59, .12); border: 1px solid var(--amber); font-size: .9rem; }

.sent-ok { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; font-weight: 650; color: #fff; background: var(--green); }
.sent-error { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--red-soft); border: 1px solid var(--red); }
.sent-error[hidden] { display: none; }

.evidence { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; font-size: .9rem; background: var(--surface-2); border: 1px solid var(--line); }

/* Alertas cerradas */
.closed-banner {
  display: flex; align-items: center; gap: 14px; padding: 16px; margin-bottom: 12px;
  border-radius: var(--radius); border: 2px solid;
}
.closed-banner b { font-size: 1.25rem; display: block; margin-bottom: 2px; }
.closed-banner .ico {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  font-size: 1.4rem; font-weight: 800; color: #fff;
}
.closed-banner.resolved { border-color: var(--green); background: var(--green-soft); }
.closed-banner.resolved .ico { background: var(--green); }
.closed-banner.false_alarm { border-color: var(--muted); background: var(--surface-2); }
.closed-banner.false_alarm .ico { background: var(--muted); color: var(--bg); }
.closed-banner.expired { border-color: var(--amber); background: rgba(242, 169, 59, .08); }
.closed-banner.expired .ico { background: var(--amber); color: var(--bg); }
.pill.expired { background: rgba(242, 169, 59, .15); color: var(--amber); }
.card.closed { opacity: .85; }
.alert-item.closed { border-left: 4px solid var(--muted); }
.alert-item.closed.resolved { border-left-color: var(--green); }
.alert-item.closed.expired { border-left-color: var(--amber); }

/* Alertas */
.alert-item { display: block; text-decoration: none; }
.alert-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.pill { flex: none; align-self: flex-start; line-height: 1.5; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.active { background: var(--red); color: #fff; }
.pill.resolved { background: var(--green); color: #fff; }
.pill.false_alarm { background: var(--surface-2); color: var(--muted); }
.pill.pending { background: rgba(242, 169, 59, .15); color: var(--amber); }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--red-soft); } }
.notes { list-style: none; padding: 0; margin: 4px 0 12px; border-left: 3px solid var(--amber); }
.notes li { display: flex; gap: 10px; padding: 4px 0 4px 10px; }
.notes li:first-child span { font-weight: 650; } /* el más reciente */
/* Detalles y respuestas de una alerta: caja con scroll propio que carga los anteriores al bajar */
.scroll-box { max-height: 45vh; overflow-y: auto; overscroll-behavior: contain; }
.more { text-align: center; margin: 8px 0; } /* "Cargando más…" al final de una lista con scroll infinito */
.notes time, .responses time { flex: none; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.responses { list-style: none; padding: 0; margin: 8px 0 0; }
.responses li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.resp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.resp-grid .btn { margin-top: 0; font-size: .9rem; }
.resp-grid .btn.on { outline: 2px solid var(--green); }
.counts { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0; font-size: .9rem; }
.counts b { font-size: 1.2rem; }

.member { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.member:first-of-type { border-top: 0; }
.member .actions { display: flex; gap: 6px; }
.member .actions .btn { width: auto; min-height: 44px; margin: 0; padding: 6px 10px; font-size: .85rem; }

ol.steps { padding-left: 1.2em; margin: 0; }
ol.steps li { margin-bottom: 6px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 12px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: #000; color: #fff; border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: .2s;
  z-index: 20; font-size: .9rem;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (prefers-reduced-motion: reduce) { .pulse, .reload.spinning svg { animation: none; } .reload.spinning { opacity: .6; } }
.tabs[hidden] { display: none; }
.member { flex-wrap: wrap; }
.member > div:first-child { flex: 1 1 180px; min-width: 0; }
.member .actions { flex-wrap: wrap; }
.member .actions .btn { white-space: nowrap; }
/* Miembros (administración): cada persona se pliega; las acciones, solo al desplegarla */
details.member.fold { display: block; }
details.member.fold > summary > div { flex: 1; min-width: 0; }
details.member.fold[open] > summary { margin-bottom: 8px; }
#memberZone { margin-bottom: 8px; }

/* Códigos de ingreso */
.code-input { font-size: 1.6rem; text-align: center; letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.code-answer { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-weight: 650; }
.code-big { margin: 8px 0; font-size: 2.6rem; font-weight: 850; text-align: center; letter-spacing: .15em; font-variant-numeric: tabular-nums; }
.sent-ok[hidden] { display: none; }

/* Alertas de distritos vecinos: naranja (vecino) y amarilla (cercano) */
:root { --orange: #f07c2a; --yellow: #e8c33b; }
.card.lvl-orange { border-color: var(--orange); background: rgba(240, 124, 42, .12); }
.card.lvl-yellow { border-color: var(--yellow); background: rgba(232, 195, 59, .10); }
.link-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.link-row span { flex: 1; min-width: 0; }
.link-row select { width: auto; flex: none; padding: 8px; }
.link-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.link-add .link-target { flex: 1 1 100%; }
.link-add .link-level { flex: 1; width: auto; }
.link-add .btn { width: auto; margin: 0; }
a.geo-row { text-decoration: none; }
a.geo-row > span { font-size: 1.4rem; color: var(--muted); flex: none; }

.tabs a[hidden] { display: none; }
/* Casillas con su explicación (reglas de las categorías) */
.check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; font-size: .95rem; color: var(--text); }
.check input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--red); }
.check small { display: block; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.chip.out { color: var(--orange); border-color: var(--orange); }

/* Secciones que se abren y se cierran (Ajustes) */
details.fold > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; min-height: 44px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; }
details.fold > summary::after { content: '▾'; color: var(--muted); font-size: 1.1rem; transition: transform .2s; }
details.fold[open] > summary { margin-bottom: 12px; }
details.fold[open] > summary::after { transform: rotate(180deg); }
.fold-note { font-size: .9rem; }

/* Accesos a las listas de Vecinos */
.nav-card { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.nav-card .ico { font-size: 1.5rem; line-height: 1; }
.nav-card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-card .count { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.nav-card .chev { color: var(--muted); font-size: 1.5rem; line-height: 1; }
input[type="search"] { margin-top: 4px; }

/* Menú ☰ junto al nombre del distrito */
.menu-btn {
  position: relative; /* para el número de respuestas nuevas (#menuBadge) */
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; margin-right: 2px; cursor: pointer;
  color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 10px;
}
.menu-btn svg { width: 22px; height: 22px; fill: currentColor; }
.menu-btn[hidden] { display: none; }
.menu-btn[aria-expanded="true"] { background: var(--surface-2); }
.menu {
  position: fixed; z-index: 20; top: calc(64px + var(--safe-t)); left: 12px; min-width: 220px;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.menu[hidden], .menu a[hidden] { display: none; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; text-decoration: none; font-weight: 600; }
.menu a:hover, .menu a.active { background: var(--surface-2); }
.menu svg { width: 22px; height: 22px; fill: var(--muted); }
.menu .badge { position: static; margin-left: auto; }
.menu-btn .badge { top: -2px; left: auto; right: -6px; }

/* Avisos */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: .4em; }
.title-row h1 { margin: 0; }
.btn.small-btn { width: auto; min-height: 44px; margin: 0; padding: 6px 12px; font-size: .9rem; }
.notice-item { display: flex; gap: 12px; text-decoration: none; }
.notice-item .ico { font-size: 1.5rem; line-height: 1.2; }
.notice-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notice-item:not(.unread) b { font-weight: 500; }
.notice-item.unread { border-color: var(--amber); }
.notice-item .excerpt { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.unread-dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: var(--amber); vertical-align: middle; }
.notice-body { white-space: pre-line; overflow-wrap: anywhere; }

/* Mal uso */
.abuse-item { color: inherit; text-decoration: none; }
.abuse-item .chev { color: var(--muted); font-size: 1.5rem; }
.abuse-events { list-style: none; padding: 0; margin: 0; }
.abuse-events li { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
.abuse-events li:first-child { border-top: 0; }
.abuse-events .pill { vertical-align: middle; }
select:disabled { opacity: .5; } /* registro: cantón y distrito se habilitan al elegir el nivel de arriba */

/* Administración: barrios con quién valida identidades y avisos con su lectura */
.zone-row { padding: 10px 0; border-top: 1px solid var(--line); }
.zone-row:first-of-type { border-top: 0; }
.zone-row .member { border-top: 0; padding-top: 0; }
.zone-row select { margin-top: 8px; padding: 8px 10px; font-size: .9rem; }
.chip-x { margin-left: 4px; padding: 6px 8px; min-width: 32px; min-height: 32px; font: inherit; color: var(--muted); background: none; border: 0; cursor: pointer; }
.admin-notice .reads { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.admin-notice .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.admin-notice .bar span { display: block; height: 100%; background: var(--green); }
.admin-notice .row .btn { min-height: 44px; }

/* Grupos y redes del distrito */
.link-list { display: grid; gap: 8px; }
.link-btn { justify-content: flex-start; gap: 12px; margin-top: 0; text-align: left; }
.link-btn .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.link-btn .small { font-weight: 400; }
.link-url { overflow-wrap: anywhere; }


/* Página principal (sin sesión). Se adapta al ancho de la página principal, no al de la pantalla (container queries): en
   el editor de Sistema, la vista previa dentro de una tarjeta se ve como en un teléfono. */
main.wide { max-width: 1120px; }
.landing { container-type: inline-size; }
.landing h2 { font-size: 1.35rem; letter-spacing: -.01em; margin: 0 0 16px; }
.lp-hero { display: grid; gap: 8px; padding: 8px 0 12px; }
.lp-hero-text { text-align: center; }
.lp-eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 6px 12px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text);
  background: var(--red-soft); border: 1px solid rgba(229, 50, 45, .35);
}
.lp-live { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 rgba(229, 50, 45, .6); animation: lp-live 2s infinite; }
@keyframes lp-live { 70% { box-shadow: 0 0 0 8px rgba(229, 50, 45, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 50, 45, 0); } }
.lp-hero h1 { font-size: clamp(1.9rem, 7cqi, 3.2rem); line-height: 1.08; letter-spacing: -.02em; margin: 0 0 14px; text-wrap: balance; }
.lp-lead { font-size: 1.1rem; line-height: 1.55; color: var(--muted); margin: 0 auto; max-width: 34em; text-wrap: pretty; }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.hero-actions .btn { margin: 0; }
.lp-trust { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 18px 0 0; padding: 0; font-size: .875rem; color: var(--muted); }
.lp-trust li::before { content: "✓"; color: var(--green); font-weight: 800; margin-right: 6px; }

/* El teléfono de la ilustración, con las ondas de alarma detrás */
/* Las ondas se centran con márgenes negativos (no con translate): Safari en iPhone las dejaba corridas hacia abajo, encima
   del texto. Los márgenes en % se calculan sobre el ancho, igual que width, así que sirven también para el alto. */
.landing { overflow-x: clip; } /* las ondas son más anchas que la pantalla del teléfono */
.lp-art { position: relative; isolation: isolate; padding: 28px 0 8px; } /* isolation: las ondas (z-index -1) quedan detrás del teléfono, no del fondo */
.lp-waves {
  position: absolute; z-index: -1; top: 50%; left: 50%; width: min(150%, 560px); height: auto; aspect-ratio: 1;
  margin: calc(min(150%, 560px) / -2) 0 0 calc(min(150%, 560px) / -2); pointer-events: none; animation: lp-breathe 4s ease-in-out infinite;
}
@keyframes lp-breathe { 50% { transform: scale(1.04); opacity: .8; } }
/* Las secciones de abajo quedan siempre encima de las ondas */
.lp-section, .lp-cta, .lp-footer { position: relative; }
.lp-phone {
  position: relative; width: 240px; margin: 0 auto; padding: 14px 14px 18px; border-radius: 34px; text-align: center;
  background: var(--bg); border: 8px solid #2a2e37; box-shadow: 0 30px 60px rgba(0, 0, 0, .55), 0 0 0 1px #3a3f4a;
}
.lp-phone-bar { display: flex; justify-content: space-between; align-items: center; font-size: .75rem; font-weight: 700; margin-bottom: 12px; }
.lp-phone-bar b { padding: 2px 9px; border: 1.5px solid var(--red); border-radius: 999px; }
.lp-phone-bar span { display: inline-flex; align-items: center; gap: 6px; }
.lp-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.lp-phone-alert { display: grid; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--red); font-size: .8rem; }
.lp-phone-alert small { color: var(--muted); }
.lp-pill { justify-self: start; font-size: .62rem; font-weight: 800; letter-spacing: .05em; padding: 1px 7px; border-radius: 999px; background: var(--red); color: #fff; }
.lp-phone-btn {
  display: grid; place-items: center; width: 132px; height: 132px; margin: 20px auto 8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f0524d, var(--red) 55%, var(--red-deep));
  box-shadow: 0 0 0 10px var(--red-soft), 0 12px 30px rgba(229, 50, 45, .45);
}
.lp-phone-btn span { font-size: 1.5rem; font-weight: 800; letter-spacing: .06em; color: #fff; }
.lp-phone-hint { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 12px; }
.lp-phone-where { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: .68rem; }
.lp-phone-where span { padding: 7px 4px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.lp-phone-where .on { border-color: var(--red); background: var(--red-soft); }

/* Secciones */
.lp-section { margin-top: 48px; }
.lp-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: none; }
/* En el teléfono, filas compactas: el número o el ícono a la izquierda; en computadora, tarjetas en columnas */
.lp-steps li, .lp-feature {
  display: grid; grid-template-columns: auto 1fr; column-gap: 14px; row-gap: 4px; align-items: start; margin: 0; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
}
.lp-steps li > :first-child, .lp-feature > :first-child { grid-row: span 2; }
.lp-steps li .muted, .lp-feature .muted { font-size: .95rem; line-height: 1.5; }
.lp-num {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--red); color: #fff; font-weight: 800; box-shadow: 0 0 0 5px var(--red-soft);
}
.lp-features { display: grid; grid-template-columns: 1fr; gap: 12px; }
.lp-ico { display: grid; place-items: center; width: 48px; height: 48px; font-size: 1.5rem; line-height: 1; background: var(--surface-2); border-radius: 14px; }
.lp-towns { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.lp-towns li { display: flex; flex-direction: column; padding: 10px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.lp-towns span { font-size: .8rem; color: var(--muted); }
.lp-cta {
  margin-top: 48px; padding: 28px 24px; border-radius: 22px; text-align: center; display: grid; gap: 16px; justify-items: center;
  background: radial-gradient(120% 140% at 0% 0%, rgba(229, 50, 45, .28), transparent 60%), var(--surface);
  border: 1px solid rgba(229, 50, 45, .35);
}
.lp-cta h2 { margin: 0 0 6px; }
.lp-cta p { margin: 0; }
.lp-cta .btn { margin: 0; width: auto; min-width: 200px; }
.lp-footer { margin: 40px 0 8px; padding-top: 20px; border-top: 1px solid var(--line); display: grid; gap: 8px; justify-items: center; }
.lp-brand { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 800; }
.lp-brand img { border-radius: 8px; }
.lp-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 20px; }
.lp-footer a, .lp-footer nav span { display: inline-flex; align-items: center; min-height: 44px; font-size: .9rem; color: var(--muted); text-decoration: none; }
.lp-footer a:hover { color: var(--text); text-decoration: underline; }

@container (max-width: 340px) { .hero-actions { grid-template-columns: 1fr; } }
@container (min-width: 560px) {
  .lp-features { grid-template-columns: 1fr 1fr; }
}
/* Computadora o tableta: el texto a la izquierda y el teléfono a la derecha; pasos en fila */
@container (min-width: 820px) {
  .lp-hero { grid-template-columns: 1.15fr .85fr; align-items: center; gap: 40px; padding: 40px 0 24px; }
  .lp-hero-text { text-align: left; }
  .lp-lead { margin: 0; }
  .hero-actions { display: flex; }
  .hero-actions .btn { width: auto; min-width: 180px; }
  .lp-trust { justify-content: flex-start; }
  .lp-art { padding: 0; }
  .landing { overflow-x: visible; } /* en computadora hay espacio: las ondas no se recortan */
  .lp-phone { width: 260px; }
  .lp-section { margin-top: 72px; }
  .landing h2 { font-size: 1.6rem; }
  .lp-steps { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .lp-steps li, .lp-feature { display: flex; flex-direction: column; gap: 6px; padding: 20px; }
  .lp-num, .lp-ico { margin-bottom: 6px; }
  .lp-features { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .lp-cta { grid-template-columns: 1fr auto; text-align: left; justify-items: stretch; align-items: center; padding: 36px 40px; margin-top: 72px; }
  .lp-footer { grid-template-columns: auto 1fr; justify-items: stretch; }
  .lp-footer nav { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) { .lp-live, .lp-waves { animation: none; } }
.landing.preview { pointer-events: none; }
.land-fieldset { border: 0; border-top: 1px solid var(--line); margin: 14px 0 0; padding: 4px 0 0; }
.land-fieldset legend { padding: 0 6px 0 0; font-weight: 650; }
.icon-row { display: grid; grid-template-columns: 76px 1fr; gap: 10px; }

/* Ayuda */
.nav-card .help-num { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); font-size: 1rem; font-weight: 700; }
.nav-card .excerpt { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Reportes de errores */
.bug-tech { margin-top: 4px; overflow-wrap: anywhere; }

/* Notificaciones obligatorias: pantalla para activarlas */
.gate { text-align: center; }
.gate .gate-ico { font-size: 3rem; line-height: 1; margin: 4px 0 8px; }
.gate .steps { text-align: left; }
/* Términos y Privacidad */
.legal h2 { font-size: 1.05rem; }
.legal p:last-child, .legal ul:last-child { margin-bottom: 0; }
.legal .steps { padding-left: 1.2em; }
/* Campo trampa contra robots: fuera de la vista, sin foco ni lector de pantalla */
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Aviso persistente: este teléfono no recibirá alertas. Aparece arriba en todas las pantallas, pero no es fijo (en un
   teléfono pequeño no debe quitarle espacio al botón AYUDA) ni bloquea: se puede seguir usando la app y pedir ayuda. */
.push-banner {
  flex: none; width: 100%; display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 0 auto;
  padding: 8px calc(16px + var(--safe-r)) 8px calc(16px + var(--safe-l));
  background: #3a2a0e; border-bottom: 2px solid var(--amber); color: var(--text); font-size: .875rem; line-height: 1.3;
}
.push-banner[hidden] { display: none; }
.push-banner .ico { font-size: 1.2rem; flex: none; }
.push-banner .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.push-banner .small { font-size: .8rem; }
.push-banner .btn { width: auto; flex: none; margin: 0; min-height: 44px; padding: 6px 10px; font-size: .85rem; max-width: 9em; text-align: center; line-height: 1.15; }

/* Pasos con estado (activación de notificaciones, estado del envío): ✓ listo, ✕ falla, ○ pendiente; con texto, no solo color */
.push-steps { list-style: none; margin: 0; padding: 0; }
.push-steps li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.push-steps li:first-child { border-top: 0; }
.push-steps .mark { flex: none; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  border: 2px solid var(--muted); color: var(--muted); font-weight: 800; font-size: .9rem; }
.push-steps li.done .mark { background: var(--green); border-color: var(--green); color: #fff; }
.push-steps li.bad .mark { background: var(--red); border-color: var(--red); color: #fff; }
.push-steps li > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.push-result { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.push-result.ok { border-color: var(--green); background: var(--green-soft); }
.push-result.bad { border-color: var(--red); background: var(--red-soft); }
.push-result[hidden] { display: none; }
.delivery h2 { margin-bottom: 4px; }

/* Ayuda para entrar: los pedidos se distinguen de los contactos de confianza */
.member.asking { background: rgba(242, 169, 59, .08); border-radius: 10px; padding-left: 8px; padding-right: 8px; }

/* Avisos: fecha y lugar del evento, distintos de la fecha de publicación */
.event-line { display: block; font-size: .9rem; margin-top: 2px; }
.event-box { display: grid; gap: 8px; margin: 4px 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--amber); }
.event-box div { display: flex; flex-direction: column; }
.event-fields { border: 1px solid var(--line); border-radius: 10px; margin: 12px 0 0; padding: 8px 12px 12px; min-width: 0; } /* sin min-width el fieldset crece con su contenido */
.event-fields[hidden] { display: none; }
.event-fields legend { padding: 0 6px; font-weight: 650; }


/* Horizontal o pantallas bajas: el botón se achica por el alto (ver .panic) y la barra inferior ocupa menos */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --tabs-h: calc(2.6rem + 8px); }
  .tabs a { flex-direction: row; gap: 6px; min-height: 40px; }
  .panic-wrap { padding: 8px 0 6px; }
}

/* Mensajes con la administración */
.msg-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.msg-replies { list-style: none; margin: 10px 0 0; padding: 0 0 0 10px; border-left: 3px solid var(--line); display: grid; gap: 8px; }
.msg-replies li.from-admin { border-left: 3px solid var(--green); margin-left: -13px; padding-left: 10px; }
.msg-reply textarea { margin-top: 10px; }
.msg-reply .row .btn { margin-top: 8px; }
.msg-reply .btn.primary { margin-top: 8px; }
/* Cerrar o terminar: aparte y discreto, para no tocarlo por error al responder */
.msg-reply .btn.msg-close { margin-top: 20px; color: var(--muted); font-weight: 500; }
/* Conversación plegable (lado de la administración) */
details.msg.fold > summary { display: block; min-height: 0; }
details.msg.fold > summary::after { display: block; text-align: center; margin-top: 4px; }
details.msg.fold[open] > summary { margin-bottom: 8px; }
.msg-sum { min-width: 0; }
.msg-snippet { margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.msg.fold[open] .msg-snippet { display: none; }

/* Cuadro para pedir la contraseña (confirmar que es la persona) */
dialog.ask {
  width: calc(100% - 32px); max-width: 420px; box-sizing: border-box; padding: 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
}
dialog.ask::backdrop { background: rgba(0, 0, 0, .6); }
dialog.ask p { margin-top: 0; }
dialog.ask .row { margin-top: 12px; }

/* Ajustes → otros dispositivos con la cuenta abierta */
.devices { list-style: none; padding: 0; margin: 10px 0 12px; }
.devices li { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.devices li.current b { color: var(--green, inherit); }

/* Foto de una persona (o sus iniciales) */
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; object-fit: cover;
  background: var(--line); color: var(--muted); font-weight: 700; }
.avatar-link { display: inline-flex; flex: none; border-radius: 50%; padding: 0; border: 0; background: none; cursor: zoom-in; }
dialog.photo-view { width: calc(100% - 32px); max-width: 480px; box-sizing: border-box; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); text-align: center; }
dialog.photo-view::backdrop { background: rgba(0, 0, 0, .75); }
dialog.photo-view img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
dialog.photo-view p { margin: 12px 0 0; }
/* Nombre alineado a la izquierda; a su derecha, en la misma línea, el enlace discreto para reportar la imagen */
dialog.photo-view .photo-name { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; text-align: left; }
dialog.photo-view .photo-name b { flex: 1; min-width: 0; }
dialog.photo-view .report-link { flex: none; margin: 0; padding: 10px 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: .8rem; text-decoration: underline; cursor: pointer; }
dialog.photo-view #photoReport { text-align: left; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > div { min-width: 0; }
.alert-item .who { margin: 6px 0 2px; }
.who.sender { margin: 8px 0; }
.photo-field .row { margin-top: 8px; }
