:root {
    --purple: #8b5cf6;
    --purple-hover: #7c3aed;
    --bg-primary: #ffffff;
    --bg-secondary: #f4f4f5;
    --text-main: #18181b;
    --text-muted: #71717a;
    --border-color: #e4e4e7;
    --radius: 8px;
    --danger: #ef4444;
}

@media (prefers-color-scheme: dark) {
    :root {
        --purple: #9333ea;
        --purple-hover: #a855f7;
        --bg-primary: #18181b;
        --bg-secondary: #27272a;
        --text-main: #fafafa;
        --text-muted: #a1a1aa;
        --border-color: #3f3f46;
    }
}

html, body { height: 100%; height: 100dvh; margin: 0; padding: 0; overflow: hidden; background-color: var(--bg-primary); transition: background-color 0.3s, color 0.3s; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text-main); -webkit-font-smoothing: antialiased; font-size: 16px;}
body { display: flex; flex-direction: column; padding-top: 85px; box-sizing: border-box;}

/* Flat Header */
.header { position: fixed; top: 0; left: 0; width: 100%; background: var(--bg-primary); border-bottom: 1px solid var(--border-color); z-index: 1000; padding: 12px 20px; box-sizing: border-box; transition: background-color 0.3s, border-color 0.3s;}
.header-content { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; max-width: 800px; margin-left: auto; margin-right: auto;}
.header-left { display: flex; align-items: flex-start; gap: 12px; }
.header-titles { display: flex; flex-direction: column; justify-content: center; margin-top: 3px; }
.progress-text { font-size: 14px; font-weight: 500; color: var(--text-muted); margin-bottom: 0; display: flex; align-items: center; gap: 8px;}
.sync-status-text { font-size: 12px; font-weight: 500;}

.header-right { display: flex; gap: 12px; align-items: center; }
.icon-btn { display: flex; align-items: center; gap: 6px; padding: 4px; border: none; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 500; cursor: pointer; transition: color 0.2s;}
.icon-btn:hover { color: var(--text-main); }
.action-btn { color: var(--purple); }
.action-btn:hover { color: var(--purple-hover); }

