/* Fonts loaded via <link> in HTML templates with font-display: swap */

:root {
    --lime-cream: #d9ed92;
    --light-green: #b5e48c;
    --light-green-2: #99d98c;
    --emerald: #76c893;
    --ocean-mist: #52b69a;
    --tropical-teal: #34a0a4;
    --bondi-blue: #168aad;
    --cerulean: #1a759f;
    --baltic-blue: #1e6091;
    --yale-blue: #184e77;

    --bg: #0f1a2e;
    --bg-glass: rgba(24, 78, 119, 0.15);
    --surface: rgba(30, 96, 145, 0.12);
    --surface-solid: #142544;
    --surface-hover: rgba(30, 96, 145, 0.22);
    --border: rgba(181, 228, 140, 0.08);
    --border-glass: rgba(181, 228, 140, 0.12);
    --text: #e8f0f2;
    --text-muted: #9bbdd4;
    --primary: #b5e48c;
    --primary-dim: rgba(181, 228, 140, 0.15);
    --primary-hover: #99d98c;
    --accent: #52b69a;
    --accent-dim: rgba(82, 182, 154, 0.15);
    --correct: #b5e48c;
    --correct-bg: rgba(181, 228, 140, 0.1);
    --wrong: #ef6f6c;
    --wrong-bg: rgba(239, 111, 108, 0.1);
    --radius: 16px;
    --radius-sm: 10px;
    --glass-blur: 20px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(82, 182, 154, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(24, 78, 119, 0.12) 0%, transparent 60%);
}

.container {
    max-width: 1020px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

header { margin-bottom: 2rem; }

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--primary);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.back {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 0.75rem;
    transition: color 0.15s;
}
.back:hover { color: var(--primary-hover); text-decoration: underline; }

/* ── Glass card ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: 1rem;
}

.card {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s, transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}
.card:hover {
    background: var(--surface-hover);
    transform: translateY(-3px);
    border-color: rgba(181, 228, 140, 0.25);
    box-shadow: var(--shadow), 0 0 24px rgba(181, 228, 140, 0.06);
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0.5rem 0;
}

.badge {
    display: inline-block;
    background: var(--primary-dim);
    color: var(--primary);
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid rgba(181, 228, 140, 0.12);
}

.chapter-num {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

/* ── Buttons ── */
.mode-btns {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--emerald));
    color: var(--bg);
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(181, 228, 140, 0.2);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-hover), var(--ocean-mist)); box-shadow: 0 4px 16px rgba(181, 228, 140, 0.3); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(10px);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--primary); }

.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; margin-top: 1.5rem; }

/* ── Progress ── */
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(181, 228, 140, 0.08);
    border-radius: 3px;
    margin-bottom: 1rem;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--emerald), var(--primary));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 10%;
}
.progress-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* ── Quiz question cards ── */
.question-card {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
    box-shadow: var(--shadow-sm);
}
.question-card.correct {
    border-color: rgba(181, 228, 140, 0.4);
    background: rgba(181, 228, 140, 0.06);
    box-shadow: 0 0 20px rgba(181, 228, 140, 0.08);
}
.question-card.wrong {
    border-color: rgba(239, 111, 108, 0.4);
    background: rgba(239, 111, 108, 0.06);
    box-shadow: 0 0 20px rgba(239, 111, 108, 0.08);
}

.question-text {
    font-size: 1rem;
    margin-bottom: 1rem;
    line-height: 1.7;
}

.options { display: flex; flex-direction: column; gap: 0.5rem; }

.option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    backdrop-filter: blur(8px);
}
.option:hover {
    background: rgba(181, 228, 140, 0.04);
    border-color: rgba(181, 228, 140, 0.2);
    box-shadow: 0 2px 8px rgba(181, 228, 140, 0.06);
}

.option input[type=radio] {
    margin-top: 0.3rem;
    accent-color: var(--primary);
}

.opt-label { font-size: 0.95rem; line-height: 1.5; }

.opt-correct {
    border-color: rgba(181, 228, 140, 0.5) !important;
    background: rgba(181, 228, 140, 0.1) !important;
    box-shadow: 0 0 12px rgba(181, 228, 140, 0.1) !important;
}
.opt-wrong {
    border-color: rgba(239, 111, 108, 0.5) !important;
    background: rgba(239, 111, 108, 0.1) !important;
    box-shadow: 0 0 12px rgba(239, 111, 108, 0.1) !important;
}

