:root {
    --navy: #012169;
    --navy-deep: #01184d;
    --orange: #ff671f;
    --orange-deep: #e05612;
    --sky: #8dc8e8;
    --sky-soft: #e7f5fb;
    --white: #ffffff;
    --ink: #292724;
    --ink-soft: #43433d;
    --muted: #666666;
    --line: #d9d9d9;
    --paper: #fafafa;
    --ok: #1f7a4d;
    --ok-soft: #e7f6ee;
    --bad: #b42318;
    --bad-soft: #fdecea;
    --shadow: 0 16px 40px rgba(1, 33, 105, 0.08);
    --radius: 18px;
    --font: "Raleway", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.5;
}
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.4rem; }
p { margin: 0.4rem 0; }
code { font-family: ui-monospace, monospace; font-size: 0.92em; }

.skip {
    position: absolute;
    left: 1rem;
    top: -4rem;
    background: var(--orange);
    color: white;
    padding: 0.5rem 0.8rem;
    z-index: 5;
}
.skip:focus { top: 1rem; }

.splash {
    min-height: 100vh;
    background: var(--white);
    display: grid;
    place-items: center;
}
.splash-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.2rem;
    padding: 2rem 1rem 3rem;
    width: min(980px, 100%);
}
.splash-logo { width: min(850px, 92vw); height: auto; }
.splash-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: clamp(1rem, 4vw, 3rem);
}
.splash-icon, .splash-qcm {
    width: clamp(64px, 12vw, 100px);
    height: clamp(64px, 12vw, 100px);
    display: grid;
    place-items: center;
    text-decoration: none;
    transition: transform 0.2s ease;
}
.splash-icon svg { width: 78%; height: 78%; }
.splash-icon:hover, .splash-qcm:hover { transform: scale(1.18); }
.instagram { color: #e1306c; }
.facebook { color: #1877f2; }
.tiktok { color: #000; }
.game { color: var(--orange); }
.splash-qcm {
    border-radius: 50%;
    background: var(--orange);
    color: white;
    font-weight: 800;
    letter-spacing: 0.04em;
    font-size: clamp(0.95rem, 2vw, 1.35rem);
    box-shadow: 0 10px 24px rgba(255, 103, 31, 0.28);
}
.splash-caption { margin: 0; color: var(--muted); font-weight: 600; }
.splash-site { color: var(--navy); font-weight: 700; text-decoration: none; }

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1.2rem;
    background: var(--navy);
    color: white;
    position: sticky;
    top: 0;
    z-index: 4;
}
.brand, .brand-invert {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: white;
    text-decoration: none;
    font-weight: 700;
}
.brand img, .brand-invert img { background: white; border-radius: 50%; }
.topnav { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.topnav a { color: white; text-decoration: none; font-weight: 700; }
.who { color: var(--sky); font-weight: 700; }
.page { width: min(1100px, calc(100% - 2rem)); margin: 1.4rem auto 2rem; }
.quiz-body .page { width: min(1240px, calc(100% - 1.2rem)); }
.colophon { text-align: center; color: var(--muted); padding: 0 1rem 2rem; font-size: 0.92rem; }

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.2rem 1.25rem 1.3rem;
    margin: 0 0 1rem;
}
.narrow { width: min(520px, 100%); margin-left: auto; margin-right: auto; }
.page-head, .block-head, .chapter-head, .quiz-status, .actions, .attachment-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}
.eyebrow {
    margin: 0;
    color: var(--orange);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.78rem;
}
.lede { color: var(--ink-soft); max-width: 62ch; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 0.9rem; }
label { display: grid; gap: 0.35rem; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem 0.8rem;
    background: white;
    min-height: 48px;
}
textarea { min-height: 120px; resize: vertical; }
.check { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; }
.check input { width: auto; min-height: 0; }
.form-grid, .filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.8rem; align-items: end; }
.help { color: var(--muted); }

