/* ==========================================================================
   Españolito — design system
   ========================================================================== */
:root {
  --bg: #faf7f2;
  --bg-2: #f3eee6;
  --surface: #ffffff;
  --surface-2: #fbf9f6;
  --border: #e7e0d5;
  --border-2: #d9cfc1;
  --text: #1f1b16;
  --text-2: #5b5248;
  --text-3: #73695e;
  --brand: #c1272d;          /* rojo */
  --brand-2: #9e1c22;
  --brand-soft: #fbe9e8;
  --gold: #f1b400;           /* gualda */
  --gold-soft: #fff4d1;
  --ok: #1f9d55;
  --ok-soft: #e3f6ea;
  --bad: #d64545;
  --bad-soft: #fde8e8;
  --info: #2563eb;
  --info-soft: #e6eefe;
  --a1: #16a34a; --a1-soft: #e3f7e9;
  --a2: #0d9488; --a2-soft: #dcf5f2;
  --b1: #2563eb; --b1-soft: #e3ecfd;
  --b2: #7c3aed; --b2-soft: #efe7fd;
  --c1: #c026d3; --c1-soft: #fae8fc;
  --c2: #e11d48; --c2-soft: #fde7ec;
  --box-notes: #fff6d6; --box-notes-b: #f0c94a;
  --box-fix: #fde8e7; --box-fix-b: #e0605a;
  --box-tip: #e5f6ea; --box-tip-b: #3fae6a;
  --box-warn: #fff0e0; --box-warn-b: #f08c2e;
  --box-rule: #e6eefe; --box-rule-b: #4b7be5;
  --box-song: #f1e8fd; --box-song-b: #9a64e6;
  --box-why: #eef1f4; --box-why-b: #8796a8;
  --shadow-sm: 0 1px 2px rgba(40, 28, 10, .06), 0 1px 1px rgba(40, 28, 10, .04);
  --shadow: 0 4px 16px rgba(40, 28, 10, .08), 0 1px 3px rgba(40, 28, 10, .06);
  --shadow-lg: 0 18px 50px rgba(40, 28, 10, .14);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-ar: 'Noto Naskh Arabic', 'Amiri', 'Segoe UI', Tahoma, sans-serif;
  --side-w: 268px;
  --top-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120f; --bg-2: #1b1814; --surface: #1f1c18; --surface-2: #26221d; --border: #332e27; --border-2: #443d34;
    --text: #f3eee7; --text-2: #c2b8ab; --text-3: #8f8576;
    --brand: #ef5a5f; --brand-2: #ff7b7f; --brand-soft: #3a1a1b; --gold: #ffc933; --gold-soft: #3a2f10;
    --ok: #3ccf7f; --ok-soft: #12301f; --bad: #ff6b6b; --bad-soft: #3a1717; --info: #6c9bff; --info-soft: #172443;
    --a1: #3ccf7f; --a1-soft: #12301f; --a2: #2dd4bf; --a2-soft: #0f2e2b; --b1: #6c9bff; --b1-soft: #172443; --b2: #a78bfa; --b2-soft: #261b40; --c1: #e879f9; --c1-soft: #3b1240; --c2: #fb7185; --c2-soft: #3d1520;
    --box-notes: #2f2810; --box-notes-b: #b8932a; --box-fix: #351a19; --box-fix-b: #c2524c; --box-tip: #132a1c; --box-tip-b: #3a9c62;
    --box-warn: #33230f; --box-warn-b: #c9792c; --box-rule: #172443; --box-rule-b: #4c74d0; --box-song: #261b40; --box-song-b: #8b5fd4; --box-why: #22262c; --box-why-b: #6b7a8c;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 4px 18px rgba(0,0,0,.45); --shadow-lg: 0 18px 50px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14120f; --bg-2: #1b1814; --surface: #1f1c18; --surface-2: #26221d; --border: #332e27; --border-2: #443d34;
  --text: #f3eee7; --text-2: #c2b8ab; --text-3: #8f8576;
  --brand: #ef5a5f; --brand-2: #ff7b7f; --brand-soft: #3a1a1b; --gold: #ffc933; --gold-soft: #3a2f10;
  --ok: #3ccf7f; --ok-soft: #12301f; --bad: #ff6b6b; --bad-soft: #3a1717; --info: #6c9bff; --info-soft: #172443;
  --a1: #3ccf7f; --a1-soft: #12301f; --a2: #2dd4bf; --a2-soft: #0f2e2b; --b1: #6c9bff; --b1-soft: #172443; --b2: #a78bfa; --b2-soft: #261b40; --c1: #e879f9; --c1-soft: #3b1240; --c2: #fb7185; --c2-soft: #3d1520;
  --box-notes: #2f2810; --box-notes-b: #b8932a; --box-fix: #351a19; --box-fix-b: #c2524c; --box-tip: #132a1c; --box-tip-b: #3a9c62;
  --box-warn: #33230f; --box-warn-b: #c9792c; --box-rule: #172443; --box-rule-b: #4c74d0; --box-song: #261b40; --box-song-b: #8b5fd4; --box-why: #22262c; --box-why-b: #6b7a8c;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 4px 18px rgba(0,0,0,.45); --shadow-lg: 0 18px 50px rgba(0,0,0,.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-family: var(--font-display); font-weight: 650; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.01em; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.5rem; margin-top: 1.6em; }
h3 { font-size: 1.12rem; font-weight: 700; margin-top: 1.3em; }
p { margin: 0 0 .9em; }
::selection { background: var(--gold); color: #1f1b16; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[lang="ar"], .ar { font-family: var(--font-ar); direction: rtl; unicode-bidi: isolate; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px 14px; gap: 6px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; flex: none; box-shadow: var(--shadow-sm); }
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; line-height: 1.1; }
.brand-sub { font-size: .74rem; color: var(--text-3); font-weight: 600; letter-spacing: .04em; }
.nav-label { font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: .93rem;
}
.nav a:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav .count { margin-left: auto; font-size: .72rem; color: var(--text-3); font-weight: 700; }
.side-foot { margin-top: auto; padding: 12px 8px 4px; font-size: .78rem; color: var(--text-3); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.icon-btn.menu-btn { display: none; }
.search { flex: 1; max-width: 520px; position: relative; }
.search input {
  width: 100%; height: 42px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); padding: 0 16px 0 42px; font-size: .95rem;
}
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
.search svg { position: absolute; left: 14px; top: 11px; width: 20px; height: 20px; color: var(--text-3); }
.search-results {
  position: absolute; top: 48px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 70vh; overflow-y: auto; padding: 6px; display: none;
}
.search-results.open { display: block; }
.search-results a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--bg-2); text-decoration: none; }
.search-results small { color: var(--text-3); display: block; font-size: .78rem; }
.top-stats { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pill-stat { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 700; font-size: .88rem; }
.pill-stat svg { width: 17px; height: 17px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }
.icon-btn svg { width: 20px; height: 20px; }
.site-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 18px 28px 24px; border-top: 1px solid var(--border); font-size: .84rem; color: var(--text-3); }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer a, .site-footer button { color: var(--text-2); background: none; border: 0; padding: 0; cursor: pointer; font-size: .84rem; font-weight: 600; }
.site-footer a:hover, .site-footer button:hover { color: var(--brand); text-decoration: underline; }
.consent { position: fixed; z-index: 80; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(760px, calc(100% - 32px)); background: var(--surface); border: 1px solid var(--border-2); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 16px 18px; display: flex; gap: 16px; align-items: center; }
.consent p { margin: 4px 0 0; font-size: .88rem; color: var(--text-2); }
.consent-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
@media (max-width: 640px) { .consent { flex-direction: column; align-items: stretch; bottom: 10px; } .consent-btns { justify-content: stretch; } .consent-btns .btn { flex: 1; } .site-footer { padding: 16px 16px 90px; } }
.legal h2 { font-size: 1.2rem; }
mark.ph { background: var(--gold-soft); color: var(--text); border: 1px dashed var(--gold); border-radius: 5px; padding: 0 4px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--brand), #8f1820); color: #fff; font-weight: 800; font-size: 1.05rem; flex: none; box-shadow: var(--shadow-sm); }
.avatar:hover { text-decoration: none; filter: brightness(1.08); }
@media (max-width: 560px) { .signin-btn { padding: 0 10px; font-size: .8rem; } }
.content { width: 100%; max-width: 1000px; margin: 0 auto; padding: 28px 28px 80px; }
.content.wide { max-width: 1180px; }
.scrim { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 290px; transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 90px; }
  .pill-stat .lbl { display: none; }
}
@media (max-width: 560px) { .top-stats .pill-stat.xp { display: none; } }

