/* === Design Tokens === */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #222240;
    --bg-elevated: #2a2a4a;
    --gold: #c8a45c;
    --gold-dim: #a08040;
    --gold-glow: rgba(200, 164, 92, 0.15);
    --text-primary: #f0ece4;
    --text-secondary: #a0a0b8;
    --text-muted: #6a6a80;
    --green: #4caf7c;
    --green-bg: rgba(76, 175, 124, 0.15);
    --red: #e05555;
    --red-bg: rgba(224, 85, 85, 0.15);
    --orange: #e0a040;
    --orange-bg: rgba(224, 160, 64, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --tab-height: 64px;
    --font-en: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-ar: 'Noto Sans Arabic', 'Arial', sans-serif;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: #f5f0e8;
        --bg-secondary: #ebe5d8;
        --bg-card: #ffffff;
        --bg-elevated: #f8f4ec;
        --text-primary: #1a1a2e;
        --text-secondary: #555568;
        --text-muted: #8888a0;
        --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    }
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-en);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    padding-top: var(--safe-top);
}

#app {
    min-height: calc(100dvh - var(--tab-height) - var(--safe-bottom) - var(--safe-top));
    padding-bottom: calc(var(--tab-height) + var(--safe-bottom) + 8px);
}

/* === Arabic Text === */
.ar {
    font-family: var(--font-ar);
    direction: rtl;
    text-align: right;
    font-size: 1.35em;
    line-height: 1.7;
}

.ar-inline {
    font-family: var(--font-ar);
    direction: rtl;
    unicode-bidi: isolate;
}

.transliteration {
    color: var(--text-secondary);
    font-size: 0.85em;
    font-style: italic;
}

/* === Tab Bar === */
#tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--tab-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 8px 16px;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.tab-item.active {
    color: var(--gold);
}

.tab-item svg {
    width: 22px;
    height: 22px;
}

/* Hide tab bar on lesson screens */
body.hide-tabs #tab-bar {
    display: none;
}

body.hide-tabs #app {
    padding-bottom: var(--safe-bottom);
}

/* === Screen Header === */
.screen-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 50;
}

.back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-card);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    transition: background var(--transition);
}

.back-btn:active {
    background: var(--bg-elevated);
}

.screen-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.screen-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-family: var(--font-en);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.btn-primary {
    background: var(--gold);
    color: #0f0f1a;
}

