/* ============================================
   STUDY CAFE — Soft Dark + Warm Light Design
   ============================================ */

/* ===== THEME VARIABLES ===== */
:root {
    /* Rich Deep Dark Mode (from Quizzy-v4) */
    --bg-primary: #070a12;
    --bg-secondary: #0f172a;
    --bg-card: rgba(15, 23, 42, 0.88);
    --bg-hover: rgba(30, 41, 59, 0.70);
    --bg-elevated: #1e293b;

    --border: rgba(148, 163, 184, 0.18);
    --border-hover: rgba(0, 191, 165, 0.40);
    --border-strong: rgba(148, 163, 184, 0.35);

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    /* Primary Neon Mint + Indigo Accent */
    --accent: #00bfa5;
    --accent-light: #5eead4;
    --accent-dark: #00a892;
    --accent-glow: rgba(0, 191, 165, 0.25);
    --accent-glow-strong: rgba(0, 191, 165, 0.45);

    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.10);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.10);
    --success: #3dd6c4;
    --success-bg: rgba(61, 214, 196, 0.10);

    /* Answer-status palette. Shared by Test Cafe and Question Cafe so a correct
       or incorrect option looks identical in both. */
    --st-green: #22c55e;
    --st-green-bg: rgba(34, 197, 94, 0.14);
    --st-green-soft: rgba(34, 197, 94, 0.08);
    --st-red: #ef4444;
    --st-red-bg: rgba(239, 68, 68, 0.14);
    --st-red-soft: rgba(239, 68, 68, 0.08);
    --st-purple: #a855f7;
    --st-purple-bg: rgba(168, 85, 247, 0.16);
    --st-grey-bg: rgba(255, 255, 255, 0.06);

    --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Height of the sticky top navbar — sub-headers stick right below it. */
    --nav-h: 57px;
}

[data-theme="light"] {
    /* Warm Light Mode */
    --bg-primary: #f2f1ee;
    --bg-secondary: #e8e6e1;
    --bg-card: rgba(255, 255, 255, 0.75);
    --bg-hover: rgba(0, 0, 0, 0.04);
    --bg-elevated: #ffffff;

    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --border-strong: rgba(0, 0, 0, 0.20);

    --text-primary: #1c1e24;
    --text-secondary: #4a4e58;
    --text-muted: #8a8e98;
    --text-subtle: #b0b4be;

    --accent: #0d9488;
    --accent-light: #14b8a6;
    --accent-dark: #0f766e;
    --accent-glow: rgba(13, 148, 136, 0.15);
    --accent-glow-strong: rgba(13, 148, 136, 0.25);

    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.08);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.08);
    --success: #0d9488;
    --success-bg: rgba(13, 148, 136, 0.08);

    --st-green: #16a34a;
    --st-green-bg: rgba(22, 163, 74, 0.12);
    --st-green-soft: rgba(22, 163, 74, 0.06);
    --st-red: #dc2626;
    --st-red-bg: rgba(220, 38, 38, 0.10);
    --st-red-soft: rgba(220, 38, 38, 0.05);
    --st-purple: #9333ea;
    --st-purple-bg: rgba(147, 51, 234, 0.12);
    --st-grey-bg: rgba(0, 0, 0, 0.05);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* NOTE: Keep transition scoped. Do NOT add opacity/transform here — that
       would fight the screen fadeIn animation and cause the blink/flash. */
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Prevent the universal transition above from fighting .screen display changes.
   Screens switch instantly (display:none/block) and fade via @keyframes, so
   they must not carry an inherited CSS transition on opacity or visibility. */