.progress-wrapper { max-width: 800px; margin: 0 auto; }
.progress-container { display: flex; width: 100%; height: 4px; overflow: hidden; background: var(--border-color); gap: 0;}
.prog-seg { flex: 1; background: transparent; transition: background 0.2s ease; }
.prog-seg.done { background: var(--purple); }
.prog-seg.skip { background: #f59e0b; }

/* Main Container */
.container { flex: 1; display: flex; flex-direction: column; max-width: 800px; margin: 0 auto; width: 100%; padding: 12px 20px; box-sizing: border-box; min-height: 0;}
#quiz-screen { flex: 1; display: flex; flex-direction: column; min-height: 0; max-height: 100%; justify-content: space-between; overflow-y: auto; padding-bottom: 8px; box-sizing: border-box;}

/* Question Content - Flattened, no card */
.q-number { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500;}
.q-title { font-size: 24px; font-weight: 600; margin-bottom: 12px; line-height: 1.4; color: var(--text-main); letter-spacing: -0.02em;}

.q-anchor { 
    font-size: 16px; 
    line-height: 1.5;
    color: var(--text-muted); 
    border-left: 3px solid var(--purple); 
    padding-left: 12px; 
    margin-bottom: 16px; 
}

/* Options Area */
.options-area { flex-shrink: 0; display: flex; flex-direction: column; gap: 12px;}
.row-int { display: flex; justify-content: space-between; gap: 12px;}
.row-half { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px;}

.opt-btn { flex: 1; padding: 16px 0; border: 1px solid var(--border-color); background: var(--bg-primary); border-radius: var(--radius); cursor: pointer; font-size: 22px; font-weight: 600; color: var(--text-main); transition: all 0.2s ease; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center;}
.opt-btn:active { background: var(--bg-secondary); }
.opt-btn.selected { background: var(--purple); color: #FFF; border-color: var(--purple);}
.opt-btn span.label { display: block; font-size: 12px; font-weight: 500; margin-top: 8px; color: var(--text-muted); transition: color 0.2s;}
.opt-btn.selected span.label { color: rgba(255,255,255,0.85); }

/* Controls */
.controls { display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; padding-top: 16px; padding-bottom: 12px; border-top: 1px solid var(--border-color); margin-top: 16px; position: relative; z-index: 50;}
.right-controls { display: flex; gap: 16px; align-items: center; }
.nav-btn { background: transparent; border: 1px solid var(--border-color); padding: 12px; border-radius: 50%; cursor: pointer; color: var(--text-main); display: flex; align-items: center; justify-content: center; transition: background 0.2s, border-color 0.2s;}
.nav-btn:hover { background: var(--bg-secondary); border-color: var(--text-muted); }
.skip-btn { color: var(--text-muted); background: transparent; border: none; font-size: 16px; font-weight: 500; padding: 12px; border-radius: 0; border-radius: var(--radius);}
.skip-btn:hover { background: var(--bg-secondary); color: var(--text-main); }
.primary-btn { background: var(--purple); color: #fff; border: none; }
.primary-btn:hover { background: var(--purple-hover); border-color: var(--purple-hover); }

/* Doubt Input */
.doubt-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 15px; color: var(--text-muted); font-weight: 500; padding: 8px 12px; border-radius: var(--radius); border: 1px solid transparent; transition: all 0.2s;}
.doubt-toggle:hover { background: var(--bg-secondary); }
.doubt-toggle.active { color: var(--danger); background: transparent; }
.apple-input { display: block; width: 100%; box-sizing: border-box; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 14px 16px; font-size: 16px; color: var(--text-main); font-family: inherit; transition: border-color 0.2s, background 0.2s; -webkit-appearance: none; appearance: none; }
.apple-input:focus { outline: none; border-color: var(--purple); background: var(--bg-primary); }

/* Mobile Optimizations */
@media (max-width: 600px) {
    body { padding-top: 95px; }
    .header { padding: 10px 15px; }
    .container { padding: 15px 15px; }
    .q-title { font-size: 24px; margin-bottom: 20px;}
    .q-anchor { font-size: 16px; padding-left: 12px; margin-bottom: 24px;}
    .opt-btn { padding: 14px 0; font-size: 20px; }
    .opt-btn span.label { font-size: 11px;}
    .row-int { gap: 8px; }
    .row-half { gap: 8px; }
    .controls { padding-top: 16px; margin-top: 16px; }
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out forwards; }

.result-screen { display: none; background: transparent; padding: 20px 0; overflow-y: auto; height: 100%;}
.result-title { font-size: 32px; margin-bottom: 40px; font-weight: 600; color: var(--text-main);}
.result-actions { display: flex; flex-direction: column; gap: 16px; margin-bottom: 40px;}
.export-btn { padding: 16px 24px; color: white; border-radius: var(--radius); cursor: pointer; border: none; font-size: 16px; font-weight: 500; display: flex; align-items: center; gap: 10px; transition: background 0.2s; width: 100%; justify-content: center;}
.primary-action { background: var(--purple); }
.primary-action:hover { background: var(--purple-hover); }
.secondary-action { background: transparent; color: var(--text-main); border: 1px solid var(--border-color); }
.secondary-action:hover { background: var(--bg-secondary); }

.summary-section { border-top: 1px solid var(--border-color); padding-top: 40px;}
.result-table { width: 100%; border-collapse: collapse; font-size: 15px;}
.result-table th, .result-table td { padding: 16px 12px; text-align: left; border-bottom: 1px solid var(--border-color);}
.result-table th { color: var(--text-muted); font-weight: 500;}

/* ===== Test Switcher Drawer ===== */
.hamburger-btn { display: flex; flex-direction: column; justify-content: center; gap: 5px; width: 36px; height: 36px; padding: 0 8px; border: none; background: transparent; cursor: pointer; flex-shrink: 0; outline: none; -webkit-tap-highlight-color: transparent;}
.hamburger-btn span { display: block; height: 2px; width: 20px; background: var(--text-muted); border-radius: 2px; transition: background 0.2s; }
.hamburger-btn:hover span { background: var(--text-main); }

.drawer-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.45); z-index: 2000; opacity: 0; pointer-events: none; transition: opacity 0.28s ease; }
.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer { position: fixed; top: 0; left: 0; height: 100%; width: 280px; max-width: 80vw; background: var(--bg-primary); border-right: 1px solid var(--border-color); z-index: 2001; display: flex; flex-direction: column; transform: translateX(-100%); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); box-shadow: 4px 0 24px rgba(0,0,0,0.12); }
.drawer.open { transform: translateX(0); }

.drawer-header { padding: 24px 20px 16px; border-bottom: 1px solid var(--border-color); }
.drawer-header h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text-main); }
.drawer-header p { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); }

.drawer-list { flex: 1; overflow-y: auto; padding: 12px 0; }
.drawer-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; cursor: pointer; transition: background 0.18s; border: none; background: transparent; width: 100%; text-align: left; color: var(--text-main); }
.drawer-item:hover { background: var(--bg-secondary); }
.drawer-item.active { background: rgba(139, 92, 246, 0.08); }
.drawer-item-icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(139,92,246,0.1); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--purple); }
.drawer-item-info { display: flex; flex-direction: column; gap: 2px; }
.drawer-item-name { font-size: 14px; font-weight: 600; }
.drawer-item-desc { font-size: 11px; color: var(--text-muted); }

@keyframes slide-in-left { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes slide-in-right { from { transform: translateX(200%); } to { transform: translateX(0); } }

/* Header test name badge */
.header-test-name { font-size: 12px; font-weight: 600; color: var(--purple); letter-spacing: 0.02em; line-height: 1; margin-bottom: 3px; }

/* Slide animations for question card */
.slide-in-left { animation: slideInFromRight 0.25s cubic-bezier(0.4,0,0.2,1) forwards; }
.slide-in-right { animation: slideInFromLeft 0.25s cubic-bezier(0.4,0,0.2,1) forwards; }
@keyframes slideInFromRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInFromLeft { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: translateX(0); } }

/* Drawer progress badge */
.drawer-item-badge { margin-left: auto; font-size: 10px; font-weight: 600; background: rgba(139,92,246,0.15); color: var(--purple); padding: 2px 7px; border-radius: 999px; white-space: nowrap; }