/* Vatan — talabalar portali */

:root {
    --navy-950: #001a33;
    --navy: #00315e;
    --navy-700: #0b4378;
    --navy-500: #3a6a99;
    --navy-100: #e6edf4;
    --gold: #dfb77e;
    --gold-600: #c99a55;
    --gold-700: #9c7236;
    --gold-100: #f8efe1;
    --gold-50: #fcf8f1;
    --green: #2f8f6b;
    --green-100: #e3f3ec;
    --red: #c8473f;
    --red-100: #fbe8e6;
    --ink: #14243a;
    --ink-2: #4a5a70;
    --ink-3: #8592a6;
    --line: #e7e2d8;
    --bg: #f6f3ee;
    --surface: #fff;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 1px 2px rgba(0, 49, 94, .06), 0 10px 30px rgba(0, 49, 94, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
[hidden] { display: none !important; }

body {
    min-height: 100vh;
    font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background:
        radial-gradient(80% 50% at 100% 0%, rgba(223, 183, 126, .18) 0%, transparent 60%),
        radial-gradient(60% 40% at 0% 100%, rgba(58, 106, 153, .10) 0%, transparent 70%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
}

.icon { flex-shrink: 0; }
.muted { color: var(--ink-3); }

/* ---------- Header ---------- */

.s-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px max(16px, calc((100% - 1100px) / 2));
    background: rgba(0, 49, 94, .96);
    backdrop-filter: blur(10px);
    color: #fff;
}

.s-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.s-brand img { width: 32px; height: auto; }
.s-brand strong { display: block; font-size: 15px; line-height: 1.2; }
.s-brand small { display: block; color: rgba(255, 255, 255, .6); font-size: 12px; }

.s-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.s-user-text { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; line-height: 1.25; }
.s-user-text strong { max-width: 220px; overflow: hidden; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.s-user-text small { color: rgba(255, 255, 255, .6); font-size: 12px; }

.s-logout {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 11px;
    background: rgba(255, 255, 255, .06);
    color: #fff;
    cursor: pointer;
}

.s-logout:hover { background: rgba(255, 255, 255, .14); }

.s-main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 28px 16px 64px; }
.s-main--narrow { max-width: 480px; }

/* ---------- Cards, flash, steps ---------- */

.s-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.s-card-body { padding: 24px; }

.s-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 22px; text-align: center; }
.s-hero img { width: 68px; height: auto; filter: drop-shadow(0 10px 22px rgba(0, 49, 94, .25)); }
.s-hero h1 { color: var(--navy); font-size: 24px; font-weight: 800; line-height: 1.2; }
.s-hero p { max-width: 360px; color: var(--ink-2); font-size: 14.5px; }

.s-flash { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; }
.s-flash--success { border: 1px solid #bfe3d4; background: var(--green-100); color: var(--green); }
.s-flash--error { border: 1px solid #f1c4c0; background: var(--red-100); color: var(--red); }

.s-steps { display: flex; gap: 6px; margin-bottom: 18px; }
.s-step { display: flex; flex: 1; align-items: center; gap: 8px; color: var(--ink-3); font-size: 12.5px; font-weight: 700; }
.s-step::before {
    content: attr(data-n);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--navy-100);
    color: var(--navy);
    font-size: 12px;
}

.s-step.is-done::before { content: "✓"; background: var(--green); color: #fff; }
.s-step.is-active { color: var(--navy); }
.s-step.is-active::before { background: var(--navy); color: var(--gold); }

/* ---------- Forms ---------- */

.s-form { display: flex; flex-direction: column; gap: 18px; }
.s-field { display: flex; flex-direction: column; gap: 8px; }
.s-label { color: var(--ink-2); font-size: 13px; font-weight: 800; }
.s-hint { color: var(--ink-3); font-size: 12.5px; }
.s-error { color: var(--red); font-size: 13px; font-weight: 600; }

.s-input, .phone-field {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 0 16px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}

.s-input:focus-within, .phone-field:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(223, 183, 126, .25); }
.s-input.has-error, .phone-field.has-error { border-color: var(--red); }

.s-input input, .phone-field input {
    flex: 1;
    min-width: 0;
    height: 52px;
    border: 0;
    outline: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 17px;
    font-weight: 600;
}

.s-input .icon { color: var(--ink-3); }

.phone-field { padding-left: 12px; }
.phone-prefix { display: flex; align-items: center; gap: 8px; padding-right: 12px; border-right: 1.5px solid var(--line); color: var(--navy); font-size: 17px; font-weight: 800; }
.phone-prefix svg { width: 30px; height: 15px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); }
.phone-field input { letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.phone-state { color: var(--ink-3); }
.phone-state.is-ok { color: var(--green); }

.pw-toggle { padding: 6px; border: 0; background: none; color: var(--ink-3); cursor: pointer; }
.pw-toggle:hover { color: var(--navy); }

.mode-note { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--gold-50); color: var(--gold-700); font-size: 13.5px; font-weight: 700; }
.mode-note--login { background: var(--navy-100); color: var(--navy); }