.btn, button.btn, a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.7rem 1.1rem;
    border-radius: 999px;
    border: 2px solid transparent;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    background: transparent;
    color: var(--navy);
}
.btn-primary, button.btn-primary, a.btn-primary {
    background: var(--orange);
    border-color: var(--orange);
    color: white;
}
.btn-primary:hover, button.btn-primary:hover, a.btn-primary:hover { background: var(--orange-deep); border-color: var(--orange-deep); }
.btn-navy, button.btn-navy, a.btn-navy {
    background: var(--navy);
    border-color: var(--navy);
    color: white;
}
.btn-ghost, button.btn-ghost, a.btn-ghost {
    background: white;
    border-color: var(--line);
    color: var(--navy);
}
.topnav .btn-ghost, .topnav a.btn-ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.45);
    color: white;
}
.btn-small { min-height: 40px; padding: 0.35rem 0.75rem; font-size: 0.92rem; }
.btn:disabled, button:disabled { opacity: 0.45; cursor: not-allowed; }
.row-actions button, .pager a {
    border: 0;
    background: transparent;
    color: var(--navy);
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    padding: 0.2rem 0.35rem;
}
.row-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }

.flash { padding: 0.8rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 700; }
.flash-error { background: var(--bad-soft); color: var(--bad); }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.auth-body { background: linear-gradient(180deg, var(--sky-soft), var(--paper) 280px); }
.auth-logo { width: min(280px, 80%); }
.auth-card h1 { color: var(--navy); }

.mode-grid, .metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.metric-grid .card { display: grid; gap: 0.2rem; }
.metric-grid b { font-size: 1.8rem; color: var(--navy); }
.mode-card h2 { font-size: 2rem; color: var(--navy); }
.quota { list-style: none; padding: 0; margin: 0.6rem 0; }
.quota li, .stat-row, .review header, .attachment-row {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
}
.quota li { padding: 0.28rem 0; border-bottom: 1px solid var(--line); }
.resume { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; border-left: 6px solid var(--orange); }

.cert-block h2, .chapter-block h3 { color: var(--navy); }
.chapter-block { margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.sub-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.sub-list li, .sub-actions { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.sub-list li { padding: 0.55rem 0; }
.sub-actions input { width: 5.5rem; min-height: 44px; }
.selection-total {
    position: sticky;
    top: 4.4rem;
    width: fit-content;
    background: white;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.7rem 1rem;
    box-shadow: var(--shadow);
    z-index: 2;
}
.sticky-actions {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    z-index: 3;
    width: min(640px, calc(100% - 1.5rem));
    background: white;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.55rem 0.7rem;
    box-shadow: var(--shadow);
}
body { padding-bottom: 0; }
.page { margin-bottom: 5.5rem; }

.quiz-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1rem; align-items: start; }
.quiz-map {
    position: sticky;
    top: 4.6rem;
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.8rem;
}
.map-label { margin: 0 0 0.6rem; font-weight: 800; color: var(--navy); }
.q-map { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.35rem; max-height: calc(100vh - 220px); overflow: auto; }
.q-num {
    min-height: 42px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    font-weight: 800;
    cursor: pointer;
}
.q-num.is-answered { background: var(--sky-soft); border-color: var(--sky); }
.q-num.is-current { outline: 3px solid var(--orange); }
.q-num.is-correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.q-num.is-wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.legend { list-style: none; padding: 0.7rem 0 0; margin: 0; color: var(--muted); font-size: 0.88rem; }
.legend li { display: flex; gap: 0.4rem; align-items: center; }
.swatch { width: 0.9rem; height: 0.9rem; border-radius: 4px; border: 1px solid var(--line); display: inline-block; background: white; }
.swatch.is-answered { background: var(--sky-soft); border-color: var(--sky); }
.swatch.is-current { outline: 2px solid var(--orange); }
.swatch.is-correct { background: var(--ok-soft); border-color: var(--ok); }
.swatch.is-wrong { background: var(--bad-soft); border-color: var(--bad); }
.question-card h1 { font-size: clamp(1.25rem, 2vw, 1.7rem); }
.answers { border: 0; margin: 0; padding: 0; display: grid; gap: 0.65rem; }
.answer {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 0.7rem;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.75rem 0.8rem;
    cursor: pointer;
    font-weight: 600;
}
.answer input { width: auto; min-height: 0; }
.letter {
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--navy);
    color: white;
    font-weight: 800;
}
.answer:has(input:checked) { border-color: var(--navy); background: var(--sky-soft); }
.answer.is-right { border-color: var(--ok); background: var(--ok-soft); }
.answer.is-bad { border-color: var(--bad); background: var(--bad-soft); }
.correction { border-radius: 14px; padding: 0.9rem 1rem; }
.correction.is-right { background: var(--ok-soft); }
.correction.is-bad { background: var(--bad-soft); }
.quiz-status { margin-bottom: 0.8rem; font-weight: 800; color: var(--navy); }
.attachments { display: grid; gap: 0.7rem; margin: 0.8rem 0; }
.zoom { border: 0; background: var(--paper); border-radius: 14px; padding: 0.4rem; cursor: zoom-in; text-align: left; }
.zoom img { border-radius: 10px; display: block; max-height: 420px; width: auto; background: white; }
.zoom span, .file-link { font-weight: 800; color: var(--navy); }
#lightbox { border: 0; border-radius: 16px; width: min(960px, 96vw); padding: 1rem; }
#lightbox img { width: 100%; height: auto; }
#lightbox::backdrop { background: rgba(1, 33, 105, 0.72); }

