/* ═══════════════════════════════════════════════════════════════════
   ITI EXAM PORTAL — Corporate Blue + Orange Accent Theme
   Clean exam UI · pastel option chips · square number palette
═══════════════════════════════════════════════════════════════════ */

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

:root {
    /* Brand — corporate blue + orange */
    --primary:        #2451d1;
    --primary-dark:   #1e40af;
    --primary-light:  #3b6cf5;
    --primary-deep:   #1e3a8a;
    --primary-soft:   #e6edff;
    --primary-soft2:  #d1ddff;
    --primary-border: #b9caff;

    --orange:        #f97316;
    --orange-dark:   #ea580c;
    --orange-light:  #fb923c;
    --orange-soft:   #fff1e6;

    /* Neutrals */
    --bg:        #f4f6fb;
    --paper:     #ffffff;
    --panel:     #f8fafc;
    --ink:       #1e293b;
    --ink-2:     #334155;
    --muted:     #64748b;
    --muted-2:   #94a3b8;
    --border:    #e2e8f0;
    --border-2:  #eef1f6;

    /* Option chip pastels (cycle A→B→C→D) */
    --opt-a:        #2563eb;
    --opt-a-bg:     #dbeafe;
    --opt-b:        #a855f7;
    --opt-b-bg:     #f3e8ff;
    --opt-c:        #16a34a;
    --opt-c-bg:     #dcfce7;
    --opt-d:        #f97316;
    --opt-d-bg:     #ffedd5;

    /* Palette state colors */
    --st-answered: #10b981;
    --st-answered-bg: #d1fae5;
    --st-review:   #f59e0b;
    --st-review-bg: #fef3c7;
    --st-not-ans:  #ef4444;
    --st-not-ans-bg: #fee2e2;
    --st-not-vis-bg: #f1f5f9;
    --st-not-vis-bd: #cbd5e1;

    /* Semantic */
    --success:      #10b981;
    --success-soft: #d1fae5;
    --danger:       #ef4444;
    --danger-soft:  #fee2e2;
    --warn:         #f59e0b;
    --warn-soft:    #fef3c7;

    --radius:    14px;
    --radius-sm: 10px;
    --radius-lg: 20px;

    --shadow-1: 0 1px 3px rgba(15,23,42,0.05), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-2: 0 4px 14px rgba(15,23,42,0.08);
    --shadow-lg: 0 20px 48px rgba(15,23,42,0.18);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg); color: var(--ink);
    -webkit-user-select: none; user-select: none;
    display: flex; flex-direction: column; min-height: 100vh;
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }

