/* ========================================================= */
/* CSS VARIABLES - DARK THEME ONLY (ULTRA LOW MEMORY)        */
/* ========================================================= */

:root {
    --bg-base: #0a0e17;
    --bg-surface: #111827;
    --bg-surface-elevated: #1e293b;
    --bg-surface-subtle: #0f172a;
    
    --border-subtle: #1f293d;
    --border-strong: #334155;
    --border-focus: #60a5fa;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.15);
    --primary-text: #ffffff;
    
    --accent-color: #06b6d4;
    --accent-hover: #0891b2;
    
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    --card-shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.5);
    
    /* Official CBT Simulation Palette */
    --cbt-header-bg: #0f172a;
    --cbt-body-bg: #111827;
    --cbt-sidebar-bg: #0c1220;
    --cbt-footer-bg: #0f172a;
    --cbt-question-bg: #111827;
    --cbt-border: #1e293b;

    --pal-not-visited-bg: #334155;
    --pal-not-visited-border: #475569;
    --pal-not-visited-text: #f8fafc;
    
    --pal-not-answered-bg: #dc2626; /* Official Red */
    --pal-not-answered-text: #ffffff;
    
    --pal-answered-bg: #16a34a;     /* Official Green */
    --pal-answered-text: #ffffff;
    
    --pal-marked-bg: #9333ea;       /* Official Purple */
    --pal-marked-text: #ffffff;
    
    --pal-dot-color: #22c55e;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
    
    --transition-fast: 0.12s ease;
}

/* ========================================================= */
/* BASE RESET & GLOBAL STYLES                                */
/* ========================================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* KaTeX LaTeX Inline & Block Math Typography */
.katex {
    font-size: 1.05em !important;
    text-rendering: geometricPrecision;
    white-space: normal;
}
.katex-display {
    margin: 0.8em 0 !important;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
}
.katex .katex-html {
    white-space: normal;
}

/* High-efficiency Opaque Surface Panel */
.dark-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, #60a5fa 0%, #a855f7 50%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
}

/* ========================================================= */
/* BUTTONS & CONTROLS                                        */
/* ========================================================= */

button, input, select, textarea {
    font-family: inherit;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #2563eb;
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.btn-primary:hover {
    background: #3b82f6;
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn-secondary:hover {
    background: var(--border-subtle);
    border-color: var(--border-focus);
}

.btn-accent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #0891b2;
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.3);
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.btn-accent:hover {
    background: #06b6d4;
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-surface-elevated);
    border-color: var(--border-subtle);
}

.btn-block {
    width: 100%;
}
.btn-large {
    padding: 14px 28px;
    font-size: 1.05rem;
}

/* Badges & Pills */
.badge-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-blue { background: rgba(59, 130, 246, 0.18); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-red { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-green { background: rgba(34, 197, 94, 0.18); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-purple { background: rgba(168, 85, 247, 0.18); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-dark { background: var(--bg-surface-elevated); color: var(--text-primary); border: 1px solid var(--border-strong); }

.badge-status {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-valid { background: rgba(34, 197, 94, 0.2); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.4); }
.badge-invalid { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }

/* ========================================================= */
/* NAVBAR & EXAM COUNTDOWN PILL                              */
/* ========================================================= */

.global-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 28px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}
.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}
.brand-title span {
    color: var(--text-secondary);
    font-weight: 500;
}
.nav-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}
.nav-user-panel {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}
.avatar-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
}

/* Exam Countdown Badges */
.exam-countdown-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
    border: 1px solid rgba(96, 165, 250, 0.4);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.84rem;
    color: #93c5fd;
    animation: subtle-pulse 3s infinite ease-in-out;
}
.exam-countdown-pill strong {
    color: #ffffff;
    font-weight: 700;
}

@keyframes subtle-pulse {
    0%, 100% { border-color: rgba(96, 165, 250, 0.4); }
    50% { border-color: rgba(168, 85, 247, 0.7); box-shadow: 0 0 10px rgba(168, 85, 247, 0.25); }
}

