:root {
    --primary: #4F46E5;
    --primary-glow: rgba(79, 70, 229, 0.4);
    --secondary: #10B981;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-glass: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: rgba(255, 255, 255, 0.1);
    --font-family: 'Outfit', sans-serif;
}

[data-theme="light"] {
    --primary: #4338ca;
    --primary-glow: rgba(67, 56, 202, 0.3);
    --background: #f1f5f9;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.8);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-image:
        radial-gradient(circle at 10% 20%, var(--primary-glow) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.15) 0%, transparent 20%);
}

.app-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.glass-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.pro-badge {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 0.8em;
    margin-left: 2px;
}

.icon-btn {
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1rem;
    padding: 0.5rem;
    border-radius: 8px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.theme-switch-wrapper {
    display: flex;
    align-items: center;
}

.theme-switch {
    display: inline-block;
    height: 34px;
    position: relative;
    width: 60px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: var(--surface);
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
}

.slider:before {
    background-color: #fff;
    bottom: 3px;
    content: "";
    height: 26px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 26px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(26px);
}

.sun-icon,
.moon-icon {
    font-size: 14px;
    user-select: none;
    z-index: 1;
}

.sun-icon {
    color: #FFD700;
}

.moon-icon {
    color: #f8fafc;
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.active-view {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero & Grid */
.hero-section {
    text-align: center;
    margin-bottom: 2rem;
}

.hero-section h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.hero-section p {
    color: var(--text-muted);
}

.menu-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}

.menu-card {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.menu-card:hover {
    transform: translateX(10px);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.menu-icon {
    font-size: 3rem;
    background: rgba(255, 255, 255, 0.05);
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    transition: transform 0.3s ease;
}

.menu-card:hover .menu-icon {
    transform: scale(1.1) rotate(5deg);
}

.menu-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.menu-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.4;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

.year-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.year-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity 0.3s;
}

.year-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.year-card:hover::before {
    opacity: 1;
}

.year-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.year-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.card-status {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--secondary);
    background: rgba(16, 185, 129, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
}

/* Quiz Styles */
.glass-card {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.progress-container {
    flex: 1;
    margin: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.5s ease;
}

.question-meta {
    margin-bottom: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.year-tag,
.category-tag {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-weight: 600;
}

.year-tag {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}

.category-tag {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary);
}

h3#question-text {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

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

.option-btn {
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.option-btn:hover:not(:disabled) {
    background: rgba(79, 70, 229, 0.05);
    border-color: var(--primary);
}

.option-letter {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Feedback States */
.option-btn.correct {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--secondary);
    color: var(--secondary);
}

.option-btn.wrong {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.feedback {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.explanation {
    margin: 1rem 0;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.55;
}

.explanation h1,
.explanation h2,
.explanation h3 {
    margin: 1.5rem 0 0.75rem 0;
    color: var(--primary);
}

.explanation h3 {
    font-size: 1.2rem;
}

.explanation p {
    margin-bottom: 1rem;
}

.explanation ul,
.explanation ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.explanation li {
    margin-bottom: 0.5rem;
}

.explanation strong {
    color: var(--secondary);
    font-weight: 700;
}

.explanation code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.primary-btn,
.secondary-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

.primary-btn {
    background: var(--primary);
    color: white;
    width: 100%;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.primary-btn:hover {
    background: #4338ca;
}

.primary-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    background: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border);
}

/* Results */
.results-card {
    text-align: center;
    max-width: 500px;
    margin: 2rem auto;
}

.results-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 1s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.score-display {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary);
    margin: 1rem 0;
}

.total-score {
    font-size: 1.5rem;
    color: var(--text-muted);
    font-weight: 400;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Loader */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--primary);
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: rotation 1s linear infinite;
    margin: 2rem auto;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Mobile */
@media (max-width: 600px) {
    .glass-card {
        padding: 1rem;
    }

    .score-display {
        font-size: 3rem;
    }

    .action-buttons {
        flex-direction: column;
    }
}

/* ========================================
   TEST MODE STYLES
   ======================================== */

/* Timer Display */
.test-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-radius: 10px;
    font-weight: 600;
    font-size: 1.1rem;
    border: 1px solid var(--border);
}

.test-timer.warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--warning);
    color: var(--warning);
    animation: pulse 1s infinite;
}

.test-timer.critical {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    color: var(--danger);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Question Navigator */
.question-navigator {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--surface-glass);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    max-height: 150px;
    overflow-y: auto;
}

.nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

.nav-btn.current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.nav-btn.answered {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.nav-btn.current.answered {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: var(--primary);
}

/* Test Mode Option States */
.option-btn.selected {
    background: rgba(79, 70, 229, 0.15);
    border-color: var(--primary);
    border-width: 2px;
}

.option-btn.selected .option-letter {
    background: var(--primary);
    color: white;
}

/* Review Mode Styles */
.option-btn.review-correct {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--secondary);
}

.option-btn.review-correct .option-letter {
    background: var(--secondary);
    color: white;
}

.option-btn.review-wrong {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

.option-btn.review-wrong .option-letter {
    background: var(--danger);
    color: white;
}

/* Test Navigation Buttons */
.test-nav-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.test-nav-buttons button {
    flex: 1;
}

/* Submit Confirmation Modal */
.submit-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.submit-modal-content {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.submit-modal h2 {
    margin-bottom: 1rem;
}

.submit-modal .stats {
    display: flex;
    justify-content: space-around;
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.submit-modal .stat-item {
    text-align: center;
}

.submit-modal .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.submit-modal .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.submit-modal .modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.submit-modal .modal-buttons button {
    flex: 1;
}

/* Review Results Header */
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--surface-glass);
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.review-score {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Mobile adjustments for test mode */
@media (max-width: 600px) {
    .quiz-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .test-timer {
        order: -1;
        width: 100%;
        justify-content: center;
    }

    .question-navigator {
        max-height: 100px;
    }

    .nav-btn {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }
}

/* Review Mode Navigator Colors */
.nav-btn.review-correct {
    background-color: var(--secondary) !important;
    /* Green */
    color: white !important;
    border-color: var(--secondary) !important;
}

.nav-btn.review-wrong {
    background-color: var(--danger) !important;
    /* Red */
    color: white !important;
    border-color: var(--danger) !important;
}

.nav-btn.review-unanswered {
    background-color: var(--warning) !important;
    /* Yellow */
    color: black !important;
    border-color: var(--warning) !important;
}

/* Highlight current question in ALL modes (Review & Exam) */
/* precise selector to override the above !important backgrounds if needed, 
   or just use box-shadow/border to indicate selection without changing the color code. */
/* Specific handling for Review Mode + Current: Keep the status color, but add a visual indicator (Border/Scale) */
.nav-btn.review-correct.current,
.nav-btn.review-wrong.current,
.nav-btn.review-unanswered.current {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px var(--background), 0 0 0 5px var(--primary);
    z-index: 10;
}

/* Bookmark Button Styles */
.bookmark-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--warning);
    outline: none;
}

.bookmark-btn:hover {
    transform: scale(1.2);
}

.bookmark-btn:active {
    transform: scale(0.9);
}

.bookmark-btn .star-filled {
    display: none;
}

.bookmark-btn.active .star-outline {
    display: none;
}

.bookmark-btn.active .star-filled {
    display: inline;
    filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.5));
}

@media (max-width: 600px) {
    .bookmark-btn {
        font-size: 1.3rem;
    }
}

#btn-bookmarks-header {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0.8;
}

#btn-bookmarks-header:hover {
    transform: scale(1.2) rotate(10deg);
    opacity: 1;
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.4));
}

@media (max-width: 600px) {
    .header-actions {
        gap: 0.8rem;
    }
}