/* ===== Design tokens ===== */
:root {
  --bg: #f7f4f4;
  --bg-2: #f2eaea;
  --surface: #ffffff;
  --surface-2: #fbf8f8;
  --border: #ecdfe0;
  --text: #171113;
  --text-2: #3d3336;
  --muted: #7a6d70;
  --primary: #d90429;
  --primary-2: #8d0718;
  --primary-soft: #ffe7ea;
  --accent: #ff7a45;
  --accent-soft: #fff0e8;
  --success: #15a05a;
  --success-soft: #e3f7ec;
  --danger: #dc3545;
  --danger-soft: #fde8ea;
  --warn: #e69a00;
  --warn-soft: #fff5db;
  --info-soft: #e6f4ff;
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .06), 0 1px 3px rgba(20, 30, 60, .05);
  --shadow: 0 6px 24px rgba(30, 45, 90, .08), 0 2px 6px rgba(30, 45, 90, .05);
  --shadow-lg: 0 20px 50px rgba(30, 45, 90, .16);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --grad: linear-gradient(135deg, #ef233c 0%, #c1121f 45%, #4a040b 100%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0b; --bg-2: #121214; --surface: #161618; --surface-2: #1c1c1f; --border: #2d2b2e;
    --text: #f3eeee; --text-2: #d8cfd0; --muted: #a19596; --primary: #ff2e43; --primary-2: #ff6b6b;
    --primary-soft: #3a0d14; --accent: #ff9466; --accent-soft: #3a2a26; --success: #3ccf86; --success-soft: #173a2c;
    --danger: #ff6b78; --danger-soft: #3d1f27; --warn: #ffc246; --warn-soft: #3a3120; --info-soft: #1b2d45;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0b; --bg-2: #121214; --surface: #161618; --surface-2: #1c1c1f; --border: #2d2b2e;
  --text: #f3eeee; --text-2: #d8cfd0; --muted: #a19596; --primary: #ff2e43; --primary-2: #ff6b6b;
  --primary-soft: #3a0d14; --accent: #ff9466; --accent-soft: #3a2a26; --success: #3ccf86; --success-soft: #173a2c;
  --danger: #ff6b78; --danger-soft: #3d1f27; --warn: #ffc246; --warn-soft: #3a3120; --info-soft: #1b2d45;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; font-size: 15.5px; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ===== Top navigation ===== */
.topnav { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 24px; padding: 10px 28px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: -.5px; box-shadow: 0 4px 14px rgba(217, 4, 41, .35); }
.brand-text { display: flex; flex-direction: column; font-weight: 800; font-size: 17px; line-height: 1.1; }
.brand-text small { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a { padding: 8px 13px; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: 14.5px; text-decoration: none; transition: background .15s, color .15s; }
.nav-links a:hover { background: var(--bg-2); }
.nav-links a.active { background: var(--primary-soft); color: var(--primary); }
.nav-tools { display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--bg-2); }
.menu-btn { display: none; }
@media (max-width: 1080px) {
  .topnav { padding: 10px 16px; gap: 12px; }
  .menu-btn { display: grid; }
  .nav-links { display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px; box-shadow: var(--shadow); }
  .nav-links.open { display: flex; }
  .nav-tools { margin-left: auto; }
}

/* ===== Layout ===== */
#app { min-height: calc(100vh - 60px); }
.container { max-width: 1200px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.page-head p { color: var(--muted); margin: 0; max-width: 760px; }
.eyebrow { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); margin-bottom: 8px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .container { padding: 22px 16px 48px; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.card.hover { transition: transform .15s, box-shadow .15s, border-color .15s; cursor: pointer; color: inherit; text-decoration: none !important; display: block; }
.card.hover:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.card h3 { font-size: 18px; margin-bottom: 6px; }
.card p { color: var(--muted); margin: 0; font-size: 14.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 11px; border: 1px solid transparent; font-weight: 700; font-size: 14.5px; cursor: pointer; text-decoration: none !important; transition: transform .1s, box-shadow .15s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(217, 4, 41, .3); }
.btn-primary:hover { box-shadow: 0 8px 22px rgba(217, 4, 41, .42); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bg-2); color: var(--text-2); }
.chip.lv-A0, .chip.lv-A1 { background: #e3f7ec; color: #11804a; }
.chip.lv-A2 { background: #e6f4ff; color: #1767b5; }
.chip.lv-B1 { background: #efe9ff; color: #5a3fd1; }
.chip.lv-B2 { background: #fff0e8; color: #c4511c; }
.chip.lv-C1 { background: #fde8ea; color: #b4232f; }
:root[data-theme="dark"] .chip[class*="lv-"] { background: var(--surface-2); color: var(--text); }
.chip.done { background: var(--success-soft); color: var(--success); }

.progress-bar { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width .4s; }

/* ===== Hero ===== */
.hero { position: relative; overflow: hidden; background: var(--grad); color: #fff; border-radius: 26px; padding: 54px 50px; margin-bottom: 30px; box-shadow: var(--shadow-lg); }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .09); }
.hero::before { width: 420px; height: 420px; right: -120px; top: -160px; }
.hero::after { width: 260px; height: 260px; right: 180px; bottom: -150px; }
.hero h1 { font-size: 42px; font-weight: 800; letter-spacing: -1px; max-width: 700px; position: relative; }
.hero p { font-size: 17px; opacity: .92; max-width: 640px; position: relative; }
.hero .row { position: relative; margin-top: 22px; }
.hero .btn-ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .35); }
.hero .btn-light { background: #fff; color: var(--primary); }
.hero-stats { display: flex; gap: 34px; margin-top: 34px; position: relative; flex-wrap: wrap; }
.hero-stats b { display: block; font-size: 28px; font-weight: 800; }
.hero-stats span { font-size: 13px; opacity: .85; }
@media (max-width: 620px) { .hero { padding: 34px 22px; border-radius: 20px; } .hero h1 { font-size: 30px; } }

.feature-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 14px; font-size: 22px; }
.fi-1 { background: #e8eeff; } .fi-2 { background: #e3f7ec; } .fi-3 { background: #fff0e8; } .fi-4 { background: #efe9ff; } .fi-5 { background: #fde8ea; } .fi-6 { background: #fff5db; }
:root[data-theme="dark"] .feature-icon { background: var(--surface-2); }

.section-title { display: flex; align-items: baseline; gap: 12px; margin: 38px 0 16px; }
.section-title h2 { font-size: 22px; font-weight: 800; margin: 0; }

/* ===== Roadmap ===== */
.roadmap { position: relative; padding-left: 34px; }
.roadmap::before { content: ""; position: absolute; left: 13px; top: 8px; bottom: 8px; width: 3px; background: linear-gradient(var(--primary), var(--primary-2), var(--accent)); border-radius: 3px; }
.stage { position: relative; margin-bottom: 22px; }
.stage-dot { position: absolute; left: -34px; top: 22px; width: 29px; height: 29px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--primary); }
.stage .card { padding: 22px 24px; }
.stage-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.stage-head h3 { margin: 0; font-size: 19px; }
.stage ul { margin: 10px 0 0; padding-left: 20px; color: var(--text-2); }
.stage li { margin: 3px 0; }
.stage .links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ===== Two-column doc layout (lessons, guides) ===== */
.doc-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; max-width: 1320px; margin: 0 auto; padding: 26px 24px 64px; }
.doc-side { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 92px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.doc-side .side-search { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; margin-bottom: 10px; }
.side-group { margin-bottom: 8px; }
.side-group > summary { list-style: none; cursor: pointer; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 8px; display: flex; align-items: center; gap: 6px; border-radius: 8px; }
.side-group > summary::-webkit-details-marker { display: none; }
.side-group > summary::before { content: "▸"; transition: transform .15s; font-size: 11px; }
.side-group[open] > summary::before { transform: rotate(90deg); }
.side-group > summary:hover { background: var(--bg-2); }
.side-link { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 22px; border-radius: 9px; color: var(--text-2); font-size: 14px; text-decoration: none !important; }
.side-link:hover { background: var(--bg-2); }
.side-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.side-link .tick { margin-left: auto; color: var(--success); font-size: 12px; }
.doc-main { min-width: 0; }
@media (max-width: 960px) { .doc-layout { grid-template-columns: 1fr; padding: 18px 16px 48px; } .doc-side { position: static; max-height: 360px; } }

.lesson-head { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 30px; margin-bottom: 18px; }
.lesson-head h1 { font-size: 28px; font-weight: 800; margin: 8px 0 4px; letter-spacing: -.4px; }
.lesson-head .en-title { color: var(--muted); font-weight: 600; }
.lesson-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px 34px; }
@media (max-width: 620px) { .lesson-body, .lesson-head { padding: 20px 18px; } }
.lesson-body h3 { font-size: 20px; margin: 30px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--bg-2); }
.lesson-body h3:first-child { margin-top: 0; }
.lesson-body h4 { font-size: 16.5px; margin: 20px 0 8px; color: var(--text); }
.lesson-body p { margin: 0 0 12px; color: var(--text-2); }
.lesson-body ul, .lesson-body ol { color: var(--text-2); padding-left: 22px; }
.lesson-body li { margin: 4px 0; }
.lesson-body mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; padding: 0 3px; border-radius: 4px; font-weight: 600; }
.box { border-radius: 12px; padding: 14px 18px; margin: 16px 0; border: 1px solid; }
.box p:last-child, .box ul:last-child { margin-bottom: 0; }
.box-title { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.box.formula { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.box.formula .box-title { color: var(--primary); }
.box.formula .box-title::before { content: "∑"; }
.box.formula p { font-family: "Consolas", "Cascadia Mono", monospace; font-size: 14.5px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.box.tip { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.box.tip .box-title { color: var(--success); }
.box.tip .box-title::before { content: "💡"; }
.box.warn { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.box.warn .box-title { color: var(--danger); }
.box.warn .box-title::before { content: "⚠️"; }
.box.warn s { color: var(--danger); }
.box.note { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.box.note .box-title { color: var(--warn); }
.box.note .box-title::before { content: "📌"; }
.box.ielts { background: var(--info-soft); border-color: color-mix(in srgb, #1d8fe0 35%, transparent); }
.box.ielts .box-title { color: #1d7fd0; }
.box.ielts .box-title::before { content: "🎯"; }
ul.examples { list-style: none; padding: 0; margin: 12px 0 16px; }
ul.examples li { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; padding: 10px 14px; margin: 8px 0; display: flex; flex-direction: column; }
ul.examples .en { color: var(--text); font-weight: 500; }
ul.examples .vi { color: var(--muted); font-size: 14px; font-style: italic; }
.speak { cursor: pointer; border: none; background: none; color: var(--primary); padding: 0 4px; vertical-align: middle; }
.speak svg { width: 16px; height: 16px; }
table.tbl { width: 100%; border-collapse: collapse; margin: 14px 0 18px; font-size: 14.5px; overflow: hidden; border-radius: 10px; border: 1px solid var(--border); display: table; }
.tbl-wrap { overflow-x: auto; }
table.tbl th { background: var(--bg-2); text-align: left; padding: 10px 12px; font-weight: 700; color: var(--text); }
table.tbl td { padding: 9px 12px; border-top: 1px solid var(--border); color: var(--text-2); vertical-align: top; }
table.tbl tr:nth-child(even) td { background: var(--surface-2); }

/* Exercises */
.exercises { margin-top: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 30px; }
.exercises h2 { font-size: 21px; display: flex; align-items: center; gap: 10px; }
.ex-item { padding: 16px 0; border-top: 1px dashed var(--border); }
.ex-item:first-of-type { border-top: none; }
.ex-q { font-weight: 600; margin-bottom: 10px; }
.ex-q .num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-size: 13px; margin-right: 8px; }
.ex-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.ex-opt { padding: 8px 14px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; font-size: 14.5px; }
.ex-opt:hover { border-color: var(--primary); }
.ex-opt.correct { border-color: var(--success); background: var(--success-soft); color: var(--success); font-weight: 700; }
.ex-opt.wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.ex-input { padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; min-width: 240px; }
.ex-input.correct { border-color: var(--success); background: var(--success-soft); }
.ex-input.wrong { border-color: var(--danger); background: var(--danger-soft); }
.ex-explain { margin-top: 10px; font-size: 14px; padding: 10px 14px; border-radius: 10px; background: var(--bg-2); color: var(--text-2); display: none; }
.ex-explain.show { display: block; }
.ex-score { font-weight: 800; color: var(--primary); }
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; flex-wrap: wrap; }

/* Lesson list cards */
.unit-block { margin-bottom: 30px; }
.unit-block h2 { font-size: 19px; display: flex; align-items: center; gap: 10px; }
.lesson-card { display: flex; gap: 14px; align-items: flex-start; }
.lesson-card .lc-num { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; background: var(--primary-soft); color: var(--primary); }
.lesson-card.done .lc-num { background: var(--success-soft); color: var(--success); }
.lesson-card h3 { font-size: 16px; margin: 0 0 4px; }
.lesson-card p { font-size: 13.5px; }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.filter-bar .pill { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; font-weight: 600; font-size: 13.5px; }
.filter-bar .pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-bar input { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; min-width: 220px; }

/* ===== Vocabulary ===== */
.vocab-set h3 { font-size: 16.5px; }
.vocab-set .meta { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.fc-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 10px 0 20px; }
.flashcard { width: min(560px, 100%); height: 330px; perspective: 1400px; cursor: pointer; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.2, .8, .2, 1); transform-style: preserve-3d; }
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; box-shadow: var(--shadow-lg); }
.fc-front { background: var(--grad); color: #fff; }
.fc-back { background: var(--surface); border: 1px solid var(--border); transform: rotateY(180deg); }
.fc-word { font-size: 42px; font-weight: 800; letter-spacing: -.5px; }
.fc-ipa { font-size: 18px; opacity: .9; margin-top: 6px; font-family: "Segoe UI", "Lucida Sans Unicode", sans-serif; }
.fc-pos { margin-top: 10px; padding: 3px 12px; border-radius: 99px; background: rgba(255, 255, 255, .2); font-size: 13px; font-weight: 700; }
.fc-vi { font-size: 26px; font-weight: 800; color: var(--primary); }
.fc-ex { margin-top: 16px; color: var(--text); font-size: 16px; }
.fc-exvi { color: var(--muted); font-style: italic; font-size: 14.5px; margin-top: 4px; }
.fc-hint { font-size: 12.5px; opacity: .75; position: absolute; bottom: 14px; }
.fc-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.word-table td:first-child { font-weight: 700; color: var(--text); white-space: nowrap; }
.word-table .ipa { color: var(--muted); font-size: 13px; }
.known-badge { color: var(--success); font-weight: 700; }
.quiz-box { max-width: 640px; margin: 0 auto; }
.quiz-q { font-size: 26px; font-weight: 800; text-align: center; margin: 10px 0 22px; }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opts .ex-opt { padding: 14px 18px; text-align: left; font-size: 15.5px; }

/* ===== Tests list ===== */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.book-card { position: relative; overflow: hidden; border-radius: 16px; padding: 20px; color: #fff; min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s; text-decoration: none !important; }
.book-card:hover { transform: translateY(-4px); }
.book-card .bk-num { font-size: 46px; font-weight: 800; line-height: 1; letter-spacing: -2px; }
.book-card .bk-title { font-weight: 700; font-size: 14px; opacity: .95; }
.book-card .bk-meta { font-size: 12px; opacity: .85; }
.book-card.unavailable { filter: grayscale(.8); opacity: .65; cursor: default; }
.book-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.test-row { display: grid; grid-template-columns: 120px repeat(4, 1fr) auto; gap: 12px; align-items: center; padding: 16px 20px; border-top: 1px solid var(--border); }
.test-row:first-child { border-top: none; }
.test-row .t-name { font-weight: 800; font-size: 17px; }
.skill-btn { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.skill-btn:hover { border-color: var(--primary); background: var(--primary-soft); }
.skill-btn b { font-size: 14px; }
.skill-btn span { font-size: 12px; color: var(--muted); }
.skill-btn .best { color: var(--success); font-weight: 700; }
.skill-btn[disabled] { opacity: .45; cursor: not-allowed; }
@media (max-width: 860px) { .test-row { grid-template-columns: 1fr 1fr; } .test-row .t-name { grid-column: 1 / -1; } }

.mode-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.mode-choice label { border: 2px solid var(--border); border-radius: 14px; padding: 14px 16px; cursor: pointer; display: block; }
.mode-choice input { margin-right: 8px; }
.mode-choice label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(10, 15, 30, .55); z-index: 200; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 18px; padding: 26px 28px; max-width: 620px; width: 100%; box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto; }
.modal h2 { font-size: 22px; }
@keyframes fade { from { opacity: 0; } }

/* ===== Progress ===== */
.stat-card { text-align: left; }
.stat-card .stat-num { font-size: 32px; font-weight: 800; color: var(--primary); }
.history-table td, .history-table th { white-space: nowrap; }

/* Search */
.search-overlay { position: fixed; inset: 0; background: rgba(10, 15, 30, .5); z-index: 300; display: flex; justify-content: center; padding-top: 10vh; }
.search-overlay[hidden] { display: none; }
.search-box { width: min(640px, 92vw); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; align-self: flex-start; }
.search-box input { width: 100%; padding: 18px 20px; font: inherit; font-size: 17px; border: none; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); outline: none; }
.search-results { max-height: 60vh; overflow: auto; }
.search-results a { display: block; padding: 11px 20px; color: var(--text); border-bottom: 1px solid var(--border); text-decoration: none; }
.search-results a:hover, .search-results a.sel { background: var(--primary-soft); }
.search-results small { color: var(--muted); display: block; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px); background: #1b2333; color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; z-index: 400; transition: transform .25s; box-shadow: var(--shadow-lg); }
.toast.show { transform: translateX(-50%) translateY(0); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 16px 40px; }
body.in-exam { overflow: hidden; }
body.in-exam #topnav, body.in-exam #app { display: none; }

/* ===== Red / black theme accents ===== */
:root[data-theme="dark"] { --grad: linear-gradient(135deg, #e5091f 0%, #8d0718 40%, #140405 100%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --grad: linear-gradient(135deg, #e5091f 0%, #8d0718 40%, #140405 100%); } }
.topnav { border-bottom: 2px solid var(--primary); }
.hero { box-shadow: 0 24px 60px rgba(160, 6, 25, .35); }
.hero h1 { text-shadow: 0 2px 18px rgba(0, 0, 0, .25); }
.brand-text { letter-spacing: -.2px; }
.nav-links a.active { background: var(--primary); color: #fff; }
.filter-bar .pill.active { box-shadow: 0 4px 12px rgba(217, 4, 41, .3); }
.section-title h2::before, .unit-block h2::before { content: ""; display: inline-block; width: 5px; height: 20px; border-radius: 3px; background: var(--primary); margin-right: 4px; vertical-align: -3px; }
.lesson-body h3 { border-bottom-color: color-mix(in srgb, var(--primary) 25%, transparent); }
ul.examples li { border-left-color: var(--primary); }
.lesson-card .lc-num { background: var(--primary); color: #fff; }
.lesson-card.done .lc-num { background: var(--success); }
.stage-dot { border-color: var(--primary); color: var(--primary); }
.roadmap::before { background: linear-gradient(var(--primary), var(--primary-2), #1a1a1a); }
.book-card { border: 1px solid rgba(255, 255, 255, .08); }
