:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --secondary: #10b981;
    --accent: #f43f5e;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --correct-bg: #d1fae5;
    --correct-text: #065f46;
    --wrong-bg: #ffe4e6;
    --wrong-text: #9f1239;
    --radius: 12px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body.dark-mode {
    --primary: #38bdf8;
    --primary-dark: #0284c7;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --correct-bg: #064e3b;
    --correct-text: #34d399;
    --wrong-bg: #4c0519;
    --wrong-text: #fb7185;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

body.dark-mode .explanation-card {
    background: #0f172a;
}

body.dark-mode .flashcard-front {
    background: linear-gradient(135deg, #1e293b, #0f172a);
}

body.dark-mode .flashcard-back {
    background: #0f172a;
}

body.dark-mode .option.selected {
    background: #0f172a;
}

body.dark-mode .option {
    background: #1e293b;
}

body.dark-mode .option:hover:not(.disabled) {
    background: #334155;
    border-color: #475569;
}

body.dark-mode .action-card {
    background: #1e293b;
}

body.dark-mode input,
body.dark-mode select {
    background-color: #0f172a;
    color: var(--text-main);
}

body.dark-mode .option-letter {
    background: #334155;
    color: var(--text-muted);
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Header */
.app-header {
    background-color: var(--bg-card);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.header-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
}

/* Container */
.app-container {
    max-width: 1000px;
    /* Expanded for better PC viewing */
    margin: 2rem auto;
    padding: 0 1.5rem;
    flex-grow: 1;
    width: 100%;
}

/* Cards */
.auth-card,
.dashboard-card,
.question-card,
.explanation-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.explanation-card {
    border-left: 4px solid var(--primary);
    background: #f0f9ff;
    padding: 1.5rem;
}

.explanation-card h4 {
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

/* Typography */
h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Buttons */
button {
    cursor: pointer;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}

.btn-secondary:hover {
    background-color: #f1f5f9;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem;
}

.btn-text:hover {
    color: var(--primary);
}

.btn-back {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.btn-back:hover {
    color: var(--text-main);
}

/* Forms & Tabs */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 10;
}

.tab-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.875rem;
}

input,
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.auth-form .btn-primary {
    width: 100%;
    margin-top: 1rem;
}

.auth-mock-notice {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    text-align: center;
    color: var(--text-muted);
}

/* Dashboard Config */
.config-group {
    margin-bottom: 2rem;
}

.subject-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
}

.chip:hover {
    background: #f1f5f9;
}

.chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Action Cards */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.action-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.action-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.action-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.125rem;
}

.action-card p {
    font-size: 0.875rem;
    margin-bottom: 0;
}

/* Quiz Area */
.quiz-header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    justify-content: space-between;
}

