/* ============================================================
   Giáo dục định hướng — Thực tập sinh đi Nhật Bản
   ============================================================ */
:root {
    --header-height: 64px;     /* chiều cao site-header — dùng cho sticky summary */
    --primary: #1c3f95;        /* xanh chủ đạo */
    --primary-dark: #142d6b;
    --accent: #d92e2e;         /* đỏ nhấn (cờ VN/Nhật) */
    --accent-soft: #fde8e8;
    --ok: #1a9d5a;
    --ok-soft: #e3f6ec;
    --warn: #e08a00;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #667085;
    --border: #e4e8f0;
    --shadow: 0 2px 12px rgba(20, 45, 107, .08);
    --shadow-lg: 0 10px 30px rgba(20, 45, 107, .14);
    --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.65;
}

.container { width: min(1120px, 92%); margin: 0 auto; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: .65rem 0; }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-flags { font-size: 1.5rem; display: inline-flex; align-items: center; gap: .15rem; }
.brand-flags .arrow { font-size: 1rem; color: var(--muted); }
.brand-text strong { display: block; font-size: 1.05rem; color: var(--primary-dark); line-height: 1.2; }
.brand-text small { color: var(--muted); font-size: .8rem; }
.site-nav { display: flex; gap: .3rem; }
.site-nav a {
    padding: .5rem .9rem; border-radius: 8px; color: var(--text);
    font-weight: 500; font-size: .95rem;
}
.site-nav a:hover { background: var(--bg); text-decoration: none; }
.site-nav a.active { color: var(--primary); background: #eef2fd; }
.nav-toggle { display: none; background: none; border: none; font-size: 1.6rem; cursor: pointer; color: var(--primary-dark); }

/* ---------- Layout ---------- */
.main-content { padding: 2rem 0 3rem; min-height: 60vh; }

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; border-radius: var(--radius); padding: 2.6rem 2rem;
    margin-bottom: 2rem; box-shadow: var(--shadow-lg);
    position: relative; overflow: hidden;
}
.hero::after {
    content: "🗾"; position: absolute; right: -10px; bottom: -30px;
    font-size: 11rem; opacity: .10;
}
.hero h1 { margin: 0 0 .6rem; font-size: 2rem; font-weight: 800; }
.hero p { margin: 0 0 1.2rem; max-width: 640px; font-size: 1.05rem; opacity: .95; }
.hero .badges { display: flex; flex-wrap: wrap; gap: .5rem; }
.hero .badge {
    background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28);
    padding: .35rem .8rem; border-radius: 999px; font-size: .85rem;
}

/* ---------- Banner đề thi kích hoạt (trang chủ) ---------- */
.exam-banner {
    background: linear-gradient(135deg, #0e4f30 0%, #1a7a4a 100%);
    border-radius: var(--radius);
    margin: 1.5rem 0;
    box-shadow: 0 4px 20px rgba(14, 79, 48, .25);
}
.exam-banner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.4rem 1.8rem;
    flex-wrap: wrap;
}
.exam-banner-label {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.7);
    margin-bottom: .25rem;
}
.exam-banner-title {
    margin: 0 0 .25rem;
    font-size: 1.25rem;
    color: #fff;
    font-weight: 700;
}
.exam-banner-desc {
    margin: 0 0 .4rem;
    color: rgba(255,255,255,.8);
    font-size: .93rem;
}
.exam-banner-meta {
    display: flex;
    gap: 1rem;
    font-size: .88rem;
    color: rgba(255,255,255,.75);
    font-weight: 500;
}
.btn-exam-start {
    display: inline-block;
    background: #fff;
    color: #0e4f30;
    font-weight: 700;
    font-size: 1rem;
    padding: .75rem 1.6rem;
    border-radius: 8px;
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s, transform .15s;
}
.btn-exam-start:hover { background: #e6f9ef; transform: translateY(-1px); text-decoration: none; }

/* ---------- Section title ---------- */
.section-title { display: flex; align-items: baseline; gap: .6rem; margin: 2rem 0 1rem; }
.section-title h2 { margin: 0; font-size: 1.5rem; color: var(--primary-dark); }
.section-title span { color: var(--muted); font-size: .95rem; }

/* ---------- Module grid ---------- */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.1rem; }
.module-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.3rem; box-shadow: var(--shadow); display: flex; flex-direction: column;
    transition: transform .15s ease, box-shadow .15s ease;
}
.module-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.module-card .num {
    width: 42px; height: 42px; border-radius: 11px; background: #eef2fd; color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.2rem;
    margin-bottom: .8rem;
}
.module-card .num .ic { font-size: 1.3rem; }
.module-card h3 { margin: 0 0 .4rem; font-size: 1.1rem; color: var(--text); }
.module-card p { margin: 0 0 1rem; color: var(--muted); font-size: .92rem; flex: 1; }
.module-card .meta { display: flex; align-items: center; gap: .8rem; font-size: .82rem; color: var(--muted); margin-bottom: .9rem; }
.module-card .meta .tiet { background: var(--accent-soft); color: var(--accent); padding: .15rem .55rem; border-radius: 6px; font-weight: 600; }
.module-card .actions { display: flex; gap: .5rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
    padding: .6rem 1.1rem; border-radius: 9px; font-weight: 600; font-size: .92rem;
    border: 1px solid transparent; cursor: pointer; transition: all .15s ease; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--primary); }
