:root {
    --primary-color: #2dd4bf; /* Teal 400 - lighter for dark mode */
    --primary-dark: #14b8a6; /* Teal 500 */
    --accent-color: #fbbf24; /* Amber 400 */
    --bg-color: #0f172a; /* Slate 900 */
    --card-bg: #1e293b; /* Slate 800 */
    --text-primary: #f1f5f9; /* Slate 100 */
    --text-secondary: #94a3b8; /* Slate 400 */
    --text-tertiary: #64748b; /* Slate 500 */
    --border-color: #334155; /* Slate 700 */
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.2);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.2);
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-serif: 'Playfair Display', serif;
    --font-arabic: 'Amiri', serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    letter-spacing: -0.02em;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    margin: 0;
    background-color: var(--bg-color);
    overflow: hidden;
}

/* Main Content Wrapper */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Top Bar (Navbar) */
.top-bar {
    height: 72px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 20;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 20px;
    color: var(--primary-color);
    margin-right: 24px;
}

.logo-icon {
    font-size: 24px;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    /* margin-right: auto; Push remaining items to right */
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 14px;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: rgba(45, 212, 191, 0.1);
    color: var(--primary-color);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-profile-compact {
    cursor: pointer;
}

.avatar {
    width: 36px;
    height: 36px;
    background-color: var(--primary-color);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

/* App Bar */
.app-bar {
    background-color: var(--card-bg); /* White background for web feel */
    color: var(--text-primary);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.app-bar h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

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

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
}

.icon-btn:hover {
    background-color: #f1f5f9;
    color: var(--primary-color);
}

/* Mode Toggle Button Internals */
/* Mode Toggle Button Internals */
.btn-icon { display: none; }
.btn-text { display: inline; }

/* Desktop Controls Layout */
@media (min-width: 641px) {
    .lesson-controls {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
        width: auto;
    }
}

/* Main Content */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 80px;
}

/* Quick Access Section */
.quick-access-section {
    padding: 0 0 24px 0;
}

.quick-access-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.quick-tile {
    flex: 0 0 160px;
    height: 100px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.quick-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.quick-tile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.quick-tile-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 8px;
}

.quick-tile-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Search Bar */
.search-bar {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 400px; /* Reduced from 600px */
    margin: 0 24px; /* Added margin */
    margin-right: auto; /* Push remaining items to right */
}

.search-icon {
    position: absolute;
    left: 16px;
    color: var(--text-tertiary);
    font-size: 20px;
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 10px 48px 10px 48px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

#search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.1);
}

.search-hint {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--primary-color);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    padding: 12px 16px;
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.2s ease-out;
}

.search-hint strong {
    color: var(--primary-color);
    font-weight: 600;
}

.search-hint .hint-key {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 8px;
}

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

#search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

#clear-search {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.hidden {
    display: none !important;
}

/* Section Header */
.section-header {
    padding: 0 0 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Surah Grid */
.surah-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Responsive grid */
    gap: 16px;
    padding: 0;
}

.surah-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 72px;
    box-shadow: var(--shadow-sm);
}

.surah-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.surah-number {
    width: 32px;
    height: 32px;
    background-color: #f0fdfa; /* Teal 50 */
    color: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-right: 12px;
    flex-shrink: 0;
}

.surah-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.surah-name-en {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.surah-verses {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.surah-name-ar {
    font-family: var(--font-arabic);
    font-size: 18px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 8px;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 20;
}

.fab:hover {
    background-color: var(--primary-dark);
    transform: scale(1.05);
}

.fab:active {
    transform: scale(0.95);
}

/* Loading Spinner */
.loading-spinner {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spacer {
    height: 80px;
}

/* --- LESSON VIEW STYLES (Dark Mode) --- */

/* --- LESSON VIEW STYLES (Dark Mode) --- */

.lesson-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #121212;
    color: #ffffff;
    overflow: hidden; /* Prevent body scroll */
}

.lesson-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 100px; /* Space for auto-advance timer */
    -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
}

/* Removed overlay specific styles as it's now a separate page */

/* Header */
.lesson-header {
    padding: 16px 24px 0 24px;
    background-color: #121212;
    flex-shrink: 0;
}

.lesson-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 24px;
}