.greeting-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 6px;
}
.countdown-badge-hero {
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 8px;
}
.countdown-badge-hero strong {
    color: #ffffff;
    font-size: 0.95rem;
}

.cbt-exam-countdown-tag {
    display: block;
    font-size: 0.75rem;
    color: #60a5fa;
    margin-top: 3px;
    font-weight: 600;
}

/* ========================================================= */
/* VIEW CONTAINERS                                           */
/* ========================================================= */

.view-container {
    width: 100%;
    min-height: calc(100vh - 65px);
    position: relative;
}

/* ========================================================= */
/* VIEW 1: LOGIN                                             */
/* ========================================================= */

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 85vh;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 440px;
    padding: 38px 32px;
    border-radius: var(--radius-xl);
}
.login-header {
    text-align: center;
    margin-bottom: 28px;
}
.shield-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}
.login-header h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}
.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}
.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}
.input-with-icon svg {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
}
.input-with-icon input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition-fast);
}
.input-with-icon input:focus {
    border-color: var(--border-focus);
}
.alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    margin-bottom: 18px;
}
.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #f87171;
}

/* ========================================================= */
/* VIEW 2: DASHBOARD                                         */
/* ========================================================= */

.dashboard-layout {
    max-width: 1280px;
    margin: 28px auto;
    padding: 0 24px 60px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}
.dash-hero {
    padding: 30px 36px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}
.hero-text h2 {
    font-size: 1.7rem;
    margin-bottom: 6px;
}
.hero-text p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.hero-actions {
    display: flex;
    gap: 14px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 24px;
}
.chart-card {
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 700;
}
.chart-canvas-wrapper {
    position: relative;
    height: 260px;
    width: 100%;
}

.history-card {
    padding: 24px 28px;
}
.table-responsive {
    overflow-x: auto;
    margin-top: 10px;
}
.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
}
.custom-table th {
    background: var(--bg-surface-elevated);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-strong);
}
.custom-table th:first-child { border-top-left-radius: var(--radius-sm); }
.custom-table th:last-child { border-top-right-radius: var(--radius-sm); }
.custom-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}
.custom-table tr {
    content-visibility: auto;
    contain-intrinsic-size: 0 48px;
}
.custom-table tr:hover td {
    background: var(--bg-surface-subtle);
}
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* ========================================================= */
/* VIEW 3: CREATE TEST (SPLIT-SCREEN JSON DUMP & PREVIEW)    */
/* ========================================================= */

.create-test-layout {
    max-width: 1600px;
    margin: 18px auto;
    padding: 0 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: calc(100vh - 90px);
}
.create-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}
.title-meta {
    display: flex;
    align-items: center;
    gap: 14px;
}
.title-meta h2 {
    font-size: 1.25rem;
}
.title-meta p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.create-top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.split-container {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 18px;
    flex: 1;
    min-height: 0;
}
.pane-editor, .pane-preview {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}
.pane-header {
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface-subtle);
}
.pane-title {
    display: flex;
    align-items: center;
    gap: 8px;
}
.editor-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }
.pane-label {
    font-weight: 600;
    font-size: 0.88rem;
    margin-left: 4px;
}

.editor-area-wrapper {
    flex: 1;
    position: relative;
    display: flex;
}
#json-dump-input {
    width: 100%;
    height: 100%;
    background: var(--bg-base);
    color: #38bdf8;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.6;
    padding: 16px;
    border: none;
    outline: none;
    resize: none;
    tab-size: 2;
}

.json-error-banner {
    background: rgba(239, 68, 68, 0.15);
    border-top: 1px solid rgba(239, 68, 68, 0.35);
    padding: 12px 16px;
    max-height: 120px;
    overflow-y: auto;
}
.error-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #f87171;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}
.error-details {
    color: #fca5a5;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    white-space: pre-wrap;
}