/* ---------- generic components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card.pad-lg { padding: 28px; }
.card h3:first-child, .card h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: .86rem; }
.center { text-align: center; }
.mt0 { margin-top: 0 !important; } .mt1 { margin-top: 8px; } .mt2 { margin-top: 16px; } .mt3 { margin-top: 28px; } .mb0 { margin-bottom: 0; }
.hide { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 700; font-size: .93rem; cursor: pointer; transition: transform .06s ease, background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--border-2); background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #2b2000; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.sm { height: 34px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn.lg { height: 50px; padding: 0 24px; font-size: 1rem; border-radius: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 800; letter-spacing: .03em; background: var(--bg-2); color: var(--text-2); white-space: nowrap; }
.lv { font-weight: 800; }
.lv-A1 { background: var(--a1-soft); color: var(--a1); }
.lv-A2 { background: var(--a2-soft); color: var(--a2); }
.lv-B1 { background: var(--b1-soft); color: var(--b1); }
.lv-B2 { background: var(--b2-soft); color: var(--b2); }
.lv-C1 { background: var(--c1-soft); color: var(--c1); }
.lv-C2 { background: var(--c2-soft); color: var(--c2); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--text-2); }
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.input, select.input, textarea.input {
  width: 100%; min-height: 44px; border-radius: 11px; border: 1.5px solid var(--border-2); background: var(--surface); padding: 9px 13px; font-size: 1rem;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
textarea.input { line-height: 1.6; resize: vertical; }
.input.ok { border-color: var(--ok); background: var(--ok-soft); }
.input.bad { border-color: var(--bad); background: var(--bad-soft); }
label.field { display: block; font-weight: 700; font-size: .88rem; margin-bottom: 6px; }

.progress { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .4s ease; }
.progress.ok > span { background: var(--ok); }
.ring { --p: 0; --c: var(--brand); width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--bg-2) 0); flex: none; }
.ring::before { content: ''; grid-area: 1/1; width: 74%; height: 74%; border-radius: 50%; background: var(--surface); }
.ring > b { grid-area: 1/1; font-size: .82rem; z-index: 1; }

.page-head { margin-bottom: 22px; }
.page-head .eyebrow { font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page-head .lede { font-size: 1.08rem; color: var(--text-2); max-width: 680px; }
.crumbs { font-size: .85rem; color: var(--text-3); margin-bottom: 10px; }
.crumbs a { color: var(--text-3); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 22px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 11px 14px; font-weight: 700; color: var(--text-3); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: .93rem; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; padding: 1px 6px; border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); }

/* toast + modal */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow-lg); animation: toastIn .25s ease; font-size: .92rem; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.modal-bg { position: fixed; inset: 0; background: rgba(20, 14, 6, .45); z-index: 90; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: min(560px, 100%); max-height: 88vh; overflow-y: auto; padding: 26px; box-shadow: var(--shadow-lg); }
.modal h2 { margin-top: 0; }

