/* --- Local fonts: avoid a render-blocking Google Fonts request --- */
@font-face {
    font-family: 'Heebo';
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
    src: url('/src/assets/fonts/heebo-hebrew.woff2') format('woff2');
    unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}

@font-face {
    font-family: 'Heebo';
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
    src: url('/src/assets/fonts/heebo-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Noto Serif Hebrew';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/src/assets/fonts/noto-serif-hebrew.woff2') format('woff2');
    unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}

/* --- CSS Variables & Design System --- */

:root {
    /* Warm Color Palette */
    --bg-primary: #ffffff;
    --bg-secondary: #FBF8F4;
    --bg-tertiary: #F3EDE6;
    --bg-body: #FFFBF5;
    
    --text-primary: #2A2421;
    --text-secondary: #5C524A;
    --text-tertiary: #8A7363;
    
    /* Subject Colors (warm-shifted) */
    --color-civics: #3B5998;
    --color-civics-glow: rgba(59, 89, 152, 0.15);
    --color-civics-light: #EEF1F8;
    
    --color-bible: #955F1D;
    --color-bible-glow: rgba(168, 113, 42, 0.15);
    --color-bible-light: #FDF6EB;
    
    --color-history: #587535;
    --color-history-glow: rgba(94, 125, 58, 0.15);
    --color-history-light: #F2F6EC;
    
    /* UI Colors */
    --color-accent: #7C6A56;
    --color-accent-light: #F3EDE6;
    --color-success: #4A7C59;
    --color-success-light: #E8F3EB;
    --color-error: #B34040;
    --color-error-light: #FBEAEA;
    --color-border: #E8DFD4;
    
    /* Typography */
    --font-family: 'Heebo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* Warm Soft Shadows */
    --shadow-sm: 0 1px 4px rgba(138, 115, 99, 0.08);
    --shadow-md: 0 6px 20px -4px rgba(138, 115, 99, 0.12), 0 2px 8px -2px rgba(138, 115, 99, 0.06);
    --shadow-lg: 0 20px 40px -8px rgba(138, 115, 99, 0.18), 0 8px 16px -4px rgba(138, 115, 99, 0.08);
    --shadow-glow: 0 0 30px rgba(124, 106, 86, 0.2);
    
    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.5rem;
    --radius-pill: 9999px;
    
    /* Transitions */
    --transition-fast: 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
    --transition-normal: 400ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* --- Typography --- */
h1, h2, h3, h4 {
    color: var(--text-primary);
    font-weight: 800;
    line-height: 1.2;
}

/* --- Layout --- */
.view {
    display: none;
    opacity: 0;
    animation: fadeInUp var(--transition-normal) forwards;
}

.view.active {
    display: block;
}

body.no-js .view.active {
    animation: none;
    opacity: 1;
    transform: none;
}

.hidden {
    display: none !important;
}

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

/* --- Components --- */

/* Navbar — Clean: Logo (right) + Login (left) */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

body:not(.dark-mode) .navbar {
    background-color: rgba(255, 251, 245, 0.92);
}

body.dark-mode .navbar {
    background-color: rgba(30, 30, 30, 0.92);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    transition: opacity var(--transition-fast);
}

.logo:hover {
    opacity: 0.8;
}

.logo .dot {
    color: var(--color-bible);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Login Button — Clean pill style */
.btn-login {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 2px solid var(--color-border);
    padding: 0.55rem 1.5rem;
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1rem;
    background-color: transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
}

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

.btn-login:hover {
    background-color: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg-body);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-login:hover svg {
    stroke: var(--bg-body);
}

.hamburger-btn {
    display: none;
    color: var(--text-primary);
}

/* --- Hamburger Drawer --- */
.drawer-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s;
}

.nav-drawer {
    position: fixed;
    top: 0; bottom: 0; right: 0;
    width: 280px;
    background: var(--bg-primary);
    z-index: 1001;
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.nav-drawer.open {
    transform: translateX(0);
}

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

.drawer-close {
    color: var(--text-secondary);
}

.drawer-links-container {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.drawer-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 700;
    transition: background 0.2s;
}

.drawer-link:hover {
    background: var(--bg-tertiary);
    color: var(--color-accent);
}


/* Hero Section */
.hero {
    max-width: 850px;
    margin: 5rem auto 4rem;
    padding: 0 1.5rem;
    text-align: center;
}

.badge {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--color-accent);
    padding: 0.4rem 1.25rem;
    border-radius: var(--radius-pill);
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2rem;
    border: 1px solid var(--color-border);
    animation: badgePulse 4s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(168, 113, 42, 0); }
    50% { box-shadow: 0 0 0 6px rgba(168, 113, 42, 0.08); }
}

.hero-title {
    font-size: clamp(3rem, 6vw, 4.5rem);
    letter-spacing: -1.5px;
    margin-bottom: 1.25rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.highlight {
    color: var(--color-bible);
    position: relative;
    display: inline-block;
}

.highlight::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 0;
    width: 100%;
    height: 10px;
    background: rgba(168, 113, 42, 0.15);
    border-radius: 5px;
    z-index: -1;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    max-width: 650px;
    margin-inline: auto;
    font-weight: 500;
}

.search-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--bg-primary);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-pill);
    padding: 0.5rem;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.search-container:focus-within {
    border-color: var(--color-accent-light);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.search-icon {
    position: absolute;
    right: 1.5rem;
    color: var(--text-tertiary);
    pointer-events: none;
    z-index: 1;
}

.search-input {
    flex-grow: 1;
    border: none;
    padding: 0.85rem 3rem 0.85rem 1rem;
    font-size: 1.1rem;
    font-family: inherit;
    background: transparent;
    outline: none;
    color: var(--text-primary);
    position: relative;
    z-index: 2;
}

.search-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 600;
}

/* Filter Button — now in the prominent position */
.btn-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--text-primary);
    color: var(--bg-body);
    padding: 0.85rem 1.8rem;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    border: none;
}

.btn-filter svg {
    stroke: var(--bg-body);
}

.btn-filter:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* Filter Dropdown — Panel Layout */
.filter-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 201;
    padding: 1rem 1.25rem;
    animation: fadeInUp 0.15s ease forwards;
}

.filter-dropdown.hidden {
    display: none;
}

.filter-section {
    margin-bottom: 0.25rem;
}

.filter-section-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
}

.filter-pills {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.filter-option {
    padding: 0.45rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-option:hover {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

.filter-option.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.filter-divider {
    height: 1px;
    background: var(--color-border);
    margin: 0.75rem 0;
}

/* Grade Accordion Toggle */
.filter-grade-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem 0;
    transition: color var(--transition-fast);
}

.filter-grade-toggle:hover {
    color: var(--color-accent);
}

.filter-grade-toggle .chevron-icon {
    transition: transform var(--transition-fast);
}

.filter-grade-toggle.open .chevron-icon {
    transform: rotate(180deg);
}

/* Grade List — compact scrollable */
.filter-grades-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    max-height: 120px;
    overflow-y: auto;
    padding: 0.5rem 0 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.filter-grades-list.hidden {
    display: none;
}

.filter-grade-chip {
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 700;
    font-family: inherit;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-grade-chip:hover {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

.filter-grade-chip.active {
    background: var(--color-bible);
    color: white;
    border-color: var(--color-bible);
}
.search-autocomplete {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 380px;
    overflow-y: auto;
    animation: fadeInUp 0.15s ease forwards;
}

.search-autocomplete.hidden {
    display: none;
}

.autocomplete-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid rgba(232, 223, 212, 0.4);
}

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

.autocomplete-item:hover,
.autocomplete-item.ac-highlighted {
    background: var(--color-accent-light);
}

.ac-topic-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.ac-topic-name mark {
    background: rgba(168, 113, 42, 0.25);
    color: var(--color-accent);
    border-radius: 3px;
    padding: 0 2px;
}

.ac-meta {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 600;
    white-space: nowrap;
    margin-right: 1rem;
}

/* Filter Dropdown */
.filter-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: auto;
    right: auto;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 201;
    padding: 0.5rem;
    display: flex;
    gap: 0.4rem;
    animation: fadeInUp 0.15s ease forwards;
}

.filter-dropdown.hidden {
    display: none;
}

.filter-option {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-option:hover {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

.filter-option.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

/* Print Worksheet Button (in Practice Lab) */
.lab-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-print-worksheet {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-bible-light);
    color: var(--color-bible);
    border: 1px solid var(--color-bible-glow);
    padding: 0.5rem 1.2rem;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-print-worksheet:hover {
    background: var(--color-bible);
    color: white;
    border-color: var(--color-bible);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-print-worksheet:hover svg {
    stroke: white;
}

/* Subjects Section */
.subjects-section {
    max-width: 1200px;
    margin: 0 auto 6rem;
    padding: 0 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
}

.section-header h2 {
    font-size: 1.75rem;
    letter-spacing: -0.5px;
}

.view-all {
    color: var(--color-accent);
    font-weight: 700;
    font-size: 1.05rem;
    transition: opacity var(--transition-fast);
}

.view-all:hover {
    opacity: 0.8;
}

.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
}

.subject-card {
    position: relative;
    background-color: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
    color: inherit;
}

.subject-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

/* Card Image */
.card-image {
    width: 100%;
    height: 240px;
    overflow: hidden;
    position: relative;
}

.card-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(to top, rgba(255,255,255,0.3), transparent);
    pointer-events: none;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.subject-card:hover .card-image img {
    transform: scale(1.08);
}

.card-content {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.subject-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.subject-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
    flex-grow: 1;
    line-height: 1.6;
}

.btn-start {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-pill);
    transition: all var(--transition-fast);
    align-self: flex-start;
}

.btn-arrow {
    transition: transform var(--transition-fast);
    font-size: 1.2rem;
}

.subject-card:hover .btn-arrow {
    transform: translateX(-4px);
}

/* Subject-specific card styles */
.card-civics .btn-start { background: var(--color-civics-light); color: var(--color-civics); }
.card-civics:hover .btn-start { background: var(--color-civics); color: white; }

.card-bible .btn-start { background: var(--color-bible-light); color: var(--color-bible); }
.card-bible:hover .btn-start { background: var(--color-bible); color: white; }

.card-history .btn-start { background: var(--color-history-light); color: var(--color-history); }
.card-history:hover .btn-start { background: var(--color-history); color: white; }

/* Topic View */
#topic-view {
    max-width: 1300px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.topic-header {
    margin-bottom: 3rem;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    background-color: var(--bg-tertiary);
    transition: all var(--transition-fast);
}

.btn-back:hover {
    color: var(--text-primary);
    background-color: #e2e8f0;
    transform: translateX(3px);
}

.topic-meta {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.subject-tag {
    align-self: flex-start;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-civics);
    background-color: var(--color-civics-light);
    padding: 0.35rem 1rem;
    border-radius: var(--radius-pill);
}

.topic-title {
    font-size: 2.5rem;
    letter-spacing: -0.5px;
}

.split-layout {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 2.5rem;
    align-items: start;
}

/* Fact Sheet (Right Column now in RTL) */
.fact-sheet {
    background-color: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    position: sticky;
    top: 6rem;
    box-shadow: var(--shadow-sm);
}

.fact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--bg-tertiary);
    padding-bottom: 1rem;
}

.fact-header h2 {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.btn-icon {
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    background-color: var(--bg-secondary);
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--color-border);
}

.btn-icon:hover {
    color: var(--text-primary);
    background-color: var(--color-accent-light);
    border-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Download Worksheet Button Accent */
.btn-download-worksheet {
    background-color: var(--color-bible-light);
    border-color: var(--color-bible-glow);
    color: var(--color-bible);
}

.btn-download-worksheet:hover {
    background-color: var(--color-bible);
    color: white;
    border-color: var(--color-bible);
}

.btn-download-worksheet:hover svg {
    stroke: white;
}

.fact-content {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.fact-list {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.fact-list li {
    position: relative;
    padding-right: 2rem;
}

.fact-list li::before {
    content: "•";
    position: absolute;
    right: 0;
    color: var(--color-accent);
    font-weight: 800;
    font-size: 1.5rem;
    line-height: 1;
    top: -4px;
}

.interactive-term {
    color: var(--color-civics);
    font-weight: 700;
    border-bottom: 2px dotted var(--color-civics);
    cursor: help;
    transition: all var(--transition-fast);
    position: relative;
}

.interactive-term:hover {
    background-color: var(--color-civics-light);
    border-radius: 4px;
    padding: 0 4px;
}

/* Practice Lab (Left Column now in RTL) */
.practice-lab {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.lab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.lab-header h2 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--color-accent);
}

.question-counter {
    background: var(--bg-tertiary);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-container {
    height: 10px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent), var(--color-bible));
    border-radius: var(--radius-pill);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.quiz-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 5px;
    background: linear-gradient(90deg, var(--color-bible), var(--color-accent));
}

.scenario {
    margin-bottom: 2.5rem;
}

.scenario-label {
    display: inline-block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 800;
    color: var(--color-accent);
    margin-bottom: 0.75rem;
    background-color: var(--color-accent-light);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
}

.scenario p {
    font-size: 1.25rem;
    color: var(--text-primary);
    line-height: 1.7;
    font-weight: 500;
}

.options-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    text-align: right;
    padding: 1.25rem 1.5rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    background-color: var(--bg-primary);
    transition: all var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    color: var(--text-primary);
}

.option-btn:hover:not(:disabled) {
    border-color: var(--color-accent);
    background-color: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.option-btn.selected {
    border-color: var(--color-accent);
    background-color: var(--color-accent-light);
    box-shadow: 0 0 0 1px var(--color-accent), var(--shadow-sm);
}

.option-btn.correct {
    border-color: var(--color-success);
    background-color: var(--color-success-light);
    color: #064e3b;
    box-shadow: 0 0 0 1px var(--color-success);
}

.option-btn.incorrect {
    border-color: var(--color-error);
    background-color: var(--color-error-light);
    color: #7f1d1d;
}

.option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--bg-tertiary);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

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

.option-btn.correct .option-letter { background-color: var(--color-success); color: white; }
.option-btn.incorrect .option-letter { background-color: var(--color-error); color: white; }

.option-text {
    font-size: 1.1rem;
    font-weight: 600;
}

.quiz-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--color-border);
    padding-top: 2rem;
}