/* ═════════════ LANGUAGE MODAL ═════════════ */
.lang-modal-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: linear-gradient(160deg, var(--primary-deep) 0%, var(--primary) 60%, var(--primary-light) 100%);
    display: none; align-items: center; justify-content: center;
    padding: 20px; overflow-y: auto;
}
.lang-modal-overlay.active { display: flex; }
.lang-modal {
    background: var(--paper); border-radius: 24px;
    padding: 36px 32px 28px;
    width: 100%; max-width: 680px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.42s cubic-bezier(0.16,1,0.3,1);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(28px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.lang-modal-top { text-align: center; margin-bottom: 28px; }
.lang-modal-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.lang-modal-title { font-size: 1.65rem; font-weight: 800; color: var(--ink); letter-spacing: -0.025em; margin-bottom: 8px; }
.lang-modal-sub { font-size: 0.85rem; color: var(--muted); font-weight: 500; line-height: 1.6; }
.lang-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.lang-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 5px; padding: 14px 8px;
    border: 2px solid var(--border); border-radius: 14px;
    cursor: pointer; background: var(--paper);
    transition: all 0.18s; position: relative; min-height: 78px;
}
.lang-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(37,81,209,0.15); }
.lang-card.active { background: var(--primary); border-color: var(--primary); box-shadow: 0 8px 20px rgba(37,81,209,0.35); }
.lang-card.active .lang-native, .lang-card.active .lang-english { color: #fff; }
.lang-card.active .lang-check { display: flex; }
.lang-native { font-size: 1rem; font-weight: 700; color: var(--ink); line-height: 1.2; text-align: center; }
.lang-english { font-size: 0.66rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.lang-check { display: none; position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; background: rgba(255,255,255,0.28); border-radius: 50%; align-items: center; justify-content: center; }
.lang-check svg { width: 11px; height: 11px; stroke: white; stroke-width: 3; }
.lang-note { text-align: center; font-size: 0.78rem; color: var(--muted); font-weight: 500; }

/* ═════════════ LOGIN ═════════════ */
#loginOverlay {
    position: fixed; inset: 0;
    background: linear-gradient(160deg, var(--primary-deep) 0%, var(--primary) 50%, var(--primary-light) 100%);
    z-index: 5000;
    display: flex; align-items: center; justify-content: center;
    overflow-y: auto; padding: 24px;
}
.login-bg-shape { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.08); animation: floatY 7s ease-in-out infinite; pointer-events: none; }
.login-bg-shape.s1 { width:480px;height:480px;top:-160px;right:-140px; }
.login-bg-shape.s2 { width:340px;height:340px;bottom:-100px;left:-80px;animation-delay:-3s; background: rgba(249,115,22,0.16); }
.login-bg-shape.s3 { width:200px;height:200px;top:48%;left:8%;animation-delay:-5s; background: rgba(255,255,255,0.1); }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }
.login-card {
    background: var(--paper); padding: 44px 32px 28px;
    border-radius: 24px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 460px; text-align: center;
    animation: slideUp 0.5s cubic-bezier(0.16,1,0.3,1) forwards;
    position: relative; z-index: 1;
    overflow: hidden;
}
.login-card-glow {
    position: absolute;
    top: -120px; left: 50%;
    transform: translateX(-50%);
    width: 280px; height: 280px; border-radius: 50%;
    background: radial-gradient(circle, var(--primary-soft) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 20px; position: relative; z-index: 1; }
.login-logo-ring {
    position: relative;
    padding: 8px;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--primary), var(--orange));
    box-shadow: 0 12px 30px rgba(37,81,209,0.35);
}
.login-logo-ring::before {
    content: ''; position: absolute; inset: -10px;
    border-radius: 30px;
    border: 2px dashed var(--primary-border);
    opacity: 0.6;
    animation: rotateRing 18s linear infinite;
}
@keyframes rotateRing { to { transform: rotate(360deg); } }

.login-lang-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: linear-gradient(135deg, var(--primary-soft), var(--orange-soft));
    color: var(--primary); font-size: 0.72rem; font-weight: 700;
    padding: 6px 14px; border-radius: 50px;
    letter-spacing: 0.06em; margin-bottom: 14px; text-transform: uppercase;
    position: relative; z-index: 1;
    border: 1px solid var(--primary-border);
}
.login-lang-badge::before {
    content: '🌐';
    font-size: 0.78rem;
}

.login-card h2 { font-size: 1.75rem; font-weight: 800; color: var(--ink); letter-spacing: -0.03em; margin-bottom: 6px; position: relative; z-index: 1; }
.login-sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 22px; font-weight: 500; position: relative; z-index: 1; }