.q-feedback { margin-top: 1rem; min-height: 1rem; }
.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}
.tag-correct {
    background: var(--correct-bg);
    color: var(--correct);
    border: 1px solid rgba(181, 228, 140, 0.25);
}
.tag-wrong {
    background: var(--wrong-bg);
    color: var(--wrong);
    border: 1px solid rgba(239, 111, 108, 0.25);
}
.tag-answer {
    background: rgba(181, 228, 140, 0.06);
    color: var(--primary);
    border: 1px solid rgba(181, 228, 140, 0.2);
}

.explanation {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    backdrop-filter: blur(8px);
}

.nav-btns {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.score-box {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.score-box h2 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

/* ── Live score bar ── */
.live-score {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.ls-correct { color: var(--correct); }
.ls-wrong { color: var(--wrong); }
.ls-left { color: var(--text-muted); }

/* ── Mini progress ── */
.progress-mini {
    width: 100%;
    height: 4px;
    background: rgba(181, 228, 140, 0.08);
    border-radius: 2px;
    margin-top: 0.75rem;
    overflow: hidden;
}
.progress-mini-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--emerald), var(--primary));
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}
.progress-mini-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Accent / jumble ── */
.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--tropical-teal));
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(82, 182, 154, 0.2);
}
.btn-accent:hover { background: linear-gradient(135deg, var(--ocean-mist), var(--bondi-blue)); box-shadow: 0 4px 16px rgba(82, 182, 154, 0.3); }

/* ── Revision ── */
.btn-revise {
    background: linear-gradient(135deg, var(--cerulean), var(--baltic-blue));
    color: var(--text);
    font-weight: 500;
    box-shadow: 0 2px 12px rgba(26, 117, 159, 0.2);
}
.btn-revise:hover { background: linear-gradient(135deg, var(--bondi-blue), var(--yale-blue)); box-shadow: 0 4px 16px rgba(26, 117, 159, 0.3); }

.badge-wrong {
    display: inline-block;
    background: var(--wrong-bg);
    color: var(--wrong);
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid rgba(239, 111, 108, 0.15);
}

.revision-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.6rem 1rem;
    background: rgba(239, 111, 108, 0.08);
    border: 1px solid rgba(239, 111, 108, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--wrong);
}
.revision-icon { font-size: 1.1rem; }

/* ── Question actions row (mark review + explain) ── */
.q-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.btn-review {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-review:hover { border-color: var(--lime-cream); color: var(--lime-cream); }
.btn-review.review-active {
    background: rgba(217, 237, 146, 0.1);
    border-color: var(--lime-cream);
    color: var(--lime-cream);
}
.review-flag { font-size: 1rem; }

.btn-explain {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-explain:hover { border-color: var(--accent); color: var(--accent); }

/* ── Top bar ── */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.user-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.logout-link {
    color: var(--wrong);
    text-decoration: none;
    font-weight: 500;
    margin-left: 0.3rem;
    transition: color 0.15s;
}
.logout-link:hover { color: #ff6b6b; }

/* ── Login page ── */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}
.login-card {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: var(--shadow);
}
.login-card h1 {
    color: var(--primary);
    font-size: 1.6rem;
    margin-bottom: 0.25rem;
}
.form-group {
    text-align: left;
    margin-top: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}
.form-group input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: rgba(15, 26, 46, 0.6);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(8px);
}
.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(181, 228, 140, 0.1);
}
.btn-block {
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.65rem;
    font-size: 1rem;
}
.error-msg {
    background: var(--wrong-bg);
    color: var(--wrong);
    border: 1px solid rgba(239, 111, 108, 0.2);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* ═══════════════════════════════════════
   ANALYTICS PAGE
   ═══════════════════════════════════════ */

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
}

/* ── Summary stat cards ── */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-val {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.15rem;
}
.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}
.stat-green .stat-val { color: var(--primary); }
.stat-teal .stat-val { color: var(--accent); }
.stat-blue .stat-val { color: var(--cerulean); }
.stat-red .stat-val { color: var(--wrong); }