.btn-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-tertiary);
    font-weight: 600;
    transition: color var(--transition-fast);
}

.btn-hint:hover {
    color: var(--color-bible); 
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-body);
    padding: 0.85rem 2.5rem;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    box-shadow: none;
    cursor: not-allowed;
    border: 1px solid var(--color-border);
}

.feedback {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    font-weight: 500;
    font-size: 1.1rem;
    animation: fadeInUp var(--transition-fast);
}

.feedback.hidden {
    display: none;
}

.feedback.correct {
    background-color: var(--color-success-light);
    color: #064e3b;
    border: 2px solid var(--color-success);
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.15);
}

.feedback.incorrect {
    background-color: var(--color-error-light);
    color: #7f1d1d;
    border: 2px solid var(--color-error);
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.15);
}

.feedback small {
    display: block;
    margin-top: 0.5rem;
    font-weight: 400;
    font-size: 0.95rem;
    opacity: 0.85;
}

/* Tooltip / Popover */
.tooltip {
    position: absolute;
    z-index: 1000;
    background: var(--text-primary);
    color: var(--bg-body);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    width: max-content;
    max-width: 280px;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.25s, transform 0.25s;
    text-align: right;
    border: 1px solid rgba(255,255,255,0.1);
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip.hidden {
    display: none;
}

.tooltip-content strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-civics-light);
    font-size: 1.1rem;
    font-weight: 800;
}

.tooltip-content p {
    font-size: 0.95rem;
    color: #e2e8f0;
    line-height: 1.5;
    margin: 0;
}

.tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

/* Tooltip Position */
.tooltip[data-popper-placement^='bottom'] .tooltip-arrow {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 8px 8px 8px;
    border-color: transparent transparent #1e293b transparent;
}
.tooltip[data-popper-placement^='top'] .tooltip-arrow {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0 8px;
    border-color: #0f172a transparent transparent transparent;
}


/* --- Breadcrumbs --- */
.breadcrumb-container {
    max-width: 1200px;
    margin: 2rem auto 0;
    padding: 0 1.5rem;
}

.breadcrumb-container.hidden {
    display: none;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    font-size: 1.05rem;
    font-weight: 600;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-tertiary);
}

.breadcrumbs li:not(:last-child)::after {
    content: "/";
    color: var(--color-border);
}

.breadcrumbs li a {
    color: var(--text-secondary);
    transition: color var(--transition-fast);
    cursor: pointer;
}

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

.breadcrumbs li:last-child {
    color: var(--text-primary);
    font-weight: 700;
}

/* --- Selection Grids (Grades & Topics) --- */
.selection-container {
    max-width: 1200px;
    margin: 3rem auto 5rem;
    padding: 0 1.5rem;
}

.view-title {
    font-size: 2.5rem;
    letter-spacing: -0.5px;
    margin-bottom: 0.75rem;
}

.view-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
}

.grades-grid {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.grade-card {
    width: 180px;
    height: 110px;
    background: #FFFFFF;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(138, 115, 99, 0.08);
    color: inherit;
}

.grade-card h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #2A2421;
}

.grade-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-bible);
}

.grade-card:hover h3 {
    color: var(--color-bible);
}

body.dark-mode .grade-card {
    background: #2D2D2D;
    color: #FFFFFF;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

body.dark-mode .grade-card h3 {
    color: #FFFFFF;
}

body.dark-mode .grade-card:hover { border-color: var(--color-bible); }
body.dark-mode .grade-card:hover h3 { color: var(--color-bible); }

/* (Gradient removed for dark mode via block above) */
/* Replaced and cleaned */

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.topic-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: inherit;
}

.topic-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-accent);
}

.topic-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.topic-card-icon {
    color: var(--text-tertiary);
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.topic-card:hover .topic-card-icon {
    color: var(--color-accent);
    transform: translateX(-5px);
}

/* Specific Subject Themes via body data attribute */
body[data-subject="civics"] .view-title { color: var(--color-civics); }
body[data-subject="civics"] .grade-card:hover { border-color: var(--color-civics); box-shadow: 0 10px 25px var(--color-civics-glow); }
body[data-subject="civics"] .grade-card:hover h3 { color: var(--color-civics); }
body[data-subject="civics"] .topic-card:hover { border-color: var(--color-civics); box-shadow: 0 5px 15px var(--color-civics-glow); }
body[data-subject="civics"] .topic-card:hover .topic-card-icon { color: var(--color-civics); }

body[data-subject="bible"] .view-title { color: var(--color-bible); }
body[data-subject="bible"] .grade-card:hover { border-color: var(--color-bible); box-shadow: 0 10px 25px var(--color-bible-glow); }
body[data-subject="bible"] .grade-card:hover h3 { color: var(--color-bible); }
body[data-subject="bible"] .topic-card:hover { border-color: var(--color-bible); box-shadow: 0 5px 15px var(--color-bible-glow); }
body[data-subject="bible"] .topic-card:hover .topic-card-icon { color: var(--color-bible); }

body[data-subject="history"] .view-title { color: var(--color-history); }
body[data-subject="history"] .grade-card:hover { border-color: var(--color-history); box-shadow: 0 10px 25px var(--color-history-glow); }
body[data-subject="history"] .grade-card:hover h3 { color: var(--color-history); }
body[data-subject="history"] .topic-card:hover { border-color: var(--color-history); box-shadow: 0 5px 15px var(--color-history-glow); }
body[data-subject="history"] .topic-card:hover .topic-card-icon { color: var(--color-history); }

/* --- True/False Question Styles --- */
.tf-options {
    flex-direction: row;
    gap: 1.5rem;
}

.tf-btn {
    flex: 1;
    justify-content: center;
    padding: 2rem;
    font-size: 1.5rem;
    font-weight: 800;
}

.tf-btn .option-text {
    font-size: 1.5rem;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
    
    .fact-sheet {
        position: static;
        order: -1;
    }
}

@media (max-width: 768px) {
    .tf-options {
        flex-direction: column;
    }
    
    .nav-links { display: none; }
    .hamburger-btn { display: block; }
    
    .hero-title { font-size: 2rem; }
    .hero-subtitle { font-size: 1.05rem; }
    
    .search-container {
        border-radius: var(--radius-pill);
        padding: 0.35rem;
    }
    
    /* Hide text on filter button so it doesn't break out of the search bar */
    .btn-filter span { display: none; }
    .btn-filter { padding: 0.6rem; }
    
    .subjects-grid, .content-browser-grid, .topics-grid, .grades-grid {
        grid-template-columns: 1fr;
    }
    
    .grade-card {
        width: 100%;
        height: auto;
        padding: 1.5rem;
    }
    
    .presentation-banner-inner {
        flex-direction: column;
        text-align: center;
    }
    .presentation-arrow {
        transform: rotate(90deg);
    }
    
    .auth-modal, .upgrade-modal {
        width: 95%;
        padding: 1.5rem;
    }
    
    .settings-container, .privacy-container {
        padding: 1.5rem;
        margin-top: 2rem;
    }

    /* Lesson view fixes for mobile */
    .lab-header-actions {
        gap: 0.5rem;
    }
    .lab-header-actions button span { display: none; }
    .lab-header-actions button { padding: 0.6rem; }
    .question-counter { font-size: 0.85rem; }
}

/* ==========================================================================
   PRINT SETTINGS PANEL
   ========================================================================== */
.print-settings-panel {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.print-settings-header h3 {
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.print-settings-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

.print-options {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.print-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.print-checkbox input {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--color-primary);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    background-color: transparent;
    transition: all var(--transition-fast);
}

.print-checkbox input:checked {
    background-color: var(--color-primary);
}

.print-checkbox input:checked::after {
    content: "✓";
    position: absolute;
    color: white;
    font-size: 16px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.print-checkbox:hover input {
    border-color: var(--color-accent);
}

/* ==========================================================================
   PRESENTATION BANNER & MODAL
   ========================================================================== */

/* --- Hero Banner --- */
.presentation-banner {
    margin: 0 0 2rem 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.presentation-banner.hidden {
    display: none !important;
}

.presentation-banner-inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.1rem 1.75rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: var(--radius-lg);
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(15, 52, 96, 0.45), 0 2px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.presentation-banner-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(168, 113, 42, 0.15) 0%, transparent 60%);
    pointer-events: none;
}

.presentation-banner-inner:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(15, 52, 96, 0.55), 0 4px 12px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.1);
}

.presentation-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(168, 113, 42, 0.2);
    border: 1.5px solid rgba(168, 113, 42, 0.5);
    color: #e8c880;
    flex-shrink: 0;
}