.screen, .screen * {
    transition: none !important;
}
/* Re-allow transitions on interactive children inside active screens. */
.screen.active .mcq-option,
.screen.active .mcq-letter,
.screen.active .mcq-flag,
.screen.active .show-answer-btn,
.screen.active .explanation-box,
.screen.active .fib-answer-box,
.screen.active .subject-rect,
.screen.active .chapter-row,
.screen.active .btn,
.screen.active button,
.screen.active a {
    transition: background-color 0.2s ease, color 0.2s ease,
                border-color 0.2s ease, box-shadow 0.2s ease,
                transform 0.2s ease, opacity 0.2s ease !important;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    background-image: radial-gradient(circle at 50% -120px, rgba(0, 191, 165, 0.15) 0%, rgba(99, 102, 241, 0.08) 45%, transparent 75%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--text-secondary);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 0.95rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { 
    color: var(--accent); 
    text-decoration: none; 
    transition: all var(--transition-fast);
}
a:hover { 
    color: var(--accent-light); 
}

/* ===== NAVBAR ===== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.logo-img {
    height: 32px;
    width: auto;
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.3rem 0;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
    transition: width var(--transition-fast);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ===== SECTIONS ===== */
.section {
    padding: 2rem 0;
    border-bottom: 1px solid var(--border);
}

.section:last-child {
    border-bottom: none;
}

/* ===== HERO ===== */
.hero {
    text-align: center;
    padding: 3rem 0 2rem;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 1rem;
    border: 1px solid var(--border-hover);
    border-radius: 50px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 1.25rem;
    background: var(--bg-card);
}

.hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.15;
    margin-bottom: 0.75rem;
    letter-spacing: -0.5px;
}

.hero h1 span {
    color: var(--accent);
    text-shadow: 0 0 25px var(--accent-glow);
}

.hero p {
    font-size: 0.95rem;
    color: var(--text-muted);
    max-width: 440px;
    margin: 0 auto 1.5rem;
    line-height: 1.7;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    color: #fff;
    box-shadow: 0 2px 8px var(--accent-glow), var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--accent-glow-strong), var(--shadow-md);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-ghost {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
}

.btn-ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-hover);
    box-shadow: var(--shadow-sm);
}

.btn-sm {
    padding: 0.45rem 1rem;
    font-size: 0.8rem;
}

/* ===== SYLLABUS BUTTON & MODAL ===== */
.syllabus-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.7rem;
    font-size: 0.76rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: rgba(108, 92, 231, 0.12);
    color: var(--accent);
    border: 1px solid rgba(108, 92, 231, 0.28);
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1.2;
    text-decoration: none;
    user-select: none;
}
.syllabus-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--accent-glow);
}
.syllabus-btn.pdf {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}
.syllabus-btn.pdf:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

.syllabus-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2100;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}
.syllabus-overlay.active {
    display: flex;
}
.syllabus-panel {
    width: 100%;
    max-width: 620px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.syllabus-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.syllabus-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.syllabus-body {
    padding: 1.25rem;
    overflow-y: auto;
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 60vh;
}
.syllabus-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* ===== ROW ITEMS ===== */
.row-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
    margin: 0 -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.row-item:last-child {
    border-bottom: none;
}

.row-item:hover {
    background: var(--bg-hover);
    padding-left: 1rem;
}

.row-item:hover .row-title {
    color: var(--accent);
}

.row-icon {
    font-size: 1.3rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-shrink: 0;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.row-content {
    flex: 1;
    min-width: 0;
}

.row-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    transition: color var(--transition-fast);
}

.row-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.row-arrow {
    color: var(--text-subtle);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.row-item:hover .row-arrow {
    transform: translateX(5px);
    color: var(--accent);
}

/* ===== TAG PILLS ===== */
.tag-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.tag {
    padding: 0.35rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.tag:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-hover);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* ===== MINI STATS ===== */
.mini-stats {
    display: flex;
    gap: 2.5rem;
    justify-content: center;
    padding: 0.75rem 0;
}

.mini-stat {
    text-align: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    min-width: 80px;
}

.mini-stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    text-shadow: 0 0 10px var(--accent-glow);
}

.mini-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 0.35rem;
    font-weight: 600;
}

/* ===== STEPS ===== */
.steps-inline {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.step-inline {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    box-shadow: 0 0 8px var(--accent-glow);
}

/* ===== QUOTE ===== */
.quote-line {
    text-align: center;
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 0.75rem 0;
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    margin: 1rem 0;
}

/* ===== TESTIMONIAL ===== */
.testimonial-line {
    text-align: center;
    padding: 1rem 0;
}

.testimonial-line blockquote {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.testimonial-line cite {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== SECTION HEADER ===== */
.section-header-thin {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.section-header-thin h2 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.section-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border), var(--border-hover), var(--border));
}

/* ===== ABOUT ===== */
.about-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.8;
    text-align: center;
    max-width: 520px;
    margin: 0 auto;
}

