/* =========================================================
   Tin học THCS – giao diện chung (v4, 19/10/2026)
   Nguyên tắc: gọn, rõ, dễ đọc tiếng Việt; một phông sans;
   không hiệu ứng hiện dần; màu nhấn dùng tiết chế.
   ========================================================= */
:root {
    --ink: #1c2733;
    --ink-2: #3b4a59;
    --muted: #66768a;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f8fafb;
    --line: #e1e6eb;
    --line-2: #cfd7df;
    --brand: #0f6e5e;
    --brand-deep: #0b5548;
    --brand-soft: #e3f2ee;
    --accent: #c4621f;
    --accent-soft: #fdeee3;
    --ok: #1f7a4a;
    --ok-soft: #e2f4e9;
    --warn: #8a5a00;
    --warn-soft: #fdf3d7;
    --danger: #b42318;
    --danger-soft: #fdebe9;
    --info: #1f5f99;
    --info-soft: #e5eff9;
    --radius: 10px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.08);
    --sidebar-w: 248px;
    --font: "Be Vietnam Pro", "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
}

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

h1, h2, h3, h4 { color: var(--ink); line-height: 1.3; letter-spacing: -0.01em; }

code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9em;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0 4px;
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.ico { width: 18px; height: 18px; flex: none; }

/* ---------- Thương hiệu ---------- */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.brand:hover { text-decoration: none; }

.brand-mark {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 9px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    background: var(--brand);
}

.brand-text strong { display: block; font-size: 1rem; line-height: 1.2; }
.brand-text span { display: block; color: var(--muted); font-size: 0.75rem; }

/* ---------- Bố cục sau đăng nhập: thanh bên + nội dung ---------- */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.sidebar > .brand { padding: 16px 18px; border-bottom: 1px solid var(--line); }

.side-nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }

.side-group + .side-group { margin-top: 14px; }

.side-title {
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: 0.92rem;
    font-weight: 500;
}

.side-link .ico { color: var(--muted); }
.side-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.side-link.is-active { background: var(--brand-soft); color: var(--brand-deep); font-weight: 600; }
.side-link.is-active .ico { color: var(--brand); }

.side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
}

.avatar {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand-deep);
    font-weight: 700;
}

.side-user-text { min-width: 0; flex: 1; }
.side-user-text strong { display: block; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-text span { display: block; font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user form { margin: 0; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }

.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 10px 28px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
}

.app-header-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header-meta {
    font-size: 0.82rem;
    color: var(--muted);
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    white-space: nowrap;
}

.menu-btn { display: none; }
.sidebar-backdrop { display: none; }

.app-content { width: 100%; max-width: 1200px; padding: 24px 28px 48px; }

@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-md); }
    .nav-toggle:checked ~ .app-shell .sidebar { transform: none; }
    .nav-toggle:checked ~ .app-shell .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 30;
        background: rgba(16, 24, 40, 0.35);
    }
    .app-main { margin-left: 0; }
    .menu-btn { display: inline-grid; margin-left: -6px; }
    .app-header { padding: 8px 16px; }
    .app-content { padding: 16px 16px 40px; }
}

@media (max-width: 520px) {
    .app-header-meta { display: none; }
}

/* ---------- Trang công khai (chưa đăng nhập) ---------- */
.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 16px 0 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }

.nav a:not(.btn) {
    color: var(--ink-2);
    font-size: 0.92rem;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
}

.nav a:not(.btn):hover,
.nav a.is-active:not(.btn) { background: var(--brand-soft); color: var(--brand-deep); text-decoration: none; }

.footer-note { margin-top: 32px; color: var(--muted); font-size: 0.82rem; text-align: center; }