.s-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 0 22px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--navy);
    color: #fff;
    font-weight: 800;
    font-size: 15.5px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0, 49, 94, .22);
    transition: background .15s, transform .1s, opacity .15s;
}

.s-btn:hover { background: var(--navy-700); }
.s-btn:active { transform: translateY(1px); }
.s-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.s-btn--block { width: 100%; }
.s-btn--gold { background: var(--gold); color: var(--navy); box-shadow: 0 10px 24px rgba(223, 183, 126, .35); }
.s-btn--gold:hover { background: var(--gold-600); }
.s-btn--ghost { border: 1.5px solid var(--line); background: var(--surface); color: var(--navy); box-shadow: none; }
.s-btn--ghost:hover { border-color: var(--gold); background: var(--gold-50); }
.s-btn--sm { min-height: 42px; padding: 0 16px; font-size: 14px; }

/* Kurs tanlash */

.course-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.course-option input { position: absolute; opacity: 0; pointer-events: none; }

.course-option span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--navy);
    font-weight: 800;
    cursor: pointer;
    transition: all .15s;
}

.course-option span:hover { border-color: var(--gold); }
.course-option input:checked + span { border-color: var(--navy); background: var(--navy); color: #fff; box-shadow: 0 8px 18px rgba(0, 49, 94, .2); }
.course-option input:focus-visible + span { box-shadow: 0 0 0 4px rgba(223, 183, 126, .35); }

.lookup { display: flex; gap: 12px; padding: 14px; border: 1.5px dashed var(--line); border-radius: var(--radius-sm); color: var(--ink-3); font-size: 14px; }
.lookup.is-loading { border-style: solid; }
.lookup.is-found { border: 1.5px solid #bfe3d4; background: var(--green-100); color: var(--ink); }
.lookup.is-error { border: 1.5px solid #f1c4c0; background: var(--red-100); color: var(--red); font-weight: 600; }
.lookup-avatar { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; background: var(--green); color: #fff; font-weight: 800; }
.lookup-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.lookup-body strong { color: var(--navy); }
.lookup-body small { color: var(--ink-2); font-size: 13px; }

.spinner { width: 18px; height: 18px; border: 2.5px solid var(--navy-100); border-top-color: var(--navy); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Testlar ro'yxati ---------- */

.s-welcome {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    padding: 22px 24px;
    border-radius: var(--radius);
    background: radial-gradient(70% 140% at 100% 0%, rgba(223, 183, 126, .35) 0%, transparent 60%), linear-gradient(120deg, var(--navy) 0%, var(--navy-700) 100%);
    color: #fff;
    box-shadow: var(--shadow);
}

.s-welcome h1 { font-size: 22px; font-weight: 800; }
.s-welcome p { color: rgba(255, 255, 255, .75); font-size: 14px; }
.s-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.s-tag { padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .12); font-size: 12.5px; font-weight: 700; }

.s-section-title { margin: 6px 0 12px; color: var(--navy); font-size: 17px; font-weight: 800; }

.test-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; margin-bottom: 28px; }

.test-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.test-card h3 { color: var(--navy); font-size: 17px; font-weight: 800; line-height: 1.3; }
.test-card p { color: var(--ink-2); font-size: 14px; }
.test-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.test-meta div { padding: 10px; border-radius: 10px; background: var(--gold-50); text-align: center; }
.test-meta dt { color: var(--ink-3); font-size: 11.5px; font-weight: 700; }
.test-meta dd { margin: 2px 0 0; color: var(--navy); font-size: 15px; font-weight: 800; }
.test-card form { margin-top: auto; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge--gold { background: var(--gold-100); color: var(--gold-700); }
.badge--green { background: var(--green-100); color: var(--green); }

.s-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; text-align: center; }
.s-empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border: 1px dashed var(--gold); border-radius: 50%; background: var(--gold-50); color: var(--gold-700); }
.s-empty strong { color: var(--navy); }
.s-empty p { max-width: 340px; color: var(--ink-3); font-size: 14px; }

.done-list { display: grid; gap: 10px; }
.done-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.done-item:hover { border-color: var(--gold); }
.done-score { display: grid; place-items: center; flex-shrink: 0; width: 52px; height: 52px; border-radius: 14px; background: var(--navy); color: var(--gold); font-weight: 800; }
.done-body { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 1.35; }
.done-body strong { color: var(--navy); }
.done-body small { color: var(--ink-3); font-size: 12.5px; }

/* ---------- Test topshirish ---------- */

body.is-exam { background: var(--bg); }

.exam-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px max(16px, calc((100% - 1180px) / 2));
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(10px);
}

.exam-title { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 1.3; }
.exam-title strong { overflow: hidden; color: var(--navy); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.exam-title small { color: var(--ink-3); font-size: 12.5px; }

.exam-progress { height: 4px; background: var(--navy-100); }
.exam-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-600), var(--gold)); transition: width .3s; }

