/* ─── Local Font: Vazirmatn (IR offline) ──────────────────────── */
@font-face { font-family: 'Vazirmatn'; font-weight: 400; font-style: normal; font-display: swap; src: url('fonts/Vazirmatn-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Vazirmatn'; font-weight: 600; font-style: normal; font-display: swap; src: url('fonts/Vazirmatn-SemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Vazirmatn'; font-weight: 700; font-style: normal; font-display: swap; src: url('fonts/Vazirmatn-Bold.woff2') format('woff2'); }

/* ─── CSS Variables (Dark Mode + Font Size) ──────────────────────── */
:root {
    --bg-body: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --bg-card: white;
    --bg-input: white;
    --bg-secondary: #f8f9fa;
    --text-heading: #1e3c72;
    --text-primary: #333;
    --text-secondary: #555;
    --text-muted: #888;
    --border-color: #e8e8e8;
    --border-light: #f0f0f0;
    --shadow-color: rgba(0,0,0,0.06);
}
html.dark {
    --bg-body: linear-gradient(135deg, #0d1b2a 0%, #1b2838 100%);
    --bg-card: #1e2a3a;
    --bg-input: #253545;
    --bg-secondary: #253545;
    --bg-tertiary: #1a2535;
    --text-heading: #7db3ff;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888;
    --border-color: #2a3a4a;
    --border-light: #2a3a4a;
    --shadow-color: rgba(0,0,0,0.3);
    --link-color: #7db3ff;
    --accent-light-bg: #1a2a3f;
    --hover-bg: #2a3f55;
}
html.font-small { font-size: 14px; }
html.font-medium { font-size: 16px; }
html.font-large { font-size: 18px; }

/* ─── Design tokens: type scale (1.2 ratio) + 8pt spacing ─────────── */
:root {
    /* Fluid body — auto-scales between mobile and desktop */
    --fs-base: clamp(14.5px, 0.85rem + 0.25vw, 17px);

    /* Type scale (relative to base) */
    --fs-xs:   0.75rem;   /* 12 */
    --fs-sm:   0.875rem;  /* 14 */
    --fs-md:   1rem;      /* 16 — body */
    --fs-lg:   1.125rem;  /* 18 — sub-heading / card title */
    --fs-xl:   1.35rem;   /* 21.6 — h3 */
    --fs-2xl:  1.625rem;  /* 26 — h2 */
    --fs-3xl:  2rem;      /* 32 — h1 */
    --fs-4xl:  2.5rem;    /* 40 — display */

    /* Line-heights */
    --lh-tight:  1.25;
    --lh-snug:   1.4;
    --lh-normal: 1.6;
    --lh-loose:  1.8;

    /* Spacing scale (8pt with 4px half-step) */
    --sp-0: 0;
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;
    --sp-8: 64px;

    /* Radii */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
}

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

html { overflow-x: hidden; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-body);
    min-height: 100vh;
    color: var(--text-primary);
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    overflow-x: hidden;
    max-width: 100vw;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; }

/* ─── Global typography defaults (overridable per component) ──────── */
h1 { font-size: var(--fs-3xl); line-height: var(--lh-tight); font-weight: 700; }
h2 { font-size: var(--fs-2xl); line-height: var(--lh-tight); font-weight: 700; }
h3 { font-size: var(--fs-xl);  line-height: var(--lh-snug);  font-weight: 600; }
h4 { font-size: var(--fs-lg);  line-height: var(--lh-snug);  font-weight: 600; }
h5, h6 { font-size: var(--fs-md); line-height: var(--lh-snug); font-weight: 600; }

p { line-height: var(--lh-normal); }
small { font-size: var(--fs-sm); }

button, input, select, textarea {
    font-family: inherit;
    font-size: var(--fs-md);
}

.under-construction-banner {
    background: #ff9800;
    color: #fff;
    text-align: center;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 16px;
    position: relative;
    z-index: 1;
}

@media (min-width: 768px) {
    .container { padding: 24px; }
}

@media (min-width: 1200px) {
    .container { padding: 32px; }
}

/* Soft ambient accents on the body so empty side space feels intentional */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle at 8% 18%, rgba(255, 255, 255, 0.10), transparent 38%),
        radial-gradient(circle at 92% 82%, rgba(126, 179, 255, 0.14), transparent 42%),
        radial-gradient(circle at 90% 10%, rgba(255, 255, 255, 0.06), transparent 30%);
}

html.dark body::before {
    background:
        radial-gradient(circle at 8% 18%, rgba(125, 179, 255, 0.08), transparent 40%),
        radial-gradient(circle at 92% 82%, rgba(100, 150, 220, 0.07), transparent 45%),
        radial-gradient(circle at 90% 10%, rgba(255, 255, 255, 0.03), transparent 35%);
}

/* Login Page */
.login-box {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    margin: 80px auto;
    text-align: center;
}

.login-box h1 {
    color: var(--text-heading);
    font-size: 1.5em;
    margin-bottom: 10px;
}

.login-box h2 {
    color: #666;
    font-size: 1.2em;
    margin-bottom: 30px;
    font-weight: normal;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #2a5298;
}

/* Login Footer */
.login-info {
    margin-top: 25px;
    padding: 15px;
    background: #f0f4ff;
    border-radius: 8px;
    border-right: 4px solid #2a5298;
    font-size: 0.9em;
    color: #333;
    direction: rtl;
    text-align: right;
    line-height: 1.8;
}

.login-info p {
    margin-bottom: 6px;
}

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

.login-info a {
    color: #2a5298;
    font-weight: bold;
    text-decoration: none;
}

.login-info a:hover {
    text-decoration: underline;
}

.login-info strong {
    color: #1a7a1a;
}

.login-signup-link {
    margin-top: 20px;
    text-align: center;
    direction: rtl;
    font-size: 0.9em;
    color: #666;
}

.login-signup-link a {
    color: #2a5298;
    font-weight: bold;
    text-decoration: none;
}

.login-signup-link a:hover {
    text-decoration: underline;
}

.btn-telegram {
    display: block;
    margin-top: 20px;
    text-align: center;
    text-decoration: none;
    font-size: 1.1em;
}

.login-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85em;
    color: #666;
}

.login-footer p {
    margin-bottom: 8px;
}

.login-footer a {
    color: #2a5298;
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* Home Footer */
.home-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85em;
    color: #666;
}

.home-footer p {
    margin-bottom: 8px;
}

.home-footer a {
    color: #2a5298;
    text-decoration: none;
}

.home-footer a:hover {
    text-decoration: underline;
}

/* Home Page Cards */
.home-main {
    text-align: center;
}

.home-main > h2 {
    display: none;
}

.home-section {
    margin-bottom: var(--sp-6);
}

.home-section-title {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    margin: 0 var(--sp-1) var(--sp-4);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border-color, #e0e4ea);
    text-align: left;
}

