/* 
============================================================================
   Thai Learning App - Complete Optimized Stylesheet
   ============================================================================ */

/* ============================================================================
   1. CSS RESET & GLOBAL VARIABLES
   ============================================================================ */

:root {
    /* The order matters: English first, then Farsi, then Thai, then generic fallbacks */
    --font-primary:
        "Inter", "Vazirmatn", "Prompt", system-ui, -apple-system, sans-serif;

    /* Core colors */
    --primary: #2563eb;
    --primary-light: #60a5fa;
    --primary-dark: #1d4ed8;
    --bg: #ffffff;
    --text: #1a1a1a;
    --card: #f8fafc;
    --border: #e2e8f0;
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --text-secondary: #64748b;

    /* Language-specific colors */
    --thai-color: #1d4ed8;
    --english-color: #059669;
    --farsi-color: #b91c1c;

    /* Interactive states */
    --hover-bg: rgba(0, 0, 0, 0.05);

    /* Consonant class colors */
    --middle-class: #059669;
    --high-class: #dc2626;
    --low-class: #2563eb;
}

.dark-theme {
    --bg: #0f172a;
    --text: #f1f5f9;
    --card: #1e293b;
    --border: #334155;
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --text-secondary: #94a3b8;
    --thai-color: #60a5fa;
    --english-color: #34d399;
    --farsi-color: #f87171;
    --hover-bg: rgba(255, 255, 255, 0.05);

    --middle-class: #34d399;
    --high-class: #f87171;
    --low-class: #60a5fa;
}

.material-icons {
    font-family: "Material Symbols Outlined" !important; /* Crucial: Overrides the body font */
    font-weight: normal;
    font-style: normal;
    font-size: 24px; /* Adjust to your preferred icon size */
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;

    /* Support for all WebKit browsers. */
    -webkit-font-smoothing: antialiased;
    /* Support for Safari and Chrome. */
    text-rendering: optimizeLegibility;
    /* Support for Firefox. */
    -moz-osx-font-smoothing: grayscale;
    /* Support for IE and Edge. Enables the text-to-icon ligatures */
    font-feature-settings: "liga";
}

/* ============================================================================
   2. BASE STYLES & TYPOGRAPHY
   ============================================================================ */

body {
    margin: 0;
    padding-top: 0;
    background: var(--bg);
    color: var(--text);
    transition:
        background 0.3s,
        color 0.3s;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Font Families */
body {
    font-family: var(--font-primary);
    font-weight: 400;
    line-height: 1.6; /* Slightly increased line height accommodates Thai tone marks and Farsi diacritics */
}
/* 1. Modern Multilingual (Recommended Default)
   Prioritizes clean English (Inter), gracefully falls back to 
   Farsi (Vazirmatn), then Modern Thai (Prompt). */
body.font-modern {
    font-family:
        "Inter",
        "Vazirmatn",
        "Prompt",
        system-ui,
        -apple-system,
        sans-serif;
}

/* 2. Traditional Multilingual
   Uses a classic serif aesthetic for Thai, while maintaining modern 
   readability for English and Farsi. */
body.font-traditional {
    font-family: "Inter", "Vazirmatn", "Noto Serif Thai", Georgia, serif;
}

/* Language-specific text direction */
:lang(fa) {
    direction: rtl;
}

:lang(th),
:lang(en) {
    direction: ltr;
    text-align: left;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text);
    font-weight: 700;
}

.block-heading {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--primary-light);
    opacity: 0.9;
}

.block-heading:first-of-type {
    margin-top: 0.5rem;
}

/* ============================================================================
   3. LAYOUT & STRUCTURE
   ============================================================================ */

/* Toolbar */
#app-toolbar {
    position: sticky;
    top: 0;
    width: 100%;
    height: 56px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.toolbar-left header {
    padding: 1rem;
}
.toolbar-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 4px;
}

/* Main Content */
#main-content {
    position: relative;
    z-index: 1;
}

/* Cards */
.card,
.card-help {
    background: var(--card);
    margin: 12px;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

.card-help {
    margin: 0;
    padding: 5px;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    15% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    85% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* ============================================================================
   4. MEDIA PLAYER
   ============================================================================ */

#media-player-container:empty {
    display: none;
}

#media-player-container:not(:empty) {
    display: block;
    position: sticky;
    top: 56px;
    z-index: 950;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

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

.media-row {
    position: sticky;
    top: 56px;
    width: 100%;
    height: 50px;
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--primary);
    z-index: 950;
}

.media-col {
    display: flex;
    align-items: center;
    gap: 2vw;
    flex-shrink: 0;
}