.presentation-banner-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 2px;
}

.presentation-banner-label {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f0e8d5;
    letter-spacing: 0.01em;
}

.presentation-banner-sub {
    font-size: 0.85rem;
    color: rgba(240, 232, 213, 0.65);
}

.presentation-arrow {
    color: rgba(240, 232, 213, 0.5);
    transform: rotate(180deg);
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s ease;
}

.presentation-banner-inner:hover .presentation-arrow {
    color: #e8c880;
    transform: rotate(180deg) translateX(-4px);
}

/* --- Modal Overlay --- */
.presentation-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.25s ease forwards;
}

.presentation-modal-overlay.hidden {
    display: none !important;
}

.presentation-modal {
    position: relative;
    width: 96vw;
    height: 92vh;
    max-width: 1800px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 4px 16px rgba(0,0,0,0.4);
    animation: slideUp 0.3s cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
    background: #0d1117;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

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

/* Strict 16:9 responsive iframe */
.presentation-iframe-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
}

.presentation-iframe-container iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Close button */
.presentation-modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(4px);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
}

.presentation-modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

/* ==========================================================================
   PRINT STYLES (A4 Optimized)
   ========================================================================== */
@media print {
    /* Safe overrides based on body class - SPECIFICITY INCREASED */
    body.print-hide-story #fact-story-view,
    body.print-hide-story .fact-story-view { 
        display: none !important; 
    }
    
    body.print-hide-summary #fact-list-container,
    body.print-hide-summary .fact-list { 
        display: none !important; 
    }
    
    body.print-hide-questions #worksheet-questions-container,
    body.print-hide-questions .print-only-section,
    body.print-hide-questions .worksheet-print-divider,
    body.print-hide-questions .teacher-answer-key { 
        display: none !important; 
    }
    
    /* Hide the summary heading if both summary and story are hidden (or if just summary is hidden and story is what's left, hide "דף עובדות") */
    body.print-hide-summary .fact-header h2 { display: none !important; }
    
    @page {
        size: A4;
        margin: 0;
    }

    body.dark-mode {
        --bg-primary: #ffffff !important;
        --bg-secondary: #ffffff !important;
        --bg-tertiary: #ffffff !important;
        --bg-body: #ffffff !important;
        --text-primary: #2A2421 !important;
        --text-secondary: #5C524A !important;
        --text-tertiary: #8A7363 !important;
        --color-accent-light: #ffffff !important;
        --color-border: #cccccc !important;
    }

    body.dark-mode * {
        color: #2A2421 !important;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        transition: none !important;
        animation: none !important;
    }

    /* ====== HIDE: Only specific UI chrome ====== */
    .navbar,
    .noprint,
    .practice-lab,
    .topic-header,
    .breadcrumb-container,
    .mobile-menu-btn,
    #btn-print,
    #btn-download-pdf,
    .fact-tabs,
    .search-wrapper,
    .hero,
    .subjects-section,
    .footer,
    #home-view,
    #grade-selection-view,
    #topic-selection-view,
    .definition-popup,
    .presentation-modal-overlay {
        display: none !important;
    }

    /* ====== SHOW: Safe container resets ====== */
    html, body {
        background: white !important;
        color: black !important;
        visibility: visible !important;
        opacity: 1 !important;
        overflow: visible !important;
        height: auto !important;
        width: auto !important;
    }

    #topic-view {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .split-layout,
    .fact-sheet,
    #printable-fact-sheet,
    .fact-content {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: static !important;
        width: auto !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        overflow: visible !important;
        color: black !important;
    }

    .split-layout,
    .fact-sheet,
    .fact-content {
        padding: 0 !important;
    }

    #printable-fact-sheet {
        padding: 1.5cm 1.5cm 2.9cm !important;
        box-sizing: border-box !important;
    }

    /* Force BOTH content views visible during print */
    .fact-story-view {
        display: block !important;
        visibility: visible !important;
        font-size: 12pt !important;
        line-height: 1.6 !important;
        color: black !important;
        margin-bottom: 20px !important;
    }

    .fact-story-view p {
        margin-bottom: 10px !important;
    }

    .fact-list,
    #fact-list-container {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        color: black !important;
        font-size: 13pt !important;
        line-height: 1.8 !important;
    }

    #worksheet-questions-container {
        display: block !important;
        visibility: visible !important;
        padding-bottom: 2.1cm !important;
    }

    /* Fact Header — show the title only, hide the tabs */
    .fact-header {
        display: block !important;
        visibility: visible !important;
    }

    .fact-header h2 {
        display: block !important;
        font-size: 16pt !important;
        color: #2A2421 !important;
        margin-bottom: 10px !important;
    }

    /* ====== Branded Header ====== */
    .print-header-brand {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        border-bottom: 2px solid #A8712A !important;
        padding-bottom: 15px !important;
        margin-bottom: 20px !important;
        page-break-inside: avoid !important;
    }

    .print-logo-text {
        font-size: 28pt !important;
        font-weight: 800 !important;
        color: #2A2421 !important;
        text-align: center !important;
    }

    .print-student-info {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .print-fields {
        display: flex !important;
        justify-content: space-between !important;
        font-size: 12pt !important;
        font-weight: 600 !important;
        margin-top: 5px !important;
    }

    /* ====== Worksheet Sections ====== */
    .print-only-section {
        display: block !important;
        margin-top: 30px !important;
        page-break-before: auto !important;
    }

    .worksheet-print-divider {
        border-top: 2px dashed #E8DFD4 !important;
        margin: 30px 0 !important;
    }

    .worksheet-title {
        font-size: 18pt !important;
        color: #A8712A !important;
        margin-bottom: 15px !important;
        border-right: 4px solid #A8712A !important;
        padding-right: 10px !important;
    }

    .print-question-item {
        margin-bottom: 25px !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .print-answer-line {
        border-bottom: 1px solid #E8DFD4 !important;
        height: 35px !important;
        width: 100% !important;
        margin-bottom: 5px !important;
    }

    /* ====== True/False & Multiple Choice Print ====== */
    .print-tf-options {
        display: flex !important;
        gap: 2rem !important;
        margin-top: 10px !important;
        margin-right: 20px !important;
    }

    .print-tf-opt {
        border: 2px solid #E8DFD4 !important;
        padding: 5px 20px !important;
        border-radius: 8px !important;
        font-weight: 700 !important;
    }

    .print-mc-options {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        margin-top: 10px !important;
        margin-right: 20px !important;
    }

    .print-mc-letter {
        display: inline-block !important;
        font-weight: 800 !important;
        border: 2px solid #A8712A !important;
        color: #A8712A !important;
        border-radius: 50% !important;
        width: 24px !important;
        height: 24px !important;
        text-align: center !important;
        line-height: 20px !important;
        margin-left: 8px !important;
    }

    .print-correction-lines {
        margin-top: 10px !important;
        font-weight: 700 !important;
    }

    .print-matching-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 14px !important;
        margin-top: 10px !important;
    }

    .print-matching-col {
        border: 1px solid #E8DFD4 !important;
        border-radius: 8px !important;
        padding: 8px !important;
    }

    .print-matching-row {
        padding: 6px 4px !important;
        border-bottom: 1px solid #F0E8DF !important;
    }

    .print-matching-row:last-child {
        border-bottom: none !important;
    }

    .print-ordering-bank {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        margin-top: 10px !important;
        margin-bottom: 10px !important;
    }

    .print-ordering-chip {
        border: 1px solid #E8DFD4 !important;
        border-radius: 999px !important;
        padding: 5px 12px !important;
        font-weight: 700 !important;
        background: #FFFDF9 !important;
    }

    /* ====== Teacher Answer Key ====== */
    .teacher-answer-key {
        display: block !important;
        page-break-before: always !important;
        margin-top: 40px !important;
        padding-top: 40px !important;
        border-top: 4px solid #A8712A !important;
    }

    .teacher-title {
        color: #B34040 !important;
        border-right-color: #B34040 !important;
    }

    .print-answer-item {
        font-size: 13pt !important;
        margin-bottom: 15px !important;
        padding-right: 15px !important;
        border-right: 2px solid #E8DFD4 !important;
    }

    /* ====== Print Footer ====== */
    .print-footer {
        position: fixed !important;
        right: auto !important;
        bottom: 0.45cm !important;
        left: 1.15cm !important;
        width: auto !important;
        max-width: 8.4cm !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        direction: ltr !important;
        text-align: left !important;
        font-size: 8.5pt !important;
        font-weight: 800 !important;
        color: #8A7363 !important;
        border: none !important;
        padding: 0 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        z-index: 10 !important;
    }

    .print-footer-qr {
        width: 50px !important;
        height: 50px !important;
        flex: 0 0 auto !important;
        padding: 4px !important;
        background: #ffffff !important;
        border: 1px solid #E8DFD4 !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 8px rgba(42, 36, 33, 0.12) !important;
    }

    .print-footer-text {
        flex: 0 0 auto !important;
        line-height: 1.25 !important;
        padding: 0 !important;
        direction: rtl !important;
        white-space: normal !important;
        text-align: right !important;
        max-width: 6.4cm !important;
    }

    .print-footer-text p {
        margin: 0 !important;
    }
}

/* Watermark Removal and Web Hiding */
.print-only-section, .print-header-brand, .print-footer {
    display: none;
}

/* --- Fact Sheet Tabs (V2 Data) --- */
.fact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.fact-tabs {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    padding: 0.35rem;
    gap: 0.25rem;
}

.fact-tabs.hidden {
    display: none !important;
}

.fact-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.fact-tab:hover {
    color: var(--color-accent);
}

.fact-tab.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.fact-story-view {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    animation: fadeIn 0.3s ease forwards;
}

.fact-story-view.hidden {
    display: none !important;
}

.fact-story-view p {
    margin-bottom: 1.25rem;
}

