/* Tutor de Estudios — estilos base. Tres temas: familia (panel), peque (11) y mayor (14). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.45; }
img, svg { display: block; max-width: 100%; }
a { color: var(--link); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: var(--tracking, 0); }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }

/* ---------- Temas ---------- */
.t-familia {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font);
  --bg: #F4F6FA; --surface: #FFFFFF; --surface-2: #EEF1F7; --border: #DCE2EC;
  --text: #17202F; --muted: #566175; --link: #2450E0;
  --primary: #2450E0; --on-primary: #FFFFFF; --primary-shadow: transparent;
  --danger: #B3261E; --ok-bg: #DDF5EA; --ok-fg: #0B5C39; --err-bg: #FDE3E1; --err-fg: #8C1D18;
  --radius: 16px; --radius-lg: 22px;
}
.t-peque {
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
  --font-display: var(--font);
  --bg: #F3F6FD; --surface: #FFFFFF; --surface-2: #E6ECFF; --border: #D5DDF2;
  --text: #1B2340; --muted: #5A6380; --link: #2450E0;
  --primary: #2450E0; --on-primary: #FFFFFF; --primary-shadow: #1A3DB0;
  --danger: #B3261E; --ok-bg: #DDF5EA; --ok-fg: #0B5C39; --err-bg: #FDE3E1; --err-fg: #8C1D18;
  --radius: 20px; --radius-lg: 28px;
}
.t-mayor {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font); --tracking: -0.01em;
  --bg: #0E1014; --surface: #181B21; --surface-2: #22262E; --border: #2C313B;
  --text: #ECEEF3; --muted: #A2A8B5; --link: #C8F560;
  --primary: var(--accent, #C8F560); --on-primary: #0E1014; --primary-shadow: transparent;
  --danger: #FF8A8A; --ok-bg: rgba(95,211,184,.14); --ok-fg: #5FD3B8; --err-bg: rgba(255,138,138,.14); --err-fg: #FF8A8A;
  --radius: 16px; --radius-lg: 24px;
}
.t-mayor ::selection { background: var(--primary); color: var(--on-primary); }

/* ---------- Estructura ---------- */
.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 28px 16px 48px; display: flex; flex-direction: column; gap: 18px; }
.wrap.wide { max-width: 880px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.center { text-align: center; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.t-peque .card { border: none; box-shadow: 0 2px 0 rgba(27,35,64,.06); }
.hero-title { font-size: 30px; font-weight: 700; }
.t-peque .hero-title { font-size: 32px; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: var(--radius); border: none;
  background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer; box-shadow: 0 4px 0 var(--primary-shadow); }
.btn:hover { filter: brightness(1.05); }
.btn:focus-visible, .field input:focus-visible, .pick input:focus-visible + span, a:focus-visible, button:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn.block { width: 100%; }
.btn.big { min-height: 60px; font-size: 20px; }
.btn.ghost { background: transparent; color: var(--text); border: 2px solid var(--border); box-shadow: none; }
.btn.danger { background: transparent; color: var(--danger); border: 2px solid var(--border); box-shadow: none; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.linkbtn { background: none; border: none; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; font-size: 15px; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 700; font-size: 15px; }
.field input, .field select { min-height: 52px; padding: 0 16px; border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface); font-size: 17px; width: 100%; }
.field .hint { font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 420px) { .grid2.collapse { grid-template-columns: 1fr; } }

/* Tarjetas seleccionables (avatar, estilo) */
.pick { position: relative; display: block; cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick > span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 100px; padding: 12px 8px; border-radius: var(--radius); border: 3px solid var(--border); background: var(--surface); text-align: center; font-weight: 700; font-size: 14px; }
.pick input:checked + span { border-color: var(--primary); background: var(--surface-2); }

/* ---------- Avisos ---------- */
.alert { padding: 14px 16px; border-radius: var(--radius); font-weight: 600; }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert.error { background: var(--err-bg); color: var(--err-fg); }
.alert ul { margin: 0; padding-left: 18px; }

/* ---------- Avatares ---------- */
.blob { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--eye) * .35); flex: none; }
.blob .eyes { display: flex; gap: calc(var(--eye) * .6); }
.blob .eye { width: var(--eye); height: var(--eye); border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; }
.blob .eye span { width: var(--pupil); height: var(--pupil); border-radius: 50%; background: #1B2340; }
.blob .mouth { width: calc(var(--eye) * 1.1); height: calc(var(--eye) * .5); border-bottom: max(3px, calc(var(--eye) * .2)) solid #1B2340; border-radius: 0 0 50% 50% / 0 0 100% 100%; }

/* Pantalla "¿Quién eres?" */
.who { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.who a { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 12px; border-radius: var(--radius-lg); background: var(--surface); text-decoration: none; color: var(--text); font-weight: 800; font-size: 20px; box-shadow: 0 4px 0 #D5DDF2; }
.who a:hover { transform: translateY(-2px); }

/* ---------- PIN ---------- */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 6px 0; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--border); }
.pin-dots span.on { background: var(--primary); border-color: var(--primary); }
.pin-input { text-align: center; letter-spacing: .5em; font-size: 28px !important; font-weight: 700; }
.pinpad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 320px; margin: 0 auto; width: 100%; }
.pinpad button { min-height: 68px; border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface); font-size: 28px; font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 var(--border); }
.pinpad button:active { transform: translateY(2px); box-shadow: none; }
.pinpad .k-del { font-size: 18px; }
.js .pin-fallback { display: none; }
form.sending { opacity: .6; pointer-events: none; }