.lesson-title-container {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.lesson-title {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
}

.lesson-subheader {
    font-size: 12px;
    color: #a0a0a0;
}

.lesson-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: #1e1e1e;
    padding: 8px 16px;
    border-radius: 32px; /* Pill shape */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.lesson-controls .icon-btn {
    color: #ffffff;
    padding: 10px;
    border-radius: 50%; /* Circular buttons */
    background-color: transparent;
    transition: all 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.mode-toggle {
    display: flex;
    background-color: #333;
    border-radius: 20px;
    padding: 2px;
    margin-right: 8px;
}

.mode-btn {
    background: none;
    border: none;
    color: #a0a0a0;
    padding: 6px 12px;
    border-radius: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mode-btn.active {
    background-color: #4ade80; /* Green active state */
    color: #000000;
}

.lesson-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 150px;
    justify-content: flex-end;
}

.stats-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #a0a0a0;
    background-color: #1e1e1e;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.stats-compact:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: #404040;
    color: #ffffff;
}

.stats-divider {
    color: #404040;
}

.icon-btn.active {
    color: #ef4444; /* Red for active mic */
    background-color: rgba(239, 68, 68, 0.1);
}

.lesson-progress-container {
    width: 100%;
    height: 4px;
    background-color: #333333;
    border-radius: 2px;
    overflow: hidden;
}

.lesson-progress-bar {
    height: 100%;
    background-color: #ffffff;
    width: 0%; /* Dynamic */
    transition: width 0.3s ease;
}

/* Removed Toolbar Styles */

/* Main Content Area */
.lesson-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Changed from center to prevent clipping */
    align-items: center;
    padding: 40px 24px; /* Increased top padding */
    overflow-y: auto;
}

/* Word Display */
.word-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center; /* Vertically align */
    gap: 16px; /* Reduced gap */
    direction: rtl; /* Arabic RTL */
    width: 100%;
    max-width: 1000px;
    padding: 10px; /* Reduced padding */
    margin-top: 10px; /* Reduced margin */
}

.word-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.word-column.active {
    border-color: #3b82f6; /* Blue border for active word */
    background-color: rgba(59, 130, 246, 0.2); /* Increased opacity */
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); /* Glow effect */
    transform: scale(1.05); /* Slight pop */
    z-index: 10; /* Ensure it sits on top */
}

.word-column.success {
    border-color: #4ade80; /* Green border */
    background-color: rgba(74, 222, 128, 0.1);
}

.word-column.error {
    border-color: #ef4444; /* Red border */
    background-color: rgba(239, 68, 68, 0.1);
}

.word-arabic {
    font-family: var(--font-arabic);
    font-size: 48px; /* Increased from 36px */
    color: #ffffff;
    line-height: 1.4;
}

.word-transliteration {
    font-size: 12px;
    color: #a0a0a0;
    font-style: italic;
}

.word-translation {
    font-size: 14px;
    color: #ffffff;
    font-weight: 500;
    margin-top: 4px;
}

/* Footer (Options) */
.lesson-footer {
    padding: 24px;
    background-color: #121212;
    flex-shrink: 0;
}

.options-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.option-btn {
    background-color: transparent;
    border: 1px solid #404040;
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.option-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: #ffffff;
}