.media-col.middle {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.player-ctrl {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 24px;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-ctrl:hover {
    background: rgba(0, 0, 0, 0.05);
}

.media-text-display {
    max-width: calc(100% - 100px);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================================
   5. DOCUMENT VIEW
   ============================================================================ */

/* Scroll offset for fixed headers */
/* Scroll offset for fixed headers - adjust these values */
.document-content .source-wrapper,
.document-content .word-card,
.document-content .sentence-group,
.document-content .words-grid,
.section-details,
.active-highlight,
.alphabet-grid-item,
.character-grid-item,
.alphabet-table-container,
.tone-rule-table-container {
    scroll-margin-top: 146px;
    /* Increased from 126px for alphabet content */
}

body:not(.has-media-bar) .document-content .source-wrapper,
body:not(.has-media-bar) .document-content .word-card,
body:not(.has-media-bar) .document-content .sentence-group,
body:not(.has-media-bar) .document-content .words-grid,
body:not(.has-media-bar) .section-details,
body:not(.has-media-bar) .active-highlight,
body:not(.has-media-bar) .alphabet-grid-item,
body:not(.has-media-bar) .character-grid-item,
body:not(.has-media-bar) .alphabet-table-container,
body:not(.has-media-bar) .tone-rule-table-container {
    scroll-margin-top: 86px;
    /* Increased from 76px */
}

.document-content {
    padding-bottom: 20px;
    scroll-padding-top: 146px;
}

.document-content [data-text] {
    cursor: pointer;
}

.document-content > .doc-title {
    margin: 0 12px 15px;
    padding: 15px;
    background: var(--card);
    border-radius: 8px;
    font-size: 1.4rem;
}

/* Section Details */
.section-details {
    margin: 12px 8px;
    border-radius: 8px;
    background: var(--card);
    overflow: hidden;
    border: 1px solid var(--border);
}

.section-details summary {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
    transition: background-color 0.2s;
    list-style: none;
}

.section-details summary:hover {
    background-color: var(--hover-bg);
}

.section-details summary::-webkit-details-marker {
    display: none;
}

.section-details summary::before {
    content: "chevron_right";

    /* 1. Update to the exact name used in your new HTML <link> */
    font-family: "Material Symbols Outlined" !important;

    /* 2. CRITICAL: Enable ligatures so the text becomes the icon */
    font-feature-settings: "liga";
    -webkit-font-feature-settings: "liga";

    /* 3. Standard Material Symbols rendering properties */
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    display: inline-block;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;

    /* Your original styling */
    font-size: 0.9rem;
    transition: transform 0.2s;
    color: var(--primary);
}

.section-details[open] summary {
    background-color: rgba(37, 99, 235, 0.1);
    border-bottom: 1px solid var(--primary);
}

.section-details[open] summary::before {
    transform: rotate(90deg);
}

.section-title-text {
    flex: 1;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.section-card {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ============================================================================
   6. BUTTONS
   ============================================================================ */

.doc-quiz-btn,
.section-quiz-btn,
.btn-flashcard,
.btn-flashcard-small,
.btn-activity,
.btn-sentence-game,
.btn-sentence-game-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 8px;
    white-space: nowrap;
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.doc-quiz-btn:hover,
.section-quiz-btn:hover,
.btn-flashcard:hover,
.btn-flashcard-small:hover,
.btn-activity:hover,
.btn-sentence-game:hover,
.btn-sentence-game-small:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.doc-quiz-btn .material-icons,
.section-quiz-btn .material-icons,
.btn-flashcard .material-icons,
.btn-flashcard-small .material-icons,
.btn-activity .material-icons,
.btn-sentence-game .material-icons,
.btn-sentence-game-small .material-icons {
    font-size: 18px;
}

/* Size variations */
.doc-quiz-btn,
.btn-flashcard,
.btn-activity {
    padding: 10px 16px;
    font-size: 0.95rem;
}

.section-quiz-btn,
.btn-flashcard-small,
.btn-sentence-game-small {
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* Document level controls */
.document-controls-wrapper {
    display: flex;
    flex-direction: row;
    gap: 12px;
    padding: 8px;
    flex-wrap: wrap;
}

.document-controls-wrapper > * {
    flex: 1;
    min-width: 120px;
}

/* Section level controls */
.section-all-controls {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    margin-bottom: 16px;
}

.section-all-controls > * {
    flex: 1;
    min-width: 100px;
}

/* Explanation Details */
.explanation-details {
    margin: 16px 8px;
    border-radius: 8px;
    background: var(--card);
    overflow: hidden;
    border: 1px solid var(--border);
}

.explanation-details summary {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
    transition: background-color 0.2s;
    list-style: none;
}

.explanation-details summary:hover {
    background-color: var(--hover-bg);
}

.explanation-details summary::-webkit-details-marker {
    display: none;
}

.explanation-details summary::after {
    content: "expand_more";
    /* 1. Update to the exact name used in your new HTML <link> */
    font-family: "Material Symbols Outlined" !important;

    /* 2. CRITICAL: Enable ligatures so the text becomes the icon */
    font-feature-settings: "liga";
    -webkit-font-feature-settings: "liga";

    /* 3. Standard Material Symbols rendering properties */
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    display: inline-block;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;

    margin-left: auto;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
    font-size: 24px;
}

.explanation-details[open] summary::after {
    transform: rotate(180deg);
}

.explanation-details summary .material-icons {
    color: var(--primary);
    font-size: 20px;
}

.explanation-details[open] summary {
    background-color: rgba(37, 99, 235, 0.1);
    border-bottom: 1px solid var(--primary);
}

.explanation-content {
    padding: 16px;
    margin: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

.explanation-content p {
    margin: 0;
    line-height: 1.6;
    white-space: pre-line;
}

/* Dark theme button consistency */
.dark-theme .doc-quiz-btn,
.dark-theme .section-quiz-btn,
.dark-theme .btn-flashcard,
.dark-theme .btn-flashcard-small,
.dark-theme .btn-activity,
.dark-theme .btn-sentence-game,
.dark-theme .btn-sentence-game-small {
    background: var(--primary);
    color: white;
}

.dark-theme .doc-quiz-btn:hover,
.dark-theme .section-quiz-btn:hover,
.dark-theme .btn-flashcard:hover,
.dark-theme .btn-flashcard-small:hover,
.dark-theme .btn-activity:hover,
.dark-theme .btn-sentence-game:hover,
.dark-theme .btn-sentence-game-small:hover {
    background: var(--primary-dark);
}

/* ============================================================================
   7. LIBRARY COMPONENT
   ============================================================================ */

.library-container {
    padding: 0 12px;
    margin-top: 10px;
}

.library-section {
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--card);
    overflow: hidden;
    border: 1px solid var(--border);
}

.library-summary {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
    transition: background-color 0.2s;
    list-style: none;
}

.library-summary:hover {
    background-color: var(--hover-bg);
}

.library-summary::-webkit-details-marker {
    display: none;
}

.library-summary .material-icons {
    font-size: 20px;
    transition: transform 0.2s;
    color: var(--primary);
}

.library-section[open] .library-summary .material-icons {
    transform: rotate(180deg);
    background-color: rgba(37, 99, 235, 0.1);
}

.library-title {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-count {
    font-size: 0.85rem;
    opacity: 0.7;
}

.library-docs {
    padding: 8px 0;
    border-top: 1px solid var(--border);
}

.doc-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    text-align: left;
    color: var(--text);
    cursor: pointer;
    transition: background-color 0.2s;
    gap: 12px;
}

.doc-btn:hover {
    background-color: var(--hover-bg);
}

.doc-btn-icon {
    font-size: 20px;
    color: var(--primary);
    opacity: 0.8;
}

.doc-btn-text {
    flex-grow: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-btn-arrow {
    font-size: 20px;
    opacity: 0.5;
}

.doc-btn.last-opened {
    border-left: 3px solid var(--primary);
    background-color: rgba(37, 99, 235, 0.05);
}

.doc-btn.last-opened .doc-btn-icon {
    color: var(--primary);
}

.dark-theme .doc-btn.last-opened {
    background-color: rgba(59, 130, 246, 0.15);
}

/* ============================================================================
   8. SENTENCE & WORD COMPONENTS
   ============================================================================ */

.sentence-group {
    display: inline-block;
    vertical-align: top;
    margin: 0 1rem 1rem 0;
    padding: 0 1rem 1rem 0;
    border-right: 1px solid #3b82f626;
}

/* Clickable text hover effects */
.sentence-group [data-text]:hover,
.word-card [data-text]:hover,
.flashcard-front[data-text]:hover,
.flashcard-translation-item[data-text]:hover {
    background-color: rgba(37, 99, 235, 0.1);
    border-radius: 4px;
}

.stack-column {
    display: inline-flex;
    flex-direction: column;
    vertical-align: top;
}

.stack-item {
    width: 100%;
    display: block;
}

.stack-item.source {
    font-size: 1.2rem;
    color: var(--thai-color);
    line-height: 1.8;
    word-break: break-word;
    font-family: inherit;
}

.stack-item.trans {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Word blocks */
.sent-word-block,
.words-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin: 0.5rem 0 1rem 0;
}

.sent-word-item,
.word-card {
    display: inline-flex;
    flex-direction: column;
    vertical-align: top;
    border-radius: 6px;
    transition: background-color 0.2s;
    cursor: pointer;
    padding: 4px 0;
}

.sent-word-item:hover {
    background-color: var(--hover-bg);
}

.sent-word-source,
.word-source {
    color: var(--thai-color);
    font-family: inherit;
}

.word-source {
    font-size: 1.1rem;
}

.sent-word-trans {
    font-size: 0.85em;
    opacity: 0.8;
}

/* Thai spans in source text */
.word-span {
    display: inline-block;
    border-radius: 3px;
    cursor: pointer;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.word-span:hover {
    color: var(--thai-color);
    border-bottom-color: var(--thai-color);
    background-color: rgba(37, 99, 235, 0.1);
}

.word-span.matched-word {
    display: inline-block;
    background-color: rgba(37, 99, 235, 0.1);
    border-radius: 4px;
    cursor: pointer;
    color: var(--thai-color);
    font-family: inherit;
}

.word-span.matched-word:hover {
    background-color: var(--hover-bg);
    border-bottom: var(--primary-light) 1px solid;
}

.unmatched-text {
    display: inline;
    opacity: 0.7;
    color: var(--text);
    font-family: inherit;
}

/* ============================================================================
   9. HIGHLIGHTING SYSTEM
   ============================================================================ */

.active-highlight {
    background-color: #fbbf24 !important;
    color: #000000 !important;
    transition: all 0.2s ease;
}

.dark-theme .active-highlight {
    background-color: #fcd34d !important;
    color: #000000 !important;
}

/* Highlighting for English/Farsi translation word spans */
.word-span.active-highlight {
    background-color: #fbbf24 !important;
    color: #000000 !important;
    border-radius: 3px;
    transition: background-color 0.1s ease;
}

.dark-theme .word-span.active-highlight {
    background-color: #fcd34d !important;
    color: #000000 !important;
}
.stack-item.source.active-highlight {
    background-color: #fbbf24 !important;
    color: #000000 !important;
}

.dark-theme .stack-item.source.active-highlight {
    background-color: #fcd34d !important;
    color: #000000 !important;
}

.sent-word-item.active-highlight {
    background-color: rgba(251, 191, 36, 0.3) !important;
}

.sent-word-item.active-highlight .sent-word-source {
    color: #000000 !important;
}

.dark-theme .sent-word-item.active-highlight {
    background-color: rgba(252, 211, 77, 0.3) !important;
}

.dark-theme .sent-word-item.active-highlight .sent-word-source {
    color: #000000 !important;
}

/* Expanded to explicitly force text color change on child word spans for EN/FA */
.word-trans.active-highlight,
.word-trans.active-highlight .word-span,
.sent-word-trans.active-highlight,
.sent-word-trans.active-highlight .word-span {
    background-color: #fbbf24 !important;
    color: #000000 !important;
}
.dark-theme .word-trans.active-highlight,
.dark-theme .word-trans.active-highlight .word-span,
.dark-theme .sent-word-trans.active-highlight,
.dark-theme .sent-word-trans.active-highlight .word-span {
    background-color: #fcd34d !important;
    color: #000000 !important;
}

.word-card .word-source.active-highlight {
    background-color: #fbbf24 !important;
    color: #000000 !important;
}

.dark-theme .word-card .word-source.active-highlight {
    background-color: #fcd34d !important;
    color: #000000 !important;
}

[data-link].active-highlight,
span[data-link].active-highlight,
div[data-link].active-highlight {
    background-color: #fbbf24 !important;
    color: #000000 !important;
}

.dark-theme [data-link].active-highlight,
.dark-theme span[data-link].active-highlight,
.dark-theme div[data-link].active-highlight {
    background-color: #fcd34d !important;
    color: #000000 !important;
}

/* Language-specific text colors */
.lang-fa {
    color: var(--farsi-color);
    font-weight: 500;
}

.lang-en {
    color: var(--english-color);
    font-weight: 500;
}

/* ============================================================================
   10. GRAMMAR ICONS
   ============================================================================ */

.grammar-icon-btn,
.grammar-icon-btn-inline {
    background: none;
    border: none;
    color: var(--thai-color);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.grammar-icon-btn:hover,
.grammar-icon-btn-inline:hover {
    background: rgba(29, 78, 216, 0.1);
    transform: scale(1.1);
}

.grammar-icon-btn .material-icons,
.grammar-icon-btn-inline .material-icons {
    font-size: 24px;
}

.source-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.heading-with-grammar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 1.5rem 0 0.75rem 0;
}

.heading-with-grammar .block-heading {
    margin: 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #60a5fa3d;
    flex: 1;
}

.grammar-icon-btn-inline {
    margin-bottom: 0.5rem;
    flex-shrink: 0;
    order: -1;
}

/* ============================================================================
   11. QUIZ SYSTEM
   ============================================================================ */

.quiz-container {
    max-width: 500px;
    margin: 10px auto;
    padding: 0 1rem;
}

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

.quiz-header-top h2 {
    margin: 0;
    font-size: 1.2rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quiz-progress-section {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 16px 0 20px;
}

.quiz-progress-container {
    flex: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

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

.quiz-counter {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
    background: var(--card);
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

[dir="rtl"] .quiz-counter {
    direction: ltr;
}

/* Language Selectors - Compact Inline Version */
.quiz-lang-selectors {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    padding: 8px 12px;
    background: var(--card);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.lang-select {
    padding: 6px 10px;
    font-size: 0.9rem;
    border-radius: 4px;
    border: 1px solid var(--primary);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    min-width: 80px;
}

.lang-select:hover {
    border-color: var(--primary-dark);
    background: var(--hover-bg);
}

.lang-arrow {
    color: var(--primary);
    font-size: 18px;
}

.quiz-score {
    text-align: center;
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

/* Quiz Cards */
.quiz-question-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    color: var(--text);
    border: 2px solid var(--primary);
    border-radius: 8px;
    min-height: 70px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-question-card:hover {
    background: rgba(37, 99, 235, 0.05);
    transform: scale(1.02);
}

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

.quiz-question-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--thai-color);
    line-height: 1.2;
    text-align: center;
    font-family: inherit;
}

.quiz-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.quiz-option-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    color: var(--text);
    border: 2px solid #ddd;
    border-radius: 8px;
    min-height: 60px;
    padding: 1rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.quiz-option-btn:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
    transform: scale(1.02);
}

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

.quiz-option-btn.correct {
    background-color: #4caf50 !important;
    color: white;
    border-color: #2e7d32 !important;
}

.quiz-option-btn.incorrect {
    background-color: #f44336 !important;
    color: white;
    border-color: #c62828 !important;
}

.quiz-option-btn[data-text] span {
    pointer-events: none;
}

.quiz-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-width: 40px;
    min-height: 40px;
}

.quiz-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
    transform: scale(1.1);
}

.quiz-close-btn .material-icons {
    font-size: 24px;
}

.dark-theme .quiz-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dark-theme .quiz-option-btn:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* Review List */
.review-list {
    margin-top: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.review-item {
    padding: 16px;
    margin-bottom: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.review-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.review-item-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.review-question {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 1.1rem;
    color: var(--thai-color);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.review-question:hover {
    background-color: rgba(37, 99, 235, 0.1);
}

.review-answer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    margin-left: 28px;
    transition: background-color 0.2s ease;
}

.review-answer:hover {
    background-color: rgba(37, 99, 235, 0.1);
}

.review-speech-icon {
    font-size: 18px;
    color: var(--primary);
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.review-speech-icon-small {
    font-size: 16px;
    color: var(--primary);
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.review-question:hover .review-speech-icon,
.review-answer:hover .review-speech-icon-small {
    opacity: 1;
}

[dir="rtl"] .review-answer {
    margin-left: 0;
    margin-right: 28px;
}

[dir="rtl"] .review-question {
    flex-direction: row-reverse;
}

[dir="rtl"] .review-answer {
    flex-direction: row-reverse;
}

.dark-theme .review-question:hover,
.dark-theme .review-answer:hover {
    background-color: rgba(96, 165, 250, 0.15);
}

.dark-theme .review-speech-icon,
.dark-theme .review-speech-icon-small {
    color: var(--primary-light);
}

/* Perfect Score */
.perfect-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    background: var(--card);
    border: 2px solid var(--success);
    border-radius: 12px;
    margin: 20px 0;
}

.perfect-icon {
    font-size: 48px;
    color: var(--success);
    margin-bottom: 16px;
}

.perfect-score p {
    font-size: 1.2rem;
    color: var(--text);
    font-weight: 500;
}

.quiz-footer-btns {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* ============================================================================
   12. FLASHCARD SYSTEM
   ============================================================================ */

.flashcard-container {
    max-width: 600px;
    margin: 20px auto;
    padding: 0 16px;
}

.flashcard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.flashcard-progress {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.flashcard-header-buttons {
    display: flex;
    gap: 8px;
}

.flashcard-header-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.flashcard-header-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
    transform: scale(1.1);
}

.flashcard {
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 2px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.flashcard:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.flashcard-front,
.flashcard-back {
    padding: 32px 24px;
    text-align: center;
    position: relative;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.flashcard-front {
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.flashcard.show-answer .flashcard-front {
    border-bottom: none;
}

.flashcard-back {
    background: rgba(0, 0, 0, 0.02);
    border-top: 2px solid var(--primary);
    display: none;
}

.flashcard.show-answer .flashcard-back {
    display: flex;
}

.flashcard.show-answer .flashcard-front {
    border-bottom: 2px solid var(--primary);
}

.flashcard-content {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 2px;
    line-height: 1.3;
    word-break: break-word;
    font-family: inherit;
}

.flashcard-front .flashcard-content {
    color: var(--thai-color);
}

.flashcard-back .flashcard-content {
    color: var(--english-color);
}

.btn-show-answer {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 16px;
}

.btn-show-answer:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.answer-rating {
    text-align: center;
    margin: 16px 0;
}

.answer-rating p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.rating-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.rating-btn {
    padding: 12px 8px;
    border: none;
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.rating-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Flashcard Translations */
.flashcard-translations {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.flashcard-translation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--card);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.flashcard-translation-item:hover {
    background: var(--hover-bg);
    transform: translateX(4px);
}

.flashcard-translation-item[dir="rtl"] {
    border-left: none;
    border-right: 3px solid var(--primary);
}

[dir="rtl"] .flashcard-translation-item:hover {
    transform: translateX(-4px);
}

.translation-lang {
    font-weight: bold;
    color: var(--primary);
    min-width: 40px;
}

.translation-text {
    flex: 1;
    font-size: 1.1rem;
}

.translation-example {
    margin-left: 24px !important;
    background: var(--card) !important;
    border-left: 3px solid var(--primary-light) !important;
    opacity: 0.9;
}

.translation-example:hover {
    border-left-color: var(--primary) !important;
    transform: translateX(8px) !important;
    opacity: 1;
}

.example-group {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border);
}

.example-group:last-child {
    border-bottom: none;
}

.audio-icon-small {
    font-size: 18px !important;
    color: var(--primary);
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.pattern-example:hover .audio-icon-small {
    opacity: 1;
}

[dir="rtl"] .translation-example {
    margin-left: 0 !important;
    margin-right: 24px !important;
    border-left: none !important;
    border-right: 3px solid var(--primary-light) !important;
}

[dir="rtl"] .translation-example:hover {
    transform: translateX(-8px) !important;
}

/* ============================================================================
   13. SENTENCE BUILDING GAME
   ============================================================================ */

.sentence-game-container {
    max-width: 800px;
    margin: 16px auto;
    padding: 0 12px;
}

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

.game-header-top h2 {
    margin: 0;
    font-size: 1.3rem;
    line-height: 1.4;
    word-break: break-word;
}

.game-close-btn {
    min-width: 48px;
    min-height: 48px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.game-close-btn:active {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(0.95);
}

.game-close-btn .material-icons {
    font-size: 24px;
}

.game-progress-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.game-progress-container {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

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

.game-counter {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 65px;
    text-align: center;
    background: var(--card);
    padding: 6px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.sentence-hint {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 12px;
    border-left: 4px solid var(--primary);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 20px;
    word-break: break-word;
    cursor: pointer;
    transition: all 0.2s;
}

.sentence-hint:hover {
    background: rgba(37, 99, 235, 0.12);
}

.sentence-hint .material-icons {
    color: var(--primary);
    font-size: 22px;
    flex-shrink: 0;
}

.sentence-game-area {
    background: var(--card);
    border-radius: 20px;
    padding: 20px 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.construction-zone {
    margin-bottom: 24px;
}

.construction-label,
.word-bank-label {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
    font-size: 1rem;
    padding-left: 4px;
}

.word-construction {
    min-height: 100px;
    background: rgba(0, 0, 0, 0.02);
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    transition: all 0.2s ease;
}

.word-construction.correct {
    border-color: var(--success);
    background: rgba(5, 150, 105, 0.05);
}

.word-construction.incorrect {
    border-color: var(--error);
    background: rgba(220, 38, 38, 0.05);
}

.constructed-word {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--primary);
    color: white;
    border-radius: 30px;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
    -webkit-tap-highlight-color: transparent;
}

.constructed-word .word-text {
    padding: 2px 0;
    cursor: pointer;
}

.constructed-word .word-text:hover {
    text-decoration: underline;
}

.remove-word-btn {
    min-width: 36px;
    min-height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.remove-word-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.9);
}

.remove-word-btn .material-icons {
    font-size: 18px;
}

.construction-placeholder {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    width: 100%;
    padding: 24px 12px;
    font-size: 1rem;
}

.word-bank {
    border-top: 2px solid var(--border);
    padding-top: 24px;
}

.words-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 70px;
}

.word-tile {
    min-height: 48px;
    padding: 10px 18px;
    background: var(--card);
    border: 2px solid var(--primary);
    border-radius: 30px;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex: 0 1 auto;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.word-tile:active {
    background: var(--primary);
    color: white;
    transform: scale(0.95);
}

.word-tile:disabled {
    opacity: 0.4;
    pointer-events: none;
    border-color: var(--text-secondary);
    color: var(--text-secondary);
}

.no-words-message {
    color: var(--text-secondary);
    font-style: italic;
    padding: 16px;
    text-align: center;
    width: 100%;
}

.game-controls {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.game-controls .btn-activity {
    flex: 1 1 0;
    min-width: 100px;
    min-height: 52px;
    padding: 12px 8px;
    font-family: inherit;
    font-family: inherit;
    font-size: 1rem;
    border-radius: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
}

.game-controls .btn-activity:active:not(:disabled) {
    transform: scale(0.97);
}

.game-controls .btn-activity .material-icons {
    font-size: 22px;
}

.game-controls .btn-activity .btn-text {
    display: inline-block;
}

.btn-check {
    background: var(--success) !important;
}

.btn-check:hover:not(:disabled) {
    background: #047857 !important;
}

.btn-reset {
    background: var(--warning) !important;
}

.btn-reset:hover:not(:disabled) {
    background: #b45309 !important;
}

.btn-next {
    background: var(--primary) !important;
}

.btn-next:hover:not(:disabled) {
    background: var(--primary-dark) !important;
}

.btn-exit {
    background: var(--text-secondary) !important;
}

.btn-exit:hover {
    background: #4b5563 !important;
}

.btn-activity:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
}

.result-feedback {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 18px 16px;
    border-radius: 16px;
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
}

.result-feedback.correct {
    background: rgba(5, 150, 105, 0.12);
    color: var(--success);
    border: 2px solid var(--success);
}

.result-feedback.incorrect {
    background: rgba(220, 38, 38, 0.12);
    color: var(--error);
    border: 2px solid var(--error);
}

.result-feedback .material-icons {
    font-size: 32px;
}

.feedback-text {
    line-height: 1.5;
    word-break: break-word;
}

.btn-show-answer {
    min-height: 44px;
    padding: 10px 24px;
    background: var(--card);
    border: 2px solid currentColor;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-show-answer:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.game-footer {
    display: flex;
    justify-content: center;
    padding-top: 16px;
    border-top: 2px solid var(--border);
}

.game-footer .btn-activity {
    min-height: 52px;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1rem;
}

.game-complete {
    min-height: 70vh;
}

.game-complete-buttons .btn-activity {
    min-height: 52px;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1rem;
    flex: 1 1 auto;
    min-width: 160px;
}

/* ============================================================================
   14. SETTINGS OVERLAY
   ============================================================================ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.overlay-full,
.overlay-menu {
    position: fixed;
    z-index: 2500;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.overlay-full {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
    border-radius: 12px;
}

.overlay-menu {
    top: 60px;
    right: 10px;
    min-width: 150px;
    border-radius: 8px;
    overflow: hidden;
}

.overlay-menu button {
    width: 100%;
    padding: 12px;
    border: none;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.overlay-menu button:last-child {
    border-bottom: none;
}

.overlay-menu button:hover {
    background: var(--hover-bg);
}

.overlay-menu.lang-menu {
    top: 100px !important;
    right: 10px !important;
    bottom: auto;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.settings-header h2 {
    font-size: 1.5rem;
    margin: 0;
}

.settings-sliders {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
}

.control-row-inline {
    display: grid;
    grid-template-columns: 60px 1fr 40px;
    align-items: center;
    gap: 10px;
}

.control-row-inline label {
    font-size: 0.85rem;
    font-weight: bold;
}

.val-label {
    font-size: 0.8rem;
    text-align: right;
    color: var(--primary);
}

#voice-select {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--primary);
    border-radius: 4px;
    background: var(--card);
    color: var(--text);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th,
td {
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

[dir="rtl"] th,
[dir="rtl"] td {
    text-align: right;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 26px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

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

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

.dark-theme .toggle-slider {
    background-color: var(--border);
}

.dark-theme input:checked + .toggle-slider {
    background-color: var(--primary);
}
/* ============================================================================
VOICE SPEED PRESET SECTION
============================================================================ */
.voice-speed-section {
    margin-bottom: 20px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.dark-theme .voice-speed-section {
    background: rgba(255, 255, 255, 0.03);
}

.voice-speed-title {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 12px;
}

.voice-speed-title .material-icons {
    color: var(--primary);
    font-size: 20px;
}

.voice-speed-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.voice-speed-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.voice-speed-option:hover {
    border-color: var(--primary-light);
    background: var(--hover-bg);
}

.voice-speed-option.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.06);
}

.dark-theme .voice-speed-option.active {
    background: rgba(59, 130, 246, 0.12);
}

.voice-speed-option input[type="radio"] {
    display: none;
}

.voice-speed-radio-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s ease;
}

.voice-speed-option.active .voice-speed-radio-dot {
    border-color: var(--primary);
}

.voice-speed-option.active .voice-speed-radio-dot::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
}

.voice-speed-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.voice-speed-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.voice-speed-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.voice-speed-test-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.voice-speed-test-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.voice-speed-test-btn:active {
    transform: scale(0.95);
}

.voice-speed-test-btn .material-icons {
    font-size: 20px;
}
/* ============================================================================
   15. GRAMMAR SHEET
   ============================================================================ */

#grammar-sheet-anchor {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    pointer-events: none;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2001;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    border-top: 1px solid var(--border);
}

.bottom-sheet.open {
    transform: translateY(0);
}

.sheet-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
    z-index: 2000;
    pointer-events: auto;
    backdrop-filter: blur(2px);
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto;
    cursor: pointer;
    transition: background 0.2s;
}

.sheet-handle:hover {
    background: var(--text-secondary);
}

.sheet-handle:active {
    transform: scale(0.95);
}

.sheet-header {
    padding: 8px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sheet-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
}

.sheet-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-width: 44px;
    min-height: 44px;
}

.sheet-close:hover {
    background: var(--hover-bg);
    color: var(--text);
    transform: scale(1.1);
}

.sheet-content {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.grammar-pattern {
    background: rgba(37, 99, 235, 0.08);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.pattern-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.pattern-example {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--card);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.pattern-example:last-child {
    margin-bottom: 0;
}

.pattern-example:hover {
    background: rgba(37, 99, 235, 0.05);
    border-color: var(--primary);
    transform: translateX(4px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.pattern-example:active {
    transform: scale(0.99);
}

.example-thai {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--thai-color);
    flex: 1;
    line-height: 1.4;
    font-family: inherit;
}

.example-en {
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 45%;
    text-align: right;
    line-height: 1.4;
}

.grammar-note {
    font-style: italic;
    padding: 20px;
    margin-bottom: 20px;
    background: rgba(255, 193, 7, 0.08);
    border-left: 4px solid #fbbf24;
    border-radius: 8px;
    line-height: 1.6;
    font-size: 1rem;
    color: var(--text);
}

.grammar-usage {
    padding: 16px;
    margin-bottom: 20px;
    background: rgba(5, 150, 105, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(5, 150, 105, 0.2);
}

.grammar-usage p {
    margin: 8px 0 0 0;
    line-height: 1.6;
    color: var(--text);
}

.current-sentence {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.current-sentence .pattern-example {
    background: rgba(37, 99, 235, 0.05);
    border-color: var(--primary);
}

.more-examples {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.grammar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
}

.grammar-empty .material-icons {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.grammar-empty p {
    margin: 0;
    font-size: 1rem;
}

/* ============================================================================
   16. EMPTY STATES
   ============================================================================ */

.flashcard-empty-state,
.flashcard-complete,
.game-complete {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    min-height: 60vh;
    gap: 16px;
}

.flashcard-empty-state .material-icons,
.flashcard-complete .material-icons,
.game-complete .material-icons {
    font-size: 64px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.flashcard-complete .material-icons,
.game-complete .material-icons {
    color: var(--success);
}

.flashcard-empty-state h2,
.flashcard-complete h2,
.game-complete h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.5rem;
}

.flashcard-empty-state p,
.flashcard-complete p,
.game-complete p {
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0;
}

.flashcard-complete-buttons,
.game-complete-buttons {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ============================================================================
   17. HELP SECTION
   ============================================================================ */

.help-section {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
}

.help-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--primary);
    font-size: 1.8rem;
}

.help-details {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.help-details:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.help-details summary {
    padding: 18px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(to right, rgba(37, 99, 235, 0.03), transparent);
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    min-height: 70px;
    box-sizing: border-box;
    list-style: none;
}

.help-details summary::-webkit-details-marker {
    display: none;
}

.help-details summary::after {
    content: "expand_more";
    /* 1. Update to the exact name used in your new HTML <link> */
    font-family: "Material Symbols Outlined" !important;

    /* 2. CRITICAL: Enable ligatures so the text becomes the icon */
    font-feature-settings: "liga";
    -webkit-font-feature-settings: "liga";

    /* 3. Standard Material Symbols rendering properties */
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    display: inline-block;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;

    margin-left: auto;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
    font-size: 24px;
    flex-shrink: 0;
}

.help-details[open] summary::after {
    transform: rotate(180deg);
}

.help-details summary .material-icons {
    color: var(--primary);
    font-size: 28px;
    flex-shrink: 0;
}

.help-details summary span:not(.material-icons) {
    flex: 1;
    white-space: normal;
    word-break: break-word;
}

.help-details[open] summary {
    border-bottom: 1px solid var(--border);
    background: linear-gradient(to right, rgba(37, 99, 235, 0.08), transparent);
}

.help-content {
    padding: 20px;
    background: var(--bg);
}

.help-content h4 {
    margin: 0 0 12px 0;
    color: var(--text);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-content h4:not(:first-child) {
    margin-top: 24px;
}

.help-content h4::before {
    content: "•";
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: bold;
}

.help-steps,
.help-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
}

.help-steps li,
.help-list li {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--card);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.help-list li:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.help-steps li .material-icons,
.help-list li .material-icons {
    color: var(--primary);
    font-size: 22px;
    flex-shrink: 0;
    margin-top: 2px;
}

.help-steps li strong,
.help-list li strong {
    color: var(--text);
    font-weight: 600;
    min-width: 120px;
}

.help-steps li span:not(.material-icons),
.help-list li span:not(.material-icons) {
    color: var(--text-secondary);
    line-height: 1.5;
}

.help-note {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    margin: 16px 0;
}

.help-note .material-icons {
    color: var(--primary);
    font-size: 24px;
    flex-shrink: 0;
}

.help-note p {
    margin: 0;
    color: var(--text);
    line-height: 1.6;
}

.help-note ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
    color: var(--text-secondary);
}

.help-note li {
    margin-bottom: 4px;
}

.help-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: var(--card);
    border-radius: 8px;
    overflow: hidden;
}

.help-table th,
.help-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.help-table th {
    background: rgba(37, 99, 235, 0.1);
    color: var(--text);
    font-weight: 600;
}

.help-table tr:last-child td {
    border-bottom: none;
}

.help-table td:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.help-table td:first-child .material-icons {
    color: var(--primary);
    font-size: 22px;
}

.help-table td:last-child {
    color: var(--text-secondary);
    width: 100%;
}

/* ============================================================================
   18. RTL SUPPORT
   ============================================================================ */

[dir="rtl"] .btn-audio {
    right: auto;
    left: 8px;
}

[dir="rtl"] .context-sentence small {
    text-align: left;
}

[dir="rtl"] .grammar-icon-btn {
    margin-left: 0;
    margin-right: 8px;
}

[dir="rtl"] .stack-item .lang-fa {
    text-align: left !important;
}

[dir="rtl"] .section-controls-wrapper {
    flex-direction: row-reverse;
}

[dir="rtl"] .section-details summary::before {
    content: "chevron_left";
}

[dir="rtl"] .pattern-example {
    flex-direction: row-reverse;
}

[dir="rtl"] .example-en {
    text-align: left;
}

[dir="rtl"] .grammar-note {
    border-left: none;
    border-right: 4px solid #fbbf24;
}

[dir="rtl"] .sheet-close {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .help-table td:first-child {
    justify-content: flex-end;
}

[dir="rtl"] .help-note {
    border-left: none;
    border-right: 4px solid var(--primary);
}

[dir="rtl"] .help-list li:hover {
    transform: translateX(-4px);
}

[dir="rtl"] .constructed-word .remove-word-btn {
    margin-left: 0;
    margin-right: 4px;
}

[dir="rtl"] .sentence-hint {
    border-left: none;
    border-right: 4px solid var(--primary);
}

[dir="rtl"] .flashcard-translation-item {
    border-left: none;
    border-right: 3px solid var(--primary);
}

[dir="rtl"] .flashcard-translation-item:hover {
    transform: translateX(-4px);
}

/* Character summary card */
.flashcard-translation-item.character-summary {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    background: var(--card);
    border: 2px solid;
    border-radius: 16px;
    margin-bottom: 8px;
}

.character-summary.middle-class {
    border-color: var(--middle-class);
}

.character-summary.high-class {
    border-color: var(--high-class);
}

.character-summary.low-class {
    border-color: var(--low-class);
}

.character-summary-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.character-symbol {
    font-size: 3rem;
    line-height: 1;
    font-family: "Inter", "Vazirmatn", "Noto Serif Thai", Georgia, serif;
}

.character-symbol.middle-class {
    color: var(--middle-class);
}

.character-symbol.high-class {
    color: var(--high-class);
}

.character-symbol.low-class {
    color: var(--low-class);
}

.character-mnemonic {
    font-size: 1.2rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.character-meaning {
    font-size: 1rem;
    color: var(--text-secondary);
}

.character-class-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--card);
}

.character-class-badge.middle {
    color: var(--middle-class);
    border: 1px solid var(--middle-class);
}

.character-class-badge.high {
    color: var(--high-class);
    border: 1px solid var(--high-class);
}

.character-class-badge.low {
    color: var(--low-class);
    border: 1px solid var(--low-class);
}

.character-audio-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.audio-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 30px;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

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

.audio-chip .material-icons {
    font-size: 16px;
}

[dir="rtl"] .audio-preview-icon {
    left: auto;
    right: 3px;
}

/* ============================================================================
   ALPHABET LEARNING COMPONENTS (Added for PDF content)
   ============================================================================ */

/* Character Grid */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 12px;
    padding: 16px;
}

.character-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 90px;
    -webkit-tap-highlight-color: transparent;
}

.character-grid-item:active {
    transform: scale(0.97);
    background: var(--hover-bg);
    border-color: var(--primary);
}

.character-symbol {
    font-size: 2.5rem;
    line-height: 1.2;
    color: var(--thai-color);
    font-family: inherit;
}

.character-sound {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Detailed Character Card */
.character-card-detailed {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    margin: 16px 0;
    border: 1px solid var(--border);
}

.character-main {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.character-large {
    font-size: 5rem;
    line-height: 1;
    color: var(--thai-color);
    font-family: "Inter", "Vazirmatn", "Noto Serif Thai", Georgia, serif;
    min-width: 120px;
    text-align: center;
}

.character-info {
    flex: 1;
}

.character-sound-large {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary);
    line-height: 1.2;
}

.character-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* Sound Matching */
.sound-matching-exercise {
    padding: 16px;
}

.sound-items {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
}

.sound-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.btn-play-sound {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.btn-play-sound:active {
    transform: scale(0.95);
    background: var(--primary-dark);
}

.sound-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    flex: 1;
}

.sound-option {
    aspect-ratio: 1/1;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--thai-color);
    cursor: pointer;
    transition: all 0.2s;
    font-family: "Inter", "Vazirmatn", "Noto Serif Thai", Georgia, serif;
}

.sound-option:active {
    transform: scale(0.95);
    border-color: var(--primary);
    background: var(--hover-bg);
}

.sound-option.correct {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

/* Tone Rule Tables */
.tone-rule-table-container {
    margin: 20px 0;
    overflow-x: auto;
}

.tone-rule-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
}

.tone-rule-table th {
    background: var(--primary);
    color: white;
    padding: 12px;
    font-weight: 600;
}

.tone-rule-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.tone-rule-table .example-word {
    cursor: pointer;
    color: var(--thai-color);
    font-weight: 500;
}

.tone-rule-table .example-word:hover {
    text-decoration: underline;
}

.tone-indicator {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.tone-mid {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.tone-low {
    background: rgba(220, 38, 38, 0.1);
    color: var(--error);
}

.tone-falling {
    background: rgba(217, 119, 6, 0.1);
    color: var(--warning);
}

.tone-high {
    background: rgba(5, 150, 105, 0.1);
    color: var(--success);
}

.tone-rising {
    background: rgba(124, 58, 237, 0.1);
    color: #7c3aed;
}

/* Alphabet Table Grid */
.alphabet-table-container {
    margin: 20px 0;
}

.alphabet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.alphabet-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.alphabet-grid-item:active {
    transform: scale(0.97);
    border-color: var(--primary);
    background: var(--hover-bg);
}

.alphabet-symbol {
    font-size: 2rem;
    color: var(--thai-color);
    font-family: inherit;
    /* Change from fixed font to inherit */
}

.alphabet-sound {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    margin-top: 4px;
}

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

/* Add these to your :root variables section (around line 20-30) */
:root {
    /* ... existing variables ... */

    /* Consonant class colors */
    --middle-class: #059669;
    /* green */
    --high-class: #dc2626;
    /* red */
    --low-class: #2563eb;
    /* blue */
}

.dark-theme {
    /* ... existing dark theme variables ... */

    /* Consonant class colors for dark mode */
    --middle-class: #34d399;
    /* light green */
    --high-class: #f87171;
    /* light red */
    --low-class: #60a5fa;
    /* light blue */
}

/* Add these new classes for consonant class styling */
.alphabet-grid-item.middle-class {
    border-color: var(--middle-class);
    background: rgba(5, 150, 105, 0.05);
}

.alphabet-grid-item.middle-class .alphabet-symbol {
    color: var(--middle-class);
}

.alphabet-grid-item.high-class {
    border-color: var(--high-class);
    background: rgba(220, 38, 38, 0.05);
}

.alphabet-grid-item.high-class .alphabet-symbol {
    color: var(--high-class);
}

.alphabet-grid-item.low-class {
    border-color: var(--low-class);
    background: rgba(37, 99, 235, 0.05);
}

.alphabet-grid-item.low-class .alphabet-symbol {
    color: var(--low-class);
}

/* Class indicator dots */
.class-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 4px;
}

.class-dot.middle-class {
    background-color: var(--middle-class);
}

.class-dot.high-class {
    background-color: var(--high-class);
}

.class-dot.low-class {
    background-color: var(--low-class);
}

/* For character grid items */
.character-grid-item.middle-class {
    border-color: var(--middle-class);
}

.character-grid-item.middle-class .character-symbol {
    color: var(--middle-class);
}

.character-grid-item.high-class {
    border-color: var(--high-class);
}

.character-grid-item.high-class .character-symbol {
    color: var(--high-class);
}

.character-grid-item.low-class {
    border-color: var(--low-class);
}

.character-grid-item.low-class .character-symbol {
    color: var(--low-class);
}

/* Class indicators for flashcards and other displays */
.class-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 8px;
}

.class-indicator.middle {
    background: var(--middle-class);
    color: white;
}

.class-indicator.high {
    background: var(--high-class);
    color: white;
}

.class-indicator.low {
    background: var(--low-class);
    color: white;
}

/* Tone rule table class headers */
.tone-rule-table th.middle-class {
    background: var(--middle-class);
}

.tone-rule-table th.high-class {
    background: var(--high-class);
}

.tone-rule-table th.low-class {
    background: var(--low-class);
}

/* Audio Buttons */
.btn-audio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 30px;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-audio:active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(0.97);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .character-large {
        font-size: 4rem;
        min-width: 90px;
    }

    .sound-options {
        grid-template-columns: repeat(2, 1fr);
    }

    .sound-item {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-play-sound {
        align-self: center;
    }

    .alphabet-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================================================
   19. RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    .document-content > .doc-title {
        margin: 0 8px 12px;
        padding: 12px;
        font-size: 1.2rem;
    }

    .section-details summary {
        padding: 12px;
    }

    .document-controls-wrapper,
    .section-all-controls {
        gap: 8px;
    }

    .document-controls-wrapper > *,
    .section-all-controls > * {
        min-width: 0;
    }
}

@media (max-width: 640px) {
    .document-controls-wrapper > *,
    .section-all-controls > * {
        min-width: 0;
        flex: 0 1 calc(30% - 4px);
        font-size: 0.8rem;
    }

    .library-container {
        padding: 0 8px;
    }

    .library-summary {
        padding: 12px 14px;
        font-size: 0.95rem;
    }

    .doc-btn {
        padding: 10px 14px;
    }

    .sentence-group {
        border: none;
    }

    .quiz-progress-section {
        gap: 12px;
    }

    .quiz-counter {
        min-width: 50px;
        font-size: 0.85rem;
        padding: 2px 6px;
    }

    .quiz-lang-selectors {
        /*        flex-direction: column; */
        align-items: stretch;
        gap: 8px;
    }

    .lang-select {
        width: 100%;
    }

    .lang-arrow {
        transform: rotate(90deg);
        align-self: center;
    }

    .pattern-example {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .example-en {
        max-width: 100%;
        text-align: left;
        padding-left: 28px;
    }

    [dir="rtl"] .pattern-example {
        align-items: flex-end;
    }

    [dir="rtl"] .example-en {
        text-align: right;
        padding-left: 0;
        padding-right: 28px;
    }

    .sentence-game-container {
        padding: 0 8px;
    }

    .sentence-game-area {
        padding: 16px 12px;
    }

    .game-controls .btn-activity {
        width: 100%;
    }

    .word-tile {
        font-size: 1rem;
        padding: 10px 16px;
    }

    .constructed-word {
        font-size: 1rem;
        padding: 8px 12px;
    }

    .game-header-top h2 {
        font-size: 1.2rem;
    }

    .game-counter {
        min-width: 55px;
        font-size: 0.85rem;
        padding: 4px 8px;
    }
}

@media (max-width: 480px) {
    .document-content > .doc-title {
        margin: 0 6px 10px;
        padding: 10px;
        font-size: 1.1rem;
    }

    .section-details summary {
        padding: 10px;
    }

    .document-controls-wrapper > *,
    .section-all-controls > * {
        flex: 0 1 calc(30%);
        /*                flex: 0 1 calc(30% - 4px); */
        font-size: 0.8rem;
    }

    .library-container {
        padding: 0 6px;
    }

    .library-summary {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .quiz-close-btn {
        min-width: 36px;
        min-height: 36px;
    }

    .quiz-close-btn .material-icons {
        font-size: 20px;
    }

    .quiz-lang-selectors {
        gap: 4px;
        padding: 6px 8px;
    }

    .lang-select {
        padding: 4px 6px;
        font-size: 0.8rem;
        min-width: 70px;
    }

    .lang-arrow {
        font-size: 16px;
    }

    .review-question {
        font-size: 1rem;
    }

    .review-answer {
        font-size: 0.9rem;
        margin-left: 20px;
    }

    .review-speech-icon {
        font-size: 16px;
    }

    .review-speech-icon-small {
        font-size: 14px;
    }

    .review-badge {
        background: var(--warning);
        color: white;
        font-size: 0.7rem;
        padding: 2px 8px;
        border-radius: 12px;
        margin-left: 8px;
        text-transform: uppercase;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 24px 8px 0 8px;
        min-height: 80px;
    }

    .flashcard-content {
        font-size: 1.5rem;
    }

    .rating-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .sheet-header h3 {
        font-size: 1.2rem;
    }

    .sheet-content {
        padding: 16px;
    }

    .grammar-pattern {
        padding: 16px;
    }

    .sentence-hint {
        font-size: 0.95rem;
        padding: 12px;
    }

    .word-construction {
        min-height: 80px;
        padding: 12px;
    }

    .construction-placeholder {
        font-size: 0.95rem;
        padding: 16px 8px;
    }

    .game-controls {
        gap: 8px;
    }

    .game-controls .btn-activity {
        min-width: 0;
        padding: 12px 4px;
        font-size: 0.9rem;
    }

    .game-controls .btn-activity .material-icons {
        font-size: 20px;
    }

    .game-complete h2 {
        font-size: 1.6rem;
    }

    .game-complete p {
        font-size: 1rem;
    }

    .game-complete-buttons {
        flex-direction: column;
        width: 100%;
    }

    .game-complete-buttons .btn-activity {
        width: 100%;
    }

    .help-section h2 {
        font-size: 1.5rem;
    }

    .help-details summary {
        font-size: 1rem;
        padding: 12px;
    }

    .help-details summary .material-icons {
        font-size: 24px;
    }

    .help-content {
        padding: 12px;
    }

    .help-note {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 360px) {
    .library-summary {
        padding: 10px 12px;
        font-size: 0.9rem;
        gap: 10px;
    }

    .doc-btn {
        padding: 8px 12px;
        gap: 10px;
    }

    .doc-btn-text {
        font-size: 0.9rem;
    }
}

/* ============================================================================
   20. ACCESSIBILITY
   ============================================================================ */

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    .word-tile,
    .constructed-word,
    .btn-activity,
    .game-close-btn,
    .remove-word-btn {
        -webkit-touch-callout: none;
    }
}

/* Remove tap highlight on mobile */
.word-tile,
.constructed-word,
.btn-activity,
.game-close-btn,
.remove-word-btn,
.btn-show-answer,
.pattern-example,
.flashcard-translation-item,
.sentence-hint {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Ensure buttons are usable on all devices */
@media (hover: none) and (pointer: coarse) {
    .word-tile:hover,
    .btn-activity:hover,
    .constructed-word:hover,
    .pattern-example:hover,
    .flashcard-translation-item:hover {
        transform: none;
    }

    .word-tile:active,
    .btn-activity:active,
    .constructed-word:active,
    .pattern-example:active,
    .flashcard-translation-item:active {
        transform: scale(0.97);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary: #0056b3;
        --text: #000000;
        --thai-color: #0000ff;
        --english-color: #006400;
        --farsi-color: #8b0000;
    }

    .dark-theme {
        --primary: #4da6ff;
        --text: #ffffff;
        --thai-color: #add8e6;
        --english-color: #90ee90;
        --farsi-color: #ffb6c1;
    }

    .word-tile {
        border-width: 3px;
    }

    .word-construction {
        border-width: 3px;
    }

    .result-feedback {
        border-width: 3px;
    }

    .grammar-pattern {
        border: 2px solid var(--primary);
    }

    .pattern-example {
        border: 2px solid var(--border);
    }

    .grammar-note {
        border-left: 6px solid #fbbf24;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .word-tile,
    .constructed-word,
    .btn-activity,
    .game-progress-fill,
    .result-feedback,
    .bottom-sheet,
    .sheet-backdrop,
    .pattern-example,
    .flashcard-translation-item {
        transition: none;
    }

    .word-tile:active,
    .btn-activity:active,
    .constructed-word:active,
    .pattern-example:active,
    .flashcard-translation-item:active {
        transform: none;
    }
}

/* Progress Panel Styles */
.progress-streak {
    background: linear-gradient(
        135deg,
        var(--primary) 0%,
        var(--primary-dark) 100%
    );
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    color: white;
}

.streak-card {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.streak-card .material-icons {
    font-size: 48px;
}

.streak-numbers {
    display: flex;
    flex-direction: column;
}

.streak-current {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.streak-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.streak-calendar {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.streak-day {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.streak-day.active {
    background: white;
    color: var(--primary);
    font-weight: bold;
}

.progress-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card .material-icons {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

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

.progress-due {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
}

.progress-due h4 {
    margin: 0 0 12px 0;
    font-size: 1rem;
}

.due-cards {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.due-count {
    font-size: 2rem;
    font-weight: 700;
    color: var(--warning);
    min-width: 60px;
}

.due-label {
    color: var(--text-secondary);
}

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

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

.recent-activity {
    margin-bottom: 24px;
}

.recent-activity h4 {
    margin: 0 0 12px 0;
}

.activity-timeline {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-icon .material-icons {
    font-size: 18px;
    color: var(--primary);
}

.activity-details {
    flex: 1;
}

.activity-text {
    font-size: 0.95rem;
    color: var(--text);
}

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

.achievements-section h4 {
    margin: 0 0 12px 0;
}

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

.achievement-badge {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    opacity: 0.5;
    transition: all 0.2s;
}

.achievement-badge.unlocked {
    opacity: 1;
    border-color: var(--success);
    background: rgba(5, 150, 105, 0.1);
}

.achievement-badge .material-icons {
    font-size: 24px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.achievement-badge.unlocked .material-icons {
    color: var(--success);
}

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

.next-milestone {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
}

.milestone-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--text);
}

.milestone-header .material-icons {
    color: var(--primary);
}

.milestone-progress {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

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

.milestone-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.progress-footer {
    display: flex;
    justify-content: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

@media (max-width: 480px) {
    .progress-stats-grid {
        grid-template-columns: 1fr;
    }

    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .streak-calendar {
        flex-wrap: wrap;
    }
}

/* Consonant Detail Bottom Sheet */
.consonant-detail-sheet {
    padding: 0 20px 20px;
}

.consonant-detail-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.consonant-detail-symbol {
    font-size: 5rem;
    line-height: 1;
    font-family: inherit;
    min-width: 120px;
    text-align: center;
}

.consonant-detail-symbol.middle-class {
    color: var(--middle-class);
}

.consonant-detail-symbol.high-class {
    color: var(--high-class);
}

.consonant-detail-symbol.low-class {
    color: var(--low-class);
}

.consonant-detail-info {
    flex: 1;
}

.consonant-name {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.consonant-name .thai-name {
    font-family: "Inter", "Vazirmatn", "Noto Serif Thai", Georgia, serif;
}

.consonant-mnemonic {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.mnemonic-emoji {
    font-size: 1.8rem;
}

.consonant-class-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 8px;
}

.consonant-class-badge.middle {
    background: var(--middle-class);
    color: white;
}

.consonant-class-badge.high {
    background: var(--high-class);
    color: white;
}

.consonant-class-badge.low {
    background: var(--low-class);
    color: white;
}

/* Example words in detail view */
.consonant-examples {
    margin-top: 24px;
}

.consonant-examples h4 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: var(--text-secondary);
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.example-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 30px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.example-chip:hover {
    border-color: var(--primary);
    background: var(--hover-bg);
}

.example-chip .example-word {
    font-family: "Inter", "Vazirmatn", "Noto Serif Thai", Georgia, serif;
    font-weight: 500;
}

.example-chip .example-meaning {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Audio button in detail view */
.detail-audio-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 16px;
    transition: all 0.2s;
}

.detail-audio-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

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

/* Character large display on flashcard front */
.character-large-display {
    font-size: 5rem;
    line-height: 1.2;
    font-family: inherit;
}

.character-large-display.middle-class {
    color: var(--middle-class);
}

.character-large-display.high-class {
    color: var(--high-class);
}

.character-large-display.low-class {
    color: var(--low-class);
}

/* Character summary card */
.flashcard-translation-item.character-summary {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    background: var(--card);
    border: 2px solid;
    border-radius: 16px;
    margin-bottom: 8px;
}

.character-summary.middle-class {
    border-color: var(--middle-class);
}

.character-summary.high-class {
    border-color: var(--high-class);
}

.character-summary.low-class {
    border-color: var(--low-class);
}

.character-summary-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.character-symbol {
    font-size: 3rem;
    line-height: 1;
    font-family: "Inter", "Vazirmatn", "Noto Serif Thai", Georgia, serif;
}

.character-symbol.middle-class {
    color: var(--middle-class);
}

.character-symbol.high-class {
    color: var(--high-class);
}

.character-symbol.low-class {
    color: var(--low-class);
}

.character-mnemonic {
    font-size: 1.2rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mnemonic-emoji {
    font-size: 1.5rem;
    margin-right: 4px;
}

.character-meaning {
    font-size: 1rem;
    color: var(--text-secondary);
}

.character-class-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--card);
}

.character-class-badge.middle {
    color: var(--middle-class);
    border: 1px solid var(--middle-class);
}

.character-class-badge.high {
    color: var(--high-class);
    border: 1px solid var(--high-class);
}

.character-class-badge.low {
    color: var(--low-class);
    border: 1px solid var(--low-class);
}

.character-audio-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.audio-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 30px;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

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

.audio-chip .material-icons {
    font-size: 16px;
}

/* Blog ======================================= */

.blog-index {
    max-width: 800px;
    margin: 20px auto;
    padding: 0 16px;
}

.blog-index h2 {
    color: var(--primary);
    font-size: 1.8rem;
    margin-bottom: 24px;
}

.blog-entry {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    gap: 16px;
}

.blog-entry:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.blog-entry .material-icons:first-child {
    font-size: 32px;
    color: var(--primary);
}

.blog-entry-content {
    flex: 1;
}

.blog-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.blog-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.blog-entry .material-icons:last-child {
    color: var(--text-secondary);
}

/* Blog Reader */
.blog-content {
    max-width: 700px;
    margin: 20px auto;
    padding: 0 16px;
}

.blog-content h1 {
    font-size: 2rem;
    margin: 0 0 8px 0;
    color: var(--primary);
    line-height: 1.3;
}

.blog-metadata {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.blog-lang-selector {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.blog-lang-selector select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
}

.blog-sentence {
    display: block;
    margin-bottom: 1.2em;
    font-size: 1.1rem;
    line-height: 1.6;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background-color 0.2s;
    font-family: inherit;
}

.blog-sentence:hover {
    background-color: var(--hover-bg);
}

.blog-sentence.active-highlight {
    background-color: #fbbf24 !important;
    color: #000000 !important;
}

.dark-theme .blog-sentence.active-highlight {
    background-color: #fcd34d !important;
    color: #000000 !important;
}

/* Images and videos */
.blog-image,
.blog-video {
    margin: 32px 0;
    text-align: center;
}

.blog-image img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.blog-image figcaption,
.blog-video figcaption {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

.blog-video iframe {
    max-width: 100%;
    border-radius: 12px;
}

/* RTL adjustments */
[dir="rtl"] .blog-sentence {
    text-align: right;
}

[dir="rtl"] .blog-entry {
    text-align: right;
}

.blog-container {
    padding: 0 12px;
    margin-top: 10px;
}

.blog-section {
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--card);
    overflow: hidden;
    border: 1px solid var(--border);
}

.blog-summary {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
    transition: background-color 0.2s;
    list-style: none;
}

.blog-summary:hover {
    background-color: var(--hover-bg);
}

.blog-summary::-webkit-details-marker {
    display: none;
}

.blog-summary .material-icons {
    font-size: 20px;
    transition: transform 0.2s;
    color: var(--primary);
}

.blog-section[open] .blog-summary .material-icons {
    transform: rotate(180deg);
}

.blog-title {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blog-count {
    font-size: 0.85rem;
    opacity: 0.7;
}

.blog-docs {
    padding: 8px 0;
    border-top: 1px solid var(--border);
}

.blog-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    text-align: left;
    color: var(--text);
    cursor: pointer;
    transition: background-color 0.2s;
    gap: 12px;
}

.blog-btn:hover {
    background-color: var(--hover-bg);
}

.blog-btn-icon {
    font-size: 20px;
    color: var(--primary);
    opacity: 0.8;
}

.blog-btn-text {
    flex-grow: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blog-btn-arrow {
    font-size: 20px;
    opacity: 0.5;
}
/* ============================================================================
PROGRESS PAGE
============================================================================ */
.progress-page-container {
    max-width: 600px;
    margin: 20px auto;
    padding: 0 16px 40px;
}
.progress-page-title {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 24px;
    text-align: center;
}
.progress-category-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.progress-cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.progress-cat-title {
    font-weight: 600;
    /*    font-size: 1.1rem; */
    font-size: 1rem;
    color: var(--text);
}
.progress-cat-stats {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}
.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}
.btn-next-exercise {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-next-exercise:hover {
    background: var(--primary-dark);
}
.btn-next-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.progress-completed-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: rgba(5, 150, 105, 0.1);
    color: var(--success);
    border-radius: 8px;
    font-weight: 600;
}