/* ── Chart panels ── */
.chart-panel {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.chart-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

/* ── D3 chart styling ── */
.chart-panel svg {
    width: 100%;
    overflow: visible;
}
.axis text {
    fill: var(--text-muted);
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
}
.axis line, .axis path {
    stroke: var(--border-glass);
}
.grid-line line {
    stroke: rgba(181, 228, 140, 0.06);
    stroke-dasharray: 3 3;
}

/* ── Subject breakdown table ── */
.subject-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1rem;
}
.subject-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-glass);
    font-weight: 600;
}
.subject-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(181, 228, 140, 0.04);
    vertical-align: middle;
}
.subject-table tr:hover td {
    background: rgba(181, 228, 140, 0.03);
}
.subject-table .bar-cell {
    width: 120px;
}
.mini-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    overflow: hidden;
}
.mini-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.mini-bar-fill.green { background: linear-gradient(90deg, var(--emerald), var(--primary)); }
.mini-bar-fill.teal { background: linear-gradient(90deg, var(--tropical-teal), var(--accent)); }

/* ── Subject link in table ── */
.subject-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.subject-link:hover { text-decoration: underline; }

/* ── Legend ── */
.legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

/* ── Chart tooltip ── */
.tooltip {
    position: fixed;
    background: var(--surface-solid);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text);
    pointer-events: none;
    box-shadow: var(--shadow);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.15s;
    max-width: 220px;
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

@media (max-width: 600px) {
    .container { padding: 1.25rem 1rem; }
    .grid { grid-template-columns: 1fr; }
    .mode-btns { flex-direction: column; }
    header h1 { font-size: 1.35rem; }
    .stat-row { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .stat-val { font-size: 1.4rem; }
    .stat-card { padding: 0.75rem 0.5rem; }
    .analytics-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .live-score { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0.9rem; font-size: 0.82rem; }
    .legend { gap: 0.5rem; }
    .chart-panel { padding: 1rem; }
    .chart-grid { grid-template-columns: 1fr !important; }
    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
    }
    .top-bar nav, .top-bar .analytics-link, .top-bar .mains-link, .top-bar .syllabus-link, .top-bar .notable-link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
    .user-info {
        text-align: right;
        padding-top: 0.4rem;
        border-top: 1px solid var(--border);
        justify-content: flex-end;
    }
    .option { padding: 0.85rem 0.75rem; min-height: 44px; }
    .question-card { padding: 1.1rem; }
    .score-box { padding: 1.1rem; }
    .score-box h2 { font-size: 1.15rem; }
    .btn-lg { padding: 0.7rem 1.5rem; font-size: 0.95rem; }
    .quick-access { grid-template-columns: repeat(2, 1fr); }
    .nav-btns {
        position: sticky;
        bottom: 0;
        background: var(--bg);
        padding: 0.75rem 0;
        border-top: 1px solid var(--border);
        z-index: 10;
        margin-top: 0;
    }
    .nav-btns .btn-primary { flex: 1; min-height: 48px; }
    .nav-btns .btn-secondary { min-height: 48px; }
}

@media (max-width: 380px) {
    .stat-row { grid-template-columns: 1fr 1fr; }
    .stat-val { font-size: 1.2rem; }
    .live-score { gap: 0.4rem; }
    .login-card { padding: 1.5rem 1.25rem; }
    .quick-access { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    .card:hover, .stat-card:hover, .btn:hover { transform: none; }
}

/* ── Performance: reduce heavy blur on low-end ── */
@supports not (backdrop-filter: blur(1px)) {
    .card, .question-card, .login-card, .stat-card, .chart-panel,
    .live-score, .score-box, .btn-secondary, .option, .explanation {
        background: var(--surface-solid);
    }
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}

/* ── Top bar links ── */
.analytics-link, .mains-link {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s;
}
.analytics-link { color: var(--accent); border: 1px solid var(--accent-dim); }
.analytics-link:hover { background: var(--accent-dim); }
.mains-link { color: var(--lime-cream); border: 1px solid rgba(217, 237, 146, 0.15); }
.mains-link:hover { background: rgba(217, 237, 146, 0.08); }

/* ── Latest Current Affairs section ── */
.latest-section {
    margin-bottom: 1.5rem;
}
.latest-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.latest-header h2 {
    font-size: 1rem;
    color: var(--lime-cream);
}
.latest-cards {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}
.latest-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    min-width: 140px;
    flex-shrink: 0;
    transition: all 0.15s;
}
.latest-card:hover { background: var(--surface-hover); border-color: var(--accent); }
.latest-count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--lime-cream);
}
.latest-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── Quick access cards ── */
.quick-access {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.quick-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 1rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    text-align: center;
    transition: all 0.15s;
}
.quick-card:hover { background: var(--surface-hover); transform: translateY(-2px); }
.quick-icon { font-size: 1.5rem; }
.quick-label { font-size: 0.85rem; font-weight: 600; }
.quick-meta { font-size: 0.7rem; color: var(--text-muted); }
.quick-ca { border-left: 3px solid var(--lime-cream); }
.quick-csat { border-left: 3px solid var(--accent); }
.quick-pyq { border-left: 3px solid var(--cerulean); }
.quick-mains { border-left: 3px solid var(--tropical-teal); }