/* ---------- Banner trang chủ / đầu trang ---------- */
.hero {
    position: relative;
    border-radius: 14px;
    padding: clamp(24px, 4vw, 44px);
    margin-bottom: 20px;
    color: #fff;
    background: linear-gradient(120deg, #0b5548 0%, #0f6e5e 55%, #1b6f8a 100%);
}

.hero-kicker {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.85;
}

.hero h1 { margin: 0 0 10px; color: #fff; font-size: clamp(1.6rem, 3.4vw, 2.4rem); max-width: 22ch; }
.hero p { margin: 0; max-width: 60ch; font-size: 1rem; opacity: 0.92; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.site .hero .btn-secondary { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.35); }

/* Bên trong khu vực đăng nhập, “hero” trở thành đầu trang gọn */
.app .hero {
    padding: 0 0 4px;
    margin-bottom: 18px;
    color: var(--ink);
    background: none;
    border-radius: 0;
}

.app .hero-kicker { color: var(--brand); opacity: 1; margin-bottom: 2px; font-size: 0.72rem; }
.app .hero h1 { color: var(--ink); font-size: 1.55rem; max-width: none; margin-bottom: 4px; }
.app .hero p { color: var(--muted); font-size: 0.95rem; opacity: 1; }
.app .hero-actions { margin-top: 12px; }

/* ---------- Khối nội dung ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.panel h1, .panel h2, .panel h3 { margin: 0 0 8px; }
.panel h1 { font-size: 1.45rem; }
.panel h2 { font-size: 1.12rem; }
.panel h3 { font-size: 1rem; }
.panel > :last-child { margin-bottom: 0; }

.muted { color: var(--muted); font-size: 0.92rem; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }

.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.grid-3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat {
    display: block;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    color: inherit;
}

a.stat:hover { border-color: var(--line-2); text-decoration: none; box-shadow: var(--shadow-md); }
.stat .label { color: var(--muted); font-size: 0.8rem; font-weight: 500; margin-bottom: 4px; }
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--ink); line-height: 1.2; }

.feature {
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.feature h3 { margin: 0 0 6px; font-size: 1.02rem; }
.feature p { margin: 0; }

.course-tile {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
}

.course-tile:hover { border-color: var(--line-2); }
.course-tile h3 { margin: 0 0 4px; font-size: 1.02rem; }

.meta-list { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.88rem; }

.log-box {
    font-size: 0.85rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px;
    max-height: 220px;
    overflow: auto;
}

.log-box h4 { margin: 0 0 8px; font-size: 0.85rem; }
.log-box ul { margin: 0; padding-left: 18px; }

/* ---------- Nút ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 16px;
    border: 1px solid var(--brand);
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease;
}

.btn:hover { background: var(--brand-deep); border-color: var(--brand-deep); text-decoration: none; color: #fff; }

.btn-secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }

.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: #a9531a; border-color: #a9531a; }

.btn-sm { min-height: 30px; padding: 5px 10px; font-size: 0.82rem; }

button.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; }

/* Nút trong bảng: dạng viền nhẹ để bảng không rối mắt */
table.data .btn,
table.data .btn-accent {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 0.8rem;
    background: var(--surface);
    color: var(--brand-deep);
    border-color: var(--line-2);
}

table.data .btn:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); }
table.data .btn-secondary { color: var(--ink-2); }

/* ---------- Nhãn trạng thái ---------- */
.chip, .pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
    background: var(--brand-soft);
    color: var(--brand-deep);
}

.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.pill-muted { background: #edf0f3; color: var(--muted); }

/* ---------- Thông báo ---------- */
.flash {
    background: var(--ok-soft);
    border: 1px solid #b9e2c9;
    color: #14532d;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.92rem;
}

.flash-error { background: var(--danger-soft); border-color: #f3c1bb; color: #7f1d1d; }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; }

.panel:has(> table.data) { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; }

table.data th,
table.data td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    vertical-align: middle;
}

table.data th {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--surface-2);
    white-space: nowrap;
}

table.data tbody tr:hover td { background: #fafcfb; }
table.data tr:last-child td { border-bottom: 0; }

.data td .row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
table.data td:has(> .row-actions) { width: 1%; white-space: nowrap; }
.data .inline-form { display: inline; }

/* ---------- Biểu mẫu ---------- */
label { display: block; margin: 0 0 5px; font-size: 0.86rem; font-weight: 600; color: var(--ink-2); }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=date], input[type=datetime-local], input[type=file], input[type=search], select, textarea {
    width: 100%;
    margin-bottom: 12px;
    padding: 9px 11px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 0.92rem;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 110, 94, 0.14); }

textarea { min-height: 110px; resize: vertical; }

.field { margin-bottom: 14px; }
.field input, .field select, .field textarea { margin-bottom: 0; }
.field .hint { font-size: 0.78rem; color: var(--muted); font-weight: 400; margin-top: 4px; }

.form-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 160px; }
.filters .field input, .filters .field select { min-height: 38px; }

/* Thanh điều hướng phụ cũ – giữ cho trang chưa chuyển */
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.subnav a { padding: 6px 12px; border-radius: var(--radius-sm); font-size: 0.88rem; color: var(--muted); }
.subnav a.is-active { background: var(--brand-soft); color: var(--brand-deep); font-weight: 600; }