.home-section-title .hs-fr {
    font-size: var(--fs-xl);
    font-weight: 700;
    line-height: var(--lh-tight);
    color: var(--text-heading, #1e3c72);
    letter-spacing: 0.3px;
}

.home-section-title .hs-fa {
    font-size: var(--fs-sm);
    color: var(--text-muted, #888);
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    margin-left: auto;
}

html.dark .home-section-title { border-color: var(--border-color, #2a3a4a); }

.home-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

@media (min-width: 900px) {
    .home-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .home-cards {
        grid-template-columns: repeat(4, 1fr);
    }
}

.home-card {
    --card-color: #2a5298;
    background: var(--bg-card);
    border-radius: 14px;
    padding: 34px 24px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    border: 1.5px solid var(--border-color, #e6e9ef);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.25s ease;
}

.home-card:hover {
    border-color: var(--card-color);
    box-shadow: 0 6px 20px rgba(20, 30, 60, 0.08);
    transform: translateY(-2px);
}

.card-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.card-title {
    font-size: var(--fs-lg);
    font-weight: 600;
    line-height: var(--lh-snug);
    color: var(--text-primary);
}

.card-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: var(--lh-snug);
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

/* Card color themes */
.home-card.card-ce { --card-color: #2a5298; }
.home-card.card-co { --card-color: #1e88e5; }
.home-card.card-sl { --card-color: #00897b; }
.home-card.card-ee { --card-color: #43a047; }
.home-card.card-eo { --card-color: #7b1fa2; }
.home-card.card-education { --card-color: #e65100; }
.home-card.card-vocab {
    --card-color: #f9a825;
}

.home-card:hover .card-title {
    color: var(--card-color);
}

@media (max-width: 768px) {
    .home-cards {
        grid-template-columns: 1fr;
    }

    .card-icon {
        font-size: 2.5em;
    }

    .card-title {
        font-size: 1.05em;
    }
}

/* Buttons */
.btn {
    display: inline-block;
    padding: var(--sp-3) var(--sp-5);
    border: none;
    border-radius: var(--r-sm);
    font-size: var(--fs-md);
    line-height: var(--lh-tight);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #2a5298;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #1e3c72;
}

.btn-large {
    padding: 40px 30px;
    font-size: 1.2em;
    text-align: center;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    min-height: 180px;
    justify-content: center;
}

.btn-large:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.btn-icon {
    font-size: 2.5em;
    margin-bottom: 8px;
}

.btn-title {
    font-weight: 700;
    font-size: 1.1em;
}

.btn-subtitle {
    font-size: 0.85em;
    opacity: 0.85;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.btn-comprehension {
    background: #2a5298;
    color: white;
}

.btn-comprehension:hover {
    background: #1e3c72;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(42, 82, 152, 0.4);
}

.btn-expression {
    background: #3a6cb8;
    color: white;
}

.btn-expression:hover {
    background: #2a5298;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(58, 108, 184, 0.4);
}

.btn-vocabulary-saved {
    background: #ffc107;
    color: #333;
}

.btn-vocabulary-saved:hover {
    background: #e0a800;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 193, 7, 0.4);
}

.btn-logout {
    background: #95a5a6;
    color: white;
    padding: 8px 20px;
    font-size: 0.9em;
}

.btn-logout:hover {
    background: #7f8c8d;
}

.btn-back {
    background: #3498db;
    color: white;
    padding: 8px 20px;
    font-size: 0.9em;
}

.btn-back:hover {
    background: #2980b9;
}

/* Header */
.header {
    background: var(--bg-card);
    padding: var(--sp-4) var(--sp-5);
    border-radius: var(--r-md);
    margin-bottom: var(--sp-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 5px 15px var(--shadow-color);
}

.header h1 {
    color: var(--text-heading);
    font-size: var(--fs-2xl);
    line-height: var(--lh-tight);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: #666;
}

.nav-links {
    display: flex;
    gap: 10px;
}

/* Main Content */
.main-content {
    background: var(--bg-card);
    padding: var(--sp-6);
    border-radius: var(--r-md);
    box-shadow: 0 5px 15px var(--shadow-color);
    text-align: center;
}

.main-content h2 {
    color: var(--text-heading);
    font-size: var(--fs-2xl);
    margin-bottom: var(--sp-6);
}

.button-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.placeholder-content {
    padding: 40px;
    background: #f8f9fa;
    border-radius: 10px;
    color: #666;
}

/* Series Grid */
.series-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    padding: 20px;
}

.series-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: #2a5298;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s;
    gap: 8px;
}

.series-btn:hover {
    background: #1e3c72;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(30, 60, 114, 0.4);
}

.series-title {
    font-size: 1em;
}

.series-progress {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.progress-text {
    font-size: 0.75em;
    opacity: 0.9;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #4ade80;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Book tags on series cards */
.book-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    justify-content: center;
    width: 100%;
}

.book-tag {
    font-size: 0.7em;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    line-height: 1.5;
    font-weight: 500;
}

.book-tag-bontcf,
.book-tag-Bontcf {
    background: rgba(255, 165, 0, 0.35);
    color: #ffcc80;
}

.book-tag-reussir,
.book-tag-Reussir {
    background: rgba(76, 175, 80, 0.35);
    color: #a5d6a7;
}

.book-tag-cenacle,
.book-tag-Cenacle {
    background: rgba(156, 39, 176, 0.35);
    color: #ce93d8;
}

/* Book filter buttons */
.book-filter {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.book-filter-btn {
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    background: #2a5298;
    color: white;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    text-decoration: none;
    opacity: 0.6;
}

.book-filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(42, 82, 152, 0.5);
    opacity: 0.85;
}

.book-filter-btn.active {
    opacity: 1;
    background: #fff;
    color: #1e3c72;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.3);
}

.book-filter-btn.filter-Bontcf,
.book-filter-btn.filter-bontcf {
    background: linear-gradient(135deg, #e65100, #ff9800);
}
.book-filter-btn.filter-Bontcf:hover,
.book-filter-btn.filter-bontcf:hover {
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}
.book-filter-btn.filter-Bontcf.active,
.book-filter-btn.filter-bontcf.active {
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.5);
}

.book-filter-btn.filter-Reussir,
.book-filter-btn.filter-reussir {
    background: linear-gradient(135deg, #2e7d32, #4caf50);
}
.book-filter-btn.filter-Reussir:hover,
.book-filter-btn.filter-reussir:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}
.book-filter-btn.filter-Reussir.active,
.book-filter-btn.filter-reussir.active {
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.5);
}

.book-filter-btn.filter-Cenacle,
.book-filter-btn.filter-cenacle {
    background: linear-gradient(135deg, #7b1fa2, #ab47bc);
}
.book-filter-btn.filter-Cenacle:hover,
.book-filter-btn.filter-cenacle:hover {
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
}
.book-filter-btn.filter-Cenacle.active,
.book-filter-btn.filter-cenacle.active {
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.5);
}

/* Series Question Page */
.series-page {
    display: flex;
    min-height: 100vh;
}

.question-sidebar {
    width: 200px;
    background: var(--bg-card);
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 55px;
    height: calc(100vh - 55px);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, padding 0.3s ease, box-shadow 0.3s ease;
}

.question-sidebar .question-nav-grouped {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.question-sidebar .score-section {
    flex-shrink: 0;
}

.sidebar-header {
    margin-bottom: var(--sp-5);
}

.sidebar-header h3 {
    color: var(--text-heading);
    font-size: var(--fs-lg);
    margin-bottom: var(--sp-3);
}

.btn-small {
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-sm);
}

.question-nav-grouped {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.difficulty-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.difficulty-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.difficulty-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.question-nav-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1.5px solid var(--border-color, #e0e0e0);
    background: var(--bg-card, white);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: var(--fs-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.question-nav-btn:hover {
    border-color: #2a5298;
    background: #f0f4ff;
}

.question-nav-btn.active {
    background: #2a5298;
    color: white;
    border-color: #2a5298;
}

.question-main {
    flex: 1;
    margin-left: 200px;
    padding: var(--sp-5);
    transition: margin-left 0.3s ease, margin-right 0.3s ease;
}

/* Only reserve right margin when a right-bar actually exists (desktop only) */
@media (min-width: 769px) {
    .series-page:has(.question-rightbar) .question-main {
        margin-right: 160px;
    }
}

.question-rightbar {
    position: fixed;
    top: 55px;
    right: 0;
    width: 160px;
    height: calc(100vh - 55px);
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 16px rgba(20, 30, 60, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-3);
    box-sizing: border-box;
    z-index: 50;
}

.rb-stack {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.rb-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    box-shadow: 0 2px 8px rgba(20, 30, 60, 0.04);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    align-items: stretch;
}

.rb-card-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
}

/* Timer card overrides default .timer-display fixed positioning */
.question-rightbar .timer-display {
    position: static;
    width: 100%;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    border: none;
    box-shadow: 0 6px 18px rgba(30, 60, 114, 0.25);
}
.question-rightbar .timer-display .rb-card-label { color: rgba(255, 255, 255, 0.7); }

.rb-timer-value {
    font-family: 'SF Mono', 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: center;
    line-height: 1;
    padding: var(--sp-1) 0;
    font-variant-numeric: tabular-nums;
}

.rb-timer-progress {
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    overflow: hidden;
}
.rb-timer-progress-fill {
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    transition: width 0.4s ease, background 0.3s ease;
}

.question-rightbar .timer-controls {
    display: flex;
    gap: var(--sp-1);
    justify-content: center;
    margin-top: var(--sp-1);
}

.question-rightbar .timer-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.question-rightbar .timer-btn:hover { background: rgba(255, 255, 255, 0.28); }
.question-rightbar .timer-btn:active { transform: scale(0.94); }
.question-rightbar .timer-close-btn { background: rgba(255, 255, 255, 0.08); }
.question-rightbar .timer-close-btn:hover { background: rgba(231, 76, 60, 0.55); }

.question-rightbar .timer-display.timer-negative {
    background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
    box-shadow: 0 6px 18px rgba(192, 57, 43, 0.35);
    animation: pulse 1.5s infinite;
}

/* Progress card */
.rb-progress-fraction {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-heading);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    padding: var(--sp-1) 0;
}
.rb-progress-fraction .rb-progress-sep {
    color: var(--text-muted);
    font-weight: 400;
    margin: 0 4px;
}
.rb-progress-bar {
    height: 6px;
    background: var(--border-light);
    border-radius: 999px;
    overflow: hidden;
}
.rb-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #43a047, #66bb6a);
    border-radius: 999px;
    transition: width 0.4s ease;
}

html.dark .question-rightbar { background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-tertiary, #1a2535) 100%); }
html.dark .rb-card { background: var(--bg-card); }
html.dark .rb-progress-bar { background: var(--bg-secondary); }

.question-rightbar .timer-controls {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 4px;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 15px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #e0e0e0;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    z-index: 1001;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    padding: 0;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: #f0f4ff;
    color: #2a5298;
    border-color: #2a5298;
}

.sidebar-toggle svg {
    transition: transform 0.3s ease;
}

/* Sidebar Collapsed State */
.series-page.sidebar-collapsed .question-sidebar {
    width: 0;
    padding: 0;
    box-shadow: none;
    overflow: visible;
}

.series-page.sidebar-collapsed .question-sidebar .sidebar-toggle {
    right: -32px;
}

.series-page.sidebar-collapsed .question-sidebar .sidebar-toggle svg {
    transform: rotate(180deg);
}

.series-page.sidebar-collapsed .question-sidebar .sidebar-header,
.series-page.sidebar-collapsed .question-sidebar .question-nav-grouped,
.series-page.sidebar-collapsed .question-sidebar .score-section {
    opacity: 0;
    pointer-events: none;
}

.series-page.sidebar-collapsed .question-main {
    margin-left: 0;
}

.question-container {
    background: var(--bg-card);
    border-radius: var(--r-md);
    padding: var(--sp-6);
    max-width: 1100px;
    margin: 0 auto;
    box-shadow: 0 5px 15px var(--shadow-color);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-5);
    padding-bottom: var(--sp-4);
    border-bottom: 1.5px solid var(--border-light);
}

.question-number {
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--text-heading);
}

.question-difficulty {
    padding: var(--sp-1) var(--sp-4);
    border-radius: 999px;
    font-size: var(--fs-sm);
    font-weight: 500;
}

.answer-edited-badge {
    display: inline-block;
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
}

.difficulty-A1 { background: #d4edda; color: #155724; }
.difficulty-A2 { background: #cce5ff; color: #004085; }
.difficulty-B1 { background: #fff3cd; color: #856404; }
.difficulty-B2 { background: #ffeeba; color: #856404; }
.difficulty-C1 { background: #f8d7da; color: #721c24; }
.difficulty-C2 { background: #f5c6cb; color: #721c24; }

/* Question Stats Section */
.question-stats {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    border-radius: 10px;
    padding: 15px 20px;
    margin-top: 25px;
    border: 1px solid #d0deff;
    direction: rtl;
    text-align: right;
}

.stats-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #c5d5f5;
}

.stats-icon {
    font-size: 1.2em;
}

.stats-title {
    font-weight: 600;
    color: #1e3c72;
    font-size: 1em;
}

.stats-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.stat-label {
    font-weight: 500;
    color: #555;
    min-width: 80px;
    font-size: 0.9em;
}

.stat-value {
    color: #1e3c72;
    font-weight: 600;
    font-size: 0.95em;
}

.stat-series {
    font-weight: 500;
    color: #2a5298;
    line-height: 1.6;
}

/* Question Mark Selector (CE/CO) */
.question-mark-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
    direction: rtl;
}
.q-mark-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 2px solid #e0e0e0;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    color: #555;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.q-mark-btn:hover {
    border-color: #aaa;
    background: #f8f8f8;
}
.q-mark-btn.selected {
    border-color: #4a7c59;
    background: #e8f5e9;
    color: #2e5a3a;
    font-weight: 600;
}
.q-mark-btn .mark-emoji {
    font-size: 14px;
}
.q-mark-btn-clear {
    border-style: dashed;
    color: #999;
}
.q-mark-btn-clear:hover {
    border-color: #e74c3c;
    color: #e74c3c;
    background: #fdf0ef;
}

/* Nav mark indicators */
.nav-mark-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 9px;
    line-height: 1;
    pointer-events: none;
}

/* Mark Filter Bar */
.mark-filter-bar {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: #f5f6f8;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    direction: rtl;
    overflow-x: auto;
}

.mark-filter-bar::-webkit-scrollbar {
    display: none;
}

.mark-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1.5px solid #e0e3e8;
    border-radius: 16px;
    background: white;
    color: #555;
    font-size: 0.78em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.mark-filter-btn:hover {
    border-color: #b0b8c4;
    background: #f0f2f5;
}

.mark-filter-btn.active {
    border-color: #1e3c72;
    background: #1e3c72;
    color: white;
    box-shadow: 0 2px 8px rgba(30,60,114,0.2);
}

.mark-filter-btn .filter-emoji {
    font-size: 0.95em;
    line-height: 1;
}

.mark-filter-btn .filter-count {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 8px;
    font-size: 0.8em;
    font-weight: 600;
    min-width: 14px;
    text-align: center;
}

.mark-filter-btn.active .filter-count {
    background: rgba(255,255,255,0.2);
}

.mark-filter-btn .filter-label {
    font-size: 0.85em;
}

.mark-filter-bar-top {
    max-width: 900px;
    margin: 15px auto;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 6px;
}

.mark-filter-bar-top .mark-filter-btn {
    font-size: 0.85em;
    padding: 6px 10px;
    gap: 4px;
    border-radius: 20px;
}

.mark-filter-bar-top .mark-filter-btn .filter-emoji {
    font-size: 1.1em;
}

.mark-filter-bar-top .mark-filter-btn .filter-count {
    font-size: 0.85em;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
}

.audio-section {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.audio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    padding: 10px;
    border-radius: 8px;
}

.audio-label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 60px;
}

.audio-item audio {
    flex: 1;
}

.audio-speed-select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85em;
    cursor: pointer;
    min-width: 60px;
    text-align: center;
}

.btn-delete-audio {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.2s;
}

.btn-delete-audio:hover {
    background: #dc3545;
    color: white;
}

.image-section {
    margin: 20px 0;
    text-align: center;
    position: relative;
}

.image-toolbar {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.18s;
    z-index: 2;
}

.image-section:hover .image-toolbar,
.image-toolbar:focus-within {
    opacity: 1;
}

.img-tool-btn {
    background: transparent;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.img-tool-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.image-wrap {
    overflow: hidden;
    max-width: 100%;
    text-align: center;
    border-radius: 8px;
}

.image-wrap img {
    border-radius: 8px;
    cursor: zoom-in;
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    transition: transform 0.2s;
    transform-origin: center top;
}

.image-section[data-mode="fit"] .image-wrap img {
    max-width: 100%;
    max-height: 360px;
    width: auto;
    object-fit: contain;
}

.image-section[data-mode="stretch"] .image-wrap img {
    width: 100%;
    max-width: 100%;
    max-height: 55vh;
    height: auto;
    object-fit: contain;
}

.image-section[data-mode="zoom"] .image-wrap img {
    max-width: none;
    max-height: none;
}

.image-section.img-hidden .image-wrap {
    height: 44px;
    background: var(--bg-secondary, #f5f7fa);
    border: 1px dashed var(--border-color, #e0e4ea);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-section.img-hidden .image-wrap img { display: none; }

.image-section.img-hidden .image-wrap::before {
    content: 'تصویر مخفی شده';
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    font-size: 0.85em;
    color: var(--text-muted, #888);
}

.image-section.img-hidden .image-toolbar { opacity: 1; }

/* Text hide (CE transcript + question content) */
.btn-text-hide {
    background: transparent;
    border: 1px solid var(--border-color, #e0e4ea);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted, #888);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.btn-text-hide:hover { color: #2a5298; background: var(--bg-card, #fff); }
.btn-text-hide.active { background: #fff3e0; border-color: #ffb74d; color: #e65100; }
html.dark .btn-text-hide { color: var(--text-muted, #888); }
html.dark .btn-text-hide:hover { background: var(--bg-card, #1e2a3a); color: #7db3ff; }
html.dark .btn-text-hide.active { background: #3a2a1a; border-color: #ffb74d; color: #ffb74d; }

#questionContainer.text-hidden .french-text,
#questionContainer.text-hidden .english-text,
#questionContainer.text-hidden .persian-text,
#questionContainer.text-hidden .question-content,
#questionContainer.text-hidden .question-content-translation {
    display: none !important;
}

/* Lightbox */
.img-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.img-lightbox.open { display: flex; }

.img-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.img-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 1.6em;
    cursor: pointer;
    line-height: 1;
}

.img-lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }

.text-section {
    margin: var(--sp-5) 0;
    padding: var(--sp-5);
    background: var(--bg-secondary);
    border-radius: var(--r-md);
    border-left: 4px solid #2a5298;
}

.french-text {
    font-size: var(--fs-md);
    line-height: var(--lh-loose);
    color: var(--text-primary);
}

/* CE side-by-side translation layout */
.ce-text-section.side-by-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    border-left: none;
}

.ce-text-section.side-by-side .ce-tts-bar {
    grid-column: 1 / -1;
}

.ce-text-section.side-by-side .french-text {
    padding-right: 20px;
    border-right: 2px solid var(--border-color);
}

.ce-text-section.side-by-side .persian-text,
.ce-text-section.side-by-side .english-text {
    padding-left: 20px;
}

.persian-text {
    font-size: var(--fs-md);
    line-height: var(--lh-loose);
    color: var(--text-primary);
}

/* Responsive: stack on mobile */
@media (max-width: 768px) {
    .ce-text-section.side-by-side {
        grid-template-columns: 1fr;
    }

    .ce-text-section.side-by-side .french-text {
        padding-right: 0;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        padding-bottom: 15px;
    }

    .ce-text-section.side-by-side .persian-text,
    .ce-text-section.side-by-side .english-text {
        padding-left: 0;
        padding-top: 15px;
    }
}

.question-content {
    font-size: var(--fs-lg);
    color: var(--text-primary);
    margin-bottom: var(--sp-5);
    line-height: var(--lh-normal);
    font-weight: 500;
}

.question-content-translation {
    font-size: var(--fs-md);
    color: var(--text-secondary);
    margin-top: calc(-1 * var(--sp-3));
    margin-bottom: var(--sp-5);
    padding: var(--sp-2) var(--sp-4);
    border-right: 3px solid var(--primary);
    background: var(--card-bg);
    border-radius: 0 var(--r-md) var(--r-md) 0;
    line-height: var(--lh-normal);
}

.question-content-translation.rtl {
    border-right: none;
    border-left: 3px solid var(--primary);
    border-radius: 8px 0 0 8px;
    direction: rtl;
    text-align: right;
}

.options-section {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.option-btn {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: var(--sp-4);
    border: 1.5px solid var(--border-color);
    border-radius: var(--r-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: var(--fs-md);
    line-height: var(--lh-normal);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    user-select: text;
    -webkit-user-select: text;
}

.option-btn:hover {
    border-color: #2a5298;
    background: #f8faff;
}

.option-btn.selected {
    border-color: #2a5298;
    background: #e8f0ff;
}

.option-btn.correct {
    border-color: #28a745;
    background: #d4edda;
}

.option-btn.wrong {
    border-color: #dc3545;
    background: #f8d7da;
}

html.dark .option-btn:hover {
    background: #253a52;
}

html.dark .option-btn.selected {
    background: #1a3358;
}

html.dark .option-btn.correct {
    border-color: #28a745;
    background: #1a3a2a;
    color: #c8e6c9;
}

html.dark .option-btn.wrong {
    border-color: #dc3545;
    background: #3a1a1a;
    color: #f8c0c0;
}

.option-label {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-light);
    color: var(--text-primary);
    border-radius: 50%;
    margin-right: var(--sp-3);
    font-weight: 600;
    font-size: var(--fs-sm);
}

.option-btn.selected .option-label {
    background: #2a5298;
    color: white;
}

.option-btn.correct .option-label {
    background: #28a745;
    color: white;
}

.option-btn.wrong .option-label {
    background: #dc3545;
    color: white;
}

.option-text {
    flex: 1;
}

.option-english {
    display: none;
    width: 100%;
    font-size: 1em;
    color: var(--text-secondary);
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
}

.option-english.show {
    display: block;
}

.option-persian {
    display: none;
    width: 100%;
    font-size: 1em;
    color: var(--text-secondary);
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
    direction: rtl;
    text-align: right;
}

.option-persian.show {
    display: block;
}

.btn-options-fa.active,
.btn-translation.active {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.action-buttons {
    display: flex;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.btn-answer {
    background: #17a2b8;
    color: white;
    flex: 1;
}

.btn-answer:hover {
    background: #138496;
}

.btn-prev {
    background: #6c757d;
    color: white;
    flex: 0 0 auto;
    padding: 10px 15px;
    font-size: 0.9em;
}

.btn-prev:hover {
    background: #5a6268;
}

.btn-prev:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-next {
    background: #28a745;
    color: white;
    flex: 0 0 auto;
    padding: 10px 15px;
    font-size: 0.9em;
}

.btn-next:hover {
    background: #218838;
}

.btn-next:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-answer {
    flex: 1;
}

.translation-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-translation {
    background: #6c757d;
    color: white;
    flex: 1;
    padding: 10px;
}

.btn-translation:hover {
    background: #5a6268;
}

.btn-vocabulary {
    background: #ffc107;
    color: #333;
}

.btn-vocabulary:hover {
    background: #e0a800;
}

.btn-summary {
    background: #4caf50;
    color: #fff;
}

.btn-summary:hover {
    background: #388e3c;
}

.translation-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 15px;
}

.translation-panel h4 {
    color: var(--text-heading);
    margin-bottom: 15px;
}

.transcript-content {
    line-height: 1.8;
    margin-bottom: 15px;
}

.reason-content {
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    line-height: 1.6;
}

/* Reason Panel (correct/wrong explanations) */
.reason-panel {
    margin-top: 20px;
}

.reason-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.reason-column {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 15px 20px;
}

.reason-column h4 {
    margin-bottom: 12px;
    font-size: 0.95em;
}

.reason-column.correct-reason {
    border-left: 4px solid #28a745;
}

.reason-column.correct-reason h4 {
    color: #28a745;
}

.reason-column.wrong-reason {
    border-left: 4px solid #dc3545;
}

.reason-column.wrong-reason h4 {
    color: #dc3545;
}

.reason-columns.rtl .reason-column {
    border-left: none;
}

.reason-columns.rtl .reason-column.correct-reason {
    border-right: 4px solid #28a745;
}

.reason-columns.rtl .reason-column.wrong-reason {
    border-right: 4px solid #dc3545;
}

.reason-text {
    line-height: 1.7;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .reason-columns {
        grid-template-columns: 1fr;
    }
}

.rtl {
    direction: rtl;
    text-align: right;
}

/* CO Text Section (above options, like CE side-by-side) */
.co-text-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #1e3c72;
    line-height: 1.8;
}

.co-text-section.side-by-side {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px;
    border-left: none;
}

.co-text-section.side-by-side .french-text {
    padding-right: 20px;
    border-right: 2px solid var(--border-color);
}

.co-text-section.side-by-side .persian-text,
.co-text-section.side-by-side .english-text {
    padding-left: 20px;
}

.english-text {
    font-size: 1.05em;
    line-height: 1.8;
    color: var(--text-primary);
}

@media (max-width: 576px) {
    .co-text-section.side-by-side {
        grid-template-columns: 1fr !important;
    }
    .co-text-section.side-by-side .french-text {
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        padding-right: 0;
        padding-bottom: 15px;
        margin-bottom: 15px;
    }
    .co-text-section.side-by-side .persian-text,
    .co-text-section.side-by-side .english-text {
        padding-left: 0;
    }
}

/* Vocabulary Section */
.vocabulary-section {
    background: #fff8e1;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    border-left: 4px solid #ffc107;
}

.vocabulary-section h4 {
    color: #856404;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.vocabulary-content {
    line-height: 1.8;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 5px;
}

.vocabulary-content:last-child {
    margin-bottom: 0;
}

/* Summary Section Styling */
.summary-section {
    background: #e8f5e9;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    border-left: 4px solid #4caf50;
    color: #1a1a1a;
}

html.dark .summary-section {
    background: #1a2e1a;
    color: var(--text-primary);
}

.summary-section h4 {
    color: #2e7d32;
    margin-bottom: 15px;
    font-size: 1.1em;
}

html.dark .summary-section h4 {
    color: #66bb6a;
}

.summary-block {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

html.dark .summary-block {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.summary-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.summary-block h4 {
    margin-bottom: 8px;
}

.summary-content {
    line-height: 1.8;
    padding: 10px;
    border-radius: 5px;
    color: #000;
    font-weight: 500;
}

html.dark .summary-content {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
}

.summary-empty {
    color: var(--text-muted);
    font-weight: 400;
    font-style: italic;
}

/* Summary Tabs */
.summary-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 15px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 10px;
}

html.dark .summary-tabs {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.summary-tab {
    padding: 6px 14px;
    border: 1.5px solid #ccc;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
}

.summary-tab:hover {
    border-color: #4caf50;
    color: #2e7d32;
}

.summary-tab.active {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

html.dark .summary-tab {
    background: rgba(255, 255, 255, 0.05);
    border-color: #555;
    color: #aaa;
}

html.dark .summary-tab:hover {
    border-color: #66bb6a;
    color: #66bb6a;
}

html.dark .summary-tab.active {
    background: #388e3c;
    color: white;
    border-color: #388e3c;
}

.summary-tab-content {
    display: none;
}

.summary-tab-content.active {
    display: block;
}

/* Vocabulary Table Styling */
.vocab-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.vocab-table tr {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

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

.vocab-table tr:hover {
    background: rgba(255, 255, 255, 0.7);
}

.vocab-table td {
    padding: 8px 15px;
    vertical-align: middle;
}

.vocab-table .vocab-fr {
    font-weight: 600;
    color: #2c5282;
    width: 45%;
    padding-right: 25px;
}

.vocab-table .vocab-en {
    color: #2d3748;
    padding-left: 20px;
}

.vocab-table .vocab-fa {
    color: #2d3748;
    text-align: right;
    direction: rtl;
    padding-right: 25px;
}

.vocab-table .vocab-example {
    color: #718096;
    font-style: italic;
    font-size: 0.88em;
    padding-left: 20px;
}

/* Keep vocab table LTR even in RTL container */
.rtl .vocab-table {
    direction: ltr;
}

/* Vocabulary Star Button */
.vocab-star-cell {
    width: 30px;
    text-align: center;
}

.vocab-star {
    cursor: pointer;
    font-size: 1.3em;
    color: #ddd;
    transition: all 0.2s ease;
    display: inline-block;
}

.vocab-star:hover {
    color: #ffc107;
    transform: scale(1.2);
}

.vocab-star.saved {
    color: #ffc107;
}

/* Vocabulary TTS Button */
.btn-tts-vocab {
    background: none;
    border: none;
    cursor: pointer;
    padding: 1px 3px;
    display: inline-flex;
    align-items: center;
    color: #94a3b8;
    vertical-align: middle;
    margin-right: 4px;
    border-radius: 4px;
    transition: color 0.2s;
}
.btn-tts-vocab:hover { color: #3b82f6; background: #eff6ff; }
.btn-tts-vocab.playing { color: #ef4444; }

/* Timer Display - Fixed top right */
.timer-display {
    position: fixed;
    top: 65px;
    right: 20px;
    background: #1e3c72;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 1.4em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 999;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.timer-icon {
    font-size: 1.1em;
}

.timer-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.timer-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.timer-close-btn {
    background: rgba(255, 255, 255, 0.15);
    font-size: 0.8em;
    width: 26px;
    height: 26px;
    margin-left: -4px;
}

.timer-close-btn:hover {
    background: rgba(231, 76, 60, 0.7);
}

.timer-display.timer-negative {
    background: #dc3545;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Score Section */
.score-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.score-display {
    font-size: 1.1em;
    font-weight: 600;
    color: #1e3c72;
    margin-bottom: 5px;
}

.answered-count {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 15px;
}

.btn-results {
    width: 100%;
    background: #9b59b6;
    color: white;
    padding: 10px;
}

.btn-results:hover {
    background: #8e44ad;
}

.btn small, a.btn small, button.btn small {
    font-weight: normal;
    opacity: 0.75;
    font-size: 0.8em;
}

/* Mobile floating results bar - hidden on desktop */
.mobile-results-bar {
    display: none;
}

/* Answered question nav buttons */
.question-nav-btn.answered {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

.question-nav-btn.answered-correct {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.question-nav-btn.answered-wrong {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

/* Results Page */
.results-container {
    text-align: center;
}

.results-container h2 {
    color: #1e3c72;
    margin-bottom: 30px;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.result-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

.result-label {
    display: block;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.result-value {
    font-size: 1.5em;
    font-weight: 600;
    color: #333;
}

.result-score {
    background: #e8f4fd;
}

.result-clb {
    background: #1e3c72;
}

.result-clb .result-label {
    color: rgba(255,255,255,0.8);
}

.result-clb .result-value {
    color: white;
}

.clb-level {
    font-size: 2em !important;
}

.cefr-level {
    font-size: 2em !important;
}

.cefr-description {
    font-size: 0.45em;
    opacity: 0.7;
    display: block;
    margin-top: 2px;
}

.results-by-level {
    text-align: left;
    margin: 30px 0;
}

.results-by-level h3 {
    color: #1e3c72;
    margin-bottom: 15px;
}

.level-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.level-breakdown-item {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.05);
}

.lb-level {
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 6px;
}

.lb-stats {
    font-size: 0.9em;
}

.lb-stats > div {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
}

.lb-label {
    opacity: 0.75;
}

.lb-value {
    font-weight: 600;
}

.results-detail {
    text-align: left;
    margin: 30px 0;
}

.results-detail h3 {
    color: #1e3c72;
    margin-bottom: 15px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

.result-question {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    background: #f0f0f0;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.result-question:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.result-question.correct {
    background: #d4edda;
}

.result-question.wrong {
    background: #f8d7da;
}

.result-question.not-answered {
    background: #e9ecef;
    opacity: 0.6;
}

.rq-num {
    font-weight: 600;
    font-size: 1.1em;
}

.rq-points {
    font-size: 0.8em;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: none;
    }

    .question-sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .question-main {
        margin-left: 0;
    }

    .series-page {
        flex-direction: column;
    }

    .question-nav-grouped {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .difficulty-group {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .difficulty-label {
        min-width: 25px;
    }
}

/* Alerts */
.alert {
    padding: 12px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: left;
}

.alert-error {
    background: #fee;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

html.dark .alert-error {
    background: rgba(220, 53, 69, 0.18);
    color: #ff8a80;
    border-color: rgba(220, 53, 69, 0.4);
}
html.dark .alert-success {
    background: rgba(46, 125, 50, 0.18);
    color: #a5d6a7;
    border-color: rgba(46, 125, 50, 0.4);
}

/* Responsive - Mobile Styles */
@media (max-width: 768px) {
    /* Header */
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px;
    }

    .header h1 {
        font-size: 1.2em;
    }

    .user-info {
        flex-direction: column;
        gap: 10px;
    }

    /* Login Page */
    .login-box {
        margin: 20px auto;
        padding: 25px 20px;
        max-width: 95%;
    }

    .login-box h1 {
        font-size: 1.2em;
    }

    .login-box h2 {
        font-size: 1em;
        margin-bottom: 20px;
    }

    .form-group input {
        padding: 14px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .login-footer {
        font-size: 0.8em;
    }

    /* Home Page */
    .main-content {
        padding: 20px 15px;
    }

    .main-content h2 {
        font-size: 1.2em;
        margin-bottom: 25px;
    }

    .button-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .btn-large {
        min-width: 100%;
        padding: 22px 25px;
        font-size: 1.1em;
    }

    .btn-subtitle {
        font-size: 0.8em;
    }

    .home-footer {
        font-size: 0.8em;
    }

    /* Timer on mobile: inline instead of fixed overlay */
    .timer-display {
        position: static;
        display: flex;
        justify-content: center;
        border-radius: 0;
        padding: 8px 12px;
        font-size: 1.1em;
        gap: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        order: 0;
    }

    .timer-btn {
        width: 28px;
        height: 28px;
        font-size: 0.8em;
    }

    /* Series/Question Page */
    .series-page {
        flex-direction: column;
        padding-top: 0;
    }

    .question-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 15px;
        order: 2; /* Move sidebar below main content on mobile */
    }

    /* Hide sidebar results button on mobile (mobile-results-bar handles this) */
    .question-sidebar .btn-results {
        display: none;
    }

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

    .sidebar-header h3 {
        font-size: 1.1em;
    }

    .question-main {
        margin-left: 0;
        margin-right: 0;
        padding: 15px;
        order: 1;
        width: 100%;
    }

    .question-rightbar {
        position: relative;
        top: 0;
        width: 100%;
        height: auto;
        order: 0;
        padding: 8px;
    }

    .question-rightbar .timer-display {
        flex-direction: row;
        font-size: 1.1em;
        padding: 8px 12px;
    }
    .question-rightbar .timer-controls { margin-top: 0; }

    .question-container {
        padding: 20px 15px;
    }

    .question-header {
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }

    .question-number {
        font-size: 1.1em;
    }

    .question-content {
        font-size: 1em;
    }

    /* Navigation buttons grouped */
    .question-nav-grouped {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .difficulty-group {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
    }

    .difficulty-label {
        min-width: 25px;
        font-size: 0.8em;
    }

    .difficulty-buttons {
        gap: 4px;
    }

    .question-nav-btn {
        width: 32px;
        height: 32px;
        font-size: 0.8em;
    }

    .question-mark-selector {
        gap: 4px;
    }
    .q-mark-btn {
        padding: 4px 7px;
        font-size: 11px;
    }

    /* Options */
    .option-btn {
        padding: 12px;
    }

    .option-label {
        width: 26px;
        height: 26px;
        margin-right: 10px;
        font-size: 0.9em;
    }

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

    /* Action buttons: single row — prev | answer | next */
    .action-buttons {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        max-width: 100%;
        align-items: stretch;
    }

    .btn-prev, .btn-next {
        flex: 0 0 auto;
        padding: 8px 12px;
        font-size: 1em;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 50px;
    }

    .btn-prev .btn-arrow, .btn-next .btn-arrow {
        font-size: 1.4em;
        line-height: 1;
        order: 0;
    }

    .btn-prev .btn-label, .btn-next .btn-label {
        font-size: 0.6em;
        opacity: 0.85;
        order: 1;
    }

    .btn-answer {
        flex: 1 1 0;
        padding: 14px 10px;
        font-size: 1em;
        font-weight: 600;
        min-width: 0;
        white-space: nowrap;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Translation buttons: 2 per row */
    .translation-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .btn-translation {
        padding: 10px 8px;
        font-size: 0.85em;
        text-align: center;
        justify-content: center;
    }

    .translation-panel {
        padding: 15px;
    }

    .translation-panel h4 {
        font-size: 1em;
    }

    /* Audio section */
    .audio-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .audio-speed-select {
        align-self: flex-start;
    }

    .audio-item audio {
        width: 100%;
        min-width: 200px;
        min-height: 40px;
    }

    /* Text section */
    .text-section {
        padding: 15px;
    }

    .french-text {
        font-size: 1em;
    }

    /* Score section */
    .score-section {
        margin-top: 15px;
        padding-top: 15px;
    }

    .score-display {
        font-size: 1em;
    }

    /* Mobile floating results bar */
    .mobile-results-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 10px 15px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
        z-index: 1000;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .mobile-results-info {
        font-size: 0.9em;
        font-weight: 600;
        color: #333;
        white-space: nowrap;
    }

    .mobile-results-bar .btn-results {
        width: auto;
        padding: 8px 16px;
        font-size: 0.85em;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Add bottom padding to page so content isn't hidden behind floating bar */
    .series-page {
        padding-bottom: 60px;
    }

    /* Results */
    .results-summary {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .result-item {
        padding: 15px;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 6px;
    }

    .result-question {
        padding: 8px;
    }

    .rq-num {
        font-size: 1em;
    }

    .rq-points {
        font-size: 0.7em;
    }

    /* Question stats */
    .question-stats {
        padding: 12px 15px;
    }

    .stats-title {
        font-size: 0.9em;
    }

    .stat-label, .stat-value {
        font-size: 0.85em;
    }

    /* Series grid - 2 columns on mobile */
    .series-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 15px;
    }

    .series-btn {
        padding: 12px;
    }

    .series-title {
        font-size: 0.9em;
    }

    /* Action buttons row on mobile */
    .saved-questions-link {
        gap: 8px !important;
    }

    .saved-questions-link .btn {
        padding: 10px 14px;
        font-size: 0.85em;
    }

    /* Container */
    .container {
        padding: 10px;
    }

    /* Vocabulary section */
    .vocabulary-section {
        padding: 15px;
    }

    .vocabulary-section h4 {
        font-size: 1em;
    }

    .vocabulary-content {
        font-size: 0.9em;
    }

    .summary-section {
        padding: 15px;
    }

    .summary-section h4 {
        font-size: 1em;
    }

    .summary-content {
        font-size: 0.9em;
    }
}

/* Bookmark/Save Button Styles */
.btn-bookmark {
    background: transparent;
    border: 2px solid #ffc107;
    color: #ffc107;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.btn-bookmark:hover {
    background: #fff8e1;
}

.btn-bookmark.saved {
    background: #ffc107;
    color: #333;
}

.btn-bookmark.saved:hover {
    background: #e0a800;
}

.bookmark-icon {
    font-size: 1.2em;
}

.btn-copy {
    background: transparent;
    border: 2px solid #90a4ae;
    color: #607d8b;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-copy:hover {
    background: #eceff1;
    border-color: #607d8b;
}

/* Saved Questions Link on Series List Page */
.saved-questions-link {
    text-align: center;
    margin-bottom: 20px;
}

.saved-questions-link .btn small {
    display: block;
    font-size: 0.75em;
    opacity: 0.85;
    margin-top: 2px;
}

.btn-saved {
    background: #ffc107;
    color: #333;
    padding: 12px 25px;
    font-size: 1em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    text-align: center;
    line-height: 1.4;
}

.btn-saved:hover {
    background: #e0a800;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

.saved-icon {
    font-size: 1.3em;
}

.btn-levels {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 25px;
    font-size: 1em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.4;
}

.btn-levels:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-levels-locked {
    background: linear-gradient(135deg, #9e9e9e 0%, #757575 100%);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-levels-locked::after {
    content: ' \1F512';
}

.btn-levels-locked:hover {
    transform: none;
    box-shadow: none;
}

.btn-premium-feature {
    position: relative;
}

.premium-ribbon {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ffd700, #f0a500);
    color: #3a2800;
    font-size: 0.6em;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(255, 215, 0, 0.4);
    line-height: 1.4;
    white-space: nowrap;
}

/* Saved Questions Page */
.saved-page {
    display: flex;
    min-height: 100vh;
}

.saved-count-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    text-align: center;
}

.saved-count {
    font-size: 1em;
    color: #1e3c72;
    font-weight: 600;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 4em;
    color: #ffc107;
    margin-bottom: 20px;
}

.empty-state h2 {
    color: #1e3c72;
    margin-bottom: 15px;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.empty-state p {
    color: #666;
    margin-bottom: 25px;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.loading-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 1.1em;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.no-saved-message {
    text-align: center;
    padding: 20px;
    color: #666;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

/* Saved page responsive */
@media (max-width: 768px) {
    .saved-page {
        flex-direction: column;
    }

    .btn-bookmark {
        padding: 5px 10px;
        font-size: 0.8em;
    }

    .saved-questions-link {
        margin-bottom: 15px;
    }

    .btn-saved {
        padding: 10px 20px;
        font-size: 0.9em;
    }

    .empty-state {
        padding: 40px 15px;
    }

    .empty-icon {
        font-size: 3em;
    }
}

/* Extra small devices */
@media (max-width: 400px) {
    .login-box {
        padding: 20px 15px;
    }

    .login-box h1 {
        font-size: 1.1em;
    }

    .btn-large {
        padding: 20px 25px;
        font-size: 1em;
    }

    .timer-display {
        font-size: 1em;
        padding: 6px 10px;
    }

    .question-nav-btn {
        width: 28px;
        height: 28px;
        font-size: 0.75em;
    }

    .btn-translation {
        flex: 1 1 100%;
    }
}

/* Search Button */
.btn-search {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 25px;
    font-size: 1em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    border-radius: 25px;
    text-align: center;
    line-height: 1.4;
}

.btn-search:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-search svg {
    flex-shrink: 0;
}

/* Profile Settings Page */
.profile-box {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 5px 15px var(--shadow-color);
    max-width: 550px;
    margin: 20px auto;
    direction: rtl;
    text-align: right;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.profile-box h2 {
    color: var(--text-heading);
    font-size: 1.4em;
    margin-bottom: 10px;
    text-align: center;
}

.profile-username {
    text-align: center;
    color: #666;
    margin-bottom: 25px;
    font-size: 0.95em;
}

.profile-box .form-group {
    margin-bottom: 20px;
    text-align: right;
}

.profile-box .form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.profile-box .form-group input,
.profile-box .form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    box-sizing: border-box;
    background-color: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 15px center;
}

.profile-box .form-group input {
    cursor: text;
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
    background-image: none;
}

.profile-box .form-group input:focus,
.profile-box .form-group select:focus {
    outline: none;
    border-color: #2a5298;
}

.profile-box .btn-primary {
    width: 100%;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    font-size: 1.05em;
    margin-top: 10px;
}

.profile-premium-info {
    margin-top: 25px;
    padding: 15px;
    background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
    border-radius: 8px;
    text-align: center;
    border: 1px solid #ffc107;
}

.premium-badge {
    font-weight: 600;
    color: #856404;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.profile-meta {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85em;
    color: #888;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.profile-meta p {
    margin-bottom: 6px;
}

/* Nav profile button */
.nav-profile-btn {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 1.1em;
    transition: all 0.2s;
    margin-right: 10px;
}

.nav-profile-btn:hover,
.nav-profile-btn.active {
    background: rgba(255, 255, 255, 0.15);
}

/* Profile page responsive */
@media (max-width: 768px) {
    .profile-box {
        margin: 10px auto;
        padding: 25px 20px;
        max-width: 95%;
    }

    .profile-box h2 {
        font-size: 1.2em;
    }

    .profile-box .form-group input,
    .profile-box .form-group select {
        padding: 14px 12px;
        font-size: 16px;
    }
}

/* Home card - Notebook */
.home-card.card-notebook {
    --card-color: #5c6bc0;
}

/* Home card - Partner */
.home-card.card-partner {
    --card-color: #e65100;
}

/* Home card - About Exam */
.home-card.card-exam {
    --card-color: #c62828;
}

/* Home card - Resources */
.home-card.card-resources {
    --card-color: #00897b;
}

/* Home card - Donate */
.home-card.card-donate {
    --card-color: #e91e63;
}

/* Home card - Contact */
.home-card.card-contact {
    --card-color: #0088cc;
}

/* Home card - Activity */
.home-card.card-activity {
    --card-color: #e65100;
}

/* Resources Page */
.resources-page {
    display: flex;
    flex-direction: column;
    gap: 25px;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.resource-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.resource-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 25px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    border-bottom: 2px solid #d0deff;
}

.resource-section-icon {
    font-size: 1.5em;
}

.resource-section-header h2 {
    color: #1e3c72;
    font-size: 1.2em;
    margin: 0;
}

.resource-section-body {
    padding: 25px;
    line-height: 1.9;
    color: #444;
}

.resource-section-body h3 {
    color: #1e3c72;
    margin: 25px 0 15px;
    font-size: 1.05em;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.resource-section-body h3:first-child {
    margin-top: 10px;
}

.resource-section-body p {
    margin-bottom: 12px;
}

.resource-coming-soon {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px 0;
    margin: 0;
}

html.dark .resource-coming-soon {
    color: #666;
}

.resource-section-body ul {
    padding-right: 25px;
    margin-bottom: 15px;
}

.resource-section-body ul li {
    margin-bottom: 8px;
    line-height: 1.7;
}

/* Mini Cards (TCF types) */
.resource-cards-mini {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 15px;
}

.resource-card-mini {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border: 1px solid #e8e8e8;
    transition: all 0.2s;
}

.resource-card-mini:hover {
    border-color: #2a5298;
    background: #f0f4ff;
}

.resource-card-mini strong {
    color: #1e3c72;
    font-size: 1em;
}

.resource-card-mini span {
    color: #666;
    font-size: 0.9em;
}

/* Exam Structure */
.exam-structure {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.exam-part {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e8e8e8;
}

.exam-part-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    color: white;
    font-size: 0.95em;
}

.exam-part-header span {
    font-size: 1.2em;
}

.exam-part-ce { background: #2a5298; }
.exam-part-co { background: #1e88e5; }
.exam-part-ee { background: #43a047; }
.exam-part-eo { background: #7b1fa2; }

.exam-part-body {
    padding: 15px 18px;
    background: #fafafa;
}

.exam-part-body p {
    margin-bottom: 10px;
    font-weight: 500;
    color: #333;
}

.exam-part-body ul {
    padding-right: 20px;
    margin-bottom: 0;
}

.exam-part-body ul li {
    margin-bottom: 5px;
    color: #555;
    font-size: 0.95em;
}

/* Levels Table */
.levels-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.level-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 18px;
    border-radius: 8px;
    background: #f8f9fa;
    border: 1px solid #e8e8e8;
    transition: all 0.2s;
}

.level-row:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.level-badge {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1em;
    color: white;
    flex-shrink: 0;
}

.level-a1 .level-badge { background: #4caf50; }
.level-a2 .level-badge { background: #2196f3; }
.level-b1 .level-badge { background: #ff9800; }
.level-b2 .level-badge { background: #f57c00; }
.level-c1 .level-badge { background: #e53935; }
.level-c2 .level-badge { background: #b71c1c; }

.level-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.level-info strong {
    color: #333;
    font-size: 0.95em;
}

.level-info span {
    color: #777;
    font-size: 0.85em;
}

/* Note Box */
.resource-note {
    background: #fff8e1;
    border-radius: 8px;
    padding: 15px 18px;
    margin-top: 20px;
    border-right: 4px solid #ffc107;
    font-size: 0.95em;
    line-height: 1.8;
}

/* Tip Groups */
.tip-group {
    margin-bottom: 20px;
}

.tip-group h3 {
    border-bottom: none !important;
    background: #f0f4ff;
    padding: 10px 15px !important;
    border-radius: 8px;
    margin-bottom: 10px !important;
}

/* Resource List */
.resource-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    transition: all 0.2s;
}

.resource-item:hover {
    border-color: #2a5298;
    background: #f0f4ff;
}

.resource-item-icon {
    font-size: 1.5em;
    flex-shrink: 0;
}

.resource-item-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.resource-item-content strong {
    color: #1e3c72;
    font-size: 0.95em;
}

.resource-item-content span {
    color: #666;
    font-size: 0.88em;
}

/* Resources Responsive */
@media (max-width: 768px) {
    .resource-section-header {
        padding: 15px 18px;
    }

    .resource-section-header h2 {
        font-size: 1.05em;
    }

    .resource-section-body {
        padding: 18px;
    }

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

    .level-row {
        padding: 10px 14px;
    }

    .level-badge {
        width: 38px;
        height: 38px;
        font-size: 0.9em;
    }
}

/* ─── Toast Notifications ─────────────────────────────────────────────────── */
#toastContainer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.api-toast {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9em;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    color: white;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: auto;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    direction: rtl;
}

.api-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.api-toast-info    { background: #2a5298; }
.api-toast-success { background: #28a745; }
.api-toast-warning { background: #e67e22; }
.api-toast-error   { background: #dc3545; }

@media (max-width: 768px) {
    #toastContainer {
        bottom: 70px;
        left: 10px;
        right: 10px;
        transform: none;
    }

    .api-toast {
        white-space: normal;
        text-align: center;
    }
}

/* ==========================================
   Add Vocabulary Panel (inline, like other panels)
   ========================================== */
.add-vocab-panel {
    border-left: 4px solid #27ae60;
}

.add-vocab-panel h4 {
    color: #27ae60;
}

.add-vocab-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.add-vocab-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color, #ddd);
    border-radius: 8px;
    font-size: 0.95em;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #333);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.add-vocab-input:focus {
    border-color: #27ae60;
}

.add-vocab-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.add-vocab-lang {
    display: flex;
    gap: 6px;
}

.add-vocab-lang-btn {
    padding: 8px 16px;
    border: 1.5px solid var(--border-color, #ddd);
    border-radius: 8px;
    background: var(--bg-primary, #fff);
    color: var(--text-secondary, #666);
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    transition: all 0.2s;
}

.add-vocab-lang-btn:hover {
    border-color: #27ae60;
    color: #27ae60;
}

.add-vocab-lang-btn.active {
    background: #27ae60;
    color: #fff;
    border-color: #27ae60;
}

.add-vocab-save-btn {
    padding: 8px 24px;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
    margin-right: auto;
}

.add-vocab-save-btn:hover {
    background: #219a52;
}

.add-vocab-save-btn.saved {
    background: #2a5298;
}

/* Add Vocab toggle button */
.btn-add-vocab {
    background: #27ae60 !important;
    color: #fff !important;
    border-color: #27ae60 !important;
}

.btn-add-vocab:hover {
    background: #219a52 !important;
}

/* ─── Enhanced Mobile Responsiveness ──────────────────────────────── */

/* Prevent horizontal overflow on all pages */
html {
    overflow-x: hidden;
}

@media (max-width: 768px) {
    /* Ensure container doesn't overflow */
    .container {
        max-width: 100vw;
    }

    /* Header: prevent long text from overflowing */
    .header {
        padding: 15px;
        word-break: break-word;
    }

    .header h1 {
        font-size: 1.1em;
        white-space: normal;
        word-break: break-word;
    }

    /* Buttons row: ensure wrapping */
    .saved-questions-link {
        gap: 8px !important;
    }

    .btn-search,
    .btn-saved,
    .btn-levels {
        padding: 8px 14px;
        font-size: 0.85em;
    }

    /* Book filter buttons compact */
    .book-filter {
        gap: 8px;
    }

    .book-filter-btn {
        padding: 7px 14px;
        font-size: 0.85em;
    }

    /* Mark filter bar: allow wrapping on mobile */
    .mark-filter-bar {
        flex-wrap: wrap;
        overflow-x: visible;
        gap: 4px;
        padding: 6px 8px;
    }

    .mark-filter-btn {
        font-size: 0.78em;
        padding: 5px 10px;
    }

    /* Results summary - smaller level fonts */
    .clb-level,
    .cefr-level {
        font-size: 1.5em !important;
    }

    .result-value {
        font-size: 1.2em;
    }

    .results-detail {
        padding: 15px;
    }

    /* Mobile results info: allow wrapping */
    .mobile-results-info {
        white-space: normal;
        font-size: 0.82em;
    }

    /* Vocabulary table: better mobile display */
    .vocab-table {
        font-size: 0.85em;
    }

    .vocab-table td {
        padding: 6px 4px;
        word-break: break-word;
    }

    /* Book filter buttons: smaller on mobile */
    .book-filter-btn {
        padding: 8px 16px;
        font-size: 0.85em;
    }

    /* Profile box: tighter mobile */
    .profile-box {
        padding: 20px 15px;
    }

    /* Add vocab panel mobile */
    .add-vocab-actions {
        flex-wrap: wrap;
    }

    .add-vocab-save-btn {
        width: 100%;
        text-align: center;
    }

    /* Translation buttons: full width on mobile */
    .btn-translation {
        flex: 1 1 100%;
    }

    /* Reason columns: tighter padding */
    .reason-column {
        padding: 12px;
    }
}

/* Extra small devices (phones < 480px) */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    .main-content {
        padding: 15px 10px;
    }

    .main-content h2 {
        font-size: 1.1em;
    }

    /* Home cards: tighter */
    .home-card {
        padding: 14px 16px;
    }

    .card-icon {
        font-size: 2em;
    }

    .card-title {
        font-size: 0.95em;
    }

    .card-subtitle {
        font-size: 0.85em;
    }

    /* Question page: tighter */
    .question-container {
        padding: 15px 10px;
    }

    .question-content {
        font-size: 0.95em;
    }

    .option-btn {
        padding: 10px;
    }

    .option-label {
        width: 24px;
        height: 24px;
        font-size: 0.8em;
        margin-right: 8px;
    }

    .option-text {
        font-size: 0.9em;
    }

    /* Action buttons: smaller */
    .btn-prev, .btn-next, .btn-answer {
        padding: 10px;
        font-size: 0.9em;
    }

    /* Header: smaller */
    .header h1 {
        font-size: 1em;
    }

    /* Login: minimal padding */
    .login-box {
        padding: 20px 15px;
        margin: 15px auto;
    }

    /* Empty state: smaller icon */
    .empty-icon {
        font-size: 2.5em;
    }

    /* Results: compact */
    .clb-level,
    .cefr-level {
        font-size: 1.3em !important;
    }

    .result-item {
        padding: 10px;
    }

    /* Timer on very small screens */
    .timer-display {
        font-size: 0.95em;
        padding: 6px 8px;
    }

    /* Series grid: 2 columns on small phones */
    .series-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }

    .series-btn {
        padding: 10px 8px;
    }

    .series-title {
        font-size: 0.85em;
    }

    .book-tag {
        font-size: 0.6em;
        padding: 1px 5px;
    }

    /* Action buttons: full width on small phones */
    .saved-questions-link .btn {
        flex: 1 1 calc(50% - 8px);
        text-align: center;
        justify-content: center;
        padding: 8px 10px;
        font-size: 0.8em;
    }

    /* Sidebar on mobile: compact */
    .question-sidebar {
        padding: 10px;
    }

    .question-nav-btn {
        width: 28px;
        height: 28px;
        font-size: 0.75em;
    }

    /* Score section compact */
    .score-display {
        font-size: 0.9em;
    }

    /* Text sections */
    .french-text,
    .persian-text,
    .english-text {
        font-size: 0.95em;
        line-height: 1.7;
    }

    .ce-text-section,
    .co-text-section {
        padding: 12px;
    }

    /* Vocabulary section compact */
    .vocabulary-section {
        padding: 12px;
    }

    /* Translation panel compact */
    .translation-panel {
        padding: 12px;
    }

    /* Home footer */
    .home-footer {
        font-size: 0.75em;
    }

    /* Toast: smaller */
    .api-toast {
        font-size: 0.82em;
        padding: 8px 14px;
    }

    /* Donation page: compact cards */
    .donation-card {
        padding: 18px !important;
    }
}

/* ─── Text Highlighting ──────────────────────── */
/* ─── Highlight toggle button in question header ──── */
.btn-highlight-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    cursor: pointer;
    font-size: 0.82em;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-highlight-toggle:hover {
    background: var(--bg-hover, #f5f5f5);
    border-color: var(--text-muted);
}

.btn-highlight-toggle.active {
    background: #fff9c4;
    border-color: #f9a825;
    color: #333;
}

html.dark .btn-highlight-toggle.active {
    background: rgba(249, 168, 37, 0.2);
    border-color: #f9a825;
    color: #ffd54f;
}

/* ─── Highlight color palette (below question header) ── */
.highlight-palette {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    animation: highlightFadeIn 0.15s ease;
}

.highlight-palette.visible {
    display: flex;
}

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

.highlight-palette-sep {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 4px;
}

.highlight-tool-btn {
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    cursor: pointer;
    font-size: 0.8em;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}

.highlight-tool-btn:hover {
    background: var(--bg-hover, #f5f5f5);
    border-color: var(--text-muted);
}

.highlight-tool-btn.active {
    background: #fff3e0;
    border-color: #ff9800;
    color: #e65100;
}

html.dark .highlight-tool-btn.active {
    background: rgba(255, 152, 0, 0.2);
    border-color: #ff9800;
    color: #ffb74d;
}

.highlight-tool-btn.highlight-clear-all:hover {
    background: #fee;
    border-color: #e74c3c;
    color: #e74c3c;
}

.highlight-color-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

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

.highlight-color-btn.active {
    border-color: #333;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.2);
}

.highlight-color-btn.yellow { background: #fff176; }
.highlight-color-btn.green { background: #a5d6a7; }
.highlight-color-btn.blue { background: #90caf9; }
.highlight-color-btn.pink { background: #f48fb1; }
.highlight-color-btn.orange { background: #ffcc80; }

/* Highlight mark styling */
mark.user-highlight {
    border-radius: 2px;
    padding: 0 1px;
    cursor: pointer;
}

mark.user-highlight.yellow { background: #fff176; }
mark.user-highlight.green { background: #a5d6a7; }
mark.user-highlight.blue { background: #90caf9; }
mark.user-highlight.pink { background: #f48fb1; }
mark.user-highlight.orange { background: #ffcc80; }

html.dark mark.user-highlight.yellow { background: rgba(255, 241, 118, 0.4); }
html.dark mark.user-highlight.green { background: rgba(165, 214, 167, 0.4); }
html.dark mark.user-highlight.blue { background: rgba(144, 202, 249, 0.4); }
html.dark mark.user-highlight.pink { background: rgba(244, 143, 177, 0.4); }
html.dark mark.user-highlight.orange { background: rgba(255, 204, 128, 0.4); }

/* ─── Floating Highlight FAB ─────────────────── */
.highlight-fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.highlight-fab.active {
    opacity: 1;
    pointer-events: auto;
}

/* Hide FAB on mobile - header button is sufficient */
@media (max-width: 768px) {
    .highlight-fab {
        display: none !important;
    }
}

.highlight-fab-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-card);
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    cursor: pointer;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.highlight-fab-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.highlight-fab-btn.active {
    background: #fff9c4;
    border: 2px solid #f9a825;
    color: #333;
}

html.dark .highlight-fab-btn {
    background: var(--bg-card);
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

html.dark .highlight-fab-btn.active {
    background: rgba(249, 168, 37, 0.25);
    border: 2px solid #f9a825;
    color: #ffd54f;
}

.highlight-fab-palette {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    animation: highlightFadeIn 0.15s ease;
}

.highlight-fab-palette.visible {
    display: flex;
}

html.dark .highlight-fab-palette {
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.highlight-fab-palette .highlight-color-btn {
    width: 28px;
    height: 28px;
}

.highlight-fab-palette .highlight-tool-btn {
    font-size: 0.75em;
    padding: 3px 8px;
}

.highlight-fab-close {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-left: 2px;
}

.highlight-fab-close:hover {
    background: #fee;
    border-color: #e74c3c;
    color: #e74c3c;
}

/* ─── Question Notes ──────────────────────── */
.question-note-section {
    margin-top: 15px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-card);
}

.question-note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: var(--bg-secondary);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.question-note-header:hover {
    background: var(--border-color);
}

.question-note-title {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}

.question-note-title .note-icon {
    font-size: 1.1em;
}

.note-has-content {
    width: 8px;
    height: 8px;
    background: #3498db;
    border-radius: 50%;
    display: inline-block;
}

.question-note-toggle {
    font-size: 0.8em;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.question-note-section.open .question-note-toggle {
    transform: rotate(180deg);
}

.question-note-body {
    display: none;
    padding: 12px 15px;
}

.question-note-section.open .question-note-body {
    display: block;
}

.question-note-textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9em;
    resize: vertical;
    background: var(--bg-input);
    color: var(--text-primary);
    line-height: 1.5;
    direction: rtl;
}

.question-note-textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.question-note-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.note-save-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    background: #3498db;
    color: white;
    transition: background 0.2s;
}

.note-save-btn:hover {
    background: #2980b9;
}

.note-save-btn.saved {
    background: #27ae60;
}

.note-status {
    font-size: 0.8em;
    color: var(--text-muted);
    align-self: center;
}

/* Note read/edit views */
.note-read-view,
.note-edit-view {
    /* shown by default */
}

.note-read-view.hidden,
.note-edit-view.hidden {
    display: none;
}

.note-read-content {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9em;
    line-height: 1.7;
    color: var(--text-primary);
    direction: rtl;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.note-edit-btn {
    margin-top: 8px;
    padding: 5px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    cursor: pointer;
    font-size: 0.82em;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.note-edit-btn:hover {
    background: var(--bg-hover, #f5f5f5);
    border-color: #3498db;
    color: #3498db;
}

/* Nav indicator for notes */
.nav-note-indicator {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 8px;
    height: 8px;
    background: #3498db;
    border-radius: 50%;
}

.question-nav-btn {
    position: relative;
}

/* ─── Highlight Responsive ──────────────────────── */
@media (max-width: 768px) {
    .highlight-palette {
        flex-wrap: wrap;
        gap: 6px;
    }

    .btn-highlight-toggle {
        padding: 3px 8px;
        font-size: 0.78em;
    }
}

/* ═══════════════════════════════════════════════
   DARK MODE – Global Overrides
   ═══════════════════════════════════════════════ */

/* Login */
html.dark .login-box h2 { color: var(--text-secondary); }
html.dark .form-group label { color: var(--text-secondary); }
html.dark .form-group input {
    border-color: var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
}
html.dark .login-info {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-right-color: #4a7cb8;
}
html.dark .login-info a { color: var(--link-color, #7db3ff); }
html.dark .login-info strong { color: #66bb6a; }
html.dark .login-signup-link { color: var(--text-muted); }
html.dark .login-signup-link a { color: var(--link-color, #7db3ff); }
html.dark .login-footer {
    border-top-color: var(--border-color);
    color: var(--text-muted);
}
html.dark .login-footer a { color: var(--link-color, #7db3ff); }

/* Home Footer */
html.dark .home-footer {
    border-top-color: var(--border-color);
    color: var(--text-muted);
}
html.dark .home-footer a { color: var(--link-color, #7db3ff); }

/* Home Cards */
html.dark .home-card { border-color: var(--border-color); }

/* User Info */
html.dark .user-info span { color: var(--text-secondary); }

/* Placeholder */
html.dark .placeholder-content {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* Sidebar */
html.dark .sidebar-header h3 { color: var(--text-heading); }
html.dark .difficulty-label { color: var(--text-secondary); }
html.dark .question-nav-btn {
    border-color: var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
}
html.dark .question-nav-btn:hover {
    border-color: #4a7cb8;
    background: var(--bg-secondary);
}
html.dark .sidebar-toggle {
    border-color: var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
}
html.dark .sidebar-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-heading);
    border-color: #4a7cb8;
}

/* Mark Filter Bar */
html.dark .mark-filter-bar {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}
html.dark .mark-filter-btn {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: var(--border-color);
}
html.dark .mark-filter-btn:hover {
    background: var(--hover-bg, #2a3f55);
    border-color: #4a6a8a;
}

/* Question Mark Selector */
html.dark .q-mark-btn {
    border-color: var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
}
html.dark .q-mark-btn:hover {
    border-color: #5a6a7a;
    background: var(--bg-secondary);
}
html.dark .q-mark-btn.selected {
    border-color: #4a8c5a;
    background: #1a3a2a;
    color: #a5d6a7;
}

/* Answer Edited Badge */
html.dark .answer-edited-badge {
    background: #3a2a1a;
    color: #ffcc80;
    border-color: #5a4a2a;
}

/* Difficulty badges – keep readable in dark */
html.dark .difficulty-A1 { background: #1a3a2a; color: #81c784; }
html.dark .difficulty-A2 { background: #1a2a3a; color: #7db3ff; }
html.dark .difficulty-B1 { background: #3a3520; color: #ffd54f; }
html.dark .difficulty-B2 { background: #3a3520; color: #ffe082; }
html.dark .difficulty-C1 { background: #3a1a1a; color: #ef9a9a; }
html.dark .difficulty-C2 { background: #3a1a1a; color: #f48fb1; }

/* Question Stats */
html.dark .question-stats {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}
html.dark .stats-header { border-bottom-color: var(--border-color); }
html.dark .stats-title { color: var(--text-heading); }
html.dark .stat-label { color: var(--text-secondary); }
html.dark .stat-value { color: var(--text-heading); }
html.dark .stat-series { color: var(--link-color, #7db3ff); }

/* Translation Panel */
html.dark .translation-panel {
    background: var(--bg-secondary);
}

/* Vocabulary */
html.dark .vocabulary-section {
    background: #2a2a1a;
    border-left-color: #ffc107;
}
html.dark .vocabulary-section h4 { color: #ffd54f; }
html.dark .vocabulary-content {
    background: rgba(255, 255, 255, 0.05);
}

/* Vocab Table */
html.dark .vocab-table tr { border-bottom-color: rgba(255, 255, 255, 0.08); }
html.dark .vocab-table tr:hover { background: rgba(255, 255, 255, 0.05); }
html.dark .vocab-table .vocab-fr { color: #7db3ff; }
html.dark .vocab-table .vocab-en,
html.dark .vocab-table .vocab-fa { color: var(--text-primary); }
html.dark .vocab-table .vocab-example { color: var(--text-muted); }

/* Score Section */
html.dark .score-section {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* EO Tâche Cards */
html.dark .tache-card {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}
html.dark .tache-number { color: var(--text-heading); }
html.dark .tache-description p { color: var(--text-primary); }
html.dark .tache-description small { color: var(--text-muted); }
html.dark .tache-stats {
    border-top-color: var(--border-color);
    color: var(--text-muted);
}

/* Subject Cards */
html.dark .subject-card {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
html.dark .subject-french { color: var(--text-primary); }
html.dark .subject-category {
    background: #1a2a3a;
    color: #4db6ac;
}
html.dark .subject-translations {
    background: var(--bg-secondary);
}
html.dark .translation { color: var(--text-secondary); }
html.dark .subject-meta {
    border-top-color: var(--border-color);
}
html.dark .answers-count { color: var(--text-muted); }
html.dark .view-btn { color: #4db6ac; }

/* Info Box */
html.dark .info-box {
    background: var(--bg-secondary);
    border-left-color: #4a7cb8;
}
html.dark .info-box h3 { color: var(--text-heading); }
html.dark .info-box p { color: var(--text-secondary); }

/* Month Subjects */
html.dark .month-subjects-section {
    border-top-color: var(--border-color);
}
html.dark .month-subjects-section h2 { color: var(--text-heading); }
html.dark .partie-tag {
    background: #1a2a3f;
    color: #7db3ff;
}
html.dark .sort-label { color: var(--text-muted); }
html.dark .sort-btn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}
html.dark .sort-btn:hover:not(.active) {
    background: var(--hover-bg, #2a3f55);
}

/* Book Filter */
html.dark .book-filter-btn.active {
    background: var(--bg-card);
    color: var(--text-heading);
}

/* EO Year Section */
html.dark .year-title {
    color: var(--text-heading);
    border-bottom-color: #4a7cb8;
}

/* Text Section */
html.dark .text-section { border-left-color: #4a7cb8; }
html.dark .co-text-section { border-left-color: #3a5a7a; }

/* Highlight Close */
html.dark .highlight-fab-close:hover {
    background: #3a1a1a;
    border-color: #e74c3c;
}

/* Timer Info Box */
html.dark .timer-info-box {
    background: var(--bg-secondary);
}
html.dark .timer-info-box h3 { color: var(--text-heading); }
html.dark .timer-info-box p { color: var(--text-muted); }
html.dark .timer-info-box .phase-badge {
    background: var(--bg-card);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Timer Overlay */
html.dark .timer-overlay-content {
    background: var(--bg-card);
}
html.dark .timer-overlay-content h2 { color: var(--text-heading); }
html.dark .timer-overlay-content p { color: var(--text-muted); }

/* Profile */
html.dark .profile-username { color: var(--text-muted); }
html.dark .profile-box .form-group label { color: var(--text-secondary); }
html.dark .profile-box .form-group input,
html.dark .profile-box .form-group select {
    border-color: var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-primary);
}
html.dark .profile-box .form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ccc' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 15px center;
}
html.dark .profile-premium-info {
    background: linear-gradient(135deg, #1a2a1a 0%, #2a3a1a 100%);
    border-color: #5a5a1a;
}
html.dark .premium-badge { color: #ffd54f; }
html.dark .profile-meta {
    border-top-color: var(--border-color);
    color: var(--text-muted);
}

/* Answered question nav buttons - dark mode */
html.dark .question-nav-btn.answered {
    background: #4a5568;
    color: #e2e8f0;
    border-color: #4a5568;
}
html.dark .question-nav-btn.answered-correct {
    background: #276749;
    color: #c6f6d5;
    border-color: #276749;
}
html.dark .question-nav-btn.answered-wrong {
    background: #9b2c2c;
    color: #fed7d7;
    border-color: #9b2c2c;
}

/* Score Section */
html.dark .score-section { border-top-color: var(--border-color); }
html.dark .score-display { color: var(--text-heading); }
html.dark .answered-count { color: var(--text-muted); }

/* Results Page */
html.dark .results-container h2 { color: var(--text-heading); }
html.dark .result-item { background: var(--bg-secondary); }
html.dark .result-label { color: var(--text-muted); }
html.dark .result-value { color: var(--text-primary); }
html.dark .result-score { background: #1a2a3f; }
html.dark .results-detail h3 { color: var(--text-heading); }
html.dark .result-question { background: var(--bg-secondary); }
html.dark .result-question.correct { background: #1a3a2a; }
html.dark .result-question.wrong { background: #3a1a1a; }
html.dark .result-question.not-answered { background: var(--bg-secondary); }
html.dark .rq-points { color: var(--text-muted); }

/* Resources Page */
html.dark .resource-section {
    background: var(--bg-card);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}
html.dark .resource-section-header {
    background: var(--bg-secondary);
    border-bottom-color: var(--border-color);
}
html.dark .resource-section-header h2 { color: var(--text-heading); }
html.dark .resource-section-body { color: var(--text-primary); }
html.dark .resource-section-body h3 {
    color: var(--text-heading);
    border-bottom-color: var(--border-color);
}
html.dark .resource-card-mini {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}
html.dark .resource-card-mini:hover {
    border-color: #4a7cb8;
    background: var(--accent-light-bg, #1a2a3f);
}
html.dark .resource-card-mini strong { color: var(--text-heading); }
html.dark .resource-card-mini span { color: var(--text-muted); }
html.dark .exam-part { border-color: var(--border-color); }
html.dark .exam-part-body {
    background: var(--bg-secondary);
}
html.dark .exam-part-body p { color: var(--text-primary); }
html.dark .exam-part-body ul li { color: var(--text-secondary); }
html.dark .level-row {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}
html.dark .level-info strong { color: var(--text-primary); }
html.dark .level-info span { color: var(--text-muted); }
html.dark .resource-note {
    background: #2a2a1a;
    border-right-color: #ffc107;
    color: var(--text-primary);
}
html.dark .tip-group h3 {
    background: var(--bg-secondary) !important;
    color: var(--text-heading);
}
html.dark .resource-item {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}
html.dark .resource-item:hover {
    border-color: #4a7cb8;
    background: var(--accent-light-bg, #1a2a3f);
}
html.dark .resource-item-content strong { color: var(--text-heading); }
html.dark .resource-item-content span { color: var(--text-muted); }

.resource-sub-list {
    padding-right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.resource-item-sub {
    padding: 10px 15px !important;
    border-style: dashed !important;
}

.resource-item-sub .resource-item-icon {
    font-size: 1.1em;
}

.resource-item-sub .resource-item-content strong {
    font-size: 0.9em;
    font-weight: 500;
}

.resource-item-channel {
    margin-bottom: 10px;
    background: #f0f4ff !important;
    border-color: #2a5298 !important;
}

html.dark .resource-item-channel {
    background: var(--accent-light-bg, #1a2a3f) !important;
    border-color: #4a7cb8 !important;
}

/* Donation */
html.dark .donation-card {
    background: var(--bg-card);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Add Vocab */
html.dark .add-vocab-panel { border-left-color: #27ae60; }
html.dark .add-vocab-panel h4 { color: #66bb6a; }

/* ============================================= */
/* Education Section                             */
/* ============================================= */

/* Education Hub (Landing Page) */
.education-hub {
    max-width: 100%;
    margin: 0 auto;
}
.education-hub-intro {
    text-align: center;
    font-size: 1.05em;
    color: #555;
    line-height: 1.9;
    margin-bottom: 30px;
}
.education-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 22px;
}
.education-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    background: white;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-top: 4px solid transparent;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    direction: ltr;
    text-align: left;
}
.education-card .edu-card-fa,
.education-card .education-card-content p {
    direction: rtl;
    text-align: right;
    unicode-bidi: isolate;
}
.education-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}
.education-card-pronunciation { border-top-color: #7b1fa2; }
.education-card-grammar       { border-top-color: #1e88e5; }
.education-card-connecteurs   { border-top-color: #00897b; }
.education-card-expressions   { border-top-color: #e65100; }
.education-card-vocabulaire   { border-top-color: #2e7d32; }
.education-card-conjugaison   { border-top-color: #5c6bc0; }
.education-card-fauxamis      { border-top-color: #c62828; }
.education-card-nombres       { border-top-color: #f9a825; }
.education-card-prepositions  { border-top-color: #3b82f6; }
.education-card-icon {
    font-size: 2.4em;
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: #f8f9fa;
}
.education-card-pronunciation .education-card-icon { background: linear-gradient(135deg, #f3e5f5, #e1bee7); }
.education-card-grammar .education-card-icon { background: linear-gradient(135deg, #e3f2fd, #bbdefb); }
.education-card-connecteurs .education-card-icon { background: linear-gradient(135deg, #e0f2f1, #b2dfdb); }
.education-card-expressions .education-card-icon { background: linear-gradient(135deg, #fff3e0, #ffccbc); }
.education-card-vocabulaire .education-card-icon { background: linear-gradient(135deg, #e8f5e9, #c8e6c9); }
.education-card-conjugaison .education-card-icon { background: linear-gradient(135deg, #e8eaf6, #c5cae9); }
.education-card-fauxamis .education-card-icon { background: linear-gradient(135deg, #ffebee, #ffcdd2); }
.education-card-nombres .education-card-icon { background: linear-gradient(135deg, #fffde7, #fff9c4); }
.education-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.education-card-content h2 {
    margin: 0;
    font-size: 1.15em;
    color: #1e3c72;
    line-height: 1.35;
}
.education-card-content p {
    margin: 0;
    color: #555;
    line-height: 1.75;
    font-size: 0.92em;
    flex: 1;
}
.education-card-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}
.education-card-topics span {
    background: #f0f4ff;
    color: #2a5298;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78em;
    border: 1px solid #d6e4ff;
    white-space: nowrap;
}
.education-card-arrow {
    position: absolute;
    top: 18px;
    left: 18px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f1f5f9;
    color: #94a3b8;
    font-size: 1rem;
    transition: all 0.3s ease;
}
.education-card:hover .education-card-arrow {
    transform: translateX(-4px);
    background: #2a5298;
    color: #fff;
}
html.dark .education-card-arrow { background: var(--bg-secondary); color: var(--text-muted); }
html.dark .education-card:hover .education-card-arrow { background: #3b82f6; color: #fff; }

/* Education Back Link */
.edu-back-link {
    display: inline-block;
    color: #2a5298;
    text-decoration: none;
    font-size: 0.9em;
    margin-bottom: 10px;
    transition: color 0.2s;
}
.edu-back-link:hover {
    color: #1e3c72;
}

/* Education Table of Contents */
.edu-toc {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}
.edu-toc-title {
    font-size: 1.1em;
    font-weight: 700;
    color: #1e3c72;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e8e8e8;
}
.edu-toc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
}
.edu-toc-item {
    display: block;
    padding: 8px 12px;
    color: #2a5298;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9em;
    transition: all 0.2s;
}
.edu-toc-item:hover {
    background: #f0f4ff;
    color: #1e3c72;
}

/* Phonetic Tables */
.edu-phonetic-table {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e8e8e8;
    margin: 15px 0;
}
.edu-phonetic-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr 2fr;
    gap: 0;
    border-bottom: 1px solid #f0f0f0;
}
.edu-phonetic-row > div {
    padding: 10px 14px;
    font-size: 0.9em;
    line-height: 1.6;
}
.edu-phonetic-header {
    background: #1e3c72;
    color: white;
    font-weight: 600;
}
.edu-phonetic-header > div {
    font-size: 0.85em;
}
.edu-phonetic-row:not(.edu-phonetic-header):hover {
    background: #f8f9ff;
}
.edu-nasal-highlight {
    background: #faf5ff;
}

/* Grammar Tables */
.edu-grammar-table {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e8e8e8;
    margin: 15px 0;
}
.edu-grammar-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0;
    border-bottom: 1px solid #f0f0f0;
}
.edu-grammar-row > div {
    padding: 10px 14px;
    font-size: 0.9em;
    line-height: 1.6;
}
.edu-grammar-header {
    background: #1e3c72;
    color: white;
    font-weight: 600;
}
.edu-grammar-header > div {
    font-size: 0.85em;
}
.edu-grammar-row:not(.edu-grammar-header):hover {
    background: #f8f9ff;
}

/* French Words Highlight */
.fr-word {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: ltr;
    unicode-bidi: isolate;
    color: #1e3c72;
    font-weight: 500;
}

/* Rule Boxes */
.edu-rule-box {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin: 15px 0;
    border-right: 4px solid #2a5298;
}
.edu-rule-box h3 {
    color: #1e3c72;
    margin: 0 0 12px;
    font-size: 1em;
}
.edu-rule-box p {
    margin-bottom: 10px;
}
.edu-rule-box ul {
    padding-right: 20px;
    margin-bottom: 10px;
}
.edu-rule-box ul li {
    margin-bottom: 8px;
    line-height: 1.7;
}

/* Liaison Box */
.edu-liaison-box {
    border-right-color: #27ae60;
    background: #f0faf0;
}
.edu-liaison-rule {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #d0d0d0;
}
.edu-liaison-rule:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.edu-liaison-label {
    font-weight: 600;
    color: #1e3c72;
    margin-bottom: 8px;
    font-size: 0.95em;
}
.edu-liaison-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.edu-liaison-examples > span {
    background: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9em;
    border: 1px solid #e0e0e0;
}

/* Examples Grid */
.edu-examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin: 10px 0;
}
.edu-example {
    background: #f8f9fa;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9em;
    line-height: 1.6;
    border: 1px solid #e8e8e8;
}

/* Comparison Box */
.edu-comparison-box {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 15px 0;
}
.edu-comparison-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 18px;
    border: 1px solid #e8e8e8;
}
.edu-comparison-item h4 {
    color: #1e3c72;
    margin: 0 0 8px;
    font-size: 1em;
}
.edu-comparison-item p {
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #666;
}

/* Formula Box */
.edu-formula {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    text-align: center;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 1.05em;
    margin: 15px 0;
    letter-spacing: 0.3px;
}

/* ============================================= */
/* Education Section - Dark Mode                 */
/* ============================================= */
html.dark .education-hub-intro { color: var(--text-secondary); }
html.dark .education-card {
    background: var(--bg-card);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
html.dark .education-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}
html.dark .education-card-icon {
    background: var(--bg-secondary);
}
html.dark .education-card-pronunciation .education-card-icon { background: linear-gradient(135deg, #2d1b3d, #3d1f5c); }
html.dark .education-card-grammar .education-card-icon { background: linear-gradient(135deg, #1a2a3f, #1e3a5f); }
html.dark .education-card-connecteurs .education-card-icon { background: linear-gradient(135deg, #1a2f2d, #1e3d3a); }
html.dark .education-card-expressions .education-card-icon { background: linear-gradient(135deg, #2d1f1a, #3d2a1e); }
html.dark .education-card-vocabulaire .education-card-icon { background: linear-gradient(135deg, #1a2d1b, #1e3d1f); }
html.dark .education-card-conjugaison .education-card-icon { background: linear-gradient(135deg, #1e1f3d, #252a5c); }
html.dark .education-card-fauxamis .education-card-icon { background: linear-gradient(135deg, #3d1a1a, #5c1e1e); }
html.dark .education-card-nombres .education-card-icon { background: linear-gradient(135deg, #2d2d1a, #3d3d1e); }
html.dark .education-card-content h2 { color: var(--text-heading); }
html.dark .education-card-content p { color: var(--text-secondary); }
html.dark .education-card-topics span {
    background: var(--bg-secondary);
    color: #7db3ff;
    border-color: var(--border-color);
}
html.dark .education-card-arrow { color: var(--text-muted); }
html.dark .education-card:hover .education-card-arrow { color: #7db3ff; }

html.dark .edu-back-link { color: #7db3ff; }
html.dark .edu-back-link:hover { color: #a0ccff; }

html.dark .edu-toc {
    background: var(--bg-card);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}
html.dark .edu-toc-title {
    color: var(--text-heading);
    border-bottom-color: var(--border-color);
}
html.dark .edu-toc-item { color: #7db3ff; }
html.dark .edu-toc-item:hover {
    background: var(--bg-secondary);
    color: #a0ccff;
}

html.dark .edu-phonetic-table,
html.dark .edu-grammar-table {
    border-color: var(--border-color);
}
html.dark .edu-phonetic-row,
html.dark .edu-grammar-row {
    border-bottom-color: var(--border-color);
}
html.dark .edu-phonetic-header,
html.dark .edu-grammar-header {
    background: #1a2a42;
}
html.dark .edu-phonetic-row:not(.edu-phonetic-header):hover,
html.dark .edu-grammar-row:not(.edu-grammar-header):hover {
    background: var(--bg-secondary);
}
html.dark .edu-nasal-highlight {
    background: #1f1a2a;
}
html.dark .edu-phonetic-row > div,
html.dark .edu-grammar-row > div {
    color: var(--text-primary);
}

html.dark .fr-word { color: #7db3ff; }

html.dark .edu-rule-box {
    background: var(--bg-secondary);
    border-right-color: #4a7cb8;
}
html.dark .edu-rule-box h3 { color: var(--text-heading); }
html.dark .edu-rule-box p,
html.dark .edu-rule-box ul li { color: var(--text-primary); }

html.dark .edu-liaison-box {
    border-right-color: #27ae60;
    background: #1a2a1f;
}
html.dark .edu-liaison-label { color: var(--text-heading); }
html.dark .edu-liaison-examples > span {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}
html.dark .edu-liaison-rule {
    border-bottom-color: var(--border-color);
}

html.dark .edu-example {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

html.dark .edu-comparison-item {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}
html.dark .edu-comparison-item h4 { color: var(--text-heading); }
html.dark .edu-comparison-item p { color: var(--text-secondary); }

html.dark .edu-formula {
    background: linear-gradient(135deg, #1a2a42, #2a3a52);
}

/* Education Topics Grid */
.edu-topics-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
}
.edu-topics-group {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}
.edu-topics-group-title {
    font-size: 1.1em;
    font-weight: 700;
    color: #1e3c72;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e8e8e8;
}
.edu-topics-group-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.edu-topic-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 18px 12px;
    border-radius: 12px;
    background: #f8f9fa;
    border: 2px solid #e8e8e8;
    text-decoration: none;
    color: inherit;
    transition: all 0.25s ease;
    gap: 6px;
}
.edu-topic-card:hover {
    border-color: #2a5298;
    background: #f0f4ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(42, 82, 152, 0.15);
}
.edu-topic-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    font-weight: 700;
    font-size: 0.85em;
    flex-shrink: 0;
}
.edu-topic-title {
    font-weight: 600;
    color: #1e3c72;
    font-size: 0.92em;
    line-height: 1.4;
}
.edu-topic-subtitle {
    font-size: 0.78em;
    color: #888;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: ltr;
}

/* Topic Navigation (back button on detail pages) */
.edu-topic-nav {
    text-align: center;
    margin: 30px 0 10px;
}
.edu-topic-nav-btn {
    display: inline-block;
    padding: 10px 24px;
    background: #f0f4ff;
    color: #2a5298;
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 500;
    border: 1px solid #d6e4ff;
    transition: all 0.2s;
}
.edu-topic-nav-btn:hover {
    background: #2a5298;
    color: white;
}

/* Education Topics Grid - Dark Mode */
html.dark .edu-topics-group {
    background: var(--bg-card);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}
html.dark .edu-topics-group-title {
    color: var(--text-heading);
    border-bottom-color: var(--border-color);
}
html.dark .edu-topic-card {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}
html.dark .edu-topic-card:hover {
    border-color: #4a7cb8;
    background: var(--accent-light-bg, #1a2a3f);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
html.dark .edu-topic-num {
    background: linear-gradient(135deg, #1a2a42, #2a4a72);
}
html.dark .edu-topic-title { color: var(--text-heading); }
html.dark .edu-topic-subtitle { color: var(--text-muted); }
html.dark .edu-topic-nav-btn {
    background: var(--bg-secondary);
    color: #7db3ff;
    border-color: var(--border-color);
}
html.dark .edu-topic-nav-btn:hover {
    background: #2a4a72;
    color: white;
}

/* Cheatsheet Banner */
.edu-cheatsheet-banner {
    display: flex;
    align-items: center;
    gap: 15px;
    background: linear-gradient(135deg, #1e3c72, #2a5298, #1e88e5);
    color: white;
    border-radius: 14px;
    padding: 18px 25px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(30, 60, 114, 0.3);
}
.edu-cheatsheet-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(30, 60, 114, 0.4);
}
.edu-cheatsheet-icon {
    font-size: 2em;
    flex-shrink: 0;
}
.edu-cheatsheet-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.edu-cheatsheet-text strong {
    font-size: 1.1em;
}
.edu-cheatsheet-text span {
    font-size: 0.85em;
    opacity: 0.85;
}

/* Cheatsheet Page */
.cheatsheet {
    max-width: 1000px;
    margin: 0 auto;
}
.cs-group {
    margin-bottom: 30px;
}
.cs-group-title {
    font-size: 1.1em;
    font-weight: 700;
    color: #1e3c72;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
}
.cs-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.cs-cards-wide {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.cs-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    border: 1px solid #e8e8e8;
    border-top: 4px solid #2a5298;
}
.cs-card-header {
    padding: 10px 14px;
    font-weight: 700;
    font-size: 0.9em;
    color: #1e3c72;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cs-card-header span {
    font-weight: 400;
    font-size: 0.85em;
    color: #888;
}
.cs-card-formula {
    padding: 12px 14px;
    font-size: 0.92em;
    font-weight: 600;
    color: #333;
    background: #fffde7;
    border-bottom: 1px solid #f0f0f0;
    line-height: 1.6;
    direction: ltr;
    text-align: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.cs-card-formula small {
    font-weight: 400;
    color: #888;
    font-size: 0.82em;
}
.cs-card-detail {
    padding: 10px 14px;
    font-size: 0.85em;
    line-height: 1.7;
}
.cs-endings {
    margin-bottom: 6px;
}
.cs-endings span {
    display: block;
    color: #555;
    font-size: 0.9em;
    direction: ltr;
    text-align: right;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.cs-example {
    color: #1e3c72;
    font-size: 0.9em;
    padding-top: 4px;
    border-top: 1px dashed #e8e8e8;
    direction: ltr;
    text-align: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Card color variants */
.cs-present { border-top-color: #2a5298; }
.cs-pc { border-top-color: #1565c0; }
.cs-imp { border-top-color: #00838f; }
.cs-pqp { border-top-color: #00695c; }
.cs-ps { border-top-color: #4e342e; }
.cs-fp { border-top-color: #7cb342; }
.cs-fs { border-top-color: #43a047; }
.cs-fa { border-top-color: #2e7d32; }
.cs-cond { border-top-color: #f57c00; }
.cs-condp { border-top-color: #e65100; }
.cs-subj { border-top-color: #8e24aa; }
.cs-subjp { border-top-color: #6a1b9a; }
.cs-imper { border-top-color: #c62828; }
.cs-gerondif { border-top-color: #ad1457; }
.cs-si1 { border-top-color: #43a047; }
.cs-si2 { border-top-color: #f57c00; }
.cs-si3 { border-top-color: #c62828; }

/* Pronoun order boxes */
.cs-pronoun-box {
    display: inline-block;
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.85em;
    margin: 2px;
    border: 1px solid #bbdefb;
}

/* DR MRS VANDERTRAMP grid */
.cs-etre-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 6px;
}
.cs-etre-grid > span {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    border: 1px solid #e8e8e8;
    direction: ltr;
    text-align: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Cheatsheet Dark Mode */
html.dark .edu-cheatsheet-banner {
    background: linear-gradient(135deg, #1a2a42, #2a3a52, #1a4a72);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}
html.dark .cs-group-title {
    color: var(--text-heading);
    border-bottom-color: var(--border-color);
}
html.dark .cs-card {
    background: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
html.dark .cs-card-header {
    background: var(--bg-secondary);
    color: var(--text-heading);
}
html.dark .cs-card-header span { color: var(--text-muted); }
html.dark .cs-card-formula {
    background: #2a2a1a;
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}
html.dark .cs-card-formula small { color: var(--text-muted); }
html.dark .cs-card-detail { color: var(--text-primary); }
html.dark .cs-endings span { color: var(--text-secondary); }
html.dark .cs-example {
    color: #7db3ff;
    border-top-color: var(--border-color);
}
html.dark .cs-pronoun-box {
    background: #1a2a3f;
    color: #7db3ff;
    border-color: #2a4a6f;
}
html.dark .cs-etre-grid > span {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

/* Education Section - Responsive */
@media (max-width: 768px) {
    .education-card {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    .education-card-arrow {
        display: none;
    }
    .education-card-topics {
        justify-content: center;
    }
    .edu-toc-grid {
        grid-template-columns: 1fr;
    }
    .edu-phonetic-row {
        grid-template-columns: 1fr 1fr;
        font-size: 0.85em;
    }
    .edu-phonetic-row > div:nth-child(3),
    .edu-phonetic-row > div:nth-child(4) {
        grid-column: span 1;
    }
    .edu-grammar-row {
        font-size: 0.85em;
    }
    .edu-comparison-box {
        grid-template-columns: 1fr;
    }
    .edu-examples-grid {
        grid-template-columns: 1fr;
    }
    .edu-liaison-examples {
        flex-direction: column;
    }
    .edu-topics-group-cards {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }
    .edu-topic-card {
        padding: 14px 8px;
    }
    .cs-cards, .cs-cards-wide {
        grid-template-columns: 1fr;
    }
    .cs-etre-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .edu-cheatsheet-banner {
        padding: 14px 18px;
    }
}
/* ═══════════════════════════════════════════════════════════════════
   DARK MODE SAFETY-NET FOR INLINE STYLES
   These override common hardcoded inline-style patterns in templates
   so dark mode stays readable even where inline styles weren't refactored.
   ═══════════════════════════════════════════════════════════════════ */
html.dark [style*="background:#fff"]:not([style*="background:#fff3"]):not([style*="background:#fff8"]):not([style*="background:#fff5"]),
html.dark [style*="background:#FFF"],
html.dark [style*="background:white"],
html.dark [style*="background: white"],
html.dark [style*="background: #fff "],
html.dark [style*="background: #ffffff"] {
    background: var(--bg-card) !important;
}
html.dark [style*="background:#f5f5f5"],
html.dark [style*="background: #f5f5f5"],
html.dark [style*="background:#f8f9fa"],
html.dark [style*="background: #f8f9fa"],
html.dark [style*="background:#f0f4ff"],
html.dark [style*="background: #f0f4ff"],
html.dark [style*="background:#eee"],
html.dark [style*="background: #eee"] {
    background: var(--bg-secondary) !important;
}
html.dark [style*="color:#333"],
html.dark [style*="color: #333"],
html.dark [style*="color:#444"],
html.dark [style*="color: #444"],
html.dark [style*="color:#555"],
html.dark [style*="color: #555"],
html.dark [style*="color:#666"],
html.dark [style*="color: #666"],
html.dark [style*="color:#2c3e50"],
html.dark [style*="color: #2c3e50"] {
    color: var(--text-primary) !important;
}
html.dark [style*="color:#888"],
html.dark [style*="color: #888"],
html.dark [style*="color:#999"],
html.dark [style*="color: #999"],
html.dark [style*="color:#7f8c8d"],
html.dark [style*="color:#94a3b8"],
html.dark [style*="color:#9ca3af"],
html.dark [style*="color:#64748b"],
html.dark [style*="color:#718096"] {
    color: var(--text-muted) !important;
}
html.dark [style*="color:#1e3c72"],
html.dark [style*="color: #1e3c72"],
html.dark [style*="color:#2a5298"],
html.dark [style*="color: #2a5298"] {
    color: var(--text-heading) !important;
}
html.dark [style*="border:1px solid #e0e0e0"],
html.dark [style*="border:1px solid #e2e8f0"],
html.dark [style*="border:1px solid #eee"],
html.dark [style*="border: 1px solid #e0e0e0"],
html.dark [style*="border: 1px solid #eee"] {
    border-color: var(--border-color) !important;
}

/* Extended safety-net — additional light-bg patterns commonly used inline */
html.dark [style*="background:#edf2f7"],
html.dark [style*="background: #edf2f7"],
html.dark [style*="background:#f5f7fa"],
html.dark [style*="background: #f5f7fa"],
html.dark [style*="background:#f8fafc"],
html.dark [style*="background: #f8fafc"],
html.dark [style*="background:#f0fff4"],
html.dark [style*="background: #f0fff4"],
html.dark [style*="background:#eff6ff"],
html.dark [style*="background: #eff6ff"],
html.dark [style*="background:#e8f0fe"],
html.dark [style*="background: #e8f0fe"],
html.dark [style*="background:#fafbfc"],
html.dark [style*="background: #fafbfc"],
html.dark [style*="background:#fafafa"],
html.dark [style*="background: #fafafa"],
html.dark [style*="background:#f0f0f0"],
html.dark [style*="background: #f0f0f0"] {
    background: var(--bg-secondary) !important;
}
html.dark [style*="background:#fef2f2"],
html.dark [style*="background: #fef2f2"],
html.dark [style*="background:#fff5f5"],
html.dark [style*="background: #fff5f5"] {
    background: rgba(220, 53, 69, 0.12) !important;
}
html.dark [style*="background:#fff3e0"],
html.dark [style*="background: #fff3e0"],
html.dark [style*="background:#fff8e1"],
html.dark [style*="background: #fff8e1"],
html.dark [style*="background:#fff5f7"],
html.dark [style*="background: #fff5f7"] {
    background: #2a2418 !important;
}
html.dark [style*="background:#e8f5e9"],
html.dark [style*="background: #e8f5e9"],
html.dark [style*="background:#dcfce7"],
html.dark [style*="background: #dcfce7"] {
    background: rgba(46, 125, 50, 0.18) !important;
}
html.dark [style*="color:#7b341e"],
html.dark [style*="color: #7b341e"],
html.dark [style*="color:#7f1d1d"],
html.dark [style*="color: #7f1d1d"] {
    color: #ffb4a8 !important;
}
html.dark [style*="color:#1a365d"],
html.dark [style*="color: #1a365d"],
html.dark [style*="color:#22543d"],
html.dark [style*="color: #22543d"] {
    color: var(--text-heading) !important;
}

/* ═══ Global dark overrides for common embedded classes (.note/.example/.legend/.skeleton) ═══
   These are defined inside <style> blocks in many EE/EO/education templates with light backgrounds.
   We override at body level with !important since the inline <style> rules also have low specificity. */
html.dark .note {
    background: #2a2418 !important;
    color: var(--text-primary);
    border-right-color: #dd6b20 !important;
}
html.dark .example {
    background: rgba(56, 161, 105, 0.12) !important;
    color: var(--text-primary);
    border-right-color: #48bb78 !important;
}
html.dark .legend {
    background: var(--bg-secondary) !important;
    color: var(--text-primary);
}
html.dark .skeleton {
    background: #0f1620 !important;
    color: #e2e8f0;
    border: 1px solid var(--border-color);
}
html.dark .definition {
    background: var(--bg-secondary) !important;
    color: var(--text-primary);
}
html.dark .tip {
    background: rgba(56, 161, 105, 0.12) !important;
    color: var(--text-primary);
}
html.dark .warning {
    background: #3a2a1a !important;
    color: #ffb74d;
}
html.dark pre,
html.dark code {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════
   GLOBAL DARK OVERRIDES FOR EMBEDDED <style> BLOCKS IN EE/EO/EDU TEMPLATES
   These templates each define their own page classes (.root, .slot, .stat-card,
   .premium-gate, table, th/td, etc.) inside a per-page <style> block. We override
   them globally with html.dark to keep dark mode consistent across the site.
   ═══════════════════════════════════════════════════════════════════ */

/* Page roots (used by ee/eo structure pages) */
html.dark .root,
html.dark .t1-root,
html.dark .t2-root,
html.dark .t3-root,
html.dark .corps-root,
html.dark .resume-root,
html.dark .fa-root,
html.dark .eo-root {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* Headings inside roots — keep tinted but readable on dark */
html.dark .root h1,
html.dark .t1-root h1,
html.dark .t2-root h1,
html.dark .t3-root h1,
html.dark .corps-root h1,
html.dark .resume-root h1,
html.dark .eo-root h1,
html.dark .root h3, html.dark .root h4,
html.dark .t1-root h3, html.dark .t1-root h4,
html.dark .t2-root h3, html.dark .t2-root h4,
html.dark .t3-root h3, html.dark .t3-root h4,
html.dark .corps-root h3, html.dark .corps-root h4,
html.dark .resume-root h3, html.dark .resume-root h4,
html.dark .eo-root h3, html.dark .eo-root h4 {
    color: var(--text-heading) !important;
    border-color: var(--border-color);
}

/* Tables inside templates */
html.dark .root table, html.dark .t1-root table, html.dark .t2-root table,
html.dark .t3-root table, html.dark .corps-root table,
html.dark .resume-root table, html.dark .eo-root table,
html.dark .root th, html.dark .t1-root th, html.dark .t2-root th,
html.dark .t3-root th, html.dark .corps-root th,
html.dark .resume-root th, html.dark .eo-root th {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
html.dark .root td, html.dark .t1-root td, html.dark .t2-root td,
html.dark .t3-root td, html.dark .corps-root td,
html.dark .resume-root td, html.dark .eo-root td {
    color: var(--text-primary);
    border-bottom-color: var(--border-color) !important;
}
html.dark .root td.ltr,
html.dark .t1-root td.ltr,
html.dark .t2-root td.ltr,
html.dark .corps-root td.ltr,
html.dark .resume-root td.ltr,
html.dark .eo-root td.ltr {
    color: #7db3ff !important;
}

/* example-full / strategy / premium-gate — special panels */
html.dark .example-full {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: #8e44ad !important;
}
html.dark .premium-gate {
    background: #2a2418 !important;
    color: #ffb74d !important;
    border-color: #f6ad55 !important;
}
html.dark .premium-gate a {
    background: #dd6b20 !important;
    color: #fff !important;
}

/* Compare table good/bad cells */
html.dark .compare-table td.good {
    background: rgba(46, 125, 50, 0.18) !important;
    color: #a5d6a7 !important;
}
html.dark .compare-table td.bad {
    background: rgba(220, 53, 69, 0.15) !important;
    color: #ff8a80 !important;
}

/* Stat cards (used in ee/ee tache pages and reports) */
html.dark .stat-card {
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

/* Generic .stat-card without color modifier — when used as plain panel */
html.dark .stat-card:not(.c1):not(.c2):not(.c3):not(.accent):not(.red):not(.green):not(.blue):not(.orange):not(.purple) {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Report container (activity_report, section_report, ee_report, eo_report) */
html.dark .report-container {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
html.dark .report-title { color: var(--text-heading) !important; }

/* Period tabs (reports) */
html.dark .period-tab {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
html.dark .period-tab:hover { background: var(--hover-bg) !important; }
html.dark .period-tab.active {
    background: var(--accent-light-bg) !important;
    color: var(--text-heading) !important;
}

/* Subject preview, scenarios, choice cards (eo/ee) */
html.dark .subject-preview,
html.dark .question-detail-card,
html.dark .question-content,
html.dark .scenario-card,
html.dark .cat-detail-card,
html.dark .cat-detail-desc,
html.dark .vocab-item,
html.dark .t1-choice-card,
html.dark .t3-choice-card,
html.dark .so-card,
html.dark .pv-stat-card,
html.dark .pv-column-card,
html.dark .cs-list,
html.dark .cs-count {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

html.dark .subject-preview-header,
html.dark .preview-toggle,
html.dark .subject-preview-content,
html.dark .question-title,
html.dark .scenarios-title,
html.dark .cat-detail-titles h2,
html.dark .t1-choice-title,
html.dark .t3-choice-title,
html.dark .t1-choice-card h2,
html.dark .t3-choice-card h2,
html.dark .so-header h1,
html.dark .so-french,
html.dark .so-toggle,
html.dark .pv-header h2,
html.dark .pv-stat-value,
html.dark .cs-topic,
html.dark .cs-fa {
    color: var(--text-primary) !important;
}

html.dark .preview-doc strong {
    color: var(--text-heading) !important;
}

/* Tab buttons (used across many templates) */
html.dark .tab-btn,
html.dark .scoring-tab,
html.dark .exam-tab {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
html.dark .tab-btn:hover,
html.dark .scoring-tab:hover {
    background: var(--hover-bg) !important;
    color: var(--text-heading) !important;
}
html.dark .tab-btn.active,
html.dark .scoring-tab.active {
    background: var(--accent-light-bg) !important;
    color: var(--text-heading) !important;
}

/* Calendar (calendar.html) */
html.dark .tc {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .tc-val { color: var(--text-heading) !important; }
html.dark .tc.goal .tc-val { color: #66bb6a !important; }
html.dark .cal-settings input,
html.dark .cal-settings select,
html.dark .cal-settings textarea {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Tips page (ee/tips.html) */
html.dark .tips-section {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .tips-section-body h3 { color: var(--text-heading) !important; }
html.dark .tips-callout-green { background: rgba(46, 125, 50, 0.15) !important; color: var(--text-primary) !important; }
html.dark .tips-callout-orange { background: #2a2418 !important; color: #ffb74d !important; }
html.dark .tips-callout-blue { background: var(--accent-light-bg) !important; color: var(--text-primary) !important; }

/* Exam session (ee/exam_session.html) */
html.dark .exam-main,
html.dark .exam-pane {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
html.dark .exam-pane h3 { color: var(--text-heading) !important; }

/* Audio/TTS buttons in eo subject pages */
html.dark .btn-tts:hover,
html.dark .btn-tts-section:hover,
html.dark .btn-tts-t1:hover,
html.dark .btn-tts-natural-t1:hover {
    background: var(--accent-light-bg) !important;
}
html.dark .natural-audio-bar {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Scoring page */
html.dark .scoring-table tbody tr:hover td {
    background: var(--hover-bg) !important;
}
html.dark .scoring-table tfoot td {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* head-bar (ee/tache3_subjects_persian) */
html.dark .head-bar {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .head-bar h1 { color: var(--text-heading) !important; }
html.dark .subject-id a { color: var(--link-color) !important; }

/* Translation buttons (eo/ee subject pages) */
html.dark .trans-btn {
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
html.dark .trans-btn:hover {
    background: var(--hover-bg) !important;
    border-color: var(--text-muted) !important;
}
html.dark .trans-btn.active {
    background: rgba(46, 125, 50, 0.18) !important;
    color: #a5d6a7 !important;
    border-color: #4a7c59 !important;
}

/* Subject preview blue panel */
html.dark .subject-preview {
    background: var(--accent-light-bg) !important;
    border-left-color: #4a7cb8 !important;
    color: var(--text-primary);
}
html.dark .subject-preview-header {
    background: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-primary) !important;
}
html.dark .subject-preview-header:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}
html.dark .subject-preview-content {
    color: var(--text-primary) !important;
    border-top-color: var(--border-color) !important;
}

/* Stats / experiences pages */
html.dark .stats-card,
html.dark .stats-section,
html.dark .experience-card,
html.dark .exp-card,
html.dark .saved-vocab-item,
html.dark .vocab-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Flashcard detail pages */
html.dark .flashcard-detail,
html.dark .argument-detail,
html.dark .idea-detail {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Generic backgrounds: any element with `background: white` defined inline-style or in <style> */
html.dark .root table { background: var(--bg-card) !important; }
html.dark .t1-root table,
html.dark .t2-root table,
html.dark .t3-root table,
html.dark .corps-root table,
html.dark .resume-root table,
html.dark .eo-root table { background: var(--bg-card) !important; }

/* ═══ More page-specific dark overrides ═══ */
/* Saved vocabulary page */
html.dark .vocabulary-page,
html.dark .add-vocab-section,
html.dark .add-form-grid,
html.dark .lookup-status,
html.dark .duplicate-warning,
html.dark .stats-row,
html.dark .stat-number,
html.dark .stat-label {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
html.dark .page-header,
html.dark .stats-header,
html.dark .stats-title { color: var(--text-heading) !important; }

/* Stats page */
html.dark .stats-container,
html.dark .stats-section,
html.dark .stats-cards,
html.dark .stats-card,
html.dark .traffic-grid,
html.dark .traffic-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .stats-section-title,
html.dark .stats-card-value,
html.dark .traffic-card-label { color: var(--text-heading) !important; }
html.dark .stats-card-label,
html.dark .stats-subtitle { color: var(--text-muted) !important; }

/* Experiences */
html.dark .exp-page,
html.dark .exp-layout,
html.dark .filters,
html.dark .exp-card,
html.dark .exp-top,
html.dark .scores,
html.dark .score-box,
html.dark .exp-snippet,
html.dark .active-filters {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .chip,
html.dark .filter-chip {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

/* Admin page_views */
html.dark .pv-container,
html.dark .pv-stats,
html.dark .pv-columns,
html.dark .pv-rank-table,
html.dark .pv-feed-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .pv-stat-label,
html.dark .pv-rank-num,
html.dark .pv-rank-path,
html.dark .pv-rank-count { color: var(--text-secondary) !important; }
html.dark .pv-header-actions { color: var(--text-primary) !important; }

/* Form inputs in <style> blocks */
html.dark input[type="text"],
html.dark input[type="number"],
html.dark input[type="email"],
html.dark input[type="password"],
html.dark input[type="date"],
html.dark textarea,
html.dark select {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}
html.dark .form-group label { color: var(--text-secondary); }

/* Scoring page extras */
html.dark .level-group-a1,
html.dark .level-group-a2,
html.dark .level-group-b1,
html.dark .level-group-b2,
html.dark .level-group-c1,
html.dark .level-group-c2 {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Calendar settings */
html.dark .cal-settings,
html.dark .cal-board,
html.dark .cal-cell,
html.dark .cal-stat {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Cheatsheet */
html.dark .cs-row { color: var(--text-primary) !important; }
html.dark .cs-row:hover { background: var(--hover-bg) !important; }

/* So options page */
html.dark .so-card {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}
html.dark .so-toggle input[type="checkbox"] { accent-color: var(--text-heading); }

/* ═══ ee/subject.html specific overrides ═══ */
html.dark .template-overlay,
html.dark .writing-timer,
html.dark .wt-mode-toggle,
html.dark .translation-toggle-bar,
html.dark .roadmap-section,
html.dark .roadmap-content,
html.dark .template-roadmap-text {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .wt-preset-btn,
html.dark .translation-toggle-btn,
html.dark .roadmap-lang-btn,
html.dark .tmpl-roadmap-lang {
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
html.dark .wt-preset-btn:hover,
html.dark .translation-toggle-btn:hover,
html.dark .roadmap-lang-btn:hover,
html.dark .tmpl-roadmap-lang:hover {
    background: var(--hover-bg) !important;
    color: var(--text-heading) !important;
}
html.dark .roadmap-header,
html.dark .template-roadmap-header { color: var(--text-heading) !important; }
html.dark .wt-time { color: var(--text-heading) !important; }

/* ═══ ee/tips.html overrides ═══ */
html.dark .tips-section,
html.dark .tips-band,
html.dark .tips-col,
html.dark .tips-example-card,
html.dark .tips-example-fr,
html.dark .tips-example,
html.dark .tips-checklist li,
html.dark .tips-credits-link {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .tips-callout-green { background: rgba(46, 125, 50, 0.15) !important; color: var(--text-primary) !important; }
html.dark .tips-callout-orange { background: #2a2418 !important; color: #ffb74d !important; }
html.dark .tips-callout-blue { background: var(--accent-light-bg) !important; color: var(--text-primary) !important; }
html.dark .tips-callout-red { background: rgba(220, 53, 69, 0.15) !important; color: #ff8a80 !important; }
html.dark .tips-badge-simple { background: var(--bg-secondary) !important; color: var(--text-secondary) !important; }
html.dark .tips-badge-complex { background: var(--accent-light-bg) !important; color: #7db3ff !important; }
html.dark .tips-structures li { background: var(--bg-secondary) !important; color: var(--text-primary) !important; }
html.dark .tips-section code,
html.dark .tips-structures code { background: var(--bg-secondary) !important; color: var(--text-heading) !important; }
html.dark .tips-band-level { background: #2a2418 !important; color: #ffb74d !important; }
html.dark .tips-example-card.tips-bad { background: rgba(220, 53, 69, 0.12) !important; }
html.dark .tips-example-card.tips-best { background: rgba(155, 89, 182, 0.15) !important; }
html.dark .tips-tag-ok { background: rgba(46, 125, 50, 0.2) !important; color: #a5d6a7 !important; }
html.dark .tips-tag-no { background: rgba(220, 53, 69, 0.18) !important; color: #ff8a80 !important; }
html.dark .tips-tag-mid { background: #2a2418 !important; color: #ffb74d !important; }
html.dark .tips-section-body h3 { color: var(--text-heading) !important; }

/* ═══ calendar.html overrides ═══ */
html.dark .day-panel,
html.dark .cal-arrow {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
html.dark .cal-arrow:hover { background: var(--hover-bg) !important; color: var(--text-heading) !important; }
html.dark .cal-cell {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .cal-cell .c-num { color: var(--text-primary) !important; }
html.dark .cal-cell.today { color: var(--text-heading) !important; border-color: var(--text-heading); }
html.dark .cal-cell.selected { background: var(--accent-light-bg) !important; color: var(--text-heading) !important; }
html.dark .cal-cell.lv1 { background: rgba(46, 125, 50, 0.15) !important; }
html.dark .cal-cell.lv2 { background: rgba(46, 125, 50, 0.25) !important; }
html.dark .cal-cell.lv3 { background: rgba(46, 125, 50, 0.35) !important; }
html.dark .cal-cell.lv4 { background: rgba(46, 125, 50, 0.5) !important; }
html.dark .cal-cell.lv4 .c-num { color: #c8e6c9 !important; }
html.dark .cal-header h2 { color: var(--text-heading) !important; }
html.dark .dp-title,
html.dark .dp-section-title,
html.dark .dp-sess-time { color: var(--text-heading) !important; }
html.dark .dp-total-badge { background: var(--accent-light-bg) !important; color: var(--text-heading) !important; }
html.dark .dp-close:hover { color: var(--text-primary) !important; }
html.dark .dp-sess { background: var(--bg-secondary) !important; color: var(--text-primary) !important; }
html.dark .pt-check { color: #66bb6a !important; }
html.dark .s-saved { color: #66bb6a !important; }

/* ═══ eo/subject formality + audio bars ═══ */
html.dark .formality-formel { background: var(--accent-light-bg) !important; color: #7db3ff !important; }
html.dark .formality-informel { background: #2a2418 !important; color: #ffb74d !important; }
html.dark .natural-audio-bar { background: rgba(16, 185, 129, 0.1) !important; color: var(--text-secondary) !important; }
html.dark .natural-audio-bar .audio-progress-wrap { background: var(--bg-secondary) !important; }
html.dark .natural-audio-bar .audio-highlight-toggle:hover { background: rgba(16, 185, 129, 0.15) !important; }
html.dark .btn-tts-natural-full:hover,
html.dark .btn-tts-natural:hover { background: rgba(16, 185, 129, 0.15) !important; }
html.dark .btn-tts-download-full:hover { background: var(--accent-light-bg) !important; color: #7db3ff !important; }
html.dark .mono-section.tts-active { background: var(--accent-light-bg) !important; }
html.dark .mono-para .tts-sentence.tts-reading { background: rgba(46, 125, 50, 0.4) !important; color: #c8e6c9 !important; }

/* ═══ structure templates extras ═══ */
html.dark .bank,
html.dark .topic-card,
html.dark .q-block {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color);
}
html.dark .bank-title { color: var(--text-heading) !important; }
html.dark .topic-name { color: var(--text-heading) !important; }
html.dark .topic-badge { background: var(--accent-light-bg) !important; color: #7db3ff !important; }
html.dark .q-count { background: rgba(155, 89, 182, 0.2) !important; color: #ce93d8 !important; }
html.dark td.slot-name { background: #2a2418 !important; color: #ffb74d !important; }

/* ═══ ee/category_detail typing/vocab ═══ */
html.dark .cat-detail-card,
html.dark .typing-area,
html.dark .typing-words,
html.dark .typing-options,
html.dark .typing-live-preview {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .cat-detail-desc,
html.dark .vocab-item,
html.dark .typing-words,
html.dark .typing-options { background: var(--bg-secondary) !important; }
html.dark .vocab-item:hover { background: var(--hover-bg) !important; }
html.dark .vocab-item.favorited { background: #2a2418 !important; color: #ffd54f !important; }
html.dark .vocab-fr,
html.dark .typing-stat-val { color: var(--text-primary) !important; }
html.dark .typing-option { color: var(--text-secondary) !important; }
html.dark .typing-option select { background: var(--bg-input) !important; color: var(--text-primary) !important; }
html.dark .typing-word.correct { color: #66bb6a !important; }
html.dark .typing-live-preview .tch-ok { color: #66bb6a !important; }
html.dark .vocab-divider::before,
html.dark .vocab-divider::after { background: var(--border-color) !important; }
html.dark .vocab-fav-btn:hover { background: rgba(241, 196, 15, 0.18) !important; color: #ffd54f !important; }
html.dark .section-title { color: var(--text-heading) !important; }

/* Activity report — common reports panels */
html.dark .activity-card,
html.dark .activity-section,
html.dark .skill-row,
html.dark .skill-bar,
html.dark .progress-row {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* ═══ scoring.html — additional ═══ */
html.dark .clb-table,
html.dark .scoring-table,
html.dark .ee-eo-card,
html.dark .ee-eo-card-ee,
html.dark .ee-eo-card-eo {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .clb-score-range { color: var(--text-heading) !important; }

/* ═══ exam_session.html ═══ */
html.dark .exam-main,
html.dark .exam-pane,
html.dark .exam-rightbar,
html.dark .subject-content,
html.dark .type-area {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .exam-tab {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
}
html.dark .exam-tab.active {
    background: var(--accent-light-bg) !important;
    color: var(--text-heading) !important;
}
html.dark .exam-tab.done .tab-status { color: #66bb6a !important; }
html.dark .clock-time { color: var(--text-heading) !important; }
html.dark .count-num { color: var(--text-primary) !important; }
html.dark .target-met { color: #66bb6a !important; }
html.dark .word-count { color: var(--text-secondary) !important; }
html.dark .key-btn,
html.dark .key-shift {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .btn-back,
html.dark .btn-cancel {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

/* ═══ Reports common ═══ */
html.dark .stat-card.accent,
html.dark .stat-card.green,
html.dark .stat-card.red,
html.dark .stat-card.gold,
html.dark .stat-card.purple { color: #fff; }
html.dark .stat-value,
html.dark .stat-number { color: var(--text-heading) !important; }
html.dark .skill-row,
html.dark .skill-bar-bg,
html.dark .score-bar-bg,
html.dark .chart-wrapper,
html.dark .chart-container,
html.dark .chart-card,
html.dark .badge-item,
html.dark .scores-table {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .skill-name,
html.dark .sub-title,
html.dark .section-header { color: var(--text-secondary) !important; }
html.dark .motivation-text { color: var(--text-primary) !important; }
html.dark .badge-item.earned { background: var(--accent-light-bg) !important; }

/* ═══ notebook.html ═══ */
html.dark .nb-fr-key { color: var(--text-heading) !important; }
html.dark .note-action-btn {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
html.dark .note-action-btn.delete:hover { color: #ef9a9a !important; }
html.dark .note-badge,
html.dark .note-badge.expression,
html.dark .note-badge.vocabulaire,
html.dark .note-badge.grammaire,
html.dark .note-badge.conjugaison,
html.dark .note-badge.general { color: #fff !important; }

/* ═══ notifications.html ═══ */
html.dark .notif-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .notif-card.unread { background: var(--accent-light-bg) !important; }
html.dark .notif-card-title { color: var(--text-heading) !important; }
html.dark .notif-header { color: var(--text-heading) !important; }
html.dark .notif-card-dismiss {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
}
html.dark .notif-btn-danger {
    background: rgba(220, 53, 69, 0.18) !important;
    color: #ff8a80 !important;
}

/* ═══ home.html study widget ═══ */
html.dark .study-widget {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .sw-streak-num,
html.dark .sw-goal-val { color: var(--text-heading) !important; }
html.dark .sw-task {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
html.dark .sw-task.done { color: var(--text-muted) !important; }
html.dark .sw-cal-link { color: var(--link-color) !important; }

/* ═══ sl_module_detail ═══ */
html.dark .sl-sub-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .sl-sub-title-fr { color: var(--text-heading) !important; }
html.dark .module-raconter,
html.dark .module-situer { color: #fff; }

/* ═══ admin/traffic.html ═══ */
html.dark .traffic-header { color: var(--text-heading) !important; }
html.dark .traffic-card-row {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .row-value { color: var(--text-heading) !important; }

/* ═══ admin/page_views.html ═══ */
html.dark .pv-feed-card,
html.dark .pv-feed-table {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .pv-feed-title { color: var(--text-heading) !important; }
html.dark .auto-refresh-toggle {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .method-get { background: rgba(46, 125, 50, 0.18) !important; color: #a5d6a7 !important; }
html.dark .method-post { background: var(--accent-light-bg) !important; color: #7db3ff !important; }
html.dark .method-other { background: var(--bg-secondary) !important; color: var(--text-secondary) !important; }
html.dark .status-ok { color: #66bb6a !important; }

/* ═══ ee/exam_index.html ═══ */
html.dark .exam-row {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .exam-date { color: var(--text-secondary) !important; }
html.dark .empty-state { color: var(--text-muted) !important; }
html.dark .status-completed { background: rgba(46, 125, 50, 0.2) !important; color: #a5d6a7 !important; }
html.dark .status-in-progress { background: var(--accent-light-bg) !important; color: #7db3ff !important; }
html.dark .status-abandoned,
html.dark .status-timeout { background: rgba(220, 53, 69, 0.18) !important; color: #ff8a80 !important; }
html.dark .section-title { color: var(--text-heading) !important; }

/* ═══ Flashcard / argument / idea / question detail (eo) ═══ */
html.dark .fc-detail-card,
html.dark .argument-detail-card,
html.dark .idea-detail-card,
html.dark .flashcard-card,
html.dark .intro-box {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .fc-detail-desc,
html.dark .argument-content,
html.dark .idea-content {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
html.dark .fc-detail-titles,
html.dark .argument-title,
html.dark .idea-title,
html.dark .fc-title-fr,
html.dark .scenarios-title,
html.dark .linked-subjects-title { color: var(--text-heading) !important; }
html.dark .fc-item {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .fc-item-fr { color: var(--text-heading) !important; }
html.dark .fc-stat { color: var(--text-secondary) !important; }
html.dark .category-tag { background: var(--accent-light-bg) !important; color: #7db3ff !important; }
html.dark .scenario-card {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .scenario-french { color: var(--text-primary) !important; }
html.dark .scenario-trans-btn,
html.dark .scenario-translation {
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

/* ═══ tache2 par_structure_choice ═══ */
html.dark .t2-choice-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .t2-choice-title { color: var(--text-heading) !important; }
html.dark .formel { background: var(--accent-light-bg) !important; color: #7db3ff !important; }
html.dark .informel { background: #2a2418 !important; color: #ffb74d !important; }
html.dark .tag { background: var(--bg-secondary) !important; color: var(--text-secondary) !important; }
html.dark .fr { color: var(--text-primary) !important; }

/* ═══ level_questions ═══ */
html.dark .level-sidebar {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .score-section {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}
html.dark .leitner-box-btn,
html.dark .leitner-box-picker {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .leitner-box-btn:hover,
html.dark .leitner-box-btn.active { background: var(--accent-light-bg) !important; color: var(--text-heading) !important; }
html.dark .premium-banner-wrong {
    background: #2a2418 !important;
    color: #ffb74d !important;
    border-color: #f6ad55 !important;
}
html.dark .btn-premium-upgrade-wrong {
    background: #dd6b20 !important;
    color: #fff !important;
}
html.dark .btn-reveal-prev-answer {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
html.dark .tts-speed-select-ce,
html.dark .btn-tts-ce {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

/* ═══ tache_by_frequency semantic ═══ */
html.dark .semantic-result,
html.dark .semantic-slider,
html.dark .toggle-slider {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .sem-score { color: var(--text-heading) !important; }
html.dark .mid { color: var(--text-secondary) !important; }

/* ═══ c1c2 structure aphorism / point-box ═══ */
html.dark .aphorism {
    background: rgba(155, 89, 182, 0.15) !important;
    color: var(--text-primary) !important;
    border-color: #8e44ad !important;
}
html.dark .aphorism-text { color: var(--text-primary) !important; }
html.dark .point-box {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .sect-block {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .sect-label { color: var(--text-heading) !important; }
html.dark .ltr { color: var(--text-primary) !important; }

/* ═══ saved_vocabulary extras ═══ */
html.dark .duplicate-warning {
    background: #2a2418 !important;
    color: #ffb74d !important;
    border-color: #f6ad55 !important;
}
html.dark .btn-edit-existing {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
html.dark .inline-edit-input {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .vocab-delete:hover { color: #ef9a9a !important; }
html.dark .vocab-speak:hover { color: #7db3ff !important; }
html.dark .type-badge,
html.dark .type-badge.expression,
html.dark .type-badge.mot,
html.dark .type-badge.mots,
html.dark .type-badge.structure,
html.dark .type-badge.speaking { color: #fff !important; }

/* ═══ special_options ═══ */
html.dark .so-summary,
html.dark .so-answer {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .so-answer-label { color: var(--text-heading) !important; }
html.dark .so-answer-text,
html.dark .so-persian { color: var(--text-primary) !important; }

/* TTS speed selectors / playing states (eo subject details) */
html.dark .btn-tts-qc,
html.dark .btn-tts-arg,
html.dark .btn-tts-idea {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}
html.dark .btn-tts-qc:hover,
html.dark .btn-tts-arg:hover,
html.dark .btn-tts-idea:hover { color: #7db3ff !important; }
html.dark .btn-tts-qc.playing,
html.dark .btn-tts-arg.playing,
html.dark .btn-tts-idea.playing { color: #ef9a9a !important; }
html.dark .translation-content {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* ═══ report.html admin user table ═══ */
html.dark .users-table {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
html.dark .users-table tbody tr:hover { background: var(--hover-bg) !important; }
html.dark .users-table th { background: var(--bg-secondary) !important; color: var(--text-primary) !important; }
html.dark .users-table td { border-bottom-color: var(--border-color) !important; }
html.dark .badge-premium.inactive { background: rgba(220, 53, 69, 0.15) !important; color: #ff8a80 !important; }
html.dark .user-count-info { color: var(--text-primary) !important; }

/* ═══ structures_de_la_langue ═══ */
html.dark .sl-section,
html.dark .sl-card,
html.dark .sl-row {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* ═══ Strategy chart partial ═══ */
html.dark .strategy-chart,
html.dark .chart-bar,
html.dark .chart-axis {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Calendar misc focus colors */
html.dark .plan-note:focus,
html.dark .pt-title:focus,
html.dark .plan-add { color: var(--text-heading) !important; }
html.dark .plan-saved-msg { color: #66bb6a !important; }

/* CO audio like button */
.btn-like-audio {
    background: transparent;
    border: 1px solid var(--border, #ccc);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform .12s ease, background .12s ease;
    margin-inline-start: 6px;
}
.btn-like-audio:hover { transform: scale(1.08); }
.btn-like-audio.liked { background: rgba(229, 57, 70, 0.12); border-color: #e53946; }
.btn-like-audio[disabled] { opacity: .5; cursor: wait; }

/* CO audio collapsed extras */
.audio-extras-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
}
.audio-extras.hidden { display: none; }
.btn-toggle-extras {
    background: rgba(120, 130, 150, 0.08);
    border: 1px solid rgba(120, 130, 150, 0.18);
    border-radius: 999px;
    padding: 7px 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.2px;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
    backdrop-filter: blur(6px);
}
.btn-toggle-extras:hover {
    background: rgba(120, 130, 150, 0.14);
    border-color: rgba(120, 130, 150, 0.3);
    color: var(--text-heading, #1f2937);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.btn-toggle-extras:active { transform: translateY(0); box-shadow: none; }
.btn-toggle-extras .caret {
    font-size: 10px;
    line-height: 1;
    opacity: 0.7;
    transition: transform 0.2s ease;
}
.btn-toggle-extras[aria-expanded="true"] .caret { transform: rotate(180deg); }
.audio-extras {
    width: 100%;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(120, 130, 150, 0.15);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
html.dark .btn-toggle-extras {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.65);
}
html.dark .btn-toggle-extras:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
html.dark .audio-extras { border-top-color: rgba(255, 255, 255, 0.1); }

/* ============================================================ */
/* ── IR-only additions ─────────────────────────────────────── */
/* ============================================================ */

/* IR-only home card colors */
.home-card.card-video-lessons { --card-color: #c2185b; }
.home-card.card-leaderboard { --card-color: #ff8f00; }
.home-card.card-chat { --card-color: #2a5298; }
.home-card.card-learning { --card-color: #00897b; }
.home-card.card-telegram { --card-color: #0088cc; }

/* ==================== Learning Resources Page ==================== */
.lr-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
}

.lr-section {
    margin-bottom: 30px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.lr-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.lr-section-header h2 {
    margin: 0;
    font-size: 1.15em;
    font-weight: 700;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.lr-section-icon {
    font-size: 1.5em;
}

.lr-section-body {
    padding: 15px 20px;
}

/* Folders */
.lr-folder {
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.lr-folder-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    cursor: pointer;
    background: #fafbfc;
    transition: background 0.2s;
    user-select: none;
}

.lr-folder-header:hover {
    background: #f0f2f5;
}

.lr-folder-icon {
    font-size: 1.3em;
}

.lr-folder-name {
    font-weight: 600;
    flex: 1;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.lr-folder-count {
    font-size: 0.85em;
    color: var(--text-muted);
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

.lr-folder-arrow {
    font-size: 0.7em;
    color: #999;
    transition: transform 0.2s;
}

.lr-folder.open .lr-folder-arrow {
    transform: rotate(180deg);
}

.lr-folder-files {
    display: none;
    padding: 5px 15px 10px;
}

.lr-folder.open .lr-folder-files {
    display: block;
}

.lr-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 5px;
    border-bottom: 1px solid #f0f0f0;
}

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

.lr-file-icon {
    font-size: 1.1em;
}

.lr-file-link {
    flex: 1;
    color: #2a5298;
    text-decoration: none;
    font-size: 0.95em;
    word-break: break-all;
}

.lr-file-link:hover {
    text-decoration: underline;
}

.lr-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

/* Telegram channels */
.lr-channels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.lr-channel-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}

.lr-channel-card:hover {
    border-color: #0088cc;
    box-shadow: 0 4px 15px rgba(0, 136, 204, 0.15);
}

.lr-channel-icon {
    font-size: 1.8em;
}

.lr-channel-name {
    font-weight: 600;
    font-size: 1.05em;
    direction: ltr;
}

/* Admin section */
.lr-admin-section {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 25px;
}

.lr-admin-section h3 {
    margin: 0 0 15px 0;
    font-size: 1.05em;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    color: #6d4c00;
}

.lr-admin-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lr-form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.lr-input {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9em;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    flex: 1;
    min-width: 150px;
}

.lr-file-input {
    display: none;
}

.lr-file-label {
    padding: 8px 16px;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    transition: background 0.2s;
    white-space: nowrap;
}

.lr-file-label:hover {
    background: #bbdefb;
}

.lr-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.lr-btn-upload {
    background: #43a047;
    color: white;
}

.lr-btn-upload:hover {
    background: #388e3c;
}

.lr-btn-folder {
    background: #1e88e5;
    color: white;
}

.lr-btn-folder:hover {
    background: #1565c0;
}

.lr-btn-delete {
    background: none;
    border: none;
    color: #e53935;
    cursor: pointer;
    font-size: 1.1em;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.lr-btn-delete:hover {
    background: #ffebee;
}

.lr-delete-form {
    display: inline;
}

/* Flash messages for learning resources */
.flash-message {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    font-size: 0.95em;
}

.flash-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.flash-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* Dark mode for learning resources */
body.dark-mode .lr-section {
    border-color: #444;
}

body.dark-mode .lr-section-header {
    background: #2a2a2a;
    border-color: #444;
}

body.dark-mode .lr-folder {
    border-color: #444;
}

body.dark-mode .lr-folder-header {
    background: #2a2a2a;
}

body.dark-mode .lr-folder-header:hover {
    background: #333;
}

body.dark-mode .lr-file-item {
    border-color: #333;
}

body.dark-mode .lr-file-link {
    color: #7aafff;
}

body.dark-mode .lr-channel-card {
    border-color: #444;
}

body.dark-mode .lr-channel-card:hover {
    border-color: #0088cc;
}

body.dark-mode .lr-admin-section {
    background: #332b00;
    border-color: #665200;
}

body.dark-mode .lr-admin-section h3 {
    color: #ffe082;
}

body.dark-mode .lr-input {
    background: #333;
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .lr-file-label {
    background: #1a3a5c;
    border-color: #2a5298;
    color: #e0e0e0;
}

body.dark-mode .home-section-title {
    border-color: #444;
}

body.dark-mode .flash-success {
    background: #1b3d1f;
    color: #81c784;
    border-color: #2e7d32;
}

body.dark-mode .flash-error {
    background: #3d1b1b;
    color: #ef9a9a;
    border-color: #c62828;
}

@media (max-width: 768px) {
    .lr-form-row {
        flex-direction: column;
        align-items: stretch;
    }
    .lr-channels {
        grid-template-columns: 1fr;
    }
}