/* Right Pane Preview Body */
.preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.preview-empty-state {
    text-align: center;
    margin: auto;
    color: var(--text-muted);
}
.preview-q-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px;
    content-visibility: auto;
    contain-intrinsic-size: 0 140px;
}
.preview-q-card:hover {
    border-color: var(--border-focus);
}
.preview-q-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}
.preview-q-text {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 14px;
    color: var(--text-primary);
}
.preview-options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.preview-opt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-surface-subtle);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    font-size: 0.92rem;
    line-height: 1.5;
}
.preview-opt-item.is-correct {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
    font-weight: 600;
}
.preview-ans-box {
    background: var(--bg-surface-subtle);
    border-left: 3px solid #3b82f6;
    padding: 10px 14px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-top: 10px;
}
.preview-ans-box strong {
    color: var(--primary-color);
}

/* ========================================================= */
/* VIEW 4: SELECT TEST                                       */
/* ========================================================= */

.select-test-layout {
    max-width: 1200px;
    margin: 32px auto;
    padding: 0 24px 60px;
}

.select-header-bar {
    padding: 20px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    gap: 20px;
    flex-wrap: wrap;
}

.select-header-bar .title-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.select-header-bar .title-meta h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 3px;
}

.select-header-bar .title-meta p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0;
}

.select-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
    margin-top: 28px;
}

.test-card {
    padding: 24px 26px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--card-shadow);
    content-visibility: auto;
    contain-intrinsic-size: 0 200px;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.test-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-focus);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.test-card-top {
    margin-bottom: 22px;
}

.test-card-subject {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.test-card-name {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.45;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.test-card-info {
    font-size: 0.88rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 14px;
    padding-top: 4px;
}

.test-card-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}

.test-card-actions .btn-start-test {
    flex: 1.6;
    padding: 10px 16px;
    font-size: 0.92rem;
    font-weight: 600;
}

.test-card-actions .btn-export-json {
    flex: 1.2;
    padding: 10px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.test-card-actions .btn-delete-test {
    padding: 10px 14px;
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.08);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.test-card-actions .btn-delete-test:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ffffff;
}

/* ========================================================= */
/* VIEW 5: OFFICIAL JEE CBT TEST INTERFACE                   */
/* ========================================================= */

#view-test {
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}
.cbt-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: var(--cbt-body-bg);
}

/* CBT Top Header */
.cbt-header {
    background: var(--cbt-header-bg);
    color: #ffffff;
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--cbt-border);
    z-index: 10;
}
.cbt-branding {
    display: flex;
    align-items: center;
    gap: 16px;
}
.exam-logo-box {
    background: #ffffff;
    color: #1e3a8a;
    font-weight: 900;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}
.exam-title-box h3 {
    font-size: 1.05rem;
    color: #ffffff;
    margin-bottom: 2px;
}
.cbt-timer-box {
    background: #090d16;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 18px;
    border-radius: 8px;
    text-align: right;
}
.timer-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #93c5fd;
}
.timer-digits {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 700;
    color: #38bdf8;
}