/* ---------- Phân trang ---------- */
.lms-pagination { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lms-pagination a, .lms-pagination span {
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid var(--line);
    color: var(--ink);
    background: #fff;
}
.lms-pagination .is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.lms-pagination .is-disabled { color: var(--muted); background: transparent; border-color: transparent; }

/* ---------- Đăng nhập ---------- */
.auth-wrap { display: grid; place-items: center; padding: 24px 0 8px; }
.auth-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px;
    box-shadow: var(--shadow-md);
}
.auth-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.auth-card .muted { margin: 0 0 18px; }
.auth-note { margin-top: 16px; font-size: 0.8rem; color: var(--muted); }

/* ---------- Video ---------- */
.video-frame {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    margin: 10px 0 18px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #0b2a24;
}

.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Trắc nghiệm (bản cũ) ---------- */
.quiz-options { display: grid; gap: 8px; }
.quiz-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
    font-weight: 500;
}
.quiz-option:hover { border-color: var(--line-2); background: #fff; }
.quiz-option input { margin-top: 3px; width: auto; }

/* ---------- Màn hình làm bài ---------- */
.quiz-exam-body { margin: 0; min-height: 100vh; background: var(--bg); overflow-x: hidden; }
.quiz-exam { min-height: 100vh; background: var(--bg); position: relative; overflow-x: hidden; }

.quiz-exam:fullscreen,
.quiz-exam:-webkit-full-screen { width: 100%; height: 100%; overflow-y: auto !important; overflow-x: hidden; background: var(--bg); }

html:fullscreen, html:-webkit-full-screen,
html:fullscreen body, html:-webkit-full-screen body { overflow-y: auto !important; height: 100%; }

.qz-layout {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
    padding: 22px 0 96px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 22px;
    align-items: start;
}

.qz-main { min-width: 0; }
.qz-head h1 { margin: 0 0 8px; font-size: 1.5rem; }
.qz-head h2 { margin: 10px 0 0; font-size: 1.1rem; }
.qz-head hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0 0; }

.qz-banner { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.9rem; margin-bottom: 10px; }
.qz-started { color: var(--muted); font-size: 0.9rem; }

.qz-question { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; box-shadow: var(--shadow); }

.qz-question-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 12px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

.qz-question-title { font-weight: 700; }
.qz-level { font-weight: 500; color: var(--muted); }
.qz-points { font-weight: 600; white-space: nowrap; color: var(--ink-2); }

.qz-question-body { padding: 16px 18px 8px; }
.qz-question-text { margin: 0 0 14px; font-size: 1.05rem; line-height: 1.6; }

.qz-options { display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; }

.qz-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 400;
}

.qz-option:hover { background: var(--surface-2); border-color: var(--line-2); }
.qz-option:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); }
.qz-option input { margin-top: 4px; width: auto; flex: none; accent-color: var(--brand); }

.qz-navbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; }
.qz-progress { color: var(--muted); font-size: 0.9rem; }

.qz-submitbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.qz-savestate { font-size: 0.88rem; color: var(--muted); }
.qz-savestate[data-state="saved"] { color: var(--ok); }
.qz-savestate[data-state="error"] { color: var(--danger); }

.qz-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; }

.qz-edit-link {
    display: block;
    text-align: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 0.88rem;
}

.qz-side-panel { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 14px; }
.qz-side-panel h3 { margin: 0 0 10px; font-size: 1rem; }

.qz-qlist { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }

.qz-qlink {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 6px;
    padding: 6px 10px;
    font: inherit;
    font-size: 0.9rem;
    color: var(--ink-2);
    cursor: pointer;
}

.qz-qlink:hover { background: var(--surface-2); }
.qz-qlink.is-current { font-weight: 700; background: var(--brand-soft); color: var(--brand-deep); }
.qz-qlink.is-answered { color: var(--ink); }
.qz-qlink.is-answered::before { content: "● "; color: var(--ok); }
.qz-qlink:not(.is-answered)::before { content: "○ "; color: var(--muted); }

.qz-timer-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--muted); }
.qz-timer-toggle { background: transparent; border: 0; color: var(--brand); cursor: pointer; font: inherit; font-size: 0.85rem; }
.qz-timer { margin-top: 6px; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.qz-timer.is-low { color: var(--danger); }

@media (max-width: 860px) {
    .qz-layout { grid-template-columns: 1fr; }
    .qz-side { position: static; order: -1; }
    .qz-qlist { max-height: 140px; }
}

.quiz-gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgba(16, 24, 40, 0.88); }
.quiz-gate[hidden] { display: none !important; }
.quiz-gate-card { width: min(520px, 100%); background: #fff; border-radius: 14px; padding: 28px; text-align: center; box-shadow: var(--shadow-md); }
.quiz-gate-card h1 { margin: 0 0 10px; font-size: 1.35rem; }

.quiz-exam.is-locked .qz-layout { filter: blur(8px); pointer-events: none; user-select: none; visibility: hidden; }

/* ---------- Di động ---------- */
@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; }
    .course-tile { flex-direction: column; align-items: stretch; }
    .panel { padding: 16px; }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---------- Câu Đúng/Sai 4 ý & điền khuyết ---------- */