/* ── Non-gradable banner ── */
.non-gradable-banner {
    padding: 0.5rem 0.75rem;
    background: rgba(82, 182, 154, 0.08);
    border: 1px solid rgba(82, 182, 154, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
}
.q-non-gradable { border-left: 3px solid var(--accent); }

/* ── Sub-topic badge ── */
.sub-topic-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: rgba(30, 96, 145, 0.2);
    border: 1px solid rgba(30, 96, 145, 0.3);
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--cerulean);
    margin-bottom: 0.5rem;
}

/* ── Reference answer area ── */
.reference-answer { margin-top: 0.75rem; }
.ref-note { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }

/* ── Solved solution ── */
.solved-solution {
    margin-top: 0.75rem;
    padding: 1rem;
    background: rgba(181, 228, 140, 0.06);
    border: 1px solid rgba(181, 228, 140, 0.15);
    border-radius: var(--radius-sm);
}
.solved-solution h4 {
    font-size: 0.85rem;
    color: var(--lime-cream);
    margin-bottom: 0.5rem;
}
.solved-solution p {
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* ── Mains Answer Writing ── */
.mains-card { border-left: 3px solid var(--tropical-teal); }
.mains-attempted { border-left-color: var(--lime-cream); }
.q-type-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.type-solved { background: rgba(181, 228, 140, 0.1); color: var(--lime-cream); border: 1px solid rgba(181, 237, 146, 0.2); }
.type-subjective { background: rgba(82, 182, 154, 0.1); color: var(--accent); border: 1px solid rgba(82, 182, 154, 0.2); }

.mains-answer-area { margin-top: 0.75rem; }
.mains-textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    margin-bottom: 0.5rem;
}
.mains-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}
.mains-textarea::placeholder { color: var(--text-muted); }

.mains-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.self-rating {
    display: flex;
    gap: 0.4rem;
}
.btn-rating {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-rating:hover { border-color: var(--accent); color: var(--accent); }

.model-answer {
    margin-top: 0.75rem;
    padding: 1rem;
    background: rgba(82, 182, 154, 0.06);
    border: 1px solid rgba(82, 182, 154, 0.15);
    border-radius: var(--radius-sm);
}
.model-answer h4 {
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

/* ── Subject/solved badges ── */
.badge-subjective {
    background: rgba(82, 182, 154, 0.1);
    color: var(--accent);
    border: 1px solid rgba(82, 182, 154, 0.15);
}
.badge-solved {
    background: rgba(181, 228, 140, 0.1);
    color: var(--lime-cream);
    border: 1px solid rgba(181, 237, 146, 0.15);
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.btn-sm { font-size: 0.8rem; padding: 0.3rem 0.6rem; }

.q-reference { border-left: 3px solid var(--text-muted); }

/* ── Syllabus link ── */
.syllabus-link {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s;
    color: var(--emerald);
    border: 1px solid rgba(118, 200, 147, 0.15);
}
.syllabus-link:hover { background: rgba(118, 200, 147, 0.08); }

/* ── Notable link ── */
.notable-link {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s;
    color: var(--tropical-teal);
    border: 1px solid rgba(52, 160, 164, 0.15);
}
.notable-link:hover { background: rgba(52, 160, 164, 0.08); }

/* ── Syllabus Tracker ── */
.syllabus-section { margin-bottom: 2rem; }
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--lime-cream);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.paper-card {
    background: var(--surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    overflow: hidden;
}
.mains-paper { border-left: 3px solid var(--accent); }

.paper-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
}
.paper-header:hover { background: var(--surface-hover); }
.paper-header h3 { font-size: 0.95rem; margin-bottom: 0.1rem; }
.paper-meta { font-size: 0.75rem; color: var(--text-muted); }
.toggle-arrow { font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s; }

.paper-body { padding: 0 1rem 0.75rem; }

.unit-card {
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
}
.unit-card:hover { border-color: var(--accent); }

.unit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.unit-header h4 { font-size: 0.85rem; font-weight: 500; }
.unit-topics-count { font-size: 0.7rem; color: var(--text-muted); }

.unit-detail { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.unit-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; line-height: 1.5; }

.topic-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.topic-tag {
    padding: 0.15rem 0.5rem;
    background: rgba(82, 182, 154, 0.08);
    border: 1px solid rgba(82, 182, 154, 0.15);
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--accent);
}

.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}
.progress-card {
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
}
.progress-card h4 {
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    color: var(--text);
}