.fact-story-view p:last-child {
    margin-bottom: 0;
}

.lesson-plan-panel {
    display: none;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.lesson-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--bg-tertiary);
}

.lesson-plan-kicker {
    display: inline-flex;
    align-items: center;
    color: var(--color-history);
    background: rgba(44, 123, 229, 0.08);
    border: 1px solid rgba(44, 123, 229, 0.2);
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
}

.lesson-plan-header h2 {
    margin: 0 0 0.75rem;
    font-size: 1.8rem;
    color: var(--text-primary);
    line-height: 1.25;
}

.lesson-plan-header p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

.lesson-plan-actions {
    flex: 0 0 auto;
}

.lesson-plan-actions .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: var(--radius-pill);
    padding: 0.75rem 1.2rem;
}

.lesson-plan-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.lesson-plan-meta span {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.lesson-plan-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.lesson-plan-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    background: var(--bg-secondary);
}

.lesson-plan-section h3 {
    margin: 0 0 0.85rem;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.lesson-plan-section p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0;
}

.lesson-plan-section ul {
    margin: 0;
    padding-right: 1.2rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.lesson-plan-stages {
    grid-column: 1 / -1;
    display: grid;
    gap: 0.85rem;
}

.lesson-stage {
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.lesson-stage-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.lesson-stage-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--color-history);
    color: white;
    font-weight: 900;
}

.lesson-stage h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.lesson-stage span {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    font-weight: 700;
}

.lesson-stage p {
    margin: 0.45rem 0 0;
}

.lesson-plan-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

@media (max-width: 760px) {
    .lesson-plan-panel {
        padding: 1.25rem;
    }

    .lesson-plan-header {
        flex-direction: column;
    }

    .lesson-plan-actions,
    .lesson-plan-actions .btn-primary {
        width: 100%;
    }

    .lesson-plan-actions .btn-primary {
        justify-content: center;
    }

    .lesson-plan-grid {
        grid-template-columns: 1fr;
    }
}

.app-with-sidebar {
    display: flex;
    min-height: calc(100vh - 70px);
}
.unified-sidebar {
    width: 380px;
    background: var(--bg-primary);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
}
.main-content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    min-width: 0;
}
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--bg-tertiary);
}
.sidebar-search {
    margin-bottom: 1rem;
    box-shadow: none;
    background: var(--bg-body);
    border-color: var(--color-border);
}
.sidebar-subject-pills {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.sb-subject-btn {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid transparent;
    background: var(--color-border);
    border-radius: var(--radius-pill);
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: 0.2s;
}
.sb-subject-btn.active {
    background: var(--color-accent);
    color: white;
}
.sb-grade-wrapper {
    position: relative;
}
.sb-grade-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-body);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    font-weight: 700;
    cursor: pointer;
}
.sb-grade-checklist {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    z-index: 10;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.sb-grade-checklist label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    cursor: pointer;
}
.sidebar-content-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.sidebar-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: 0.2s;
}
.sidebar-item:hover, .sidebar-item.active {
    border-color: var(--color-accent-light);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}
.sidebar-item.active {
    background: rgba(168, 113, 42, 0.05);
}
.sb-item-thumb {
    width: 80px;
    height: 45px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.sb-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sb-item-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.sb-item-title {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}
.sb-item-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* ============================================================
   HAMBURGER BUTTON + DRAWER
   ============================================================ */
.hamburger-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    transition: 0.2s;
}
.hamburger-btn:hover { background: var(--bg-tertiary); }

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 999;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s;
}
.drawer-overlay.hidden { opacity: 0; pointer-events: none; display: block !important; }

.nav-drawer {
    position: fixed;
    top: 0; right: 0;
    width: min(300px, calc(100vw - 18px));
    max-width: calc(100vw - 18px);
    height: 100vh;
    background: var(--bg-primary);
    box-shadow: -6px 0 24px rgba(0,0,0,0.12);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
}
.nav-drawer.hidden { transform: translateX(100%); display: flex !important; }
.nav-drawer.open { transform: translateX(0); }

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.drawer-header h3 { margin: 0; font-size: 1.1rem; font-weight: 800; color: var(--text-primary); }
.drawer-close {
    background: transparent; border: none; cursor: pointer;
    color: var(--text-secondary); padding: 0.4rem;
    border-radius: var(--radius-sm); transition: 0.2s;
    display: flex; align-items: center;
}
.drawer-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.drawer-links-container { padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.drawer-link {
    display: flex; align-items: center; gap: 0.875rem;
    padding: 0.875rem 1rem; font-size: 1rem; font-weight: 700;
    color: var(--text-primary); text-decoration: none;
    border-radius: var(--radius-lg); background: var(--bg-body);
    border: 1px solid var(--color-border); transition: 0.2s;
    font-family: var(--font-family);
}
.drawer-link:hover, .drawer-link.active {
    background: rgba(168,113,42,0.06); border-color: var(--color-accent-light); color: var(--color-accent);
}
.drawer-link svg { color: var(--text-secondary); transition: 0.2s; flex-shrink: 0; overflow: visible; }
.drawer-link .drawer-link-icon { width: 22px; height: 22px; }
.drawer-link:hover svg, .drawer-link.active svg { color: var(--color-accent); }

/* ============================================================
   CONTENT BROWSER (presentations-view / worksheets-view)
   ============================================================ */
.content-browser-container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.content-browser-header { margin-bottom: 1.5rem; }
.content-browser-header .view-title { font-size: 2rem; font-weight: 800; color: var(--text-primary); margin: 0 0 0.4rem; }
.content-browser-header .view-subtitle { color: var(--text-secondary); font-size: 1rem; margin: 0; }
.content-browser-filters {
    display: flex; align-items: center; gap: 0.875rem;
    flex-wrap: wrap; margin-bottom: 1.75rem;
    padding: 0.875rem 1.25rem; background: var(--bg-primary);
    border: 1px solid var(--color-border); border-radius: var(--radius-lg);
}
.browser-search { flex: 1; min-width: 180px; max-width: 280px; }

.browser-subject-pills { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.browser-pill {
    padding: 0.35rem 0.875rem; border-radius: var(--radius-pill);
    border: 1px solid var(--color-border); background: var(--bg-body);
    color: var(--text-secondary); font-size: 0.85rem; font-weight: 700;
    cursor: pointer; transition: 0.2s; font-family: var(--font-family);
}
.browser-pill:hover { border-color: var(--color-accent-light); color: var(--color-accent); background: rgba(168,113,42,0.05); }
.browser-pill.active { background: var(--color-accent); color: white; border-color: var(--color-accent); }

.browser-grade-wrapper { position: relative; }
.browser-grade-btn {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.875rem; border-radius: var(--radius-pill);
    border: 1px solid var(--color-border); background: var(--bg-body);
    color: var(--text-secondary); font-size: 0.85rem; font-weight: 700;
    cursor: pointer; transition: 0.2s; font-family: var(--font-family); white-space: nowrap;
}
.browser-grade-btn:hover { border-color: var(--color-accent-light); color: var(--color-accent); }
.browser-grade-checklist {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 190px; background: var(--bg-primary);
    border: 1px solid var(--color-border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 0.75rem; z-index: 200;
    display: flex; flex-direction: column; gap: 0.3rem;
    max-height: 320px; overflow-y: auto;
}
.browser-grade-checklist.hidden {
    display: none !important;
}
.browser-grade-label {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.875rem; font-weight: 600; color: var(--text-primary);
    cursor: pointer; padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm); transition: 0.15s; user-select: none;
}
.browser-grade-label:hover { background: var(--bg-tertiary); }
.browser-grade-label input { accent-color: var(--color-accent); cursor: pointer; }

.content-browser-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.25rem; }
.browser-card {
    background: var(--bg-primary); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); overflow: hidden; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex; flex-direction: column;
    color: inherit;
}
.browser-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--color-accent-light); }
.browser-card-thumb {
    width: 100%; aspect-ratio: 16/9; background: var(--bg-tertiary);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.browser-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.browser-card-fallback { display: flex; align-items: center; justify-content: center; font-size: 2.5rem; width: 100%; height: 100%; }
.worksheet-thumb { background: rgba(168,113,42,0.05); }
.lesson-plan-thumb { background: rgba(44,123,229,0.06); }
.browser-card-info { padding: 0.75rem 1rem; }
.browser-card-title {
    font-size: 0.88rem; font-weight: 700; color: var(--text-primary);
    line-height: 1.3; margin-bottom: 0.25rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.browser-card-meta { font-size: 0.72rem; color: var(--text-tertiary); }
.browser-empty { grid-column: 1/-1; text-align: center; padding: 4rem 2rem; color: var(--text-tertiary); font-size: 1rem; font-weight: 700; }

/* ============================================================
   SUPPORT VIEW
   ============================================================ */
.support-container {
    max-width: 800px;
    margin: 4rem auto 6rem;
    padding: 0 1.5rem;
}

.support-hero {
    text-align: center;
    margin-bottom: 3.5rem;
}

.support-icon-wrap {
    width: 100px;
    height: 100px;
    background: var(--color-bible-light);
    color: var(--color-bible);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: var(--shadow-md);
}

.support-title {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.support-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
}

.support-card {
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 3rem;
    box-shadow: var(--shadow-lg);
}

.support-section {
    margin-bottom: 2rem;
}

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

.support-section-title {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    text-align: center;
}

.support-email-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-bible);
    padding: 1.5rem;
    background: var(--bg-body);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--color-border);
    transition: all var(--transition-fast);
}

.support-email-link:hover {
    background: var(--color-bible-light);
    border-color: var(--color-bible);
    transform: translateY(-2px);
}

.support-divider {
    height: 1px;
    background: var(--color-border);
    margin: 3rem 0;
}

.support-socials {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: var(--bg-body);
    border: 1px solid var(--color-border);
    font-weight: 700;
    transition: all var(--transition-fast);
}

.social-btn svg {
    color: var(--text-tertiary);
}

.social-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    background: white;
}