.qz-question-text { white-space: pre-line; }
.qz-hint { margin: -6px 0 12px; font-size: 0.85rem; color: var(--muted); }

.qz-tf { display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; }
.qz-tf-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.qz-tf-row:has(input:checked) { background: var(--surface-2); }
.qz-tf-text { flex: 1; }
.qz-tf-choices { display: flex; gap: 6px; flex: none; }
.qz-tf-choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 12px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.qz-tf-choice input { width: auto; margin: 0; accent-color: var(--brand); }
.qz-tf-choice:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); }

.qz-fill { line-height: 2.4; }
.qz-fill .qz-blank {
    display: inline-block;
    width: auto;
    min-width: 150px;
    margin: 0 4px;
    padding: 4px 8px;
    font-size: 0.95rem;
    vertical-align: baseline;
    border-color: var(--brand);
    background: #fff;
}
.qz-fill input.qz-blank { width: 180px; }

@media (max-width: 600px) {
    .qz-tf-row { flex-direction: column; align-items: stretch; }
    .qz-tf-choices { justify-content: flex-end; }
}

/* ---------- Nội dung bài học (kiến thức trọng tâm) ---------- */
.lesson-content h3 { margin: 18px 0 8px; font-size: 1.02rem; color: var(--brand-deep); }
.lesson-content h3:first-child { margin-top: 0; }
.lesson-content p { margin: 0 0 10px; }
.lesson-content ul { margin: 0 0 12px; padding-left: 20px; }
.lesson-content li { margin-bottom: 4px; }
.lesson-content table.data { margin: 6px 0 14px; border: 1px solid var(--line); }
.lesson-content table.data th { text-transform: none; letter-spacing: 0; font-size: 0.85rem; color: var(--ink-2); }
.lesson-content table.data td { vertical-align: top; }
.lesson-content pre {
    margin: 6px 0 14px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    overflow-x: auto;
}
.lesson-content .table-scroll { overflow-x: auto; }
.text-lines { white-space: pre-line; line-height: 1.7; }

/* ---------- Nhập câu hỏi từ Word ---------- */
.code-sample {
    margin: 6px 0 10px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* ---------- Biểu mẫu câu hỏi ---------- */
.opt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.opt-row input[type=text] { flex: 1; min-width: 180px; margin: 0; }
.opt-label { width: 24px; flex: none; font-weight: 700; color: var(--ink-2); }
.opt-correct { display: inline-flex; align-items: center; gap: 10px; flex: none; margin: 0; font-weight: 500; white-space: nowrap; }
.opt-correct label { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-weight: 500; }
.opt-correct input { width: auto; margin: 0; accent-color: var(--brand); }
[hidden] { display: none !important; }
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.row-actions form { margin: 0; }

/* ---------- Ma trận đề nhiều bài ---------- */
table.matrix th.num, table.matrix td.num { text-align: center; width: 76px; }
table.matrix td.num input { width: 58px; margin: 0 auto; padding: 5px 6px; text-align: center; }
table.matrix td.num input:disabled { background: var(--surface-2); }
table.matrix td.num input.over { border-color: var(--danger); background: var(--danger-soft); }
table.matrix .avail { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
table.matrix tr.topic-row td { background: var(--surface-2); color: var(--brand-deep); font-size: 0.85rem; }
table.matrix tr.has-value td { background: #f4fbf8; }
table.matrix tfoot th { font-size: 0.85rem; color: var(--ink); text-transform: none; }
table.matrix .row-total { font-weight: 700; }

/* Giám sát làm bài: cảnh báo số lần rời màn hình, chặn chọn/sao chép nội dung đề */
.quiz-gate-warning { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff4e5; color: #9a3412; font-weight: 600; }
.quiz-exam { -webkit-user-select: none; user-select: none; }
.quiz-exam input, .quiz-exam textarea { -webkit-user-select: text; user-select: text; }

/* Cài đặt làm bài trên trang đề của giáo viên */
.settings-row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-start; }
.settings-row .field { margin: 0; flex: 1 1 160px; max-width: 240px; }
.settings-row .field:last-child { flex: 0 0 auto; padding-top: 24px; }
.settings-row .field small { display: block; margin-top: 4px; }
td.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
td.row-actions form { margin: 0; }