.btn-primary:active {
    background: var(--gold-dim);
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-secondary:active {
    background: var(--bg-elevated);
}

.btn-full {
    width: 100%;
}

.btn-ghost {
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

/* === Home Screen === */
.home-screen {
    padding: 20px;
}

.home-greeting {
    margin-bottom: 24px;
}

.home-greeting h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.home-greeting p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.review-banner {
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    color: #0f0f1a;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    cursor: pointer;
    transition: transform var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.review-banner:active {
    transform: scale(0.98);
}

.review-banner h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.review-banner p {
    font-size: 0.85rem;
    opacity: 0.85;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.theme-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: transform var(--transition);
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-card:active {
    transform: scale(0.98);
}

.theme-icon {
    font-size: 2.4rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gold-glow);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.theme-info {
    flex: 1;
    min-width: 0;
}

.theme-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.theme-info .theme-ar {
    font-family: var(--font-ar);
    color: var(--gold);
    font-size: 1rem;
    direction: rtl;
    unicode-bidi: isolate;
}

.theme-info .theme-progress {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.progress-bar-mini {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar-mini .fill {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* === Theme Screen === */
.theme-screen {
    padding: 0 20px 20px;
}

.lesson-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: transform var(--transition);
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    gap: 16px;
}

.lesson-card:active {
    transform: scale(0.98);
}

.lesson-card.completed {
    border-left: 3px solid var(--green);
}

.lesson-num {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--gold);
    flex-shrink: 0;
}

.lesson-card.completed .lesson-num {
    background: var(--green-bg);
    color: var(--green);
}

.lesson-info h3 {
    font-size: 1rem;
    font-weight: 600;
}

.lesson-info .lesson-ar {
    font-family: var(--font-ar);
    color: var(--text-secondary);
    font-size: 0.95rem;
    direction: rtl;
    unicode-bidi: isolate;
}

.lesson-parts {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.part-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.part-badge.done {
    background: var(--green-bg);
    color: var(--green);
}

/* === Story Screen === */
.story-screen {
    padding: 0 16px 20px;
    max-width: 500px;
    margin: 0 auto;
}

.story-setting {
    text-align: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

.dialogue-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bubble-row {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: bubbleIn 0.3s ease;
}

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.bubble-row.other {
    align-self: flex-start;
}

.bubble-row.user {
    align-self: flex-end;
}

.speaker-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding: 0 12px;
}

.bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    position: relative;
}

.bubble-row.other .bubble {
    background: var(--bg-card);
    border-bottom-left-radius: 4px;
}

.bubble-row.user .bubble {
    background: var(--gold);
    color: #0f0f1a;
    border-bottom-right-radius: 4px;
}

.bubble .arabic-text {
    font-family: var(--font-ar);
    font-size: 1.3rem;
    line-height: 1.7;
    direction: rtl;
    text-align: right;
}

.bubble .translit-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 4px;
}

.bubble-row.user .translit-text {
    color: rgba(15, 15, 26, 0.6);
}

.bubble .english-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bubble-row.user .english-text {
    color: rgba(15, 15, 26, 0.55);
    border-top-color: rgba(15, 15, 26, 0.1);
}

.english-text.hidden {
    display: none;
}

.choice-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
    max-width: 100%;
    align-self: center;
}

.choice-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.choice-row .audio-btn {
    flex-shrink: 0;
}

.choice-row .choice-btn {
    flex: 1;
}

.choice-btn {
    background: var(--bg-card);
    border: 2px solid var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    text-align: right;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

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

.choice-btn .arabic-text {
    font-family: var(--font-ar);
    font-size: 1.15rem;
    direction: rtl;
    line-height: 1.6;
}

.choice-btn .translit-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 2px;
}

.choice-btn .english-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: left;
}

.choice-btn.correct {
    border-color: var(--green);
    background: var(--green-bg);
}

.choice-btn.incorrect {
    border-color: var(--red);
    background: var(--red-bg);
}

.choice-btn.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.feedback-box {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-top: 8px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    animation: bubbleIn 0.3s ease;
}

.story-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    position: sticky;
    top: 56px;
    background: var(--bg-primary);
    z-index: 40;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: none;
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.toggle-btn.active {
    background: var(--gold-glow);
    color: var(--gold);
}

.story-next-btn {
    margin-top: 20px;
}

/* === Flashcard Screen === */
.flashcard-screen {
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cards-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 0 16px;
}

.cards-progress .bar {
    flex: 1;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
}

.cards-progress .bar .fill {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.cards-progress .count {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.flashcard-wrapper {
    width: 100%;
    max-width: 360px;
    aspect-ratio: 3 / 4;
    perspective: 1000px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

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

.flashcard-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.flashcard-front {
    background: linear-gradient(160deg, var(--bg-card), var(--bg-elevated));
    border: 1px solid rgba(200, 164, 92, 0.15);
}

.flashcard-back {
    background: linear-gradient(160deg, var(--bg-elevated), var(--bg-card));
    border: 1px solid rgba(200, 164, 92, 0.15);
    transform: rotateY(180deg);
}

.flashcard-front .card-arabic {
    font-family: var(--font-ar);
    font-size: 2.8rem;
    font-weight: 600;
    color: var(--gold);
    direction: rtl;
    margin-bottom: 12px;
}

.flashcard-front .card-translit {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.flashcard-front .tap-hint {
    position: absolute;
    bottom: 24px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.flashcard-back .card-english {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.flashcard-back .card-example {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 14px;
}

.card-example .ex-ar {
    font-family: var(--font-ar);
    font-size: 1.15rem;
    direction: rtl;
    color: var(--gold);
    margin-bottom: 4px;
}

.card-example .ex-en {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.flashcard-back .card-notes {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.swipe-actions {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    width: 100%;
    max-width: 360px;
}

.swipe-btn {
    flex: 1;
    padding: 14px;
    border-radius: var(--radius-md);
    border: none;
    font-family: var(--font-en);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all var(--transition);
    min-height: 48px;
}

.swipe-btn:active {
    transform: scale(0.96);
}

.swipe-btn.learning {
    background: var(--orange-bg);
    color: var(--orange);
    border: 1px solid rgba(224, 160, 64, 0.3);
}

.swipe-btn.known {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(76, 175, 124, 0.3);
}

.flash-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.flash-overlay.green { background: rgba(76, 175, 124, 0.2); opacity: 1; }
.flash-overlay.orange { background: rgba(224, 160, 64, 0.2); opacity: 1; }

/* Flashcard summary */
.flashcard-summary {
    padding: 40px 20px;
    text-align: center;
}

.summary-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--gold-glow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    border: 2px solid var(--gold);
}

.summary-circle .num {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--gold);
}

.summary-circle .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.summary-stats {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-bottom: 32px;
}

.summary-stat {
    text-align: center;
}

.summary-stat .num {
    font-size: 1.5rem;
    font-weight: 700;
}

.summary-stat .label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.summary-stat.known .num { color: var(--green); }
.summary-stat.learning .num { color: var(--orange); }

/* === Quiz Screen === */
.quiz-screen {
    padding: 0 20px 20px;
}

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 20px;
}

.quiz-progress .bar {
    flex: 1;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
}

.quiz-progress .bar .fill {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.quiz-progress .count {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.quiz-question {
    animation: bubbleIn 0.3s ease;
}

.quiz-question .q-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.quiz-question .q-text {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 24px;
}

.quiz-question .q-text .ar-inline {
    font-size: 1.4rem;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    background: var(--bg-card);
    border: 2px solid var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-family: var(--font-en);
    font-size: 1rem;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.quiz-option:active {
    transform: scale(0.98);
}

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

.quiz-option.incorrect {
    border-color: var(--red);
    background: var(--red-bg);
    color: var(--red);
}

.quiz-option.disabled {
    pointer-events: none;
}

.quiz-option.dim {
    opacity: 0.5;
}

.quiz-option .option-ar {
    font-family: var(--font-ar);
    font-size: 1.2rem;
    direction: rtl;
}

.quiz-explanation {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-top: 16px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    animation: bubbleIn 0.3s ease;
}

.quiz-fill-input {
    width: 100%;
    background: var(--bg-card);
    border: 2px solid var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-family: var(--font-ar);
    font-size: 1.3rem;
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    outline: none;
    transition: border-color var(--transition);
}

.quiz-fill-input:focus {
    border-color: var(--gold);
}

.quiz-fill-input.correct {
    border-color: var(--green);
    background: var(--green-bg);
}

.quiz-fill-input.incorrect {
    border-color: var(--red);
    background: var(--red-bg);
}

.quiz-submit-btn {
    margin-top: 12px;
}

.quiz-next-btn {
    margin-top: 20px;
}

/* Quiz Results */
.quiz-results {
    padding: 40px 20px;
    text-align: center;
}

.results-score {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.results-score.great {
    background: var(--green-bg);
    border: 2px solid var(--green);
}

.results-score.ok {
    background: var(--orange-bg);
    border: 2px solid var(--orange);
}

.results-score.poor {
    background: var(--red-bg);
    border: 2px solid var(--red);
}

.results-score .score-num {
    font-size: 2.6rem;
    font-weight: 700;
}

.results-score.great .score-num { color: var(--green); }
.results-score.ok .score-num { color: var(--orange); }
.results-score.poor .score-num { color: var(--red); }

.results-score .score-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.results-message {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.results-detail {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
    margin: 0 auto;
}

/* === Review Screen === */
.review-screen {
    padding: 20px;
}

.review-empty {
    text-align: center;
    padding: 60px 20px;
}

.review-empty .empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.review-empty h2 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.review-empty p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* === Progress Screen === */
.progress-screen {
    padding: 20px;
}

.progress-screen h1 {
    font-size: 1.4rem;
    margin-bottom: 24px;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
}

.stat-card .stat-num {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.vocab-mastery {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.vocab-mastery h3 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.mastery-bar {
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.mastery-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--green));
    border-radius: 4px;
    transition: width 0.4s ease;
}

.mastery-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* === Lesson Launcher === */
.lesson-launcher {
    padding: 0 20px 20px;
}

.launcher-hero {
    text-align: center;
    padding: 32px 20px;
}

.launcher-hero .lesson-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.launcher-hero h2 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.launcher-hero .lesson-ar-title {
    font-family: var(--font-ar);
    font-size: 1.4rem;
    color: var(--gold);
    direction: rtl;
}

.launcher-parts {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.launcher-part {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: transform var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.launcher-part:active {
    transform: scale(0.98);
}

.launcher-part.locked {
    opacity: 0.5;
    pointer-events: none;
}

.part-icon {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.launcher-part.done .part-icon {
    background: var(--green-bg);
}

.part-info h3 {
    font-size: 1rem;
    font-weight: 600;
}

.part-info p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* === Page Transitions === */
#app.slide-left {
    animation: slideLeft 0.25s ease;
}

#app.slide-right {
    animation: slideRight 0.25s ease;
}

@keyframes slideLeft {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideRight {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* === Breadcrumbs === */
.breadcrumbs {
    padding: 0 20px 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--gold);
}

/* === Streak === */
.streak-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--orange-bg);
    color: var(--orange);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.streak-fire {
    font-size: 1rem;
}

.streak-card {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-elevated));
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    margin-bottom: 16px;
    border: 1px solid rgba(224, 160, 64, 0.15);
}

.streak-big {
    font-size: 3rem;
    font-weight: 700;
}

.streak-label {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 4px;
}

.streak-best {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === Trouble Words === */
.trouble-preview {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.trouble-word {
    font-family: var(--font-ar);
    font-size: 1.1rem;
    color: var(--gold);
    background: var(--gold-glow);
    padding: 4px 10px;
    border-radius: 8px;
    direction: rtl;
}

.trouble-more {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-left: auto;
}

.trouble-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.trouble-section h3 {
    font-size: 1rem;
}

.link-gold {
    color: var(--gold);
    text-decoration: none;
    font-size: 0.82rem;
}

.trouble-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.trouble-ar {
    font-family: var(--font-ar);
    font-size: 1.15rem;
    color: var(--gold);
    direction: rtl;
    min-width: 60px;
}

.trouble-en {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.trouble-count {
    font-size: 0.78rem;
    color: var(--red);
    background: var(--red-bg);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* Mistakes page */
.mistakes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mistake-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
}

.mistake-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 4px;
}

.mistake-english {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.mistake-count {
    font-size: 0.78rem;
    color: var(--red);
    margin-top: 6px;
}

/* === Locked Lessons === */
.lesson-card.locked {
    opacity: 0.5;
    cursor: default;
}

.lesson-locked-msg {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 4px;
}

/* === Speaking Practice === */
.speaking-screen {
    padding: 0 20px 20px;
}

.speak-card {
    text-align: center;
    padding: 20px 0;
}

.speak-instruction {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.speak-english {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.5;
}

.speak-hint {
    margin-bottom: 24px;
}

.speak-answer {
    margin-top: 20px;
    animation: bubbleIn 0.3s ease;
}

.speak-arabic {
    font-family: var(--font-ar);
    font-size: 2.2rem;
    color: var(--gold);
    direction: rtl;
    margin-bottom: 16px;
}

.speak-audio {
    margin-bottom: 16px;
}

.speak-example {
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 20px;
}

.speak-example .ex-ar {
    font-family: var(--font-ar);
    font-size: 1.1rem;
    direction: rtl;
    color: var(--gold);
    margin-bottom: 4px;
}

.speak-example .ex-en {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.speak-rate {
    display: flex;
    gap: 12px;
}

/* === Conversation Builder === */
.conv-screen {
    padding: 0 20px 20px;
}

.conv-exercise {
    padding: 16px 0;
}

.conv-prompt {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.5;
    text-align: center;
}

.conv-dropzone {
    min-height: 60px;
    background: var(--bg-card);
    border: 2px dashed var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
}

.conv-placeholder {
    color: var(--text-muted);
    font-size: 0.88rem;
    width: 100%;
    text-align: center;
}

.conv-wordbank {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.word-chip {
    font-family: var(--font-ar);
    font-size: 1.1rem;
    direction: rtl;
    background: var(--bg-card);
    border: 1px solid var(--bg-elevated);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.word-chip:active {
    transform: scale(0.95);
}

.word-chip.used {
    opacity: 0.3;
    pointer-events: none;
}

.word-chip.in-zone {
    background: var(--gold-glow);
    border-color: var(--gold);
    color: var(--gold);
    cursor: pointer;
}

.conv-actions {
    display: flex;
    gap: 12px;
}

.conv-actions .btn {
    flex: 1;
}

.conv-correct-answer {
    font-family: var(--font-ar);
    font-size: 1.15rem;
    color: var(--gold);
}

/* === Audio === */
.bubble-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.bubble-top .arabic-text {
    flex: 1;
}

.bubble-top .audio-btn {
    flex-shrink: 0;
    margin-top: 4px;
}

.audio-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--gold-glow);
    color: var(--gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition);
    vertical-align: middle;
}

.audio-btn:active {
    background: var(--gold);
    color: #0f0f1a;
}

/* === Grammar Tips === */
.grammar-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 12px;
    border-left: 3px solid var(--gold);
}

.grammar-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.grammar-title-ar {
    font-family: var(--font-ar);
    font-size: 1rem;
    color: var(--gold);
    direction: rtl;
    margin-bottom: 10px;
}

.grammar-body {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
}

.grammar-examples {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}

.grammar-ex {
    font-size: 0.88rem;
    color: var(--text-secondary);
    padding: 4px 0;
    line-height: 1.6;
}

/* === Settings Toggle === */
.settings-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.settings-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-elevated);
    border-radius: 28px;
    cursor: pointer;
    transition: background var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--gold);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* === Utilities === */
.fade-in {
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hidden {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 0;
}