.social-instagram:hover { border-color: #E1306C; color: #E1306C; }
.social-instagram:hover svg { color: #E1306C; }

.social-facebook:hover { border-color: #1877F2; color: #1877F2; }
.social-facebook:hover svg { color: #1877F2; }

.social-youtube:hover { border-color: #FF0000; color: #FF0000; }
.social-youtube:hover svg { color: #FF0000; }

.social-tiktok:hover { border-color: #000000; color: #000000; }
.social-tiktok:hover svg { color: #000000; }

/* --- Topic View Modes --- */

/* === TOPIC RESOURCE MENU === */
#topic-view.mode-resource-menu .presentation-banner,
#topic-view.mode-resource-menu .split-layout {
    display: none !important;
}

.topic-resource-menu {
    --topic-resource-color: var(--color-bible);
    --topic-resource-light: var(--color-bible-light);
    max-width: 920px;
    margin: 0 auto 2.5rem;
}

body[data-subject="civics"] .topic-resource-menu {
    --topic-resource-color: var(--color-civics);
    --topic-resource-light: var(--color-civics-light);
}

body[data-subject="history"] .topic-resource-menu {
    --topic-resource-color: var(--color-history);
    --topic-resource-light: var(--color-history-light);
}

.topic-resource-menu-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.topic-resource-menu-header h2 {
    font-size: clamp(1.55rem, 3vw, 2rem);
    margin-bottom: 0.4rem;
}

.topic-resource-menu-header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.topic-resource-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.topic-resource-button {
    min-height: 112px;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.4rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.topic-resource-button:hover,
.topic-resource-button:focus-visible {
    transform: translateY(-3px);
    border-color: var(--topic-resource-color);
    box-shadow: var(--shadow-md);
    outline: none;
}

.topic-resource-icon {
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
    display: grid;
    place-items: center;
    color: var(--topic-resource-color);
    background: var(--topic-resource-light);
    border-radius: 18px;
}

.topic-resource-icon svg {
    width: 29px;
    height: 29px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topic-resource-copy {
    min-width: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
}

.topic-resource-copy strong {
    color: var(--text-primary);
    font-size: 1.15rem;
}

.topic-resource-copy small {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.topic-resource-arrow {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    fill: none;
    stroke: var(--text-tertiary);
    stroke-width: 2.3;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform var(--transition-fast), stroke var(--transition-fast);
}

.topic-resource-button:hover .topic-resource-arrow,
.topic-resource-button:focus-visible .topic-resource-arrow {
    stroke: var(--topic-resource-color);
    transform: translateX(-4px);
}

@media (max-width: 700px) {
    .topic-resource-actions {
        grid-template-columns: 1fr;
    }

    .topic-resource-button {
        min-height: 96px;
        padding: 1rem;
    }

    .topic-resource-icon {
        width: 52px;
        height: 52px;
        flex-basis: 52px;
    }
}

/* === INTERNAL BIBLE READER === */
.bible-reader-panel {
    --bible-reader-zoom: 1;
    max-width: 1040px;
    margin: 0 auto 2.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.bible-reader-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem 1.75rem;
    background: linear-gradient(135deg, var(--color-bible-light), var(--bg-primary));
    border-bottom: 1px solid var(--color-border);
}

.bible-reader-kicker {
    display: block;
    color: var(--color-bible);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.bible-reader-heading h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    margin-bottom: 0.2rem;
}

.bible-reader-heading p {
    color: var(--text-secondary);
    font-weight: 700;
}

.bible-reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--color-border);
}

.bible-reader-tool-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.bible-reader-tool-label {
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 800;
    margin-left: 0.2rem;
}

.bible-reader-zoom button,
.bible-marker-eraser,
.bible-marker-clear {
    min-width: 40px;
    min-height: 38px;
    padding: 0.45rem 0.75rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-weight: 800;
    transition: border-color var(--transition-fast), transform var(--transition-fast), background var(--transition-fast);
}

.bible-reader-zoom button {
    font-size: 1.1rem;
}

#btn-bible-font-reset {
    min-width: 68px;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

.bible-reader-zoom button:hover,
.bible-reader-zoom button:focus-visible,
.bible-marker-eraser:hover,
.bible-marker-eraser:focus-visible,
.bible-marker-clear:hover,
.bible-marker-clear:focus-visible {
    border-color: var(--color-bible);
    background: var(--color-bible-light);
    transform: translateY(-1px);
    outline: none;
}

.bible-marker-color {
    width: 34px;
    height: 34px;
    border: 3px solid var(--bg-primary);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--color-border);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.bible-marker-color[data-marker-color="yellow"] { background: #ffe88a; }
.bible-marker-color[data-marker-color="green"] { background: #bdecc8; }
.bible-marker-color[data-marker-color="blue"] { background: #bcdffb; }
.bible-marker-color[data-marker-color="pink"] { background: #f8bfd5; }

.bible-marker-color:hover,
.bible-marker-color:focus-visible,
.bible-marker-color.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px var(--color-bible);
    outline: none;
}

.bible-marker-eraser {
    display: grid;
    place-items: center;
    padding: 0;
}

.bible-marker-eraser.active {
    color: white;
    background: var(--color-bible);
    border-color: var(--color-bible);
}

.bible-marker-clear {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.bible-reader-help {
    padding: 0.8rem 1.75rem 0;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.bible-reader-content {
    padding: 1.5rem clamp(1rem, 4vw, 3rem) 2.5rem;
    font-size: calc(1.32rem * var(--bible-reader-zoom));
    line-height: 2.05;
    transition: font-size var(--transition-fast);
}

.bible-reader-loading,
.bible-reader-error,
.bible-reader-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.bible-reader-loading::before {
    content: '';
    display: block;
    width: 34px;
    height: 34px;
    margin: 0 auto 1rem;
    border: 3px solid var(--color-bible-glow);
    border-top-color: var(--color-bible);
    border-radius: 50%;
    animation: bibleReaderSpin 0.8s linear infinite;
}

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

.bible-reader-chapter {
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.55rem;
    color: var(--color-bible);
    font-size: 1.12em;
    border-bottom: 2px solid var(--color-bible-glow);
}

.bible-reader-chapter:first-child {
    margin-top: 0;
}

.bible-verse {
    display: grid;
    grid-template-columns: 2.2rem minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    margin: 0.2rem -0.65rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
}

.bible-verse-number {
    display: inline-grid;
    place-items: center;
    min-width: 1.9rem;
    height: 1.9rem;
    margin-top: 0.2rem;
    color: var(--color-bible);
    background: var(--color-bible-light);
    border-radius: 50%;
    font-size: 0.68em;
    font-weight: 900;
    line-height: 1;
}

.bible-verse-text {
    color: var(--text-primary);
    font-family: "Noto Serif Hebrew", "Times New Roman", serif;
}

.bible-word {
    display: inline;
    padding: 0.06em 0.12em;
    margin: 0 -0.02em;
    border-radius: 0.28em;
    cursor: pointer;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.bible-word:hover,
.bible-word:focus-visible {
    background: var(--color-bible-light);
    box-shadow: 0 0 0 2px var(--color-bible-glow);
    outline: none;
}

.bible-word[data-highlight="yellow"] { background: rgba(255, 232, 138, 0.72); }
.bible-word[data-highlight="green"] { background: rgba(189, 236, 200, 0.72); }
.bible-word[data-highlight="blue"] { background: rgba(188, 223, 251, 0.72); }
.bible-word[data-highlight="pink"] { background: rgba(248, 191, 213, 0.72); }

.bible-reader-error button {
    display: inline-flex;
    margin-top: 1rem;
}

.bible-reader-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.5rem;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    border-top: 1px solid var(--color-border);
    font-size: 0.82rem;
}

.bible-reader-footer a {
    color: var(--color-bible);
    font-weight: 800;
}

@media (max-width: 700px) {
    .bible-reader-header,
    .bible-reader-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .bible-reader-tool-group {
        justify-content: center;
    }

    .bible-reader-tool-label {
        width: 100%;
        margin: 0 0 0.2rem;
        text-align: center;
    }

    .bible-reader-help {
        text-align: center;
    }

    .bible-reader-content {
        line-height: 1.9;
    }

}

/* === SUMMARY MODE === */
#topic-view.mode-summary .practice-lab,
#topic-view.mode-summary .presentation-banner {
    display: none !important;
}

#topic-view.mode-summary .split-layout {
    display: block;
}

#topic-view.mode-summary .fact-sheet {
    max-width: 900px;
    margin: 0 auto;
}

/* === WORKSHEET MODE === */
#topic-view.mode-worksheet .presentation-banner,
#topic-view.mode-worksheet .fact-header,
#topic-view.mode-worksheet #fact-story-view,
#topic-view.mode-worksheet #fact-list-container,
#topic-view.mode-worksheet .worksheet-title,
#topic-view.mode-worksheet .print-header-brand {
    display: none !important;
}

#topic-view.mode-worksheet .split-layout { 
    display: flex !important; 
    flex-direction: column !important;
    gap: 0 !important;
}

#topic-view.mode-worksheet .practice-lab { 
    display: none !important;
}

#topic-view.mode-worksheet .fact-sheet { 
    display: block !important; 
    max-width: 1100px !important;
    width: 100% !important;
    margin: 0 auto 2.25rem !important;
    padding: 0 !important;
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    overflow: visible !important;
    background: transparent !important;
    box-shadow: none !important;
}

.print-only-content { display: none; }

#topic-view.mode-worksheet #worksheet-questions-container {
    display: block;
    width: 100%;
    margin: 0 auto 2.5rem;
    position: relative;
    z-index: 1;
    clear: both;
}

#topic-view.mode-worksheet .worksheet-print-divider {
    display: none;
}

#topic-view.mode-worksheet .worksheet-header-screen {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 2.5rem !important;
    padding: 1.25rem 1.5rem 1.5rem;
    text-align: center;
    position: relative;
    z-index: 1;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

#topic-view.mode-worksheet #btn-open-worksheet-print,
#topic-view.mode-worksheet #btn-open-worksheet-print-all {
    width: min(100%, 560px) !important;
    max-width: 560px !important;
    min-height: 76px !important;
    margin: 0.75rem auto 0 !important;
    padding: 1rem 1.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.9rem !important;
    border-radius: var(--radius-lg) !important;
    font-size: clamp(1.05rem, 2.2vw, 1.45rem) !important;
    line-height: 1.25 !important;
    white-space: normal !important;
    text-align: center !important;
    position: static !important;
    transform: none !important;
}

#topic-view.mode-worksheet #btn-open-worksheet-print {
    background-color: var(--color-history) !important;
}

#topic-view.mode-worksheet #btn-open-worksheet-print-all {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border: 2px solid var(--color-border) !important;
}

#topic-view.mode-worksheet .practice-lab {
    position: relative;
    z-index: 0;
}

.worksheet-selector {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.worksheet-selector-title {
    width: 100%;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.worksheet-selector-btn {
    border: 2px solid var(--color-border);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-pill);
    padding: 0.65rem 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.worksheet-selector-btn:hover,
.worksheet-selector-btn.active {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
    color: var(--color-accent);
}

.worksheet-locked-preview {
    width: min(100%, 760px);
    margin: 0 auto 2.5rem;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    text-align: center;
    color: var(--text-primary);
    background: linear-gradient(145deg, var(--bg-primary), var(--bg-secondary));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.worksheet-locked-preview h3 {
    margin: 0.65rem 0 0.5rem;
    font-size: clamp(1.2rem, 3vw, 1.55rem);
}

.worksheet-locked-preview p {
    margin: 0;
    color: var(--text-secondary);
    font-weight: 700;
}

.worksheet-locked-icon {
    display: inline-grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--color-accent-light);
    font-size: 1.35rem;
}

.worksheet-unavailable {
    border-style: dashed;
}

@media print {
    #topic-view.mode-worksheet .print-header-brand,
    #topic-view.mode-worksheet .print-only-content {
        display: block !important;
    }
    #topic-view.mode-worksheet .print-only-content .worksheet-title {
        display: block !important;
    }
    #topic-view.mode-worksheet .practice-lab,
    #topic-view.mode-worksheet .worksheet-header-screen,
    .btn-fullscreen,
    .btn-toggle-fullscreen {
        display: none !important;
    }
}