/* ===== FOOTER ===== */
.footer {
    text-align: center;
    padding: 2rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    margin-top: 2rem;
}

.footer p {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.footer-links {
    margin-top: 0.75rem;
    font-size: 0.78rem;
}

.footer-links a {
    color: var(--text-muted);
    margin: 0 0.5rem;
    transition: all var(--transition-fast);
}

.footer-links a:hover {
    color: var(--accent);
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.08);
    box-shadow: 0 0 20px var(--accent-glow), var(--shadow-md);
}

/* ===== QUIZ SPECIFIC ===== */
.quiz-screen {
    display: none;
}

.quiz-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.quiz-progress-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.progress-bar-thin {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.progress-fill-thin {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent));
    border-radius: 2px;
    transition: width 0.4s ease;
    box-shadow: 0 0 8px var(--accent-glow);
}

.question-box {
    padding: 0 0 1.25rem;
}

.question-number {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.6rem;
}

.question-text {
    font-size: 1.1rem;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    font-weight: 600;
    overflow-wrap: break-word;
    word-break: break-word;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
    margin: 0 -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.option-row:last-child {
    border-bottom: none;
}

.option-row:hover {
    background: var(--bg-hover);
    padding-left: 1rem;
}

.option-row.selected {
    color: var(--accent);
}

.option-row.correct {
    color: var(--success);
    background: var(--success-bg);
}

.option-row.wrong {
    color: var(--error);
    background: var(--error-bg);
}

.option-letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    background: var(--bg-card);
}

.option-row:hover .option-letter {
    border-color: var(--accent);
    color: var(--accent);
}

.option-row.selected .option-letter {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 10px var(--accent-glow);
}

.option-row.correct .option-letter {
    background: linear-gradient(135deg, #16a34a, var(--success));
    border-color: var(--success);
    color: #fff;
    box-shadow: 0 0 10px rgba(61, 214, 196, 0.25);
}

.option-row.wrong .option-letter {
    background: linear-gradient(135deg, #dc2626, var(--error));
    border-color: var(--error);
    color: #fff;
    box-shadow: 0 0 10px rgba(248, 113, 113, 0.25);
}

.option-text {
    font-size: 0.92rem;
    color: var(--text-secondary);
    flex: 1;
    font-weight: 500;
}

.explanation-line {
    display: none;
    padding: 1rem;
    margin-top: 0.75rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--bg-card);
}

.explanation-line.show {
    display: block;
}

.explanation-line h4 {
    font-size: 0.78rem;
    color: var(--accent);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
}

.explanation-line p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.quiz-actions-thin {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

/* ===== RESULTS ===== */
.results-screen {
    display: none;
    text-align: center;
    padding: 2.5rem 0;
}

.results-score {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--accent);
    line-height: 1;
    text-shadow: 0 0 25px var(--accent-glow);
}

.results-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-weight: 500;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin: 2rem 0;
}

.results-stat {
    text-align: center;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    min-width: 90px;
}

.results-stat-value {
    font-size: 1.75rem;
    font-weight: 800;
}

.results-stat-value.correct { 
    color: var(--success); 
    text-shadow: 0 0 10px rgba(61, 214, 196, 0.25);
}
.results-stat-value.wrong { 
    color: var(--error); 
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.25);
}
.results-stat-value.skipped { 
    color: var(--warning); 
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.25);
}

.results-stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 0.4rem;
    font-weight: 600;
}

/* ===== LOADING ===== */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 10px var(--accent-glow);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-subtle);
}

/* ===== SELECTION ===== */
::selection {
    background: var(--accent-glow-strong);
    color: var(--text-primary);
}

/* ============================================
   SHARED APP SHELL — hamburger + slide-out menu
   Used by every page. Keep this the single source
   of truth; pages should not re-declare it inline.
   ============================================ */
.menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 10px;
    cursor: pointer;
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    transition: all var(--transition-fast);
    z-index: 1001;
}
.menu-toggle:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}
.menu-toggle span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.2s ease;
}
.menu-toggle.active span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: min(300px, 84vw);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    padding: 1rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
    z-index: 1000;
    flex-direction: column;
    gap: 0.2rem;
    overflow-y: auto;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
}
.mobile-menu.active {
    display: flex;
    animation: menuSlideIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes menuSlideIn {
    from { transform: translateX(100%); opacity: 0.4; }
    to   { transform: translateX(0);    opacity: 1; }
}

.menu-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.25rem 0.25rem 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.menu-head .menu-logo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}
.menu-head .menu-brand {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
}
.menu-head .menu-tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}
.menu-close {
    margin-left: auto;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.menu-close:hover {
    color: var(--error);
    border-color: var(--error);
    transform: rotate(90deg);
}

.menu-section {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-subtle);
    padding: 0.9rem 0.75rem 0.35rem;
}

.mobile-menu a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
}
.mobile-menu a:hover {
    color: var(--accent);
    background: var(--bg-hover);
    border-left-color: var(--accent);
}
.mobile-menu a.current {
    color: var(--accent);
    background: var(--accent-glow);
    border-left-color: var(--accent);
    font-weight: 700;
}
.mobile-menu a .mi-ico,
.mobile-menu .theme-option .mi-ico {
    width: 26px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.mobile-menu .theme-option {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
}
.mobile-menu .theme-option:hover {
    color: var(--accent);
    background: var(--bg-hover);
    border-left-color: var(--accent);
}
.theme-switch {
    margin-left: auto;
    width: 38px;
    height: 21px;
    border-radius: 50px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    position: relative;
    flex-shrink: 0;
    transition: all var(--transition-normal);
}
.theme-switch i {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all var(--transition-normal);
}
.theme-switch.on {
    background: var(--accent-glow-strong);
    border-color: var(--accent);
}
.theme-switch.on i {
    left: 19px;
    background: var(--accent);
}

.menu-foot {
    margin-top: auto;
    padding-top: 1.25rem;
    font-size: 0.72rem;
    color: var(--text-subtle);
    text-align: center;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 999;
}
.overlay.active {
    display: block;
    animation: fadeInOverlay 0.25s ease;
}
@keyframes fadeInOverlay {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ===== BACKUP & RESTORE PANEL (injected by app-shell.js) ===== */
.data-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 1100;
}
.data-overlay.active { display: block; animation: fadeInOverlay 0.25s ease; }

.data-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(460px, 92vw);
    max-height: 86vh;
    z-index: 1101;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.data-panel.active { display: flex; }

.data-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.data-panel-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.data-panel-body {
    padding: 1.25rem;
    overflow-y: auto;
}
.data-summary {
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.data-summary strong { color: var(--accent); font-weight: 700; }

.data-block {
    padding: 1.1rem;
    margin-bottom: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.data-block h4 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}
.data-block p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 0.9rem;
}
.data-block strong { color: var(--text-secondary); }
.data-block .btn { width: 100%; }
.data-import-actions { display: flex; gap: 0.6rem; }
.data-import-actions .btn { flex: 1; }

.data-status {
    min-height: 1.3rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
}
.data-status.ok { color: var(--success); }
.data-status.err { color: var(--error); }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    :root { --nav-h: 53px; }
    .navbar {
        padding: 0.75rem 1rem;
    }
    /* Tighter container on phones — gives ~8px each side instead of 24px */
    .container {
        padding: 0 0.85rem;
    }
    .nav-links {
        gap: 1rem;
    }
    .nav-links a {
        font-size: 0.78rem;
    }
    .hero h1 {
        font-size: 1.7rem;
    }
    .mini-stats {
        gap: 1rem;
    }
    .mini-stat {
        min-width: 70px;
        padding: 0.4rem 0.75rem;
    }
    .steps-inline {
        flex-direction: column;
        align-items: center;
        gap: 0.875rem;
    }
    .results-stats {
        gap: 1rem;
    }
    .results-stat {
        padding: 0.75rem 1rem;
        min-width: 75px;
    }

    /* Question text — prevent long physics/chemistry terms from overflowing */
    .question-text {
        font-size: 1rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* Quiz top-bar action row — allow wrapping */
    .quiz-actions-thin {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Button sizes — touch-friendly minimum */
    .btn {
        padding: 0.65rem 1.25rem;
        font-size: 0.85rem;
    }
    .btn-sm {
        padding: 0.4rem 0.85rem;
        font-size: 0.78rem;
    }
}