.progress-bar-container {
    flex-grow: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 1rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

.question-tracker {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

.question-meta {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #e0f2fe;
    color: var(--primary-dark);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.question-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2rem;
    line-height: 1.6;
}

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

.option {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.option:hover:not(.disabled) {
    background: var(--bg-main);
    border-color: #cbd5e1;
}

.option.selected {
    border-color: var(--primary);
    background: #f0f9ff;
    box-shadow: 0 0 0 1px var(--primary);
}

.option.correct {
    border-color: var(--correct-text);
    background: var(--correct-bg);
}

.option.wrong {
    border-color: var(--wrong-text);
    background: var(--wrong-bg);
}

.option.disabled {
    cursor: default;
    opacity: 0.9;
}

.option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

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

.option.correct .option-letter {
    background: var(--correct-text);
    color: white;
}

.option.wrong .option-letter {
    background: var(--wrong-text);
    color: white;
}

.option-text {
    font-size: 1rem;
}

.quiz-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

/* Flashcards */
.flashcard-container {
    perspective: 1000px;
    width: 100%;
    height: 400px;
    margin: 2rem 0;
}

.flashcard {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: white;
    border: 1px solid var(--border);
}

.flashcard-front {
    background: linear-gradient(135deg, white, #f8fafc);
}

.flashcard-back {
    transform: rotateY(180deg);
    background: #f8fafc;
    overflow-y: auto;
    align-items: flex-start;
    text-align: left;
}

.card-label {
    position: absolute;
    top: 1rem;
    left: 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.flashcard-front h3 {
    font-size: 1.5rem;
    line-height: 1.4;
    margin: 0;
}

.fc-hint {
    position: absolute;
    bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.fc-answer-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--correct-bg);
    color: var(--correct-text);
    border-radius: 4px;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.fc-correct-text {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.divider {
    height: 1px;
    background: var(--border);
    width: 100%;
    margin: 1rem 0;
}

.flashcard-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 400px;
    margin: 0 auto;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: white;
    font-size: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
    background: var(--bg-main);
    transform: translateY(-2px);
}

#fcBtnFlip {
    width: auto;
    border-radius: 999px;
    padding: 0 1.5rem;
    font-size: 1rem;
}

/* Score Screen */
.score-card {
    text-align: center;
    padding: 3rem 2rem;
}

.score-circle {
    width: 150px;
    margin: 2rem auto;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 80%;
    max-height: 250px;
}

.circle-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 3;
}

.circle {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    stroke-linecap: round;
    animation: progress 1s ease-out forwards;
}

@keyframes progress {
    0% {
        stroke-dasharray: 0 100;
    }
}

.percentage {
    fill: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 0.5em;
    font-weight: 700;
    text-anchor: middle;
}

.score-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-item:nth-child(1) .stat-value {
    color: var(--correct-text);
}

.stat-item:nth-child(2) .stat-value {
    color: var(--wrong-text);
}

.stat-item:nth-child(3) .stat-value {
    color: var(--text-muted);
}

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

.score-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #1e293b;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    font-weight: 500;
    transition: opacity 0.3s;
}

/* AdSense Integration */
.ad-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
    min-height: 90px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius);
    overflow: hidden;
}

body.dark-mode .ad-container {
    background: rgba(255, 255, 255, 0.05);
}

.premium-user .premium-hidden {
    display: none !important;
}

/* Base Responsive */
@media (max-width: 640px) {
    .action-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .config-group[style*="gap: 2rem"] {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem !important;
    }

    .config-group[style*="gap: 2rem"]>div:last-child {
        margin-left: 0 !important;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

/* Mobile Devices */
@media (max-width: 640px) {
    .app-header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .auth-card,
    .dashboard-card,
    .question-card,
    .explanation-card {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }

    .action-cards {
        grid-template-columns: 1fr;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 1.5rem;
    }

    .flashcard-container {
        height: auto;
        min-height: 400px;
    }

    .score-stats {
        gap: 1rem;
        flex-direction: column;
        align-items: center;
    }

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

    .score-actions button {
        width: 100%;
    }

    .quiz-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .quiz-header .progress-bar-container {
        margin: 0;
        width: 100%;
    }

    .question-text {
        font-size: 1.1rem;
    }

    .option {
        padding: 0.75rem 1rem;
    }

    .option-text {
        font-size: 0.95rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    /* Paywall responsiveness */
    .paywall-plan-btn>div,
    .paywall-plan-btn {
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        gap: 0.5rem;
    }
}

/* Additions for Bookmark UI */
.btn-icon-small {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--border);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0.25rem;
}

.btn-icon-small:hover {
    transform: scale(1.1);
    color: #fcd34d;
}

.btn-icon-small.active {
    color: #f59e0b;
}

.btn-got-it-wrong {
    margin-top: 2rem;
    align-self: center;
    background: transparent;
    border: 1px solid var(--wrong-text);
    color: var(--wrong-text);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 999px;
    transition: all 0.2s;
}

.btn-got-it-wrong:hover {
    background: var(--wrong-bg);
    transform: translateY(-1px);
}

/* Floating Music Player */
.music-player {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 900;
    transition: all 0.3s ease;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.music-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 4px;
    width: auto;
    min-width: 140px;
    border-color: var(--border);
}

#volumeSlider {
    width: 60px;
}

body.dark-mode .music-player {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
    .music-player {
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        justify-content: center;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-main);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
    text-align: center;
}