/* === PRESENTATION MODE === */
#topic-view.mode-presentation .fact-sheet,
#topic-view.mode-presentation .practice-lab {
    display: none !important;
}

#topic-view.mode-presentation .split-layout {
    display: block;
}

#topic-view.mode-presentation .presentation-banner {
    max-width: 900px;
    margin: 0 auto 2rem;
}

/* === BIBLE TEXT MODE === */
#topic-view.mode-bible-text .presentation-banner,
#topic-view.mode-bible-text .split-layout {
    display: none !important;
}

#topic-view.mode-bible-text .bible-reader-panel {
    display: block;
}

/* === INTERACTIVE PRACTICE MODE === */
#topic-view.mode-practice .presentation-banner,
#topic-view.mode-practice .fact-sheet,
#topic-view.mode-practice .lesson-plan-panel {
    display: none !important;
}

#topic-view.mode-practice .split-layout {
    display: block;
}

#topic-view.mode-practice .practice-lab {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto 2.5rem;
}

/* === LESSON PLAN MODE === */
#topic-view.mode-lesson-plan .presentation-banner,
#topic-view.mode-lesson-plan .fact-sheet,
#topic-view.mode-lesson-plan .practice-lab {
    display: none !important;
}

#topic-view.mode-lesson-plan .split-layout {
    display: block;
}

#topic-view.mode-lesson-plan .lesson-plan-panel {
    display: block;
    max-width: 1000px;
    margin: 0 auto 2.5rem;
}

.btn-interactive-quiz {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1.25rem;
    margin-top: 2rem;
    background: var(--text-primary);
    color: white;
    border-radius: var(--radius-lg);
    font-size: 1.15rem;
    font-weight: 800;
    transition: 0.3s;
}

.btn-interactive-quiz:hover {
    background: var(--color-accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

@media (max-width: 600px) {
    .support-title { font-size: 2.25rem; }
    .support-email-link { font-size: 1.1rem; padding: 1rem; }
    .support-socials { grid-template-columns: 1fr 1fr; }
    .support-card { padding: 2rem 1.5rem; }
}

/* --- Summaries View Highlights --- */
#summaries-view .browser-card-thumb {
    background: var(--color-bible-light);
    color: var(--color-bible);
}

#summaries-view .browser-card:hover {
    border-color: var(--color-bible);
}

/* Fix for the "Stray Square" bug - ensuring all hidden elements are truly gone */
.hidden, [hidden], .browser-grade-checklist.hidden, .search-autocomplete.hidden, .filter-dropdown.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important; 
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
}

/* Home Search Specifics — push text past the magnifying-glass icon */
.home-search .search-input {
    padding-right: 3.5rem !important;
}

.home-search .search-icon {
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}

#summaries-grid .browser-card-fallback {
    font-size: 3rem;
}

@media (max-width: 768px) {
    .content-browser-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .browser-search {
        max-width: none;
    }
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    font-weight: 700;
    transition: all var(--transition-fast);
    color: white;
    border: none;
}
.social-btn svg {
    color: white;
}
.social-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    opacity: 0.9;
}
.social-instagram { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); }
.social-facebook { background: #1877F2; }
.social-youtube { background: #FF0000; }
.social-tiktok { background: #000000; }

body.dark-mode {
    --bg-primary: #1E1E1E;
    --bg-secondary: #121212;
    --bg-tertiary: #2D2D2D;
    --bg-body: #121212;
    
    --text-primary: #FFFFFF;
    --text-secondary: #AAAAAA;
    --text-tertiary: #888888;
    
    --color-civics: #7A9CE6;
    --color-civics-glow: rgba(59, 89, 152, 0.3);
    --color-civics-light: #2A3B66;
    
    --color-bible: #E2B278;
    --color-bible-glow: rgba(168, 113, 42, 0.3);
    --color-bible-light: #4A3518;
    
    --color-history: #9DB862;
    --color-history-glow: rgba(94, 125, 58, 0.3);
    --color-history-light: #33441F;
    
    --color-accent: #6FA2FF;
    --color-accent-light: #3D3D3D;
    --color-border: #4A4A4A;
    --color-success-light: #2D4A36;
    --color-error-light: #6A2121;
}

/* Ensure major elements in Dark Mode are readable without breaking buttons */
body.dark-mode, 
body.dark-mode p, 
body.dark-mode h1, 
body.dark-mode h2, 
body.dark-mode h3, 
body.dark-mode h4,
body.dark-mode span:not(.btn-filter span),
body.dark-mode li {
    color: var(--text-primary);
}

body.dark-mode .logo {
    color: #FFFFFF !important;
}

body.dark-mode .btn-filter {
    background-color: #333333 !important;
    color: #FFFFFF !important;
    border: 2px solid #555555 !important;
}

body.dark-mode .btn-filter svg {
    stroke: #FFFFFF !important;
}

body.dark-mode .navbar {
    background-color: rgba(30, 30, 30, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .nav-drawer {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

body.dark-mode .practice-lab {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

body.dark-mode .grade-card {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--color-border);
}

body.dark-mode .option-btn {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--color-border);
}

body.dark-mode .option-btn:hover:not(:disabled) {
    background-color: var(--bg-tertiary);
}

body.dark-mode .option-btn.correct { color: #A7F3D0 !important; }
body.dark-mode .option-btn.incorrect { color: #FECACA !important; }

/* Filter Dropdown in Dark Mode */
body.dark-mode .filter-dropdown {
    background-color: #2D2D2D !important;
    border-color: #4A4A4A !important;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4) !important;
}

body.dark-mode .filter-section-label {
    color: var(--text-tertiary) !important;
}

body.dark-mode .filter-option {
    background-color: #1E1E1E !important;
    color: var(--text-secondary) !important;
}

body.dark-mode .filter-option.active {
    background-color: var(--color-accent) !important;
    color: #FFFFFF !important;
}

body.dark-mode .filter-grade-toggle {
    background-color: #1E1E1E !important;
    color: var(--text-primary) !important;
    border-color: #4A4A4A !important;
}

body.dark-mode .filter-divider {
    border-color: #4A4A4A !important;
}

body.dark-mode .search-autocomplete {
    background-color: #1E1E1E !important;
    border-color: #4A4A4A !important;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4) !important;
}

body.dark-mode .autocomplete-item {
    color: var(--text-primary) !important;
}

body.dark-mode .autocomplete-item:hover {
    background-color: #2D2D2D !important;
}

body.dark-mode .autocomplete-item .item-meta {
    color: var(--text-tertiary) !important;
}

body.font-large {
    font-size: 1.2rem;
}
body.font-large h1 { font-size: 2.8rem; }
body.font-large h2 { font-size: 2.2rem; }
body.font-large h3 { font-size: 1.6rem; }
body.font-large p, body.font-large li, body.font-large .fact-story-view, body.font-large .fact-list { font-size: 1.3rem; line-height: 1.9; }

.settings-container {
    max-width: 600px;
    margin: 4rem auto 6rem;
    padding: 3rem;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
}
.subjects-section h2 {
    font-size: 2.25rem;
    margin-bottom: 3.5rem;
    margin-top: -1rem; /* Lift it up a bit as requested */
    text-align: center;
    position: relative;
    z-index: 5;
}
.settings-title {
    font-size: 2.5rem;
    margin-bottom: 2.5rem;
    text-align: center;
}
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--color-border);
}
.settings-row:last-child {
    border-bottom: none;
}
.settings-label {
    font-size: 1.25rem;
    font-weight: 700;
}
.settings-toggle {
    position: relative;
    width: 60px;
    height: 34px;
}
.settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--color-border);
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--color-accent);
}
input:checked + .slider:before {
    transform: translateX(26px);
}


/* --- Auth Modal --- */
.auth-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    width: 90%; max-width: 400px;
    max-height: 90vh; /* Enable scroll if content is too tall */
    overflow-y: auto;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.auth-modal.hidden {
    display: none !important;
}
.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.auth-header h2 { font-size: 1.5rem; margin: 0; }
.auth-body { display: flex; flex-direction: column; gap: 1rem; }
.btn-google {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: white; border: 1px solid var(--color-border);
    color: #444; border-radius: var(--radius-pill); padding: 0.75rem;
    font-weight: 700; cursor: pointer; transition: 0.2s;
    font-family: inherit; font-size: 1rem;
}
.btn-google:hover { background: #f5f5f5; box-shadow: var(--shadow-sm); }
.auth-divider { text-align: center; color: var(--text-tertiary); font-size: 0.85rem; font-weight: 600; }
.auth-input {
    width: 100%; padding: 0.75rem 1rem;
    border-radius: var(--radius-md); border: 1px solid var(--color-border);
    font-family: inherit; font-size: 1rem;
    background: var(--bg-body); color: var(--text-primary);
}
.auth-input:focus { outline: none; border-color: var(--color-accent); }

.upgrade-modal {
    max-width: 980px;
    width: min(94vw, 980px);
}

.upgrade-body {
    text-align: center;
    gap: 1.25rem;
}

.upgrade-intro {
    margin: 0;
    padding: 1rem 1.25rem;
    border: 1px solid rgba(241, 196, 15, 0.42);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #fffbe6, #fff3cd);
    color: #745700;
    line-height: 1.6;
}

.upgrade-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
}

.pricing-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    text-align: right;
}

.pricing-card-featured {
    border-color: #f1c40f;
    box-shadow: 0 14px 32px rgba(241, 196, 15, 0.2);
}

.pricing-card-plus {
    border-color: rgba(241, 196, 15, 0.7);
}

.pricing-ribbon {
    position: absolute;
    top: -12px;
    left: 16px;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-pill);
    background: #f1c40f;
    color: #5f4700;
    font-weight: 800;
    font-size: 0.85rem;
}

.pricing-card-header h3 {
    margin: 0 0 0.2rem;
    font-size: 1.35rem;
}

.pricing-card-header p {
    margin: 0 0 0.75rem;
    color: var(--text-secondary);
    font-weight: 700;
}

.pricing-price {
    color: var(--text-primary);
    font-size: 1.55rem;
    font-weight: 900;
}

.pricing-price span {
    display: block;
    margin-top: 0.2rem;
    color: var(--text-tertiary);
    font-size: 0.86rem;
    font-weight: 700;
}

.pricing-features {
    flex: 1;
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.pricing-button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    color: #fff;
    text-decoration: none;
    font-weight: 900;
    box-shadow: 0 8px 20px rgba(241, 196, 15, 0.28);
    transition: transform 0.2s, box-shadow 0.2s;
}

