@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
@font-face { font-family: 'Instrument'; src: url('/fonts/instrument.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Mono'; src: url('/fonts/mono.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Mono'; src: url('/fonts/mono-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

/* ---------- Paletas (modo claro) ---------- */
:root, [data-theme="mesa"]   { --p-bg:#E9E3D5; --p-ink:#16201B; --p-accent:#B94732; --p-soft:#F4EFE4; }
[data-theme="pizarra"]       { --p-bg:#E2E4DA; --p-ink:#1F3A2E; --p-accent:#3E6B4F; --p-soft:#EFF0E9; }
[data-theme="oceano"]        { --p-bg:#E4E7EE; --p-ink:#1B2440; --p-accent:#2F5BB7; --p-soft:#EFF1F6; }
[data-theme="grafito"]       { --p-bg:#E6E6E3; --p-ink:#1A1A1A; --p-accent:#1A1A1A; --p-soft:#F1F1EF; --p-accent-d:#E0E0DC; }
[data-theme="lavanda"]       { --p-bg:#E6E4EE; --p-ink:#2A2442; --p-accent:#6A4FC2; --p-soft:#F1EFF6; }
[data-theme="albaricoque"]   { --p-bg:#F1E9E0; --p-ink:#2A1A12; --p-accent:#B8532E; --p-soft:#F8F3EE; }
[data-theme="girasol"]       { --p-bg:#EEEDE3; --p-ink:#1D2742; --p-accent:#22345F; --p-soft:#F6F5EF; --p-accent-d:#E8B84A; }
[data-theme="sepia"]         { --p-bg:#E6DDCC; --p-ink:#3A2A1E; --p-accent:#8E3F28; --p-soft:#F2ECE1; }
[data-theme="rosa"]          { --p-bg:#F0E7E8; --p-ink:#2A1418; --p-accent:#A93552; --p-soft:#F8F2F3; }
[data-theme="escolar"]       { --p-bg:#E3E8EF; --p-ink:#22457E; --p-accent:#E2A33F; --p-soft:#EFF2F7; }
[data-theme="verde"]         { --p-bg:#E2E9E8; --p-ink:#1C3A3D; --p-accent:#2F7273; --p-soft:#EEF3F2; }
[data-theme="navidad"]       { --p-bg:#F3EADB; --p-ink:#1D3B2A; --p-accent:#C2352B; --p-soft:#FAF4EA; --p-accent-d:#E05A4E; }

:root {
  --bg: var(--p-bg);
  --card: #FFFFFF;
  --soft: var(--p-soft);
  --ink: var(--p-ink);
  --on-ink: #FFFFFF;
  --text: var(--p-ink);
  --muted: color-mix(in srgb, var(--p-ink) 58%, var(--p-bg));
  --line: color-mix(in srgb, var(--p-ink) 12%, transparent);
  --accent: var(--p-accent);
  --on-accent: #FFFFFF;
  --nav-bg: var(--p-ink);
  --ok: #2E7D4F; --ok-bg: #E5F0E8;
  --bad: #C8402F; --bad-bg: #FAEBE7;
  --hint-bg: #FBF0D6;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -12px rgba(0,0,0,.12);
  --r-lg: 28px; --r-md: 20px; --r-sm: 14px;
  --font-head: 'Bricolage', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Instrument', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --nav-h: 64px;
  color-scheme: light;
}
/* ---------- Modo oscuro (derivado de cada paleta) ---------- */
[data-dark="1"] {
  --bg: color-mix(in srgb, var(--p-ink) 62%, #000);
  --card: color-mix(in srgb, var(--p-ink) 82%, #fff);
  --soft: color-mix(in srgb, var(--p-ink) 72%, #fff);
  --ink: var(--p-bg);
  --on-ink: var(--p-ink);
  --text: #F2EEE6;
  --muted: color-mix(in srgb, #F2EEE6 60%, transparent);
  --line: rgba(255,255,255,.10);
  --accent: var(--p-accent-d, color-mix(in srgb, var(--p-accent) 78%, #fff));
  --on-accent: #fff;
  --nav-bg: color-mix(in srgb, var(--p-ink) 40%, #000);
  --ok: #5DBB83; --ok-bg: rgba(93,187,131,.14);
  --bad: #EE7B67; --bad-bg: rgba(238,123,103,.14);
  --hint-bg: rgba(240,200,110,.14);
  --shadow: 0 1px 2px rgba(0,0,0,.2), 0 10px 30px -14px rgba(0,0,0,.5);
  color-scheme: dark;
}
[data-dark="1"][data-theme="grafito"] { --on-accent: #1A1A1A; }
[data-dark="1"][data-theme="girasol"] { --on-accent: #1D2742; }
[data-theme="escolar"] { --on-accent: #1F2A44; }

/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); overscroll-behavior-y: none; }
/* Sin zoom por doble toque; textos que no se agrandan solos al girar el móvil */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
* { touch-action: manipulation; }
body { font-family: var(--font-body); font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased; min-height: 100dvh; transition: background .25s; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
h1, h2, h3 { font-family: var(--font-head); margin: 0; letter-spacing: -0.02em; }

#app { max-width: 600px; margin: 0 auto; min-height: 100dvh; }
.page { padding: calc(env(safe-area-inset-top) + 28px) 22px calc(var(--nav-h) + 40px + env(safe-area-inset-bottom)); }
.page.no-nav { padding-bottom: 40px; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; min-height: 60px; }
.page-head h1 { font-size: clamp(28px, 8.6vw, 42px); font-weight: 800; line-height: 1.05; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-bottom: 2px; }
.page-head .small-title { font-size: 26px; font-weight: 800; }
.label { font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 30px 2px 12px; display: flex; justify-content: space-between; align-items: baseline; }
.label b { font-family: var(--font-head); letter-spacing: -0.01em; text-transform: none; font-size: 17px; color: var(--text); }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 12px; }
.card.dark { background: var(--nav-bg); color: #F4F0E8; border-color: transparent; box-shadow: 0 6px 0 -1px var(--accent); }
[data-dark="1"] .card.dark { background: var(--card); color: var(--text); }
.stack > * + * { margin-top: 12px; }

.row { display: flex; align-items: center; gap: 16px; padding: 20px 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); width: 100%; text-align: left; }
.row + .row { margin-top: 12px; }
.row .ico { width: 24px; height: 24px; flex: none; color: var(--text); }
.row .ico svg { width: 24px; height: 24px; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-family: var(--font-head); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.row .sub { color: var(--muted); font-size: 14.5px; margin-top: 2px; }
.row .end { color: var(--muted); display: flex; align-items: center; gap: 8px; font-size: 16px; flex: none; }
.row .end svg { width: 20px; height: 20px; }
.row:disabled { opacity: .55; }
button.row:active { transform: scale(.99); }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 54px; padding: 0 22px; border-radius: var(--r-sm); font-weight: 700; font-size: 17px; font-family: var(--font-head); transition: transform .08s, opacity .15s; white-space: nowrap; }
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 22px; height: 22px; }
.btn-dark { background: var(--ink); color: var(--on-ink); box-shadow: 0 5px 0 0 var(--accent); margin-bottom: 5px; }
.btn-dark:active { box-shadow: 0 3px 0 0 var(--accent); }
.btn-solid { background: var(--ink); color: var(--on-ink); }
.btn-accent { background: var(--accent); color: var(--on-accent); border-radius: 18px; }
.btn-outline { border: 2px solid var(--ink); color: var(--text); background: transparent; }
.btn-ghost { color: var(--text); background: var(--soft); }
.btn-danger { color: var(--bad); background: var(--bad-bg); }
.btn-block { width: 100%; }
.btn-sm { height: 42px; padding: 0 16px; font-size: 15px; border-radius: 12px; }

.icon-btn { width: 58px; height: 58px; border-radius: 50%; background: var(--card); border: 1.5px solid var(--line); display: grid; place-items: center; box-shadow: var(--shadow); flex: none; }
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn.sm { width: 44px; height: 44px; box-shadow: none; }
.icon-btn.sm svg { width: 22px; height: 22px; }
.icon-btn.plain { background: transparent; border: 0; box-shadow: none; }

.pill { display: inline-flex; align-items: center; height: 46px; padding: 0 20px; border-radius: 999px; border: 2px solid var(--line); font-size: 17px; font-weight: 600; color: var(--muted); background: transparent; white-space: nowrap; }
.pill.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.pills { display: flex; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; background: #F1DC6A; color: #1E1E12; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.soft { background: var(--soft); color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Segmentado ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1.5px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--card); }
.seg button { height: 60px; font-size: 18px; font-weight: 600; color: var(--muted); border-left: 1.5px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--ink); color: var(--on-ink); font-weight: 700; }

/* ---------- Formularios ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 4px 8px; }
.input, textarea.input, select.input { width: 100%; min-height: 54px; padding: 14px 16px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--card); outline: none; font-size: 17px; transition: border-color .15s; }
.input:focus { border-color: var(--ink); }
textarea.input { resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--font-mono); font-size: 16px; min-height: 280px; }
.input.code-in { font-family: var(--font-mono); letter-spacing: .12em; text-transform: uppercase; font-size: 20px; text-align: center; }

.switch { position: relative; width: 76px; height: 44px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line); border: 3px solid var(--line); transition: .2s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 32px; height: 32px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.switch input:checked + i { background: var(--ink); border-color: color-mix(in srgb, var(--ink) 20%, var(--bg)); }
.switch input:checked + i::after { left: 35px; background: var(--bg); }

/* ---------- Navegación inferior ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--nav-bg); border-top: 3px solid var(--accent); padding-bottom: max(6px, min(env(safe-area-inset-bottom), 18px)); }
.nav-inner { max-width: 600px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--nav-h); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: rgba(244,240,232,.58); font-size: 13.5px; font-weight: 600; letter-spacing: .01em; position: relative; padding-top: 4px; }
.nav a svg { width: 26px; height: 26px; stroke-width: 1.9; }
.nav a.on svg { stroke-width: 2.3; }
.nav a.on { color: #FFF; font-weight: 700; }
.nav a.on::after { content: ''; position: absolute; bottom: 1px; width: 26px; height: 3px; border-radius: 3px; background: var(--accent); }
.nav a { padding-bottom: 6px; }

/* ---------- Asignaturas ---------- */
.recents { display: flex; gap: 12px; overflow-x: auto; margin: 0 -22px; padding: 2px 22px 8px; scrollbar-width: none; }
.recents::-webkit-scrollbar { display: none; }
.recent { flex: none; width: 210px; min-height: 130px; display: flex; flex-direction: column; justify-content: space-between; padding: 18px; text-align: left; }
.recent .t { font-family: var(--font-head); font-weight: 700; font-size: 18px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recent .s { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; margin-top: 14px; }
.recent .s .dot { width: 10px; height: 10px; }
.subject { display: block; width: 100%; text-align: left; position: relative; }
.subject .top { display: flex; align-items: center; gap: 18px; }
.subject .ini { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-family: var(--font-head); font-weight: 800; font-size: 30px; flex: none; }
.subject .name { font-family: var(--font-head); font-weight: 700; font-size: 24px; flex: 1; letter-spacing: -0.02em; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.subject .meta { color: var(--muted); margin-top: 14px; font-size: 16px; }

.test-item { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; }
.test-item .main { flex: 1; min-width: 0; }
.test-item .t { font-family: var(--font-head); font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.test-item .m { color: var(--muted); font-size: 14.5px; margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.score-ring { width: 54px; height: 54px; flex: none; position: relative; display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; font-size: 13px; }
.score-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }

/* ---------- Test ---------- */
.quiz-top { display: flex; align-items: center; gap: 18px; }
.quiz-top .count { font-family: var(--font-mono); font-weight: 700; font-size: 20px; letter-spacing: .06em; flex: 1; }
.flag.on { color: var(--accent); }
.flag.on svg { fill: currentColor; }
.segments { display: flex; gap: 6px; margin: 16px 0 26px; }
.segments i { flex: 1; height: 8px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 14%, transparent); transition: background .2s; }
.segments i.done { background: var(--ink); }
.segments i.wrong { background: color-mix(in srgb, var(--accent) 45%, var(--ink)); }
.segments i.cur { background: var(--accent); }
.segments.many i { height: 6px; border-radius: 3px; }
.tag { display: inline-block; max-width: 92%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-weight: 700; font-size: 13.5px; letter-spacing: .12em; text-transform: uppercase; padding: 9px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; color: var(--text); }
.q-card { margin-top: 16px; background: var(--card); border-radius: var(--r-lg); padding: 26px 24px 28px; border: 1px solid var(--line); box-shadow: 0 6px 0 0 var(--ink); margin-bottom: 26px; }
.q-card h2 { font-size: clamp(22px, 6vw, 30px); font-weight: 800; line-height: 1.15; white-space: pre-wrap; }
.opt { display: flex; align-items: center; gap: 18px; width: 100%; padding: 16px 18px; min-height: 76px; text-align: left; border-radius: var(--r-md); background: var(--card); border: 2px solid var(--line); font-size: 19px; transition: transform .08s, border-color .15s; }
.opt + .opt { margin-top: 12px; }
.opt:not(:disabled):active { transform: scale(.985); }
.opt:not(:disabled):hover { border-color: color-mix(in srgb, var(--ink) 35%, transparent); }
.opt .l { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--soft); font-family: var(--font-mono); font-weight: 700; color: var(--muted); flex: none; font-size: 16px; }
.opt .l svg { width: 22px; height: 22px; }
.opt.right { border-color: var(--ok); background: var(--ok-bg); font-weight: 600; }
.opt.right .l { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); font-weight: 600; }
.opt.wrong .l { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; color: var(--text); }
.hint { display: flex; gap: 16px; margin-top: 22px; padding: 20px 22px; background: var(--hint-bg); border-radius: var(--r-md); font-size: 17px; line-height: 1.5; animation: fade .25s; }
.hint svg { width: 26px; height: 26px; flex: none; margin-top: 1px; }
.quiz-foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 16px 22px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); z-index: 10; }
.quiz-foot .in { max-width: 556px; margin: 0 auto; display: grid; grid-template-columns: 1fr 2fr; gap: 14px; }
.quiz-foot .btn { height: 64px; font-size: 20px; }
.quiz-foot .btn-outline { border-radius: 16px; }
.quiz-foot .btn-solid { border-radius: 16px; }

.result-big { text-align: center; padding: 34px 22px; }
.result-big .pct { font-family: var(--font-head); font-size: 76px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.result-big .msg { font-family: var(--font-head); font-size: 22px; font-weight: 700; margin-top: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 6px; margin-top: 24px; }
.stats b { font-family: var(--font-head); font-size: 30px; font-weight: 800; display: block; }
.stats span { color: var(--muted); font-size: 14px; }
.review-q { padding: 18px 20px; }
.review-q .q { font-weight: 700; font-family: var(--font-head); font-size: 17px; }
.review-q .a { margin-top: 8px; font-size: 15px; display: flex; gap: 8px; align-items: flex-start; }
.review-q .a svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* ---------- Editor de preguntas ---------- */
.qe { padding: 18px; }
.qe-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.qe textarea.input { min-height: 70px; font-weight: 600; }
.qe-opt { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.qe-opt .mark { width: 44px; height: 44px; border-radius: 12px; flex: none; background: var(--soft); font-family: var(--font-mono); font-weight: 700; color: var(--muted); display: grid; place-items: center; border: 2px solid transparent; }
.qe-opt .mark.on { background: var(--ok); color: #fff; }
.qe-opt .mark svg { width: 20px; height: 20px; }
.qe-opt .input { min-height: 46px; padding: 10px 14px; font-size: 16px; }
.qe-opt.on .input { border-color: var(--ok); }
.qe .expl { margin-top: 10px; font-size: 16px; min-height: 46px; padding: 10px 14px; }
.qe.err { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad-bg); }
.qe .errs { color: var(--bad); font-size: 14px; font-weight: 600; margin-top: 10px; }
.link-btn { color: var(--muted); font-weight: 600; font-size: 15px; padding: 8px 4px; display: inline-flex; gap: 6px; align-items: center; }
.link-btn svg { width: 18px; height: 18px; }
.sticky-foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 28%); z-index: 15; }
.sticky-foot .in { max-width: 556px; margin: 0 auto; display: flex; gap: 12px; }
.sticky-foot .in > * { flex: 1; }

.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 190px; border: 2px dashed color-mix(in srgb, var(--ink) 25%, transparent); border-radius: var(--r-md); text-align: center; padding: 22px; cursor: pointer; transition: .15s; background: var(--soft); }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.drop svg { width: 40px; height: 40px; color: var(--muted); }
.drop b { font-family: var(--font-head); font-size: 19px; }
.helpbox { background: var(--soft); border-radius: var(--r-sm); padding: 16px; font-size: 14.5px; line-height: 1.55; margin-top: 12px; }
.helpbox pre { font-family: var(--font-mono); font-size: 13px; background: var(--card); padding: 12px; border-radius: 10px; overflow-x: auto; margin: 10px 0 0; border: 1px solid var(--line); }

/* ---------- Temas ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 440px) { .theme-grid { grid-template-columns: repeat(3, 1fr); } }
.theme-card { background: var(--card); border: 2px solid var(--line); border-radius: 22px; padding: 12px 6px 14px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 18px; min-height: 150px; font-size: 15px; font-weight: 600; text-align: center; line-height: 1.15; }
.theme-card.on { border: 3px solid var(--text); }
.swatch { width: 72%; max-width: 92px; aspect-ratio: 1.3; border-radius: 12px; border: 2px solid rgba(0,0,0,.08); padding: 10% 9%; display: flex; flex-direction: column; justify-content: space-between; }
.swatch i { width: 26%; aspect-ratio: 1; border-radius: 50%; }
.swatch b { height: 28%; border-radius: 6px; }

/* ---------- Perfil ---------- */
.profile { display: flex; align-items: center; gap: 18px; padding: 22px; }
.avatar { width: 72px; height: 72px; border-radius: 50%; background: rgba(255,255,255,.14); display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 34px; flex: none; }
.profile .n { font-family: var(--font-head); font-weight: 800; font-size: 26px; letter-spacing: -0.02em; text-transform: uppercase; }
.profile .e { opacity: .75; font-size: 16px; margin-top: 2px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 40px 22px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.brand-mark { width: 58px; height: 58px; border-radius: 18px; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; box-shadow: 0 5px 0 var(--accent); }
.brand-mark svg { width: 32px; height: 32px; }
.login h1 { font-size: 46px; font-weight: 800; }

/* ---------- Vacíos ---------- */
.empty { text-align: center; padding: 42px 26px; }
.empty .big-ico { width: 76px; height: 76px; border-radius: 22px; background: var(--soft); display: grid; place-items: center; margin: 0 auto 18px; color: var(--muted); }
.empty .big-ico svg { width: 38px; height: 38px; }
.empty h3 { font-size: 22px; font-weight: 800; }
.empty p { color: var(--muted); margin: 8px auto 0; max-width: 340px; }

/* ---------- Modales, hojas y avisos ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(10,12,10,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: bd .18s; }
@keyframes bd { from { opacity: 0; } }
.sheet { width: 100%; max-width: 600px; background: var(--bg); border-radius: 28px 28px 0 0; padding: 12px 22px calc(26px + env(safe-area-inset-bottom)); animation: up .24s cubic-bezier(.2,.9,.3,1); max-height: 92dvh; overflow-y: auto; }
@keyframes up { from { transform: translateY(100%); } }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 18px; }
.sheet h3 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.sheet .desc { color: var(--muted); margin: 0 0 18px; }
.sheet .actions { display: flex; gap: 12px; margin-top: 18px; }
.sheet .actions > * { flex: 1; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 18px 18px; font-size: 18px; font-weight: 600; background: var(--card); border-radius: var(--r-sm); text-align: left; }
.menu-item + .menu-item { margin-top: 8px; }
.menu-item svg { width: 22px; height: 22px; }
.menu-item.danger { color: var(--bad); }
.colors { display: flex; gap: 12px; flex-wrap: wrap; }
.colors button { width: 44px; height: 44px; border-radius: 12px; border: 3px solid transparent; }
.colors button.on { border-color: var(--text); box-shadow: inset 0 0 0 3px var(--bg); }

.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 16px); transform: translateX(-50%); z-index: 100; background: var(--ink); color: var(--on-ink); padding: 14px 20px; border-radius: 16px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 32px); animation: tin .25s; }
.toast.err { background: var(--bad); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translate(-50%, -12px); } }

.spinner { width: 22px; height: 22px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-ai { text-align: center; padding: 40px 20px; }
.loading-ai .spinner { width: 44px; height: 44px; border-width: 4px; margin: 0 auto 18px; color: var(--accent); }

.code-box { font-family: var(--font-mono); font-weight: 700; font-size: 26px; letter-spacing: .1em; text-align: center; padding: 22px 10px; background: var(--card); border: 2px dashed var(--ink); border-radius: var(--r-md); user-select: all; }
.sep { height: 1px; background: var(--line); margin: 18px 0; }
.hidden { display: none !important; }
@media (min-width: 700px) { .page { padding-top: 48px; } }

@media (max-width: 430px) {
  .page-head .icon-btn { width: 52px; height: 52px; }
  .btn-collapse { width: 54px; padding: 0; }
  .btn-collapse span { display: none; }
  .subject .icon-btn.sm { width: 36px; }
}

/* ---------- Barra superior del test ---------- */
.qhead { display: flex; align-items: center; gap: 10px; }
.qhead .icon-btn.sm { background: var(--card); border: 1.5px solid var(--line); }
.qring { width: 56px; height: 56px; position: relative; display: grid; place-items: center; flex: none; font-family: var(--font-mono); font-weight: 700; font-size: 12px; letter-spacing: -0.02em; }
.qring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.qtitle { flex: 1; min-width: 0; }
.qtitle .k { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qtitle .t { font-family: var(--font-head); font-weight: 800; font-size: 18px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cnt { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border-radius: 999px; font-family: var(--font-mono); font-weight: 700; font-size: 14px; border: 1.5px solid currentColor; flex: none; }
.cnt svg { width: 14px; height: 14px; }
.cnt.ok { color: var(--ok); background: var(--ok-bg); }
.cnt.bad { color: var(--bad); background: var(--bad-bg); }
.qtools { display: flex; gap: 7px; align-items: center; margin-top: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 13px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-size: 14.5px; color: var(--muted); transition: .15s; }
.chip svg { width: 16px; height: 16px; }
.chip.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); box-shadow: 0 3px 0 var(--accent); }
.mode-toggle { margin-left: auto; width: 60px; height: 34px; border-radius: 999px; position: relative; flex: none; background: linear-gradient(135deg, #8ECDF5, #D3EEFF); border: 1.5px solid rgba(0,0,0,.08); transition: background .25s; }
.mode-toggle i { position: absolute; top: 2px; left: 2px; width: 28px; height: 28px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-style: normal; font-size: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .25s; }
.mode-toggle.dark { background: linear-gradient(135deg, #1D2440, #3A4470); }
.mode-toggle.dark i { left: 27px; background: #2A3152; }
.q-card.has-flag { position: relative; padding-right: 58px; }
.qflag { position: absolute; top: 14px; right: 12px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.qflag svg { width: 22px; height: 22px; }
.qflag.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.qstrip { display: flex; align-items: center; gap: 8px; margin: 14px 0 20px; }
.qnums { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 5px 4px; scroll-behavior: smooth; }
.qnums::-webkit-scrollbar { display: none; }
.qn { flex: none; min-width: 42px; height: 42px; padding: 0 6px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--muted); position: relative; }
.qn.ok { background: var(--ok); color: #fff; border-color: transparent; }
.qn.bad { background: var(--bad); color: #fff; border-color: transparent; }
.qn.cur { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4.5px var(--accent); color: var(--text); }
.qn.cur.ok, .qn.cur.bad { color: #fff; }
.qn.fl::after { content: ''; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: #E2A33F; }
.arrow { flex: none; width: 42px; height: 42px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); display: grid; place-items: center; color: var(--text); }
.arrow svg { width: 18px; height: 18px; }
.arrow:disabled { opacity: .35; }
@media (max-width: 400px) { .qtools { gap: 5px; } .chip { padding: 0 8px; height: 36px; font-size: 13px; gap: 4px; } .chip svg { width: 15px; height: 15px; } .mode-toggle { width: 50px; height: 32px; } .mode-toggle i { width: 26px; height: 26px; font-size: 14px; } .mode-toggle.dark i { left: 19px; } .cnt { padding: 0 8px; font-size: 13px; } .qring { width: 50px; height: 50px; font-size: 11px; } }

/* ---------- Test a pantalla completa, sin desplazarse ---------- */
.quiz-page { height: 100dvh; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 10px); overflow: hidden; }
.quiz-page.enter { animation: fade .2s ease; }
.quiz-page .qhead { gap: 8px; }
.quiz-page .qhead .icon-btn.sm { width: 40px; height: 40px; }
.quiz-page .qring { width: 46px; height: 46px; font-size: 11px; }
.quiz-page .qtitle .t { font-size: 16px; }
.quiz-page .cnt { height: 28px; padding: 0 8px; font-size: 13px; }
.quiz-page .qtools { margin-top: 10px; gap: 6px; }
.quiz-page .chip { height: 32px; padding: 0 10px; font-size: 13.5px; gap: 5px; box-shadow: none; }
.quiz-page .chip.on { box-shadow: 0 2px 0 var(--accent); }
.quiz-page .chip svg { width: 15px; height: 15px; }
.quiz-page .mode-toggle { width: 50px; height: 30px; }
.quiz-page .mode-toggle i { width: 24px; height: 24px; font-size: 13px; top: 1.5px; left: 2px; }
.quiz-page .mode-toggle.dark i { left: 21px; }
.quiz-page .qstrip { margin: 10px 0 12px; gap: 6px; }
.quiz-page .qn { min-width: 36px; height: 36px; border-radius: 10px; font-size: 13px; }
.quiz-page .arrow { width: 36px; height: 36px; border-radius: 10px; }
.quiz-body { --qs: 1; flex: 1; min-height: 0; overflow-y: auto; padding: 2px 2px 6px; display: flex; flex-direction: column; }
.quiz-body .q-card { margin: 0 0 calc(14px * var(--qs)); padding: calc(18px * var(--qs)) 50px calc(18px * var(--qs)) calc(18px * var(--qs)); border-radius: 22px; box-shadow: 0 4px 0 0 var(--ink); }
.quiz-body .q-card h2 { font-size: calc(23px * var(--qs)); line-height: 1.18; }
.quiz-body .qflag { top: 8px; right: 6px; width: 36px; height: 36px; }
.quiz-body .qflag svg { width: 19px; height: 19px; }
.quiz-body .opt { min-height: 0; padding: calc(11px * var(--qs)) 14px; gap: 12px; font-size: calc(16.5px * var(--qs)); line-height: 1.3; border-radius: 16px; }
.quiz-body .opt + .opt { margin-top: calc(8px * var(--qs)); }
.quiz-body .opt .l { width: calc(34px * var(--qs)); height: calc(34px * var(--qs)); border-radius: 10px; font-size: calc(14px * var(--qs)); }
.quiz-body .opt .l svg { width: 18px; height: 18px; }
.quiz-body .hint { margin-top: calc(12px * var(--qs)); padding: calc(12px * var(--qs)) 14px; gap: 10px; font-size: calc(15px * var(--qs)); line-height: 1.4; border-radius: 14px; }
.quiz-body .hint svg { width: 20px; height: 20px; }
.qfoot { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding-top: 8px; flex: none; }
.qfoot .btn { height: 52px; font-size: 17px; border-radius: 14px; }
@media (min-height: 860px) { .quiz-body .q-card h2 { font-size: calc(26px * var(--qs)); } .quiz-body .opt { font-size: calc(18px * var(--qs)); padding: calc(14px * var(--qs)) 16px; } }
.hint.ghost { opacity: 0; transform: translateY(6px); pointer-events: none; animation: none; }

/* ---------- Ranking y podio ---------- */
.seg-sm button { height: 46px; font-size: 15.5px; }
.podium { display: grid; grid-template-columns: 1fr 1.1fr 1fr; align-items: end; gap: 8px; margin: 10px 0 6px; }
.pod-col { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; position: relative; }
.pod-col .crown { font-size: 28px; line-height: 1; margin-bottom: -4px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-4deg); } }
.pod-av { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 26px; background: var(--card); border: 3px solid var(--line); color: var(--text); box-shadow: var(--shadow); }
.pod-av.p1 { width: 74px; height: 74px; font-size: 32px; border-color: #E2B33C; background: #FFF3CF; color: #5C4410; }
.pod-av.p2 { border-color: #A9B1BB; background: #EEF1F4; color: #3B4450; }
.pod-av.p3 { border-color: #C98552; background: #F7E6D8; color: #5A3315; }
.pod-name { font-family: var(--font-head); font-weight: 800; font-size: 16px; margin-top: 8px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-pts { color: var(--muted); font-size: 13.5px; margin: 2px 0 8px; }
.pod-pts b { color: var(--text); font-family: var(--font-mono); font-size: 15px; }
.pod-bar { width: 100%; border-radius: 16px 16px 6px 6px; display: grid; place-items: start center; padding-top: 10px; font-family: var(--font-head); font-weight: 800; font-size: 30px; color: rgba(255,255,255,.95); }
.pod-bar.p1 { height: 120px; background: linear-gradient(180deg, #E8BD45, #C99A22); box-shadow: 0 5px 0 #9C7614; }
.pod-bar.p2 { height: 88px; background: linear-gradient(180deg, #B8C0CA, #949DA8); box-shadow: 0 5px 0 #6F7782; }
.pod-bar.p3 { height: 66px; background: linear-gradient(180deg, #D39466, #B6703E); box-shadow: 0 5px 0 #8A5129; }
.pod-col.empty .pod-bar { opacity: .35; }
.pod-col.me .pod-name { color: var(--accent); }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.rank-row.me { border: 2px solid var(--accent); }
.rank-pos { width: 30px; text-align: center; font-family: var(--font-mono); font-weight: 700; font-size: 17px; color: var(--muted); flex: none; }
.avatar.sm { width: 42px; height: 42px; font-size: 19px; background: var(--soft); color: var(--text); }
.rank-name { font-family: var(--font-head); font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-pts { text-align: right; flex: none; }
.rank-pts b { display: block; font-family: var(--font-head); font-size: 24px; font-weight: 800; line-height: 1; }
.rank-pts span { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Sensación de app: sin vista previa de enlaces, sin selección al mantener pulsado ---------- */
body { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
input, textarea, select, [contenteditable], .selectable, .code-box { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
a[data-href], [role="link"] { cursor: pointer; }
img, svg { -webkit-user-drag: none; }
.card[data-href], a.card, .row[data-href], .subject, .recent, .test-item { transition: transform .12s ease, box-shadow .12s ease; }
a.card:active, a.row:active, .row[data-href]:active, .subject:active, .recent:active, .test-item:active, button.row:active { transform: scale(.98); }
.nav a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.nav a svg { transition: transform .12s ease; }
.nav a:active svg { transform: scale(.86); }
.nav a:active { opacity: .85; }
.quiz-page .qmenu { width: 34px; height: 40px; margin-right: -6px; flex: none; }
.quiz-page .qmenu svg { width: 22px; height: 22px; }
@media (max-width: 380px) { .quiz-page .cnt { padding: 0 6px; gap: 2px; } .quiz-page .qtitle .t { font-size: 15px; } }
.test-item .tmenu { margin-right: -8px; width: 38px; flex: none; color: var(--muted); }
.test-item .tmenu svg { width: 22px; height: 22px; }
.test-item.pressing { transform: scale(.97); transition: transform .45s ease; }

/* ---------- Exámenes ---------- */
.exam { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.exam-date { --c: var(--ink); width: 56px; height: 60px; border-radius: 14px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c) 14%, var(--card)); color: var(--c); border: 1.5px solid color-mix(in srgb, var(--c) 30%, transparent); }
[data-dark="1"] .exam-date { color: color-mix(in srgb, var(--c) 55%, #fff); }
.exam-date b { font-family: var(--font-head); font-weight: 800; font-size: 24px; line-height: 1; }
.exam-date span { font-family: var(--font-mono); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; margin-top: 3px; }
.exam-main { flex: 1; min-width: 0; }
.exam-title { font-family: var(--font-head); font-weight: 800; font-size: 17.5px; line-height: 1.2; }
.exam-meta { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.exam-meta .dot { width: 9px; height: 9px; vertical-align: 0; }
.nowrap { white-space: nowrap; }
.exam-notes { color: var(--muted); font-size: 13px; margin-top: 3px; font-style: italic; }
.exam-cd { flex: none; text-align: center; font-weight: 700; font-size: 13px; padding: 7px 9px; border-radius: 12px; background: var(--soft); color: var(--muted); min-width: 58px; line-height: 1.2; }
.exam-cd.warm { background: #FBF0D6; color: #8A5A00; }
.exam-cd.hot { background: var(--bad-bg); color: var(--bad); }
[data-dark="1"] .exam-cd.warm { background: rgba(240,200,110,.15); color: #F0C86E; }
.exam-cd b { display: block; font-family: var(--font-head); font-size: 22px; font-weight: 800; line-height: 1; }
.exam-cd span { font-size: 11.5px; font-weight: 600; }
.exam.featured { border: 2px solid var(--ink); box-shadow: 0 4px 0 var(--accent); }
.exam.featured .exam-cd b { font-size: 26px; }
.exam.is-past { opacity: .55; }

/* ---------- Insignias ---------- */
.badges { display: flex; gap: 10px; overflow-x: auto; margin: 0 -22px; padding: 4px 22px 10px; scrollbar-width: none; scroll-snap-type: x proximity; }
.badges::-webkit-scrollbar { display: none; }
.badge-card { flex: none; width: 118px; height: 150px; border-radius: 22px; border: 2px solid var(--line); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 16px 10px 14px; scroll-snap-align: start; text-align: center; }
.badge-card .b-emoji { font-size: 38px; line-height: 1; filter: grayscale(.55); opacity: .45; }
.badge-card .b-name { font-family: var(--font-head); font-weight: 700; font-size: 14.5px; line-height: 1.15; color: var(--muted); opacity: .8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.b-bar { width: 100%; height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; display: block; flex: none; }
.b-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.b-bar.big { height: 10px; border-radius: 6px; max-width: 260px; margin: 0 auto; }
.badge-card.done { background: var(--card); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 70%, transparent); }
.badge-card.done .b-emoji { filter: none; opacity: 1; }
.badge-card.done .b-name { color: var(--text); opacity: 1; }
.badge-card.done .b-bar i { background: var(--ok); }
.b-big { font-size: 64px; width: 110px; height: 110px; margin: 4px auto 14px; border-radius: 30px; display: grid; place-items: center; background: var(--soft); filter: grayscale(.6); opacity: .6; }
.b-big.done { filter: none; opacity: 1; background: color-mix(in srgb, var(--accent) 12%, var(--card)); box-shadow: 0 5px 0 var(--accent); }

/* ---------- Celebración de insignia ---------- */
.celebrate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: rgba(10,12,10,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: bd .25s; overflow: hidden; cursor: pointer; }
.celebrate.out { animation: celOut .28s forwards; }
@keyframes celOut { to { opacity: 0; } }
.cel-card { position: relative; width: min(320px, 84vw); padding: 34px 24px 28px; border-radius: 32px; text-align: center; background: var(--card); box-shadow: 0 8px 0 var(--accent), 0 30px 80px rgba(0,0,0,.35); animation: celCard .55s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes celCard { from { transform: scale(.6) translateY(40px); opacity: 0; } }
.cel-glow { position: absolute; left: 50%; top: 70px; width: 210px; height: 210px; margin: -105px 0 0 -105px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 10%, color-mix(in srgb, #E8BD45 55%, transparent) 10% 15%, transparent 15% 35%, color-mix(in srgb, #E8BD45 55%, transparent) 35% 40%, transparent 40% 60%, color-mix(in srgb, #E8BD45 55%, transparent) 60% 65%, transparent 65% 85%, color-mix(in srgb, #E8BD45 55%, transparent) 85% 90%, transparent 90%);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%); mask: radial-gradient(circle, #000 30%, transparent 70%); animation: spin 6s linear infinite, fade .6s; }
.cel-emoji { position: relative; font-size: 84px; line-height: 1; height: 96px; animation: celPop .8s cubic-bezier(.2,1.6,.35,1) .1s both, celFloat 2.4s ease-in-out .9s infinite; filter: drop-shadow(0 8px 14px rgba(0,0,0,.2)); }
@keyframes celPop { 0% { transform: scale(0) rotate(-40deg); } 60% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes celFloat { 50% { transform: translateY(-6px) rotate(-3deg); } }
.cel-kicker { position: relative; margin-top: 18px; font-family: var(--font-mono); font-weight: 700; font-size: 12.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); animation: celUp .5s ease .35s both; }
.cel-name { position: relative; font-family: var(--font-head); font-weight: 800; font-size: 30px; letter-spacing: -0.02em; margin-top: 6px; animation: celUp .5s ease .45s both; }
.cel-desc { position: relative; color: var(--muted); font-size: 15px; margin-top: 8px; animation: celUp .5s ease .55s both; }
@keyframes celUp { from { opacity: 0; transform: translateY(12px); } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -20px; border-radius: 2px; opacity: 0; animation-name: confettiFall; animation-timing-function: cubic-bezier(.25,.6,.45,1); animation-fill-mode: forwards; }
@keyframes confettiFall { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), 105vh) rotate(var(--r)); } }
@media (prefers-reduced-motion: reduce) { .cel-glow, .cel-emoji, .confetti { animation: none !important; } .confetti { display: none; } }

/* ---------- Avatares ---------- */
.avatar, .pod-av { overflow: hidden; position: relative; }
.av-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.av-emo { font-size: .95em; line-height: 1; }
.avatar .av-emo { font-size: 1.15em; }
.pod-av .av-emo { font-size: 1.2em; }
.av-edit { color: inherit; font: inherit; font-family: var(--font-head); font-weight: 800; font-size: 34px; overflow: visible; }
.av-edit .av-img { border-radius: 50%; }
.av-pen { position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 2px solid var(--nav-bg); }
.av-pen svg { width: 13px; height: 13px; }
.av-preview { width: 110px; height: 110px; font-size: 48px; background: var(--soft); color: var(--text); border-radius: 50%; display: grid; place-items: center; }
.emo-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emo-grid button { aspect-ratio: 1; border-radius: 12px; font-size: 24px; background: var(--card); border: 2px solid transparent; display: grid; place-items: center; }
.emo-grid button.on { border-color: var(--text); }
@media (max-width: 400px) { .emo-grid { grid-template-columns: repeat(6, 1fr); } }

/* ---------- Modo Navidad ---------- */
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 15; overflow: hidden; }
#snow i { position: absolute; top: -30px; font-style: normal; color: #9FB4C8; animation-name: snowFall, snowSway; animation-timing-function: linear, ease-in-out; animation-iteration-count: infinite, infinite; animation-direction: normal, alternate; }
[data-dark="1"] #snow i { color: #fff; }
@keyframes snowFall { to { transform: translateY(calc(100vh + 40px)); } }
@keyframes snowSway { from { margin-left: -14px; } to { margin-left: 14px; } }
body:has(.quiz-page) #snow, body:has(.login) #snow { display: none; }

/* Guirnalda de luces en la barra inferior */
[data-xmas="1"] .nav { border-top-color: #1D5C3A; }
[data-xmas="1"] .nav::before { content: ''; position: absolute; left: 0; right: 0; top: -7px; height: 10px; pointer-events: none;
  background: radial-gradient(circle, #FFD54A 0 3px, transparent 3.5px) 0 0 / 48px 10px repeat-x,
              radial-gradient(circle, #E8453C 0 3px, transparent 3.5px) 16px 0 / 48px 10px repeat-x,
              radial-gradient(circle, #4FC3F7 0 3px, transparent 3.5px) 32px 0 / 48px 10px repeat-x;
  animation: lights 1.6s steps(1) infinite; filter: drop-shadow(0 0 3px rgba(255,220,120,.8)); }
@keyframes lights { 50% { background-position: 16px 0, 32px 0, 0 0; } }

/* Tarjeta de cuenta atrás */
.xmas-card { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; background: linear-gradient(135deg, #1D3B2A, #2B5A3E); color: #FFF7E6; border: 0; box-shadow: 0 5px 0 #C2352B; position: relative; overflow: hidden; }
.xmas-emoji { font-size: 40px; line-height: 1; animation: bob 2.6s ease-in-out infinite; }
.xmas-big { font-family: var(--font-head); font-size: 34px; font-weight: 800; line-height: 1; }
.xmas-txt { font-family: var(--font-head); font-weight: 700; font-size: 17px; }
.xmas-lights { position: absolute; right: 14px; top: 10px; display: flex; gap: 7px; }
.xmas-lights i { width: 7px; height: 7px; border-radius: 50%; background: #FFD54A; box-shadow: 0 0 6px #FFD54A; animation: twinkle 1.4s ease-in-out infinite; }
.xmas-lights i:nth-child(3n+2) { background: #E8453C; box-shadow: 0 0 6px #E8453C; animation-delay: .3s; }
.xmas-lights i:nth-child(3n) { background: #4FC3F7; box-shadow: 0 0 6px #4FC3F7; animation-delay: .6s; }
@keyframes twinkle { 50% { opacity: .3; } }

/* Gorro de Papá Noel en el 1.º del podio */
.pod-av-wrap { position: relative; }
.santa-hat { position: absolute; width: 58px; top: -26px; left: 50%; margin-left: -34px; transform: rotate(-14deg); z-index: 2; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
[data-xmas="1"] .pod-col .crown { margin-bottom: 24px; position: relative; z-index: 3; filter: drop-shadow(0 0 6px rgba(255,210,80,.9)); }

/* Insignias de temporada */
.badge-card.seasonal { border-style: dashed; border-color: color-mix(in srgb, #C2352B 45%, var(--line)); }
.badge-card.seasonal.done { border-style: solid; }

/* Celebración navideña */
.confetti i.emo { background: none !important; width: auto; height: auto; border-radius: 0; }

/* ---------- Transiciones del test ---------- */
.quiz-body.in-r { animation: qInR .28s cubic-bezier(.2,.8,.2,1); }
.quiz-body.in-l { animation: qInL .28s cubic-bezier(.2,.8,.2,1); }
@keyframes qInR { from { opacity: 0; transform: translateX(34px); } }
@keyframes qInL { from { opacity: 0; transform: translateX(-34px); } }
.quiz-body .opt { transition: background-color .2s, border-color .2s, opacity .25s, transform .08s; }
.quiz-body .opt .l { transition: background-color .2s, color .2s; }
.quiz-body .opt.dim { opacity: .55; }
.opt.pop { animation: optPop .38s cubic-bezier(.2,1.6,.4,1); }
@keyframes optPop { 40% { transform: scale(1.035); } }
.opt.shake { animation: optShake .38s ease; }
@keyframes optShake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
.quiz-body .hint { transition: opacity .28s ease, transform .28s ease; }
.cnt.bump { animation: cntBump .35s ease; }
@keyframes cntBump { 40% { transform: scale(1.18); } }
.qn { transition: background-color .2s, color .2s, box-shadow .2s; }
@media (prefers-reduced-motion: reduce) { .quiz-body.in-r, .quiz-body.in-l, .opt.pop, .opt.shake, .cnt.bump { animation: none; } }

/* ---------- Asignaturas: cabecera y tarjetas compactas ---------- */
.subj-head h1 { font-size: clamp(26px, 8vw, 40px); }
.subj-head .icon-btn { width: 50px; height: 50px; }
.round-add { width: 50px; height: 50px; padding: 0; border-radius: 50%; flex: none; }
.round-add svg { width: 24px; height: 24px; }
.subject { padding: 14px 16px; border-radius: 22px; }
.subject .top { gap: 14px; }
.subject .ini { width: 46px; height: 46px; font-size: 22px; border-radius: 13px; }
.subject .name { font-size: 19px; }
.subject .meta { margin-top: 8px; font-size: 14px; }
.subject .icon-btn.sm { width: 36px; height: 36px; }
.stack > .subject + .subject { margin-top: 10px; }
.subj-exam { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 7px 10px; border-radius: 10px; background: var(--soft); color: var(--muted); font-size: 13.5px; line-height: 1.25; }
.subj-exam svg { width: 16px; height: 16px; flex: none; }
.subj-exam b { color: var(--text); font-weight: 700; }
.subj-exam.warm { background: #FBF0D6; color: #8A5A00; }
.subj-exam.warm b { color: #6B4500; }
.subj-exam.hot { background: var(--bad-bg); color: var(--bad); }
.subj-exam.hot b { color: var(--bad); }
[data-dark="1"] .subj-exam.warm { background: rgba(240,200,110,.15); color: #F0C86E; }
[data-dark="1"] .subj-exam.warm b { color: #F6D894; }

/* Atajos de teclado: solo en ordenador (ratón) */
.kbd-hint { display: none; text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 8px; flex: none; }
.kbd-hint kbd { display: inline-block; min-width: 20px; padding: 1px 6px; margin: 0 1px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--card); font-family: var(--font-mono); font-size: 11.5px; color: var(--text); }
@media (hover: hover) and (pointer: fine) { .kbd-hint { display: block; } }

/* Avatar en la pestaña «Yo» */
.nav-av { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: rgba(255,255,255,.18); color: #fff;
  font-family: var(--font-head); font-weight: 800; font-size: 14px; box-shadow: 0 0 0 1.5px rgba(244,240,232,.45); transition: transform .12s ease, box-shadow .15s; }
.nav-av .av-img { border-radius: 50%; }
.nav-av .av-emo { font-size: 17px; }
.nav a:not(.on) .nav-av { opacity: .75; }
.nav a.on .nav-av { box-shadow: 0 0 0 2px var(--nav-bg), 0 0 0 4px #fff; opacity: 1; }
.nav a:active .nav-av { transform: scale(.88); }

/* ---------- Retos ---------- */
.duel { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 18px 0 10px; }
.duel-side { display: flex; flex-direction: column; align-items: center; position: relative; min-width: 0; }
.duel-av { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--soft); color: var(--text);
  font-family: var(--font-head); font-weight: 800; font-size: 30px; border: 3px solid var(--line); }
.duel-av .av-emo { font-size: 38px; }
.duel-side.win .duel-av { border-color: #E2B33C; box-shadow: 0 0 0 4px rgba(226,179,60,.25); }
.duel-crown { position: absolute; top: -22px; font-size: 26px; animation: bob 2.2s ease-in-out infinite; z-index: 2; }
.duel-name { font-family: var(--font-head); font-weight: 800; font-size: 16px; margin-top: 8px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-note { font-family: var(--font-head); font-weight: 800; font-size: 30px; line-height: 1.1; margin-top: 2px; }
.duel-side.win .duel-note { color: var(--ok); }
.duel-time { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.duel-vs { font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: var(--accent); letter-spacing: .1em; }
.duel-card { width: min(360px, 90vw); }
.duel-page .cel-card { width: 100%; animation: none; box-shadow: 0 6px 0 var(--accent); }
.duel-page .cel-glow { opacity: .5; }
.ch-invite { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 12px; border: 2px solid var(--accent); box-shadow: 0 4px 0 var(--accent); cursor: pointer; animation: chPulse 2.4s ease-in-out infinite; }
@keyframes chPulse { 50% { box-shadow: 0 4px 0 var(--accent), 0 0 0 6px color-mix(in srgb, var(--accent) 15%, transparent); } }
.ch-invite .btn { flex: none; pointer-events: none; }
.ch-kicker { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.ch-title { font-family: var(--font-head); font-weight: 800; font-size: 17px; margin-top: 2px; }
.ch-sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.nav a.has-dot::before { content: ''; position: absolute; top: 6px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 50%; background: #E8453C; border: 2px solid var(--nav-bg); z-index: 1; }
.duel-card .cel-glow { display: none; }
.ch-kicker { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