/* ---------- home ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 34px 34px 30px; color: #fff;
  background: radial-gradient(900px 300px at 100% 0%, rgba(241,180,0,.45), transparent 60%), linear-gradient(135deg, #b3202a 0%, #8f1820 55%, #5e1016 100%);
  box-shadow: var(--shadow);
}
.hero h1 { color: #fff; margin-bottom: 8px; }
.hero p { color: rgba(255,255,255,.88); max-width: 600px; font-size: 1.05rem; }
.hero .btn { border-color: rgba(255,255,255,.35); }
.hero .btn.ghostw { background: rgba(255,255,255,.12); color: #fff; }
.hero .btn.ghostw:hover { background: rgba(255,255,255,.22); }
.hero-deco { position: absolute; right: -10px; bottom: -30px; font-family: var(--font-display); font-size: 180px; font-weight: 800; color: rgba(255,255,255,.07); line-height: 1; pointer-events: none; user-select: none; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .levels { grid-template-columns: repeat(2, 1fr); } }
.level-card { border-radius: var(--radius); padding: 18px; border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 10px; color: var(--text); }
.level-card:hover { text-decoration: none; border-color: var(--border-2); box-shadow: var(--shadow); }
.level-card .big { font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1; }
.skill-card { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); transition: box-shadow .15s, border-color .15s, transform .15s; }
.skill-card:hover { text-decoration: none; border-color: var(--border-2); box-shadow: var(--shadow); transform: translateY(-1px); }
.skill-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.skill-icon svg { width: 24px; height: 24px; }
.skill-card h3 { margin: 0 0 3px; font-size: 1.02rem; }
.skill-card p { margin: 0; font-size: .87rem; color: var(--text-2); line-height: 1.45; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 34px 0 14px; }
.section-title h2 { margin: 0; }

/* ---------- unit lists ---------- */
.unit-list { display: flex; flex-direction: column; gap: 8px; }
.unit-item { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.unit-item:hover { text-decoration: none; border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.unit-num { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-2); font-weight: 800; font-size: .85rem; flex: none; color: var(--text-2); }
.unit-item.done .unit-num { background: var(--ok); color: #fff; }
.unit-title { font-weight: 700; line-height: 1.3; }
.unit-sub { font-size: .84rem; color: var(--text-3); }
.unit-item .badge { margin-left: auto; }
.level-group { margin-bottom: 28px; }
.level-group > h2 { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; margin: 0 0 12px; }

/* ---------- book content ---------- */
.book { font-size: 1.02rem; }
.book p { color: var(--text); }
.book i { font-style: italic; color: var(--brand-2); }
:root[data-theme="dark"] .book i { color: #ffb0a8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .book i { color: #ffb0a8; } }
.book i.say { cursor: pointer; border-radius: 4px; transition: background .12s; }
.book i.say:hover { background: var(--gold-soft); }
.book i.say.speaking { background: var(--gold); color: #2b2000; }
.book h2 { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.book ul, .book ol { padding-left: 1.4em; margin: 0 0 1em; }
.book li { margin-bottom: .35em; }
.tbl-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th { text-align: left; background: var(--bg-2); font-weight: 800; font-size: .8rem; letter-spacing: .02em; color: var(--text-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl td:first-child { font-weight: 600; }
.tbl .say-btn { margin-left: 6px; }
.box { border-radius: 12px; padding: 14px 18px 4px; margin: 0 0 1.2em; border-left: 4px solid; background: var(--box-notes); border-color: var(--box-notes-b); }
.box-label { font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.box-label svg { width: 15px; height: 15px; }
.box.notes { background: var(--box-notes); border-color: var(--box-notes-b); } .box.notes .box-label { color: color-mix(in srgb, var(--box-notes-b) 75%, var(--text)); }
.box.fix { background: var(--box-fix); border-color: var(--box-fix-b); } .box.fix .box-label { color: var(--box-fix-b); }
.box.tip { background: var(--box-tip); border-color: var(--box-tip-b); } .box.tip .box-label { color: var(--box-tip-b); }
.box.warn { background: var(--box-warn); border-color: var(--box-warn-b); } .box.warn .box-label { color: var(--box-warn-b); }
.box.rule { background: var(--box-rule); border-color: var(--box-rule-b); } .box.rule .box-label { color: var(--box-rule-b); }
.box.song { background: var(--box-song); border-color: var(--box-song-b); } .box.song .box-label { color: var(--box-song-b); }
.box.why, .box.note { background: var(--box-why); border-color: var(--box-why-b); } .box.why .box-label, .box.note .box-label { color: var(--box-why-b); }
.box .tbl-wrap { background: var(--surface); }
.passage { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px 26px; margin: 0 0 1.3em; font-family: Georgia, 'Times New Roman', serif; font-size: 1.06rem; line-height: 1.75; position: relative; box-shadow: var(--shadow-sm); }
.passage p:first-of-type { font-weight: 700; font-family: var(--font); }
.passage-tools { display: flex; gap: 8px; margin-bottom: 10px; font-family: var(--font); }
.grid-list { display: grid; gap: 2px 18px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin: 0 0 1.2em; font-size: .95rem; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }

/* practice widget */
.practice { border: 1.5px solid var(--border-2); border-radius: 16px; background: var(--surface); margin: 1.6em 0; overflow: hidden; box-shadow: var(--shadow-sm); }
.practice-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: linear-gradient(90deg, var(--brand-soft), transparent); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.practice-head .ptag { font-size: .72rem; font-weight: 800; letter-spacing: .12em; color: var(--brand); text-transform: uppercase; }
.practice-head h3 { margin: 0; font-size: 1.02rem; }
.practice-head .score { margin-left: auto; font-weight: 800; font-size: .9rem; }
.practice-body { padding: 16px 18px 18px; }
.practice-instr { color: var(--text-2); font-style: italic; margin-bottom: 14px; }
.p-items { display: flex; flex-direction: column; gap: 10px; counter-reset: none; }
.p-item { display: grid; grid-template-columns: 30px 1fr; gap: 4px 10px; align-items: start; padding: 10px 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid transparent; }
.p-item.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: var(--ok-soft); }
.p-item.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); }
.p-n { font-weight: 800; color: var(--text-3); padding-top: 9px; font-size: .9rem; }
.p-q { padding-top: 8px; }
.p-q i { color: inherit; }
.p-ans { grid-column: 2; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.p-ans .input { flex: 1; min-width: 180px; min-height: 40px; padding: 7px 12px; }
.p-sol { grid-column: 2; font-size: .92rem; color: var(--ok); font-weight: 600; }
.p-item.bad .p-sol { color: var(--bad); }
.p-sol .lbl { color: var(--text-3); font-weight: 700; margin-right: 6px; }
.opts { display: flex; flex-direction: column; gap: 6px; grid-column: 2; }
.opt { text-align: left; padding: 9px 13px; border-radius: 10px; border: 1.5px solid var(--border-2); background: var(--surface); cursor: pointer; font-size: .95rem; line-height: 1.4; }
.opt:hover { border-color: var(--text-3); }
.opt.sel { border-color: var(--info); background: var(--info-soft); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt b.k { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--bg-2); margin-right: 8px; font-size: .78rem; }
.practice-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); align-items: center; }
.model-answer { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.model-answer h4 { margin: 0 0 6px; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ok); }

.accent-bar { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.accent-bar button { min-width: 34px; height: 32px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; font-weight: 700; }
.accent-bar button:hover { background: var(--bg-2); }

.unit-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.unit-nav a { display: flex; flex-direction: column; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); max-width: 48%; min-width: 200px; flex: 1; }
.unit-nav a:hover { text-decoration: none; border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.unit-nav a.next { text-align: right; margin-left: auto; }
.unit-nav small { color: var(--text-3); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.complete-bar { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); margin-top: 30px; flex-wrap: wrap; }
.toc { position: sticky; top: calc(var(--top-h) + 20px); }

/* ---------- vocab ---------- */
.word-list { display: flex; flex-direction: column; gap: 6px; }
.word { display: grid; grid-template-columns: 38px minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.word .es { font-weight: 700; }
.word .en { color: var(--text-2); font-size: .94rem; }
.word .arw { font-family: var(--font-ar); direction: rtl; text-align: right; font-size: 1.12rem; color: var(--text); }
.word .note { grid-column: 2 / -1; font-size: .86rem; color: var(--text-3); font-style: italic; margin-top: -4px; }
.word-group { font-weight: 800; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); margin: 18px 0 4px; }
.word.known { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.word.known .es::after { content: ' ✓'; color: var(--ok); }
@media (max-width: 680px) {
  .word { grid-template-columns: 34px 1fr; }
  .word .en, .word .arw { grid-column: 2; }
  .word .arw { text-align: left; direction: rtl; }
}
.say-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); display: inline-grid; place-items: center; cursor: pointer; color: var(--text-2); flex: none; padding: 0; }
.say-btn:hover { color: var(--brand); border-color: var(--brand); }
.say-btn svg { width: 17px; height: 17px; }
.say-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.say-btn.sm svg { width: 14px; height: 14px; }

.flash-wrap { perspective: 1200px; max-width: 560px; margin: 0 auto; }
.flashcard { position: relative; height: 300px; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.2,.8,.2,1); cursor: pointer; }
.flashcard.flipped { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 26px; text-align: center; gap: 10px; }
.face.back { transform: rotateY(180deg); background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.face .big { font-family: var(--font-display); font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 650; line-height: 1.25; }
.face .arbig { font-family: var(--font-ar); font-size: 1.6rem; direction: rtl; }
.face .hint { position: absolute; bottom: 14px; font-size: .78rem; color: var(--text-3); }
.srs-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 560px; margin: 16px auto 0; }
.srs-btns .btn { flex-direction: column; height: auto; padding: 10px 6px; gap: 2px; }
.srs-btns .btn small { font-weight: 600; font-size: .72rem; color: var(--text-3); }

/* ---------- quiz ---------- */
.quiz-card { max-width: 680px; margin: 0 auto; }
.quiz-q { font-size: 1.35rem; font-weight: 700; font-family: var(--font-display); line-height: 1.35; margin: 6px 0 18px; }
.quiz-q .ar { font-size: 1.6rem; }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opts .opt { padding: 14px 16px; font-size: 1.02rem; font-weight: 600; }
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.quiz-top .progress { flex: 1; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; font-weight: 600; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .expl { color: var(--text); font-weight: 500; margin-top: 6px; font-size: .94rem; }
.result-big { font-family: var(--font-display); font-size: 3.4rem; font-weight: 800; line-height: 1; }

/* ---------- conjugation ---------- */
.conj-search { display: flex; gap: 10px; flex-wrap: wrap; }
.conj-search .input { flex: 1; min-width: 220px; font-size: 1.1rem; height: 50px; }
.verb-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 20px 0 8px; }
.verb-head h2 { margin: 0; font-size: 2rem; }
.tense-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tense { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; overflow: hidden; }
.tense h4 { margin: 0; padding: 9px 13px; font-size: .84rem; background: var(--bg-2); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.tense h4 small { font-weight: 600; color: var(--text-3); }
.tense table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tense td { padding: 5px 13px; border-bottom: 1px solid var(--border); }
.tense tr:last-child td { border-bottom: 0; }
.tense td.p { color: var(--text-3); width: 42%; font-size: .84rem; }
.tense td.f { font-weight: 600; cursor: pointer; }
.tense td.f:hover { color: var(--brand); }
.tense td.f b, .irr { color: var(--brand); }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.drill-form { font-size: 1.6rem; font-family: var(--font-display); font-weight: 700; text-align: center; }
.drill-input { font-size: 1.3rem; text-align: center; height: 56px; }

/* ---------- speaking / listening / writing ---------- */
.mic-btn { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 26px color-mix(in srgb, var(--brand) 45%, transparent); margin: 0 auto; transition: transform .1s; }
.mic-btn svg { width: 36px; height: 36px; }
.mic-btn:active { transform: scale(.96); }
.mic-btn.rec { animation: pulse 1.2s infinite; background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 55%, transparent); } 70% { box-shadow: 0 0 0 22px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.target-sentence { font-family: var(--font-display); font-size: clamp(1.3rem, 3.5vw, 1.8rem); font-weight: 600; text-align: center; line-height: 1.35; margin: 10px 0 18px; }
.heard { text-align: center; font-size: 1.1rem; min-height: 1.6em; }
.heard .w-ok { color: var(--ok); font-weight: 700; }
.heard .w-bad { color: var(--bad); text-decoration: line-through; }
.word-diff span { display: inline-block; margin: 2px 3px; padding: 2px 8px; border-radius: 7px; font-weight: 700; }
.word-diff .ok { background: var(--ok-soft); color: var(--ok); }
.word-diff .miss { background: var(--bad-soft); color: var(--bad); }
.timer { font-family: ui-monospace, Consolas, monospace; font-size: 2.4rem; font-weight: 700; text-align: center; letter-spacing: .04em; }
.timer.warn { color: var(--bad); }
textarea.input.writing-area { min-height: 340px; font-size: 1.05rem; }
.write-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: .88rem; color: var(--text-2); font-weight: 600; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px dashed var(--border); cursor: pointer; font-size: .94rem; }
.checklist input { margin-top: 5px; accent-color: var(--brand); width: 17px; height: 17px; flex: none; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.sticky-side { position: sticky; top: calc(var(--top-h) + 16px); max-height: calc(100vh - var(--top-h) - 32px); overflow-y: auto; }
.dialog-line { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.dialog-line .who { font-weight: 800; min-width: 70px; color: var(--brand); }
.dialog-line.mine .who { color: var(--info); }
.dialog-line.active { background: var(--gold-soft); border-radius: 8px; }
.audio-player { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.speed { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.speed button { border: 0; background: var(--surface); padding: 6px 10px; cursor: pointer; font-weight: 700; font-size: .82rem; color: var(--text-2); }
.speed button.on { background: var(--text); color: var(--bg); }
.hl-word { background: var(--gold-soft); border-radius: 4px; }

/* ---------- plan ---------- */
.week { display: grid; grid-template-columns: 56px 1fr; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; }
.week .wn { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; color: var(--text-3); text-align: center; line-height: 1; }
.week.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.week.done .wn { color: var(--ok); }
.week-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.week-items a { font-size: .82rem; padding: 3px 10px; border-radius: 999px; background: var(--bg-2); color: var(--text-2); font-weight: 600; }
.week-items a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.week-items a.done { background: var(--ok-soft); color: var(--ok); }

/* stats */
.stat { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat .v { font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat .l { font-size: .84rem; color: var(--text-3); font-weight: 700; }
.heat { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; }
.heat span { aspect-ratio: 1; border-radius: 4px; background: var(--bg-2); }
.heat span.l1 { background: color-mix(in srgb, var(--ok) 35%, var(--bg-2)); }
.heat span.l2 { background: color-mix(in srgb, var(--ok) 65%, var(--bg-2)); }
.heat span.l3 { background: var(--ok); }

.fade-in { animation: fadeUp .3s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  .sidebar, .topbar, .unit-nav, .complete-bar, .practice-foot, .say-btn { display: none !important; }
  .app { display: block; } .content { max-width: none; padding: 0; }
}
