/* ============================================
   FE Electrical & Computer Practice Exam
   CBT-Style Interface
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    /* Spacing scale (8px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    /* Softer shadows with slight blue tint */
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
    --shadow: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-md: 0 4px 8px rgba(15,23,42,0.06), 0 2px 4px rgba(15,23,42,0.04);
    --shadow-lg: 0 12px 24px rgba(15,23,42,0.08), 0 4px 8px rgba(15,23,42,0.04);
    /* Radii */
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height — accounts for mobile browser chrome */
    /* iOS safe areas for notch/home indicator */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.screen {
    display: none;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
}
.screen.active {
    display: flex;
    flex-direction: column;
}

/* ============ FOCUS STYLES (keyboard accessibility) ============ */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    min-height: 40px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 1px 3px rgba(37,99,235,0.2);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(37,99,235,0.3); }

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-nav {
    background: var(--gray-200);
    color: var(--gray-700);
    padding: 8px 16px;
}
.btn-nav:hover { background: var(--gray-300); }

.btn-next {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 1px 3px rgba(37,99,235,0.2);
}
.btn-next:hover { box-shadow: 0 4px 12px rgba(37,99,235,0.3); }

.btn-flag {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
    min-width: 140px;
    text-align: center;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
}
.btn-flag:hover { background: var(--warning-light); border-color: var(--warning); color: var(--gray-800); }
.btn-flag.flagged {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--gray-800);
}

.btn-check {
    background: linear-gradient(135deg, var(--success) 0%, #15803d 100%);
    color: white;
    box-shadow: 0 1px 3px rgba(22,163,74,0.2);
}
.btn-check:hover { box-shadow: 0 4px 12px rgba(22,163,74,0.3); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 13px;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.15); }

