:root {
  --bg: #f3f6f9; --surface: #fff; --ink: #18324a; --muted: #5b6f82; --line: #d9e2ea;
  --celeste: #3d8fd1; --celeste-soft: #e3f0fa; --sol: #f2b632; --ok: #2e9a63; --alert: #d6453d; --alert-soft: #fdeceb;
  --font: "Nunito", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1720; --surface: #17222e; --ink: #e6eef5; --muted: #9bb0c3; --line: #2a3a4a;
    --celeste: #6cb2ea; --celeste-soft: #1c3346; --ok: #4cc488; --alert: #ef6a62; --alert-soft: #3a1f1e; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 800; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--sol); outline-offset: 2px; }
input, textarea, select { font: inherit; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn { background: var(--celeste); color: #fff; width: 100%; }
.btn.sec { background: var(--celeste-soft); color: var(--celeste); }
.btn.red { background: var(--alert); }
.btn.ok { background: var(--ok); }

/* ---------- Cajita (pantalla de la abuela) ---------- */
body.cajita { background: #0f1a24; color: #fff; overflow: hidden; }
.pantalla { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; text-align: center; }
#reposo { background: #0f1a24; }
#foto-fondo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity 1.2s; }
#foto-fondo.sin { opacity: 0; }
.reloj { position: absolute; left: 4vw; bottom: 5vh; text-align: left; text-shadow: 0 2px 14px rgba(0,0,0,.6); }
.reloj .hora { font-size: 16vh; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.reloj .dia { font-size: 4.5vh; font-weight: 700; }
.pie-foto { position: absolute; right: 3vw; top: 4vh; background: rgba(0,0,0,.5); padding: 1vh 2vw; border-radius: 99px; font-size: 3vh; font-weight: 700; max-width: 60vw; }
.familia-tira { position: absolute; right: 3vw; bottom: 5vh; display: flex; gap: 1.5vw; }
.persona { background: rgba(0,0,0,.45); color: #fff; border-radius: 2vh; padding: 1.5vh; width: 15vh; display: flex; flex-direction: column; align-items: center; gap: 1vh; font-size: 2.6vh; }
.av { border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--celeste); overflow: hidden; flex: none; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.persona .av { width: 10vh; height: 10vh; font-size: 5vh; }
.estado-red { position: absolute; left: 3vw; top: 13vh; font-size: 2.4vh; background: rgba(0,0,0,.5); padding: .6vh 1.5vw; border-radius: 99px; }
#entrante, #saliente { background: linear-gradient(160deg, #1e4e78, #0f2a42); }
#entrante .av, #saliente .av { width: 30vh; height: 30vh; font-size: 14vh; box-shadow: 0 0 0 3vh rgba(108,178,234,.25), 0 0 0 6vh rgba(108,178,234,.1); margin-bottom: 4vh; }
.grande { font-size: 7vh; font-weight: 800; }
.medio { font-size: 3.6vh; opacity: .9; max-width: 70vw; }
.barra { width: 40vw; height: 1.2vh; border-radius: 9px; background: rgba(255,255,255,.2); overflow: hidden; }
.barra span { display: block; height: 100%; width: 0; background: var(--sol); }
.barra.corre span { animation: llenar 3s linear forwards; }
@keyframes llenar { to { width: 100%; } }
#llamada { background: #000; }
#remoto { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#local { position: absolute; right: 3vw; bottom: 4vh; width: 22vw; border-radius: 1.5vh; border: 3px solid #fff; transform: scaleX(-1); }
.en-llamada { position: absolute; left: 3vw; top: 4vh; background: var(--alert); padding: .6vh 1.5vw; border-radius: 99px; font-weight: 800; font-size: 2.6vh; }
.colgar { position: absolute; left: 50%; bottom: 4vh; transform: translateX(-50%); background: var(--alert); color: #fff; font-size: 3vh; padding: 2vh 5vw; border-radius: 99px; }
#emergencia { background: #3b1513; }
#emergencia .punto { width: 18vh; height: 18vh; border-radius: 50%; background: var(--alert); box-shadow: 0 0 0 3vh rgba(214,69,61,.3); margin-bottom: 4vh; animation: latido 1.4s ease-in-out infinite; }
@keyframes latido { 50% { transform: scale(1.08); } }
#activar { background: #132433; padding: 5vw; }
#activar button { font-size: 3.4vh; padding: 2.5vh 6vw; background: var(--sol); color: #18324a; }
.oido { position: absolute; left: 50%; top: 3vh; transform: translateX(-50%); background: rgba(0,0,0,.6); padding: 1vh 2vw; border-radius: 99px; font-size: 3vh; max-width: 80vw; }
#contactos { background: #132433; padding: 6vh 4vw; justify-content: flex-start; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(24vh, 1fr)); gap: 3vh; width: 100%; flex: 1; align-content: center; }
.rejilla .persona { width: auto; padding: 3vh; font-size: 3.4vh; background: rgba(255,255,255,.08); }
.rejilla .persona .av { width: 18vh; height: 18vh; font-size: 8vh; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- App familiar ---------- */
.app { max-width: 480px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cab h1 { font-size: 22px; margin: 0; }
.pill { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: var(--celeste-soft); color: var(--celeste); white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.bad { background: var(--alert-soft); color: var(--alert); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { font-size: 16px; margin: 0; }
.k { color: var(--muted); font-size: 13px; }
.alerta { border-color: var(--alert); background: var(--alert-soft); }
.log { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }
.miembro { display: flex; align-items: center; gap: 10px; }
.miembro .av { width: 36px; height: 36px; font-size: 15px; }
.miembro .nombre { flex: 1; min-width: 0; }
.miembro button { padding: 6px 10px; font-size: 13px; background: var(--alert-soft); color: var(--alert); }
.fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fotos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.enlace { word-break: break-all; font-size: 13px; background: var(--celeste-soft); padding: 10px; border-radius: 10px; }
.videollamada { position: fixed; inset: 0; background: #000; z-index: 10; }
.videollamada video.rem { width: 100%; height: 100%; object-fit: cover; }
.videollamada video.loc { position: absolute; right: 12px; top: 12px; width: 28vw; max-width: 160px; border-radius: 10px; border: 2px solid #fff; transform: scaleX(-1); }
.videollamada .barra-llamada { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff; text-align: center; }
.aviso { color: var(--alert); font-size: 14px; }
.ok-msg { color: var(--ok); font-size: 14px; }
.foto-item { display: flex; flex-direction: column; gap: 4px; }
.foto-acciones { display: flex; gap: 4px; }
.foto-acciones button { flex: 1; padding: 4px 2px; font-size: 12px; }
.foto-acciones button.peligro { color: #ff8a80; }
.mensaje { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -60%); width: 80vw; background: rgba(0,0,0,.72); border-radius: 3vh; padding: 3vh 4vw; text-align: center; box-shadow: 0 1vh 4vh rgba(0,0,0,.5); }
.mensaje .de { font-size: 3.5vh; font-weight: 700; opacity: .85; margin-bottom: 1vh; }
.mensaje .texto { font-size: 6vh; font-weight: 800; line-height: 1.2; }
.msg-lista { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.msg-item { display: flex; flex-direction: column; font-size: 14px; border-top: 1px solid var(--line); padding-top: 6px; }
.msg-item .k { font-size: 12px; opacity: .7; }

/* Rosa */
.btn-rosa { position: absolute; left: 3vw; top: 4vh; background: rgba(194,24,91,.92); color: #fff; border: 0; border-radius: 99px; padding: 1.8vh 3vw; font-size: 4vh; font-weight: 800; box-shadow: 0 .6vh 2vh rgba(0,0,0,.4); z-index: 4; }
.rosa-panel { position: absolute; left: 57%; top: 3vh; transform: translateX(-50%); width: 60vw; background: rgba(60,10,35,.85); border-radius: 2.5vh; padding: 2vh 3vw; text-align: center; box-shadow: 0 1vh 4vh rgba(0,0,0,.5); z-index: 5; }
.rosa-estado { font-size: 4vh; font-weight: 800; }
.rosa-dijo { font-size: 2.8vh; opacity: .8; margin-top: 1vh; font-style: italic; }
.rosa-resp { font-size: 4vh; font-weight: 700; line-height: 1.25; margin-top: 1.5vh; }