/* ---------- Panel parental ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; }
.kid { display: flex; flex-direction: column; gap: 14px; }
.kid-head { display: flex; gap: 14px; align-items: center; }
.kid-name { font-size: 20px; font-weight: 800; }
.chip { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 700; }
.chip.off { background: var(--err-bg); color: var(--err-fg); }
details.more { border-top: 1px solid var(--border); padding-top: 12px; }
details.more summary { cursor: pointer; font-weight: 700; color: var(--link); }
details.more .stack { margin-top: 12px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 160px; }
.checks .check { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--border); }
.checks .check:last-child { border-bottom: none; }
.checks .ok { color: #0B7A4B; font-weight: 800; }
.checks .ko { color: var(--danger); font-weight: 800; }
.qr { width: 220px; max-width: 100%; margin: 0 auto; background: #fff; padding: 8px; border-radius: 12px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; word-break: break-all; text-align: center; }

/* ---------- Alumno ---------- */
.kid-top { display: flex; align-items: center; gap: 14px; }
.plan { position: relative; overflow: hidden; background: var(--primary); color: var(--on-primary); border-radius: var(--radius-lg); padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.t-peque .plan::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.1); right: -60px; top: -70px; }
.plan .label { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.plan h2 { font-size: 28px; }
.soon { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.soon > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; min-height: 110px; display: flex; flex-direction: column; justify-content: space-between; font-weight: 700; }
.t-peque .soon > div { border: none; }
.soon .tag { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Aviso de entorno de pruebas ---------- */
.env-banner { position: sticky; top: 0; z-index: 10; background: repeating-linear-gradient(45deg, #FFC21A 0 14px, #FFD44D 14px 28px); color: #1B2340; text-align: center; font-weight: 800; font-size: 13px; letter-spacing: .04em; padding: 6px 12px; }

/* ---------- Códigos de recuperación ---------- */
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.codes code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; text-align: center; padding: 10px; border-radius: 10px; background: var(--surface-2); letter-spacing: .04em; }
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
@media print {
  .topbar, .btn, .env-banner, a { display: none !important; }
  body { background: #fff; }
  .card { border: 1px solid #999; }
}

/* ---------- Asignaturas (pegatinas) ---------- */
.stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sticker { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); font-weight: 700; }
.t-peque .sticker { border: none; }
.sticker-ico { width: 38px; height: 38px; flex: none; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--tint, var(--surface-2)); color: var(--fg, var(--text)); }
.pick.subject > span { flex-direction: row; justify-content: flex-start; min-height: 64px; text-align: left; gap: 10px; }
.pick.subject input:checked + span { border-color: var(--fg); background: var(--tint); }
.pick.subject input:checked + span::after { content: "✓"; margin-left: auto; width: 24px; height: 24px; border-radius: 50%; background: var(--fg); color: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex: none; }
.pick.course > span { min-height: 88px; font-size: 15px; }
.pick.course b { font-size: 32px; line-height: 1; }
.t-peque .pick > span { border-width: 3px; }
.t-mayor .pick input:checked + span { background: var(--surface-2); }
.is-hidden { display: none !important; }

/* ---------- Bienvenida por pasos ---------- */
fieldset.step { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
fieldset.step legend { padding: 0; margin-bottom: 4px; }
.steps-bar { display: none; gap: 6px; }
.steps-bar span { flex: 1; height: 8px; border-radius: 8px; background: var(--border); }
.steps-bar span.on { background: var(--primary); }
.js [data-steps] .steps-bar { display: flex; }
.steps-nav { display: flex; gap: 10px; }
.steps-nav .btn.big { flex: 1; }

/* ---------- Face ID ---------- */
.pk-card { border: 2px dashed var(--primary); }
.pk-ico { width: 48px; height: 48px; flex: none; border-radius: 14px; background: var(--surface-2); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; }
.t-peque .pk-ico { color: #2450E0; }

/* ---------- Menú inferior del alumno ---------- */
.kid-nav { position: sticky; bottom: 0; margin: 8px -16px -48px; padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--surface); border-top: 1px solid var(--border); }
.kid-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; border-radius: 12px; text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 700; }
.kid-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

/* El atributo hidden siempre gana a los estilos de componentes */
[hidden] { display: none !important; }

/* ---------- Tutor (chat) ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 88%; padding: 12px 16px; border-radius: 20px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble.tutor { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 6px; }
.t-peque .bubble.tutor { border: none; }
.bubble.me { align-self: flex-end; background: var(--primary); color: var(--on-primary); border-top-right-radius: 6px; font-weight: 600; }
.bubble.notice { align-self: center; background: var(--err-bg); color: var(--err-fg); font-size: 14px; font-weight: 600; text-align: center; }
.bubble.thinking { color: var(--muted); font-style: italic; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.field textarea { min-height: 88px; padding: 12px 16px; border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface); font-size: 17px; width: 100%; resize: vertical; font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button.sticker.as-button { cursor: pointer; font: inherit; color: inherit; text-align: left; }
.kid-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.meter { height: 12px; border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--primary); border-radius: 12px; }
label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
label.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--primary); }
a.plan { color: var(--on-primary); }