/* CBT Body Structure */
.cbt-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* CBT Main Area */
.cbt-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 2px solid var(--cbt-border);
    background: var(--cbt-question-bg);
}
.cbt-question-nav-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-surface-subtle);
    border-bottom: 1px solid var(--cbt-border);
}
.q-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}
.q-number-pill {
    background: var(--primary-color);
    color: #ffffff;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.9rem;
}
.q-type-pill {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.q-marks-scheme {
    display: flex;
    gap: 8px;
    font-weight: 700;
    font-size: 0.85rem;
}
.mark-pos { color: #22c55e; }
.mark-neg { color: #ef4444; }

.cbt-question-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
}
.question-stem {
    font-size: 1.15rem;
    line-height: 1.8;
    margin-bottom: 28px;
    color: var(--text-primary);
}

/* Options Rendering */
.options-wrapper {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.cbt-option-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.cbt-option-item:hover {
    border-color: var(--border-focus);
    background: var(--bg-surface-subtle);
}
.cbt-option-item input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}
.cbt-option-label {
    cursor: pointer;
    font-size: 1.02rem;
    line-height: 1.6;
    flex: 1;
    color: var(--text-primary);
}
.cbt-num-input-wrapper {
    background: var(--bg-surface-elevated);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    max-width: 440px;
}
.cbt-num-input-wrapper label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.95rem;
}
.cbt-num-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.2rem;
    font-family: var(--font-mono);
    background: var(--bg-surface-subtle);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
}
.cbt-num-input:focus {
    border-color: var(--border-focus);
}
.num-hint {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* CBT Action Footer */
.cbt-action-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: var(--cbt-footer-bg);
    border-top: 1px solid var(--cbt-border);
}
.action-group-left, .action-group-right {
    display: flex;
    gap: 10px;
}
.cbt-btn {
    padding: 10px 18px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition-fast);
}
.btn-default {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-default:hover {
    background: var(--border-subtle);
}
.btn-purple {
    background: #7e22ce;
    color: #ffffff;
}
.btn-purple:hover {
    background: #6b21a8;
}
.btn-blue-save {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.btn-blue-save:hover {
    background: #1d4ed8;
}

/* CBT Right Sidebar */
.cbt-sidebar {
    width: 340px;
    display: flex;
    flex-direction: column;
    background: var(--cbt-sidebar-bg);
}
.cbt-candidate-info {
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--cbt-border);
    background: var(--bg-surface-subtle);
}
.candidate-photo {
    width: 44px;
    height: 44px;
    background: var(--bg-surface-elevated);
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}
.candidate-meta {
    display: flex;
    flex-direction: column;
}
.meta-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.candidate-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* CBT Legend Grid */
.cbt-legend-box {
    padding: 14px;
    border-bottom: 1px solid var(--cbt-border);
    background: var(--bg-surface-subtle);
}
.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.legend-item.span-2 {
    grid-column: span 2;
}

/* Exact Official Shapes & Symbols */
.pal-symbol {
    width: 26px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.pal-symbol.not-visited {
    background: var(--pal-not-visited-bg);
    border: 1px solid var(--pal-not-visited-border);
    color: var(--pal-not-visited-text);
    border-radius: 4px;
}
.pal-symbol.not-answered {
    background: var(--pal-not-answered-bg);
    color: var(--pal-not-answered-text);
    clip-path: polygon(50% 0%, 100% 25%, 100% 100%, 0% 100%, 0% 25%);
}
.pal-symbol.answered {
    background: var(--pal-answered-bg);
    color: var(--pal-answered-text);
    clip-path: polygon(50% 100%, 100% 75%, 100% 0%, 0% 0%, 0% 75%);
}
.pal-symbol.marked {
    background: var(--pal-marked-bg);
    color: var(--pal-marked-text);
    border-radius: 50%;
    width: 22px;
    height: 22px;
}
.pal-symbol.answered-marked {
    background: var(--pal-marked-bg);
    color: var(--pal-marked-text);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    position: relative;
}
.pal-symbol.answered-marked::after {
    content: '';
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 7px;
    height: 7px;
    background: var(--pal-dot-color);
    border-radius: 50%;
    border: 1px solid #ffffff;
}

/* CBT Question Palette Grid */
.cbt-palette-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 14px;
}
.palette-header-bar {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.88rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}
.palette-summary {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.palette-grid-scroll {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}
.palette-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.cbt-pal-btn {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    user-select: none;
    transition: transform var(--transition-fast);
}
.cbt-pal-btn:hover {
    transform: scale(1.06);
}
.cbt-pal-btn.current {
    box-shadow: 0 0 0 3px #38bdf8 !important;
}

.cbt-pal-btn.not-visited {
    background: var(--pal-not-visited-bg);
    border: 1px solid var(--pal-not-visited-border);
    color: var(--pal-not-visited-text);
    border-radius: 4px;
}
.cbt-pal-btn.not-answered {
    background: var(--pal-not-answered-bg);
    color: var(--pal-not-answered-text);
    clip-path: polygon(50% 0%, 100% 25%, 100% 100%, 0% 100%, 0% 25%);
}
.cbt-pal-btn.answered {
    background: var(--pal-answered-bg);
    color: var(--pal-answered-text);
    clip-path: polygon(50% 100%, 100% 75%, 100% 0%, 0% 0%, 0% 75%);
}
.cbt-pal-btn.marked {
    background: var(--pal-marked-bg);
    color: var(--pal-marked-text);
    border-radius: 50%;
    width: 42px;
    margin: 0 auto;
}
.cbt-pal-btn.answered-marked {
    background: var(--pal-marked-bg);
    color: var(--pal-marked-text);
    border-radius: 50%;
    width: 42px;
    margin: 0 auto;
    position: relative;
}
.cbt-pal-btn.answered-marked::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--pal-dot-color);
    border-radius: 50%;
    border: 1.5px solid #ffffff;
}