.timer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--navy);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.timer.is-warning { background: var(--gold); color: var(--navy); }
.timer.is-danger { background: var(--red); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .75; } }

.save-state { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.save-state.is-ok { color: var(--green); }
.save-state.is-error { color: var(--red); }

.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 20px; max-width: 1180px; margin: 0 auto; padding: 20px 16px 120px; }

.q-panel { display: flex; flex-direction: column; gap: 16px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.q-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.q-index { color: var(--ink-3); font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.q-index b { color: var(--navy); font-size: 20px; }

.q-passage { max-height: 40vh; overflow-y: auto; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--gold-50); color: var(--ink-2); font-size: 14.5px; line-height: 1.7; }
.q-body { color: var(--ink); font-size: 17px; line-height: 1.7; }
.q-image { display: block; max-width: 100%; max-height: 300px; margin: 0 auto; }

.math { white-space: pre-line; overflow-wrap: anywhere; }
.math .katex { font-size: 1.1em; white-space: nowrap; }
.math .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

.opts { display: grid; gap: 10px; }

.opt {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 58px;
    padding: 10px 14px 10px 10px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 16px;
    text-align: left;
    cursor: pointer;
    transition: border-color .12s, background .12s, transform .08s;
}

.opt:hover { border-color: var(--gold); background: var(--gold-50); }
.opt:active { transform: scale(.995); }
.opt:focus-visible { outline: 0; box-shadow: 0 0 0 4px rgba(223, 183, 126, .35); }
.opt-letter { display: grid; place-items: center; flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px; background: var(--navy-100); color: var(--navy); font-weight: 800; }
.opt-text { flex: 1; min-width: 0; }
.opt[aria-checked="true"] { border-color: var(--navy); background: var(--navy-100); box-shadow: inset 0 0 0 1px var(--navy); }
.opt[aria-checked="true"] .opt-letter { background: var(--navy); color: var(--gold); }

.q-nav-buttons { display: flex; justify-content: space-between; gap: 10px; padding-top: 6px; }

.exam-side { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.side-head { display: flex; align-items: center; justify-content: space-between; color: var(--navy); font-weight: 800; }
.side-head small { color: var(--ink-3); font-size: 12.5px; font-weight: 700; }

.nav-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }

.nav-cell {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border: 1.5px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.nav-cell:hover { border-color: var(--gold); }
.nav-cell.is-answered { border-color: var(--navy); background: var(--navy); color: #fff; }
.nav-cell.is-current { box-shadow: 0 0 0 3px var(--gold); }

.legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--ink-3); font-size: 12px; font-weight: 700; }
.legend i { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -2px; border: 1.5px solid var(--line); border-radius: 4px; }
.legend i.is-answered { border-color: var(--navy); background: var(--navy); }

.nav-toggle { display: none; }

/* Modal */

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(0, 26, 51, .5); }
.modal-card { width: 100%; max-width: 420px; padding: 24px; border-radius: var(--radius); background: var(--surface); box-shadow: 0 30px 60px rgba(0, 0, 0, .25); text-align: center; }
.modal-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: var(--gold-100); color: var(--gold-700); }
.modal-card h2 { color: var(--navy); font-size: 20px; font-weight: 800; }
.modal-card p { margin-top: 8px; color: var(--ink-2); }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

/* ---------- Natija ---------- */

.result { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 32px 24px; text-align: center; }

.ring {
    --p: 0;
    display: grid;
    place-items: center;
    width: 168px;
    height: 168px;
    border-radius: 50%;
    background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--navy-100) 0);
}

.ring-inner { display: grid; place-items: center; width: 136px; height: 136px; border-radius: 50%; background: var(--surface); }
.ring-inner strong { display: block; color: var(--navy); font-size: 36px; font-weight: 800; line-height: 1; }
.ring-inner small { color: var(--ink-3); font-size: 13px; font-weight: 700; }

