/* Mensajería interna — piel Multiverso Norte (la misma que el fichaje y la web):
   base blanca, marino #12386e, naranja #ff9a00; Caveat Brush / Londrina Solid / Instrument Sans autoalojadas.
   Sin animaciones continuas: el mostrador la tiene abierta todo el día. */
@font-face { font-family: 'Caveat Brush'; src: url('/fonts/caveat-brush-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Londrina Solid'; src: url('/fonts/londrina-solid-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Londrina Solid'; src: url('/fonts/londrina-solid-900.woff2') format('woff2'); font-weight: 900; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/fonts/instrument-sans.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

:root {
  --bg: #f4f6fb; --surface: #fff; --surface-2: #f7f9fc; --line: #e2e8f2;
  --navy: #12386e; --navy-2: #0e2d5a; --navy-3: #1b4a8f;
  --ink: #15233c; --ink-2: #51607a; --ink-3: #8a97ad;
  --spot: #ff9a00; --spot-2: #ff8400; --spot-sft: #fff3e3;
  --verde: #1a9d5c; --rojo: #e03a2b; --rojo-sft: #fdecea;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-pill: 999px;
  --sh-md: 0 10px 26px -12px rgba(18,56,110,.22);
  --brush: 'Caveat Brush', 'Segoe UI', cursive;
  --slab: 'Londrina Solid', 'Arial Narrow', sans-serif;
  --body: 'Instrument Sans', system-ui, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.22,.61,.36,1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--spot); outline-offset: 2px; }

.vista { display: none; }
.vista.activa { display: block; }
.centro.activa { display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px; }
#v-app.activa { display: flex; flex-direction: column; height: 100dvh; }
.emblema-grande { width: 120px; opacity: .9; }

/* ---------- acceso ---------- */
.tarjeta { background: var(--surface); border-radius: var(--r-lg); box-shadow: 8px 8px 0 var(--spot), var(--sh-md); padding: 28px 24px; }
.acceso { width: min(400px, 100%); display: grid; gap: 14px; text-align: center; }
.emblema { width: 96px; margin: -4px auto 0; }
.titulo { font: 400 2.4rem/1 var(--brush); color: var(--navy); margin: 0; }
.sub { margin: -6px 0 6px; color: var(--ink-2); }
label { display: grid; gap: 6px; text-align: left; font-weight: 600; font-size: .95rem; }
input, textarea, select { width: 100%; border: 2px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; background: var(--surface); }
input:focus, textarea:focus, select:focus { border-color: var(--navy-3); outline: none; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: auto; }
.error { color: var(--rojo); min-height: 1.2em; margin: 0; font-size: .92rem; }

.btn { border: 0; border-radius: var(--r-pill); padding: 13px 22px; font: 400 1.15rem/1 var(--slab); letter-spacing: .03em; text-transform: uppercase; transition: transform 110ms var(--ease), background-color 170ms; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primario { background: var(--navy); color: #fff; }
.btn-ghost { background: transparent; border: 2px solid var(--line); color: var(--navy); }
.btn-mini { padding: 8px 14px; font-size: .95rem; }
.btn-icono { border: 0; background: transparent; color: #fff; font-size: 1.6rem; line-height: 1; width: 44px; height: 44px; border-radius: 50%; }

/* ---------- barra ---------- */
.barra { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--navy); color: #fff; box-shadow: 0 3px 0 var(--spot); z-index: 5; }
.emblema-barra { width: 40px; height: 40px; }
.barra-txt { display: grid; flex: 1; min-width: 0; line-height: 1.15; }
.barra-txt strong { font: 400 1.55rem/1 var(--slab); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-txt span { font-size: .85rem; opacity: .8; }
.punto-conexion { width: 10px; height: 10px; border-radius: 50%; background: #3ddc84; flex: none; }
.punto-conexion.mal { background: var(--rojo); }
.menu { position: absolute; right: 10px; top: calc(100% + 8px); background: var(--surface); color: var(--ink); border-radius: var(--r-md); box-shadow: var(--sh-md), 0 0 0 1px var(--line); display: grid; min-width: 260px; overflow: hidden; }
.menu button { border: 0; background: none; text-align: left; padding: 14px 18px; }
.aviso-sonido, .aviso-push { background: var(--spot); color: var(--navy-2); padding: 12px 16px; font-weight: 700; text-align: center; cursor: pointer; }
.aviso-push { display: flex; gap: 12px; align-items: center; justify-content: space-between; text-align: left; background: var(--spot-sft); font-weight: 500; cursor: default; }

/* ---------- cuerpo ---------- */
.cuerpo { flex: 1; display: flex; min-height: 0; }
.hilos { display: none; }
.modo-central .hilos { display: block; width: 320px; flex: none; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); }
.hilo { display: grid; gap: 4px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 14px 16px; border-left: 5px solid transparent; }
.hilo.activo { background: var(--spot-sft); border-left-color: var(--spot); }
.hilo-cab { display: flex; justify-content: space-between; gap: 8px; }
.hilo-cab strong { font: 400 1.25rem/1.1 var(--slab); text-transform: uppercase; color: var(--navy); }
.hilo-cab time { color: var(--ink-3); font-size: .85rem; }
.hilo-pie { display: flex; gap: 8px; align-items: center; }
.hilo-ultimo { flex: 1; color: var(--ink-2); font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hilo.sin-ver .hilo-ultimo { color: var(--ink); font-weight: 700; }
.insignia { background: var(--spot); color: var(--navy-2); font-weight: 800; border-radius: var(--r-pill); min-width: 24px; padding: 1px 8px; text-align: center; font-size: .85rem; }
.hilo.urgente .insignia { background: var(--rojo); color: #fff; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mensajes { flex: 1; overflow-y: auto; padding: 16px clamp(12px, 3vw, 40px); display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.vacio { color: var(--ink-3); text-align: center; margin: auto; max-width: 32ch; padding: 24px; }
.separador { align-self: center; background: var(--surface); color: var(--ink-2); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 12px; border-radius: var(--r-pill); margin: 8px 0; box-shadow: 0 0 0 1px var(--line); }
.burbuja { max-width: min(78%, 560px); padding: 9px 13px 6px; border-radius: 16px; background: var(--surface); box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line); display: grid; gap: 2px; }
.burbuja.suya { align-self: flex-start; border-bottom-left-radius: 4px; }
.burbuja.mia { align-self: flex-end; background: var(--navy); color: #fff; box-shadow: none; border-bottom-right-radius: 4px; }
.burbuja.urgente { box-shadow: 0 0 0 3px var(--rojo); }
.marca-urgente { font: 400 .85rem/1 var(--slab); letter-spacing: .06em; color: var(--rojo); }
.burbuja.mia .marca-urgente { color: #ffb3ab; }
.autor { font: 400 .95rem/1.1 var(--slab); text-transform: uppercase; color: var(--spot-2); }
.texto { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.02rem; }
.pie { display: flex; gap: 8px; justify-content: flex-end; font-size: .75rem; opacity: .75; }
.estado.visto { color: #9fe3bd; opacity: 1; font-weight: 700; }
.burbuja.suya .estado.visto { color: var(--verde); }

.redactar { border-top: 1px solid var(--line); background: var(--surface); padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.fila-redactar { display: flex; gap: 8px; align-items: flex-end; }
.fila-redactar textarea { resize: none; min-height: 48px; max-height: 160px; border-radius: 24px; padding: 12px 16px; }
.btn-enviar { height: 48px; flex: none; }
.urgente-toggle { display: inline-flex; align-items: center; gap: 8px; justify-self: start; font-weight: 700; color: var(--ink-2); padding: 4px 12px 4px 6px; border-radius: var(--r-pill); border: 2px solid var(--line); cursor: pointer; }
.urgente-toggle input { width: 20px; height: 20px; accent-color: var(--rojo); }
.urgente-toggle:has(input:checked) { border-color: var(--rojo); color: var(--rojo); background: var(--rojo-sft); }
.rapidas { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2px solid var(--line); background: var(--surface-2); border-radius: var(--r-pill); padding: 6px 14px; font-weight: 600; }

/* ---------- alerta del mostrador ---------- */
.alerta { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(14,45,90,.72); }
.alerta-tarjeta { width: min(720px, 100%); max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 26px; box-shadow: 10px 10px 0 var(--spot); padding: clamp(20px, 4vw, 40px); display: grid; gap: 14px; text-align: center; border: 6px solid var(--spot); }
.alerta.urgente .alerta-tarjeta { border-color: var(--rojo); box-shadow: 10px 10px 0 var(--rojo); }
.alerta-etiqueta { margin: 0; font: 400 1.2rem/1 var(--slab); letter-spacing: .06em; color: var(--spot-2); text-transform: uppercase; }
.alerta.urgente .alerta-etiqueta { color: var(--rojo); font-size: 1.5rem; }
.alerta-de { margin: 0; font: 400 clamp(2.4rem, 6vw, 3.6rem)/1 var(--brush); color: var(--navy); }
.alerta-texto { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }
.alerta-hora { margin: 0; color: var(--ink-2); }
.btn-visto { background: var(--verde); color: #fff; font-size: 2rem; padding: 18px; }
.alerta-rapidas { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip-grande { font-size: 1.1rem; padding: 10px 18px; }
.alerta-mas { margin: 0; color: var(--spot-2); font-weight: 700; }

/* ---------- personas ---------- */
.dialogo { border: 0; border-radius: var(--r-lg); padding: 0; width: min(620px, calc(100% - 24px)); max-height: 90dvh; box-shadow: var(--sh-md); }
.dialogo::backdrop { background: rgba(14,45,90,.55); }
.dialogo-cab { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--navy); color: #fff; position: sticky; top: 0; }
.titulo-s { margin: 0; font: 400 1.9rem/1 var(--brush); }
.personas { list-style: none; margin: 0; padding: 8px 18px; }
.persona { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.persona-info { display: grid; }
.persona-info strong { font: 400 1.2rem/1.1 var(--slab); text-transform: uppercase; color: var(--navy); }
.persona-info span { color: var(--ink-2); font-size: .88rem; }
.persona.de-baja { opacity: .55; }
.persona-acciones { display: flex; gap: 6px; }
.tu { color: var(--ink-3); font-weight: 700; }
.tarjeta-s { margin: 8px 18px 18px; padding: 16px; border: 2px dashed var(--line); border-radius: var(--r-md); display: grid; gap: 12px; }
.tarjeta-s h3 { margin: 0; font: 400 1.3rem/1 var(--slab); text-transform: uppercase; color: var(--navy); }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--r-pill); transition: opacity .2s, transform .2s var(--ease); z-index: 60; max-width: calc(100% - 32px); text-align: center; }
.toast.ver { opacity: 1; transform: translate(-50%, 0); }

/* hover solo con ratón (en el móvil se queda «pegado» tras tocar) */
@media (hover: hover) {
  .btn-primario:hover:not(:disabled) { background: var(--spot); color: var(--navy-2); }
  .btn-ghost:hover { border-color: var(--spot); color: var(--spot-2); }
  .btn-icono:hover { background: rgba(255,255,255,.12); }
  .menu button:hover { background: var(--spot-sft); }
  .hilo:hover { background: var(--surface-2); }
  .chip:hover { border-color: var(--spot); background: var(--spot-sft); }
  .btn-visto:hover { background: #158a50; }
}

/* mostrador en pantalla estrecha: lista o chat, uno cada vez */
@media (max-width: 759px) {
  .modo-central .hilos { width: 100%; border-right: 0; }
  .modo-central .chat { display: none; }
  .modo-central.ver-chat .hilos { display: none; }
  .modo-central.ver-chat .chat { display: flex; }
  .burbuja { max-width: 86%; }
}
@media (min-width: 760px) { .modo-central .js-volver { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