.cbt-submit-bar {
    padding: 14px;
    border-top: 1px solid var(--cbt-border);
    background: var(--bg-surface-subtle);
}
.btn-cbt-submit {
    width: 100%;
    padding: 12px;
    background: #16a34a;
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.35);
    transition: background var(--transition-fast);
}
.btn-cbt-submit:hover {
    background: #22c55e;
}

/* ========================================================= */
/* VIEW 6: RESULTS & PDF                                     */
/* ========================================================= */

.results-layout {
    max-width: 1000px;
    margin: 28px auto;
    padding: 0 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}
.results-score-hero {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 32px;
    text-align: center;
    gap: 20px;
}
.stat-subtitle {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}
.stat-main-number {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
}
.stat-time-number {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.2;
    color: #38bdf8;
    margin-bottom: 4px;
}
.stat-caption {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}
.metric-card {
    padding: 20px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    flex-shrink: 0;
}
.green-icon { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.red-icon { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.gray-icon { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.purple-icon { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.cyan-icon { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }

.metric-info {
    display: flex;
    flex-direction: column;
}
.metric-title {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.metric-info h3 {
    font-size: 1.45rem;
}
.text-green { color: #22c55e; }
.text-red { color: #ef4444; }

.export-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 30px;
    flex-wrap: wrap;
    gap: 20px;
    border-color: rgba(6, 182, 212, 0.3);
}
.export-text h3 {
    font-size: 1.15rem;
    margin-bottom: 4px;
}
.export-text p {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* ========================================================= */
/* PDF EXPORT STYLING                                        */
/* ========================================================= */

.hidden-pdf {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 750px;
    background: #ffffff !important;
    color: #0f172a !important;
    padding: 24px;
    font-family: Arial, sans-serif;
    line-height: 1.6;
}
.hidden-pdf * {
    color: #0f172a;
}
.pdf-header {
    border-bottom: 2px solid #2563eb;
    padding-bottom: 14px;
    margin-bottom: 24px;
}
.pdf-header h1 {
    color: #1e40af !important;
}
.pdf-header h2 {
    color: #334155 !important;
}
.pdf-q-block {
    margin-bottom: 20px;
    padding: 16px 20px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}
.pdf-q-title {
    font-weight: bold;
    font-size: 1.05em;
    margin-bottom: 12px;
    color: #0f172a !important;
    line-height: 1.6;
}
.pdf-answers {
    margin: 12px 0;
    font-size: 0.95em;
}
.pdf-ans-wrong {
    color: #dc2626 !important;
    font-weight: bold;
}
.pdf-ans-correct {
    color: #16a34a !important;
    font-weight: bold;
}
.pdf-explanation {
    background: #eff6ff !important;
    border-left: 4px solid #2563eb !important;
    padding: 12px 16px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 0.95em;
    color: #1e3a8a !important;
    line-height: 1.7;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}
.pdf-explanation * {
    color: #1e3a8a !important;
}
.pdf-time-tag {
    font-size: 0.82em;
    color: #64748b !important;
    margin-top: 8px;
}

/* ========================================================= */
/* RESPONSIVE DESIGN & TOUCH SCREEN OPTIMIZATIONS            */
/* ========================================================= */

@media (max-width: 1024px) {
    .split-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    .create-test-layout {
        height: auto;
    }
    .pane-editor {
        height: 400px;
    }
    .pane-preview {
        height: 500px;
    }
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    .results-score-hero {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Mobile & Tablet Fine-tuning */
@media (max-width: 768px) {
    .select-test-layout {
        padding: 0 16px 40px;
        margin: 16px auto;
    }
    
    .select-header-bar {
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .select-header-actions {
        flex-direction: column;
        width: 100%;
    }

    .select-header-actions button {
        width: 100%;
        min-height: 48px; /* High accessibility touch target for mobile thumbs */
        font-size: 0.95rem;
        justify-content: center;
    }

    .tests-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-top: 18px;
    }

    .test-card {
        padding: 18px;
    }

    .test-card-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .test-card-actions .btn-start-test,
    .test-card-actions .btn-export-json,
    .test-card-actions .btn-delete-test {
        width: 100%;
        min-height: 46px;
        font-size: 0.95rem;
        justify-content: center;
    }
    
    .test-card-actions .btn-delete-test {
        border-color: rgba(239, 68, 68, 0.4);
    }

    /* Navbar touch updates */
    .global-navbar {
        padding: 0 16px;
    }

    .exam-countdown-pill {
        display: none; /* Hide top header pill on small phones to keep title clear */
    }

    .hero-actions {
        flex-direction: column;
        width: 100%;
    }

    .hero-actions button {
        width: 100%;
        min-height: 48px;
    }

    /* CBT Exam Interface Mobile Responsive Fixes */
    .cbt-header {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .cbt-branding {
        gap: 8px;
    }
    
    .exam-logo-box {
        font-size: 0.8rem;
        padding: 4px 8px;
    }

    .exam-title-box h3 {
        font-size: 0.88rem;
        max-width: 160px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cbt-timer-box {
        padding: 4px 10px;
    }

    .timer-digits {
        font-size: 1.1rem;
    }

    .cbt-body {
        flex-direction: column;
        overflow-y: auto;
    }

    .cbt-main-area {
        border-right: none;
        border-bottom: 2px solid var(--cbt-border);
    }

    .cbt-question-scroll {
        padding: 16px;
    }

    .question-stem {
        font-size: 1.02rem;
        line-height: 1.6;
        margin-bottom: 20px;
    }

    /* Action Footer for Mobile - Stacks cleanly and stays accessible */
    .cbt-action-footer {
        padding: 12px;
        flex-direction: column;
        gap: 10px;
        background: var(--bg-surface);
    }

    .action-group-left, .action-group-right {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .cbt-btn {
        width: 100%;
        padding: 12px 8px;
        font-size: 0.82rem;
        text-align: center;
        justify-content: center;
        min-height: 44px;
        white-space: normal;
        line-height: 1.2;
    }

    .cbt-sidebar {
        width: 100%;
        max-width: 100%;
        border-left: none;
    }
}

/* ========================================================= */
/* AI PROMPT MODAL STYLES                                    */
/* ========================================================= */

.btn-ai-prompt {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.4);
    color: #c084fc;
}
.btn-ai-prompt:hover {
    background: rgba(168, 85, 247, 0.25);
    border-color: #c084fc;
    color: #ffffff;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-box {
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    border-color: rgba(168, 85, 247, 0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: #c084fc;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.modal-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.prompt-text-container {
    height: 280px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-strong);
}

#ai-prompt-textarea {
    width: 100%;
    height: 100%;
    background: var(--bg-base);
    color: #38bdf8;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 14px;
    border: none;
    outline: none;
    resize: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface-subtle);
}

.copy-success-msg {
    color: #4ade80;
    font-weight: 600;
    font-size: 0.88rem;
}
