/* Preparació · app.css — estilos de la app (autocontenidos: rutas relativas, valen en la raíz y en una subcarpeta).
   Móvil primero (diseño a 360 px, objetivos táctiles ≥ 44 px), claro / oscuro (prefers-color-scheme o data-theme) y modo emergencia
   (data-theme="emergency": negro/blanco/amarillo, ≥ 7:1, texto ≥ 20 px, botones ≥ 64 px, sin animaciones). WCAG 2.2 AA. */
:root {
  --bg: #f6f5f9; --card: #ffffff; --ink: #14212b; --muted: #4a5b68; --line: #d3cfe0; --soft: #efe9f7;
  --brand: #5a2d86; --brand-ink: #ffffff; --brand-hover: #3f1d63; --deep: #1c3a5c; --field: #ffffff;
  --ok: #17603a; --ok-bg: #e2f4e8; --warn: #7a4f00; --warn-bg: #fff1cf; --bad: #8f1818; --bad-bg: #fbdada; --info-bg: #e6eef8;
  --sos: #b3141b; --sos-ink: #ffffff; --focus: #5a2d86;
  --r: 14px; --shadow: 0 1px 2px rgba(13, 26, 42, .06), 0 6px 20px rgba(13, 26, 42, .07);
  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Bricolage Grotesque", var(--font);
  --fs: 16px; --tap: 44px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="emergency"]) {
    --bg: #0d1a2a; --card: #14263d; --ink: #e9eef5; --muted: #aebdce; --line: #2f4866; --soft: #1d3350;
    --brand: #b08be0; --brand-ink: #0d1a2a; --brand-hover: #c9aef0; --deep: #8fb4e3; --field: #0d1a2a;
    --ok: #86dba2; --ok-bg: #15321f; --warn: #f0d86a; --warn-bg: #353010; --bad: #ff9c9c; --bad-bg: #3d1717; --info-bg: #17304d;
    --sos: #ff5a5f; --sos-ink: #1a0000; --focus: #c9aef0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  --bg: #0d1a2a; --card: #14263d; --ink: #e9eef5; --muted: #aebdce; --line: #2f4866; --soft: #1d3350;
  --brand: #b08be0; --brand-ink: #0d1a2a; --brand-hover: #c9aef0; --deep: #8fb4e3; --field: #0d1a2a;
  --ok: #86dba2; --ok-bg: #15321f; --warn: #f0d86a; --warn-bg: #353010; --bad: #ff9c9c; --bad-bg: #3d1717; --info-bg: #17304d;
  --sos: #ff5a5f; --sos-ink: #1a0000; --focus: #c9aef0; color-scheme: dark;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .3);
}
:root[data-theme="emergency"] {
  --bg: #000000; --card: #000000; --ink: #ffffff; --muted: #ffffff; --line: #ffffff; --soft: #1a1a1a;
  --brand: #ffd400; --brand-ink: #000000; --brand-hover: #ffe55c; --deep: #ffd400; --field: #000000;
  --ok: #7dff9b; --ok-bg: #000000; --warn: #ffd400; --warn-bg: #000000; --bad: #ff8080; --bad-bg: #000000; --info-bg: #000000;
  --sos: #ffd400; --sos-ink: #000000; --focus: #ffffff; --fs: 20px; --tap: 64px; --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs)/1.5 var(--font); }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--brand); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .center { text-align: center; }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink); padding: 10px 14px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- estructura ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { min-width: 0; white-space: nowrap; font: 700 1.2rem var(--font-head); color: var(--ink); text-decoration: none; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 28px; height: 28px; flex: none; }
.sos-btn { min-height: var(--tap); padding: 0 16px; border: 2px solid transparent; border-radius: 99px; background: var(--sos); color: var(--sos-ink); font: 800 .95rem var(--font); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; letter-spacing: .02em; }
.sos-btn:hover { filter: brightness(1.08); }
.lang-btn { min-height: var(--tap); min-width: var(--tap); padding: 0 10px; font-weight: 800; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; outline: none; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600; border-top: 3px solid transparent; }
.tabs a svg { width: 22px; height: 22px; }
.tabs a[aria-current="page"] { color: var(--brand); border-top-color: var(--brand); }
@media (min-width: 900px) {
  .tabs { position: static; border: 0; background: transparent; max-width: 760px; margin: 0 auto; padding: 8px 16px 0; gap: 8px; }
  .tabs a { flex: 0 0 auto; flex-direction: row; min-height: var(--tap); padding: 0 16px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); font-size: .95rem; }
  .tabs a[aria-current="page"] { border-color: var(--brand); background: var(--soft); }
  main { padding-bottom: 40px; }
  h1 { font-size: 1.9rem; }
}
.banner { position: sticky; top: 0; z-index: 30; background: var(--info-bg); border-bottom: 1px solid var(--line); padding: 10px 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.flash { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 40; max-width: min(92vw, 520px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; }
.flash:empty { display: none; }

/* ---------- componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 0 0 14px; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.card.err { border-color: var(--bad); }
.card.hl { border-color: var(--brand); background: var(--soft); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.btn { min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font: 600 1rem var(--font); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.field { display: block; margin: 0 0 12px; }
.field > span, label.lbl { display: block; font-weight: 600; margin: 0 0 4px; }
.field .hint { display: block; font-weight: 400; color: var(--muted); font-size: .875rem; margin-top: 2px; }
input[type="text"], input[type="tel"], input[type="email"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"], input[type="password"], input[type="file"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--field); color: var(--ink); font: inherit; }
textarea { min-height: 88px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; min-height: var(--tap); padding: 6px 0; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 4px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; border: 1px solid currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-bg); } .badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); } .badge.none { color: var(--muted); background: var(--soft); }
.stat { background: var(--soft); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font: 700 1.5rem var(--font-head); }
.note { background: var(--warn-bg); color: var(--ink); border-left: 5px solid var(--warn); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.note.info { background: var(--info-bg); border-color: var(--deep); }
.note.bad { background: var(--bad-bg); border-color: var(--bad); }
.qr { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; line-height: 0; }
.qr svg { width: 220px; height: 220px; }
pre.card-text { white-space: pre-wrap; background: var(--soft); border-radius: 10px; padding: 12px; font: .95rem/1.4 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.progress { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; } .progress > i { display: block; height: 100%; background: var(--brand); }
.welcome { text-align: center; padding-top: 12px; }
.welcome .logo { width: 88px; height: 88px; margin: 0 auto 8px; }
.langs { display: flex; gap: 8px; justify-content: center; margin: 12px 0 18px; }

/* ---------- modo emergencia ---------- */
.sos { max-width: 640px; margin: 0 auto; }
.sos h1 { font-size: 1.8rem; }
.sos .big { display: flex; width: 100%; min-height: 64px; margin: 0 0 12px; padding: 12px 18px; border: 3px solid var(--ink); border-radius: 12px; background: var(--card); color: var(--ink); font: 800 1.25rem var(--font); text-align: left; text-decoration: none; align-items: center; gap: 12px; cursor: pointer; }
.sos .big.call { background: var(--sos); color: var(--sos-ink); border-color: var(--sos); font-size: 1.6rem; min-height: 96px; justify-content: center; text-align: center; }
.sos .big small { font-weight: 600; font-size: 1rem; }
:root[data-theme="emergency"] .topbar, :root[data-theme="emergency"] .tabs { background: #000; border-color: #fff; }
:root[data-theme="emergency"] *, :root[data-theme="emergency"] *::before { animation: none !important; transition: none !important; }
:root[data-theme="emergency"] .btn { border: 3px solid #fff; }
:root[data-theme="emergency"] .btn.primary { background: #ffd400; color: #000; border-color: #ffd400; }
:root[data-theme="emergency"] .card { border: 3px solid #fff; }
:root[data-theme="emergency"] pre.card-text { background: #1a1a1a; color: #fff; font-size: 1.15rem; }
.cardfull { font-size: 1.2rem; }
.cardfull dt { font-weight: 800; margin-top: 10px; } .cardfull dd { margin: 0; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .topbar, .tabs, .banner, .flash, .noprint, .sos-btn { display: none !important; }
  body { background: #fff; color: #000; } main { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #999; break-inside: avoid; }
}
[hidden] { display: none !important; }
main:focus, main:focus-visible { outline: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; }
:root[data-theme="emergency"] .brand span { font-size: 1rem; }

/* ---------- F5a: familia, comunicación, radio y puntos de encuentro ---------- */
@media print {
  body[data-print] #app > * > :not(.fam-printable) { display: none !important; }
  body[data-print] .fam-printable { display: block !important; border: 0; box-shadow: none; }
}
textarea[readonly] { font: .85rem/1.35 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
/* Rv: objetivos táctiles de 44 px que faltaban (desplegables, marca, enlaces «Temario x» de los pasos) */
summary { min-height: var(--tap); padding: 10px 0; cursor: pointer; }
.brand { min-height: var(--tap); }
.list a.small, .row > a.small { display: inline-flex; align-items: center; min-height: var(--tap); }

/* ---------- F6b: modo cuenta, sincronización e historial (nada en línea: la CSP del host de la app prohíbe style="") ---------- */
.boot-msg { padding: 24px; font-family: system-ui, sans-serif; }
.sync-ind { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap); border-radius: 99px; text-decoration: none; color: var(--muted); }
.sync-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); border: 2px solid var(--card); box-shadow: 0 0 0 1.5px var(--line); }
.sync-ind[data-level="ok"] .sync-dot { background: var(--ok); box-shadow: 0 0 0 1.5px var(--ok); }
.sync-ind[data-level="busy"] .sync-dot { background: var(--brand); box-shadow: 0 0 0 1.5px var(--brand); animation: sync-pulse 1.2s ease-in-out infinite; }
.sync-ind[data-level="warn"] .sync-dot { background: var(--warn); box-shadow: 0 0 0 1.5px var(--warn); }
.sync-ind[data-level="bad"] .sync-dot { background: var(--bad); box-shadow: 0 0 0 1.5px var(--bad); }
.sync-ind[data-level="off"] .sync-dot { background: transparent; box-shadow: 0 0 0 2px var(--muted); }
@keyframes sync-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }
.acct-tabs { margin: 8px 0 0; }
.acct-tabs .btn[aria-pressed="true"] { cursor: default; }
.acct-modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(13, 26, 42, .6); overflow-y: auto; }
.acct-modal > .card { width: min(480px, 100%); margin: 0; }
.prep-msg:empty { display: none; }
.prep-msg { color: var(--bad); font-weight: 600; }
.progress[role="progressbar"] { margin: 6px 0; }
.prep-legal { max-width: 760px; margin: 0 auto; padding: 16px; }