.pricing-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(241, 196, 15, 0.34);
}

.upgrade-security {
    margin: 0;
    color: var(--text-tertiary);
    font-size: 0.92rem;
    line-height: 1.5;
}

@media (max-width: 820px) {
    .upgrade-options {
        grid-template-columns: 1fr;
    }

    .upgrade-modal {
        width: 94vw;
        padding: 1.5rem;
    }
}

.user-profile {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    background: var(--bg-tertiary); padding: 0.25rem 1rem 0.25rem 0.25rem;
    border-radius: var(--radius-pill); font-family: inherit;
    transition: 0.2s;
}
.user-profile:hover {
    background: var(--color-border);
}
.user-profile img {
    width: 32px; height: 32px; border-radius: 50%; border: 2px solid white;
}
.user-profile span {
    font-weight: 700; font-size: 0.95rem; margin-right: 5px;
}
.user-dropdown {
    position: absolute; top: calc(100% + 10px); left: 0;
    background: var(--bg-primary); padding: 0.5rem;
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-md); z-index: 100;
    min-width: 130px;
}
.user-dropdown.hidden {
    display: none !important;
}
.btn-logout {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 0.5rem 0.75rem; color: var(--color-error); font-weight: 700;
    font-family: inherit; background: transparent; border: none;
    cursor: pointer; border-radius: var(--radius-sm);
    text-align: right; transition: 0.2s;
}
.btn-logout:hover { background: var(--color-error-light); }


/* --- Accessibility Controls --- */
.stepper {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    padding: 0.25rem 0.5rem;
}
.stepper button {
    background: var(--bg-primary); border: none; font-size: 1.25rem; font-weight: bold;
    width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--text-primary);
    display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
}
.stepper span { font-weight: bold; min-width: 40px; text-align: center; }
.btn-reset-a11y {
    width: 100%; border: 1px solid var(--color-border); padding: 0.75rem;
    border-radius: var(--radius-pill); background: var(--bg-tertiary); color: var(--text-primary);
    font-weight: bold; cursor: pointer; margin-top: 1rem; transition: 0.3s; font-family: inherit;
}
.btn-reset-a11y:hover { background: var(--color-border); }

.privacy-link {
    display: block; text-align: center; margin-top: 3rem; color: var(--color-accent);
    text-decoration: underline; font-weight: bold; font-size: 1.1rem;
}

.accessibility-statement {
    margin-top: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
    color: var(--text-secondary);
}
.accessibility-statement-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 1.35rem;
    font-weight: 800;
    padding: 0;
    text-align: right;
}
.accessibility-statement-icon {
    flex: 0 0 auto;
    transition: transform 0.2s ease;
}
.accessibility-statement-toggle[aria-expanded="true"] .accessibility-statement-icon {
    transform: rotate(180deg);
}
.accessibility-statement-toggle + div {
    margin-top: 0.9rem;
}
.accessibility-statement h4 {
    margin: 1.25rem 0 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}
.accessibility-statement p,
.accessibility-statement li {
    line-height: 1.8;
    margin-bottom: 0.65rem;
}
.accessibility-statement a {
    color: var(--color-accent);
    font-weight: 800;
    text-decoration: underline;
}

body.high-contrast {
    --bg-body: #ffffff;
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3f4f6;
    --text-primary: #000000;
    --text-secondary: #111111;
    --text-tertiary: #333333;
    --color-border: #000000;
    --color-accent: #0047ff;
}
body.high-contrast a,
body.high-contrast button {
    text-decoration-thickness: 2px;
}
body.high-contrast button,
body.high-contrast input,
body.high-contrast .topic-card,
body.high-contrast .grade-card,
body.high-contrast .subject-card,
body.high-contrast .settings-row,
body.high-contrast .privacy-container,
body.high-contrast .accessibility-statement {
    border-color: #000000 !important;
}

/* Crawlable card links and build-time SEO fallback pages */
.subject-card:focus-visible,
.grade-card:focus-visible,
.topic-card:focus-visible,
.browser-card:focus-visible,
.autocomplete-item:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

body.seo-prerendered #breadcrumb-container,
body.seo-prerendered #app-content > .view {
    display: none !important;
}

.seo-prerendered-content {
    width: min(1100px, calc(100% - 2rem));
    margin: 2rem auto 4rem;
    color: var(--text-primary);
}

.seo-prerendered-content article,
.seo-prerendered-panel {
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: clamp(1.25rem, 3vw, 2.5rem);
}

.seo-prerendered-content h1 {
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1.15;
    margin-bottom: 0.75rem;
}

.seo-prerendered-content h2 {
    font-size: clamp(1.35rem, 3vw, 1.8rem);
    margin: 2rem 0 0.75rem;
}

.seo-prerendered-content h3 {
    font-size: 1.15rem;
    margin: 1.25rem 0 0.5rem;
}

.seo-prerendered-content p,
.seo-prerendered-content li {
    line-height: 1.75;
}

.seo-prerendered-content ul,
.seo-prerendered-content ol {
    padding-inline-start: 1.5rem;
}

.seo-prerendered-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.seo-prerendered-breadcrumbs a,
.seo-prerendered-links a,
.seo-prerendered-grid a {
    color: var(--color-accent);
    font-weight: 700;
}

.seo-prerendered-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.seo-prerendered-grid > a,
.seo-prerendered-grid > section {
    display: block;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
}

.seo-prerendered-grid small {
    display: block;
    margin-top: 0.35rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.seo-prerendered-meta {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.seo-prerendered-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin: 1.5rem 0;
}

.seo-prerendered-stage {
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
    margin-top: 1rem;
}
body.high-contrast :focus-visible {
    outline: 4px solid #ffbf00 !important;
    outline-offset: 3px !important;
}
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
}

/* --- Privacy View --- */
.privacy-container {
    max-width: 800px; margin: 4rem auto 6rem; padding: 3rem;
    background: var(--bg-primary); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg); border: 1px solid var(--color-border);
}
.privacy-container h1 { font-size: 2.25rem; margin-bottom: 2rem; color: var(--color-accent); }
.privacy-container h2 { font-size: 1.5rem; margin-top: 2rem; margin-bottom: 1rem; }
.privacy-container p, .privacy-container li { font-size: 1.1rem; line-height: 1.8; color: var(--text-secondary); margin-bottom: 1rem; }
body.lab-fullscreen-active .fact-sheet,
body.lab-fullscreen-active .navbar,
body.lab-fullscreen-active .breadcrumbs-container {
    display: none !important;
}

.practice-lab.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 100000 !important;
    margin: 0 !important;
    padding: 0 !important; /* Managed by quiz-container */
    background: var(--bg-body) !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    display: block !important;
}

.practice-lab.fullscreen .quiz-container {
    max-width: 1100px;
    margin: 4rem auto;
    padding: 2rem;
    background: transparent;
}

.practice-lab.fullscreen .question-text {
    font-size: 2.2rem !important;
    line-height: 1.4 !important;
    margin-bottom: 3rem !important;
}

.practice-lab.fullscreen .options-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.practice-lab.fullscreen .option-btn {
    padding: 1.5rem !important;
    font-size: 1.3rem !important;
}

.practice-lab.fullscreen .lab-header {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 1.5rem 4rem;
    background: var(--bg-primary);
    border-bottom: 2px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100005;
}

