/* ==========================================================================
   LEARNING PLATFORM v3 — Design System
   Tema per mata pelajaran di-inject lewat blok :root di bawah.
   ========================================================================== */

:root {
    --accent:       #F46800;
    --accent-code:  #FFB27A;
    --accent-grad:  linear-gradient(135deg, #F46800, #C24E00);
    --accent-hero:  linear-gradient(135deg, rgba(244,104,0,.16), transparent 70%);
}
:root[data-mode="light"] {
    --accent:       #B85100;
    --accent-code:  #B85100;
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 15px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Neutral tokens — dark (default) */
:root {
    --bg:            #0b0f14;
    --bg-soft:       #111720;
    --surface:       #151c26;
    --surface-2:     #1b2430;
    --surface-3:     #222d3b;
    --border:        #26313f;
    --border-soft:   #1e2733;
    --text:          #e6edf3;
    --text-dim:      #a9b6c4;
    --text-muted:    #6e7f92;
    --code-bg:       #0d1117;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.35);
    --shadow-md:     0 6px 24px rgba(0,0,0,.35);
    --shadow-lg:     0 20px 60px rgba(0,0,0,.55);
    --ok:            #3fb950;
    --warn:          #d29922;
    --danger:        #f85149;
    --info:          #58a6ff;
    --radius:        12px;
    --radius-sm:     8px;
    --mono:          'JetBrains Mono', 'Fira Code', Consolas, monospace;
    --sidebar-w:     320px;
    --header-h:      64px;
}

:root[data-mode="light"] {
    --bg:            #f6f8fa;
    --bg-soft:       #ffffff;
    --surface:       #ffffff;
    --surface-2:     #f2f5f8;
    --surface-3:     #e7ecf1;
    --border:        #d6dee7;
    --border-soft:   #e6ebf0;
    --text:          #16202b;
    --text-dim:      #46586b;
    --text-muted:    #74879a;
    --code-bg:       #0d1117;
    --shadow-sm:     0 1px 2px rgba(16,32,48,.08);
    --shadow-md:     0 6px 24px rgba(16,32,48,.10);
    --shadow-lg:     0 20px 60px rgba(16,32,48,.18);
    --ok:            #1a7f37;
    --warn:          #9a6700;
    --danger:        #cf222e;
    --info:          #0969da;
}

::selection { background: var(--accent); color: #fff; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---------- HEADER ---------- */
.app-header {
    height: var(--header-h);
    background: color-mix(in srgb, var(--bg-soft) 92%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 20px;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 90;
}

.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-icon {
    width: 40px; height: 40px; border-radius: 11px;
    background: var(--accent-grad);
    display: grid; place-items: center;
    font-size: 1.25rem; font-weight: 800; color: #fff;
    box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 35%, transparent);
    flex-shrink: 0;
}
.brand-icon svg { width: 22px; height: 22px; fill: #fff; }
.brand-text h1 { font-size: 1rem; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.brand-text span { font-size: .72rem; color: var(--text-muted); font-weight: 600; }

.header-center { flex: 1; max-width: 560px; margin: 0 auto; }
.search-box { position: relative; }
.search-box input {
    width: 100%; padding: 9px 14px 9px 38px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-size: .875rem;
    font-family: inherit; transition: .18s;
}
.search-box input:focus {
    outline: none; border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.search-box input::placeholder { color: var(--text-muted); }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); opacity: .55; font-size: .9rem; }

.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.progress-widget { min-width: 168px; }
.progress-bar-bg { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress-bar-fill { height: 100%; width: 0%; background: var(--accent-grad); border-radius: 99px; transition: width .45s cubic-bezier(.4,0,.2,1); }
.progress-text { font-size: .7rem; color: var(--text-muted); font-weight: 700; margin-top: 4px; display: block; }

.icon-btn {
    width: 36px; height: 36px; display: grid; place-items: center;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 9px; color: var(--text-dim); cursor: pointer;
    font-size: .95rem; transition: .18s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--accent); border-color: var(--accent); }

.menu-toggle { display: none; }

/* ---------- LAYOUT ---------- */
.app-container { display: flex; min-height: calc(100vh - var(--header-h)); }

/* ---------- SIDEBAR ---------- */
.app-sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    height: calc(100vh - var(--header-h));
    position: sticky; top: var(--header-h);
    overflow-y: auto;
    display: flex; flex-direction: column;
}
.sidebar-header {
    padding: 16px 18px 10px;
    display: flex; align-items: center; justify-content: space-between;
    font-size: .72rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: .09em; color: var(--text-muted);
}
.badge {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    color: var(--accent); padding: 3px 9px; border-radius: 99px;
    font-size: .68rem; font-weight: 800; letter-spacing: .02em;
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.sidebar-cta { padding: 0 14px 12px; display: grid; gap: 8px; }
.cta-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-radius: 10px; cursor: pointer;
    font-size: .82rem; font-weight: 800; text-align: left;
    border: 1px solid transparent; transition: .18s; width: 100%;
    font-family: inherit;
}
.cta-project { background: var(--accent-grad); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
.cta-project:hover { transform: translateY(-1px); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 42%, transparent); }
.cta-exam { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.cta-exam:hover { border-color: var(--accent); color: var(--accent); }

.cat-filters { padding: 0 14px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.cat-chip {
    padding: 4px 10px; font-size: .68rem; font-weight: 700;
    border-radius: 99px; cursor: pointer; transition: .16s;
    background: var(--surface-2); color: var(--text-muted);
    border: 1px solid var(--border-soft); font-family: inherit;
}
.cat-chip:hover { color: var(--text); border-color: var(--accent); }
.cat-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.chapter-list { padding: 0 10px 28px; flex: 1; }
.cat-group-title {
    font-size: .68rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: .08em; color: var(--text-muted);
    padding: 14px 10px 6px; display: flex; align-items: center; gap: 8px;
}
.cat-group-title::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }

.chapter-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 9px 11px; border-radius: 9px; cursor: pointer;
    transition: .15s; margin-bottom: 2px; border: 1px solid transparent;
}
.chapter-item:hover { background: var(--surface-2); }
.chapter-item.active {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border-color: color-mix(in srgb, var(--accent) 36%, transparent);
}
.chapter-item.active .ci-title { color: var(--accent); font-weight: 700; }
.ci-num {
    width: 22px; height: 22px; flex-shrink: 0; border-radius: 6px;
    background: var(--surface-3); color: var(--text-muted);
    font-size: .66rem; font-weight: 800; display: grid; place-items: center;
    margin-top: 1px;
}
.chapter-item.done .ci-num { background: var(--ok); color: #fff; }
.chapter-item.done .ci-num::after { content: '✓'; }
.chapter-item.done .ci-num span { display: none; }
.ci-body { min-width: 0; }
.ci-title { font-size: .805rem; font-weight: 600; color: var(--text-dim); line-height: 1.42; }
.ci-meta { font-size: .66rem; color: var(--text-muted); margin-top: 2px; display: flex; gap: 8px; }

.lvl { font-weight: 800; letter-spacing: .03em; }
.lvl-dasar { color: var(--ok); }
.lvl-menengah { color: var(--warn); }
.lvl-lanjut { color: var(--danger); }

.sidebar-empty { padding: 30px 16px; text-align: center; color: var(--text-muted); font-size: .8rem; }

/* ---------- MAIN ---------- */
.main-content { flex: 1; min-width: 0; padding: 26px 34px 80px; max-width: 1180px; }

.chapter-header {
    background: var(--accent-hero);
    border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
    border-radius: 16px; padding: 24px 28px; margin-bottom: 20px;
    position: relative; overflow: hidden;
}
.chapter-header::after {
    content: ''; position: absolute; right: -60px; top: -60px;
    width: 220px; height: 220px; border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%);
    pointer-events: none;
}
.chapter-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.chapter-header h2 { font-size: 1.65rem; font-weight: 800; letter-spacing: -.025em; line-height: 1.25; margin-bottom: 8px; }
.chapter-desc { color: var(--text-dim); font-size: .93rem; max-width: 80ch; }
.pill {
    font-size: .68rem; font-weight: 800; padding: 4px 10px; border-radius: 99px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}

/* ---------- TABS ---------- */
.tabs-nav {
    display: flex; gap: 4px; border-bottom: 1px solid var(--border);
    margin-bottom: 22px; overflow-x: auto; scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }
.tab-btn {
    padding: 10px 16px; background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: .85rem; font-weight: 700;
    font-family: inherit; white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px; transition: .16s;
    display: flex; align-items: center; gap: 7px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; animation: fadeIn .25s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- THEORY TYPOGRAPHY ---------- */
.theory h2 { font-size: 1.32rem; font-weight: 800; margin: 30px 0 12px; letter-spacing: -.02em; }
.theory h3 {
    font-size: 1.08rem; font-weight: 800; margin: 26px 0 10px;
    padding-left: 12px; border-left: 3px solid var(--accent); letter-spacing: -.01em;
}
.theory h4 { font-size: .95rem; font-weight: 800; margin: 18px 0 8px; color: var(--text-dim); }
.theory h2:first-child, .theory h3:first-child { margin-top: 0; }
.theory p { margin-bottom: 13px; color: var(--text-dim); }
.theory strong { color: var(--text); font-weight: 700; }
.theory em { color: var(--accent); font-style: italic; }
.theory a { color: var(--info); text-decoration: none; border-bottom: 1px dashed currentColor; }
.theory a:hover { opacity: .8; }
.theory ul, .theory ol { margin: 0 0 15px 22px; color: var(--text-dim); }
.theory li { margin-bottom: 7px; }
.theory li::marker { color: var(--accent); font-weight: 700; }
.theory hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }
.theory code {
    font-family: var(--mono); font-size: .84em;
    background: color-mix(in srgb, var(--accent) 13%, transparent);
    color: var(--accent-code); padding: 2px 6px; border-radius: 5px;
    border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
    word-break: break-word;
}

/* ---------- TABLES ---------- */
.table-wrap { overflow-x: auto; margin: 16px 0; border-radius: var(--radius); border: 1px solid var(--border); }
.theory table, table.tbl {
    width: 100%; border-collapse: collapse; font-size: .84rem;
    background: var(--surface); min-width: 480px;
}
.theory table th, table.tbl th {
    background: var(--surface-2); padding: 11px 14px; text-align: left;
    font-weight: 800; color: var(--text); font-size: .76rem;
    text-transform: uppercase; letter-spacing: .05em;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.theory table td, table.tbl td {
    padding: 11px 14px; border-bottom: 1px solid var(--border-soft);
    color: var(--text-dim); vertical-align: top;
}
.theory table tr:last-child td, table.tbl tr:last-child td { border-bottom: none; }
.theory table tbody tr:hover, table.tbl tbody tr:hover { background: var(--surface-2); }

/* ---------- CALLOUTS ---------- */
.callout {
    border-radius: var(--radius); padding: 14px 18px; margin: 16px 0;
    border-left: 4px solid var(--info);
    background: color-mix(in srgb, var(--info) 9%, var(--surface));
    font-size: .875rem; color: var(--text-dim);
}
.callout-title { font-weight: 800; color: var(--text); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.callout p:last-child, .callout ul:last-child, .callout ol:last-child { margin-bottom: 0; }
.callout ul, .callout ol { margin: 8px 0 0 20px; }
.callout li { margin-bottom: 5px; }

.callout-info    { border-left-color: var(--info);   background: color-mix(in srgb, var(--info) 9%, var(--surface)); }
.callout-tip     { border-left-color: var(--ok);     background: color-mix(in srgb, var(--ok) 9%, var(--surface)); }
.callout-warn    { border-left-color: var(--warn);   background: color-mix(in srgb, var(--warn) 11%, var(--surface)); }
.callout-danger  { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.callout-accent  { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }

/* ---------- CODE BLOCKS ---------- */
.code-block {
    background: var(--code-bg); border: 1px solid var(--border);
    border-radius: var(--radius); margin: 16px 0; overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.code-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px; background: rgba(255,255,255,.03);
    border-bottom: 1px solid var(--border);
}
.code-file {
    font-family: var(--mono); font-size: .74rem; font-weight: 700;
    color: var(--text-muted); display: flex; align-items: center; gap: 8px;
}
.code-lang {
    font-size: .62rem; text-transform: uppercase; letter-spacing: .07em;
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent); padding: 2px 7px; border-radius: 4px; font-weight: 800;
}
.copy-btn {
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text-muted); font-size: .7rem; font-weight: 700;
    padding: 4px 10px; border-radius: 6px; cursor: pointer;
    transition: .16s; font-family: inherit;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }

.code-block pre {
    margin: 0; padding: 15px 17px; overflow-x: auto;
    font-family: var(--mono); font-size: .805rem; line-height: 1.62;
    color: #d7e0ea;
}
.code-block pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }

/* Syntax highlight tokens */
.tok-com { color: #6a7d8f; font-style: italic; }
.tok-str { color: #a5d6ff; }
.tok-key { color: #ff7b72; font-weight: 600; }
.tok-num { color: #f2cc60; }
.tok-fn  { color: #d2a8ff; }
.tok-var { color: #79c0ff; }
.tok-op  { color: #ff9bce; }
.tok-flag{ color: #7ee787; }

/* ---------- TERMINAL SIMULATOR ---------- */
.terminal {
    background: #05080c; border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-md);
    display: flex; flex-direction: column; height: 420px;
}
.term-head {
    display: flex; align-items: center; gap: 10px; padding: 9px 14px;
    background: #0d141c; border-bottom: 1px solid var(--border);
}
.term-dots { display: flex; gap: 6px; }
.term-dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.term-dots i:nth-child(1) { background: #ff5f57; }
.term-dots i:nth-child(2) { background: #febc2e; }
.term-dots i:nth-child(3) { background: #28c840; }
.term-title { font-family: var(--mono); font-size: .74rem; color: #7d8fa3; flex: 1; text-align: center; }
.term-clear {
    background: none; border: 1px solid #22303e; color: #7d8fa3;
    font-size: .68rem; padding: 3px 9px; border-radius: 5px; cursor: pointer; font-family: inherit;
}
.term-clear:hover { color: var(--accent); border-color: var(--accent); }
.term-body {
    flex: 1; overflow-y: auto; padding: 14px 16px;
    font-family: var(--mono); font-size: .8rem; line-height: 1.65; color: #c9d6e2;
}
.term-line { white-space: pre-wrap; word-break: break-word; }
.t-cmd  { color: #7ee787; }
.t-err  { color: #ff7b72; }
.t-ok   { color: #56d364; }
.t-info { color: #79c0ff; }
.t-warn { color: #e3b341; }
.t-dim  { color: #6a7d8f; }
.term-input-row {
    display: flex; align-items: center; gap: 8px; padding: 10px 16px;
    border-top: 1px solid var(--border); background: #0a1017;
}
.term-prompt { font-family: var(--mono); font-size: .8rem; color: var(--accent); font-weight: 700; flex-shrink: 0; }
.term-input {
    flex: 1; background: none; border: none; outline: none;
    font-family: var(--mono); font-size: .8rem; color: #e6edf3;
}

.snippet-bar { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.snippet-chip {
    font-family: var(--mono); font-size: .72rem; font-weight: 600;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text-dim); padding: 5px 11px; border-radius: 7px; cursor: pointer; transition: .16s;
}
.snippet-chip:hover { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }

/* ---------- PITFALL CARDS ---------- */
.pitfall-grid { display: grid; gap: 14px; }
.pitfall {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.pitfall-head {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
    font-weight: 800; font-size: .9rem; border-bottom: 1px solid var(--border-soft);
}
.pitfall-body { padding: 14px 16px; font-size: .87rem; color: var(--text-dim); }
.pitfall-body p { margin-bottom: 10px; }
.pitfall-body p:last-child { margin-bottom: 0; }
.pitfall.k-larangan .pitfall-head { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.pitfall.k-salah    .pitfall-head { color: var(--warn);   background: color-mix(in srgb, var(--warn) 11%, transparent); }
.pitfall.k-best     .pitfall-head { color: var(--ok);     background: color-mix(in srgb, var(--ok) 10%, transparent); }
.pitfall.k-kasus    .pitfall-head { color: var(--info);   background: color-mix(in srgb, var(--info) 10%, transparent); }

.vs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.vs-col { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.vs-col > .vs-label { padding: 8px 14px; font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.vs-bad  > .vs-label { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.vs-good > .vs-label { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.vs-col .code-block { margin: 0; border: none; border-radius: 0; box-shadow: none; }

/* ---------- QUIZ ---------- */
.quiz-item {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px;
}
.quiz-q { font-weight: 700; margin-bottom: 14px; font-size: .95rem; display: flex; gap: 10px; }
.quiz-q .qn {
    flex-shrink: 0; width: 24px; height: 24px; border-radius: 6px;
    background: var(--accent); color: #fff; display: grid; place-items: center;
    font-size: .72rem; font-weight: 800;
}
.quiz-opts { display: grid; gap: 8px; }
.quiz-opt {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 14px; border: 1px solid var(--border); border-radius: 9px;
    cursor: pointer; transition: .15s; font-size: .875rem; color: var(--text-dim);
    background: var(--surface-2); text-align: left; font-family: inherit; width: 100%;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.quiz-opt .ok-letter {
    flex-shrink: 0; width: 21px; height: 21px; border-radius: 5px;
    background: var(--surface-3); color: var(--text-muted);
    display: grid; place-items: center; font-size: .68rem; font-weight: 800;
}
.quiz-opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--text); }
.quiz-opt.correct .ok-letter { background: var(--ok); color: #fff; }
.quiz-opt.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }
.quiz-opt.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--text); }
.quiz-opt.picked .ok-letter { background: var(--accent); color: #fff; }
.quiz-opt.wrong .ok-letter { background: var(--danger); color: #fff; }
.quiz-opt:disabled { cursor: default; }
.quiz-exp {
    margin-top: 13px; padding: 12px 15px; border-radius: 9px;
    background: color-mix(in srgb, var(--info) 9%, var(--surface-2));
    border-left: 3px solid var(--info); font-size: .84rem; color: var(--text-dim);
    display: none;
}
.quiz-exp.show { display: block; animation: fadeIn .22s; }

/* ---------- BOTTOM NAV ---------- */
.chapter-nav {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--border);
}

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 10px; font-size: .85rem; font-weight: 700;
    cursor: pointer; border: 1px solid transparent; transition: .18s;
    font-family: inherit; white-space: nowrap;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 42%, transparent); }
.btn-secondary { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ghost { background: none; color: var(--text-muted); }
.btn-ghost:hover { color: var(--danger); }

/* ---------- MODAL ---------- */
.overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(2,5,10,.78); backdrop-filter: blur(6px);
    display: none; align-items: center; justify-content: center; padding: 24px;
}
.overlay.open { display: flex; animation: fadeIn .2s; }
.modal {
    background: var(--bg-soft); border: 1px solid var(--border);
    border-radius: 18px; width: 100%; max-width: 1000px; max-height: 92vh;
    display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-head { padding: 22px 28px; border-bottom: 1px solid var(--border); background: var(--accent-hero); }
.modal-head h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.modal-head p { color: var(--text-dim); font-size: .85rem; margin-top: 4px; }
.modal-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.modal-body { flex: 1; overflow-y: auto; padding: 24px 28px; }
.modal-foot {
    padding: 14px 28px; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--surface);
}
.exam-timer {
    font-family: var(--mono); font-size: 1.5rem; font-weight: 800; color: var(--accent);
    background: var(--surface-2); padding: 7px 16px; border-radius: 10px;
    border: 1px solid var(--border);
}
.exam-timer.danger { color: var(--danger); border-color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.exam-result { text-align: center; padding: 36px 20px; }
.score-ring {
    width: 148px; height: 148px; border-radius: 50%; margin: 0 auto 20px;
    display: grid; place-items: center; position: relative;
    background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--surface-3) 0);
}
.score-ring::before { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: var(--bg-soft); }
.score-ring span { position: relative; font-size: 2.1rem; font-weight: 900; }
.score-verdict { font-size: 1.3rem; font-weight: 800; margin-bottom: 6px; }
.review-item { text-align: left; margin-top: 12px; }

/* ---------- MINI PROJECT ---------- */
.step {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 12px; overflow: hidden;
}
.step-head {
    display: flex; align-items: center; gap: 12px; padding: 14px 18px;
    cursor: pointer; user-select: none; transition: .16s;
}
.step-head:hover { background: var(--surface-2); }
.step-num {
    width: 27px; height: 27px; border-radius: 8px; flex-shrink: 0;
    background: var(--accent-grad); color: #fff; display: grid; place-items: center;
    font-size: .76rem; font-weight: 800;
}
.step-title { font-weight: 700; font-size: .93rem; flex: 1; }
.step-toggle { color: var(--text-muted); transition: transform .2s; font-size: .8rem; }
.step.open .step-toggle { transform: rotate(90deg); }
.step-body { display: none; padding: 4px 18px 18px; border-top: 1px solid var(--border-soft); }
.step.open .step-body { display: block; animation: fadeIn .2s; }
.step-check { accent-color: var(--accent); width: 17px; height: 17px; cursor: pointer; flex-shrink: 0; }
.step.done .step-title { color: var(--text-muted); text-decoration: line-through; }

.criteria { display: grid; gap: 9px; }
.criteria-item {
    display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px;
    background: var(--surface-2); border: 1px solid var(--border-soft);
    border-radius: 9px; font-size: .85rem; color: var(--text-dim);
}
.criteria-item::before { content: '☐'; color: var(--accent); font-weight: 800; }

/* ---------- TOAST ---------- */
.toast {
    position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 90px);
    background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
    padding: 11px 22px; border-radius: 11px; font-size: .85rem; font-weight: 700;
    box-shadow: var(--shadow-lg); z-index: 500; opacity: 0; transition: .3s cubic-bezier(.4,0,.2,1);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1080px) {
    .main-content { padding: 22px 22px 70px; }
    .header-center { max-width: 320px; }
}
@media (max-width: 900px) {
    .menu-toggle { display: grid; }
    .app-sidebar {
        position: fixed; left: 0; top: var(--header-h); z-index: 80;
        transform: translateX(-100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
        box-shadow: var(--shadow-lg); width: 300px;
    }
    .app-sidebar.open { transform: none; }
    .header-center, .progress-widget { display: none; }
    .brand-text h1 { font-size: .88rem; }
    .brand-text span { display: none; }
    .vs-grid { grid-template-columns: 1fr; }
    .chapter-header { padding: 18px 20px; }
    .chapter-header h2 { font-size: 1.3rem; }
    .main-content { padding: 18px 15px 60px; }
    .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
    .chapter-nav { flex-direction: column; }
    .chapter-nav .btn { width: 100%; justify-content: center; }
}
@media print {
    .app-header, .app-sidebar, .tabs-nav, .chapter-nav, .overlay { display: none !important; }
    .tab-content { display: block !important; }
    body { background: #fff; color: #000; }
}