.btn-outline:hover { border-color: var(--primary); text-decoration: none; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #b91c1c; text-decoration: none; }
.btn-lg { padding: .8rem 1.6rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Lesson page ---------- */
.lesson-header {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.6rem 1.8rem; box-shadow: var(--shadow); margin-bottom: 1.4rem;
}
.lesson-header .crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.lesson-header h1 { margin: 0 0 .5rem; color: var(--primary-dark); font-size: 1.7rem; }
.lesson-header .lh-meta { display: flex; flex-wrap: wrap; gap: .6rem; font-size: .85rem; }
.tag { padding: .2rem .65rem; border-radius: 7px; font-weight: 500; }
.tag-tiet { background: var(--accent-soft); color: var(--accent); }
.tag-legal { background: #eef2fd; color: var(--primary); }

.lesson-body {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.8rem 2rem; box-shadow: var(--shadow); font-size: 1.02rem;
}
.lesson-body h2 { color: var(--primary-dark); font-size: 1.35rem; margin: 1.8rem 0 .7rem; padding-bottom: .35rem; border-bottom: 2px solid #eef2fd; }
.lesson-body h2:first-child { margin-top: 0; }
.lesson-body h3 { color: var(--text); font-size: 1.12rem; margin: 1.3rem 0 .5rem; }
.lesson-body p { margin: .6rem 0; }
.lesson-body ul, .lesson-body ol { margin: .6rem 0; padding-left: 1.4rem; }
.lesson-body li { margin: .35rem 0; }
.lesson-body strong { color: var(--primary-dark); }
.lesson-body table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .95rem; }
.lesson-body th, .lesson-body td { border: 1px solid var(--border); padding: .6rem .8rem; text-align: left; vertical-align: top; }
.lesson-body th { background: #eef2fd; color: var(--primary-dark); }
.lesson-body tr:nth-child(even) td { background: #fafbfe; }

.callout { border-radius: 10px; padding: 1rem 1.2rem; margin: 1.2rem 0; border-left: 4px solid; }
.callout .callout-title { font-weight: 700; margin-bottom: .3rem; display: flex; align-items: center; gap: .4rem; }
.callout p:last-child { margin-bottom: 0; }
.callout-info { background: #eef2fd; border-color: var(--primary); }
.callout-legal { background: #f3f0ff; border-color: #6d4ed1; }
.callout-warn { background: #fff6e6; border-color: var(--warn); }
.callout-danger { background: var(--accent-soft); border-color: var(--accent); }
.callout-ok { background: var(--ok-soft); border-color: var(--ok); }

.lesson-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.6rem; flex-wrap: wrap; }

/* ---------- Quiz ---------- */
.quiz-intro {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .9rem 1.4rem; box-shadow: var(--shadow); margin-bottom: .4rem;
}
.quiz-progress { font-weight: 600; color: var(--muted); }
/* Split-panel layout khi có quiz trên trang */
body:has(.quiz) {
    overflow: hidden;
}
body:has(.quiz) .main-content {
    padding: 0;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}
.quiz {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.quiz-sticky-header {
    flex-shrink: 0;
    background: var(--bg);
    padding: .5rem 0 .4rem;
}
.quiz-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 3rem;
}
.quiz-guest-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 8px 24px rgba(20, 45, 107, .22);
    overflow: hidden;
}
.quiz-guest-summary div {
    min-width: 0;
    display: grid;
    gap: .14rem;
    padding: .65rem .9rem;
    border-right: 1px solid rgba(255, 255, 255, .14);
}
.quiz-guest-summary div:last-child {
    border-right: none;
}
.quiz-guest-summary span {
    color: rgba(255, 255, 255, .65);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.quiz-guest-summary strong {
    color: #fff;
    font-size: .95rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.quiz-meta-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.quiz-timer {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 150px; border-radius: 999px; background: #eef2fd; color: var(--primary-dark);
    padding: .32rem .75rem; font-weight: 800; font-size: .9rem;
}
.quiz-timer.is-warning { background: var(--accent-soft); color: var(--accent); }
.quiz-bar { height: 8px; background: #eef2fd; border-radius: 99px; overflow: hidden; margin: .6rem 0 1.4rem; }
.quiz-bar > span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s ease; }
.quiz-nav {
    display: flex; flex-wrap: wrap; gap: .28rem; margin: .55rem 0 0;
}
.quiz-nav-item {
    min-width: 30px; height: 28px; padding: 0 .3rem;
    border-radius: 6px; border: 1.5px solid #cdd8f0;
    background: #eef2fd; color: var(--primary-dark);
    font-size: .78rem; font-weight: 700; cursor: pointer;
    font-family: inherit; display: inline-flex; align-items: center; justify-content: center;
    transition: background .12s, border-color .12s, color .12s, transform .1s;
}
.quiz-nav-item:hover { border-color: var(--primary); background: #dce6f9; transform: translateY(-1px); }
.quiz-nav-item.nav-done { background: var(--primary); border-color: var(--primary); color: #fff; }

.question {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.4rem 1.6rem; box-shadow: var(--shadow); margin-bottom: 1.1rem;
}
.question .q-num { color: var(--accent); font-weight: 700; font-size: .85rem; letter-spacing: .03em; }
.question .q-text { font-weight: 600; font-size: 1.08rem; margin: .3rem 0 1rem; }
.options { display: flex; flex-direction: column; gap: .6rem; }
.option {
    display: flex; align-items: flex-start; gap: .7rem; padding: .8rem 1rem;
    border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; transition: all .12s ease;
    background: #fff;
}
.option:hover { border-color: var(--primary); background: #f7f9ff; }
.option .mark {
    width: 26px; height: 26px; min-width: 26px; border-radius: 50%; border: 1.5px solid var(--border);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; color: var(--muted);
}
.option .opt-text { flex: 1; }
.option.selected { border-color: var(--primary); background: #eef2fd; }
.option.selected .mark { background: var(--primary); color: #fff; border-color: var(--primary); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.correct .mark { background: var(--ok); color: #fff; border-color: var(--ok); }
.option.wrong { border-color: var(--accent); background: var(--accent-soft); }
.option.wrong .mark { background: var(--accent); color: #fff; border-color: var(--accent); }
.option.locked { cursor: default; }
.option.locked:hover { background: inherit; }

.explain {
    margin-top: .9rem; padding: .9rem 1.1rem; border-radius: 9px; background: #f3f0ff;
    border-left: 4px solid #6d4ed1; font-size: .95rem; display: none;
}
.explain.show { display: block; }
.explain .ex-label { font-weight: 700; color: #6d4ed1; }

.quiz-result {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 2rem; box-shadow: var(--shadow-lg); text-align: center; margin-bottom: 1.4rem; display: none;
}
.quiz-result.show { display: block; }
.quiz-result .score-ring {
    width: 130px; height: 130px; border-radius: 50%; margin: 0 auto 1rem;
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    background: conic-gradient(var(--ok) var(--pct, 0%), #eef2fd 0);
}
.quiz-result .score-ring .inner {
    width: 104px; height: 104px; border-radius: 50%; background: #fff;
    display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.quiz-result .score-ring .pct { font-size: 1.7rem; font-weight: 800; color: var(--primary-dark); }
.quiz-result .score-ring .lbl { font-size: .75rem; color: var(--muted); }
.quiz-result h2 { margin: .4rem 0; }
.quiz-result .verdict { font-size: 1.1rem; font-weight: 600; margin-bottom: 1.2rem; }
.quiz-result .actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.quiz-save-status {
    margin: .9rem 0 0;
    font-weight: 700;
    font-size: .9rem;
}
.quiz-save-status[data-type="ok"] { color: var(--ok); }
.quiz-save-status[data-type="error"] { color: var(--accent); }
.quiz-save-status[data-type="pending"] { color: var(--muted); }
.quiz.is-locked .question,
.quiz.is-locked .quiz-intro {
    filter: saturate(.86);
}
.guest-modal {
    position: fixed; inset: 0; z-index: 100;
    display: none; align-items: center; justify-content: center;
    padding: 1.2rem;
    background:
        linear-gradient(rgba(15, 23, 42, .70), rgba(15, 23, 42, .76));
    backdrop-filter: blur(10px);
}
.guest-modal.show { display: flex; }
body.guest-modal-open { overflow: hidden; }
.guest-modal-card {
    width: min(520px, 100%);
    background: #fff;
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 14px;
    overflow: visible;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .34);
    animation: guest-modal-in .18s ease-out;
}
.guest-modal-head {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 1rem;
    align-items: center;
    padding: 1.25rem 1.35rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 14px 14px 0 0;
}
.guest-modal-icon {
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-weight: 900;
    letter-spacing: .04em;
    box-shadow: none;
}
.guest-modal-kicker {
    display: block;
    color: rgba(255, 255, 255, .72);
    font-size: .72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: .15rem;
}
.guest-modal-head h2 {
    margin: 0;
    color: #fff;
    font-size: 1.35rem;
    line-height: 1.2;
}
.guest-modal-head p {
    margin: .25rem 0 0;
    color: rgba(255, 255, 255, .80);
    font-size: .9rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.guest-info-form {
    display: grid;
    gap: 1rem;
    padding: 1.25rem 1.35rem 1.35rem;
}
.guest-field {
    display: grid;
    gap: .45rem;
}
.guest-field > span {
    font-weight: 850;
    color: var(--text);
    font-size: .9rem;
    line-height: 1.2;
}
.guest-field b { color: var(--accent); }
.guest-field em { color: var(--muted); font-style: normal; font-weight: 500; font-size: .82rem; }
.guest-input-shell {
    position: relative;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    min-height: 54px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.guest-input-shell.guest-input-no-icon {
    grid-template-columns: minmax(0, 1fr);
}
.guest-input-shell:focus-within {
    border-color: var(--primary);
    background: #fbfcff;
    box-shadow: 0 0 0 4px rgba(28, 63, 149, .10);
}
.guest-input-shell.input-shell-invalid {
    border-color: var(--accent);
    background: #fff8f8;
}
.guest-input-shell.input-shell-invalid:focus-within {
    border-color: var(--accent);
    background: #fff8f8;
    box-shadow: 0 0 0 4px rgba(217, 46, 46, .10);
}
.guest-input-shell.input-shell-valid {
    border-color: var(--ok);
    background: #f0fdf6;
}
.guest-input-shell.input-shell-valid:focus-within {
    border-color: var(--ok);
    background: #f0fdf6;
    box-shadow: 0 0 0 4px rgba(26, 157, 90, .10);
}
.guest-input-icon {
    display: inline-flex;
    width: 44px;
    height: 100%;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: .78rem;
    font-weight: 900;
}
.guest-field input,
.class-combo-input {
    width: 100%;
    min-width: 0;
    border: 0;
    padding: .85rem .9rem .85rem 0;
    font: inherit;
    color: var(--text);
    background: transparent;
}
.guest-input-no-icon input,
.guest-input-no-icon .class-combo-input {
    padding-left: .95rem;
}
.guest-field input:focus,
.class-combo-input:focus {
    outline: none;
    box-shadow: none;
}
.guest-field input.input-invalid {
    background: transparent;
}
.guest-field:has(input.input-invalid) .guest-input-shell {
    border-color: var(--accent);
    background: #fff8f8;
}
.field-error-msg { display: none; color: var(--accent); font-size: .82rem; font-weight: 600; }
.field-error-msg.show { display: block; }
.guest-error {
    padding: .78rem .9rem;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid #f3c2c2;
    font-weight: 750;
    font-size: .9rem;
}
.class-combo-wrap { position: relative; }
.class-combo-input { text-transform: uppercase; }
.class-combo-list {
    position: absolute; left: 0; right: 0; top: calc(100% + .35rem); z-index: 120;
    display: none; max-height: min(240px, 42vh); overflow-y: auto;
    margin: 0;
    padding: .35rem;
    list-style: none;
    background: #fff;
    border: 1px solid #d9e1ef;
    border-radius: 12px;
    box-shadow: 0 18px 38px rgba(15, 23, 42, .18);
}
.class-combo-list.open { display: block; }
.class-combo-item,
.class-combo-msg {
    padding: .68rem .8rem;
    font-size: .9rem;
    border-radius: 9px;
}
.class-combo-item { cursor: pointer; color: var(--text); }
.class-combo-item:hover,
.class-combo-item.class-combo-active { background: #eef2fd; color: var(--primary-dark); }
.class-combo-msg { color: var(--muted); }
.guest-lod-notice {
    display: block;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 9px;
    padding: .58rem .7rem;
    font-size: .78rem;
    line-height: 1.45;
}
.guest-lod-notice[hidden] { display: none; }
.guest-start-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    min-height: 52px;
    border: 0;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 850;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(28, 63, 149, .24);
    transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.guest-start-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(20, 45, 107, .28);
}
.guest-start-btn:active {
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(20, 45, 107, .22);
}
@keyframes guest-modal-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Gioi thieu / generic prose ---------- */
.prose { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.8rem 2rem; box-shadow: var(--shadow); }
.prose h1 { color: var(--primary-dark); margin-top: 0; }
.prose h2 { color: var(--primary-dark); margin-top: 1.6rem; }

/* ---------- Empty / message ---------- */
.notice { background: #fff6e6; border: 1px solid #f0d9a8; border-radius: var(--radius); padding: 1.2rem 1.4rem; }

/* ---------- Admin ---------- */
.admin-shell { display: flex; flex-direction: column; gap: 1rem; }
.admin-toolbar {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.4rem 1.6rem; box-shadow: var(--shadow);
}
.admin-toolbar h1 { margin: .1rem 0 .25rem; color: var(--primary-dark); font-size: 1.55rem; }
.admin-toolbar-actions, .admin-actions, .admin-row-actions, .admin-filter-actions {
    display: flex; gap: .55rem; align-items: center; flex-wrap: wrap;
}
.admin-row-actions { flex-wrap: nowrap; }
.admin-row-actions form { display: inline-flex; margin: 0; }
.admin-eyebrow {
    margin: 0; color: var(--accent); text-transform: uppercase; letter-spacing: .04em;
    font-weight: 800; font-size: .78rem;
}
.admin-subtitle, .admin-help { margin: 0; color: var(--muted); font-size: .92rem; }
.admin-help { margin-top: .9rem; }
.admin-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.2rem; box-shadow: var(--shadow);
}
.admin-auth { min-height: 52vh; display: grid; place-items: center; }
.admin-login-card { width: min(430px, 100%); }
.admin-card-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.admin-card-head h1 { margin: .1rem 0 0; color: var(--primary-dark); font-size: 1.45rem; }
.admin-field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.admin-field span { font-weight: 700; font-size: .9rem; color: var(--text); }
.admin-field input, .admin-field select, .admin-field textarea, .admin-answer-row input[type="text"] {
    width: 100%; border: 1.5px solid var(--border); border-radius: 9px;
    padding: .72rem .85rem; font-family: inherit; font-size: .95rem; background: #fff; color: var(--text);
}
.admin-field textarea { resize: vertical; min-height: 92px; }
.admin-field input:focus, .admin-field select:focus, .admin-field textarea:focus, .admin-answer-row input[type="text"]:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(28, 63, 149, .10);
}
.admin-field-grow { flex: 1; min-width: 240px; }
.admin-field-small { width: 130px; }
.admin-alert {
    border-radius: 10px; padding: .8rem 1rem; border: 1px solid; font-weight: 600;
}
.admin-alert-ok { background: var(--ok-soft); border-color: #b7e6ca; color: #137047; }
.admin-alert-danger { background: var(--accent-soft); border-color: #f3c2c2; color: var(--accent); }
.admin-alert-warn { background: #fff6e6; border-color: #f0d9a8; color: #9a5b00; }
.admin-stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: .75rem;
}
.admin-stat {
    position: relative; display: grid; grid-template-columns: 1fr auto; align-content: start; gap: .45rem .8rem;
    min-height: 116px; background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: .95rem 1rem 1rem; box-shadow: var(--shadow); color: var(--text);
}
.admin-stat::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; border-radius: 8px 0 0 8px;
    background: transparent;
}
.admin-stat:hover {
    border-color: #c8d3ec; box-shadow: 0 6px 18px rgba(20, 45, 107, .10); text-decoration: none;
}
.admin-stat.active { border-color: var(--primary); background: #f7f9ff; text-decoration: none; }
.admin-stat.active::before { background: var(--primary); }
.admin-stat span { color: var(--muted); font-size: .78rem; }
.admin-stat strong { color: var(--primary-dark); font-size: 1rem; }
.admin-stat-number { grid-column: 1; text-transform: uppercase; letter-spacing: .02em; font-weight: 700; }
.admin-stat-title {
    grid-column: 1 / -1; line-height: 1.35; min-height: 4.05em; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere;
}
.admin-stat .admin-stat-count {
    grid-column: 1; align-self: end; width: fit-content; border-radius: 999px; background: #eef2fd;
    padding: .18rem .55rem; font-weight: 800; color: var(--primary-dark); font-size: .82rem;
}
.admin-filter {
    display: flex; align-items: end; gap: .8rem; flex-wrap: wrap;
}
.admin-filter .admin-field { margin-bottom: 0; }
.admin-list { padding: 0; overflow: hidden; }
.admin-list-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
}
.admin-list-head > div { display: flex; flex-direction: column; gap: .15rem; }
.admin-list-head span { color: var(--muted); font-size: .88rem; }
.admin-empty { padding: 1.2rem; color: var(--muted); }
.admin-pagination {
    display: flex; align-items: center; justify-content: space-between; gap: .9rem; flex-wrap: wrap;
    padding: .85rem 1.2rem; border-top: 1px solid var(--border); background: #fbfcff;
}
.admin-pagination-top { border-top: 0; border-bottom: 1px solid var(--border); }
.admin-page-summary { color: var(--muted); font-size: .88rem; }
.admin-page-links { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.admin-page-link {
    display: inline-flex; min-width: 34px; height: 34px; align-items: center; justify-content: center;
    padding: 0 .65rem; border: 1px solid var(--border); border-radius: 8px; background: #fff;
    color: var(--primary); font-weight: 700; font-size: .86rem;
}
.admin-page-link:hover { border-color: var(--primary); text-decoration: none; }
.admin-page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.admin-page-link.disabled { opacity: .45; pointer-events: none; color: var(--muted); }
.admin-page-jump { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .88rem; }
.admin-page-jump input {
    width: 76px; border: 1.5px solid var(--border); border-radius: 8px;
    padding: .48rem .6rem; font-family: inherit; font-size: .9rem; color: var(--text);
}
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td {
    padding: .8rem .9rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top;
}
.admin-table th { background: #f7f9ff; color: var(--primary-dark); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.admin-stt-cell { width: 64px; color: var(--muted); font-weight: 700; text-align: center !important; }
.admin-table th:last-child, .admin-table td:last-child { width: 150px; }
.admin-module-cell { min-width: 180px; max-width: 260px; }
.admin-module-cell .admin-module-code { display: block; color: var(--primary-dark); font-weight: 800; font-size: .82rem; margin-bottom: .2rem; }
.admin-module-cell span:last-child { display: block; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.admin-question-title { font-weight: 700; color: var(--text); line-height: 1.45; }
.admin-question-module { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.admin-nowrap { white-space: nowrap; }
.admin-badge {
    display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 999px;
    font-size: .78rem; font-weight: 800;
}
.admin-badge.ok { background: var(--ok-soft); color: #137047; }
.admin-badge.warn { background: #fff6e6; color: #9a5b00; }
.admin-badge.danger { background: var(--accent-soft); color: var(--accent); }
.admin-form { display: flex; flex-direction: column; gap: .3rem; }
.admin-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 1rem; }
.exam-builder-form { padding: 0; overflow: hidden; }
.exam-builder-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 0;
    align-items: start;
}
.exam-builder-main { min-width: 0; border-right: 1px solid var(--border); }
.exam-section { padding: 1.1rem 1.2rem; border-bottom: 1px solid var(--border); }
.exam-section:last-child { border-bottom: 0; }
.exam-section-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    margin-bottom: .9rem;
}
.exam-section-head h2 {
    margin: 0; color: var(--primary-dark); font-size: 1rem; line-height: 1.3;
}
.exam-section-head span { color: var(--muted); font-size: .86rem; font-weight: 700; }
.exam-title-grid { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 1rem; }
.exam-section .admin-field:last-child { margin-bottom: 0; }
.exam-module-list {
    display: grid; border: 1px solid var(--border); border-radius: 10px;
    overflow: hidden; background: #fff;
}
.exam-module-row {
    display: grid; grid-template-columns: 42px minmax(0, 1fr) 128px; align-items: center; gap: .85rem;
    min-height: 68px; padding: .65rem .75rem; border-bottom: 1px solid var(--border);
    background: #fff; transition: background .12s ease, box-shadow .12s ease;
}
.exam-module-row:last-child { border-bottom: 0; }
.exam-module-row:hover { background: #fbfcff; }
.exam-module-row.is-selected { background: #f7f9ff; box-shadow: inset 4px 0 0 var(--primary); }
.exam-module-row.is-over { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.exam-module-index {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px; background: #eef2fd;
    color: var(--primary-dark); font-weight: 800; line-height: 1;
}
.exam-module-info { display: grid; gap: .12rem; min-width: 0; }
.exam-module-info strong {
    color: var(--text); line-height: 1.35; overflow: hidden; text-overflow: ellipsis;
}
.exam-module-info span { color: var(--muted); font-size: .84rem; }
.exam-module-info b { color: var(--primary-dark); font-weight: 800; }
.exam-module-row.is-over .exam-module-info b { color: var(--accent); }
.exam-module-control {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .45rem;
    color: var(--muted); font-size: .84rem; font-weight: 700;
}
.exam-module-control input {
    width: 100%; min-width: 0; border: 1.5px solid var(--border); border-radius: 8px;
    padding: .55rem .55rem; font-family: inherit; font-size: .95rem; color: var(--text);
    text-align: center; background: #fff;
}
.exam-module-control input:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(28, 63, 149, .10);
}
.exam-module-control input:disabled { background: #f2f4f8; color: var(--muted); }
.exam-builder-side {
    position: sticky; top: 82px; display: grid; gap: .9rem; padding: 1.1rem;
}
.exam-total-box {
    display: grid; gap: .15rem; padding: 1rem; border-radius: 10px;
    background: var(--primary); color: #fff;
}
.exam-total-box span { font-size: .82rem; opacity: .86; font-weight: 700; }
.exam-total-box strong { font-size: 2.3rem; line-height: 1; }
.exam-side-metrics { display: grid; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.exam-side-metrics div { display: grid; gap: .12rem; padding: .85rem .95rem; border-bottom: 1px solid var(--border); }
.exam-side-metrics div:last-child { border-bottom: 0; }
.exam-side-metrics span { color: var(--muted); font-size: .82rem; font-weight: 700; }
.exam-side-metrics strong { color: var(--primary-dark); }
.exam-builder-actions {
    padding: 1rem 1.2rem; border-top: 1px solid var(--border); background: #fbfcff;
}
.admin-answer-box { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: .4rem 0 1rem; }
.admin-answer-head {
    display: flex; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; background: #f7f9ff;
    border-bottom: 1px solid var(--border);
}
.admin-answer-head span { color: var(--muted); font-size: .86rem; }
.admin-answer-row {
    display: grid; grid-template-columns: 170px 1fr; gap: .8rem; align-items: center;
    padding: .75rem 1rem; border-bottom: 1px solid var(--border);
}
.admin-answer-row:last-child { border-bottom: none; }
.admin-answer-choice { display: flex; align-items: center; gap: .65rem; }
.admin-answer-letter {
    display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
    border-radius: 50%; border: 1.5px solid var(--border); background: #fff; color: var(--primary);
    font-weight: 800; line-height: 1;
}
.admin-radio {
    display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; color: var(--primary-dark);
}

@media (max-width: 760px) {
    .admin-toolbar, .admin-list-head, .admin-answer-head { flex-direction: column; align-items: stretch; }
    .quiz-guest-summary { grid-template-columns: 1fr; }
    .quiz-guest-summary div { border-right: none; border-bottom: 1px solid rgba(255,255,255,.14); }
    .quiz-guest-summary div:last-child { border-bottom: none; }
    .admin-form-grid { grid-template-columns: 1fr; gap: 0; }
    .exam-builder-layout { grid-template-columns: 1fr; }
    .exam-builder-main { border-right: 0; }
    .exam-builder-side { position: static; border-top: 1px solid var(--border); }
    .exam-title-grid { grid-template-columns: 1fr; gap: 0; }
    .exam-module-row { grid-template-columns: 38px minmax(0, 1fr); gap: .65rem; }
    .exam-module-control { grid-column: 2; grid-template-columns: 110px auto; justify-content: start; }
    .admin-answer-row { grid-template-columns: 1fr; gap: .45rem; }
    .admin-field-small { width: 100%; }
    .admin-filter-actions { width: 100%; }
    .admin-filter-actions .btn { flex: 1; }
    .admin-pagination, .admin-page-jump { align-items: stretch; flex-direction: column; }
    .admin-page-links { width: 100%; }
    .admin-page-link { flex: 1; }
    .admin-page-jump input, .admin-page-jump .btn { width: 100%; }
}

/* ---------- Footer ---------- */
.site-footer { background: var(--primary-dark); color: #d8e0f5; margin-top: 3rem; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.6rem; padding: 2.4rem 0; }
.footer-grid h4 { color: #fff; margin: 0 0 .7rem; font-size: 1rem; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin: .4rem 0; font-size: .9rem; }
.footer-grid p { font-size: .9rem; margin: 0; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.12); padding: 1rem 0; font-size: .82rem; color: #aeb9da; }

/* ---------- Cụm chuyên đề (trang chủ) ---------- */
.cluster { margin-bottom: 1.8rem; }
.cluster-head {
    display: flex; align-items: center; gap: .7rem; margin: 1.6rem 0 1rem;
    padding-left: .9rem; border-left: 5px solid var(--c, var(--primary));
}
.cluster-head h2 { margin: 0; font-size: 1.25rem; color: var(--c, var(--primary-dark)); }
.cluster-head .cluster-count {
    font-size: .78rem; font-weight: 600; color: #fff; background: var(--c, var(--primary));
    padding: .15rem .6rem; border-radius: 999px;
}
.module-card { border-top: 3px solid var(--c, var(--border)); }
.module-card .num { background: var(--c-soft, #eef2fd); color: var(--c, var(--primary)); }
.module-card .meta .tiet { background: var(--c-soft, var(--accent-soft)); color: var(--c, var(--accent)); }
.module-card .btn-primary { background: var(--c, var(--primary)); }
.module-card .btn-primary:hover { filter: brightness(.9); }
.module-card .btn-outline { color: var(--c, var(--primary)); }
.module-card .btn-outline:hover { border-color: var(--c, var(--primary)); }

/* ---------- Thanh tiến độ đọc (đỉnh trang) ---------- */
.read-progress {
    position: fixed; top: 0; left: 0; height: 4px; width: 0; z-index: 60;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    transition: width .1s linear;
}

/* ---------- Bố cục bài học + mục lục ---------- */
.lesson-layout { display: grid; grid-template-columns: 250px 1fr; gap: 1.6rem; align-items: start; }
.toc-wrap { position: sticky; top: 80px; }
.toc {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.1rem; box-shadow: var(--shadow); max-height: calc(100vh - 110px); overflow-y: auto;
}
.toc-title { font-weight: 700; color: var(--primary-dark); font-size: .95rem; margin-bottom: .6rem; display: flex; align-items: center; gap: .4rem; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: .15rem 0; }
.toc a {
    display: block; padding: .35rem .6rem; border-radius: 7px; font-size: .88rem; color: var(--muted);
    border-left: 2px solid transparent; line-height: 1.4;
}
.toc a:hover { background: #f3f6fd; color: var(--primary); text-decoration: none; }
.toc a.active { color: var(--primary); background: #eef2fd; border-left-color: var(--primary); font-weight: 600; }
.lesson-main { min-width: 0; }
.reading-time { color: var(--muted); }

/* ---------- Nút lên đầu trang ---------- */
.back-to-top {
    position: fixed; right: 22px; bottom: 22px; width: 46px; height: 46px; border-radius: 50%;
    background: var(--primary); color: #fff; border: none; cursor: pointer; font-size: 1.3rem;
    box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transform: translateY(10px); transition: all .2s ease; z-index: 55;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--primary-dark); }

/* ---------- Quiz: thanh tiến độ dính + xem lại câu sai + confetti ---------- */
.quiz-topbar { position: fixed; top: 0; left: 0; height: 4px; width: 100%; z-index: 61; background: #e4e8f0; }
.quiz-topbar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--primary)); transition: width .3s ease; }
.quiz.review-mode .question.ans-correct { display: none; }
.review-banner {
    display: none; background: var(--accent-soft); border: 1px solid #f3c2c2; color: var(--accent);
    border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1rem; font-weight: 600; font-size: .92rem;
}
.quiz.review-mode .review-banner { display: block; }
.confetti-piece {
    position: fixed; top: -12px; width: 9px; height: 14px; z-index: 70; opacity: .95;
    animation: confetti-fall linear forwards; pointer-events: none;
}
@keyframes confetti-fall {
    to { transform: translateY(105vh) rotate(720deg); opacity: .9; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .nav-toggle { display: block; }
    .site-nav {
        display: none; position: absolute; top: 100%; left: 0; right: 0; background: #fff;
        flex-direction: column; padding: .6rem; border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
    }
    body.nav-open .site-nav { display: flex; }
    .hero h1 { font-size: 1.55rem; }
    .lesson-body { padding: 1.3rem 1.2rem; }
    .lesson-body table { display: block; overflow-x: auto; }
    .lesson-layout { grid-template-columns: 1fr; }
    .toc-wrap { display: none; }
}