.result h1 { color: var(--navy); font-size: 22px; font-weight: 800; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin: 0; }
.result-stats div { padding: 12px; border-radius: var(--radius-sm); background: var(--gold-50); }
.result-stats dt { color: var(--ink-3); font-size: 12px; font-weight: 700; }
.result-stats dd { margin: 4px 0 0; color: var(--navy); font-size: 18px; font-weight: 800; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .exam-layout { grid-template-columns: 1fr; padding-bottom: 140px; }

    .exam-side {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 40;
        max-height: 70vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        transform: translateY(105%);
        transition: transform .25s ease;
    }

    .exam-side.is-open { transform: none; }
    .nav-toggle { display: inline-flex; }
    .nav-grid { grid-template-columns: repeat(8, 1fr); }

    .mobile-dock {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 35;
        display: flex;
        gap: 8px;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: rgba(255, 255, 255, .96);
        backdrop-filter: blur(10px);
    }

    .mobile-dock .s-btn { flex: 1; min-height: 48px; padding: 0 12px; }
}

@media (min-width: 901px) {
    .mobile-dock { display: none; }
}

@media (max-width: 600px) {
    .s-main { padding-top: 20px; }
    .s-card-body { padding: 20px; }
    .s-user-text { display: none; }
    .q-panel { padding: 18px; }
    .q-body { font-size: 16px; }
    .opt { font-size: 15px; }
    .exam-bar .save-state span { display: none; }
    .nav-grid { grid-template-columns: repeat(6, 1fr); }
    .s-steps .s-step span { display: none; }
}

/* ---------- Test sahifasi: qulaylik va himoya ---------- */

:root { --q-scale: 1; }

body.is-exam { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.is-exam img { -webkit-user-drag: none; pointer-events: none; }

.watermark {
    position: fixed;
    inset: -60px;
    z-index: 25;
    background-repeat: repeat;
    opacity: .075;
    pointer-events: none;
    mix-blend-mode: multiply;
}

@media print {
    body.is-exam > *:not(.watermark) { display: none !important; }
    body.is-exam::after { content: "Test sahifasini chop etish taqiqlangan."; display: block; padding: 40px; font-size: 20px; }
}

.exam-tools { display: flex; align-items: center; gap: 10px; }

.font-tools { display: inline-flex; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.font-tools .tool-btn { border: 0; border-radius: 0; }
.font-tools .tool-btn + .tool-btn { border-left: 1px solid var(--line); }

.tool-btn {
    display: inline-grid;
    place-items: center;
    min-width: 38px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--navy);
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
}

.tool-btn:hover { background: var(--gold-50); }

.spinner--sm { width: 14px; height: 14px; border-width: 2px; }

.offline-banner {
    position: sticky;
    top: 61px;
    z-index: 29;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--red);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    text-align: center;
}

.q-panel { position: relative; }
.q-body { font-size: calc(17px * var(--q-scale)); }
.opt { font-size: calc(16px * var(--q-scale)); }
.q-passage { font-size: calc(14.5px * var(--q-scale)); }

.flag-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
}

.flag-btn:hover { border-color: var(--gold); }
.flag-btn[aria-pressed="true"] { border-color: var(--gold-600); background: var(--gold-100); color: var(--gold-700); }

.q-passage-box { border-radius: var(--radius-sm); background: var(--gold-50); }
.q-passage-box summary { padding: 10px 16px 0; color: var(--gold-700); font-size: 12.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; }
.q-passage-box .q-passage { background: none; }

.opts--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.q-nav-buttons { align-items: center; }
.q-skip { margin: 0 auto; }

.side-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; }
.side-stats div { padding: 8px 6px; border-radius: 10px; background: var(--gold-50); text-align: center; }
.side-stats dt { color: var(--ink-3); font-size: 11px; font-weight: 700; }
.side-stats dd { margin: 2px 0 0; color: var(--navy); font-size: 17px; font-weight: 800; }

.nav-cell { position: relative; }
.nav-cell.is-flagged::after {
    content: "";
    position: absolute;
    top: -4px;
    right: -4px;
    width: 11px;
    height: 11px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--gold-600);
}

.legend i.is-flagged { border-color: var(--gold-600); border-radius: 50%; background: var(--gold-600); }
.side-hint { font-size: 12px; line-height: 1.5; }
.side-close { display: none; }
.side-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(0, 26, 51, .4); }

.toast {
    position: fixed;
    left: 50%;
    bottom: 90px;
    z-index: 70;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 12px;
    background: var(--navy);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .2);
    transform: translateX(-50%);
    animation: toast-in .25s ease;
}

.toast--warn { background: var(--gold); color: var(--navy); }
.toast--danger { background: var(--red); }
.toast--ok { background: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (min-width: 901px) {
    .side-backdrop { display: none; }
    .toast { bottom: 28px; }
}

@media (max-width: 900px) {
    .side-close { display: inline-grid; }
    .exam-side { z-index: 41; }
    .offline-banner { top: 57px; }
}

@media (max-width: 600px) {
    .opts--grid { grid-template-columns: 1fr; }
    .font-tools { display: none; }
    .exam-tools { gap: 6px; }
    .q-skip { display: none; }
    .exam-title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