.option-letter {
    background-color: #ffffff;
    color: #000000;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Hide options in recitation mode */
.recitation-mode .options-container {
    display: none !important;
}

/* Verse Block & Numbering */
.verse-block {
    position: relative;
    padding-top: 20px; /* Space for number */
    margin-bottom: 40px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.verse-number {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #666;
    background: #1e1e1e;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.4s ease-in-out;
    border-color: #ef4444; /* Red border on shake */
}

/* Responsive */
@media (max-width: 640px) {
    /* Header: Single Row Layout */
    .lesson-header {
        display: grid;
        grid-template-columns: minmax(0, auto) 1fr auto; /* Title, Controls, Close */
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        height: 56px; /* Fixed height to enforce compactness */
        overflow: hidden;
    }

    .lesson-header-top {
        display: contents;
    }

    .lesson-title-container {
        grid-column: 1;
        grid-row: 1;
        min-width: 0; /* Allow shrinking */
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .lesson-title {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100px;
        margin: 0;
        line-height: 1.2;
    }

    .lesson-subtitle {
        display: none;
    }

    .stats-compact {
        display: none;
    }

    /* Controls: Inline */
    .lesson-controls {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        width: 100%;
        padding: 0;
        gap: 4px;
        background: none;
        height: 100%;
    }
    
    .lesson-actions {
        grid-column: 3;
        grid-row: 1;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    /* Mobile Options */
    .options-container {
        gap: 8px;
        padding: 0 8px;
    }

    .option-btn {
        padding: 8px 12px;
        font-size: 13px;
        flex: 1 1 calc(50% - 8px); /* 2 per row */
        justify-content: center;
    }
}


    .lesson-controls > .icon-btn {
        flex: 1;
        min-width: 0;
        padding: 6px 0; /* Remove side padding completely */
        justify-content: center;
    }

    /* Mode toggle container */
    .mode-toggle {
        display: flex;
        flex: 1.5; /* Reduce from 2 */
        gap: 1px;
        margin-right: 2px;
        min-width: 0;
        background: rgba(255, 255, 255, 0.05); /* Lighter background to save visual weight */
    }

    .mode-toggle .mode-btn {
        flex: 1;
        min-width: 0;
        padding: 6px 0; /* Remove side padding */
        justify-content: center;
        border-radius: 16px; /* Tighter radius */
    }

    .lesson-controls .material-icons {
        font-size: 18px; /* Slightly smaller icons */
    }

    /* Hide Nav Buttons on Mobile */
    .lesson-controls #prev-verse, 
    .lesson-controls #next-verse {
        display: none !important;
    }

    /* Mode Toggle Icons */
    .mode-btn .btn-text { display: none; }
    .mode-btn .btn-icon { display: inline-block; font-size: 20px; vertical-align: middle; }
    
    .mode-btn {
        padding: 6px 12px; /* Adjust padding for icon */
        min-width: 44px; /* Ensure touch target */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Content */
    .lesson-content-area {
        padding: 16px 12px;
    }

    .word-row {
        gap: 12px;
        padding: 0;
        margin-top: 10px;
    }

    .word-arabic {
        font-size: 28px;
    }

    /* Footer: 2x2 Grid */
    .options-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        flex-direction: unset; /* Override previous flex-col */
        align-items: stretch;
    }

    .option-btn {
        justify-content: flex-start; /* Keep left aligned text */
        padding: 8px;
        font-size: 13px;
        height: 100%;
        min-height: 48px;
    }
}

/* --- LESSONS PAGE STYLES --- */

.lesson-section {
    margin-bottom: 32px;
}

.lesson-section h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.lesson-card-row {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.lesson-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 280px;
    cursor: pointer;
    transition: all 0.2s;
}

.lesson-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.lesson-icon {
    font-size: 24px;
    width: 48px;
    height: 48px;
    background-color: rgba(45, 212, 191, 0.1);
    color: var(--primary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lesson-details {
    flex: 1;
}

.lesson-details h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.lesson-details p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.progress-bar-sm {
    height: 4px;
    background-color: #334155;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-sm .fill {
    height: 100%;
    background-color: var(--primary-color);
}

.play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Categories */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.category-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.category-card:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

.category-card .material-icons {
    font-size: 32px;
    color: var(--accent-color);
    margin-bottom: 12px;
}

.category-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.category-card p {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Lesson List */
.lesson-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lesson-item {
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.lesson-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.lesson-number {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    width: 32px;
}

.lesson-info {
    flex: 1;
}

.lesson-info h3 {
    font-size: 14px;
    font-weight: 600;
}

.lesson-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.start-btn {
    padding: 6px 16px;
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.start-btn:hover {
    background-color: var(--primary-color);
    color: #000;
}

/* --- MODAL STYLES --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* High z-index */
    backdrop-filter: blur(4px);
    opacity: 1;
    transition: opacity 0.2s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
    display: none; /* Ensure it's hidden from layout */
}

.modal-content {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-md);
    transform: translateY(0);
    transition: transform 0.2s;
    overflow: hidden;
    position: relative;
    z-index: 1001;
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-body {
    padding: 24px;
}

.info-section {
    margin-bottom: 24px;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-section p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.example-box {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
}

.example-box ul {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
}

.example-box li {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.example-box code {
    background-color: rgba(45, 212, 191, 0.1);
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.hotkeys-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.hotkey-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.key {
    background-color: #334155;
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 2px 0 #1e293b;
}

.label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Audio Listening Indicator */
.listening-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 14px;
    color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    animation: pulse 2s infinite;
}

.listening-indicator.active {
    display: flex;
}

.listening-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.listening-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.listening-indicator .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(var(--primary-rgb), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0); }
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.recognized-text {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
    min-height: 20px;
    font-style: italic;
}

.option-btn.highlight-speech {
    background-color: rgba(var(--primary-rgb), 0.2);
    border-color: var(--primary-color);
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.3);
}

/* Auto Advance Timer */
.auto-advance-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-color);
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100;
    border: 1px solid rgba(255,255,255,0.1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.auto-advance-container.active {
    opacity: 1;
    pointer-events: all;
    transform: translateX(-50%) translateY(0);
}

.timer-circle {
    position: relative;
    width: 32px;
    height: 32px;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 32px;
    height: 32px;
}

.timer-circle-bg {
    fill: none;
    stroke: rgba(255,255,255,0.1);
    stroke-width: 3;
}

.timer-circle-progress {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 3;
    stroke-dasharray: 88; /* 2 * PI * r (r=14) */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    color: var(--text-primary);
}

.auto-advance-label {
    font-size: 14px;
    color: var(--text-primary);
}

.cancel-advance-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-advance-btn:hover {
    background: rgba(255,255,255,0.2);
    color: var(--text-primary);
}

/* Stats Modal */
.stats-modal-content {
    max-width: 500px;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.weak-words-section h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.weak-words-section h3 .material-icons {
    color: #fbbf24;
    font-size: 20px;
}

.weak-words-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.weak-word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid #fbbf24;
}

.weak-word-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.weak-word-arabic {
    font-family: 'Amiri', serif;
    font-size: 18px;
    color: var(--text-primary);
}

.weak-word-translation {
    font-size: 12px;
    color: var(--text-secondary);
}

.weak-word-attempts {
    font-size: 12px;
    color: #ef4444;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.1);
    padding: 4px 8px;
    border-radius: 12px;
}

.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-style: italic;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2px;
    margin-right: 12px;
}

.mode-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 18px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: var(--primary-color);
    color: #000;
    font-weight: 600;
}

/* Tajweed Feedback */
.tajweed-feedback {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin: 0 20px 20px;
}

.tajweed-feedback h3 {
    font-size: 16px;
    color: #4ade80;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tajweed-rule-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 8px;
}

.tajweed-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 4px;
    background: #fbbf24;
    color: #000;
}

.tajweed-badge.qalqalah { background: #fbbf24; }
.tajweed-badge.ghunnah { background: #f472b6; }
.tajweed-badge.madd { background: #60a5fa; }

.tajweed-desc {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Arabic Recitation Mode Styles */
.recitation-mode .word-translation {
    visibility: hidden;
    height: auto; /* Ensure it takes up space */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.recitation-mode .word-translation.revealed {
    visibility: visible;
    opacity: 1;
    color: #4ade80; /* Green text for revealed translation */
}

.recitation-mode .word-transliteration {
    display: none !important;
}

.recitation-mode .word-arabic {
    font-size: 32px; /* Larger Arabic */
    margin-bottom: 0;
}

.recitation-mode .word-column {
    min-width: 80px;
}

/* Scrollable Verse List */
.lesson-content-area {
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 48px; /* Space between verses */
    align-items: center;
    scroll-behavior: smooth;
}

.verse-block {
    width: 100%;
    max-width: 1000px;
    padding: 24px;
    border-radius: 16px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    opacity: 0.6; /* Dim inactive verses */
}

.verse-block.active {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: var(--border-color);
    opacity: 1;
    transform: scale(1.02);
}

.verse-number {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: block;
    text-align: center;
}

/* Mode Specific Visibility */
.recitation-mode .options-container {
    display: none !important;
}



/* Mode Toggle Styles (Restored) */
.mode-toggle {
    display: flex;
    background-color: #333;
    border-radius: 20px;
    padding: 2px;
    gap: 2px;
}

.mode-btn {
    background: none;
    border: none;
    color: #a0a0a0;
    padding: 6px 12px;
    border-radius: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mode-btn.active {
    background-color: #4ade80; /* Green for active mode */
    color: #000;
}

.mode-btn:hover:not(.active) {
    color: #fff;
}

/* Single Mic Button (Restored) */
#mic-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

#mic-btn.active {
    background-color: #ef4444;
    color: white;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

/* Verse Feedback (Subtle) */
.verse-feedback {
    font-size: 13px;
    color: var(--primary-color);
    margin-top: 12px;
    text-align: center;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.3s ease;
    font-weight: 500;
    height: 0; /* Collapsed by default */
    overflow: hidden;
}

.verse-feedback.visible {
    opacity: 1;
    transform: translateY(0);
    height: auto;
    margin-bottom: 8px;
}

.verse-feedback.success {
    color: #4ade80;
}

.verse-feedback.warning {
    color: #fbbf24;
}

.verse-feedback.error {
    color: #ef4444;
}

/* Mobile Optimization for Search & Navbar */
@media (max-width: 768px) {
    .top-bar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
        gap: 12px;
    }

    .logo {
        margin-right: auto;
        margin-bottom: 0;
    }

    .top-actions {
        margin-left: 0;
        order: 2;
    }

    .top-nav {
        order: 3;
        width: 100%;
        margin-top: 0;
        flex-wrap: wrap;
        gap: 8px;
        margin-right: 0; /* Reset margin */
    }

    .search-bar {
        width: 100%;
        max-width: 100%;
        margin: 8px 0 0 0; /* Top margin instead of bottom */
        order: 2; /* Put search bar AFTER nav items */
    }

    .nav-item {
        flex: 1;
        justify-content: center;
        font-size: 12px;
        padding: 8px;
        background-color: rgba(255, 255, 255, 0.03);
        white-space: nowrap;
    }
    
    .page-title {
        display: none;
    }
}