.login-features {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 10px; margin-bottom: 24px;
    position: relative; z-index: 1;
}
.login-feature {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 10px;
    background: var(--panel);
    border-radius: 12px;
    border: 1px solid var(--border-2);
}
.login-feature-ic {
    width: 32px; height: 32px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.login-feature-tx { display: flex; flex-direction: column; gap: 1px; text-align: left; }
.login-feature-tx b { font-size: 0.82rem; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; line-height: 1; }
.login-feature-tx span { font-size: 0.6rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.input-group { text-align: left; margin-bottom: 18px; position: relative; z-index: 1; }
.input-group label { display: block; font-size: 0.74rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.input-wrap { position: relative; }
.input-icon {
    position: absolute; left: 16px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted-2); pointer-events: none;
    transition: color 0.16s;
}
.input-group input { width: 100%; padding: 14px 18px 14px 46px; border: 2px solid var(--border); border-radius: 12px; font-size: 0.96rem; font-family: inherit; font-weight: 500; outline: none; transition: 0.2s; color: var(--ink); background: var(--paper); }
.input-group input::placeholder { color: var(--muted-2); font-weight: 400; }
.input-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,81,209,0.12); }
.input-group input:focus ~ .input-icon,
.input-wrap:focus-within .input-icon { color: var(--primary); }
.input-shake { animation: shake 0.4s; }
@keyframes shake { 10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(3px); } 30%,50%,70% { transform: translateX(-5px); } 40%,60% { transform: translateX(5px); } }

.login-btn { width: 100%; font-size: 0.98rem; padding: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; font-weight: 700; position: relative; z-index: 1; background: linear-gradient(135deg, var(--primary), var(--primary-light)) !important; box-shadow: 0 8px 22px rgba(37,81,209,0.35) !important; }
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(37,81,209,0.42) !important; }
.btn-change-lang { width: 100%; padding: 11px; background: transparent; border: 2px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: 0.84rem; font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 6px; position: relative; z-index: 1; }
.btn-change-lang:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.login-footer { margin-top: 20px; font-size: 0.74rem; color: var(--muted-2); font-weight: 500; position: relative; z-index: 1; }

