@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    color-scheme: light;
    --ink: #151c34;
    --muted: #667493;
    --line: #d9e1f4;
    --blue: #4b5ff0;
    --blue-dark: #3e64d8;
    --pale: #e8edff;
    --page-bg: #f5f7ff;
    --surface: #ffffff;
    --surface-soft: #f3f5fc;
    --text-secondary: #34415f;
    --text-muted: #647291;
    --text-subtle: #75819d;
    --border-soft: #d9e1f4;
    --border-control: #cbd5ee;
    --track-bg: #e5eaf7;
    --selected-bg: #e9edff;
    --tag-bg: #e9edff;
    --tag-text: #4358c7;
    --score-track: #e5eaf7;
    font-family: 'DM Sans', sans-serif;
    background: var(--page-bg);
    color: var(--ink);
}

:root[data-theme='dark'] {
    color-scheme: dark;
    --ink: #e7ecf7;
    --muted: #a2aec4;
    --line: #303b51;
    --blue: #8297ff;
    --blue-dark: #7188f4;
    --pale: #202a3c;
    --page-bg: #111827;
    --surface: #1a2435;
    --surface-soft: #202b3e;
    --text-secondary: #d3dced;
    --text-muted: #a2aec4;
    --text-subtle: #9aa8bf;
    --border-soft: #354158;
    --border-control: #3a465d;
    --track-bg: #303b50;
    --selected-bg: #263455;
    --tag-bg: #293557;
    --tag-text: #c1ccff;
    --score-track: #303b50;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--page-bg); transition: background-color .2s ease, color .2s ease; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px max(calc((100vw - 1100px) / 2), 28px); background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.logout-form { margin: 0; }
.signout-button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--text-secondary); background: var(--surface); cursor: pointer; font: 600 11px 'DM Sans', sans-serif; white-space: nowrap; }
.signout-button:hover { border-color: var(--border-control); background: var(--surface-soft); }
.signout-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 35%, transparent); outline-offset: 2px; }
.theme-toggle { display: flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 20px; color: var(--text-secondary); background: var(--surface); cursor: pointer; font: 600 11px 'DM Sans', sans-serif; }
.theme-toggle:hover { background: var(--surface-soft); }
.theme-icon { font-size: 15px; line-height: 1; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 360px; text-decoration: none; color: var(--ink); font-family: Manrope, sans-serif; font-size: 17px; font-weight: 800; letter-spacing: -.5px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-logo { display: block; width: 140px; height: auto; }
.brand-logo--dark { display: none; }
:root[data-theme='dark'] .brand-logo--light { display: none; }
:root[data-theme='dark'] .brand-logo--dark { display: block; }
.brand-name { line-height: 1.1; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--blue); font-size: 16px; }
.brand-tagline { margin: 0; color: var(--text-secondary); font: 600 13px 'DM Sans', sans-serif; letter-spacing: 0; line-height: 1.35; }
.topbar-label, .eyebrow, .timer-label { font-size: 10px; font-weight: 700; letter-spacing: 1.3px; color: var(--text-subtle); }
.status-badge { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 20px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.status-dot, .save-dot { width: 7px; height: 7px; border-radius: 50%; background: #f0a746; }
.exam-shell { width: min(850px, calc(100% - 40px)); margin: 48px auto 50px; }
.exam-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 28px; }
.exam-heading > div:first-child { flex: 1 1 auto; min-width: 220px; }
.camera-preview-card { flex: 0 0 190px; width: 190px; padding: 8px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.camera-preview-heading, .camera-preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.camera-preview-heading { margin-bottom: 7px; }
.camera-preview-heading .timer-label { font-size: 8px; }
.camera-local-badge { color: #15815f; font-size: 8px; font-weight: 700; white-space: nowrap; }
.camera-preview-card video { display: block; width: 100%; height: 100px; border-radius: 7px; background: #101827; object-fit: cover; }
.camera-preview-footer { min-height: 23px; padding: 5px 1px 0; }
.camera-preview-footer span { color: var(--muted); font-size: 9px; line-height: 1.35; }
.camera-preview-footer button { padding: 3px 6px; border: 1px solid var(--border-control); border-radius: 5px; color: var(--text-secondary); background: var(--surface); cursor: pointer; font: 600 9px 'DM Sans', sans-serif; white-space: nowrap; }
.eyebrow { margin: 0 0 9px; color: var(--blue); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font: 800 32px/1.2 Manrope, sans-serif; letter-spacing: -1.2px; }
.subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.timer-card { min-width: 133px; padding: 12px 17px; text-align: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.timer-label { display: block; font-size: 9px; letter-spacing: 1px; }
.timer-card strong { display: block; margin-top: 3px; font: 700 24px Manrope, sans-serif; font-variant-numeric: tabular-nums; }
.timer-warning strong { color: #d34b4b; }
.exam-meta { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 28px; padding: 17px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.exam-meta div { display: flex; flex-direction: column; align-items: center; gap: 3px; border-right: 1px solid var(--line); }
.exam-meta div:last-child { border: 0; }
.exam-meta strong { font: 700 15px Manrope, sans-serif; }
.exam-meta span { color: var(--muted); font-size: 11px; }
.progress-row { margin-bottom: 18px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 9px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.progress-track { height: 5px; overflow: hidden; border-radius: 5px; background: var(--track-bg); }
.progress-fill { width: 1.67%; height: 100%; border-radius: inherit; background: var(--blue); transition: width .2s ease; }
.question-card { display: none; padding: 29px 32px 32px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 7px 24px rgb(34 49 83 / 3%); }
.question-card.is-active { display: block; }
.question-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.question-number { color: var(--text-subtle); font-size: 10px; font-weight: 700; letter-spacing: 1.15px; }
.topic-tag { padding: 6px 10px; border-radius: 20px; color: var(--tag-text); background: var(--tag-bg); font-size: 10px; font-weight: 600; }
.question-prompt { max-width: 720px; margin-bottom: 23px; font: 700 19px/1.5 Manrope, sans-serif; letter-spacing: -.25px; }
.options-list { display: grid; gap: 10px; }
.option-row { display: flex; align-items: center; gap: 13px; min-height: 55px; padding: 11px 14px; border: 1px solid var(--border-soft); border-radius: 9px; cursor: pointer; transition: border-color .15s, background .15s; }
.option-row:hover { border-color: var(--blue); background: var(--surface-soft); }
.option-row:has(input:checked) { border-color: var(--blue); background: var(--selected-bg); }
.option-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.option-row input:focus-visible + .option-letter { outline: 3px solid #bac6ff; }
.option-letter { display: grid; flex: 0 0 27px; width: 27px; height: 27px; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: var(--text-muted); background: var(--surface); font-size: 11px; font-weight: 700; }
.option-row:has(input:checked) .option-letter { border-color: var(--blue); color: #fff; background: var(--blue); }
.option-text { color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.navigation-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.navigation-center { flex: 1; text-align: center; }
.save-indicator { display: inline-flex; align-items: center; gap: 7px; color: var(--text-subtle); font-size: 11px; }
.save-dot { width: 6px; height: 6px; background: #41b987; }
.button { min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font: 600 12px 'DM Sans', sans-serif; transition: background .15s, border .15s; }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button-secondary { border-color: var(--border-control); color: var(--text-secondary); background: var(--surface); }
.button-secondary:hover:not(:disabled) { background: var(--surface-soft); }
.button-primary { color: #fff; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-submit { color: #fff; background: #15956d; }
.button-submit:hover { background: #107a59; }
.exam-note { margin: 16px 0 0; color: var(--text-subtle); text-align: center; font-size: 11px; }
.site-footer { padding: 28px 22px 36px; color: var(--ink); text-align: center; font-size: 16px; line-height: 1.6; }
.site-footer span { padding: 0 6px; }
.footer-support { margin: 10px 0 0; color: var(--text-secondary); font-size: 18px; }
.site-footer a { color: var(--blue); font-size: 18px; font-weight: 700; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.result-shell { width: min(540px, calc(100% - 36px)); margin: 74px auto 60px; text-align: center; }
.result-icon { width: 62px; height: 62px; display: grid; place-items: center; margin: 0 auto 23px; border-radius: 50%; font: 700 30px Manrope, sans-serif; }
.result-success { color: #11835e; background: #e8f7f0; }
.result-failure { color: #c44e4e; background: #fff0ef; }
.result-shell h1 { margin-bottom: 9px; }
.result-status { margin-bottom: 28px; color: var(--muted); font-size: 14px; }
.score-panel { padding: 24px 27px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); text-align: left; }
.score-main { margin-bottom: 16px; text-align: center; }
.score-main strong { font: 800 42px Manrope, sans-serif; letter-spacing: -2px; }
.score-main span { color: var(--muted); font-size: 13px; }
.score-bar { height: 8px; overflow: hidden; border-radius: 8px; background: var(--score-track); }
.score-bar-fill { height: 100%; border-radius: inherit; background: var(--blue); }
.score-details { display: flex; justify-content: space-between; margin-top: 11px; color: var(--muted); font-size: 11px; }
.score-details strong { color: var(--text-secondary); }
.result-stats { display: grid; grid-template-columns: repeat(2, 1fr); margin-top: 16px; padding: 17px 0; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.result-stats div { display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); }
.result-stats div:last-child { border: 0; }
.certificate-download { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin: 20px auto 0; padding: 0 20px; border-radius: 8px; color: #fff; background: var(--blue); font-size: 13px; font-weight: 700; text-decoration: none; }
.certificate-download:hover { background: var(--blue-dark); }
.result-stats strong { font: 700 14px Manrope, sans-serif; }
.result-stats span { color: var(--muted); font-size: 10px; }
.final-note, .timeout-note { margin: 20px 10px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.timeout-note { color: #b4782d; }

:root[data-theme='dark'] .result-success { color: #75d6b1; background: #173a32; }
:root[data-theme='dark'] .result-failure { color: #ff9a94; background: #452b35; }
:root[data-theme='dark'] .timeout-note { color: #e6b96f; }

.exam-shell { width: min(1440px, calc(100% - 48px)); margin-top: 32px; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.exam-side { position: sticky; top: 18px; display: grid; gap: 14px; }
.exam-side .timer-card { width: 100%; padding: 18px 16px; }
.exam-side .timer-card strong { font-size: 32px; }
.exam-side .camera-preview-card { width: 100%; padding: 12px; }
.exam-side .camera-preview-card video { height: 168px; }
.exam-heading { margin-bottom: 22px; }
.exam-heading h1 { font-size: 30px; }
.exam-meta { margin-bottom: 22px; }
.progress-row { margin-bottom: 12px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.progress-copy { margin-bottom: 10px; }
.question-card { min-height: 360px; padding: 25px 30px 32px; }
.question-topline { margin-bottom: 30px; }
.question-context { display: flex; align-items: center; gap: 12px; }
.question-number { color: var(--ink); font-size: 12px; letter-spacing: .5px; }
.review-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid transparent; border-radius: 7px; color: var(--text-muted); background: transparent; cursor: pointer; font: 500 12px 'DM Sans', sans-serif; }
.review-toggle:hover, .review-toggle.is-marked { border-color: var(--border-control); color: var(--blue); background: var(--surface-soft); }
.review-checkbox { width: 15px; height: 15px; border: 1px solid #aeb8c9; border-radius: 3px; background: var(--surface); }
.review-toggle.is-marked .review-checkbox { border-color: var(--blue); background: var(--blue); box-shadow: inset 0 0 0 3px var(--surface); }
.question-prompt { display: flex; align-items: flex-start; gap: 12px; max-width: 1050px; margin-bottom: 30px; font-size: 19px; line-height: 1.55; }
.prompt-number { flex: 0 0 auto; color: var(--blue); }
.options-list { max-width: 1120px; gap: 9px; }
.option-row { min-height: 53px; }
.option-letter { flex-basis: 29px; width: 29px; height: 29px; font-size: 12px; }
.exam-navigation { display: grid; grid-template-columns: auto minmax(180px, 1fr) auto; align-items: center; gap: 14px; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.navigation-actions { display: flex; gap: 8px; }
.exam-end-actions { display: flex; gap: 8px; }
.question-nav { display: flex; justify-content: center; gap: 5px; min-width: 0; overflow: hidden; padding: 3px 2px 6px; }
.question-nav-item { position: relative; flex: 0 0 34px; width: 34px; height: 34px; border: 1px solid var(--border-control); border-radius: 50%; color: var(--text-muted); background: var(--surface); cursor: pointer; font: 600 11px 'DM Sans', sans-serif; }
.question-nav-item[hidden] { display: none; }
.question-nav-item:hover { border-color: var(--blue); color: var(--blue); }
.question-nav-item.is-answered { border-color: #178f69; color: #fff; background: #178f69; }
.question-nav-item.is-current { outline: 2px solid var(--ink); outline-offset: 2px; }
.question-nav-item.is-review::after { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: #f0a746; content: ''; }
.button-submit { white-space: nowrap; }
.button-review { border-color: var(--border-control); color: var(--text-secondary); background: var(--surface); }
.button-review:hover { background: var(--surface-soft); }
.exam-footer-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 4px 0; }
.exam-footer-row .exam-note { margin: 0; text-align: right; }
.review-count { color: var(--text-subtle); font-size: 11px; }

:root[data-theme='dark'] .question-nav-item.is-answered { border-color: #1b9b74; background: #1b9b74; }
:root[data-theme='dark'] .question-nav-item.is-current { outline-color: #e7ecf7; }

.review-dialog { width: min(680px, calc(100% - 32px)); max-height: min(80vh, 680px); padding: 25px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgb(0 0 0 / 24%); }
.review-dialog::backdrop { background: rgb(12 18 31 / 55%); backdrop-filter: blur(3px); }
.review-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.review-dialog-header .eyebrow { margin-bottom: 6px; }
.review-dialog-header h2 { margin: 0 0 6px; font: 700 22px Manrope, sans-serif; }
.review-summary { margin: 0; color: var(--muted); font-size: 12px; }
.dialog-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; color: var(--text-muted); background: var(--surface); cursor: pointer; font-size: 22px; line-height: 1; }
.review-legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 23px 0 15px; color: var(--text-muted); font-size: 11px; }
.review-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: #d7dce5; }
.legend-answered { background: #178f69; }
.legend-marked { background: #f0a746; }
.review-question-grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 9px; max-height: 40vh; overflow-y: auto; padding: 4px; }
.review-question-item { position: relative; aspect-ratio: 1; border: 1px solid var(--border-control); border-radius: 9px; color: var(--text-muted); background: var(--surface); cursor: pointer; font: 600 12px 'DM Sans', sans-serif; }
.review-question-item:hover { border-color: var(--blue); }
.review-question-item.is-answered { border-color: #178f69; color: #fff; background: #178f69; }
.review-question-item.is-current { outline: 2px solid var(--ink); outline-offset: 2px; }
.review-question-item.is-review::after { position: absolute; top: -4px; right: -4px; width: 11px; height: 11px; border: 2px solid var(--surface); border-radius: 50%; background: #f0a746; content: ''; }
.review-dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

.submit-dialog { width: min(460px, calc(100% - 32px)); padding: 0; overflow: visible; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgb(0 0 0 / 28%); }
.submit-dialog::backdrop { background: rgb(12 18 31 / 48%); backdrop-filter: blur(3px); }
.submit-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 22px 23px 17px; border-bottom: 1px solid var(--line); cursor: move; cursor: grab; touch-action: none; user-select: none; }
.submit-dialog-header:active { cursor: grabbing; }
.submit-dialog-heading { display: flex; align-items: center; gap: 13px; }
.submit-dialog-icon { display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; border: 1px solid #f4d493; border-radius: 11px; color: #a56a11; background: #fff7e8; font: 800 20px Manrope, sans-serif; }
.submit-dialog-header .eyebrow { margin-bottom: 4px; }
.submit-dialog-header h2 { margin: 0; font: 700 19px Manrope, sans-serif; }
.submit-dialog-message { margin: 0; padding: 20px 24px 22px; color: var(--text-secondary); font-size: 13px; line-height: 1.65; }
.submit-dialog-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-soft); border-radius: 0 0 16px 16px; }
:root[data-theme='dark'] .submit-dialog-icon { border-color: #675331; color: #f0c775; background: #3a3020; }

@media (max-width: 980px) {
    .exam-layout { grid-template-columns: 1fr; }
    .exam-side { position: static; grid-template-columns: minmax(140px, 180px) minmax(0, 1fr); align-items: start; }
    .exam-side .camera-preview-card video { height: 120px; }
}
@media (max-width: 620px) {
    .topbar { min-height: 62px; padding: 10px 18px; }
    .brand { max-width: 240px; }
    .brand-tagline { font-size: 12px; }
    .topbar-label { display: none; }
    .status-badge { padding: 7px 9px; font-size: 10px; }
    .status-badge { font-size: 0; padding: 7px; }
    .topbar-actions { gap: 7px; }
    .theme-toggle { min-height: 32px; padding: 0 9px; }
    .exam-shell { width: calc(100% - 28px); margin-top: 25px; }
    .exam-layout { grid-template-columns: 1fr; }
    .exam-side { position: static; grid-template-columns: 1fr; }
    .exam-heading { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
    .exam-heading > div:first-child { min-width: 0; }
    .camera-preview-card { flex-basis: 100%; width: 100%; }
    .camera-preview-card video { height: 150px; }
    h1 { font-size: 27px; }
    .subtitle { max-width: 260px; font-size: 12px; line-height: 1.5; }
    .timer-card { min-width: 100px; padding: 10px; }
    .timer-card strong { font-size: 20px; }
    .exam-meta { grid-template-columns: repeat(3, 1fr); row-gap: 8px; padding: 12px 0; }
    .exam-meta div { padding: 0 5px; border-right: 1px solid var(--line); }
    .exam-meta div:last-child { border: 0; }
    .exam-meta strong { font-size: 13px; }
    .exam-meta span { font-size: 9px; text-align: center; }
    .question-card { min-height: 330px; padding: 19px 15px; }
    .question-topline { align-items: flex-start; gap: 8px; margin-bottom: 23px; }
    .question-context { align-items: flex-start; flex-direction: column; gap: 8px; }
    .review-toggle { gap: 6px; padding: 6px; font-size: 10px; white-space: nowrap; }
    .question-prompt { gap: 8px; margin-bottom: 22px; font-size: 16px; }
    .question-prompt { font-size: 17px; }
    .option-row { gap: 10px; padding: 10px; }
    .option-text { font-size: 12px; }
    .exam-navigation { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 9px; }
    .navigation-actions { grid-column: 1 / -1; justify-content: space-between; }
    .question-nav { grid-column: 1 / -1; grid-row: 2; }
    .question-nav-item { flex-basis: 32px; width: 32px; height: 32px; }
    .exam-navigation .button { min-height: 39px; padding: 0 11px; font-size: 11px; }
    .exam-end-actions { grid-column: 1 / -1; grid-row: 3; justify-content: flex-end; }
    .review-question-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
    .review-dialog { padding: 20px 16px; }
    .review-dialog-footer { align-items: flex-start; flex-direction: column; }
    .submit-dialog-header { padding: 18px 17px 14px; }
    .submit-dialog-message { padding: 17px; }
    .submit-dialog-footer { padding: 12px; }
    .exam-footer-row { align-items: flex-start; flex-direction: column; gap: 6px; }
    .exam-footer-row .exam-note { text-align: left; }
    .result-shell { margin-top: 48px; }
    .score-panel { padding: 20px 17px; }
    .score-details { gap: 10px; font-size: 10px; }
}
