@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; }

: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: 84px;
  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); }
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)); animation: fade .22s ease; }
.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: 26px; height: 26px; flex: none; color: var(--text); }
.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: 14.5px; 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: 4px solid var(--accent); padding-bottom: env(safe-area-inset-bottom); }
.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: 4px; color: rgba(244,240,232,.62); font-size: 15px; font-weight: 500; position: relative; }
.nav a svg { width: 30px; height: 30px; }
.nav a.on { color: #FFF; font-weight: 700; }
.nav a.on::after { content: ''; position: absolute; bottom: 8px; width: 34px; height: 4px; border-radius: 4px; background: var(--accent); }

/* ---------- 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: 15px; 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 .ini { width: 54px; height: 54px; font-size: 26px; border-radius: 14px; }
  .subject .top { gap: 14px; }
  .subject .name { font-size: 21px; }
  .subject .icon-btn.sm { width: 36px; }
}