.btn-end { border-color: rgba(220,38,38,0.5); color: #fca5a5; }
.btn-end:hover { background: rgba(220,38,38,0.2); }
.btn-end-ready {
    background: #22c55e; border-color: #22c55e; color: #fff;
    animation: pulse-ready 1.5s ease-in-out infinite;
    font-weight: 700;
}
.btn-end-ready:hover { background: #16a34a; }
@keyframes pulse-ready {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px 8px;
    line-height: 1;
}
.btn-close:hover { color: var(--gray-800); }

.hidden { display: none !important; }

/* ============ PAYWALL / SALES ============ */
.paywall-content {
    text-align: center;
    max-width: 680px;
    margin: 0 auto;
}
/* Benefit cards grid (replaces old feature checklist) */
.paywall-benefits {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    text-align: left;
    margin-bottom: 32px;
}
.benefit-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 20px;
}
.benefit-card-highlight {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-color: #86efac;
    text-align: center;
}
.benefit-icon {
    font-size: 24px;
    margin-bottom: 8px;
}
.benefit-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 6px;
}
.benefit-card p {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
    margin: 0;
}
.paywall-compare {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 8px;
}
@media (max-width: 540px) {
    .paywall-benefits { grid-template-columns: 1fr; }
    .benefit-card-highlight { text-align: left; }
}
/* Legacy styles kept for compatibility */
.paywall-features {
    text-align: left;
    display: inline-block;
    margin-bottom: 32px;
}
.paywall-feature {
    padding: 6px 0;
    font-size: 15px;
    color: var(--gray-700);
}
.paywall-check {
    color: #16a34a;
    font-weight: 700;
    margin-right: 8px;
}
.paywall-pricing {
    margin-bottom: 24px;
}
.paywall-price {
    font-size: 48px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    letter-spacing: -0.03em;
}
.paywall-price-label {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
    margin-bottom: 16px;
}
.btn-buy {
    font-size: 18px;
    padding: 14px 48px;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 14px rgba(37,99,235,0.3);
}
.btn-buy:hover {
    box-shadow: 0 6px 20px rgba(37,99,235,0.4);
}
.paywall-bundle-link {
    margin-top: 12px;
    font-size: 13px;
}
.paywall-bundle-link a {
    color: var(--gray-500);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.paywall-bundle-link a:hover {
    color: var(--primary);
}
/* ============ EMAIL CAPTURE BANNER ============ */
.email-capture-banner {
    margin-top: 24px;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
}
.email-capture-inner {
    text-align: center;
}
.email-capture-text {
    font-size: 15px;
    color: var(--gray-700);
    margin-bottom: 12px;
    line-height: 1.5;
}
.email-capture-discount {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 14px;
}
.email-capture-form {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}
.email-capture-input {
    padding: 10px 16px;
    font-size: 15px;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    outline: none;
    min-width: 240px;
    font-family: var(--font-sans);
    transition: border-color 0.15s;
}
.email-capture-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.email-capture-btn {
    white-space: nowrap;
    padding: 10px 20px;
    font-weight: 700;
}
.email-capture-success {
    color: #16a34a;
    font-weight: 600;
    font-size: 15px;
    padding: 8px 0;
}
body.dark-mode .email-capture-banner {
    background: linear-gradient(135deg, #0f1a2e 0%, #0f1f15 100%);
    border-color: #2563eb;
}
body.dark-mode .email-capture-text { color: #c0c4d8; }
body.dark-mode .email-capture-input {
    background: #1a1d2e;
    border-color: #363a52;
    color: #e8eaf4;
}
body.dark-mode .email-capture-input:focus {
    border-color: #6d9efc;
    box-shadow: 0 0 0 3px rgba(109,158,252,0.1);
}
@media (max-width: 768px) {
    .email-capture-banner { padding: 16px; }
    .email-capture-input { min-width: 0; width: 100%; }
    .email-capture-form { flex-direction: column; }
    .email-capture-btn { width: 100%; }
}

.paywall-key-section {
    margin-top: 24px;
}
.paywall-blog-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.paywall-blog-link:hover {
    background: var(--primary);
    color: white;
}
.paywall-key-link {
    font-size: 13px;
    color: var(--gray-500);
}
.key-entry-form {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.key-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    text-align: center;
    padding: 10px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    width: 280px;
    max-width: 100%;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.key-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.15);
}
.key-error {
    color: #dc2626;
    font-size: 13px;
}

/* License success screen */
.license-success {
    text-align: center;
    max-width: 480px;
    margin: 0 auto;
    padding: 40px 20px;
}
.success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #16a34a;
    color: white;
    font-size: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.license-key-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px;
    font-weight: 600;
    background: var(--gray-100);
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    padding: 12px 20px;
    margin: 12px auto;
    display: inline-block;
    letter-spacing: 1px;
    user-select: all;
}
.key-save-note {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 24px;
}

.btn-demo {
    display: block;
    margin: 12px auto 0;
    font-size: 14px;
    padding: 10px 32px;
    border-radius: 8px;
}

/* Demo upsell on results page */
.demo-upsell {
    text-align: center;
    background: linear-gradient(135deg, #eef2ff, #e8f0fe);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 28px 24px;
    margin: 24px 0;
}
.demo-upsell h3 {
    font-size: 20px;
    color: var(--gray-900);
    margin-bottom: 8px;
}
.demo-upsell p {
    color: var(--gray-600);
    margin-bottom: 16px;
    font-size: 14px;
}
/* Demo analytics preview */
.demo-analytics-preview {
    margin: 20px 0;
    text-align: left;
}
.demo-stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.demo-stat {
    text-align: center;
    padding: 16px 8px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}
.demo-stat-val {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}
.demo-stat-lbl {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
}
.demo-badge-preview { margin-bottom: 16px; }
.demo-badge-preview h4, .demo-topics-preview h4 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--gray-700);
}
.demo-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.demo-badge {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}
.demo-badge-bronze { background: linear-gradient(135deg, #fef3c7, #fed7aa); border-color: #f59e0b; }
.demo-badge-silver { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); border-color: #94a3b8; }
.demo-badge-gold { background: linear-gradient(135deg, #fefce8, #fef9c3); border-color: #eab308; }
.demo-badge-locked { background: var(--gray-100); opacity: 0.5; filter: grayscale(1); }
.demo-topic-bar {
    display: grid;
    grid-template-columns: 140px 1fr 40px;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}
.demo-topic-name { font-size: 12px; color: var(--gray-700); }
.demo-bar {
    height: 8px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
}
.demo-bar-fill { height: 100%; border-radius: 4px; }
.demo-bar-strong { background: #16a34a; }
.demo-bar-moderate { background: #f59e0b; }
.demo-bar-weak { background: #dc2626; }
.demo-topic-pct { font-size: 12px; font-weight: 600; color: var(--gray-600); text-align: right; }
.demo-cta-text {
    margin: 16px 0;
    font-size: 14px;
    color: var(--gray-600);
    line-height: 1.6;
}

@media (max-width: 480px) {
    .demo-stat-row { grid-template-columns: repeat(2, 1fr); }
    .demo-topic-bar { grid-template-columns: 100px 1fr 35px; }
}
body.dark-mode .demo-upsell {
    background: linear-gradient(135deg, #1a1d3a, #1e2a4a);
    border-color: #6d9efc;
}
body.dark-mode .demo-upsell h3 { color: #e8eaf4; }
body.dark-mode .demo-upsell p { color: #a0a4b8; }
body.dark-mode .demo-stat { background: #1a1d2e; border-color: #2a2e44; }
body.dark-mode .demo-stat-val { color: #60a5fa; }
body.dark-mode .demo-stat-lbl { color: #9ca3af; }
body.dark-mode .demo-badge-preview h4, body.dark-mode .demo-topics-preview h4 { color: #d0d4e8; }
body.dark-mode .demo-badge-locked { background: #1a1d2e; }
body.dark-mode .demo-bar { background: #2a2e44; }
body.dark-mode .demo-topic-name { color: #d0d4e8; }
body.dark-mode .demo-topic-pct { color: #9ca3af; }
body.dark-mode .demo-cta-text { color: #9ca3af; }

/* Demo dashboard (locked mode cards + banner) */
.demo-dashboard-banner {
    background: linear-gradient(135deg, var(--primary-light), #dbeafe);
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    text-align: center;
}
.demo-dashboard-banner h3 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}
.demo-dashboard-banner p {
    margin: 0 0 16px;
    font-size: 14px;
    color: var(--gray-600);
}
.mode-card.demo-locked {
    pointer-events: none;
    opacity: 0.55;
    filter: grayscale(0.3);
    position: relative;
    user-select: none;
}
.mode-card.demo-locked::after {
    content: '\1F512';
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 16px;
    opacity: 0.7;
}
body.dark-mode .demo-dashboard-banner {
    background: linear-gradient(135deg, #1a1d2e, #1e2338);
    border-color: #4a6cf7;
}
body.dark-mode .demo-dashboard-banner h3 { color: #e8eaf4; }
body.dark-mode .demo-dashboard-banner p { color: #a0a4b8; }
body.dark-mode .mode-card.demo-locked {
    opacity: 0.4;
}

/* Dark mode paywall overrides */
body.dark-mode .benefit-card { background: #13152a; border-color: #1e2240; }
body.dark-mode .benefit-card h3 { color: #e8eaf4; }
body.dark-mode .benefit-card p { color: #8b8fa8; }
body.dark-mode .benefit-card-highlight { background: linear-gradient(135deg, #0a2618 0%, #0d2a1b 100%); border-color: #22c55e; }
body.dark-mode .paywall-compare { color: #8b8fa8; }
body.dark-mode .paywall-feature { color: #c8cad8; }
body.dark-mode .paywall-check { color: #4ade80; }
body.dark-mode .paywall-blog-link {
    background: rgba(99,140,255,0.15);
    border-color: #638cff;
    color: #8bb4ff;
}
body.dark-mode .paywall-blog-link:hover {
    background: #638cff;
    color: #0c0e16;
}
body.dark-mode .key-input {
    background: #181a28;
    border-color: #2a2e44;
    color: #e8eaf4;
}
body.dark-mode .license-key-display {
    background: #181a28;
    border-color: #2a2e44;
    color: #e8eaf4;
}

/* ============ SITE NAVIGATION BAR ============ */
.site-nav {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.site-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
}
.site-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 32px;
}
.site-nav-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 14px;
    font-weight: 700;
    border-radius: 8px;
}
.site-nav-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.01em;
}
.site-nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-700);
    cursor: pointer;
    padding: 4px 8px;
    margin-left: auto;
}
.site-nav-mobile-dark { display: none; }
.site-nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.site-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    font-family: var(--font-sans);
}
.site-nav-link:hover {
    background: var(--gray-100);
    color: var(--primary);
}
.site-nav-link.site-nav-app-link {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}
.site-nav-link.site-nav-app-link:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1d4ed8 100%);
    color: #fff;
}
.nav-caret {
    font-size: 10px;
    opacity: 0.6;
}
.site-nav-dark.btn-dark-toggle {
    position: static;
    font-size: 18px;
    padding: 6px 10px;
    margin-left: 4px;
    min-width: 36px;
    height: 36px;
    gap: 4px;
    white-space: nowrap;
}
.dark-label { font-size: 12px; font-weight: 500; }
.site-nav-mobile-dark .dark-label { font-size: 11px; }
.nav-menu-sublabel {
    display: block; font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--gray-400); padding: 10px 12px 4px;
}
.nav-menu-sublabel:first-child { padding-top: 4px; }

/* Dropdown menus */
.site-nav-dropdown {
    position: relative;
}
.site-nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    padding: 16px;
    min-width: 540px;
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 8px;
    z-index: 1001;
}
.site-nav-menu-sm {
    min-width: 220px;
    display: none;
    grid-template-columns: 1fr;
}
.site-nav-dropdown:hover .site-nav-menu {
    display: grid;
}
.nav-menu-group {
    padding: 8px;
    border-radius: 8px;
}
.nav-menu-group:hover {
    background: var(--gray-50);
}
.nav-menu-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 6px;
    padding: 0 4px;
}
.site-nav-menu a {
    display: block;
    padding: 4px 4px;
    font-size: 13px;
    color: var(--gray-600);
    text-decoration: none;
    border-radius: 4px;
    transition: color 0.15s;
}
.site-nav-menu a:hover {
    color: var(--primary);
}
.site-nav-menu-sm a {
    padding: 8px 12px;
    font-size: 14px;
}
.site-nav-menu-sm a:hover {
    background: var(--gray-50);
}
/* Nav sublabels */
.nav-menu-sublabel {
    display: block; font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--gray-400); padding: 10px 12px 4px;
}
.nav-menu-sublabel:first-child { padding-top: 4px; }
/* Mega menu for Resources (4-column) */
.site-nav-menu-mega {
    min-width: 700px;
    right: 0;
    left: auto;
    transform: none;
    grid-template-columns: repeat(4, 1fr);
}
.nav-menu-col {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
}
.nav-menu-col .nav-menu-sublabel {
    padding: 0 4px 4px;
}
.nav-menu-col a {
    padding: 4px;
    font-size: 13px;
    color: var(--gray-600);
    text-decoration: none;
    border-radius: 4px;
    transition: color 0.15s;
}
.nav-menu-col a:hover {
    color: var(--primary);
}

/* Mobile nav */
@media (max-width: 768px) {
    .site-nav-toggle { display: block; }
    /* Dark mode button visible next to hamburger on mobile */
    .site-nav-mobile-dark {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        font-size: 18px;
        padding: 6px 10px;
        min-width: 36px;
        height: 36px;
        cursor: pointer;
        color: var(--gray-600);
        border-radius: 8px;
        margin-left: auto;
        margin-right: 4px;
        gap: 4px;
        white-space: nowrap;
    }
    .site-nav-mobile-dark:hover { background: var(--gray-100); }
    .site-nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: white;
        border-bottom: 1px solid var(--gray-200);
        box-shadow: 0 8px 24px rgba(0,0,0,0.1);
        flex-direction: column;
        padding: 12px 16px;
        gap: 0;
        align-items: stretch;
        max-height: calc(100dvh - 56px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .nav-open .site-nav-links { display: flex; }
    .site-nav-link { justify-content: space-between; padding: 12px 8px; }
    .site-nav-dropdown { position: static; }
    /* Colored separators between dropdown sections */
    .site-nav-dropdown + .site-nav-dropdown {
        border-top: 2px solid var(--gray-200);
        margin-top: 4px;
        padding-top: 4px;
    }
    .site-nav-dropdown:nth-child(1) > .site-nav-link { color: var(--primary); font-weight: 600; }
    .site-nav-dropdown:nth-child(2) > .site-nav-link { color: #7c3aed; font-weight: 600; }
    .site-nav-dropdown:nth-child(3) > .site-nav-link { color: #059669; font-weight: 600; }
    .site-nav-menu,
    .site-nav-menu-sm,
    .site-nav-menu-mega {
        position: static;
        transform: none;
        box-shadow: none;
        border: none;
        min-width: auto;
        padding: 4px 0 4px 16px;
        display: none;
        grid-template-columns: 1fr;
    }
    .site-nav-dropdown:hover .site-nav-menu { display: none; }
    .site-nav-dropdown.menu-open .site-nav-menu { display: grid; }
    /* Hide the dark toggle inside the dropdown on mobile (moved to header bar) */
    .site-nav-dark { display: none; }
    /* Pricing link separator */
    .site-nav-links > .site-nav-link:not(.btn-dark-toggle) {
        border-top: 2px solid var(--gray-200);
        margin-top: 4px;
        padding-top: 12px;
    }
    .site-nav-link.site-nav-app-link {
        justify-content: center;
        margin-top: 8px;
    }
}

/* Dark mode nav */
body.dark-mode .site-nav {
    background: #0f1120;
    border-bottom-color: #1e2240;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
body.dark-mode .site-nav-title { color: #e8eaf4; }
body.dark-mode .site-nav-link { color: #9ca3be; }
body.dark-mode .site-nav-link:hover { background: #1a1d35; color: #6d9efc; }
body.dark-mode .site-nav-link.site-nav-app-link,
body.dark-mode .site-nav-link.site-nav-app-link:hover {
    color: #fff;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}
body.dark-mode .site-nav-menu,
body.dark-mode .site-nav-menu-sm,
body.dark-mode .site-nav-menu-mega {
    background: #13152a;
    border-color: #1e2240;
    box-shadow: 0 12px 36px rgba(0,0,0,0.4);
}
body.dark-mode .nav-menu-label { color: #e8eaf4; }
body.dark-mode .nav-menu-group:hover { background: #1a1d35; }
body.dark-mode .nav-menu-sublabel { color: #6b7280; }
body.dark-mode .site-nav-menu a { color: #8b8fa8; }
body.dark-mode .site-nav-menu a:hover { color: #6d9efc; }
body.dark-mode .site-nav-menu-sm a:hover { background: #1a1d35; }
body.dark-mode .nav-menu-col a { color: #8b8fa8; }
body.dark-mode .nav-menu-col a:hover { color: #6d9efc; }
@media (max-width: 768px) {
    body.dark-mode .site-nav-links {
        background: #0f1120;
        border-bottom-color: #1e2240;
    }
    body.dark-mode .site-nav-mobile-dark { color: #9ca3be; }
    body.dark-mode .site-nav-mobile-dark:hover { background: #1a1d35; }
    body.dark-mode .site-nav-dropdown + .site-nav-dropdown { border-top-color: #1e2240; }
    body.dark-mode .site-nav-links > .site-nav-link:not(.btn-dark-toggle) { border-top-color: #1e2240; }
}

/* ============ LANDING SCREEN ============ */
.landing-container {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 24px;
}

.landing-header {
    text-align: center;
    margin-bottom: 48px;
    position: relative;
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 28px;
    font-weight: 700;
    border-radius: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-lg), 0 4px 20px rgba(37,99,235,0.2);
}

.landing-header h1 {
    font-size: 32px;
    color: var(--gray-900);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
    font-weight: 700;
}

.landing-header h2 {
    font-size: 20px;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.landing-subtitle {
    color: var(--gray-500);
    font-size: 14px;
}
.ncees-badge {
    display: block;
    margin-top: 10px;
    padding: 0;
    background: none;
    color: var(--gray-400);
    border: none;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Discipline Selector */
.discipline-selector {
    display: none;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
    align-items: center;
}
.discipline-selector.visible {
    display: flex;
}
.btn-switch-discipline {
    display: block;
    margin: 24px auto 0;
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 13px;
    cursor: pointer;
    padding: 8px 16px;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.btn-switch-discipline:hover {
    color: var(--gray-600);
}
.disc-group-label {
    width: 100%;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-400);
    margin-bottom: -2px;
}
.disc-group-pe {
    margin-top: 6px;
    color: #7c3aed;
}
.discipline-btn {
    padding: 8px 20px;
    border: 1.5px solid var(--gray-300);
    border-radius: 24px;
    background: transparent;
    color: var(--gray-500);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.discipline-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.discipline-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
/* Per-discipline colors for FE pills */
.discipline-btn[data-discipline="ece"] { border-color: #93c5fd; color: #2563eb; }
.discipline-btn[data-discipline="ece"]:hover { border-color: #2563eb; background: #eff6ff; color: #2563eb; }
.discipline-btn[data-discipline="ece"].active { background: #2563eb; border-color: #2563eb; color: white; box-shadow: 0 2px 8px rgba(37,99,235,0.25); }

.discipline-btn[data-discipline="civil"] { border-color: #fcd34d; color: #b45309; }
.discipline-btn[data-discipline="civil"]:hover { border-color: #f59e0b; background: #fffbeb; color: #b45309; }
.discipline-btn[data-discipline="civil"].active { background: #f59e0b; border-color: #f59e0b; color: white; box-shadow: 0 2px 8px rgba(245,158,11,0.25); }

.discipline-btn[data-discipline="mechanical"] { border-color: #fca5a5; color: #dc2626; }
.discipline-btn[data-discipline="mechanical"]:hover { border-color: #dc2626; background: #fef2f2; color: #dc2626; }
.discipline-btn[data-discipline="mechanical"].active { background: #dc2626; border-color: #dc2626; color: white; box-shadow: 0 2px 8px rgba(220,38,38,0.25); }

.discipline-btn[data-discipline="chemical"] { border-color: #86efac; color: #16a34a; }
.discipline-btn[data-discipline="chemical"]:hover { border-color: #16a34a; background: #f0fdf4; color: #16a34a; }
.discipline-btn[data-discipline="chemical"].active { background: #16a34a; border-color: #16a34a; color: white; box-shadow: 0 2px 8px rgba(22,163,74,0.25); }

.discipline-btn[data-discipline="environmental"] { border-color: #67e8f9; color: #0891b2; }
.discipline-btn[data-discipline="environmental"]:hover { border-color: #0891b2; background: #ecfeff; color: #0891b2; }
.discipline-btn[data-discipline="environmental"].active { background: #0891b2; border-color: #0891b2; color: white; box-shadow: 0 2px 8px rgba(8,145,178,0.25); }

/* PE discipline pills — individual colors */
.discipline-btn-pe { border-color: #d1d5db; color: #6b7280; }
.discipline-btn-pe:hover { border-color: #7c3aed; color: #7c3aed; background: #f5f3ff; }
.discipline-btn-pe.active { background: #7c3aed; border-color: #7c3aed; color: white; box-shadow: 0 2px 8px rgba(124,58,237,0.25); }
.discipline-btn[data-discipline="pe-civil-trans"] { border-color: #fbbf24; color: #b45309; }
.discipline-btn[data-discipline="pe-civil-trans"]:hover { border-color: #d97706; color: #d97706; background: #fffbeb; }
.discipline-btn[data-discipline="pe-civil-trans"].active { background: #d97706; border-color: #d97706; color: white; box-shadow: 0 2px 8px rgba(217,119,6,0.25); }
.discipline-btn[data-discipline="pe-civil-struct"] { border-color: #f87171; color: #b91c1c; }
.discipline-btn[data-discipline="pe-civil-struct"]:hover { border-color: #dc2626; color: #dc2626; background: #fef2f2; }
.discipline-btn[data-discipline="pe-civil-struct"].active { background: #dc2626; border-color: #dc2626; color: white; box-shadow: 0 2px 8px rgba(220,38,38,0.25); }
.discipline-btn[data-discipline="pe-civil-wre"] { border-color: #67e8f9; color: #0e7490; }
.discipline-btn[data-discipline="pe-civil-wre"]:hover { border-color: #0891b2; color: #0891b2; background: #ecfeff; }
.discipline-btn[data-discipline="pe-civil-wre"].active { background: #0891b2; border-color: #0891b2; color: white; box-shadow: 0 2px 8px rgba(8,145,178,0.25); }
.discipline-btn[data-discipline="pe-elec-power"] { border-color: #c4b5fd; color: #7c3aed; }
.discipline-btn[data-discipline="pe-elec-power"]:hover { border-color: #7c3aed; color: #7c3aed; background: #f5f3ff; }
.discipline-btn[data-discipline="pe-elec-power"].active { background: #7c3aed; border-color: #7c3aed; color: white; box-shadow: 0 2px 8px rgba(124,58,237,0.25); }

/* ── Discipline Preview ─────────────────────────────────── */
.landing-header-compact { padding-top: 24px; }
.landing-header-compact .logo-mark { display: none; }
.landing-header-compact h1 { margin-top: 0; font-size: 28px; }
.landing-header-compact h2 { font-size: 18px; margin-top: 4px; }
.discipline-preview {
    margin-top: 20px;
    text-align: left;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}
.disc-group-label {
    color: var(--primary);
    font-weight: 700;
}
.preview-stats {
    text-align: center;
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 12px;
    font-weight: 500;
}
.preview-stats strong { color: var(--gray-700); }
.preview-topics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    margin-bottom: 20px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
.topic-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
}
.topic-chip .chip-count {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 600;
    margin-left: auto;
}
.topic-chip .chip-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.preview-sample {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 8px;
}
.sample-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-400);
    font-weight: 700;
    margin-bottom: 12px;
}
.sample-question {
    font-size: 15px;
    line-height: 1.6;
    color: var(--gray-800);
    margin-bottom: 14px;
}
.sample-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}
.sample-opt {
    padding: 8px 12px;
    border-radius: 8px;
    background: white;
    border: 1px solid var(--gray-200);
    font-size: 14px;
    color: var(--gray-700);
    cursor: default;
    user-select: text;
}
.sample-opt .opt-letter {
    font-weight: 700;
    color: var(--gray-400);
    margin-right: 6px;
}
.sample-reveal-btn {
    width: 100%;
    font-size: 14px;
    font-weight: 600;
    padding: 12px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background: var(--primary-light, #eff6ff);
    color: var(--primary);
    cursor: pointer;
    transition: all 0.15s ease;
}
.sample-reveal-btn:hover {
    background: var(--primary);
    color: white;
}
.sample-solution {
    margin-top: 16px;
    border-top: 1px solid var(--gray-200);
    padding-top: 16px;
}
.sample-solution .step {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-700);
}
.sample-solution .step-num {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sample-calc-steps {
    margin-top: 12px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.8;
    color: var(--gray-600);
}
.sample-calc-steps:empty { display: none; }
.sample-calc-step {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}
.sample-calc-step .calc-arrow {
    color: var(--gray-400);
    flex-shrink: 0;
}
.sample-why-wrong-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
    font-weight: 700;
    margin-bottom: 6px;
}
.sample-reference {
    margin-top: 10px;
    padding: 8px 12px;
    background: #f0f9ff;
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    font-size: 12.5px;
    color: var(--gray-600);
    font-style: italic;
}
.dark .sample-reference { background: rgba(37,99,235,0.08); color: var(--gray-400); }
.btn-enter-code {
    display: block;
    margin: 16px auto 0;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 32px;
}
.sample-calc-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
    font-weight: 700;
    margin-bottom: 6px;
}
.sample-explanation {
    font-size: 14px;
    line-height: 1.6;
    color: var(--gray-700);
    margin-top: 12px;
    padding: 14px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

/* Dark mode */
.dark .preview-stats { color: var(--gray-400); }
.dark .preview-stats strong { color: var(--gray-200); }
.dark .topic-chip { color: var(--gray-300); }
.dark .topic-chip .chip-count { color: var(--gray-500); }
.dark .preview-sample { background: var(--gray-800); border-color: var(--gray-700); }
.dark .sample-question { color: var(--gray-200); }
.dark .sample-opt { background: var(--gray-900); border-color: var(--gray-700); color: var(--gray-300); }
.dark .sample-opt .opt-letter { color: var(--gray-500); }
.dark .sample-reveal-btn { background: rgba(37,99,235,0.1); border-color: var(--primary); }
.dark .sample-solution { border-color: var(--gray-700); }
.dark .sample-solution .step { color: var(--gray-300); }
.dark .sample-calc-steps { background: var(--gray-900); border-color: var(--gray-700); color: var(--gray-400); }
.dark .sample-explanation { background: var(--gray-900); border-color: var(--gray-700); color: var(--gray-400); }

@media (max-width: 600px) {
    .sample-options { grid-template-columns: 1fr; }
    .preview-sample { padding: 16px; }
    .preview-topics { grid-template-columns: 1fr; }
}

.mode-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.mode-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    transition: all var(--transition-normal);
    position: relative;
}
.mode-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(37,99,235,0.1);
    transform: translateY(-2px);
}
.mode-card:active {
    transform: translateY(0) scale(0.99);
}
.mode-card button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--gray-200);
    border-color: var(--gray-200);
    color: var(--gray-500);
}

.mode-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.mode-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--gray-800);
}

.mode-card p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Topic Selection */
.topic-select-panel {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.topic-select-panel h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.topic-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.topic-item,
.topic-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    min-height: 40px;
    border-left: 3px solid transparent;
    overflow: hidden;
}
.topic-item:hover, .topic-checkbox:hover { background: var(--gray-50); }
.topic-item input, .topic-checkbox input { accent-color: var(--primary); flex-shrink: 0; }
.topic-item .topic-count { color: var(--gray-400); font-size: 12px; margin-left: auto; }
.topic-checkbox span { line-height: 1.3; }

.topic-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

/* ============ REFRESHER MODE ============ */
.refresher-panel {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.refresher-panel h3 { margin-bottom: 4px; font-size: 18px; }
.refresher-subtitle { color: var(--gray-500); font-size: 14px; margin-bottom: 16px; }
.refresher-plan {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 16px;
}
.refresher-topic {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--gray-50);
}
.refresher-topic-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.refresher-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.refresher-weak { background: #dc2626; }
.refresher-unseen { background: var(--gray-300); }
.refresher-moderate { background: #f59e0b; }
.refresher-strong { background: #16a34a; }
.refresher-stage {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin: 2px 4px 2px 0;
    background: var(--gray-100);
    color: var(--gray-500);
    cursor: default;
}
.refresher-stage.current {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.refresher-stage.done {
    background: #dcfce7;
    color: #16a34a;
}
.refresher-check { font-weight: 700; }
.refresher-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}
.refresher-info { flex: 1; font-size: 13px; color: var(--gray-500); }

#topic-question-count {
    flex: 1;
    text-align: center;
    color: var(--gray-500);
    font-size: 13px;
}

/* ============ QUICK NAV BAR ============ */
.quick-nav-bar {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.quick-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-nav-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
}

.quick-nav-legend {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--gray-500);
    flex-wrap: wrap;
}

.qn-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.qn-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}
.qn-legend-dot.qn-strong { background: var(--success); }
.qn-legend-dot.qn-moderate { background: var(--warning); }
.qn-legend-dot.qn-weak { background: var(--danger); }
.qn-legend-dot.qn-unseen { background: var(--gray-300); }

/* Section group (Part 1 / Part 2) */
.quick-nav-section {
    margin-bottom: 16px;
}

.quick-nav-section:last-child {
    margin-bottom: 0;
}

.quick-nav-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    margin-bottom: 8px;
    padding-left: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.quick-nav-section-label .qn-section-toggle {
    font-size: 9px;
    transition: transform 0.2s;
    display: inline-block;
}

.quick-nav-section-label .qn-section-toggle.collapsed {
    transform: rotate(-90deg);
}

.quick-nav-section-label:hover {
    color: var(--gray-600);
}

/* Topic buttons grid */
.quick-nav-topics {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.quick-nav-topics.collapsed {
    display: none;
}

/* Individual topic button */
.qn-topic-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    background: white;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    position: relative;
    overflow: hidden;
    min-height: 56px;
}

.qn-topic-btn:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.qn-topic-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Strength indicator stripe on left */
.qn-topic-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--gray-300);
    border-radius: var(--radius) 0 0 var(--radius);
}

.qn-topic-btn.qn-strength-strong::before { background: var(--success); }
.qn-topic-btn.qn-strength-moderate::before { background: var(--warning); }
.qn-topic-btn.qn-strength-weak::before { background: var(--danger); }
.qn-topic-btn.qn-strength-unseen::before { background: var(--gray-300); }

/* Progress ring */
.qn-ring-wrap {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    position: relative;
}

.qn-ring-wrap svg {
    width: 36px;
    height: 36px;
    transform: rotate(-90deg);
}

.qn-ring-bg {
    fill: none;
    stroke: var(--gray-200);
    stroke-width: 3;
}

.qn-ring-fill {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.4s ease;
}

.qn-ring-fill.qn-strong { stroke: var(--success); }
.qn-ring-fill.qn-moderate { stroke: var(--warning); }
.qn-ring-fill.qn-weak { stroke: var(--danger); }
.qn-ring-fill.qn-unseen { stroke: var(--gray-300); }

.qn-ring-pct {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--gray-600);
}

/* Topic text info */
.qn-topic-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.qn-topic-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    line-height: 1.3;
    /* Allow wrapping but limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.qn-topic-meta {
    font-size: 11px;
    color: var(--gray-400);
    white-space: nowrap;
}

/* Practice icon on hover */
.qn-topic-action {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.15s;
}

.qn-topic-btn:hover .qn-topic-action {
    opacity: 1;
}

/* Quick nav footer */
.quick-nav-footer {
    display: flex;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
    margin-top: 16px;
    flex-wrap: wrap;
}

/* ============ QUICK NAV RESPONSIVE ============ */
@media (max-width: 1024px) {
    .quick-nav-topics {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 639px) {
    .quick-nav-bar { padding: 16px; }
    .quick-nav-topics {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    .qn-topic-btn {
        padding: 8px 10px;
        min-height: 48px;
        gap: 8px;
    }
    .qn-ring-wrap { width: 30px; height: 30px; }
    .qn-ring-wrap svg { width: 30px; height: 30px; }
    .qn-ring-pct { font-size: 8px; }
    .qn-topic-name { font-size: 12px; }
    .qn-topic-meta { font-size: 10px; }
    .qn-topic-action { display: none; }
    .quick-nav-legend { gap: 8px; }
}

@media (max-width: 479px) {
    .quick-nav-topics {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .qn-topic-btn {
        padding: 6px 8px;
        min-height: 44px;
        gap: 6px;
    }
    .qn-ring-wrap { width: 28px; height: 28px; }
    .qn-ring-wrap svg { width: 28px; height: 28px; }
    .qn-ring-pct { font-size: 7px; }
    .qn-topic-name { font-size: 11px; }
    .qn-topic-meta { font-size: 9px; }
    .quick-nav-header { margin-bottom: 12px; }
    .quick-nav-header h3 { font-size: 16px; }
}

/* ============ QUICK NAV DARK MODE ============ */
body.dark-mode .quick-nav-bar {
    background: #1a1d2e;
    color: #d0d4e8;
}
body.dark-mode .quick-nav-header h3 { color: #e8eaf4; }
body.dark-mode .quick-nav-legend { color: #8b8fa8; }
body.dark-mode .quick-nav-section-label { color: #5c5f77; }
body.dark-mode .quick-nav-section-label:hover { color: #8b8fa8; }
body.dark-mode .qn-topic-btn {
    background: #13151f;
    border-color: #2a2e44;
}
body.dark-mode .qn-topic-btn:hover {
    border-color: #6d9efc;
    box-shadow: 0 2px 8px rgba(109, 158, 252, 0.1);
}
body.dark-mode .qn-topic-name { color: #e8eaf4; }
body.dark-mode .qn-topic-meta { color: #5c5f77; }
body.dark-mode .qn-ring-bg { stroke: #2a2e44; }
body.dark-mode .qn-ring-pct { color: #8b8fa8; }
body.dark-mode .qn-topic-action {
    background: rgba(109, 158, 252, 0.15);
    color: #6d9efc;
}
body.dark-mode .quick-nav-footer { border-top-color: #2a2e44; }
body.dark-mode .qn-legend-dot.qn-unseen { background: #5c5f77; }

/* History */
.history-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.history-section h3 { margin-bottom: 12px; }

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    font-size: 13px;
}

.history-item .hist-score {
    font-weight: 700;
    font-size: 16px;
    min-width: 48px;
}

.history-item .hist-score.pass { color: var(--success); }
.history-item .hist-score.fail { color: var(--danger); }
.history-item .hist-details { flex: 1; color: var(--gray-600); }
.history-item .hist-date { color: var(--gray-400); font-size: 12px; }

.history-item:hover { background: var(--gray-100); transform: translateX(2px); }
.history-item { transition: background var(--transition-fast), transform var(--transition-fast); }

.history-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.history-date { font-size: 12px; color: var(--gray-500); }
.history-mode { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; }
.history-score { display: flex; align-items: center; gap: 8px; }
.history-pct { font-weight: 700; font-size: 16px; }
.history-detail { font-size: 12px; color: var(--gray-500); }
.history-pass { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.history-pass.pass { background: var(--success-light); color: var(--success); }
.history-pass.fail { background: var(--danger-light); color: var(--danger); }

.history-review-btn {
    padding: 4px 12px;
    font-size: 11px;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
    margin-left: 8px;
}
.history-review-btn:hover { background: var(--primary); color: white; }

.history-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.history-delete-btn {
    padding: 2px 8px;
    font-size: 14px;
    background: transparent;
    color: var(--gray-400);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s, border-color 0.15s;
}
.history-delete-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ============ EXAM SCREEN ============ */
#exam-screen {
    overflow: hidden;
}

/* Desktop: nav + exam-body sit side by side below the header */

.exam-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-800);
    color: white;
    padding: 0 20px;
    height: 52px;
    flex-shrink: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.exam-title {
    font-weight: 600;
    font-size: 15px;
}

.exam-mode-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--primary);
    font-weight: 500;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.timer-display {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    transition: background var(--transition-fast);
}
.timer-display:hover { background: rgba(0,0,0,0.05); }
.timer-hidden-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-400);
    font-family: var(--font-sans);
    letter-spacing: 0.3px;
}

.timer-display.warning { color: var(--warning); }
.timer-display.critical { color: #ef4444; animation: pulse 1s infinite; }

@keyframes pulse {
    50% { opacity: 0.6; }
}

.progress-info {
    font-size: 12px;
    color: var(--gray-400);
}

.pace-indicator {
    display: inline-block;
    margin-left: 8px;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(0,0,0,0.05);
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 2px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Exam Body Layout */
.exam-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    margin-left: 220px;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

/* Question Navigation Sidebar — fixed on left, outside overflow containers */
.question-nav {
    position: fixed;
    left: 0;
    top: 52px;
    bottom: 0;
    width: 220px;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 90;
}

.question-nav.collapsed {
    display: none;
}
.btn-expand-nav {
    display: none;
    position: fixed;
    top: 62px;
    left: 8px;
    z-index: 95;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
}
.btn-expand-nav:hover { background: var(--primary-dark); }
/* Show expand button on desktop when nav is collapsed */
.btn-expand-nav.desktop-visible {
    display: flex;
}

.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-200);
}

.btn-collapse {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-400);
    padding: 2px 6px;
}
.btn-close-mobile-nav {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-400);
    padding: 4px 8px;
    margin-left: auto;
}
@media (max-width: 768px) {
    .btn-close-mobile-nav { display: block; }
    .btn-collapse { display: none; }
}

.nav-legend {
    display: flex;
    gap: 12px;
    padding: 8px 16px;
    font-size: 11px;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-100);
}

.legend-item { display: flex; align-items: center; gap: 4px; }

.dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}
.dot-answered { background: var(--primary); }
.dot-flagged { background: var(--warning); }
.dot-current { background: var(--gray-800); border: 2px solid var(--primary); }

.nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1;
    min-width: 0;
    align-content: start;
}

.nav-btn {
    width: 100%;
    max-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--gray-600);
    padding: 6px 2px;
}
/* Difficulty border indicators for review mode */
.nav-btn.diff-easy { border-left: 3px solid var(--success); }
.nav-btn.diff-medium { border-left: 3px solid var(--warning); }
.nav-btn.diff-hard { border-left: 3px solid var(--danger); }
/* Accordion nav for large question sets */
.nav-jump-row {
    display: flex;
    gap: 4px;
    padding: 4px 12px;
    border-bottom: 1px solid var(--gray-200);
    grid-column: 1 / -1;
}
.nav-jump-input {
    flex: 1;
    padding: 4px 6px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 11px;
    min-width: 0;
}
.nav-jump-input:focus { outline: none; border-color: var(--primary); }
.nav-jump-btn {
    padding: 4px 8px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.nav-jump-btn:hover { background: var(--primary-dark); }
.nav-accordion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    transition: background 0.15s;
    grid-column: 1 / -1;
}
.nav-accordion-header:hover { background: var(--gray-50); }
.nav-accordion-header.accordion-active { background: var(--gray-50); }
.accordion-color {
    width: 4px;
    height: 24px;
    border-radius: 2px;
    flex-shrink: 0;
}
.accordion-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.accordion-meta {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-400);
    flex-shrink: 0;
}
.accordion-chevron {
    font-size: 10px;
    color: var(--gray-400);
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}
.nav-accordion-body { grid-column: 1 / -1; }
.nav-accordion-body.collapsed { display: none; }
.nav-accordion-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px 12px;
}

.nav-btn:hover { background: var(--gray-100); }
.nav-btn.answered { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.nav-btn.flagged { background: var(--warning-light); border-color: var(--warning); color: #92400e; }
.nav-btn.current { border-color: var(--gray-800); border-width: 2px; font-weight: 700; }
.nav-btn.correct { background: var(--success-light); border-color: var(--success); color: var(--success); }
.nav-btn.incorrect { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }

.nav-filters {
    display: flex;
    border-top: 1px solid var(--gray-200);
    padding: 8px 12px;
    gap: 6px;
}

.btn-filter {
    flex: 1;
    padding: 4px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font-sans);
}
.btn-filter.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* Review Mode Topic Filter */
.nav-topic-filter {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-200);
}
.nav-topic-filter select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    background: white;
    color: var(--gray-700);
    cursor: pointer;
}
.nav-topic-filter select:focus {
    outline: none;
    border-color: var(--primary);
}
.nav-topic-filter select + select {
    margin-top: 6px;
}
.review-diff-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 10px;
    color: var(--gray-500);
}
.diff-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}
.diff-dot.diff-easy { background: var(--success); }
.diff-dot.diff-medium { background: var(--warning); }
.diff-dot.diff-hard { background: var(--danger); }

.nav-topic-divider {
    grid-column: 1 / -1;
    padding: 6px 4px 2px;
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-top: 2px solid var(--primary-light);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-topic-divider .topic-count {
    font-weight: 400;
    color: var(--gray-400);
    text-transform: none;
    letter-spacing: 0;
}

/* Main Question Area */
.question-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px 32px;
    background: var(--gray-50);
}

.question-topic-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.topic-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.difficulty-badge {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 500;
}

.difficulty-badge.easy { background: var(--success-light); color: var(--success); }
.difficulty-badge.medium { background: var(--warning-light); color: #92400e; }
.difficulty-badge.hard { background: var(--danger-light); color: var(--danger); }

.question-content {
    flex: 1 0 auto;
}

.question-text {
    font-size: 16px;
    line-height: 1.7;
    margin-bottom: 24px;
    color: var(--gray-800);
}

.question-text code {
    font-family: var(--font-mono);
    background: var(--gray-200);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 14px;
}

.question-text .formula {
    display: block;
    text-align: center;
    margin: 12px 0;
    font-family: var(--font-mono);
    font-size: 15px;
    padding: 14px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    letter-spacing: 0.01em;
}

/* Code blocks and pseudocode */
.question-text pre, .feedback-explanation pre, .feedback-steps pre {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    background: var(--gray-800);
    color: #e5e7eb;
    padding: 14px 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 12px 0;
    white-space: pre;
    tab-size: 4;
}
.option-text pre, .option-text code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--gray-100);
    padding: 1px 5px;
    border-radius: 3px;
}
.option-text pre {
    display: block;
    padding: 6px 10px;
    margin: 4px 0 0;
    white-space: pre;
    overflow-x: auto;
}

/* Answer Options */
.answer-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 680px;
}

.option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
}
@media (hover: hover) {
    .option:hover { border-color: var(--primary); background: var(--primary-light); transform: translateX(2px); }
}
.option.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 1px var(--primary); }
.option.correct { border-color: var(--success); background: var(--success-light); }
.option.incorrect { border-color: var(--danger); background: var(--danger-light); }
.option.disabled { pointer-events: none; opacity: 0.7; }
.option.disabled.correct { opacity: 1; }
.option.disabled.incorrect { opacity: 1; }

/* Strikethrough elimination tool */
.option.struck { opacity: 0.45; }
.option.struck .option-text { text-decoration: line-through; text-decoration-color: var(--danger); text-decoration-thickness: 2px; }
.option.struck .option-letter { text-decoration: line-through; text-decoration-color: var(--danger); }
.btn-strikethrough {
    background: none; border: 1px solid var(--gray-300); border-radius: 4px;
    color: var(--gray-500); font-size: 11px; padding: 2px 6px;
    cursor: pointer; margin-left: auto; flex-shrink: 0;
    opacity: 0; transition: opacity var(--transition-fast);
}
@media (hover: hover) {
    .option:hover .btn-strikethrough { opacity: 1; }
    .btn-strikethrough:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
}
.option.struck .btn-strikethrough { opacity: 1; }

.option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
    color: var(--gray-600);
    transition: all 0.15s;
}

.option.selected .option-letter { border-color: var(--primary); background: var(--primary); color: white; }
.option.correct .option-letter { border-color: var(--success); background: var(--success); color: white; }
.option.incorrect .option-letter { border-color: var(--danger); background: var(--danger); color: white; }

.option-text { flex: 1; padding-top: 2px; }

/* Multi-select indicator */
.multi-select-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    margin-bottom: 8px;
    background: var(--warning-light);
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: #92400e;
}
.multi-select-hint .hint-icon { font-size: 16px; }

/* Multi-select: square letter badges instead of circles */
.option.multi-select .option-letter {
    border-radius: 4px;
}
.option.multi-select.selected .option-letter::after {
    content: '\2713';
    position: absolute;
    font-size: 18px;
    font-weight: 700;
}
.option.multi-select .option-letter {
    position: relative;
}
.option.multi-select.selected .option-letter {
    font-size: 0;
}
.option.multi-select.selected .option-letter::after {
    font-size: 14px;
}
/* Partial credit indicator */
.partial-credit {
    color: #d97706;
    font-weight: 600;
}

/* Feedback Panel */
.feedback-panel {
    margin-top: 20px;
    border-radius: var(--radius);
    overflow: visible;
    border: 1px solid var(--gray-200);
    border-left: 4px solid var(--gray-300);
}
.feedback-panel:has(.feedback-header.correct) { border-left-color: var(--success); }
.feedback-panel:has(.feedback-header.incorrect) { border-left-color: var(--danger); }

.feedback-header {
    padding: 12px 18px;
    font-weight: 600;
    font-size: 14px;
}
.feedback-header.correct { background: var(--success-light); color: var(--success); }
.feedback-header.incorrect { background: var(--danger-light); color: var(--danger); }

.feedback-explanation {
    padding: 12px 14px;
    background: white;
    font-size: 14px;
    line-height: 1.7;
    color: var(--gray-700);
    border-top: 1px solid var(--gray-200);
}

.feedback-explanation .formula {
    display: block;
    text-align: center;
    margin: 8px 0;
    font-family: var(--font-mono);
    font-size: 14px;
    padding: 8px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.feedback-reference {
    padding: 10px 18px;
    background: var(--gray-50);
    font-size: 12px;
    color: var(--gray-500);
    border-top: 1px solid var(--gray-200);
}
.feedback-reference:empty {
    display: none;
}

/* Question Controls — sticky at bottom of scrollable question area */
.question-controls {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin-top: auto;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: var(--gray-50);
    z-index: 10;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.controls-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--gray-200);
}
.controls-actions .btn-sm {
    font-size: 12px;
    padding: 4px 10px;
}

.controls-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.controls-center {
    display: flex;
    gap: 12px;
}

/* ============ RESIZE HANDLES ============ */
.resize-handle {
    width: 5px;
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    background: transparent;
    transition: background var(--transition-fast);
}
.resize-handle:hover, .resize-handle.active {
    background: var(--primary);
    opacity: 0.4;
}
.resize-handle-ref.hidden { display: none; }

/* ============ REFERENCE PANEL ============ */
.reference-panel {
    width: 400px;
    background: white;
    border-left: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.ref-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    position: relative;
}

.ref-header h3 {
    font-size: 14px;
    flex: 1;
}

.btn-close-ref {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 1;
}
.btn-close-ref:hover { background: var(--danger-light); color: var(--danger); }

.ref-search {
    width: 100%;
    margin-top: 8px;
    padding: 6px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font-sans);
}

.ref-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--gray-200);
    padding: 8px;
    max-height: 140px;
    overflow-y: auto;
}

.ref-tab {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    white-space: nowrap;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    font-family: var(--font-sans);
    transition: all 0.15s;
    line-height: 1.4;
}
.ref-tab:hover { color: var(--gray-700); background: var(--gray-100); }
.ref-tab.active { color: white; background: var(--primary); border-color: var(--primary); }
.ref-search-badge {
    display: none;
    padding: 8px 16px;
    background: var(--primary-light);
    border-bottom: 1px solid var(--primary);
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    align-items: center;
    justify-content: space-between;
}
.ref-search-badge.visible { display: flex; }
.ref-search-badge .ref-clear-search {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-decoration: underline;
}

.ref-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-size: 13px;
    line-height: 1.7;
}

.ref-section h4 {
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--gray-200);
}

.ref-section {
    margin-bottom: 20px;
}

.ref-formula {
    font-family: var(--font-mono);
    background: var(--gray-50);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    margin: 4px 0;
    font-size: 13px;
    border-left: 3px solid var(--primary);
    transition: background 0.3s, box-shadow 0.3s;
}
.ref-formula.ref-highlight {
    background: #e8f0fe;
    box-shadow: 0 0 0 2px var(--primary), 0 2px 8px rgba(26,86,219,0.2);
    border-left-color: var(--primary);
}
body.dark-mode .ref-formula.ref-highlight {
    background: #1e2a4a;
    box-shadow: 0 0 0 2px #6d9efc, 0 2px 8px rgba(109,158,252,0.25);
}

.ref-formula-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 8px;
}

/* ============ CALCULATOR ============ */
.calculator-modal {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 390px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    border: 1px solid var(--gray-200);
}

.calc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--gray-800);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    font-size: 13px;
    font-weight: 600;
    cursor: move;
}

.calc-mode-indicator {
    background: #f59e0b;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
}

.calc-body { padding: 10px; position: relative; }

/* Two-line display */
.calc-display-wrap {
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 8px;
    min-height: 58px;
    font-family: var(--font-mono);
    text-align: right;
}
.calc-expr {
    font-size: 13px;
    color: var(--gray-500);
    overflow-x: auto;
    white-space: nowrap;
    min-height: 18px;
    scrollbar-width: none;
}
.calc-expr::-webkit-scrollbar { display: none; }
.calc-result {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-800);
    min-height: 26px;
    overflow-x: auto;
    white-space: nowrap;
}

/* Mode tabs */
.calc-mode-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 6px;
}
.calc-mode-tab {
    flex: 1;
    padding: 4px 2px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.1s;
    text-align: center;
    color: var(--gray-600);
}
.calc-mode-tab:hover { background: var(--gray-100); }
.calc-mode-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Base mode controls */
.calc-base-controls { margin-bottom: 6px; }
.calc-base-select {
    display: flex;
    gap: 3px;
    margin-bottom: 4px;
}
.calc-base-btn {
    flex: 1;
    padding: 4px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: var(--gray-700);
}
.calc-base-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.calc-hex-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
    margin-bottom: 4px;
}
.calc-hex-btn {
    padding: 5px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: #f0f4ff;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.calc-hex-btn:disabled { opacity: 0.3; cursor: default; }
.calc-bitwise-row {
    display: flex;
    gap: 3px;
}
.calc-bitwise-row button {
    flex: 1;
    padding: 4px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: #f0f4ff;
    color: var(--primary);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
}

/* Button grid */
.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
}
.calc-buttons.calc-buttons-6col {
    grid-template-columns: repeat(6, 1fr);
}
.calc-buttons button {
    padding: 7px 3px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: white;
    font-family: var(--font-sans);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.1s;
    min-height: 34px;
}
.calc-buttons button:hover { background: var(--gray-100); }
.calc-buttons button.calc-op { background: var(--gray-100); font-weight: 600; font-size: 14px; }
.calc-buttons button.calc-fn { background: #f0f4ff; color: var(--primary); font-size: 11px; }
.calc-buttons button.calc-fn:hover { background: #dbe4ff; }
.calc-buttons button.calc-2nd { background: #fef3c7; color: #b45309; font-weight: 700; }
.calc-buttons button.calc-2nd:hover { background: #fde68a; }
.calc-buttons button.calc-clear { background: var(--danger-light); color: var(--danger); font-weight: 600; }
.calc-buttons button.calc-clear:hover { background: #fca5a5; }
.calc-buttons button.calc-eq { background: var(--primary); color: white; font-weight: 600; font-size: 16px; }
.calc-buttons button.calc-eq:hover { background: var(--primary-dark); }
.calc-buttons button:disabled { opacity: 0.3; cursor: default; }

/* Mode panels (STAT, Matrix, Solver) */
.calc-mode-panel {
    padding: 8px 0;
    font-size: 12px;
}

/* STAT panel */
.calc-stat-header { display: flex; gap: 4px; margin-bottom: 8px; }
.calc-stat-type-btn {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 12px;
    cursor: pointer;
}
.calc-stat-type-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.calc-stat-data {
    max-height: 120px;
    overflow-y: auto;
    margin-bottom: 6px;
}
.calc-stat-empty {
    text-align: center;
    color: var(--gray-500);
    padding: 12px;
    font-size: 11px;
}
.calc-stat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: var(--font-mono);
}
.calc-stat-table th, .calc-stat-table td {
    padding: 3px 6px;
    border: 1px solid var(--gray-200);
    text-align: center;
}
.calc-stat-table th { background: var(--gray-50); font-size: 10px; }
.calc-stat-actions {
    display: flex;
    gap: 4px;
}
.calc-stat-actions button {
    flex: 1;
    padding: 5px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 11px;
    cursor: pointer;
}
.calc-stat-actions button:hover { background: var(--gray-100); }
.calc-stat-go { background: var(--primary) !important; color: white !important; border-color: var(--primary) !important; }
.calc-stat-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 8px;
}
.calc-stat-results-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--gray-100);
}
.calc-stat-results-table td:first-child { font-weight: 600; color: var(--gray-600); }
.calc-stat-results-table td:last-child { text-align: right; font-family: var(--font-mono); }

/* Matrix panel */
.calc-matrix-select-title, .calc-matrix-ops-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 4px;
}
.calc-matrix-select { margin-bottom: 10px; }
.calc-matrix-pick {
    display: block;
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 3px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
}
.calc-matrix-pick:hover { background: var(--gray-50); }
.calc-matrix-ops {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}
.calc-matrix-ops button {
    flex: 1;
    padding: 5px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: #f0f4ff;
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.calc-matrix-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
}
.calc-matrix-size select {
    padding: 2px 4px;
    border: 1px solid var(--gray-300);
    border-radius: 3px;
    font-size: 11px;
}
.calc-matrix-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 6px;
}
.calc-mat-cell {
    width: 100%;
    padding: 4px;
    border: 1px solid var(--gray-300);
    border-radius: 3px;
    text-align: center;
    font-size: 12px;
    font-family: var(--font-mono);
}
.calc-matrix-actions {
    display: flex;
    gap: 4px;
}
.calc-matrix-actions button {
    flex: 1;
    padding: 5px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 11px;
    cursor: pointer;
}
.calc-matrix-actions button:hover { background: var(--gray-100); }

/* Solver panel */
.calc-solver-header {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}
.calc-solver-help {
    font-size: 10px;
    color: var(--gray-500);
    margin-bottom: 4px;
}
.calc-solver-input {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.calc-solver-input label {
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}
.calc-solver-field {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 13px;
}
.calc-solver-result { margin: 8px 0; }
.calc-solver-answer {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    font-family: var(--font-mono);
}
.calc-solver-iters { font-size: 10px; color: var(--gray-500); }
.calc-solver-warn { font-size: 11px; color: var(--danger); margin-bottom: 4px; }
.calc-solver-actions {
    display: flex;
    gap: 4px;
}
.calc-solver-actions button {
    flex: 1;
    padding: 6px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 12px;
    cursor: pointer;
}
.calc-solver-go { background: var(--primary) !important; color: white !important; border-color: var(--primary) !important; }

/* Memory panel */
.calc-memory-panel {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.97);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.calc-mem-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.calc-mem-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    width: 100%;
    max-width: 280px;
    margin-bottom: 10px;
}
.calc-mem-btn {
    padding: 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}
.calc-mem-btn:hover { background: var(--gray-50); }
.calc-mem-val {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    font-weight: 400;
    font-family: var(--font-mono);
}
.calc-mem-close {
    padding: 6px 20px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    font-size: 12px;
}
.calc-memory-panel.hidden { display: none; }

/* ============ RESULTS SCREEN ============ */
.results-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px;
}

.results-header {
    text-align: center;
    margin-bottom: 40px;
}

.results-header h1 {
    font-size: 28px;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

.score-circle {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 24px;
}

.score-circle svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-bg {
    fill: none;
    stroke: var(--gray-200);
    stroke-width: 8;
}

.score-fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 1.5s ease;
}

.score-fill.pass { stroke: var(--success); }
.score-fill.fail { stroke: var(--danger); }

.score-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-pct {
    font-size: 36px;
    font-weight: 700;
    color: var(--gray-800);
}

.score-label {
    font-size: 13px;
    color: var(--gray-500);
}

.score-summary {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 16px;
}

.summary-stat { text-align: center; }

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pass-indicator {
    font-size: 16px;
    font-weight: 600;
    padding: 8px 24px;
    border-radius: 20px;
    display: inline-block;
}
.pass-indicator.pass { background: var(--success-light); color: var(--success); }
.pass-indicator.fail { background: var(--danger-light); color: var(--danger); }

/* Results Breakdown */
.results-breakdown {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.results-breakdown h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.breakdown-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
}
.breakdown-row:last-child { border-bottom: none; }

.breakdown-topic {
    width: 200px;
    font-weight: 500;
    color: var(--gray-700);
}

.breakdown-bar-wrap {
    flex: 1;
    margin: 0 16px;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.breakdown-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease;
}
.breakdown-bar.good { background: var(--success); }
.breakdown-bar.ok { background: var(--warning); }
.breakdown-bar.bad { background: var(--danger); }

.breakdown-score {
    width: 80px;
    text-align: right;
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 13px;
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
}

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.modal p {
    color: var(--gray-600);
    font-size: 14px;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}


/* ============ KEYBOARD SHORTCUTS MODAL ============ */
.shortcuts-modal { max-width: 380px; }
.shortcuts-section { margin-bottom: 16px; }
.shortcuts-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--gray-200);
}
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 13px;
}
.shortcut-row span {
    margin-left: auto;
    color: var(--gray-600);
}
.shortcut-row kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 24px;
    padding: 0 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    box-shadow: 0 1px 0 var(--gray-300);
    color: var(--gray-700);
}

/* ============ NCEES IMPORT MODAL ============ */
.ncees-modal {
    max-width: 560px;
}

.ncees-modal p {
    margin-bottom: 16px;
}

.ncees-topic-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding-right: 4px;
}

.ncees-topic-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ncees-topic-name {
    flex: 1;
    font-size: 13px;
    color: var(--gray-700);
    min-width: 0;
}

.ncees-topic-input {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
}

.ncees-topic-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.ncees-topic-bar {
    width: 80px;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.ncees-topic-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.2s ease;
}

.ncees-scale-note {
    font-size: 12px;
    color: var(--gray-500);
    text-align: center;
    margin-bottom: 12px;
}

/* ============ TOAST NOTIFICATIONS ============ */
.toast-notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(24px) scale(0.92);
    background: var(--gray-800);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
    backdrop-filter: blur(8px);
}

.toast-notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}
.toast-notification.toast-badge {
    background: linear-gradient(135deg, #1e3a5f, #1a56db);
    border: 1px solid rgba(255,255,255,0.15);
    font-size: 15px;
    padding: 14px 28px;
}
body.dark-mode .toast-notification {
    background: #e8eaf4;
    color: #0c0e16;
}
body.dark-mode .toast-notification.toast-badge {
    background: linear-gradient(135deg, #312e81, #4338ca);
    color: #e8eaf4;
}

.ncees-existing-note {
    background: var(--warning-light, #fef3c7);
    border: 1px solid #fbbf24;
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 12px;
    color: #92400e;
    margin-bottom: 12px;
}

/* ============ ANALYTICS DASHBOARD ============ */
.analytics-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.analytics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.analytics-header h3 {
    font-size: 18px;
    color: var(--gray-800);
    margin: 0;
}

.analytics-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.analytics-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.analytics-empty h3 {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.analytics-no-data {
    color: var(--gray-500);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.analytics-subtitle {
    color: var(--gray-500);
    font-size: 13px;
    margin: -8px 0 12px;
}

/* --- Summary stat cards --- */
.analytics-summary {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.analytics-stat-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.analytics-stat-icon { font-size: 20px; }
.analytics-stat-value { font-size: 20px; font-weight: 700; color: var(--gray-800); }
.analytics-stat-label { font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Layout rows --- */
.analytics-row {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 16px;
    margin-bottom: 16px;
}

.analytics-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.analytics-card h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 12px;
}

.analytics-chart {
    width: 100%;
    height: auto;
}

/* --- Streak calendar --- */
.analytics-calendar { margin-bottom: 0; }

.streak-calendar-svg {
    width: 100%;
    height: auto;
}

.streak-calendar-svg .cal-month {
    font-size: 9px;
    fill: var(--gray-500);
    font-family: 'Inter', sans-serif;
}

.streak-calendar-svg .cal-day {
    font-size: 9px;
    fill: var(--gray-400);
    font-family: 'Inter', sans-serif;
}

.cal-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 8px;
    font-size: 11px;
    color: var(--gray-500);
}

.cal-legend-box {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.cal-legend-label { font-size: 11px; }

/* --- Daily goal ring --- */
.analytics-goal-ring {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.goal-ring-container { width: 130px; height: 130px; }
.goal-ring-svg { width: 100%; height: 100%; }

.goal-ring-count {
    font-size: 24px;
    font-weight: 700;
    fill: var(--gray-800);
    font-family: 'Inter', sans-serif;
}

.goal-ring-label {
    font-size: 11px;
    fill: var(--gray-500);
    font-family: 'Inter', sans-serif;
}

.goal-ring-progress {
    transition: stroke-dashoffset 0.6s ease;
}

.goal-ring-stats {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.goal-ring-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.goal-ring-stat-val { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.goal-ring-stat-lbl { font-size: 10px; color: var(--gray-500); }

/* --- SVG chart axis labels --- */
.axis-label {
    font-size: 9px;
    fill: var(--gray-400);
    font-family: 'Inter', sans-serif;
}

.pass-label {
    font-size: 9px;
    fill: #22c55e;
    font-family: 'Inter', sans-serif;
}

/* --- Topic heatmap --- */
.heatmap-legend {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.heatmap-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--gray-500);
}

.heatmap-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.heatmap-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.heatmap-row {
    display: grid;
    grid-template-columns: 200px 1fr 50px 50px;
    align-items: center;
    gap: 8px;
}

.heatmap-topic {
    font-size: 12px;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.heatmap-bar-container {
    height: 14px;
    background: var(--gray-100);
    border-radius: 4px;
    position: relative;
    overflow: visible;
}

.heatmap-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
    min-width: 0;
}

.heatmap-baseline-marker {
    position: absolute;
    top: -3px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--gray-600);
    transform: translateX(-5px);
}

.heatmap-pct {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    text-align: right;
}

.heatmap-count {
    font-size: 11px;
    color: var(--gray-400);
    text-align: right;
}

.heatmap-baseline-legend {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 8px;
    text-align: right;
}

/* --- Gap analysis table --- */
.gap-table {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gap-header {
    display: grid;
    grid-template-columns: 1fr 60px 60px 60px 60px;
    gap: 8px;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
}

.gap-row {
    display: grid;
    grid-template-columns: 1fr 60px 60px 60px 60px;
    gap: 8px;
    padding: 6px 8px;
    font-size: 13px;
    border-radius: var(--radius);
    align-items: center;
}

.gap-col-topic {
    font-size: 12px;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gap-col {
    text-align: center;
    font-size: 12px;
    color: var(--gray-600);
}

.gap-positive { color: #22c55e !important; font-weight: 600; }
.gap-negative { color: #ef4444 !important; font-weight: 600; }
.gap-neutral { color: var(--gray-400) !important; }

.gap-row-high { background: rgba(239, 68, 68, 0.06); }
.gap-row-med { background: rgba(245, 158, 11, 0.06); }
.gap-row-low { background: transparent; }

/* --- Badge shelf --- */
.badge-shelf {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    text-align: center;
    position: relative;
    transition: transform 0.15s ease;
}

.badge-item:hover { transform: translateY(-2px); }

.badge-earned {
    background: linear-gradient(135deg, #fefce8, #fef9c3);
    border-color: #fbbf24;
    box-shadow: 0 1px 4px rgba(251, 191, 36, 0.25);
}

.badge-earned .badge-icon {
    animation: badge-pop 0.5s ease-out;
}

@keyframes badge-pop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.badge-locked {
    background: var(--gray-50);
    opacity: 0.45;
    filter: grayscale(0.85);
}

.badge-icon { font-size: 28px; line-height: 1; }

.badge-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-700);
}

.badge-lock {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 10px;
}

/* Badge tiers */
.badge-tier-section { margin-bottom: 16px; }
.badge-tier-header {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px 0;
    padding: 4px 0;
    border-bottom: 1px solid var(--gray-200);
}
.badge-tier-bronze .badge-tier-header,
.badge-tier-header.badge-tier-bronze { color: #b45309; }
.badge-tier-header.badge-tier-silver { color: #6b7280; }
.badge-tier-header.badge-tier-gold { color: #d97706; }
.badge-tier-header.badge-tier-guarantee { color: #059669; }

.badge-earned.badge-bronze {
    background: linear-gradient(135deg, #fef3c7, #fed7aa);
    border-color: #f59e0b;
}
.badge-earned.badge-silver {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-color: #94a3b8;
    box-shadow: 0 1px 4px rgba(148, 163, 184, 0.3);
}
.badge-earned.badge-gold {
    background: linear-gradient(135deg, #fefce8, #fef9c3);
    border-color: #eab308;
    box-shadow: 0 1px 6px rgba(234, 179, 8, 0.35);
}
.badge-earned.badge-guarantee {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border-color: #10b981;
    box-shadow: 0 1px 4px rgba(16, 185, 129, 0.3);
}
.badge-earned.badge-guarantee.badge-culmination {
    background: linear-gradient(135deg, #d1fae5, #6ee7b7, #34d399);
    border-color: #059669;
    box-shadow: 0 2px 12px rgba(5, 150, 105, 0.4);
    animation: badge-glow-green 2s ease-in-out infinite alternate;
}
@keyframes badge-glow {
    from { box-shadow: 0 2px 12px rgba(217, 119, 6, 0.3); }
    to { box-shadow: 0 4px 20px rgba(217, 119, 6, 0.6); }
}
@keyframes badge-glow-green {
    from { box-shadow: 0 2px 12px rgba(5, 150, 105, 0.3); }
    to { box-shadow: 0 4px 20px rgba(5, 150, 105, 0.6); }
}

/* Tier indicator dot */
.badge-tier-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
}
.badge-tier-dot.tier-bronze { background: #f59e0b; }
.badge-tier-dot.tier-silver { background: #94a3b8; }
.badge-tier-dot.tier-gold { background: #eab308; }
.badge-tier-dot.tier-guarantee { background: #10b981; }

/* --- Analytics responsive --- */
@media (max-width: 768px) {
    .analytics-summary { grid-template-columns: repeat(3, 1fr); }
    .analytics-row { grid-template-columns: 1fr; }
    .heatmap-row { grid-template-columns: 120px 1fr 40px 40px; }
    .gap-header,
    .gap-row { grid-template-columns: 1fr 50px 50px 50px 50px; font-size: 11px; }
    .badge-shelf { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}

@media (max-width: 480px) {
    .analytics-summary { grid-template-columns: repeat(2, 1fr); }
    .heatmap-row { grid-template-columns: 100px 1fr 35px; }
    .heatmap-count { display: none; }
    .gap-header,
    .gap-row { grid-template-columns: 1fr 45px 45px 45px; }
    .gap-col:last-child { display: none; }
}

/* ============ UNLIMITED MODE ============ */
.btn-unlimited-next {
    margin-left: auto;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(26, 86, 219, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(26, 86, 219, 0); }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ============ KATEX FORMULA STYLING ============ */
.formula-expr .katex { font-size: 1.1em; }
.ref-content .katex-display { margin: 8px 0; }

/* ============ USER PROFILE / DASHBOARD ============ */
.profile-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    width: 100%;
}

.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.profile-header h3 {
    font-size: 18px;
    color: var(--gray-800);
    margin: 0;
}

/* --- Backup reminder --- */
.backup-reminder {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #eff6ff;
    border: 1px solid #93c5fd;
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #1e40af;
}

.backup-reminder-icon { font-size: 20px; flex-shrink: 0; }
.backup-reminder-text { flex: 1; }
.btn-dismiss-backup { color: var(--gray-500) !important; background: transparent !important; border: none !important; font-size: 12px; }
.btn-dismiss-backup:hover { color: var(--gray-700) !important; }

.profile-streak-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    font-weight: 600;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #fbbf24;
    white-space: nowrap;
}

.daily-progress {
    font-size: 13px;
    color: var(--gray-500);
    white-space: nowrap;
}

.profile-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Cloud Sync */
.btn-sync {
    background: var(--primary);
    color: #fff;
    border: none;
    font-weight: 600;
}
.btn-sync:hover { background: var(--primary-dark); }
.btn-sync.syncing {
    opacity: 0.7;
    pointer-events: none;
}
.sync-status {
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
}
.sync-status.sync-ok { color: #16a34a; }
.sync-status.sync-err { color: #dc2626; }

.profile-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 0;
}

.profile-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--transition-fast), border-color var(--transition-normal), background var(--transition-fast);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-family: var(--font-sans);
}

.profile-tab:hover {
    color: var(--gray-700);
    background: var(--gray-50);
}

.profile-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.profile-tab-content {
    width: 100%;
    min-width: 0;
}
.profile-tab-content.hidden {
    display: none;
}

.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.profile-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    flex: 1;
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    border: 1px solid var(--gray-200);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Topic Strength Grid */
.topic-strength-grid {
    margin-bottom: 20px;
}

.strength-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 11px;
    color: var(--gray-500);
}

.strength-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.strength-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.strength-dot.strength-strong { background: var(--success); }
.strength-dot.strength-moderate { background: var(--warning); }
.strength-dot.strength-weak { background: var(--danger); }
.strength-dot.strength-unseen { background: var(--gray-300); }

.strength-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.strength-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    border-left: 4px solid transparent;
    transition: background 0.15s;
}

.strength-item:hover {
    background: var(--gray-50);
}

.strength-item.strength-strong {
    background: rgba(22, 163, 74, 0.08);
    border-left-color: var(--success);
}

.strength-item.strength-moderate {
    background: rgba(245, 158, 11, 0.08);
    border-left-color: var(--warning);
}

.strength-item.strength-weak {
    background: rgba(220, 38, 38, 0.08);
    border-left-color: var(--danger);
}

.strength-item.strength-unseen {
    background: var(--gray-50);
    border-left-color: var(--gray-300);
    color: var(--gray-400);
}

.strength-topic-name {
    font-weight: 500;
    color: var(--gray-700);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.strength-item.strength-unseen .strength-topic-name {
    color: var(--gray-400);
}

.strength-pct {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--gray-500);
    margin-left: 8px;
    flex-shrink: 0;
}
.strength-baseline {
    font-size: 10px;
    color: var(--gray-400);
    margin-left: 6px;
    flex-shrink: 0;
}
body.dark-mode .strength-baseline { color: #6b7094; }

/* Recommendations */
.recommendations {
    margin-top: 4px;
}

.recommendations h4 {
    font-size: 14px;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.rec-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    font-size: 13px;
    transition: background 0.15s, box-shadow 0.15s;
}
.rec-card[onclick] {
    cursor: pointer;
}
.rec-card[onclick]:hover {
    box-shadow: var(--shadow-sm);
    filter: brightness(0.97);
}
.rec-arrow {
    font-size: 20px;
    color: var(--gray-400);
    margin-left: auto;
    flex-shrink: 0;
    font-weight: 600;
}

.rec-card.rec-weak {
    background: rgba(220, 38, 38, 0.04);
    border-color: rgba(220, 38, 38, 0.2);
}

.rec-card.rec-unseen {
    background: rgba(37, 99, 235, 0.04);
    border-color: rgba(37, 99, 235, 0.2);
}

.rec-card.rec-flagged {
    background: rgba(245, 158, 11, 0.04);
    border-color: rgba(245, 158, 11, 0.2);
}

.rec-card.rec-review {
    background: rgba(147, 51, 234, 0.04);
    border-color: rgba(147, 51, 234, 0.2);
}

.rec-card.rec-good {
    background: rgba(22, 163, 74, 0.04);
    border-color: rgba(22, 163, 74, 0.2);
}

.rec-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
}

.rec-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rec-text strong {
    font-size: 13px;
    color: var(--gray-800);
}

.rec-detail {
    font-size: 12px;
    color: var(--gray-600);
}

.rec-action {
    font-size: 11px;
    color: var(--gray-400);
}

.rec-empty {
    color: var(--gray-400);
    font-size: 13px;
    text-align: center;
    padding: 16px 0;
}

/* ============ WEAK AREAS MODE CARD ============ */
.mode-card[data-mode="weakareas"] {
    border: 2px solid transparent;
}
.mode-card[data-mode="weakareas"]:hover {
    border-color: var(--danger);
}

/* ============ FLAG FOR PRACTICE BUTTON ============ */
.btn-flag-practice {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-flag-practice:hover {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--gray-800);
}
.btn-flag-practice.flagged-for-practice {
    background: var(--warning-light);
    border-color: var(--warning);
    color: #92400e;
    font-weight: 600;
}

/* ============ RESULTS WEAK AREAS ============ */
.results-weak-areas {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border-left: 4px solid var(--danger);
}

.results-weak-areas h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--gray-800);
}

.weak-topics-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.weak-topic-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.weak-topic-name {
    font-weight: 500;
    color: var(--gray-700);
}

.weak-topic-pct {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--danger);
    font-weight: 600;
}

/* ============ RESPONSIVE UPDATES ============ */
@media (max-width: 1024px) {
    .mode-cards { grid-template-columns: repeat(2, 1fr); }
    .strength-items { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .mode-cards { grid-template-columns: 1fr; }
    .topic-grid { grid-template-columns: repeat(2, 1fr); }
    .question-nav { display: none; }
    .reference-panel { width: 100%; position: absolute; right: 0; top: 52px; bottom: 0; z-index: 50; }
    .question-area { padding: 16px 20px; }
    .score-summary { gap: 20px; }
    .profile-stats { flex-wrap: wrap; }
    .stat-card { min-width: calc(50% - 8px); }
    .strength-items { grid-template-columns: 1fr; }
    .profile-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .profile-actions { flex-wrap: wrap; }
}

/* ============ ENHANCED FEEDBACK WALKTHROUGH ============ */
.feedback-pattern {
    background: #f0f4ff;
    border-left: 4px solid #4f46e5;
    padding: 10px 14px;
    margin: 0;
    border-radius: 0;
}
.feedback-pattern .pattern-name {
    font-weight: 700;
    color: #4f46e5;
    font-size: 15px;
}
.feedback-pattern .pattern-keywords {
    margin-top: 6px;
    color: #6b7280;
    font-size: 13px;
}
.feedback-pattern .pattern-keywords span {
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 12px;
    margin-right: 6px;
    font-family: var(--font-mono);
    display: inline-block;
    margin-top: 4px;
}

.feedback-steps {
    margin: 0;
    padding: 12px 14px;
    background: #f9fafb;
    border-top: 1px solid var(--gray-200);
}
.feedback-steps h4 {
    margin-bottom: 8px;
    font-size: 14px;
    color: #374151;
}
.feedback-steps ol {
    margin: 0;
    padding-left: 20px;
}
.feedback-steps ol li {
    margin-bottom: 6px;
    line-height: 1.5;
    font-size: 14px;
    color: var(--gray-700);
}

.feedback-handbook {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 8px 14px;
    background: #fff7ed;
    border-top: 1px solid var(--gray-200);
    font-size: 13px;
}
.feedback-handbook .handbook-icon { font-size: 18px; }
.feedback-handbook .handbook-section { font-weight: 600; color: #9a3412; }

.feedback-calculator {
    margin: 0;
    padding: 8px 14px;
    background: #f0fdf4;
    border-top: 1px solid var(--gray-200);
    font-size: 13px;
    color: var(--gray-700);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.feedback-calculator .calc-icon { font-size: 16px; margin-right: 6px; }

.controls-actions .btn-flag-practice.flagged-for-practice,
.btn-flag-practice.flagged-for-practice {
    background: var(--success-light);
    color: var(--success);
    border-color: var(--success);
}

/* ============ SAVE PROBLEM BUTTON ============ */
.btn-save-problem {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-save-problem:hover {
    background: #fef3c7;
    border-color: #f59e0b;
    color: var(--gray-800);
}
.btn-save-problem.problem-saved {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
    font-weight: 600;
}

/* ============ SAVED PROBLEMS TAB ============ */
.saved-summary {
    margin-bottom: 12px;
    font-size: 15px;
    color: var(--gray-700);
}
.saved-topic-group {
    margin-bottom: 20px;
}
.saved-topic-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--gray-200);
}
.saved-topic-count {
    font-weight: 400;
    color: var(--gray-500);
}
.saved-problem-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 4px;
    background: var(--gray-50);
    border-radius: 6px;
    border: 1px solid var(--gray-200);
}
.saved-problem-stem {
    flex: 1;
    font-size: 13px;
    color: var(--gray-700);
    line-height: 1.4;
}
.saved-problem-meta {
    font-size: 11px;
    color: var(--gray-500);
    white-space: nowrap;
}
.btn-unsave {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
}
.btn-unsave:hover {
    background: #fee2e2;
    color: #dc2626;
}
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--gray-600);
}

/* Toast notification */
.feedback-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--gray-800);
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-sans);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 3000;
    pointer-events: none;
}
.feedback-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============ SVG DIAGRAMS ============ */
.diagram-placeholder {
    margin: 16px 0;
    text-align: center;
}
.fe-diagram {
    --diagram-bg: #ffffff;
    --diagram-voltage: #1a56db;
    --diagram-current: #dc2626;
    --diagram-value: #16a34a;
    --diagram-accent: #1a56db;
    --diagram-grid: #d1d5db;
    max-width: 500px;
    width: 100%;
    height: auto;
    margin: 0 auto;
    display: block;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--diagram-bg);
    padding: 12px;
    overflow: visible;
    color: #1f2937;
}
.feedback-panel .fe-diagram {
    max-width: 420px;
    margin: 12px auto;
}

/* ============ MOBILE RESPONSIVE ============ */

/* Prevent iOS zoom on input focus */
input, select, textarea { font-size: 16px; }

/* --- Phones (max-width: 479px) --- */
@media (max-width: 479px) {
    .landing-container { padding: 24px 12px; }
    .landing-header { padding: 24px 16px 20px; }
    .landing-header h1 { font-size: 22px; }
    .landing-header h2 { font-size: 15px; }
    .landing-subtitle { font-size: 12px; }
    .logo-mark { width: 52px; height: 52px; font-size: 20px; margin-bottom: 10px; }
    .mode-cards { grid-template-columns: 1fr; gap: 12px; }
    .mode-card { padding: 16px 14px; }
    .mode-icon { font-size: 24px; margin-bottom: 6px; }
    .mode-card h3 { font-size: 15px; }
    .mode-card p { font-size: 12px; }
    .question-area { padding: 12px 14px; }
    .question-text { font-size: 15px; }
    .answer-options { max-width: 100%; }
    .option { padding: 10px 12px; font-size: 14px; }
    .option-letter { width: 22px; height: 22px; font-size: 11px; }
    .profile-stats .stat-card { min-width: 100%; }
    .score-circle { width: 100px; height: 100px; }
    .topic-grid { grid-template-columns: 1fr; }
}

/* --- Small tablets / large phones (max-width: 639px) --- */
@media (max-width: 639px) {
    .landing-container { padding: 32px 14px; }
    .mode-cards { grid-template-columns: 1fr; gap: 14px; }
    .topic-grid { grid-template-columns: 1fr; }
    .profile-stats { flex-wrap: wrap; }
    .profile-stats .stat-card { min-width: calc(50% - 8px); }
}

/* --- Tablets and below (max-width: 768px) --- */
@media (max-width: 768px) {
    /* Exam header — wrap for mobile */
    .exam-header {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 4px;
    }
    .header-left { flex: 1; min-width: 0; overflow: hidden; }
    .header-left .exam-mode-badge { font-size: 10px; padding: 1px 6px; white-space: nowrap; }
    .header-center { order: 3; width: 100%; justify-content: center; padding: 4px 0; }
    .header-right { gap: 2px; flex-shrink: 0; }
    .exam-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .btn-icon { padding: 6px 8px; font-size: 12px; min-height: 40px; }
    .btn-end { font-size: 11px; }

    /* Question navigator — slide-out drawer on mobile */
    .question-nav {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 260px;
        max-width: 80vw;
        z-index: 200;
        background: var(--gray-50);
        border-right: 1px solid var(--gray-200);
        box-shadow: var(--shadow-lg);
        overflow-y: auto;
        display: none;
    }
    .question-nav.mobile-open {
        display: flex;
    }
    .btn-expand-nav:not(.hidden) {
        display: flex !important;
        position: fixed;
        left: 8px;
        top: 70px;
        bottom: auto;
        z-index: 199;
        width: auto;
        height: 40px;
        padding: 0 12px 0 10px;
        border-radius: 20px;
        font-size: 13px;
        gap: 4px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }

    /* Question area takes full width on mobile — no sidebar margin */
    .exam-body { flex-direction: column; flex: 1; overflow: hidden; margin-left: 0; }
    .question-area { flex: 1; width: 100%; min-width: 0; }
    .answer-options { max-width: 100%; }

    /* Hide resize handles on mobile */
    .resize-handle { display: none !important; }

    /* Reference panel — full-screen overlay on mobile */
    .reference-panel {
        position: fixed;
        width: 100%;
        max-width: 100%;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 250;
        border: none;
    }

    /* Calculator — bottom sheet on mobile */
    .calculator-modal {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        max-height: 65vh;
        border-radius: 16px 16px 0 0;
        z-index: 300;
    }
    .calc-buttons button { min-height: 44px; font-size: 13px; }

    /* Nav grid */
    .nav-grid { grid-template-columns: repeat(8, 1fr); gap: 3px; padding: 8px; }
    .nav-accordion-grid { grid-template-columns: repeat(8, 1fr); gap: 3px; padding: 6px 8px; }
    .nav-btn { min-height: 36px; font-size: 11px; }
    .nav-accordion-header { padding: 8px 10px; font-size: 11px; }
    .accordion-color { height: 20px; }

    /* Question controls — sticky bottom bar on mobile */
    .question-controls {
        margin: 0 -14px;
    }
    .controls-actions {
        padding: 6px 8px;
        gap: 4px;
        flex-wrap: wrap;
    }
    .controls-actions .btn-sm {
        font-size: 11px;
        padding: 4px 8px;
    }
    .controls-nav {
        padding: 10px 8px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
    }
    .controls-center { gap: 6px; flex-wrap: wrap; justify-content: center; }
    .btn-nav { padding: 8px 10px; font-size: 13px; }
    .btn-flag { padding: 8px 10px; font-size: 12px; min-width: 120px; }

    /* Exam body fills remaining space */
    .exam-body {
        flex: 1;
        min-height: 0;
    }
}

/* --- Mobile nav overlay backdrop --- */
.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}
.nav-backdrop.active {
    display: block;
}

/* --- Touch target minimums --- */
@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; padding: 8px 14px; }
    .option { min-height: 48px; }
    .nav-btn { min-height: 40px; }
    .calc-buttons button { min-height: 48px; }
    .btn-dark-toggle { width: 44px; height: 44px; }
    .ref-nav-btn { min-height: 40px; padding: 8px 10px; }
    .btn-filter { min-height: 36px; padding: 6px 8px; }
    .ref-tab { min-height: 36px; padding: 6px 10px; }
}

/* --- Diagram responsiveness --- */
.fe-diagram { max-width: 100%; }
@media (max-width: 479px) {
    .fe-diagram { max-width: 100%; border: none; padding: 4px; }
}

/* --- Legal footer --- */
.legal-footer {
    margin-top: 32px;
    padding: 20px 24px;
    text-align: center;
    font-size: 11px;
    color: var(--gray-400);
    border-top: 1px solid var(--gray-200);
    line-height: 1.6;
}
.legal-footer p { margin-bottom: 4px; }
.legal-footer a { color: var(--primary); text-decoration: none; }
.legal-footer a:hover { text-decoration: underline; }

/* --- Report Issue Modal --- */
.btn-report { color: var(--warning); border-color: var(--warning); }
.btn-report:hover { background: var(--warning-light); }
.report-modal { max-width: 440px; }
.report-question-id { font-size: 13px; color: var(--gray-500); margin-bottom: 12px; }
.report-types { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.report-type-option {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; cursor: pointer; padding: 6px 8px;
    border-radius: var(--radius-sm); transition: background 0.15s;
}
.report-type-option:hover { background: var(--gray-50); }
.report-type-option input[type="radio"] { accent-color: var(--primary); }
.report-textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300);
    border-radius: var(--radius); font-family: var(--font-sans); font-size: 14px;
    resize: vertical; background: var(--gray-50); color: var(--gray-800);
}
.report-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
.report-success { text-align: center; padding: 24px 16px; }
.report-success .check-icon { font-size: 48px; color: var(--success); margin-bottom: 8px; }
.report-success p { color: var(--gray-600); margin-top: 8px; }

/* Dark mode report modal */
body.dark-mode .report-type-option:hover { background: #222540; }
body.dark-mode .report-textarea { background: #0c0e16; border-color: #2a2e44; color: #e8eaf4; }
body.dark-mode .report-textarea:focus { border-color: #6d9efc; box-shadow: 0 0 0 3px rgba(109,158,252,0.15); }

/* Dark mode footer */
body.dark-mode .legal-footer { border-top-color: #2a2e44; }

/* ============ DARK MODE TOGGLE ============ */
.btn-dark-toggle {
    position: absolute;
    top: 16px;
    right: 20px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    font-size: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}
.btn-dark-toggle:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}
/* In exam header the toggle is inline, not absolute */
.header-right .btn-dark-toggle {
    position: static;
    width: 36px;
    height: 36px;
    font-size: 18px;
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #e2e8f0;
}
.header-right .btn-dark-toggle:hover {
    background: rgba(255,255,255,0.2);
}

/* ============ DARK MODE ============ */
body.dark-mode {
    --primary: #6d9efc;
    --primary-dark: #5b8dee;
    --primary-light: #1a2744;
    --success: #4ade80;
    --success-light: #12302a;
    --danger: #f87171;
    --danger-light: #381c1c;
    --warning: #fbbf24;
    --warning-light: #382e10;
    --gray-50: #0c0e16;
    --gray-100: #13151f;
    --gray-200: #1a1d2e;
    --gray-300: #2a2e44;
    --gray-400: #5a5e78;
    --gray-500: #8b8fa8;
    --gray-600: #b0b4cc;
    --gray-700: #d0d4e8;
    --gray-800: #e8eaf4;
    --gray-900: #f4f5fb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
    --shadow: 0 1px 3px rgba(0,0,0,0.45);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.45);
    color-scheme: dark;
}
body.dark-mode {
    background: #0c0e16;
    color: #e8eaf4;
}

/* Landing screen */
body.dark-mode .landing-container {
    background: #0c0e16;
}
body.dark-mode .landing-header {
    background: linear-gradient(135deg, #141624 0%, #0c0e16 100%);
}
body.dark-mode .mode-card {
    background: #13151f;
    border-color: #2a2e44;
}
body.dark-mode .mode-card:hover {
    border-color: #6d9efc;
    box-shadow: 0 4px 16px rgba(109,158,252,0.12);
}

/* Exam header */
body.dark-mode .exam-header {
    background: #0c0e16;
    border-bottom: 1px solid #2a2e44;
}

/* Question area */
body.dark-mode .question-area {
    background: #13151f;
}
body.dark-mode .question-content {
    color: #e8eaf4;
}

/* Options */
body.dark-mode .option {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}
@media (hover: hover) {
    body.dark-mode .option:hover:not(.disabled) {
        background: #222540;
        border-color: #6d9efc;
    }
}
body.dark-mode .option.selected {
    background: #1a2744;
    border-color: #6d9efc;
    box-shadow: 0 0 0 1px #6d9efc;
}
body.dark-mode .btn-strikethrough { border-color: #2a2e44; color: #6b7094; }
body.dark-mode .btn-strikethrough:hover { background: #3b1c1c; color: #f87171; border-color: #f87171; }
body.dark-mode .option.struck { opacity: 0.35; }
body.dark-mode .option.correct {
    background: #14332a;
    border-color: #4ade80;
}
body.dark-mode .option.incorrect {
    background: #3b1c1c;
    border-color: #f87171;
}
body.dark-mode .option-letter {
    background: #2a2e44;
    color: #b0b4cc;
}

/* Feedback panel */
body.dark-mode .feedback-panel {
    background: #181a28;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .feedback-pattern,
body.dark-mode .feedback-steps,
body.dark-mode .feedback-handbook,
body.dark-mode .feedback-calculator,
body.dark-mode .feedback-explanation {
    border-top-color: #2a2e44;
}

/* Navigator */
body.dark-mode .question-nav {
    background: #0c0e16;
    border-color: #2a2e44;
}
body.dark-mode .nav-jump-row { border-bottom-color: #2a2e44; }
body.dark-mode .nav-jump-input { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .nav-accordion-header { border-bottom-color: #1a1d2e; color: #b0b4cc; }
body.dark-mode .nav-accordion-header:hover, body.dark-mode .nav-accordion-header.accordion-active { background: #181a2a; }
body.dark-mode .accordion-meta { color: #6b7094; }
body.dark-mode .accordion-chevron { color: #6b7094; }
body.dark-mode .nav-btn {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #b0b4cc;
}
body.dark-mode .nav-btn.current {
    border-color: #6d9efc;
    background: #1a2744;
}
body.dark-mode .nav-btn.answered {
    background: #12302a;
    border-color: #4ade80;
    color: #4ade80;
}
body.dark-mode .nav-btn.flagged {
    background: #382e10;
    border-color: #fbbf24;
}
body.dark-mode .nav-btn.correct {
    background: #12302a;
    border-color: #4ade80;
    color: #4ade80;
}
body.dark-mode .nav-btn.incorrect {
    background: #3b1c1c;
    border-color: #f87171;
    color: #f87171;
}

/* Reference panel */
body.dark-mode .resize-handle:hover, body.dark-mode .resize-handle.active { background: #6d9efc; opacity: 0.4; }
body.dark-mode .btn-close-ref { background: #2a2e44; color: #b0b4cc; }
body.dark-mode .btn-close-ref:hover { background: #3b1c1c; color: #f87171; }
body.dark-mode .reference-panel {
    background: #13151f;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .ref-nav-btn {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #b0b4cc;
}
body.dark-mode .ref-nav-btn.active,
body.dark-mode .ref-nav-btn:hover {
    background: #1a2744;
    border-color: #6d9efc;
    color: #6d9efc;
}
body.dark-mode .ref-formula {
    background: #1a1d2e;
    border-color: #2a2e44;
}
body.dark-mode .ref-tab {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #8b8fa8;
}
body.dark-mode .ref-tab:hover { background: #222540; color: #d0d4e8; }
body.dark-mode .ref-tab.active { background: #638cff; border-color: #638cff; color: #0c0e16; }
body.dark-mode .ref-search-badge {
    background: rgba(99,140,255,0.15);
    border-color: #638cff;
    color: #8bb4ff;
}
body.dark-mode .ref-clear-search { color: #8bb4ff; }

/* Calculator */
body.dark-mode .calculator-modal {
    background: #181a28;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .calc-display-wrap {
    background: #0c0e16;
    border-color: #2a2e44;
}
body.dark-mode .calc-expr { color: #8b8fa8; }
body.dark-mode .calc-result { color: #e8eaf4; }
body.dark-mode .calc-mode-tab { background: #1a1d2e; border-color: #2a2e44; color: #8b8fa8; }
body.dark-mode .calc-mode-tab:hover { background: #222540; }
body.dark-mode .calc-mode-tab.active { background: #6d9efc; color: #0c0e16; border-color: #6d9efc; }
body.dark-mode .calc-base-btn { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .calc-base-btn.active { background: #6d9efc; color: #0c0e16; border-color: #6d9efc; }
body.dark-mode .calc-hex-btn { background: #181a36; color: #a5b4fc; border-color: #2a2e44; }
body.dark-mode .calc-bitwise-row button { background: #181a36; color: #a5b4fc; border-color: #2a2e44; }
body.dark-mode .calc-buttons button {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .calc-buttons button:hover { background: #222540; }
body.dark-mode .calc-memory-panel { background: rgba(24,26,40,0.97); }
body.dark-mode .calc-mem-btn { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .calc-mem-val { color: #8b8fa8; }
body.dark-mode .calc-mem-close { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .calc-stat-type-btn { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .calc-stat-type-btn.active { background: #6d9efc; color: #0c0e16; }
body.dark-mode .calc-stat-table th { background: #1a1d2e; }
body.dark-mode .calc-stat-table th, body.dark-mode .calc-stat-table td { border-color: #2a2e44; }
body.dark-mode .calc-stat-actions button { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .calc-matrix-pick { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .calc-matrix-ops button { background: #181a36; color: #a5b4fc; border-color: #2a2e44; }
body.dark-mode .calc-matrix-actions button { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .calc-mat-cell { background: #0c0e16; color: #e8eaf4; border-color: #2a2e44; }
body.dark-mode .calc-solver-field { background: #0c0e16; color: #e8eaf4; border-color: #2a2e44; }
body.dark-mode .calc-solver-actions button { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }

/* Code blocks */
body.dark-mode pre,
body.dark-mode code {
    background: #0c0e16;
    color: #e8eaf4;
}

/* Scrollbars */
body.dark-mode ::-webkit-scrollbar-track {
    background: #13151f;
}
body.dark-mode ::-webkit-scrollbar-thumb {
    background: #2a2e44;
}

/* SVG diagrams */
body.dark-mode .fe-diagram {
    --diagram-bg: #1a1d2e;
    --diagram-voltage: #6d9efc;
    --diagram-current: #f87171;
    --diagram-value: #4ade80;
    --diagram-accent: #6d9efc;
    --diagram-grid: #3a3e58;
    background: var(--diagram-bg);
    border-color: #2a2e44;
    color: #e8eaf4;
}

/* Buttons */
body.dark-mode .btn {
    border-color: #2a2e44;
}
body.dark-mode .btn-primary {
    background: linear-gradient(135deg, #6d9efc 0%, #5b8dee 100%);
    color: #0c0e16;
    box-shadow: 0 1px 3px rgba(109,158,252,0.2);
}
body.dark-mode .btn-primary:hover { box-shadow: 0 4px 12px rgba(109,158,252,0.3); }
body.dark-mode .btn-secondary {
    background: #1a1d2e;
    color: #d0d4e8;
    border-color: #2a2e44;
}
body.dark-mode .btn-secondary:hover {
    background: #222540;
}
body.dark-mode .btn-icon {
    color: #b0b4cc;
}
body.dark-mode .btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

/* Topic filter */
body.dark-mode .nav-topic-filter select {
    background: #1a1d2e;
    color: #d0d4e8;
    border-color: #2a2e44;
}

/* Results screen */
body.dark-mode .results-container {
    background: #13151f;
    color: #d0d4e8;
}
body.dark-mode .stat-card {
    background: #1a1d2e;
    border-color: #2a2e44;
}

/* KaTeX in dark mode */
body.dark-mode .katex { color: #e8eaf4; }

/* Toggle button in dark mode */
body.dark-mode .btn-dark-toggle {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #fbbf24;
}

/* --- Step-by-step solution & calculator tips --- */
body.dark-mode .feedback-panel,
body.dark-mode .feedback-panel * {
    color: #d0d4e8;
}
body.dark-mode .feedback-panel h4,
body.dark-mode .feedback-panel strong {
    color: #e8eaf4;
}
body.dark-mode .feedback-correct { background: #14332a; color: #4ade80; border-color: #22543d; }
body.dark-mode .feedback-incorrect { background: #3b1c1c; color: #f87171; border-color: #7f1d1d; }

/* Feedback sub-section backgrounds (all hardcode light colors) */
body.dark-mode .feedback-explanation {
    background: #181a28;
    color: #d0d4e8;
    border-top-color: #2a2e44;
}
body.dark-mode .feedback-explanation .formula {
    background: #0c0e16;
    color: #d0d4e8;
}
body.dark-mode .feedback-pattern {
    background: #1a1d3a;
    border-left-color: #818cf8;
}
body.dark-mode .feedback-pattern .pattern-name {
    color: #a5b4fc;
}
body.dark-mode .feedback-pattern .pattern-keywords {
    color: #8b8fa8;
}
body.dark-mode .feedback-pattern .pattern-keywords span {
    background: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .feedback-steps {
    background: #13151f;
    border-top-color: #2a2e44;
}
body.dark-mode .feedback-steps h4 {
    color: #e8eaf4;
}
body.dark-mode .feedback-steps ol li {
    color: #d0d4e8;
}
body.dark-mode .feedback-handbook {
    background: #281e0e;
    border-top-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .feedback-handbook .handbook-section {
    color: #fb923c;
}
body.dark-mode .feedback-calculator {
    background: #0e1e16;
    border-top-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .feedback-reference {
    background: #13151f;
    color: #8b8fa8;
}
body.dark-mode .controls-actions {
    border-bottom-color: #2a2e44;
}
body.dark-mode .feedback-header.correct {
    background: #14332a;
    color: #4ade80;
}
body.dark-mode .feedback-header.incorrect {
    background: #3b1c1c;
    color: #f87171;
}

/* --- Difficulty badges --- */
body.dark-mode .difficulty-badge.easy { background: #14332a; color: #4ade80; }
body.dark-mode .difficulty-badge.medium { background: #3b2f0f; color: #fbbf24; }
body.dark-mode .difficulty-badge.hard { background: #3b1c1c; color: #f87171; }

/* --- Nav button states (answered, flagged, difficulty colors) --- */
body.dark-mode .nav-btn.diff-easy { border-left-color: #4ade80; }
body.dark-mode .nav-btn.diff-medium { border-left-color: #fbbf24; }
body.dark-mode .nav-btn.diff-hard { border-left-color: #f87171; }
body.dark-mode .dot-answered { background: #6d9efc; }
body.dark-mode .dot-flagged { background: #fbbf24; }
body.dark-mode .nav-btn.flagged { color: #fbbf24; }

/* --- Flag button --- */
body.dark-mode .btn-flag { background: #1a1d2e; border-color: #2a2e44; color: #b0b4cc; }
body.dark-mode .btn-flag:hover { background: #382e10; border-color: #fbbf24; color: #fbbf24; }
body.dark-mode .btn-flag.flagged { background: #382e10; border-color: #fbbf24; color: #fbbf24; }

/* --- Question controls --- */
body.dark-mode .question-controls { background: #13151f; border-color: #2a2e44; box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3); }

/* --- Profile / Your Progress section --- */
body.dark-mode .profile-section,
body.dark-mode .profile-card {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .profile-section h3,
body.dark-mode .profile-card h3 { color: #e8eaf4; }
body.dark-mode .profile-tabs { border-bottom-color: #2a2e44; }
body.dark-mode .profile-tab { color: #5c5f77; }
body.dark-mode .profile-tab:hover { color: #8b8fa8; }
body.dark-mode .profile-tab.active { color: #6b8afd; border-bottom-color: #6b8afd; }
body.dark-mode .stat-card {
    background: #222540;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .backup-reminder { background: #1a2544; border-color: #2a4878; color: #93c5fd; }
body.dark-mode .streak-badge {
    background: linear-gradient(135deg, #78350f, #92400e);
    color: #fde68a;
    border-color: #b45309;
}
body.dark-mode .daily-progress { color: #8b8fa8; }
body.dark-mode .stat-value { color: #e8eaf4; }
body.dark-mode .stat-label { color: #8b8fa8; }
body.dark-mode .progress-bar { background: #2a2e44; }
body.dark-mode .progress-fill { background: #6d9efc; }

/* --- Previous Results / History --- */
body.dark-mode .history-section {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .history-section h3 { color: #e8eaf4; }
body.dark-mode .history-item {
    background: #222540;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .history-item:hover { background: #2a2e44; }
body.dark-mode .history-date,
body.dark-mode .history-mode,
body.dark-mode .history-detail,
body.dark-mode .hist-details,
body.dark-mode .hist-date { color: #8b8fa8; }
body.dark-mode .history-pass.pass { background: #14332a; color: #4ade80; }
body.dark-mode .history-pass.fail { background: #3b1c1c; color: #f87171; }
body.dark-mode .history-review-btn {
    background: transparent;
    border-color: #6d9efc;
    color: #6d9efc;
}
body.dark-mode .history-review-btn:hover { background: #6d9efc; color: #0c0e16; }
body.dark-mode .history-delete-btn { color: #555a72; }
body.dark-mode .history-delete-btn:hover { color: #f87171; border-color: #f87171; }

/* --- Topic selection grid --- */
body.dark-mode .topic-item,
body.dark-mode .topic-checkbox {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .topic-item:hover,
body.dark-mode .topic-checkbox:hover { background: #222540; }
body.dark-mode .topic-count { color: #8b8fa8; }

/* --- Topic select / topic filter dropdown --- */
body.dark-mode .topic-select-container,
body.dark-mode .topic-select-grid {
    background: #13151f;
    color: #d0d4e8;
}

/* --- Score/results screen --- */
body.dark-mode .score-circle { background: #1a1d2e; border-color: #2a2e44; }
body.dark-mode .score-label { color: #8b8fa8; }
body.dark-mode .results-topic-bar { background: #2a2e44; }
body.dark-mode .results-topic-fill { background: #6d9efc; }

/* --- All white backgrounds to dark --- */
body.dark-mode .question-area,
body.dark-mode .question-content,
body.dark-mode .answer-options-container {
    background: #13151f;
}
body.dark-mode .question-controls {
    background: #13151f;
    border-top-color: #2a2e44;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

/* --- Review filter legend dots --- */
body.dark-mode .diff-dot.easy { background: #4ade80; }
body.dark-mode .diff-dot.medium { background: #fbbf24; }
body.dark-mode .diff-dot.hard { background: #f87171; }
body.dark-mode .review-diff-legend { color: #8b8fa8; }

/* --- Nav topic dividers --- */
body.dark-mode .nav-topic-divider { background: #2a2e44; color: #8b8fa8; }

/* --- Modals and overlays --- */
body.dark-mode .modal-overlay { background: rgba(0,0,0,0.7); }
body.dark-mode .modal-content {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}

/* --- General white bg catch-all --- */
body.dark-mode .landing-container { background: #0c0e16; }
body.dark-mode .mode-card h3 { color: #e8eaf4; }
body.dark-mode .mode-card p { color: #8b8fa8; }
body.dark-mode .landing-subtitle { color: #8b8fa8; }
body.dark-mode .ncees-badge { color: #5a5e78; }
body.dark-mode .landing-header h1 { color: #e8eaf4; }
body.dark-mode .landing-header h2 { color: #6d9efc; }
body.dark-mode .discipline-btn {
    border-color: #363a52;
    color: #8b8fa8;
}
body.dark-mode .discipline-btn:hover {
    border-color: #6d9efc;
    color: #6d9efc;
}
body.dark-mode .discipline-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
/* Dark mode per-discipline pill colors */
body.dark-mode .discipline-btn[data-discipline="ece"] { border-color: #1e3a5f; color: #60a5fa; }
body.dark-mode .discipline-btn[data-discipline="ece"]:hover { border-color: #60a5fa; color: #60a5fa; background: rgba(37,99,235,0.1); }
body.dark-mode .discipline-btn[data-discipline="ece"].active { background: #2563eb; border-color: #2563eb; color: white; }

body.dark-mode .discipline-btn[data-discipline="civil"] { border-color: #5c3d0e; color: #fbbf24; }
body.dark-mode .discipline-btn[data-discipline="civil"]:hover { border-color: #fbbf24; color: #fbbf24; background: rgba(245,158,11,0.1); }
body.dark-mode .discipline-btn[data-discipline="civil"].active { background: #f59e0b; border-color: #f59e0b; color: white; }

body.dark-mode .discipline-btn[data-discipline="mechanical"] { border-color: #5c1a1a; color: #f87171; }
body.dark-mode .discipline-btn[data-discipline="mechanical"]:hover { border-color: #f87171; color: #f87171; background: rgba(220,38,38,0.1); }
body.dark-mode .discipline-btn[data-discipline="mechanical"].active { background: #dc2626; border-color: #dc2626; color: white; }

body.dark-mode .discipline-btn[data-discipline="chemical"] { border-color: #14532d; color: #4ade80; }
body.dark-mode .discipline-btn[data-discipline="chemical"]:hover { border-color: #4ade80; color: #4ade80; background: rgba(22,163,74,0.1); }
body.dark-mode .discipline-btn[data-discipline="chemical"].active { background: #16a34a; border-color: #16a34a; color: white; }

body.dark-mode .discipline-btn[data-discipline="environmental"] { border-color: #164e63; color: #22d3ee; }
body.dark-mode .discipline-btn[data-discipline="environmental"]:hover { border-color: #22d3ee; color: #22d3ee; background: rgba(8,145,178,0.1); }
body.dark-mode .discipline-btn[data-discipline="environmental"].active { background: #0891b2; border-color: #0891b2; color: white; }

body.dark-mode .disc-group-label { color: #6b7094; }
body.dark-mode .disc-group-pe { color: #a78bfa; }
body.dark-mode .discipline-btn-pe { border-color: #4c3d80; color: #a78bfa; }
body.dark-mode .discipline-btn-pe:hover { border-color: #a78bfa; color: #a78bfa; background: rgba(124,58,237,0.1); }
body.dark-mode .discipline-btn-pe.active { background: #7c3aed; border-color: #7c3aed; color: white; }
body.dark-mode .btn-switch-discipline { color: #5a5e78; }
body.dark-mode .btn-switch-discipline:hover { color: #8b8fa8; }

/* --- Remaining white backgrounds --- */
body.dark-mode .topic-select-panel,
body.dark-mode .refresher-panel {
    background: #1a1d2e;
    color: #d0d4e8;
}
body.dark-mode .topic-select-panel h3,
body.dark-mode .refresher-panel h3 { color: #e8eaf4; }
body.dark-mode .refresher-topic { background: #14161f; }
body.dark-mode .refresher-stage { background: #222540; color: #8b8fa8; }
body.dark-mode .refresher-stage.done { background: #052e16; color: #4ade80; }
body.dark-mode .refresher-subtitle,
body.dark-mode .refresher-info { color: #8b8fa8; }
body.dark-mode .question-text .formula {
    background: #0c0e16;
    color: #d0d4e8;
}
body.dark-mode .calc-buttons button.calc-op { background: #222540; color: #e8eaf4; }
body.dark-mode .calc-buttons button.calc-fn { background: #181a36; color: #a5b4fc; }
body.dark-mode .calc-buttons button.calc-fn:hover { background: #222548; }
body.dark-mode .calc-buttons button.calc-2nd { background: #3d2f0f; color: #fbbf24; }
body.dark-mode .calc-buttons button.calc-2nd:hover { background: #4a3812; }
body.dark-mode .calc-buttons button.calc-clear { background: #381c1c; color: #f87171; }
body.dark-mode .calc-buttons button.calc-clear:hover { background: #5a2020; }
body.dark-mode .calc-buttons button.calc-eq { background: #6d9efc; color: #0c0e16; }
body.dark-mode .calc-buttons button.calc-eq:hover { background: #5b8dee; }
body.dark-mode .results-breakdown {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .results-breakdown h2 { color: #e8eaf4; }
body.dark-mode .results-weak-areas {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .results-weak-areas h2 { color: #e8eaf4; }
body.dark-mode .btn-filter {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #b0b4cc;
}
body.dark-mode .btn-filter.active {
    background: #1a2744;
    border-color: #6d9efc;
    color: #6d9efc;
}
body.dark-mode .modal {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}

body.dark-mode .shortcut-row kbd {
    background: #2a2e44;
    border-color: #3a3e58;
    box-shadow: 0 1px 0 #3a3e58;
    color: #d0d4e8;
}
body.dark-mode .shortcuts-section-label {
    color: #8b8fa8;
    border-bottom-color: #2a2e44;
}
body.dark-mode .shortcut-row span { color: #9a9ec0; }

/* --- Dark mode gaps (audit fixes) --- */
body.dark-mode .pace-indicator {
    background: rgba(255,255,255,0.1);
    color: #b0b4cc;
}
body.dark-mode .rec-card {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .rec-card.rec-weak { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.25); }
body.dark-mode .rec-card.rec-unseen { background: rgba(109, 158, 252, 0.08); border-color: rgba(109, 158, 252, 0.25); }
body.dark-mode .rec-card.rec-flagged { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.25); }
body.dark-mode .rec-card.rec-review { background: rgba(167, 139, 250, 0.08); border-color: rgba(167, 139, 250, 0.25); }
body.dark-mode .rec-card.rec-good { background: rgba(74, 222, 128, 0.08); border-color: rgba(74, 222, 128, 0.25); }
body.dark-mode .rec-card-topic { color: #e8eaf4; }
body.dark-mode .multi-select-hint {
    background: #3b2f0f;
    border-color: #b45309;
    color: #fde68a;
}
body.dark-mode .feedback-toast {
    background: #e8eaf4;
    color: #0c0e16;
}

/* --- Saved problems dark mode --- */
body.dark-mode .saved-topic-label {
    color: #e8eaf4;
    border-bottom-color: #2a2e44;
}
body.dark-mode .saved-problem-card {
    background: #13152a;
    border-color: #2a2e44;
}
body.dark-mode .saved-problem-stem { color: #d0d4e8; }
body.dark-mode .saved-problem-meta { color: #8b8fa8; }
body.dark-mode .btn-unsave { color: #8b8fa8; }
body.dark-mode .btn-unsave:hover { background: #3b1c1c; color: #f87171; }
body.dark-mode .saved-summary { color: #d0d4e8; }
body.dark-mode .btn-save-problem { color: #b0b4cc; border-color: #2a2e44; }
body.dark-mode .btn-save-problem:hover { background: #3b2f0f; border-color: #f59e0b; color: #fde68a; }
body.dark-mode .btn-save-problem.problem-saved { background: #3b2f0f; border-color: #f59e0b; color: #fde68a; }

/* --- NCEES modal dark mode --- */
body.dark-mode .ncees-topic-name { color: #d0d4e8; }
body.dark-mode .ncees-topic-input {
    background: #222540;
    border-color: #2a2e44;
    color: #e8eaf4;
}
body.dark-mode .ncees-topic-input:focus { border-color: #6d9efc; box-shadow: 0 0 0 3px rgba(109, 158, 252, 0.15); }
body.dark-mode .ncees-topic-bar { background: #2a2e44; }
body.dark-mode .ncees-topic-fill { background: #6d9efc; }
body.dark-mode .ncees-scale-note { color: #8b8fa8; }
body.dark-mode .ncees-existing-note { background: #3b2f0f; border-color: #b45309; color: #fde68a; }

/* --- Analytics dark mode --- */
body.dark-mode .analytics-section {
    background: #1a1d2e;
    border-color: #2a2e44;
    color: #d0d4e8;
}
body.dark-mode .analytics-header h3 { color: #e8eaf4; }
body.dark-mode .analytics-card {
    background: #222540;
    border-color: #2a2e44;
}
body.dark-mode .analytics-card h4 { color: #e8eaf4; }
body.dark-mode .analytics-stat-card {
    background: #222540;
    border-color: #2a2e44;
}
body.dark-mode .analytics-stat-value { color: #e8eaf4; }
body.dark-mode .analytics-stat-label { color: #8b8fa8; }
body.dark-mode .analytics-empty { color: #8b8fa8; }
body.dark-mode .analytics-empty h3 { color: #d0d4e8; }
body.dark-mode .analytics-no-data { color: #8b8fa8; }
body.dark-mode .analytics-subtitle { color: #8b8fa8; }

/* Calendar dark */
body.dark-mode .streak-calendar-svg .cal-month { fill: #8b8fa8; }
body.dark-mode .streak-calendar-svg .cal-day { fill: #5c5f77; }
body.dark-mode .cal-legend { color: #8b8fa8; }
body.dark-mode { --heat-0: #13151f; --heat-1: #0e4429; --heat-2: #006d32; --heat-3: #26a641; --heat-4: #39d353; }

/* Goal ring dark */
body.dark-mode .goal-ring-count { fill: #e8eaf4; }
body.dark-mode .goal-ring-label { fill: #8b8fa8; }
body.dark-mode .goal-ring-stat-val { color: #e8eaf4; }
body.dark-mode .goal-ring-stat-lbl { color: #8b8fa8; }
body.dark-mode { --ring-bg: #2a2e44; }

/* Chart axes dark */
body.dark-mode .axis-label { fill: #5c5f77; }
body.dark-mode { --grid-line: #2a2e44; }

/* Heatmap dark */
body.dark-mode .heatmap-legend-item { color: #8b8fa8; }
body.dark-mode .heatmap-topic { color: #d0d4e8; }
body.dark-mode .heatmap-bar-container { background: #2a2e44; }
body.dark-mode .heatmap-pct { color: #d0d4e8; }
body.dark-mode .heatmap-count { color: #5c5f77; }
body.dark-mode .heatmap-baseline-marker { border-top-color: #8b8fa8; }
body.dark-mode .heatmap-baseline-legend { color: #8b8fa8; }

/* Gap analysis dark */
body.dark-mode .gap-header { color: #8b8fa8; border-color: #2a2e44; }
body.dark-mode .gap-col-topic { color: #d0d4e8; }
body.dark-mode .gap-col { color: #8b8fa8; }
body.dark-mode .gap-row-high { background: rgba(239, 68, 68, 0.1); }
body.dark-mode .gap-row-med { background: rgba(245, 158, 11, 0.1); }

/* Badge shelf dark */
body.dark-mode .badge-item { border-color: #2a2e44; }
body.dark-mode .badge-earned { background: linear-gradient(135deg, #382e10, #402006); border-color: #b45309; box-shadow: 0 1px 6px rgba(180, 83, 9, 0.3); }
body.dark-mode .badge-locked { background: #1a1d2e; }
body.dark-mode .badge-name { color: #9ca3af; }
body.dark-mode .badge-earned .badge-name { color: #fbbf24; }
body.dark-mode .badge-name { color: #d0d4e8; }
body.dark-mode .badge-earned.badge-bronze { background: linear-gradient(135deg, #451a03, #78350f); border-color: #f59e0b; }
body.dark-mode .badge-earned.badge-silver { background: linear-gradient(135deg, #1e293b, #334155); border-color: #94a3b8; }
body.dark-mode .badge-earned.badge-gold { background: linear-gradient(135deg, #422006, #713f12); border-color: #eab308; }
body.dark-mode .badge-earned.badge-guarantee { background: linear-gradient(135deg, #022c22, #064e3b); border-color: #10b981; }
body.dark-mode .badge-earned.badge-guarantee.badge-culmination { background: linear-gradient(135deg, #064e3b, #047857, #059669); border-color: #34d399; }
body.dark-mode .badge-tier-header { border-color: #2a2e44; }

/* --- Scrollbar dark mode --- */
body.dark-mode ::-webkit-scrollbar { width: 8px; }
body.dark-mode ::-webkit-scrollbar-track { background: #0c0e16; }
body.dark-mode ::-webkit-scrollbar-thumb { background: #2a2e44; border-radius: 4px; }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: #5a5e78; }

/* ============ FLASHCARD SYSTEM ============ */

/* Setup screen */
.fc-setup { max-width: 800px; margin: 0 auto; padding: 32px 20px; }
.fc-setup-header { text-align: center; margin-bottom: 32px; }
.fc-setup-header h2 { font-size: 28px; font-weight: 700; margin: 16px 0 8px; }
.fc-subtitle { color: var(--gray-500); font-size: 15px; }
.fc-setup-header .btn { position: absolute; left: 20px; top: 20px; }

.fc-categories { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.fc-cat-card {
    background: white; border-radius: var(--radius-lg); padding: 24px; text-align: center;
    cursor: pointer; border: 2px solid var(--gray-200); transition: all 0.2s;
    display: flex; flex-direction: column; gap: 8px;
}
.fc-cat-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.fc-cat-icon { font-size: 36px; margin-bottom: 4px; }
.fc-cat-card h3 { font-size: 17px; font-weight: 600; }
.fc-cat-card > p { font-size: 13px; color: var(--gray-500); line-height: 1.4; }
.fc-cat-boxes { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.fc-box { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.fc-box1 { background: #fee2e2; color: #dc2626; }
.fc-box2 { background: #fef3c7; color: #d97706; }
.fc-box3 { background: #dcfce7; color: #16a34a; }

/* Session header */
.fc-session { max-width: 700px; margin: 0 auto; padding: 20px; }
.fc-session-header {
    display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
    padding-bottom: 16px; border-bottom: 1px solid var(--gray-200);
}
.fc-progress { flex: 1; }
#fc-progress-text { font-size: 13px; color: var(--gray-500); margin-bottom: 4px; display: block; }
.fc-progress-bar { height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; }
.fc-progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s ease; }
.fc-session-score { display: flex; gap: 12px; font-size: 14px; font-weight: 600; }
.fc-knew { color: var(--success); }
.fc-learning { color: var(--danger); }

/* Card container + flip animation */
.fc-card-container { perspective: 1000px; margin: 0 auto 24px; max-width: 560px; }
.fc-card {
    position: relative; width: 100%; min-height: 320px; cursor: pointer;
    border-radius: var(--radius-lg); transition: transform 0.15s;
}
.fc-card:active { transform: scale(0.98); }
.fc-card-inner {
    position: relative; width: 100%; height: 100%; min-height: 320px;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}
.fc-card-inner.flipped { transform: rotateY(180deg); }
.fc-card-front, .fc-card-back {
    width: 100%; min-height: 320px;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    border-radius: var(--radius-lg); padding: 32px;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    box-shadow: var(--shadow-lg);
}
.fc-card-back {
    position: absolute; top: 0; left: 0;
}
.fc-card-front {
    background: linear-gradient(135deg, #f0f4ff, #e8f0fe);
    border: 2px solid var(--primary-light);
}
.fc-card-back {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid #bbf7d0;
    transform: rotateY(180deg);
}
.fc-card-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600;
    color: var(--gray-400); margin-bottom: 16px;
}
.fc-card-text {
    font-size: 18px; line-height: 1.6; text-align: center; word-break: break-word;
    max-width: 100%; overflow-wrap: anywhere;
}
.fc-card-back .fc-card-text { font-size: 16px; }
.fc-card-meta {
    margin-top: 16px; font-size: 12px; color: var(--gray-400);
    text-align: center;
}
.fc-tap-hint {
    position: absolute; bottom: 16px; font-size: 12px; color: var(--gray-400);
    opacity: 0.7;
}

/* Rating buttons */
.fc-rating { display: flex; gap: 16px; justify-content: center; max-width: 560px; margin: 0 auto; }
.fc-btn-learning {
    flex: 1; padding: 14px 24px; font-size: 16px; font-weight: 600;
    background: #fee2e2; color: #dc2626; border: 2px solid #fca5a5; border-radius: var(--radius);
    cursor: pointer; transition: all 0.2s;
}
.fc-btn-learning:hover { background: #fca5a5; }
.fc-btn-knew {
    flex: 1; padding: 14px 24px; font-size: 16px; font-weight: 600;
    background: #dcfce7; color: #16a34a; border: 2px solid #86efac; border-radius: var(--radius);
    cursor: pointer; transition: all 0.2s;
}
.fc-btn-knew:hover { background: #86efac; }

/* MC options on flashcards */
.fc-mc-options {
    display: flex; flex-direction: column; gap: 8px;
    margin-top: 12px; width: 100%; text-align: left;
}
.fc-mc-options.hidden { display: none; }
.fc-mc-btn {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 10px 14px; background: var(--gray-50);
    border: 2px solid var(--gray-200); border-radius: var(--radius);
    cursor: pointer; font-family: inherit; font-size: 14px;
    text-align: left; transition: all 0.15s;
}
.fc-mc-btn:hover:not(:disabled) { border-color: var(--primary); background: #eff6ff; }
.fc-mc-letter {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff; font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.fc-mc-text { flex: 1; line-height: 1.4; }
.fc-mc-btn:disabled { cursor: default; opacity: 0.85; }
.fc-mc-btn.fc-mc-correct { border-color: #16a34a; background: #dcfce7; }
.fc-mc-btn.fc-mc-correct .fc-mc-letter { background: #16a34a; }
.fc-mc-btn.fc-mc-wrong { border-color: #dc2626; background: #fee2e2; }
.fc-mc-btn.fc-mc-wrong .fc-mc-letter { background: #dc2626; }
.fc-mc-result {
    width: 100%; padding: 10px 14px; margin-top: 10px;
    font-size: 15px; font-weight: 700; border-radius: var(--radius); text-align: center;
}
.fc-mc-result-correct { background: #dcfce7; color: #16a34a; }
.fc-mc-result-wrong { background: #fee2e2; color: #dc2626; }
.fc-mc-explanation {
    width: 100%; padding: 12px 14px; margin-top: 8px;
    font-size: 13px; line-height: 1.6; color: var(--gray-600);
    background: var(--gray-50); border-radius: var(--radius);
    text-align: left; max-height: 180px; overflow-y: auto;
}
.fc-mc-next-btn {
    width: 100%; padding: 14px 24px; margin-top: 8px;
    font-size: 16px; font-weight: 600; font-family: inherit;
    background: var(--primary); color: #fff; border: none;
    border-radius: var(--radius); cursor: pointer; transition: background 0.15s;
}
.fc-mc-next-btn:hover { background: var(--primary-hover); }

/* Session summary */
.fc-summary { max-width: 500px; margin: 0 auto; padding: 40px 20px; text-align: center; }
.fc-summary-content h2 { font-size: 26px; font-weight: 700; margin-bottom: 24px; }
.fc-summary-ring { margin: 0 auto 24px; }
.fc-summary-ring svg { width: 140px; height: 140px; }
.fc-summary-ring .ring-bg { fill: none; stroke: var(--gray-200); stroke-width: 10; }
.fc-summary-ring .ring-fill { fill: none; stroke-width: 10; stroke-linecap: round;
    transition: stroke-dashoffset 1s ease; }
.fc-summary-ring .ring-pct { font-size: 28px; font-weight: 700; fill: var(--gray-800); text-anchor: middle; }
.fc-summary-ring .ring-label { font-size: 12px; fill: var(--gray-500); text-anchor: middle; }
.fc-summary-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px;
}
.fc-stat-card {
    background: var(--gray-50); border-radius: var(--radius); padding: 16px;
}
.fc-stat-val { font-size: 24px; font-weight: 700; display: block; }
.fc-stat-lbl { font-size: 12px; color: var(--gray-500); }
.fc-summary-actions { display: flex; flex-direction: column; gap: 10px; }
.fc-summary-actions .btn { width: 100%; }

/* Flashcard responsive */
@media (max-width: 768px) {
    .fc-categories { grid-template-columns: 1fr; }
    .fc-setup-header .btn { position: static; margin-bottom: 8px; }
    .fc-card-front, .fc-card-back { min-height: 260px; padding: 24px; }
    .fc-card-inner { min-height: 260px; }
    .fc-card { min-height: 260px; }
    .fc-card-text { font-size: 16px; }
    .fc-session-header { flex-wrap: wrap; }
}

/* Flashcard dark mode */
body.dark-mode .fc-cat-card { background: #1a1d2e; border-color: #2a2e44; }
body.dark-mode .fc-cat-card:hover { border-color: var(--primary); }
body.dark-mode .fc-cat-card h3 { color: #e8eaf4; }
body.dark-mode .fc-cat-card > p { color: #8b8fa8; }
body.dark-mode .fc-subtitle { color: #8b8fa8; }
body.dark-mode .fc-box1 { background: rgba(239, 68, 68, 0.15); color: #f87171; }
body.dark-mode .fc-box2 { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
body.dark-mode .fc-box3 { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
body.dark-mode .fc-card-front {
    background: linear-gradient(135deg, #1a1d35, #1e2348);
    border-color: #2e3560;
}
body.dark-mode .fc-card-back {
    background: linear-gradient(135deg, #0f2a1a, #132d1e);
    border-color: #1a4a2e;
}
body.dark-mode .fc-card-label { color: #5c5f77; }
body.dark-mode .fc-card-text { color: #e8eaf4; }
body.dark-mode .fc-card-meta { color: #5c5f77; }
body.dark-mode .fc-tap-hint { color: #5c5f77; }
body.dark-mode .fc-mc-btn { background: #1a1d2e; border-color: #2a2e44; color: #e8eaf4; }
body.dark-mode .fc-mc-btn:hover:not(:disabled) { border-color: var(--primary); background: #1e2348; }
body.dark-mode .fc-mc-btn.fc-mc-correct { border-color: #16a34a; background: rgba(34, 197, 94, 0.15); }
body.dark-mode .fc-mc-btn.fc-mc-wrong { border-color: #dc2626; background: rgba(239, 68, 68, 0.15); }
body.dark-mode .fc-mc-result-correct { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
body.dark-mode .fc-mc-result-wrong { background: rgba(239, 68, 68, 0.15); color: #f87171; }
body.dark-mode .fc-mc-explanation { background: #1a1d2e; color: #c0c4d8; }
body.dark-mode .fc-mc-next-btn { background: var(--primary); }
body.dark-mode .fc-btn-learning { background: rgba(239, 68, 68, 0.15); color: #f87171; border-color: rgba(239, 68, 68, 0.3); }
body.dark-mode .fc-btn-learning:hover { background: rgba(239, 68, 68, 0.25); }
body.dark-mode .fc-btn-knew { background: rgba(34, 197, 94, 0.15); color: #4ade80; border-color: rgba(34, 197, 94, 0.3); }
body.dark-mode .fc-btn-knew:hover { background: rgba(34, 197, 94, 0.25); }
body.dark-mode .fc-progress-bar { background: #2a2e44; }
body.dark-mode .fc-session-header { border-color: #2a2e44; }
body.dark-mode .fc-stat-card { background: #1a1d2e; }
body.dark-mode .fc-stat-val { color: #e8eaf4; }
body.dark-mode .fc-stat-lbl { color: #8b8fa8; }
body.dark-mode .fc-summary-ring .ring-bg { stroke: #2a2e44; }
body.dark-mode .fc-summary-ring .ring-pct { fill: #e8eaf4; }
body.dark-mode .fc-summary-ring .ring-label { fill: #8b8fa8; }

/* ============ ALTERNATIVE ITEM TYPES ============ */
/* Fill-in-blank */
.fib-container { display: flex; align-items: center; gap: 12px; max-width: 400px; padding: 8px 0; }
.fib-input {
    width: 200px; padding: 10px 14px; font-size: 16px;
    border: 2px solid var(--gray-300); border-radius: var(--radius);
    font-family: var(--font-mono); transition: border-color var(--transition-fast);
}
.fib-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.fib-unit { font-size: 14px; color: var(--gray-600); font-weight: 600; }
.fib-tolerance { font-size: 12px; color: var(--gray-400); }
.fib-input.correct { border-color: var(--success); background: var(--success-light); }
.fib-input.incorrect { border-color: var(--danger); background: var(--danger-light); }

/* Drag and drop */
.drag-drop-container { display: flex; flex-direction: column; gap: 6px; max-width: 600px; }
.drag-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; background: white;
    border: 1.5px solid var(--gray-200); border-radius: var(--radius);
    cursor: grab; user-select: none; transition: all var(--transition-fast);
}
.drag-item:active { cursor: grabbing; }
.drag-item.dragging { opacity: 0.4; background: var(--primary-light); }
.drag-item.drag-over { border-color: var(--primary); border-style: dashed; background: var(--primary-light); }
.drag-item-number {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--gray-200); display: flex;
    align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.drag-handle { color: var(--gray-400); cursor: grab; flex-shrink: 0; }
.drag-item-text { flex: 1; font-size: 14px; }
.drag-item.disabled { cursor: default; opacity: 0.85; }
.drag-item.dd-correct { border-color: var(--success); background: var(--success-light); }
.drag-item.dd-correct .drag-item-number { background: var(--success); color: white; }
.drag-item.dd-incorrect { border-color: var(--danger); background: var(--danger-light); }
.drag-item.dd-incorrect .drag-item-number { background: var(--danger); color: white; }
.fib-input.disabled { cursor: default; opacity: 0.85; }
.dd-move-btns { display: flex; flex-direction: column; gap: 2px; margin-left: auto; }
.dd-move-btn {
    width: 28px; height: 22px; border: 1px solid var(--gray-300);
    background: var(--gray-50); border-radius: 4px; cursor: pointer;
    font-size: 10px; line-height: 1; display: flex;
    align-items: center; justify-content: center; color: var(--gray-600);
}
.dd-move-btn:hover:not(:disabled) { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.dd-move-btn:disabled { opacity: 0.3; cursor: default; }

/* Dark mode AIT */
body.dark-mode .fib-input { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .fib-unit { color: #8b8fa8; }
body.dark-mode .drag-item { background: #1a1d2e; border-color: #2a2e44; color: #d0d4e8; }
body.dark-mode .drag-item.drag-over { background: #1a2744; border-color: #6d9efc; }
body.dark-mode .drag-item-number { background: #2a2e44; color: #b0b4cc; }
body.dark-mode .drag-handle { color: #6b7094; }
body.dark-mode .drag-item.dd-correct { background: #052e16; border-color: #16a34a; }
body.dark-mode .drag-item.dd-incorrect { background: #450a0a; border-color: #dc2626; }
body.dark-mode .fib-input.correct { background: #052e16; border-color: #16a34a; color: #86efac; }
body.dark-mode .fib-input.incorrect { background: #450a0a; border-color: #dc2626; color: #fca5a5; }
body.dark-mode .dd-move-btn { background: #1a1d2e; border-color: #2a2e44; color: #8b8fa8; }
body.dark-mode .dd-move-btn:hover:not(:disabled) { background: #1a2744; border-color: #6d9efc; color: #6d9efc; }

/* ============ HIGHLIGHT TOOL ============ */
.hl-toolbar {
    position: fixed; z-index: 300;
    display: flex; gap: 4px; padding: 6px 8px;
    background: white; border: 1px solid var(--gray-300);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.hl-color-btn {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid transparent; cursor: pointer;
    transition: transform var(--transition-fast);
}
.hl-color-btn:hover { transform: scale(1.2); }
.hl-yellow { background: #fef08a; }
.hl-green { background: #bbf7d0; }
.hl-blue { background: #bfdbfe; }
.hl-red { background: #fecaca; }
.hl-clear {
    background: var(--gray-200); font-size: 12px; display: flex;
    align-items: center; justify-content: center; color: var(--gray-600);
}
.hl-clear:hover { background: var(--danger-light); color: var(--danger); }

mark.ref-hl { padding: 1px 0; border-radius: 2px; }
mark.ref-hl-yellow { background: #fef08a; }
mark.ref-hl-green { background: #bbf7d0; }
mark.ref-hl-blue { background: #bfdbfe; }
mark.ref-hl-red { background: #fecaca; }

body.dark-mode .hl-toolbar { background: #1a1d2e; border-color: #2a2e44; }
body.dark-mode mark.ref-hl-yellow { background: rgba(254,240,138,0.3); color: #fef08a; }
body.dark-mode mark.ref-hl-green { background: rgba(187,247,208,0.3); color: #bbf7d0; }
body.dark-mode mark.ref-hl-blue { background: rgba(191,219,254,0.3); color: #bfdbfe; }
body.dark-mode mark.ref-hl-red { background: rgba(254,202,202,0.3); color: #fecaca; }

/* ============ ITEM REVIEW SCREEN ============ */
.item-review-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.item-review-panel {
    background: white; border-radius: var(--radius-lg);
    max-width: 900px; width: 100%; max-height: 85vh;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.item-review-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--gray-200);
}
.item-review-header h3 { font-size: 18px; margin-bottom: 8px; }
.item-review-summary {
    display: flex; gap: 16px; margin-bottom: 12px; font-size: 13px;
}
.ir-stat { font-weight: 600; }
.ir-stat-complete { color: var(--success); }
.ir-stat-incomplete { color: var(--gray-500); }
.ir-stat-flagged { color: var(--warning); }
.item-review-filters { display: flex; gap: 8px; }
.ir-filter { font-size: 12px; padding: 4px 12px; }
.ir-filter.active { background: var(--primary); color: white; }
.item-review-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 5px; padding: 20px 24px; overflow-y: auto; flex: 1;
}
.ir-card {
    display: flex; align-items: center; justify-content: center;
    height: 40px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--gray-300); background: white;
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all var(--transition-fast);
}
.ir-card:hover { transform: scale(1.08); box-shadow: var(--shadow); }
.ir-card.ir-complete { border-color: var(--success); background: var(--success-light); color: var(--success); }
.ir-card.ir-incomplete { border-color: var(--gray-300); color: var(--gray-500); border-style: dashed; }
.ir-card.ir-flagged { background: var(--warning-light); border-color: var(--warning); color: #92400e; }
.ir-card.ir-complete.ir-flagged { background: var(--warning-light); border-color: var(--warning); }
.item-review-actions {
    display: flex; justify-content: space-between; padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
}
.btn-review {
    background: none; border: 1px solid var(--gray-400); color: var(--gray-600);
    font-size: 12px; padding: 4px 12px; border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition-fast);
}
.btn-review:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* Item review dark mode */
body.dark-mode .item-review-panel { background: #13151f; }
body.dark-mode .item-review-header { border-color: #2a2e44; }
body.dark-mode .item-review-header h3 { color: #e8eaf4; }
body.dark-mode .item-review-actions { border-color: #2a2e44; }
body.dark-mode .ir-card { background: #1a1d2e; border-color: #2a2e44; color: #b0b4cc; }
body.dark-mode .ir-card.ir-complete { background: #12302a; border-color: #4ade80; color: #4ade80; }
body.dark-mode .ir-card.ir-incomplete { background: #1a1d2e; border-color: #3a3e54; color: #6b7094; }
body.dark-mode .ir-card.ir-flagged { background: #382e10; border-color: #fbbf24; color: #fbbf24; }
body.dark-mode .btn-review { border-color: #2a2e44; color: #b0b4cc; }
body.dark-mode .btn-review:hover { border-color: #6d9efc; color: #6d9efc; background: #1a2744; }

/* ============ SECTION BREAK OVERLAY ============ */
.break-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.3s ease;
}
.break-content {
    background: var(--bg-primary, #fff); border-radius: 16px;
    padding: 48px 40px; max-width: 480px; width: 90%;
    text-align: center; box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}
.break-icon { font-size: 64px; margin-bottom: 16px; }
.break-content h2 { margin: 0 0 8px; font-size: 24px; }
.break-message { color: var(--gray-500); margin: 0 0 24px; font-size: 15px; }
.break-timer {
    display: flex; flex-direction: column; align-items: center;
    margin: 0 0 24px; padding: 20px; border-radius: 12px;
    background: var(--gray-50, #f9fafb);
}
.break-timer-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-400); }
.break-timer-text { font-size: 48px; font-weight: 700; font-family: 'JetBrains Mono', monospace; color: var(--primary); margin: 4px 0; }
.break-timer-note { font-size: 12px; color: var(--gray-400); }
.break-tip { margin-top: 16px; font-size: 13px; color: var(--gray-400); font-style: italic; }
.btn-lg { padding: 14px 32px; font-size: 16px; }

body.dark-mode .break-content { background: #13151f; }
body.dark-mode .break-timer { background: rgba(255,255,255,0.05); }

/* Section-locked nav buttons */
.nav-btn.section-locked {
    opacity: 0.35; cursor: not-allowed;
    background: var(--gray-200) !important;
    pointer-events: auto;
}
body.dark-mode .nav-btn.section-locked { background: var(--gray-700) !important; }

/* ============ TOPIC SELECTION MODAL ============ */
.topic-modal-overlay {
    position: fixed; inset: 0; z-index: 5000;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
}
.topic-modal {
    background: var(--bg-primary, #fff); border-radius: 16px;
    padding: 24px; max-width: 600px; width: 92%; max-height: 85vh;
    display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,0.2);
}
.topic-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--gray-200);
}
.topic-modal-header h3 { margin: 0; font-size: 18px; }
.btn-close-topic-modal {
    background: none; border: none; font-size: 24px; cursor: pointer;
    color: var(--gray-400); padding: 4px 8px; border-radius: 6px;
}
.btn-close-topic-modal:hover { background: var(--gray-100); color: var(--gray-600); }
.topic-modal .topic-grid {
    flex: 1; overflow-y: auto; margin-bottom: 16px;
    max-height: 40vh; padding-right: 4px;
}
.topic-modal-options {
    display: flex; flex-direction: column; gap: 10px;
    margin-bottom: 16px; padding: 12px; border-radius: 10px;
    background: var(--gray-50, #f9fafb);
}
.topic-option-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.topic-option-label { font-size: 13px; font-weight: 600; color: var(--gray-500); min-width: 140px; }
.topic-len-btn, .topic-diff-btn {
    padding: 4px 12px !important; font-size: 12px !important; border-radius: 6px !important;
}
.topic-len-btn.active, .topic-diff-btn.active {
    background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important;
}
.topic-modal .topic-actions {
    display: flex; align-items: center; gap: 12px; justify-content: space-between;
    padding-top: 12px; border-top: 1px solid var(--gray-200);
}

body.dark-mode .topic-modal { background: #13151f; }
body.dark-mode .topic-modal-header { border-color: var(--gray-700); }
body.dark-mode .btn-close-topic-modal:hover { background: var(--gray-700); }
body.dark-mode .topic-modal-options { background: rgba(255,255,255,0.05); }
body.dark-mode .topic-modal .topic-actions { border-color: var(--gray-700); }

/* ============ ACCOUNT / LICENSE MODAL ============ */
.account-link-row {
    text-align: center; margin-top: 24px; padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}
.account-link-subtle {
    color: var(--gray-400); font-size: 12px; text-decoration: none;
}
.account-link-subtle:hover { color: var(--gray-600); text-decoration: underline; }
.account-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.account-modal {
    background: #fff; border-radius: 12px; width: 90%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden;
}
.account-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
}
.account-modal-header h3 { margin: 0; font-size: 18px; }
.account-modal-body { padding: 20px; }
.account-key-display, .account-disc-display {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; font-size: 14px;
}
.account-key-label { color: var(--gray-500); font-size: 13px; }
.account-key-value { font-family: monospace; font-size: 14px; letter-spacing: 1px; }
.account-warning {
    margin: 16px 0; padding: 12px; border-radius: 8px;
    background: #fef3c7; border: 1px solid #f59e0b; font-size: 13px; line-height: 1.5;
}
.account-confirm-area { margin-top: 16px; }
.account-confirm-area p { font-size: 13px; margin-bottom: 8px; }
.account-confirm-area .key-input { width: 100%; margin-bottom: 10px; box-sizing: border-box; }
.account-confirm-area .btn-danger {
    width: 100%; background: #dc2626; color: #fff; border: none;
    padding: 10px; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.account-confirm-area .btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }
.account-confirm-area .btn-danger:not(:disabled):hover { background: #b91c1c; }
#account-show-confirm { margin-top: 12px; width: 100%; }

body.dark-mode .account-modal { background: #13151f; }
body.dark-mode .account-modal-header { border-color: var(--gray-700); }
body.dark-mode .account-warning { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.4); color: #fbbf24; }
body.dark-mode .account-link-subtle { color: var(--gray-500); }
body.dark-mode .account-link-subtle:hover { color: var(--gray-300); }

/* ============ PUSH NOTIFICATION TOGGLE ============ */
.push-notify-row {
    text-align: center; margin-top: 16px; padding: 8px 0;
}
.push-toggle-label {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--gray-500); cursor: pointer;
}
.push-toggle-label input[type="checkbox"] {
    width: 36px; height: 20px; appearance: none; -webkit-appearance: none;
    background: var(--gray-300); border-radius: 10px; position: relative;
    cursor: pointer; transition: background 0.2s;
}
.push-toggle-label input[type="checkbox"]::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; transition: transform 0.2s;
}
.push-toggle-label input[type="checkbox"]:checked {
    background: var(--primary);
}
.push-toggle-label input[type="checkbox"]:checked::after {
    transform: translateX(16px);
}
body.dark-mode .push-toggle-label { color: var(--gray-400); }
body.dark-mode .push-toggle-label input[type="checkbox"] { background: var(--gray-600); }
body.dark-mode .push-toggle-label input[type="checkbox"]:checked { background: var(--primary); }

/* ============ STUDY PLANNER (Adaptive) ============ */

/* Wizard */
.sp-wizard { padding: 8px 0; }
.sp-progress { display: flex; align-items: center; gap: 0; margin-bottom: 20px; padding: 0 4px; }
.sp-dot { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; }
.sp-dot-num {
    width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; background: var(--gray-200); color: var(--gray-500); transition: all 0.2s;
}
.sp-dot.active .sp-dot-num { background: var(--primary); color: #fff; }
.sp-dot.done .sp-dot-num { background: var(--success); color: #fff; }
.sp-dot-label { font-size: 10px; color: var(--gray-400); white-space: nowrap; }
.sp-dot.active .sp-dot-label { color: var(--primary); font-weight: 600; }
.sp-line { flex: 1; height: 2px; background: var(--gray-200); margin: 0 4px; margin-bottom: 14px; }
.sp-line.done { background: var(--success); }

.sp-title { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.sp-sub { color: var(--gray-500); font-size: 13px; margin: 0 0 16px; }

/* Choice cards */
.sp-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.sp-cards-2 { grid-template-columns: 1fr 1fr; }
.sp-card {
    display: flex; flex-direction: column; gap: 4px; padding: 14px 12px;
    border: 2px solid var(--gray-200); border-radius: 10px; background: #fff;
    cursor: pointer; transition: all 0.15s; text-align: left;
    font-family: inherit; font-size: inherit;
}
.sp-card:hover { border-color: var(--primary); }
.sp-card.selected { border-color: var(--primary); background: rgba(37, 99, 235, 0.04); box-shadow: 0 0 0 1px var(--primary); }
.sp-card-title { font-weight: 700; font-size: 14px; color: var(--gray-800); }
.sp-card-desc { font-size: 12px; color: var(--gray-500); }

/* Hours buttons */
.sp-hours { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.sp-hour-btn {
    padding: 10px 16px; border: 2px solid var(--gray-200); border-radius: 8px;
    background: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: all 0.15s; font-family: inherit;
}
.sp-hour-btn:hover { border-color: var(--primary); }
.sp-hour-btn.selected { border-color: var(--primary); background: var(--primary); color: #fff; }

/* Date input */
.sp-date-wrap {
    display: flex; flex-direction: column; gap: 4px; margin: 12px 0;
    font-size: 13px; font-weight: 600; color: var(--gray-600);
}
.sp-date-input {
    padding: 12px 14px; border: 1px solid var(--gray-300); border-radius: 10px;
    font-size: 16px; font-weight: 500; background: #fff; color: var(--gray-800);
    font-family: inherit; font-variant-numeric: tabular-nums;
}
.sp-date-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

.sp-hint { font-size: 12px; color: var(--gray-500); margin: 8px 0; }
.sp-hint a { color: var(--primary); }

/* Wizard nav buttons */
.sp-nav { display: flex; gap: 8px; margin-top: 16px; }
.sp-btn { flex: 1; padding: 10px 16px; }
.sp-gen-btn { background: var(--success); border-color: var(--success); }
.sp-gen-btn:hover { background: #15803d; }

/* ============ Adaptive Plan View ============ */
.sp-plan { padding: 4px 0; }

.sp-header {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    border-radius: 12px; padding: 16px; color: #fff; margin-bottom: 12px;
}
.sp-countdown { text-align: center; margin-bottom: 12px; }
.sp-days { font-size: 44px; font-weight: 800; line-height: 1; }
.sp-days-label { font-size: 13px; opacity: 0.9; margin-top: 2px; }
.sp-exam-date { font-size: 11px; opacity: 0.7; margin-top: 2px; }

.sp-readiness { background: rgba(255,255,255,0.15); border-radius: 8px; padding: 10px 12px; }
.sp-readiness-hdr { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.sp-readiness-num { font-weight: 800; }
.sp-readiness-bar { height: 6px; background: rgba(255,255,255,0.2); border-radius: 3px; overflow: hidden; }
.sp-readiness-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.sp-readiness-label { font-size: 11px; opacity: 0.85; margin-top: 4px; }

/* Path info */
.sp-path { font-size: 12px; color: var(--gray-500); margin-bottom: 10px; padding: 0 2px; }

/* Quick stats */
.sp-stats { display: flex; gap: 6px; margin-bottom: 12px; }
.sp-stat { flex: 1; text-align: center; padding: 8px 4px; background: var(--gray-50); border-radius: 8px; }
.sp-stat-val { display: block; font-size: 16px; font-weight: 700; color: var(--gray-800); }
.sp-stat-lbl { display: block; font-size: 10px; color: var(--gray-500); margin-top: 1px; }

/* Week list */
.sp-weeks { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.sp-week { border: 1px solid var(--gray-200); border-radius: 8px; overflow: hidden; transition: all 0.15s; }
.sp-week-current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.sp-week-past { opacity: 0.5; }
.sp-week-open { border-color: var(--primary); }

.sp-week-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; cursor: pointer; transition: background 0.1s;
}
.sp-week-head:hover { background: rgba(37, 99, 235, 0.02); }
.sp-week-left { display: flex; flex-direction: column; gap: 1px; }
.sp-week-num { font-weight: 700; font-size: 13px; }
.sp-week-phase { font-size: 11px; color: var(--gray-500); }
.sp-week-right { display: flex; align-items: center; gap: 8px; }
.sp-week-dates { font-size: 11px; color: var(--gray-500); }
.sp-week-done { font-size: 11px; font-weight: 600; color: var(--gray-400); }
.sp-chevron { font-size: 10px; color: var(--gray-400); }

/* Expanded week: tasks */
.sp-tasks { padding: 0 12px 12px; border-top: 1px solid var(--gray-100); }

.sp-week-topics { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.sp-topic-tag { font-size: 11px; padding: 2px 8px; border-radius: 12px; background: var(--gray-100); color: var(--gray-600); }
.sp-topic-tag.sp-topic-strong { background: #d1fae5; color: #065f46; }
.sp-topic-tag.sp-topic-started { background: #dbeafe; color: #1e40af; }

.sp-task {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--gray-100);
}
.sp-task:last-child { border-bottom: none; }
.sp-task-done { opacity: 0.5; }
.sp-task-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.sp-task-check { font-size: 18px; cursor: pointer; line-height: 1; flex-shrink: 0; }
.sp-task-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sp-task-type {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 1px 6px; border-radius: 4px; display: inline-block; width: fit-content;
}
.sp-t-flash { background: #dbeafe; color: #1d4ed8; }
.sp-t-prac { background: #ede9fe; color: #6d28d9; }
.sp-t-rev { background: #fef3c7; color: #92400e; }
.sp-t-calc { background: #ffedd5; color: #c2410c; }
.sp-t-exam { background: #fee2e2; color: #b91c1c; }
.sp-task-desc { font-size: 12px; color: var(--gray-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-task-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sp-task-time { font-size: 11px; color: var(--gray-400); white-space: nowrap; }
.sp-task-btn { padding: 4px 12px !important; font-size: 12px !important; }

.sp-reset-btn { width: 100%; }

/* ============ Dark Mode ============ */
body.dark-mode .sp-card { background: var(--gray-800); border-color: var(--gray-600); }
body.dark-mode .sp-card.selected { background: rgba(37, 99, 235, 0.15); border-color: var(--primary); }
body.dark-mode .sp-card-title { color: var(--gray-100); }
body.dark-mode .sp-card-desc { color: var(--gray-400); }
body.dark-mode .sp-hour-btn { background: var(--gray-800); border-color: var(--gray-600); color: var(--gray-300); }
body.dark-mode .sp-hour-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
body.dark-mode .sp-date-input { background: var(--gray-800); border-color: var(--gray-600); color: var(--gray-100); color-scheme: dark; }
body.dark-mode .sp-date-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25); }
body.dark-mode .sp-sub { color: var(--gray-400); }
body.dark-mode .sp-stat { background: var(--gray-800); }
body.dark-mode .sp-stat-val { color: var(--gray-100); }
body.dark-mode .sp-week { border-color: var(--gray-700); }
body.dark-mode .sp-week-current { background: rgba(37, 99, 235, 0.08); }
body.dark-mode .sp-week-head:hover { background: rgba(37, 99, 235, 0.06); }
body.dark-mode .sp-tasks { border-top-color: var(--gray-700); }
body.dark-mode .sp-task { border-bottom-color: var(--gray-700); }
body.dark-mode .sp-task-desc { color: var(--gray-400); }
body.dark-mode .sp-topic-tag { background: var(--gray-700); color: var(--gray-300); }
body.dark-mode .sp-topic-tag.sp-topic-strong { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
body.dark-mode .sp-topic-tag.sp-topic-started { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
body.dark-mode .sp-readiness-bar { background: rgba(255,255,255,0.15); }
body.dark-mode .sp-path { color: var(--gray-400); }
body.dark-mode .sp-t-flash { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
body.dark-mode .sp-t-prac { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
body.dark-mode .sp-t-rev { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
body.dark-mode .sp-t-calc { background: rgba(249, 115, 22, 0.2); color: #fdba74; }
body.dark-mode .sp-t-exam { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

/* ============ SEARCH MODE ============ */
.search-input-wrapper {
    display: flex; gap: 8px; margin-top: 8px;
}
.search-mode-input {
    flex: 1; padding: 8px 12px; border: 1px solid var(--gray-300);
    border-radius: 8px; font-size: 14px; background: var(--bg-primary, #fff);
    color: var(--text-primary); outline: none;
}
.search-mode-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
.btn-search-go { padding: 8px 16px !important; white-space: nowrap; }
body.dark-mode .search-mode-input { background: #1a1d2e; border-color: #2a2e44; color: #e8eaf0; }

/* ============ FLASHCARD OPTIONS ============ */
.fc-options {
    padding: 12px 16px; margin-bottom: 16px; border-radius: 10px;
    background: var(--gray-50, #f9fafb);
}
.fc-option-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.fc-option-row:last-child { margin-bottom: 0; }
.fc-option-label { font-size: 13px; font-weight: 600; color: var(--gray-500); min-width: 130px; }
.fc-topic-select {
    padding: 5px 10px; border: 1px solid var(--gray-300); border-radius: 6px;
    font-size: 13px; background: var(--bg-primary, #fff); color: var(--text-primary);
}
.fc-size-btn {
    padding: 4px 12px !important; font-size: 12px !important; border-radius: 6px !important;
}
.fc-size-btn.active {
    background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important;
}
body.dark-mode .fc-options { background: rgba(255,255,255,0.05); }
body.dark-mode .fc-topic-select { background: var(--gray-800); border-color: var(--gray-600); color: #e8eaf0; }

/* ============ SCORE TREND CHART ============ */
.score-trend-chart { margin-bottom: 20px; }
.trend-title { font-size: 14px; font-weight: 600; margin: 0 0 10px; color: var(--gray-500); }
.score-trend-svg { width: 100%; height: auto; }
.score-trend-svg text { font-family: 'Inter', sans-serif; }
body.dark-mode .score-trend-svg line { stroke: var(--gray-700); }

/* ============ WHY SECTION (pre-purchase only) ============ */
.why-section {
    max-width: 800px;
    margin: 48px auto 0;
    padding: 0 16px;
}
.why-section.hidden { display: none; }
.why-header {
    text-align: center;
    margin-bottom: 32px;
}
.why-header h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}
.why-subtitle {
    font-size: 15px;
    color: var(--gray-500);
    font-weight: 400;
    line-height: 1.5;
}
/* How It Works panels */
.why-panels {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 32px;
}
.why-panel {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 20px;
}
.why-panel-number {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
}
.why-panel-content h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 6px;
}
.why-panel-content p {
    font-size: 14px;
    color: var(--gray-600);
    line-height: 1.6;
    margin: 0;
}
.install-instructions {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-200);
}
.install-instructions-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin: 0 0 6px;
}
.install-instructions ul {
    margin: 0;
    padding-left: 18px;
    list-style: disc;
}
.install-instructions li {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.7;
}
.install-app-btn {
    margin-top: 12px;
    font-size: 14px;
    padding: 8px 20px;
}
.install-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin: 0 0 6px;
}
body.dark-mode .install-instructions {
    border-top-color: var(--gray-700);
}
body.dark-mode .install-instructions-label {
    color: #c0c3d4;
}
body.dark-mode .install-instructions li {
    color: #8b8fa8;
}
body.dark-mode .install-hint {
    color: #8b8fa8;
}
.why-cta {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}
.why-features {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 32px;
}
.why-feature {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.why-feature-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--success);
    color: white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}
.why-feature h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0 0 4px;
}
.why-feature p {
    font-size: 14px;
    color: var(--gray-500);
    line-height: 1.5;
    margin: 0;
}
.why-bottom-line {
    background: var(--primary-light);
    border: 1px solid rgba(37,99,235,0.15);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 8px;
}
.why-bottom-line p {
    font-size: 14px;
    color: var(--gray-700);
    line-height: 1.6;
    margin: 0;
    text-align: center;
}
@media (max-width: 640px) {
    .why-header h2 { font-size: 22px; }
    .why-subtitle { font-size: 14px; }
    .why-bottom-line { padding: 16px; }
}
/* Dark Mode — Why Section */
body.dark-mode .why-header h2 { color: #e8eaf4; }
body.dark-mode .why-subtitle { color: #8b8fa8; }
body.dark-mode .why-panel { background: #13152a; border-color: #1e2240; }
body.dark-mode .why-panel-content h3 { color: #e8eaf4; }
body.dark-mode .why-panel-content p { color: #8b8fa8; }
body.dark-mode .why-feature h3 { color: #e8eaf4; }
body.dark-mode .why-feature p { color: #8b8fa8; }
body.dark-mode .why-feature-icon { background: #22c55e; }
body.dark-mode .why-bottom-line {
    background: #1a2744;
    border-color: rgba(109,158,252,0.2);
}
body.dark-mode .why-bottom-line p { color: #d0d4e8; }

/* ============ APP VERSION INDICATOR ============ */
.app-version {
    position: fixed;
    bottom: 6px;
    right: 8px;
    font-size: 11px;
    font-family: system-ui, -apple-system, sans-serif;
    color: #9ca3af;
    opacity: 0.55;
    z-index: 10;
    pointer-events: none;
    user-select: none;
    line-height: 1;
}
body.dark-mode .app-version {
    color: #6b7280;
}

/* ============ PRINT STYLES ============ */
@media print {
    .exam-header, .question-nav, .question-controls, .reference-panel, .calculator-modal { display: none; }
    .question-area { padding: 0; }
}