.practice-lab.fullscreen .btn-fullscreen {
    position: relative;
    top: auto;
    left: auto;
    margin: 0;
    padding: 0.6rem 1.2rem;
    background: var(--color-error-light);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.practice-lab.fullscreen .lab-header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.practice-lab.fullscreen .btn-print-worksheet {
    display: none !important;
}

.btn-fullscreen {
    display: flex; align-items: center; gap: 8px;
    padding: 0.5rem 1rem; border-radius: var(--radius-pill);
    background: var(--bg-tertiary); color: var(--text-primary);
    font-weight: 700; cursor: pointer; transition: 0.2s;
}
.btn-fullscreen:hover { background: var(--color-border); }

body.dark-mode .btn-fullscreen { background: #333; color: white; }

/* === DARK MODE REFINEMENTS === */
body.dark-mode .btn-google {
    background: #2D2D2D;
    color: #FFFFFF;
    border-color: #4A4A4A;
}
body.dark-mode .btn-google:hover {
    background: #3D3D3D;
}
body.dark-mode .user-profile {
    background: #2D2D2D;
    border: 1px solid var(--color-border);
}
body.dark-mode .user-profile:hover {
    background: #3D3D3D;
}
body.dark-mode .user-profile img {
    border-color: var(--color-accent);
}
body.dark-mode .user-dropdown {
    background: #2D2D2D;
    border-color: #4A4A4A;
}

/* ==========================================================================
   MOBILE POLISH
   ========================================================================== */
@media (max-width: 768px) {
    .nav-container {
        min-height: 64px;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .nav-container > div:first-child {
        gap: 0.65rem !important;
        min-width: 0;
    }

    .logo {
        font-size: 1.55rem;
        letter-spacing: 0;
        white-space: nowrap;
    }

    .hamburger-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        padding: 0;
        border-radius: var(--radius-pill);
        flex: 0 0 auto;
    }

    .nav-links {
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        flex: 0 0 auto;
        gap: 0.5rem;
        min-width: 0;
    }

    .btn-login {
        min-height: 40px;
        padding: 0.45rem 0.85rem;
        border-width: 1px;
        font-size: 0.92rem;
        white-space: nowrap;
        gap: 0.35rem;
        box-shadow: var(--shadow-sm);
        background: var(--bg-primary);
    }

    .btn-login svg {
        width: 17px;
        height: 17px;
    }

    .user-profile:not(.hidden) {
        display: flex !important;
    }

    .user-profile {
        max-width: 132px;
        padding: 0.25rem 0.7rem 0.25rem 0.3rem;
        gap: 0.35rem;
    }

    .user-profile span {
        max-width: 82px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.86rem;
    }

    .user-dropdown {
        left: 0;
        right: auto;
        min-width: 175px;
        z-index: 1200;
    }

    .nav-drawer {
        width: min(88vw, 320px);
        max-width: calc(100vw - 14px);
    }

    .drawer-links-container {
        padding: 1rem 0.85rem;
    }

    .drawer-link {
        min-height: 48px;
        border-radius: var(--radius-md);
        padding-inline: 0.9rem;
    }

    .hero {
        margin: 3rem auto 2.75rem;
        padding: 0 1.15rem;
    }

    .hero-title {
        font-size: 2.15rem;
        line-height: 1.16;
        letter-spacing: 0;
        margin-bottom: 1rem;
    }

    .hero-subtitle {
        font-size: 1rem;
        line-height: 1.65;
        margin-bottom: 2rem;
    }

    .search-wrapper {
        max-width: none;
        width: 100%;
    }

    .search-container {
        width: 100%;
        padding: 0.35rem;
        border-width: 1px;
        box-shadow: var(--shadow-sm);
    }

    .search-input {
        min-width: 0;
        font-size: 0.98rem;
        padding: 0.75rem 3rem 0.75rem 0.5rem;
    }

    .home-search .search-input {
        padding-right: 2.85rem !important;
    }

    .search-icon,
    .home-search .search-icon {
        right: 1rem;
        width: 18px;
        height: 18px;
    }

    .btn-filter {
        width: 44px;
        height: 44px;
        padding: 0;
        align-items: center;
        justify-content: center;
    }

    .filter-dropdown:not(.hidden) {
        display: flex !important;
        flex-direction: column;
        left: 0;
        right: 0;
        width: 100%;
        padding: 0.9rem;
        gap: 0.75rem;
    }

    .filter-pills {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
    }

    .filter-option,
    .filter-grade-toggle,
    .filter-grade-chip,
    .browser-pill,
    .browser-grade-btn {
        min-height: 40px;
        justify-content: center;
        text-align: center;
    }

    .subjects-section {
        margin-bottom: 3.5rem;
        padding: 0 1rem;
    }

    .subjects-section h2 {
        font-size: 2rem;
        line-height: 1.18;
        letter-spacing: 0;
        margin: 0 0 2rem;
    }

    .subjects-grid {
        gap: 1.25rem;
    }

    .subject-card {
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
    }

    .card-image {
        height: 168px;
    }

    .card-content {
        padding: 1.25rem;
    }

    .subject-card h3 {
        font-size: 1.35rem;
    }

    .subject-card p {
        font-size: 0.98rem;
        margin-bottom: 1.1rem;
    }

    .btn-start {
        align-self: stretch;
        justify-content: center;
        min-height: 46px;
        padding: 0.7rem 1rem;
    }

    .content-browser-container {
        padding: 1.5rem 1rem 3rem;
    }

    .content-browser-header .view-title {
        font-size: 1.65rem;
        line-height: 1.2;
        letter-spacing: 0;
    }

    .content-browser-filters {
        padding: 0.85rem;
        border-radius: var(--radius-md);
    }

    .browser-subject-pills {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
    }

    .browser-grade-wrapper,
    .browser-grade-btn {
        width: 100%;
    }

    .browser-grade-checklist {
        position: static;
        width: 100%;
        min-width: 0;
        margin-top: 0.5rem;
        box-shadow: none;
    }

    .content-browser-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .browser-card {
        border-radius: var(--radius-md);
    }

    .settings-container,
    .privacy-container,
    .support-container {
        width: auto;
        margin: 2rem 1rem 4rem;
        padding: 1.25rem;
    }

    .auth-modal {
        width: calc(100vw - 24px);
        max-width: none;
        max-height: 92dvh;
        padding: 1.35rem;
        border-radius: var(--radius-lg);
        gap: 1rem;
    }

    .auth-header h2 {
        font-size: 1.25rem;
        line-height: 1.25;
    }

    .upgrade-modal {
        width: calc(100vw - 20px);
        max-height: 92dvh;
    }

    .upgrade-body {
        gap: 1rem;
    }

    .pricing-card {
        padding: 1rem;
    }

    .site-footer {
        padding: 1.5rem 1rem;
    }

    .site-footer-links {
        flex-wrap: wrap;
        justify-content: center;
        row-gap: 0.75rem;
    }
}

@media (max-width: 360px) {
    .nav-container {
        padding-inline: 0.75rem;
    }

    .logo {
        font-size: 1.42rem;
    }

    .btn-login {
        width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }

    .btn-login span {
        display: none;
    }

    .hero-title {
        font-size: 1.9rem;
    }

    .filter-pills,
    .browser-subject-pills {
        grid-template-columns: 1fr;
    }
}
body.dark-mode .user-dropdown .btn-logout:hover {
    background: rgba(179, 64, 64, 0.2);
}
body.dark-mode .auth-input {
    background: #2D2D2D;
    border-color: #4A4A4A;
    color: #FFFFFF;
}
body.dark-mode .stepper {
    background: #2D2D2D;
}
body.dark-mode .stepper button {
    background: #3D3D3D;
    color: #FFFFFF;
}
body.dark-mode .btn-reset-a11y {
    background: #2D2D2D;
    border-color: #4A4A4A;
}
body.dark-mode .btn-reset-a11y:hover {
    background: #3D3D3D;
}
body.dark-mode .accessibility-statement {
    background: #1E1E1E;
    border-color: #333;
}
body.dark-mode .accessibility-statement p,
body.dark-mode .accessibility-statement li {
    color: var(--text-secondary);
}
body.dark-mode .privacy-container {
    background: #1E1E1E;
    border-color: #333;
}
body.dark-mode .privacy-container p, 
body.dark-mode .privacy-container li {
    color: var(--text-secondary);
}

/* --- Site Footer --- */
.site-footer {
    margin-top: auto;
    padding: 1.5rem 1.5rem 2rem;
    text-align: center;
    border-top: 1px solid var(--color-border);
    background: var(--bg-secondary);
}
.site-footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.footer-link-btn {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    padding: 0.3rem 0.9rem;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.footer-link-btn:hover {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    transform: translateY(-1px);
}
.footer-sep {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}
.footer-copy {
    font-size: 0.75rem;
    color: #806959;
    margin-top: 0.25rem;
}
body.dark-mode .site-footer {
    background: #1A1A1A;
    border-top-color: #333;
}
body.dark-mode .footer-link-btn {
    border-color: #4A4A4A;
    color: #AAA;
}
body.dark-mode .footer-link-btn:hover {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

/* --- Password Eye-Toggle Wrapper --- */
.auth-password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}
.auth-password-wrapper .auth-input {
    flex: 1;
    margin-bottom: 0 !important;
    padding-left: 44px; /* leave room for eye icon (LTR visually on left for RTL) */
}
.btn-toggle-password {
    position: absolute;
    left: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color var(--transition-fast), background var(--transition-fast);
    z-index: 3;
}
.btn-toggle-password:hover {
    color: var(--color-accent);
    background: var(--color-accent-light);
}
body.dark-mode .btn-toggle-password {
    color: #888;
}
body.dark-mode .btn-toggle-password:hover {
    color: var(--color-accent);
    background: rgba(124,106,86,0.15);
}

/* --- Zbangim / Z-Coin --- */
#settings-credits-section {
    transition: box-shadow 0.2s;
}
body.dark-mode #settings-credits-section {
    background: linear-gradient(135deg, #2a2500, #1e1a00) !important;
    border-color: #b8960050 !important;
    box-shadow: 0 4px 16px rgba(241,196,15,0.08) !important;
}
body.dark-mode #settings-credits-section div {
    color: #d4a800 !important;
}
.z-coin {
    display: inline-flex;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #f1c40f;
    border: 1.5px solid #c8960c;
    align-items: center;
    justify-content: center;
    font-family: 'Arial Black', sans-serif;
    font-size: 0.75rem;
    font-weight: 900;
    color: #7a5c00;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(200,150,12,0.3);
    vertical-align: middle;
    line-height: 1;
}

/* ==========================================================================
   MOBILE TOPIC VIEW FIXES
   ========================================================================== */
@media (max-width: 768px) {
    .breadcrumb-container {
        margin: 1.25rem auto 0;
        padding: 0 1rem;
        max-width: 100%;
    }

    .breadcrumbs {
        flex-wrap: wrap;
        gap: 0.35rem 0.5rem;
        font-size: 0.9rem;
        line-height: 1.45;
    }

    .breadcrumbs li {
        min-width: 0;
        gap: 0.35rem;
    }

    .breadcrumbs li:last-child {
        flex-basis: 100%;
        font-size: 1rem;
    }

    #topic-view {
        width: 100%;
        max-width: 100%;
        padding: 1.75rem 1rem 3rem;
        overflow-x: hidden;
    }

    .topic-header {
        margin-bottom: 1.5rem;
        text-align: center;
    }

    .topic-meta {
        align-items: center;
    }

    .topic-title {
        width: 100%;
        font-size: 2rem;
        line-height: 1.18;
        letter-spacing: 0;
        overflow-wrap: anywhere;
    }

    .presentation-banner {
        margin-bottom: 1.25rem;
        border-radius: var(--radius-md);
    }

    .presentation-banner-inner {
        padding: 1rem;
        gap: 0.75rem;
    }

    .presentation-banner-label {
        font-size: 1rem;
    }

    .presentation-banner-sub {
        font-size: 0.78rem;
        line-height: 1.5;
    }

    .split-layout {
        display: flex !important;
        flex-direction: column;
        gap: 1.25rem;
        width: 100%;
        min-width: 0;
    }

    #topic-view.mode-summary .split-layout {
        display: block !important;
    }

    .fact-sheet,
    .practice-lab {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .fact-sheet {
        position: static;
        top: auto;
        padding: 1.15rem;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
    }

    .fact-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        margin-bottom: 1.25rem;
        padding-bottom: 0.9rem;
    }

    .fact-header h2 {
        font-size: 1.25rem;
        text-align: right;
    }

    .fact-header > div {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }

    .fact-tabs {
        width: 100%;
        border-radius: var(--radius-lg);
    }

    .fact-tab {
        flex: 1 1 0;
        min-height: 44px;
        padding: 0.5rem 0.6rem;
        white-space: normal;
        line-height: 1.35;
    }

    .fact-content,
    .fact-story-view {
        font-size: 1rem;
        line-height: 1.75;
        overflow-wrap: anywhere;
    }

    .fact-list {
        gap: 1rem;
    }

    .fact-list li {
        padding-right: 1.5rem;
    }

    .lab-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.9rem;
        margin-bottom: 1rem;
    }

    .lab-header h2 {
        font-size: 1.25rem;
        text-align: center;
    }

    .lab-header-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.6rem;
    }

    .question-counter,
    .btn-fullscreen,
    .btn-print-worksheet {
        min-height: 40px;
        font-size: 0.85rem;
    }

    .btn-print-worksheet,
    .btn-fullscreen {
        padding: 0.55rem 0.85rem;
    }

    .quiz-card {
        padding: 1.25rem;
        border-radius: var(--radius-lg);
    }

    .scenario {
        margin-bottom: 1.5rem;
    }

    .scenario p {
        font-size: 1.05rem;
        line-height: 1.65;
    }

    .options-group {
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .option-btn {
        padding: 0.95rem 1rem;
        gap: 0.75rem;
    }

    .option-text {
        font-size: 0.98rem;
        line-height: 1.45;
    }

    .quiz-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.8rem;
        padding-top: 1.25rem;
    }

    .quiz-actions .btn-primary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 360px) {
    .topic-title {
        font-size: 1.65rem;
    }

    .fact-sheet,
    .quiz-card {
        padding: 1rem;
    }

    .fact-tab {
        font-size: 0.78rem;
    }
}