/* ── Planner ── */
.planner-section {
    margin-bottom: 2rem;
    background: var(--surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.planner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
}
.planner-header:hover { background: var(--surface-hover); }
.planner-header h2 { font-size: 1rem; }
.planner-toggle { font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s; }

.planner-body { padding: 0 1rem 1rem; }

.planner-filters {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.planner-task {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.4rem;
    transition: all 0.15s;
}
.planner-task:hover { border-color: var(--accent); }
.task-done { opacity: 0.5; }

.task-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}
.task-check {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
}
.task-check:hover { color: var(--lime-cream); }

.task-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.task-text { font-size: 0.85rem; }
.task-done-text { text-decoration: line-through; color: var(--text-muted); }

.task-paper-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    background: rgba(30, 96, 145, 0.2);
    border-radius: 12px;
    color: var(--cerulean);
}
.task-priority {
    font-size: 0.6rem;
    padding: 0.1rem 0.35rem;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}
.priority-high { background: rgba(239, 111, 108, 0.1); color: var(--wrong); }
.priority-medium { background: rgba(82, 182, 154, 0.1); color: var(--accent); }

.task-notes-btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}
.task-notes-btn:hover { color: var(--accent); }

.task-notes-panel {
    padding: 0 0.6rem 0.5rem;
}
.task-notes-textarea {
    width: 100%;
    min-height: 60px;
    padding: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.8rem;
    resize: vertical;
}
.task-notes-textarea:focus { outline: none; border-color: var(--accent); }
.task-notes-textarea::placeholder { color: var(--text-muted); }

/* ── Resume Banner ── */
.resume-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, rgba(82, 182, 154, 0.12), rgba(30, 96, 145, 0.12));
    border: 1px solid rgba(82, 182, 154, 0.25);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}
.resume-banner:hover {
    background: linear-gradient(135deg, rgba(82, 182, 154, 0.18), rgba(30, 96, 145, 0.18));
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(82, 182, 154, 0.1);
}
.resume-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.resume-icon {
    font-size: 1.4rem;
    color: var(--accent);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(82, 182, 154, 0.15);
    border-radius: 50%;
}
.resume-text {
    display: flex;
    flex-direction: column;
}
.resume-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent);
}
.resume-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.resume-arrow {
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* ── Read More link (CA) ── */
.read-more-link {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.2rem 0.6rem;
    background: rgba(82, 182, 154, 0.1);
    border: 1px solid rgba(82, 182, 154, 0.2);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.15s;
    vertical-align: middle;
}
.read-more-link:hover {
    background: rgba(82, 182, 154, 0.18);
    border-color: var(--accent);
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal-card {
    background: var(--surface-solid);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body {
    padding: 1.25rem;
}
.modal-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.modal-note {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    min-height: 1.2rem;
}

/* ── Form Elements ── */
.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    margin-top: 0.75rem;
}
.form-input, .form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238bacc4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}
.form-select option {
    background: var(--surface-solid);
    color: var(--text);
}

/* ── Prev/next buttons ── */
.prev-btn, .next-btn { font-size: 0.85rem; }
.done-btn { font-size: 0.85rem; }

/* ── Subject card (quick access) ── */
.subject-card h2 { font-size: 0.95rem; }

/* ── Chapter card body ── */
.chapter-card .card-body { padding: 0; }

/* ── Quiz scroll-snap ── */
#single-mode {
    height: calc(100dvh - 120px);
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}
.qpanel {
    scroll-snap-align: start;
    min-height: calc(100dvh - 120px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem;
}

@media (max-width: 768px) {
    #single-mode {
        height: calc(100dvh - 100px);
    }
    .qpanel {
        min-height: calc(100dvh - 100px);
    }
}

/* ── Explanation bottom sheet ── */
.explanation-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    background: var(--surface-solid);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    overflow-y: auto;
    padding: 0.75rem 1rem 1.5rem;
}
.explanation-sheet.open {
    transform: translateY(0);
}
.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
    margin: 0 auto 0.75rem;
    opacity: 0.4;
}

/* ── Skeleton loading ── */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
.skeleton-card { height: 120px; margin-bottom: 0.75rem; }
.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-text.short { width: 60%; }
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