/* ═════════════ ALERT ═════════════ */
#customAlert { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.65); backdrop-filter: blur(6px); z-index: 6000; align-items: center; justify-content: center; padding: 16px; }
.alert-box { background: var(--paper); padding: 32px 28px 24px; border-radius: 20px; text-align: center; max-width: 400px; width: 100%; box-shadow: var(--shadow-lg); animation: popIn 0.28s cubic-bezier(0.16,1,0.3,1); }
@keyframes popIn { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.alert-icon { font-size: 1.8rem; margin: 0 auto 12px; width: 56px; height: 56px; background: var(--warn-soft); color: var(--warn); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.alert-box h3 { font-size: 1.2rem; font-weight: 800; color: var(--ink); margin-bottom: 6px; letter-spacing: -0.01em; }
.alert-box p { color: var(--muted); font-size: 0.88rem; line-height: 1.55; }
.alert-actions { display: flex; gap: 10px; margin-top: 22px; }

/* ═════════════ HEADER — Solid blue block ═════════════ */
.header {
    background: var(--primary);
    padding: 14px 18px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 100;
    color: #fff;
    flex-wrap: wrap;
}
.header-left { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.header-center { flex-shrink: 0; }
.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo img { background: #fff; padding: 4px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.header-title-block { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.header-title { font-size: 1.04rem; font-weight: 800; color: #fff; letter-spacing: -0.01em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-sub { font-size: 0.7rem; color: rgba(255,255,255,0.78); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1; }

/* Chip-style buttons in header */
.header-lang-btn, .timer-box, .candidate-chip {
    background: rgba(255,255,255,0.13);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 14px;
    padding: 7px 14px;
    color: #fff; font-weight: 700; font-size: 0.78rem;
    cursor: pointer; transition: all 0.18s;
    font-family: inherit;
    display: flex; align-items: center; gap: 9px;
}
.header-lang-btn:hover { background: rgba(255,255,255,0.22); }
.timer-box {
    cursor: default;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.92rem; font-weight: 800;
    letter-spacing: 0.02em;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px; padding: 5px 14px;
}
.timer-box svg { display: none; }
.timer-box span { font-family: 'JetBrains Mono', monospace; font-size: 1.05rem; font-weight: 800; letter-spacing: 0.02em; line-height: 1.1; }
.timer-box::after { content: 'TIME LEFT'; font-size: 0.55rem; font-weight: 700; letter-spacing: 0.1em; color: rgba(255,255,255,0.75); font-family: 'Inter', sans-serif; line-height: 1; }
.timer-box.warning { background: var(--danger); border-color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.75; } }

.header-lang-btn { flex-direction: column; align-items: flex-start; gap: 1px; padding: 5px 14px; }
.header-lang-icon { font-size: 0.95rem; display: none; }
.header-lang-name { font-size: 0.86rem; font-weight: 800; line-height: 1.1; }
.header-lang-btn::after { content: 'LANGUAGE'; font-size: 0.55rem; font-weight: 700; letter-spacing: 0.1em; color: rgba(255,255,255,0.75); line-height: 1; }

.candidate-chip { padding: 4px 14px 4px 4px; border-radius: 50px; cursor: default; }
.avatar {
    width: 32px; height: 32px;
    background: var(--orange);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.88rem; color: #fff; flex-shrink: 0;
}
.candidate-info { display: flex; flex-direction: column; gap: 1px; }
.candidate-name { font-weight: 800; font-size: 0.84rem; max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; color: #fff; }
.candidate-label { font-size: 0.55rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: rgba(255,255,255,0.75); line-height: 1; }

/* ═════════════ INFO BAR (Module card) ═════════════ */
.info-bar { background: transparent; padding: 14px 14px 0; }
.info-bar-inner {
    display: flex; align-items: center;
    max-width: 1420px; margin: auto;
    background: var(--paper);
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: var(--shadow-1);
    gap: 18px; flex-wrap: wrap;
    position: relative;
}
.info-bar-inner::before {
    content: '📘';
    font-size: 1.1rem;
    margin-right: 4px;
}
.info-item { display: flex; flex-direction: column; gap: 2px; padding: 0; }
.info-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.info-value { font-size: 0.96rem; font-weight: 800; color: var(--orange); letter-spacing: -0.005em; }
.info-item:not(:first-of-type) .info-value { color: var(--ink); }
.info-divider { display: none; }

/* ═════════════ MAIN CONTAINER ═════════════ */
.main-container { display: none; padding: 14px; gap: 16px; max-width: 1420px; margin: auto; width: 100%; flex: 1; flex-direction: column; }
.content-area { flex: 1; min-width: 0; }

/* On desktop, restore side-by-side */
@media (min-width: 961px) {
    .main-container { flex-direction: row; padding: 18px; }
}

/* ═════════════ QUESTION CARD ═════════════ */
.question-card {
    background: var(--paper);
    border-radius: 16px;
    padding: 20px 22px;
    box-shadow: var(--shadow-1);
    animation: cardIn 0.32s cubic-bezier(0.16,1,0.3,1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.q-header {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    margin-bottom: 18px;
}
.q-badge {
    background: var(--primary); color: #fff;
    padding: 6px 14px; border-radius: 10px;
    font-weight: 800; font-size: 0.82rem;
    white-space: nowrap; flex-shrink: 0;
}
/* Progress bar replaced with segmented dots */
.q-progress {
    flex: 1; height: 5px;
    background: transparent;
    border-radius: 50px; overflow: visible;
    display: flex; gap: 4px;
    position: relative;
}
.q-progress-bar {
    height: 5px;
    background: var(--orange);
    border-radius: 50px; transition: width 0.4s ease;
    position: absolute; left: 0; top: 0;
}
.q-counter {
    font-size: 0.8rem; font-weight: 700;
    color: var(--muted); white-space: nowrap;
}

/* Question text */
.q-text {
    font-size: 1.05rem; font-weight: 700; line-height: 1.55;
    color: var(--ink); margin-bottom: 6px;
    -webkit-user-select: text; user-select: text;
    letter-spacing: -0.01em;
    opacity: 0; transform: translateY(4px);
    transition: opacity 0.3s, transform 0.3s;
}
.q-text.translated { opacity: 1; transform: translateY(0); }
.q-text mark { background: var(--warn-soft); color: var(--warn); padding: 1px 6px; border-radius: 5px; font-weight: 800; }
.q-lang-line { display: block; font-size: 0.92rem; font-weight: 500; color: var(--muted); margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.q-translate-loading { display: flex; align-items: center; gap: 10px; color: var(--primary); font-weight: 600; font-size: 0.92rem; }
.translate-spinner { width: 14px; height: 14px; border: 2px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.q-image-container {
    margin: 16px 0;
    border-radius: 14px; overflow: hidden;
    border: 1px solid var(--border); background: var(--panel);
    text-align: center; max-height: 380px;
}
.q-image { max-width: 100%; max-height: 360px; object-fit: contain; padding: 10px; display: block; margin: 0 auto; }

/* ═════════════ OPTIONS — Pastel letter chips ═════════════ */
.options-list { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.option-label {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    background: var(--paper);
    border-radius: 12px;
    cursor: pointer; transition: all 0.16s;
    min-height: 58px;
}
.option-label:nth-child(4n+1) .opt-letter { background: var(--opt-a-bg); color: var(--opt-a); }
.option-label:nth-child(4n+2) .opt-letter { background: var(--opt-b-bg); color: var(--opt-b); }
.option-label:nth-child(4n+3) .opt-letter { background: var(--opt-c-bg); color: var(--opt-c); }
.option-label:nth-child(4n)   .opt-letter { background: var(--opt-d-bg); color: var(--opt-d); }
.option-label:hover { border-color: var(--primary-border); }
.option-label.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.option-label.correct { border-color: var(--success); background: var(--success-soft); }
.option-label.wrong { border-color: var(--danger); background: var(--danger-soft); }
.option-label.loading-opt { opacity: 0.45; pointer-events: none; }
.opt-letter {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.95rem;
    flex-shrink: 0;
}
.opt-text { flex: 1; font-weight: 600; font-size: 0.94rem; color: var(--ink-2); line-height: 1.45; -webkit-user-select: text; user-select: text; }
.opt-text b, .opt-text strong { color: var(--primary); font-weight: 800; }
.opt-icon { flex-shrink: 0; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }
.option-label.correct .opt-icon { color: var(--success); }
.option-label.wrong .opt-icon { color: var(--danger); }

/* Code blocks */
.code-block { background: var(--ink); color: #e2e8f0; border-radius: 10px; margin: 12px 0; position: relative; overflow: hidden; font-family: 'JetBrains Mono', monospace; font-size: 0.86rem; }
.code-lang-badge { position: absolute; top: 8px; right: 12px; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; color: rgba(255,255,255,0.5); text-transform: uppercase; }
.code-pre { padding: 16px 18px; overflow-x: auto; line-height: 1.6; }
.inline-code { background: var(--primary-soft); color: var(--primary); font-family: 'JetBrains Mono', monospace; font-size: 0.86em; padding: 2px 7px; border-radius: 5px; font-weight: 600; }
.sh-tag { color: #f87171; } .sh-attr { color: #fbbf24; } .sh-str { color: #86efac; } .sh-cmt { color: #94a3b8; font-style: italic; }
.sh-prop { color: #93c5fd; } .sh-val { color: #fcd34d; } .sh-sel { color: #f9a8d4; } .sh-num { color: #fbbf24; } .sh-kw { color: #c4b5fd; } .sh-fn { color: #93c5fd; }

/* ═════════════ BUTTONS ═════════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px;
    border-radius: 12px;
    font-weight: 700; font-size: 0.88rem;
    cursor: pointer; transition: all 0.16s;
    border: 1.5px solid transparent;
    font-family: inherit;
}
.btn-primary {
    background: var(--primary); color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37,81,209,0.28);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); }
.btn-outline {
    background: var(--paper);
    border-color: var(--border);
    color: var(--ink-2);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-result {
    background: linear-gradient(90deg, var(--orange), #ef4444);
    color: #fff; flex: 1; justify-content: center;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(249,115,22,0.3);
}
.btn-submit {
    width: 100%;
    background: linear-gradient(90deg, var(--orange) 0%, #ef4444 100%);
    color: #fff; border: none;
    padding: 16px 0;
    font-size: 1rem; font-weight: 800;
    border-radius: 14px; cursor: pointer;
    letter-spacing: 0.04em; transition: 0.16s;
    font-family: inherit;
    box-shadow: 0 6px 18px rgba(249,115,22,0.32);
    text-transform: uppercase;
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(249,115,22,0.42); }

.q-nav {
    display: flex; gap: 10px;
    margin-top: 22px; padding-top: 18px;
    border-top: 1px solid var(--border-2);
    align-items: center;
    justify-content: space-between;
}

/* ═════════════ SIDEBAR (PALETTE) ═════════════ */
.sidebar { width: 300px; flex-shrink: 0; }
.sidebar-card {
    background: var(--paper);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-1);
}
.sidebar-header {
    padding: 14px 18px;
    font-weight: 800; font-size: 0.96rem;
    color: #fff;
    background: var(--primary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-header::after {
    content: '';
    width: 18px; height: 18px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-size: contain; background-repeat: no-repeat;
}

/* Legend on top */
.legend {
    padding: 12px 18px;
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    border-bottom: 1px solid var(--border-2);
}
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.76rem; color: var(--ink-2); font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* Square number palette */
.nav-grid {
    padding: 14px 16px 8px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}
.num-btn {
    aspect-ratio: 1.1 / 1;
    display: flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--border);
    background: var(--paper);
    color: var(--ink-2);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700; font-size: 0.92rem;
    border-radius: 8px;
    cursor: pointer; transition: 0.14s;
}
.num-btn:hover { border-color: var(--primary); color: var(--primary); }
.num-btn.answered { background: var(--st-answered); color: #fff; border-color: var(--st-answered); }
.num-btn.visited { background: var(--st-not-ans); color: #fff; border-color: var(--st-not-ans); }
.num-btn.active { background: var(--st-review); color: #fff; border-color: var(--st-review); box-shadow: 0 3px 8px rgba(245,158,11,0.35); transform: scale(1.04); }

.sidebar-footer { padding: 14px 18px 16px; border-top: 1px solid var(--border-2); }
.sidebar-stats {
    display: flex;
    gap: 18px; margin-bottom: 14px;
    align-items: center;
}
.sidebar-stats::before {
    content: '📋';
    font-size: 2rem;
    flex-shrink: 0;
}
.stat-item { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; }
.stat-num {
    font-size: 1.5rem; font-weight: 800;
    color: var(--ink); line-height: 1;
    font-family: 'JetBrains Mono', monospace;
}
.stat-num.answered-count { color: var(--success); }
.stat-num.unanswered-count { color: var(--danger); }
.stat-label { font-size: 0.65rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ═════════════ FOOTER ═════════════ */
.footer { text-align: center; padding: 18px; font-size: 0.78rem; color: var(--muted); font-weight: 500; }

/* ═════════════ RESULT OVERLAY ═════════════ */
#resultOverlay {
    display: none; position: fixed; inset: 0;
    background: linear-gradient(160deg, var(--primary-deep) 0%, var(--primary) 60%, var(--primary-light) 100%);
    z-index: 7000;
    align-items: center; justify-content: center;
    padding: 20px; overflow-y: auto;
}
.result-modal {
    background: var(--paper); padding: 36px 30px 26px;
    border-radius: 24px; max-width: 480px; width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: popIn 0.4s cubic-bezier(0.16,1,0.3,1);
}
.result-top { margin-bottom: 18px; }
.result-trophy {
    font-size: 2.6rem;
    width: 78px; height: 78px;
    margin: 0 auto 14px;
    background: linear-gradient(135deg, var(--orange), #ef4444);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 24px rgba(249,115,22,0.35);
}
.result-title { font-size: 1.55rem; font-weight: 800; color: var(--ink); letter-spacing: -0.025em; margin-bottom: 12px; }
.status-badge {
    display: inline-block;
    padding: 6px 18px; border-radius: 50px;
    font-size: 0.82rem; font-weight: 800;
    letter-spacing: 0.06em; text-transform: uppercase;
}
.status-badge.pass { background: var(--success); color: #fff; }
.status-badge.fail { background: var(--danger); color: #fff; }
.result-score-ring { position: relative; width: 170px; height: 170px; margin: 22px auto; }
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--primary-soft); stroke-width: 10; }
.ring-fill { fill: none; stroke: var(--primary); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 314; stroke-dashoffset: 314; transition: stroke-dashoffset 1.2s cubic-bezier(0.16,1,0.3,1); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-score { font-size: 2.6rem; font-weight: 800; color: var(--ink); line-height: 1; font-family: 'JetBrains Mono', monospace; letter-spacing: -0.025em; }
.ring-label { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }
.result-table { width: 100%; border-collapse: collapse; margin: 16px 0 20px; background: var(--panel); border-radius: 14px; overflow: hidden; }
.result-table tr { border-bottom: 1px solid var(--border-2); }
.result-table tr:last-child { border-bottom: none; }
.result-table td { padding: 11px 16px; text-align: left; font-size: 0.86rem; }
.rt-label { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.7rem; }
.rt-value { color: var(--ink); font-weight: 700; }
.result-actions { display: flex; gap: 10px; margin-top: 8px; }
.result-actions .btn { flex: 1; }
.res-footer { margin-top: 20px; font-size: 0.72rem; color: var(--muted-2); font-weight: 500; }

/* ═════════════ TOAST ═════════════ */
#customToast {
    position: fixed; bottom: 26px; left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--ink); color: #fff;
    padding: 13px 22px; border-radius: 12px;
    font-size: 0.88rem; font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 9999; opacity: 0;
    transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
    max-width: 90%;
}
#customToast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═════════════ MOBILE STAT STRIP (hidden on desktop) ═════════════ */
.mobile-stat-strip { display: none; }

/* ═════════════ MOBILE FAB + BOTTOM SHEET ═════════════ */
.palette-fab, .mobile-palette-backdrop, .sidebar-close, .sidebar-grab { display: none; }

/* ═════════════ RESPONSIVE ═════════════ */
@media (max-width: 960px) {
    .sidebar { width: 100%; }
    .sidebar-card { position: static; }
    .nav-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 768px) {
    .header {
        padding: 12px 14px 14px;
        flex-wrap: wrap;
        gap: 12px;
    }
    .header-left { gap: 10px; width: 100%; }
    .header-logo img { width: 38px !important; height: 38px !important; }
    .header-title { font-size: 0.92rem; }
    .header-sub { font-size: 0.6rem; }
    .header-center,
    .header-right { order: 3; }
    .header-right { gap: 8px; flex: 1; justify-content: flex-end; flex-wrap: wrap; }
    .header-center { flex-shrink: 0; }
    .timer-box,
    .header-lang-btn,
    .candidate-chip { padding: 5px 12px; }
    .timer-box span { font-size: 0.98rem; }
    .candidate-info { display: flex; }
    .candidate-name { font-size: 0.78rem; max-width: 60px; }
    .candidate-label { display: none; }

    .info-bar { padding: 10px 12px 0; }
    .info-bar-inner { padding: 12px 14px; gap: 10px; }
    .info-bar-inner::before { font-size: 1rem; }
    .info-item { padding: 0; }
    /* On mobile, show ONLY Module Name in the top info bar */
    .info-bar-inner .info-item:not(:first-of-type) { display: none; }
    .info-bar-inner .info-divider { display: none; }
    .info-bar-inner .info-item:first-of-type { flex: 1; }
    .info-bar-inner .info-item .info-value { font-size: 0.9rem; }

    /* Mobile-only stat strip below info bar */
    .mobile-stat-strip {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 4px;
    }
    .ms-item {
        background: var(--paper);
        border-radius: 12px;
        padding: 10px 10px;
        display: flex; align-items: center; gap: 8px;
        box-shadow: var(--shadow-1);
        min-width: 0;
    }
    .ms-ic {
        width: 28px; height: 28px;
        border-radius: 8px;
        display: flex; align-items: center; justify-content: center;
        flex-shrink: 0;
    }
    .ms-tx { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
    .ms-lbl { font-size: 0.56rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .ms-tx b { font-size: 0.96rem; font-weight: 800; color: var(--ink); line-height: 1; font-family: 'JetBrains Mono', monospace; }

    .main-container { padding: 10px 12px 90px; gap: 12px; }
    .question-card { padding: 18px 16px 0; border-radius: 14px; }
    .q-text { font-size: 1rem; }

    .options-list { gap: 10px; margin-top: 16px; }
    .option-label { padding: 11px 12px; min-height: 56px; gap: 12px; border-radius: 12px; }
    .option-label:active { transform: scale(0.98); transition: transform 80ms; }
    .opt-letter { width: 36px; height: 36px; font-size: 0.92rem; border-radius: 9px; }
    .opt-text { font-size: 0.9rem; }

    .q-nav {
        position: sticky; bottom: 0;
        background: var(--paper);
        margin: 20px -16px 0;
        padding: 12px 16px max(12px, env(safe-area-inset-bottom));
        border-top: 1px solid var(--border-2);
        border-radius: 0 0 14px 14px;
        z-index: 40; gap: 10px;
    }
    .q-nav .btn { flex: 1; padding: 12px 12px; font-size: 0.86rem; border-radius: 11px; }

    .footer { display: none; }

    /* Sidebar inline (not bottom sheet) — palette appears below question */
    .sidebar { position: static; transform: none; pointer-events: auto; width: 100%; }
    .sidebar-card { border-radius: 14px; max-height: none; overflow: visible; box-shadow: var(--shadow-1); }
    .sidebar-grab { display: none !important; }
    .sidebar-close { display: none !important; }
    .nav-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
        padding: 14px 14px 10px;
    }
    .num-btn {
        aspect-ratio: 1 / 1;
        border-radius: 50%;
        font-size: 0.82rem;
        font-weight: 700;
        border-width: 1.5px;
    }
    .num-btn.active { transform: scale(1.06); }

    /* Hide FAB on mobile since palette is inline */
    .palette-fab, .mobile-palette-backdrop { display: none !important; }

    /* Modals */
    .lang-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .lang-card { padding: 12px 6px; min-height: 70px; }
    .lang-native { font-size: 0.92rem; }
    .lang-modal { padding: 28px 20px 22px; border-radius: 22px; }
    .lang-modal-title { font-size: 1.4rem; }
    .lang-modal-sub { font-size: 0.78rem; }
    .login-card { padding: 36px 22px 24px; border-radius: 22px; max-width: 100%; }
    .login-card h2 { font-size: 1.45rem; }
    .login-features { gap: 8px; margin-bottom: 20px; }
    .login-feature { padding: 8px 8px; gap: 7px; }
    .login-feature-ic { width: 28px; height: 28px; border-radius: 8px; }
    .login-feature-tx b { font-size: 0.76rem; }
    .login-feature-tx span { font-size: 0.55rem; }
    .result-modal { padding: 32px 22px 24px; border-radius: 22px; }
    .result-score-ring { width: 150px; height: 150px; margin: 18px auto; }
    .ring-score { font-size: 2.1rem; }
    .result-actions { flex-direction: column; }
}

@media (max-width: 420px) {
    .header-right { flex-wrap: nowrap; }
    .timer-box, .header-lang-btn { padding: 4px 10px; }
    .timer-box span { font-size: 0.9rem; }
    .header-lang-name { font-size: 0.78rem; }
    .candidate-name { display: none; }
    .candidate-chip { padding: 4px; }
    .lang-grid { grid-template-columns: repeat(2, 1fr); }
    .nav-grid { grid-template-columns: repeat(5, 1fr); gap: 7px; }
    .num-btn { font-size: 0.78rem; }
}