.result-hero {
    border-radius: var(--radius);
    padding: 1.4rem;
    color: white;
    margin-bottom: 1rem;
}
.result-hero.is-pass { background: var(--navy); }
.result-hero.is-fail { background: #3d2a24; }
.result-hero h1 { font-size: clamp(3rem, 8vw, 5rem); }
.result-label { font-size: 1.4rem; font-weight: 800; color: var(--sky); }
.result-figures { display: flex; gap: 1rem; flex-wrap: wrap; padding: 0; list-style: none; }
.result-figures li { background: rgba(255,255,255,0.08); border-radius: 14px; padding: 0.7rem 0.9rem; min-width: 140px; }
.result-figures b { display: block; font-size: 1.4rem; }
.stat-list { display: grid; gap: 0.75rem; }
.stat-row { align-items: center; }
.stat-row div:first-child { min-width: min(100%, 240px); display: grid; }
.stat-row span { color: var(--muted); font-size: 0.92rem; }
.bar { flex: 1; height: 10px; background: var(--paper); border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--navy), var(--sky)); }
.weak-list { display: grid; gap: 0.7rem; padding-left: 1.1rem; }
.weak-list span { display: block; color: var(--muted); }
.contact-card { background: var(--sky-soft); }
.review { padding: 1rem 0; border-top: 1px solid var(--line); }
.review-answers { list-style: none; padding: 0; }
.review-answers li { padding: 0.25rem 0; }
.review-answers .is-right { color: var(--ok); font-weight: 800; }
.review-answers .is-bad { color: var(--bad); font-weight: 800; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--navy); font-size: 0.92rem; }
.admin-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.admin-side { background: var(--navy); color: white; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.admin-side nav { display: grid; gap: 0.25rem; }
.admin-side a { color: white; text-decoration: none; font-weight: 700; padding: 0.45rem 0.5rem; border-radius: 10px; }
.admin-side a.is-active, .admin-side a:hover { background: rgba(141, 200, 232, 0.18); }
.side-back { margin-top: auto; }
.admin-main { padding: 1rem 1.1rem 2rem; }
.admin-top { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.pager { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.8rem; }
.pager a { min-width: 2rem; text-align: center; border-radius: 8px; }
.pager a.is-active { background: var(--navy); color: white; }
.report { display: grid; gap: 0.25rem; padding-left: 1.1rem; }
.report.warn { color: #8a4b08; }
.report.bad { color: var(--bad); }
.attachment-row img { width: 120px; border-radius: 10px; }
.simple-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

@media (max-width: 860px) {
    .topbar { flex-wrap: wrap; padding: 0.65rem 0.8rem; gap: 0.55rem; }
    .brand span { white-space: nowrap; }
    .topnav { width: 100%; justify-content: flex-end; }
    .quiz-layout, .admin-shell { grid-template-columns: 1fr; }
    .quiz-map { position: static; }
    .q-map {
        display: flex;
        max-height: none;
        overflow-x: auto;
        padding-bottom: 0.3rem;
    }
    .q-num { flex: 0 0 46px; }
    .admin-side nav { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .topbar { align-items: flex-start; }
    .selection-total { top: 0.4rem; }
}

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