/* ═══ Church membership × Fable hometown cozy vibe (warm, pastoral, not gamey) ═══ */
:root {
    --bg: #f5f0e8;
    --bg-warm: #ebe5dc;
    --bg-card: #fffef9;
    --bg-sidebar: #e8e2d8;
    --bg-elevated: #fffcf6;
    --bg-input: #faf8f3;
    --bg-hover: #e8e2d8;
    --border: #d4c9b8;
    --border-light: #e0d8cb;
    --text: #2c2825;
    --text-secondary: #5c5549;
    --text-muted: #7a7266;
    --primary: #6b5344;
    --primary-hover: #8b7355;
    --primary-bg: rgba(107, 83, 68, 0.08);
    --primary-border: rgba(107, 83, 68, 0.25);
    --accent: #5a7d5a;
    --accent-bg: rgba(90, 125, 90, 0.1);
    --success: #4a7c59;
    --success-bg: rgba(74, 124, 89, 0.12);
    --success-border: rgba(74, 124, 89, 0.3);
    --warning: #b8860b;
    --warning-bg: rgba(184, 134, 11, 0.12);
    --danger: #a63d3d;
    --danger-bg: rgba(166, 61, 61, 0.12);
    --gold: #c9a227;
    --stained: #8b6914;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(44, 40, 37, 0.08);
    --shadow-sm: 0 2px 8px rgba(44, 40, 37, 0.06);
    --shadow-book: 0 12px 40px rgba(44, 40, 37, 0.12);
    --shadow-3d: 0 8px 24px rgba(44, 40, 37, 0.1), 0 20px 48px rgba(44, 40, 37, 0.08);
    --shadow-3d-hover: 0 16px 40px rgba(44, 40, 37, 0.14), 0 32px 64px rgba(44, 40, 37, 0.1);
    --perspective: 1200px;
    --transition: 0.25s ease;
    --font: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-book: 'Lora', Georgia, 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', monospace;
    --sidebar-width: 320px;
    --card: var(--bg-card);
    /* Sticky TTS / layout offset for window-scrolled pages (must match .navbar height) */
    --navbar-height: 64px;
}

/* Dark theme: same variable names, darker palette */
[data-theme="dark"] {
    --bg: #1a1917;
    --bg-warm: #252320;
    --bg-card: #22211e;
    --bg-sidebar: #2a2825;
    --bg-elevated: #2d2b28;
    --bg-input: #262421;
    --bg-hover: #2f2d2a;
    --border: #3d3934;
    --border-light: #36332e;
    --text: #e8e4df;
    --text-secondary: #b8b2a8;
    --text-muted: #8c857a;
    --primary: #c4a77d;
    --primary-hover: #d4b78d;
    --primary-bg: rgba(196, 167, 125, 0.15);
    --primary-border: rgba(196, 167, 125, 0.35);
    --accent: #7d9a7d;
    --accent-bg: rgba(125, 154, 125, 0.15);
    --success: #6ba86b;
    --success-bg: rgba(107, 168, 107, 0.18);
    --success-border: rgba(107, 168, 107, 0.4);
    --warning: #d4a84b;
    --warning-bg: rgba(212, 168, 75, 0.18);
    --danger: #c95c5c;
    --danger-bg: rgba(201, 92, 92, 0.18);
    --gold: #d4b040;
    --stained: #a88430;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-book: 0 12px 40px rgba(0, 0, 0, 0.3);
    --shadow-3d: 0 8px 24px rgba(0, 0, 0, 0.25), 0 20px 48px rgba(0, 0, 0, 0.2);
    --shadow-3d-hover: 0 16px 40px rgba(0, 0, 0, 0.3), 0 32px 64px rgba(0, 0, 0, 0.25);
}
/* Dark mode: navbar and nav text (inline index.html also sets html[data-theme="dark"] #navbar) */
[data-theme="dark"] .navbar,
[data-theme="dark"] #navbar {
    background: rgba(26, 25, 23, 0.96);
    border-bottom-color: var(--border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] #navbar .nav-brand,
[data-theme="dark"] .nav-brand { color: #f0ebe5; }
[data-theme="dark"] .nav-brand svg { color: var(--primary); }
[data-theme="dark"] .nav-back { color: var(--primary); }
[data-theme="dark"] .nav-back:hover { color: var(--primary-hover); background: var(--bg-hover); }
[data-theme="dark"] .nav-links a { color: var(--text-secondary); }
[data-theme="dark"] .nav-links a:hover,
[data-theme="dark"] .nav-links a.active { color: var(--text); background: var(--bg-hover); }
[data-theme="dark"] .nav-user { color: var(--text-secondary); }
[data-theme="dark"] .nav-links button.nav-theme-toggle { color: var(--text-secondary); }
[data-theme="dark"] .nav-links button.nav-theme-toggle:hover { color: var(--text); background: var(--bg-hover); }
[data-theme="dark"] .nav-wallet,
[data-theme="dark"] .nav-wallet .nav-wallet-amount,
[data-theme="dark"] .nav-wallet .price-ref { color: var(--text-secondary); }
[data-theme="dark"] .nav-role-tag { color: #1a1917; background: var(--primary); }

/* Dark mode: course cards and section titles so course text is readable */
[data-theme="dark"] .section-title,
[data-theme="dark"] .courses-page-title,
[data-theme="dark"] .course-title { color: var(--text); }
[data-theme="dark"] .course-desc,
[data-theme="dark"] .course-meta { color: var(--text-secondary); }
[data-theme="dark"] .course-category { color: var(--primary); }
[data-theme="dark"] .course-price { color: var(--success); }
[data-theme="dark"] .course-footer .price-ref { color: var(--text-muted); }

/* Dark mode: module/lesson reading area — dark background so body text and headings are readable */
[data-theme="dark"] .lesson-main {
    background-color: var(--bg-card);
    background-image:
        linear-gradient(180deg, rgba(34, 33, 30, 0.98) 0%, rgba(28, 27, 25, 0.99) 100%),
        linear-gradient(90deg, transparent 0%, rgba(196, 167, 125, 0.03) 50%, transparent 100%);
    box-shadow:
        2px 2px 8px rgba(0, 0, 0, 0.2),
        8px 8px 32px rgba(0, 0, 0, 0.25),
        16px 0 40px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(61, 57, 52, 0.6);
}
[data-theme="dark"] .lesson-main::before {
    background: linear-gradient(
        90deg,
        rgba(20, 18, 16, 0.8) 0%,
        rgba(40, 36, 32, 0.5) 35%,
        rgba(61, 57, 52, 0.3) 70%,
        rgba(61, 57, 52, 0.2) 100%
    );
}
[data-theme="dark"] .lesson-main::after {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(0, 0, 0, 0.08) 50%,
        rgba(0, 0, 0, 0.12) 100%
    );
}
[data-theme="dark"] .lesson-breadcrumbs { color: var(--text-muted); }
[data-theme="dark"] .lesson-breadcrumbs a { color: var(--primary); }
[data-theme="dark"] .lesson-breadcrumbs .sep { color: var(--border); }
[data-theme="dark"] .lesson-module-num { color: var(--primary); }
[data-theme="dark"] .lesson-header h1 { color: var(--text); }
[data-theme="dark"] .rendered-md,
[data-theme="dark"] .rendered-md p,
[data-theme="dark"] .rendered-md li { color: var(--text); }
[data-theme="dark"] .rendered-md h1,
[data-theme="dark"] .rendered-md h2,
[data-theme="dark"] .rendered-md h4 { color: var(--text); }
[data-theme="dark"] .rendered-md h3 { color: var(--primary); }
[data-theme="dark"] .rendered-md strong { color: var(--text); }
[data-theme="dark"] .rendered-md em { color: var(--primary); }
[data-theme="dark"] .rendered-md blockquote { color: var(--text-secondary); }
[data-theme="dark"] .book-page { box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2), 2px 0 8px rgba(0, 0, 0, 0.15); }

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Ensure main content area always has room and is visible */
#app {
    min-height: calc(100vh - 180px);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Navbar (subtle 3D depth) ── */
.navbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem; height: var(--navbar-height);
    background: rgba(255, 254, 249, 0.92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(44, 40, 37, 0.06);
}
.nav-brand {
    display: flex; align-items: center; gap: 0.5rem;
    font-weight: 700; font-size: 1.1rem; cursor: pointer;
    color: var(--text);
}
.nav-brand svg { width: 28px; height: 28px; color: var(--primary); }
.nav-back {
    display: inline-flex; align-items: center; gap: 0.4rem;
    color: var(--primary); font-size: 0.9rem; font-weight: 500;
    padding: 0.4rem 0.75rem; margin-left: 0.5rem;
    border-radius: var(--radius-xs); text-decoration: none;
    transition: var(--transition);
    flex-shrink: 0; white-space: nowrap;
    border-left: 1px solid var(--border); padding-left: 0.85rem; margin-left: 0.75rem;
}
.nav-back:hover { color: var(--primary-hover); background: var(--bg-hover); }
.nav-back svg { flex-shrink: 0; }
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-links a {
    color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
    padding: 0.4rem 0.75rem; border-radius: var(--radius-xs);
    transition: var(--transition);
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg-hover); }
.nav-user { color: var(--text-secondary); font-size: 0.85rem; }
.nav-links button.nav-theme-toggle {
    background: transparent; color: var(--text-secondary); border: none;
    padding: 0.4rem 0.5rem; border-radius: var(--radius-xs);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.nav-links button.nav-theme-toggle:hover { color: var(--text); background: var(--bg-hover); }
.nav-links button:not(.nav-theme-toggle) {
    background: var(--primary); color: #fff; border: none;
    padding: 0.5rem 1.1rem; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 0.85rem; cursor: pointer;
    transition: var(--transition);
}
.nav-links button:not(.nav-theme-toggle):hover { background: var(--primary-hover); color: #fff; }
.nav-admin-badge {
    background: var(--warning-bg); color: var(--warning);
    font-size: 0.7rem; font-weight: 700; padding: 0.2rem 0.5rem;
    border-radius: var(--radius-xs); text-transform: uppercase; letter-spacing: 0.05em;
}

/* ── Hero ── */
.hero {
    padding: 5rem 2rem 4rem;
    background: linear-gradient(165deg, var(--bg-warm) 0%, var(--bg) 50%, rgba(90, 125, 90, 0.06) 100%);
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.hero h1 { font-size: 2.8rem; font-weight: 800; line-height: 1.15; margin-bottom: 1rem; color: var(--text); }
.hero h1 span { color: var(--primary); }
.hero p { color: var(--text-secondary); font-size: 1.1rem; max-width: 600px; margin: 0 auto 2rem; }
.hero-btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: var(--primary); color: #fff; border: none;
    padding: 0.85rem 1.8rem; border-radius: var(--radius);
    font-weight: 600; font-size: 1rem; cursor: pointer;
    transition: var(--transition);
}
.hero-btn:hover { background: var(--primary-hover); transform: translateY(-1px); color: #fff; }
.hero-stats { display: flex; justify-content: center; gap: 3rem; margin-top: 3rem; }
.hero-stat-num { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.hero-stat-label { font-size: 0.85rem; color: var(--text-muted); }

/* ── Section ── */
.section { padding: 3rem 0; }
.section-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.5rem; }
.section-subtitle { color: var(--text-secondary); margin-bottom: 2rem; }

/* ── Categories Bar ── */
.categories-bar { display: flex; gap: 0.5rem; margin-bottom: 2rem; flex-wrap: wrap; }
.cat-btn {
    padding: 0.45rem 1rem; border-radius: 99px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-secondary); font-size: 0.85rem;
    font-weight: 500; cursor: pointer; transition: var(--transition);
}
.cat-btn:hover { border-color: var(--primary); color: var(--text); }
.cat-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── 3D book entrance animation ── */
@keyframes bookAppear {
    0% {
        opacity: 0;
        transform: translateY(24px) translateZ(-20px) rotateX(8deg) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateY(0) translateZ(0) rotateX(2deg) scale(1);
    }
}

/* ── Course Grid: each course is a 3D book ── */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    perspective: var(--perspective);
}
.book-card-wrap {
    perspective: var(--perspective);
    min-height: 200px;
    animation: bookAppear 0.55s ease-out backwards;
}
.book-card-wrap:nth-child(1) { animation-delay: 0.05s; }
.book-card-wrap:nth-child(2) { animation-delay: 0.1s; }
.book-card-wrap:nth-child(3) { animation-delay: 0.15s; }
.book-card-wrap:nth-child(4) { animation-delay: 0.2s; }
.book-card-wrap:nth-child(5) { animation-delay: 0.25s; }
.book-card-wrap:nth-child(6) { animation-delay: 0.3s; }
.book-card-wrap:nth-child(7) { animation-delay: 0.35s; }
.book-card-wrap:nth-child(8) { animation-delay: 0.4s; }
.book-card-wrap:nth-child(9) { animation-delay: 0.45s; }
.book-card-wrap:nth-child(n+10) { animation-delay: 0.5s; }
.course-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.4s ease, box-shadow 0.4s ease, border-color 0.25s ease;
    transform-style: preserve-3d;
    transform: translateZ(0) rotateX(2deg) rotateY(0deg);
    box-shadow: var(--shadow-3d), 8px 0 0 0 rgba(60, 50, 40, 0.2), 0 2px 0 0 rgba(255,255,255,0.4) inset;
    position: relative;
}
/* Book spine (left edge) */
.course-card::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0; width: 10px;
    background: linear-gradient(90deg, rgba(50,40,32,0.9) 0%, var(--primary) 35%, var(--primary-hover) 100%);
    border-radius: var(--radius) 0 0 var(--radius);
    pointer-events: none;
    z-index: 1;
    box-shadow: 2px 0 6px rgba(0,0,0,0.15);
}
/* Page edge (right side — stacked pages look) */
.course-card::after {
    content: '';
    position: absolute; right: 0; top: 0; bottom: 0; width: 6px;
    background: linear-gradient(90deg, transparent 0%, rgba(44, 40, 37, 0.08) 100%);
    border-radius: 0 var(--radius) var(--radius) 0;
    pointer-events: none;
}
.course-card:hover {
    border-color: var(--primary-border);
    transform: translateZ(28px) translateY(-10px) rotateX(-4deg) rotateY(0deg);
    box-shadow: var(--shadow-3d-hover), 12px 0 0 0 rgba(60, 50, 40, 0.25), 0 2px 0 0 rgba(255,255,255,0.5) inset;
}
.course-card.book-opening {
    animation: bookOpenClick 0.5s ease-out forwards;
    pointer-events: none;
}
@keyframes bookOpenClick {
    0% { transform: translateZ(28px) translateY(-10px) rotateX(-4deg) rotateY(0deg) scale(1); }
    40% { transform: translateZ(20px) translateY(-4px) rotateX(-8deg) rotateY(-6deg) scale(1.02); }
    100% { transform: translateZ(0) translateY(0) rotateX(0deg) rotateY(-25deg) scale(0.98); opacity: 0.97; }
}
.course-img-wrap { position: relative; height: 180px; overflow: hidden; }
.course-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.course-card:hover .course-img { transform: scale(1.02); }
.course-badge-featured {
    position: absolute; top: 12px; right: 12px;
    background: var(--gold); color: #1a1a1a; padding: 0.2rem 0.6rem;
    border-radius: var(--radius-xs); font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase;
}
.course-body { padding: 1.25rem; }
.course-category { font-size: 0.75rem; color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.course-title { font-size: 1.05rem; font-weight: 700; margin: 0.4rem 0; line-height: 1.3; font-family: var(--font-book); }
.course-desc { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 1rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-meta { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1rem; flex-wrap: wrap; }
.course-meta span { display: flex; align-items: center; gap: 0.3rem; }
.course-footer { display: flex; justify-content: space-between; align-items: center; }
.course-price { font-size: 1.2rem; font-weight: 800; color: var(--success); }
.price-ref { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.course-footer .price-ref { display: block; margin-top: 0.15rem; }

/* ── Buttons ── */
.btn-sm {
    padding: 0.4rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.8rem; font-weight: 600; cursor: pointer;
    border: none; transition: var(--transition);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-accent { background: var(--primary); color: #fff; }
.btn-full { width: 100%; padding: 0.75rem; border: none; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.btn-buy { background: var(--primary); color: #fff; }
.btn-buy:hover { background: var(--primary-hover); }
.btn-owned { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); cursor: default; }
.btn-outline {
    background: var(--bg-card); border: 2px solid var(--border);
    color: var(--text); padding: 0.5rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(44, 40, 37, 0.06);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

.empty-state { text-align: center; padding: 4rem 2rem; }
.empty-state h3 { margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Course Detail Page ── */
.course-detail { padding: 2rem 0; font-family: var(--font-book); }
.cd-header { display: grid; grid-template-columns: 1fr 340px; gap: 2rem; margin-bottom: 2rem; }
.cd-info h1 { font-size: 2rem; margin: 0.5rem 0; font-family: var(--font-book); color: var(--text); }
.cd-cat { font-size: 0.8rem; color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font); }
.cd-stats { display: flex; gap: 1.5rem; margin: 1rem 0; flex-wrap: wrap; }
.cd-stat { font-size: 0.9rem; color: var(--text-secondary); }
.cd-stat strong { color: var(--text); }
.cd-sidebar {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; height: fit-content;
    box-shadow: var(--shadow-sm);
}
.cd-img { width: 100%; border-radius: var(--radius-sm); }
.price-tag { font-size: 1.8rem; font-weight: 800; color: var(--text); }
.includes { list-style: none; padding: 0; margin-top: 1rem; }
.includes h4 { font-size: 0.9rem; margin-bottom: 0.5rem; }
.includes li {
    font-size: 0.85rem; color: var(--text-secondary);
    padding: 0.35rem 0; padding-left: 1.25rem;
    position: relative;
}
.includes li::before { content: '✓'; position: absolute; left: 0; color: var(--success); font-weight: 700; }

/* Course curriculum list on detail page — each module is a small 3D book */
.cd-modules { margin-top: 2rem; perspective: 800px; }
.cd-modules h2 { font-size: 1.4rem; margin-bottom: 1rem; }
.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem 1rem 1.5rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.25s ease;
    transform-style: preserve-3d;
    transform: translateZ(0);
    box-shadow: 0 2px 8px rgba(44, 40, 37, 0.06), 4px 0 0 0 rgba(107, 83, 68, 0.12);
    position: relative;
    overflow: hidden;
}
.module-card::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
    background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 50%, var(--primary-hover) 100%);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    pointer-events: none;
    box-shadow: 1px 0 4px rgba(0,0,0,0.1);
}
.module-card:hover:not(.locked) {
    border-color: var(--primary-border);
    background: var(--bg-elevated);
    transform: translateZ(8px) translateY(-2px);
    box-shadow: 0 6px 20px rgba(44, 40, 37, 0.1), 6px 0 0 0 rgba(107, 83, 68, 0.18);
}
.module-card.module-opening {
    animation: moduleBookOpen 0.4s ease-out forwards;
    pointer-events: none;
}
@keyframes moduleBookOpen {
    0% { transform: translateZ(8px) translateY(-2px) rotateY(0deg); }
    50% { transform: translateZ(4px) rotateY(-12deg); }
    100% { transform: translateZ(0) rotateY(-20deg); opacity: 0.95; }
}
.module-card.completed { border-left: none; }
.module-card.completed::before { background: linear-gradient(180deg, var(--success) 0%, #3d9960 50%, var(--success) 100%); }
.module-card.active { border-color: var(--primary); background: var(--primary-bg); }
.module-card.active::before { box-shadow: 1px 0 6px rgba(107, 83, 68, 0.3); }
.module-num {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg-elevated); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.module-card.completed .module-num { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.module-info { flex: 1; }
.module-title-text { font-weight: 600; font-size: 0.95rem; }
.module-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.module-status-icon { font-size: 1.1rem; }
.module-card.locked {
    opacity: 0.5; cursor: not-allowed;
}
.module-card.locked::before { background: linear-gradient(180deg, var(--text-muted) 0%, #888 50%, var(--text-muted) 100%); opacity: 0.7; }
.module-card.locked .module-num {
    background: var(--bg-elevated); border-color: var(--text-muted);
    color: var(--text-muted); font-size: 0.7rem;
}

/* ── Progress Bar ── */
.progress-bar-wrap {
    background: var(--bg-input); border-radius: 99px; height: 8px;
    overflow: hidden; margin: 0.5rem 0;
}
.progress-bar-fill {
    height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 99px; transition: width 0.5s ease;
}
.progress-label { font-size: 0.8rem; color: var(--text-muted); }
.progress-percent { font-weight: 700; color: var(--primary); }

/* ── Lesson Page Layout (centered: left flex | sidebar | main | right filler) ── */
/* Fixed height so center column scrolls internally; TTS player scrolls with content */
.lesson-layout {
    display: grid;
    grid-template-columns:
        1fr
        minmax(200px, var(--lesson-sidebar-width, 320px))
        12px
        minmax(0, 1320px)
        12px
        minmax(180px, var(--lesson-filler-width, 260px))
        1fr;
    grid-template-rows: minmax(0, 1fr) 0px;
    height: calc(100vh - 64px);
    max-width: 100%;
}
.lesson-layout.lesson-layout--sidebar-collapsed:not(.lesson-layout--filler-collapsed) {
    grid-template-columns:
        1fr
        0px
        0px
        minmax(0, 1320px)
        12px
        minmax(180px, var(--lesson-filler-width, 260px))
        1fr;
}
.lesson-layout.lesson-layout--filler-collapsed:not(.lesson-layout--sidebar-collapsed) {
    grid-template-columns:
        1fr
        minmax(200px, var(--lesson-sidebar-width, 320px))
        12px
        minmax(0, 1320px)
        0px
        0px
        1fr;
}
.lesson-layout.lesson-layout--sidebar-collapsed.lesson-layout--filler-collapsed {
    grid-template-columns:
        1fr
        0px
        0px
        minmax(0, 1320px)
        0px
        0px
        1fr;
}
.lesson-layout--sidebar-collapsed .lesson-sidebar {
    overflow: hidden;
    padding: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
    min-width: 0;
    box-shadow: none;
}
.lesson-layout--filler-collapsed .lesson-right-filler {
    overflow: hidden;
    padding: 0;
    border-left: none;
    opacity: 0;
    pointer-events: none;
    min-width: 0;
}
.lesson-gutter {
    min-height: 0;
    align-self: stretch;
    cursor: col-resize;
    touch-action: none;
    position: relative;
    z-index: 4;
    background: transparent;
}
.lesson-gutter::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    transform: translateX(-50%);
    background: var(--border);
    border-radius: 2px;
    opacity: 0.55;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.lesson-gutter:hover::after,
.lesson-gutter:focus-visible::after {
    opacity: 1;
    background: var(--primary);
}
.lesson-gutter.is-dragging::after {
    opacity: 1;
    background: var(--primary);
}
.sidebar-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}
.sidebar-header-top h3 {
    flex: 1;
    min-width: 0;
    margin: 0;
}
.lesson-col-collapse-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.lesson-col-collapse-btn:hover {
    color: var(--primary);
    border-color: var(--primary-border);
    background: var(--primary-bg);
}
.filler-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 0.15rem 0.5rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-light);
}
.filler-column-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
}
.lesson-floating-col-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 0;
    max-height: 0;
    overflow: visible;
    pointer-events: none;
    position: relative;
    z-index: 130;
}
.lesson-col-restore-tab {
    display: none;
    position: fixed;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: var(--transition);
    pointer-events: auto;
}
.lesson-col-restore-tab:hover {
    border-color: var(--primary-border);
    color: var(--primary);
    background: var(--primary-bg);
}
.lesson-col-restore-tab--sidebar {
    left: 0.75rem;
    top: 7rem;
}
.lesson-col-restore-tab--tools {
    left: 0.75rem;
    top: calc(7rem + 2.85rem);
}
.lesson-col-restore-tab--filler {
    right: 0.75rem;
    top: 7rem;
}
.lesson-split.lesson-split--tools-collapsed .lesson-tools-rail {
    flex: 0 0 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}
.lesson-split.lesson-split--tools-collapsed .lesson-split-resizer {
    display: none !important;
}
.lesson-split.lesson-split--tools-collapsed .lesson-reading-stack {
    flex: 1;
}
.notes-panel-heading {
    justify-content: space-between !important;
    width: 100%;
    flex-wrap: nowrap !important;
}
.notes-panel-heading-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.lesson-sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto; height: calc(100vh - 64px);
    position: sticky; top: 64px;
    padding: 1.25rem 0;
    font-family: var(--font);
    box-shadow: 2px 0 12px rgba(44, 40, 37, 0.04);
}
.sidebar-header {
    padding: 0 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.sidebar-header h3 { font-size: 0.95rem; line-height: 1.3; }
.sidebar-header .progress-info { margin-top: 0.75rem; }
.sidebar-module {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.5rem 0.65rem 0.5rem 1.25rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-module:hover { background: var(--bg-hover); }
.sidebar-module.active {
    background: var(--primary-bg); border-left-color: var(--primary);
}
.sidebar-module-row {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.15rem 0;
    border-radius: var(--radius-xs);
}
.sidebar-module-note-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    margin-top: 2px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.sidebar-module-note-btn:hover {
    color: var(--primary);
    border-color: var(--primary-border);
    background: var(--primary-bg);
}
.sidebar-module-note-btn.has-notes {
    color: var(--primary);
    border-color: var(--primary-border);
    background: var(--primary-bg);
}
.sidebar-module.completed .sidebar-check { color: var(--success); }
.sidebar-check {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--border); display: flex;
    align-items: center; justify-content: center;
    font-size: 0.7rem; flex-shrink: 0; margin-top: 2px;
}
.sidebar-module.completed .sidebar-check {
    background: var(--success-bg); border-color: var(--success);
}
.sidebar-mod-title { font-size: 0.85rem; font-weight: 500; line-height: 1.3; }
.sidebar-mod-num { font-size: 0.75rem; color: var(--text-muted); }
.sidebar-module.locked {
    opacity: 0.55;
}
.sidebar-module.locked .sidebar-module-row {
    cursor: not-allowed;
    pointer-events: none;
}
.sidebar-module.locked .sidebar-module-note-btn {
    pointer-events: auto;
    cursor: pointer;
    opacity: 1;
}
.sidebar-module.locked .sidebar-check {
    border-color: var(--text-muted); font-size: 0.6rem;
}
.notes-panel-scope-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0 0 0.65rem 0;
}
.sidebar-course-notes-block {
    padding: 0 1rem 0.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    max-height: min(220px, 28vh);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.sidebar-course-notes-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    flex-shrink: 0;
}
.sidebar-course-notes-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 0;
}
.sidebar-course-notes-empty {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}
.sidebar-course-note-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    padding: 0.35rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
}
.sidebar-course-note-row:hover {
    border-color: var(--primary-border);
    background: var(--primary-bg);
}
.sidebar-course-note-title {
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-course-note-mod {
    flex-shrink: 0;
    font-size: 0.68rem;
    color: var(--text-muted);
}
.lesson-notes-toolbar {
    margin-bottom: 0.5rem;
}
.lesson-notes-list {
    list-style: none;
    margin: 0 0 0.75rem 0;
    padding: 0;
    max-height: 140px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-input);
}
.lesson-notes-list-item {
    border-bottom: 1px solid var(--border);
}
.lesson-notes-list-item:last-child {
    border-bottom: none;
}
.lesson-notes-list-item.is-active {
    background: var(--primary-bg);
}
.lesson-notes-pick {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.55rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.82rem;
    font-family: var(--font);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lesson-notes-pick:hover {
    color: var(--primary);
}
.notes-field-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 0.25rem 0;
}
.notes-title-input {
    width: 100%;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.88rem;
    font-family: var(--font);
}
.notes-title-input:focus {
    outline: none;
    border-color: var(--primary);
}
.module-notes-modal-list {
    max-height: 120px;
    margin-bottom: 0.75rem;
}
.tutor-popout-page {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    font-family: var(--font);
}

/* Popout window: pin tutor UI to the viewport so #app / min-heights cannot leave a dead band. */
html.tutor-popout-active {
    overflow: hidden;
    height: 100%;
}
body.tutor-popout-active {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    margin: 0;
}
body.tutor-popout-active #app {
    min-height: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    padding: 0;
    margin: 0;
    display: block;
    overflow: hidden;
    box-sizing: border-box;
}
body.tutor-popout-active .tutor-popout-page {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    z-index: 200;
    flex: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.tutor-popout-active .tutor-popout-chat-wrap {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    padding: 0.75rem 1rem 1rem;
    max-width: none;
}
body.tutor-popout-active .tutor-popout-chat-wrap .chat-panel {
    /* Pop-out windows are often 720px wide; @media (max-width: 900px) sets .chat-panel to position:fixed.
       That rips the panel out of the flex column, leaves a dead hit-target band, and can stack under
       .tutor-popout-page (z-index 200) so the textarea is unreachable. Keep in-flow here. */
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: auto;
    max-height: none !important;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 0;
    overflow: hidden;
}
body.tutor-popout-active .tutor-popout-chat-wrap .chat-body {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
body.tutor-popout-active .tutor-popout-chat-wrap .chat-pane {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
/* min-height:0 beats default min-height:auto so this region scrolls instead of growing past the viewport */
body.tutor-popout-active .tutor-popout-chat-wrap .chat-messages {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: scroll !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}
body.tutor-popout-active .tutor-popout-chat-wrap .chat-pane-admin {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
body.tutor-popout-active .tutor-popout-chat-wrap .chat-pane-admin .admin-ai-messages {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: scroll !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}
.tutor-popout-toolbar {
    flex-shrink: 0;
    padding: 1rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
}
.tutor-popout-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.35rem 0;
}
.tutor-popout-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    line-height: 1.4;
}
.tutor-popout-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.tutor-popout-chat-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 1rem;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}
.tutor-popout-chat-wrap .chat-panel {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}
.tutor-popout-chat-wrap .chat-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.tutor-popout-chat-wrap .chat-pane {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.tutor-popout-chat-wrap .chat-messages {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.tutor-popout-chat-wrap .chat-typing {
    flex-shrink: 0;
}
.tutor-popout-chat-wrap .chat-input-row {
    flex-shrink: 0;
}
.tutor-popout-chat-wrap .chat-pane-admin .admin-ai-messages {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.chat-popout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.chat-popout-btn:hover {
    color: var(--primary);
    background: var(--primary-bg);
}

/* Spacer for centering: takes the left 1fr so sidebar+main+filler sit in the middle */
.lesson-layout-spacer { min-height: 0; }
.lesson-layout-spacer--right { min-height: 0; }

/* Right filler column (centered layout) */
.lesson-right-filler {
    padding: 1.5rem 1rem 2rem 1rem;
    max-width: none;
    justify-self: stretch;
    width: 100%;
    background: linear-gradient(180deg, var(--bg-warm) 0%, var(--bg) 100%);
    border-left: 1px solid var(--border-light);
    overflow-y: auto;
    height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-family: var(--font);
}
.filler-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.1rem;
}
.filler-card h4 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    margin-bottom: 0.5rem;
}
.filler-module-title {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text);
    margin: 0;
}
.filler-terms-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.filler-terms-list li {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-light);
}
.filler-terms-list li:last-child { border-bottom: none; }
.filler-tip p {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin: 0;
}
.filler-progress {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.filler-progress-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.filler-progress-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
}

/* ── Book reading: page opens (3D turn) ── */
@keyframes bookPageIn {
    0% {
        opacity: 0;
        transform: perspective(800px) rotateY(-18deg) translateX(16px);
    }
    60% {
        opacity: 1;
        transform: perspective(800px) rotateY(2deg) translateX(0);
    }
    100% {
        opacity: 1;
        transform: perspective(800px) rotateY(0deg) translateX(0);
    }
}
@keyframes sidebarModuleFocus {
    0% { background-color: transparent; }
    30% { background-color: var(--primary-bg); }
    100% { background-color: var(--primary-bg); }
}

/* Lesson main: open book on screen — 3D spine, paper texture, depth shadows. */
.lesson-main {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    min-height: 0; /* grid child must shrink so overflow works */
    font-family: var(--font-book);
    /* Warm paper: cream/ivory like real book pages */
    background-color: #faf6ef;
    background-image:
        linear-gradient(180deg, rgba(255,253,248,0.97) 0%, rgba(248,244,235,0.98) 100%),
        linear-gradient(90deg, transparent 0%, rgba(210,195,170,0.03) 50%, transparent 100%);
    position: relative;
    /* visible avoids clipping the sticky TTS controls at the top of .lesson-main__scroll */
    overflow: visible;
    /* 3D book open: deeper shadow for lifted page */
    box-shadow:
        2px 2px 8px rgba(44, 40, 37, 0.06),
        8px 8px 32px rgba(44, 40, 37, 0.1),
        16px 0 40px rgba(44, 40, 37, 0.06),
        0 0 0 1px rgba(212, 201, 184, 0.4);
}
/* Inner scroll area: TTS player and book content scroll together here */
.lesson-main__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    padding: 2.25rem 2rem 3rem;
}

/* Notes / flashcards / AI: left rail beside reading — sticky in module scroll (like TTS) */
.lesson-split {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}
.lesson-split-resizer {
    flex: 0 0 12px;
    width: 12px;
    margin: 0 -5px;
    padding: 0;
    cursor: col-resize;
    align-self: stretch;
    min-height: 160px;
    border: none;
    border-radius: 4px;
    background: transparent;
    position: relative;
    z-index: 3;
    touch-action: none;
    box-sizing: border-box;
}
.lesson-split-resizer::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 3px;
    transform: translateX(-50%);
    background: var(--border);
    border-radius: 2px;
    opacity: 0.55;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.lesson-split-resizer:hover::after,
.lesson-split-resizer:focus-visible::after {
    opacity: 1;
    background: var(--primary);
}
.lesson-split-resizer.is-dragging::after {
    opacity: 1;
    background: var(--primary);
}
.lesson-tools-rail {
    position: sticky;
    top: 0;
    align-self: flex-start;
    flex: 0 0 var(--lesson-rail-width, 252px);
    width: var(--lesson-rail-width, 252px);
    max-width: 100%;
    max-height: calc(100vh - 64px - 5rem);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.35rem;
    scrollbar-gutter: stable;
}
.lesson-reading-stack {
    flex: 1;
    min-width: 0;
    min-height: 0;
    position: relative;
    z-index: 1;
    isolation: isolate;
}
.lesson-tools-rail .notes-panel {
    margin: 0;
}
.lesson-tools-rail .flashcards-section {
    margin: 0;
}
.lesson-tools-rail .flashcard-grid {
    grid-template-columns: 1fr;
}
.lesson-chat-slot {
    flex-shrink: 0;
}
.lesson-chat-slot .chat-panel {
    border-top: none;
    max-height: min(520px, 48vh);
}

/* Book spine (binding) on the left — like opening a book */
.lesson-main::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 12px;
    background: linear-gradient(
        90deg,
        rgba(60,50,40,0.35) 0%,
        rgba(80,70,55,0.25) 25%,
        rgba(100,85,65,0.15) 50%,
        rgba(212,201,184,0.4) 85%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 1;
}
/* Inner page edge shadow (right side of open page) */
.lesson-main::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(44, 40, 37, 0.03) 30%,
        rgba(44, 40, 37, 0.06) 100%
    );
    pointer-events: none;
    z-index: 0;
}
/* The “page” content block: entrance only (filter removed — caused paint clipping/blank cutoff) */
.book-page {
    animation: bookPageIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    position: relative;
    z-index: 1;
    transform-origin: left center;
    box-shadow: 4px 0 20px rgba(44, 40, 37, 0.08), 2px 0 8px rgba(44, 40, 37, 0.04);
}
.lesson-layout .sidebar-module.active {
    animation: sidebarModuleFocus 0.6s ease-out;
}
.lesson-breadcrumbs {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.8rem; color: var(--text-muted);
    margin-bottom: 1.5rem; flex-wrap: wrap;
    font-family: var(--font);
}
.lesson-breadcrumbs a { color: var(--primary); font-weight: 500; }
.lesson-breadcrumbs .sep { color: var(--border); }
.lesson-header { margin-bottom: 2rem; }
.lesson-header h1 { font-size: 1.6rem; font-weight: 700; line-height: 1.35; font-family: var(--font-book); color: var(--text); }
.lesson-module-num { font-size: 0.8rem; color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; font-family: var(--font); }

/* Lesson toolbar */
.lesson-toolbar {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; margin-bottom: 1.5rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); flex-wrap: wrap;
    font-family: var(--font);
}
.tool-btn {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.75rem; border-radius: var(--radius-xs);
    background: transparent; border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.8rem;
    font-weight: 500; cursor: pointer; transition: var(--transition);
}
.tool-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--primary-border); }
.tool-btn.active { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.tool-btn svg { width: 16px; height: 16px; }
.tool-spacer { flex: 1; }

/* TTS Audio Player – sticky at top of .lesson-main__scroll so it tracks with scroll */
.tts-player {
    position: sticky;
    top: 0;
    margin-bottom: 1.5rem;
    padding: 0.85rem 1.25rem 1rem;
    background: linear-gradient(135deg, var(--bg-card), color-mix(in srgb, var(--primary) 4%, var(--bg-card)));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex; flex-direction: column; gap: 0.55rem;
    z-index: 10;
    transition: box-shadow 0.3s ease, border-radius 0.3s ease, border-color 0.3s ease;
    box-shadow: var(--shadow-sm);
}
/* Window scroll (Bible chapter, case brief reader): stick below sticky navbar */
#app .section > .container > .tts-player,
.case-briefs-reader-scroll > .tts-player {
    top: calc(var(--navbar-height) + 6px);
    z-index: 90;
}
/* Course lesson: inset at inner scroll top (scrollport is .lesson-main__scroll, not under navbar) */
.lesson-main__scroll .tts-player {
    top: 6px;
    z-index: 15;
    pointer-events: auto;
}
.tts-player.stuck {
    box-shadow: 0 4px 16px rgba(44, 40, 37, 0.12);
}
/* 1px sentinel above TTS player for IntersectionObserver (sticky state) */
.tts-sticky-sentinel {
    height: 1px;
    width: 100%;
    margin: 0;
    padding: 0;
    pointer-events: none;
    visibility: hidden;
}
.tts-player-label {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.72rem; font-weight: 600; color: var(--primary);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.tts-controls {
    display: flex; align-items: center; justify-content: center; gap: 0.6rem;
}
.tts-btn {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border-radius: 50%; border: 1px solid var(--border);
    background: transparent; color: var(--text-secondary);
    cursor: pointer; transition: var(--transition); position: relative;
}
.tts-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--primary-border); }
.tts-play-btn {
    width: 48px; height: 48px;
    background: var(--primary); color: #fff; border-color: var(--primary);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent);
}
.tts-play-btn:hover {
    background: var(--primary-hover); color: #fff; border-color: var(--primary-hover);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 45%, transparent);
}
.tts-seek-label {
    position: absolute; font-size: 0.55rem; font-weight: 700;
    bottom: 2px; left: 50%; transform: translateX(-50%);
    color: inherit; pointer-events: none; line-height: 1;
}
.tts-progress-row {
    display: flex; align-items: center; gap: 0.6rem;
}
.tts-time {
    font-size: 0.72rem; font-family: var(--font-mono);
    color: var(--text-muted); min-width: 3.2rem; text-align: center;
}
.tts-progress-wrap {
    flex: 1; height: 6px;
    background: var(--bg-hover); border-radius: 3px;
    cursor: pointer; position: relative; overflow: hidden;
    transition: height 0.15s ease;
}
.tts-progress-wrap:hover { height: 10px; }
.tts-progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #60a5fa));
    border-radius: 3px;
    transition: width 0.15s linear;
}
.tts-progress-wrap--dragging .tts-progress-fill {
    transition: none;
}
.tts-narration--interactive .tts-word {
    cursor: pointer;
}
.tts-options {
    display: flex; align-items: center; gap: 1.25rem;
    justify-content: center; flex-wrap: wrap;
}
.tts-speed {
    display: flex; align-items: center; gap: 0.35rem;
}
.tts-speed label {
    font-size: 0.72rem; color: var(--text-muted); font-weight: 500;
}
.tts-speed select {
    font-size: 0.75rem; padding: 0.2rem 0.4rem;
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    background: var(--bg); color: var(--text);
    cursor: pointer; font-family: var(--font-mono);
}
.tts-voice-label {
    display: flex; align-items: center; gap: 0.3rem;
    font-size: 0.72rem; color: var(--text-muted); font-weight: 500;
}
/* Narration sync: proportional word highlight (see app.js ttsPrepareNarrationRoot) */
.tts-word.tts-word--active {
    background: linear-gradient(transparent 58%, color-mix(in srgb, var(--primary) 35%, transparent) 58%);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    border-radius: 2px;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 20%, transparent);
}
[data-theme="dark"] .tts-word.tts-word--active {
    background: linear-gradient(transparent 58%, color-mix(in srgb, var(--primary) 45%, transparent) 58%);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent);
}

.tts-no-audio {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 1rem; padding: 0.6rem 1rem;
    font-size: 0.78rem; color: var(--text-muted);
    background: var(--bg-card); border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}
.lesson-main__scroll .tts-no-audio {
    position: sticky;
    top: 6px;
    z-index: 15;
    pointer-events: auto;
}

/* Rendered markdown: interactive book text (book-like column) */
.rendered-md {
    font-size: 1.05rem; line-height: 1.85; color: var(--text);
    font-family: var(--font-book);
    text-align: justify;
    hyphens: auto;
}
.rendered-md a.citation-pdf-link,
a.citation-pdf-link {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
}
.citation-pdf-link-wrap {
    display: inline;
    white-space: normal;
}
button.citation-pdf-readaloud-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-left: 0.35rem;
    padding: 0.15rem 0.35rem;
    border: none;
    background: var(--primary-bg, rgba(107, 83, 68, 0.12));
    color: var(--primary);
    border-radius: var(--radius-xs, 4px);
    cursor: pointer;
    line-height: 1;
}
button.citation-pdf-readaloud-btn:hover {
    background: var(--primary-bg, rgba(107, 83, 68, 0.2));
}
.citation-pdf-source-attrib {
    display: inline;
    margin-left: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted, #7a7266);
    vertical-align: middle;
    white-space: normal;
}
.citation-pdf-source-label {
    margin-right: 0.2rem;
}
a.citation-pdf-source-link {
    color: var(--text-muted, #7a7266);
    text-decoration: underline;
    text-underline-offset: 1px;
}
a.citation-pdf-source-link:hover {
    color: var(--primary);
}
.citation-pdf-source-plain {
    color: var(--text-muted, #7a7266);
    word-break: break-all;
}
.citation-source-retrieved {
    font-size: 0.75rem;
    margin-top: 0.35rem;
    color: var(--text-muted, #7a7266);
}
.rendered-md h1 { font-size: 1.4rem; margin: 2rem 0 1rem; font-weight: 700; font-family: var(--font-book); color: var(--text); transition: color 0.2s ease; text-align: left; }
.rendered-md h2, .rendered-md h3, .rendered-md h4 { text-align: left; }
.rendered-md h2 { font-size: 1.2rem; margin: 1.75rem 0 0.75rem; font-weight: 700; font-family: var(--font-book); color: var(--text); transition: color 0.2s ease; }
.rendered-md h3 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; font-weight: 600; color: var(--primary); font-family: var(--font-book); transition: color 0.2s ease; }
.rendered-md h4 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; font-weight: 600; font-family: var(--font-book); color: var(--text); }
.rendered-md p {
    margin-bottom: 1.1rem;
    transition: color 0.2s ease, background 0.2s ease;
    border-radius: var(--radius-xs);
    padding: 0.15rem 0;
}
.rendered-md p:hover { color: var(--text); background: rgba(107, 83, 68, 0.04); }
.rendered-md ul, .rendered-md ol { margin: 0.5rem 0 1rem 1.5rem; }
.rendered-md li { margin-bottom: 0.45rem; }
.rendered-md strong { color: var(--text); font-weight: 600; }
.rendered-md em { color: var(--primary); font-style: italic; }
.rendered-md blockquote {
    border-left: 4px solid var(--primary); padding: 0.75rem 1rem;
    background: var(--primary-bg); border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    margin: 1rem 0; color: var(--text-secondary);
    font-style: italic;
}
.rendered-md code {
    background: var(--bg-input); padding: 0.15rem 0.4rem;
    border-radius: 4px; font-family: var(--font-mono);
    font-size: 0.85em; border: 1px solid var(--border-light);
}
.rendered-md pre {
    background: var(--bg-input); padding: 1rem; border-radius: var(--radius-sm);
    overflow-x: auto; margin: 1rem 0; border: 1px solid var(--border-light);
}
.rendered-md hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* Bible reader: easier reading, verse number spacing */
.bible-text.rendered-md {
    max-width: 720px;
    margin: 0 auto;
    font-size: 1.1rem;
    line-height: 1.9;
    letter-spacing: 0.02em;
}
.bible-verse {
    margin-bottom: 1rem;
}

/* Lesson navigation */
.lesson-nav {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 2rem; padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.lesson-nav-btn {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 1.25rem; border-radius: var(--radius-sm);
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: var(--transition);
    font-family: var(--font);
}
.lesson-nav-btn:hover { border-color: var(--primary); color: var(--primary); }
.lesson-nav-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.lesson-nav-btn.primary:hover { background: var(--primary-hover); }
.lesson-nav-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Notes Panel ── */
.notes-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
    margin: 1.5rem 0;
}
.notes-panel h3 { font-size: 0.95rem; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.notes-panel-hint {
    font-size: 0.78rem; line-height: 1.45; color: var(--text-muted);
    margin: -0.35rem 0 0.65rem 0;
}
.notes-textarea {
    width: 100%; min-height: 120px; padding: 0.75rem;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: var(--font); font-size: 0.9rem;
    resize: vertical; line-height: 1.6;
}
.notes-textarea:focus { outline: none; border-color: var(--primary); }
.notes-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.75rem; }
.notes-saved { font-size: 0.8rem; color: var(--success); }

/* ── Flashcard ── */
.flashcards-section { margin: 1.5rem 0; }
.flashcards-section h3 { font-size: 0.95rem; margin-bottom: 0.75rem; }
.flashcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.75rem; }
.flashcard {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 1rem;
    cursor: pointer; transition: var(--transition);
    min-height: 100px; position: relative;
}
.flashcard:hover { border-color: var(--primary-border); }
.flashcard.flipped { background: var(--primary-bg); border-color: var(--primary-border); }
.flashcard-term {
    font-weight: 700; font-size: 0.9rem; color: var(--primary);
    margin-bottom: 0.5rem;
}
.flashcard-def {
    font-size: 0.85rem; color: var(--text-secondary);
    line-height: 1.5; display: none;
}
.flashcard.flipped .flashcard-def { display: block; }
.flashcard-hint {
    font-size: 0.7rem; color: var(--text-muted);
    position: absolute; bottom: 0.5rem; right: 0.75rem;
}
.flashcard.flipped .flashcard-hint { display: none; }

.flashcards-subheading {
    font-size: 0.82rem; font-weight: 700; margin: 1rem 0 0.35rem 0; color: var(--text);
}
.flashcards-section > .flashcards-subheading:first-of-type { margin-top: 0; }
.flashcards-subhint { font-size: 0.78rem; color: var(--text-muted); margin: 0 0 0.65rem 0; line-height: 1.45; }
.flashcards-signin-hint { margin-top: 0.25rem; }

.user-flashcard-form {
    display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem;
}
.user-flashcard-input {
    width: 100%; padding: 0.6rem 0.75rem; box-sizing: border-box;
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: var(--font); font-size: 0.88rem;
}
.user-flashcard-input:focus { outline: none; border-color: var(--primary); }
.user-flashcard-textarea { resize: vertical; min-height: 3.5rem; line-height: 1.5; }

.flashcard--custom { padding-top: 0.15rem; cursor: default; }
.flashcard--custom .flashcard-flip-hit {
    cursor: pointer; min-height: 88px; padding-top: 0.25rem;
}
.flashcard-remove-btn {
    position: absolute; top: 0.35rem; right: 0.35rem; z-index: 2;
    width: 1.65rem; height: 1.65rem; padding: 0; margin: 0;
    border: none; border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-card) 85%, var(--border));
    color: var(--text-muted); font-size: 0.75rem; line-height: 1; cursor: pointer;
    transition: var(--transition);
}
.flashcard-remove-btn:hover {
    background: color-mix(in srgb, var(--danger) 15%, var(--bg-card));
    color: var(--danger);
}
.user-flashcard-grid { margin-top: 0.25rem; }

/* ── End of chapter: set down the book, then quiz & essay ── */
.chapter-end {
    margin: 2.5rem 0 2rem;
    padding: 1.75rem 2rem;
    text-align: center;
    background: linear-gradient(180deg, var(--bg-input) 0%, var(--bg-sidebar) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    animation: chapterEndIn 0.6s ease;
}
@keyframes chapterEndIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.chapter-end-icon {
    display: inline-block;
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    animation: bookRest 2s ease-in-out infinite;
}
@keyframes bookRest {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-4px) rotate(0deg); }
}
.chapter-end-title {
    font-family: var(--font-book);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.35rem;
}
.chapter-end-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.desk-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ── Essay Submission ── */
.essay-section {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem;
    margin: 1.5rem 0;
}
.essay-section h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.essay-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.essay-textarea {
    width: 100%; min-height: 200px; padding: 1rem;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: var(--font); font-size: 0.9rem;
    resize: vertical; line-height: 1.7;
}
.essay-textarea:focus { outline: none; border-color: var(--primary); }
.essay-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 0.75rem; flex-wrap: wrap; gap: 0.5rem; }
.word-count { font-size: 0.8rem; color: var(--text-muted); }
.word-count.low { color: var(--danger); }
.essay-status {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.3rem 0.75rem; border-radius: var(--radius-xs);
    font-size: 0.8rem; font-weight: 600;
}
.essay-status.submitted { background: var(--warning-bg); color: var(--warning); }
.essay-status.reviewed { background: var(--success-bg); color: var(--success); }
.essay-feedback {
    margin-top: 1rem; padding: 1rem; background: var(--bg-elevated);
    border-radius: var(--radius-sm); border-left: 3px solid var(--success);
}
.essay-feedback h4 { font-size: 0.9rem; margin-bottom: 0.5rem; }
.essay-feedback p { font-size: 0.85rem; color: var(--text-secondary); }

/* ── Quiz Component (desk activity after setting down the book) ── */
.quiz-section {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; margin: 1rem 0 1.5rem;
}
.quiz-section h3 { font-size: 1rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.quiz-question {
    padding: 1rem 0; border-bottom: 1px solid var(--border);
}
.quiz-question:last-child { border-bottom: none; }
.quiz-q-text { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.75rem; }
.quiz-q-num { color: var(--primary); margin-right: 0.4rem; }
.quiz-options { display: flex; flex-direction: column; gap: 0.5rem; }
.quiz-option {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.85rem; border-radius: var(--radius-sm);
    background: var(--bg-input); border: 1px solid var(--border);
    cursor: pointer; transition: var(--transition); font-size: 0.85rem;
}
.quiz-option:hover { border-color: var(--primary-border); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary-bg); }
.quiz-option.correct { border-color: var(--success); background: var(--success-bg); }
.quiz-option.wrong { border-color: var(--danger); background: var(--danger-bg); }
.quiz-radio {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--border); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.quiz-option.selected .quiz-radio { border-color: var(--primary); background: var(--primary); }
.quiz-option.correct .quiz-radio { border-color: var(--success); background: var(--success); }
.quiz-option.wrong .quiz-radio { border-color: var(--danger); background: var(--danger); }
.quiz-explanation {
    margin-top: 0.5rem; padding: 0.6rem; background: var(--bg-elevated);
    border-radius: var(--radius-xs); font-size: 0.8rem;
    color: var(--text-secondary); display: none;
}
.quiz-explanation.show { display: block; }
.quiz-actions { margin-top: 1rem; display: flex; gap: 0.75rem; }
.quiz-score {
    text-align: center; padding: 1rem; background: var(--bg-elevated);
    border-radius: var(--radius-sm); margin-bottom: 1rem;
}
.quiz-score-num { font-size: 2rem; font-weight: 800; }
.quiz-score-num.pass { color: var(--success); }
.quiz-score-num.fail { color: var(--danger); }
.quiz-pass-msg {
    margin-top: 0.5rem; font-size: 0.9rem; font-weight: 600;
    color: var(--success); padding: 0.5rem; background: rgba(16,185,129,0.1);
    border-radius: var(--radius-xs);
}
.quiz-fail-msg {
    margin-top: 0.5rem; font-size: 0.9rem; font-weight: 500;
    color: var(--danger); padding: 0.5rem; background: rgba(239,68,68,0.08);
    border-radius: var(--radius-xs);
}
.quiz-gate-msg {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 1rem 1.25rem; margin: 1rem 0;
    background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25);
    border-radius: var(--radius-sm); color: #b45309;
    font-size: 0.9rem; font-weight: 500;
}
.module-completed-badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    margin-top: 0.5rem; padding: 0.35rem 0.85rem;
    background: rgba(16,185,129,0.1); color: var(--success);
    border-radius: 999px; font-size: 0.8rem; font-weight: 600;
}

/* ── Admin Dashboard ── */
.admin-layout { padding: 2rem; }
.admin-header { margin-bottom: 2rem; }
.admin-header h1 { font-size: 1.6rem; }
.admin-tabs { display: flex; gap: 0.25rem; margin-bottom: 2rem; border-bottom: 1px solid var(--border); }
.admin-tab {
    padding: 0.65rem 1.25rem; border: none; background: transparent;
    color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: var(--transition);
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.site-checklist-cat {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    padding: 0.5rem 1rem 1rem;
}
.site-checklist-cat summary {
    cursor: pointer;
    padding: 0.35rem 0;
    font-size: 0.95rem;
}
.site-checklist-items { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.site-checklist-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.75rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
}
.site-checklist-check { flex-shrink: 0; padding-top: 0.2rem; }
.site-checklist-body { flex: 1; min-width: 0; }
.site-checklist-desc { font-size: 0.9rem; margin-bottom: 0.25rem; }
.site-checklist-notes {
    width: 100%;
    padding: 0.45rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    resize: vertical;
}

.site-backlog-new-grid {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1fr 1fr;
    max-width: 720px;
}
.site-backlog-new-grid input,
.site-backlog-new-grid textarea,
.site-backlog-new-grid select {
    padding: 0.45rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
}
.site-backlog-new-grid .site-backlog-add-btn { grid-column: 1 / -1; justify-self: start; }
.site-backlog-table .sb-title,
.site-backlog-table .sb-desc,
.site-backlog-table .sb-assignee,
.site-backlog-table .sb-due {
    box-sizing: border-box;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
}
.stat-card-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.stat-card-value { font-size: 1.8rem; font-weight: 800; }
.stat-card-value.primary { color: var(--primary); }
.stat-card-value.success { color: var(--success); }
.stat-card-value.warning { color: var(--warning); }
.stat-card-value.accent { color: var(--accent); }

/* Admin tables */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.admin-table th {
    text-align: left; padding: 0.75rem 1rem;
    font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em;
    background: var(--bg-elevated); border-bottom: 1px solid var(--border);
}
.admin-table td {
    padding: 0.75rem 1rem; font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg-hover); }

/* Essay review card */
.essay-review-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
    margin-bottom: 1rem;
}
.essay-review-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 0.75rem; flex-wrap: wrap; gap: 0.5rem;
}
.essay-review-meta { font-size: 0.8rem; color: var(--text-muted); }
.essay-review-content {
    padding: 1rem; background: var(--bg-input);
    border-radius: var(--radius-sm); font-size: 0.85rem;
    line-height: 1.6; margin: 0.75rem 0;
    max-height: 300px; overflow-y: auto;
    white-space: pre-wrap;
}
.essay-review-actions { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.essay-review-actions textarea {
    flex: 1; min-width: 300px; min-height: 80px;
    padding: 0.6rem; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: var(--font); font-size: 0.85rem;
    resize: vertical;
}
.essay-review-actions textarea:focus { outline: none; border-color: var(--primary); }
.grade-select {
    padding: 0.5rem 0.75rem; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: var(--font); font-size: 0.85rem;
}
.grade-select:focus { outline: none; border-color: var(--primary); }

/* Completion certificate */
.certificate-card {
    background: linear-gradient(135deg, var(--primary-bg), var(--accent-bg));
    border: 2px solid var(--primary-border);
    border-radius: var(--radius); padding: 2rem;
    text-align: center; margin: 2rem 0;
}
.certificate-card h2 { font-size: 1.4rem; margin-bottom: 0.5rem; color: var(--text); }
.certificate-card .cert-icon { font-size: 3rem; margin-bottom: 1rem; }
.certificate-card p { color: var(--text-secondary); font-size: 0.9rem; }

/* ── My Courses Grid ── */
.my-courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; }
.my-course-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    cursor: pointer; transition: var(--transition);
}
.my-course-card:hover { border-color: var(--primary-border); transform: translateY(-2px); }
.my-course-body { padding: 1.25rem; }
.my-course-body h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; }
.owned-badge { background: var(--success-bg); color: var(--success); padding: 0.2rem 0.6rem; border-radius: var(--radius-xs); font-size: 0.75rem; font-weight: 600; }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(44, 40, 37, 0.5); backdrop-filter: blur(6px);
    display: none; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal,
.modal-content {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem;
    width: 90%; max-width: 440px; max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-book);
}
.modal h2, .modal-content h2, .modal-content h3 { font-size: 1.3rem; margin-bottom: 1.25rem; }
.form-group textarea {
    width: 100%; padding: 0.6rem 0.85rem; min-height: 100px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: var(--font); font-size: 0.9rem; resize: vertical;
}
.form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.3rem; }
.form-group input, .form-group select {
    width: 100%; padding: 0.6rem 0.85rem;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: var(--font); font-size: 0.9rem;
}
.form-group input:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-error { color: var(--danger); font-size: 0.8rem; min-height: 1.2rem; }
.form-submit {
    width: 100%; padding: 0.7rem; background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius-sm); font-weight: 600;
    font-size: 0.95rem; cursor: pointer; margin-top: 0.5rem;
    transition: var(--transition);
}
.form-submit:hover { background: var(--primary-hover); }
.form-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.form-switch { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--text-muted); }
.form-switch a { color: var(--primary); cursor: pointer; font-weight: 600; }

.checkout-summary { display: flex; gap: 1rem; margin-bottom: 1.25rem; align-items: center; }
.checkout-summary img { width: 80px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); }
.cs-title { font-weight: 600; }
.cs-price { font-size: 1.2rem; font-weight: 800; color: var(--success); }

/* Checkout tabs */
.checkout-tabs {
    display: flex; gap: 0.25rem; margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.checkout-tab {
    padding: 0.55rem 1rem; border: none; background: transparent;
    color: var(--text-secondary); font-size: 0.85rem; font-weight: 600;
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: var(--transition);
}
.checkout-tab:hover { color: var(--text); }
.checkout-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Balance display */
.checkout-balance-info {
    padding: 1.25rem; margin-bottom: 1rem;
    background: var(--success-bg); border: 1px solid var(--success-border);
    border-radius: var(--radius-sm); text-align: center;
}
.balance-display { display: flex; justify-content: center; align-items: baseline; gap: 0.5rem; }
.balance-label { font-size: 0.85rem; color: var(--text-secondary); }
.balance-amount { font-size: 1.6rem; font-weight: 800; color: var(--success); }
.balance-after { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.5rem; }

/* Cash App instructions */
.cashapp-instructions { margin-bottom: 1rem; }
.cashapp-step {
    display: flex; align-items: flex-start; gap: 0.75rem;
    padding: 0.65rem 0; border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.cashapp-step:last-child { border-bottom: none; }
.cashapp-step-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.cashapp-tag { color: var(--success); font-size: 1rem; }

/* Pending order cards */
.pending-order-card {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.85rem 1rem; margin-bottom: 0.5rem;
    background: var(--bg-card); border: 1px solid var(--warning-bg);
    border-left: 3px solid var(--warning); border-radius: var(--radius-sm);
}
.pending-order-info { display: flex; flex-direction: column; gap: 0.2rem; }
.pending-order-meta { font-size: 0.78rem; color: var(--text-muted); }
.pending-order-badge {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    padding: 0.25rem 0.6rem; border-radius: 99px;
    background: var(--warning-bg); color: var(--warning);
    letter-spacing: 0.04em;
}

/* Admin pending review card */
.pending-review-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius); padding: 1.25rem;
    margin-bottom: 1rem;
}
.pending-review-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 0.5rem; flex-wrap: wrap; gap: 0.5rem;
}
.pending-review-meta { font-size: 0.8rem; color: var(--text-muted); }
.message-unread { border-left-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--bg-card)); }
.message-list .pending-review-card { margin-bottom: 1rem; }

/* ── Messages page & private message cards ── */
.messages-page { max-width: 42rem; }
.messages-page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.messages-page-header .section-title { margin-bottom: 0.25rem; }
.messages-page-header .section-subtitle { margin-bottom: 0; }
.empty-state-messages { padding: 2.5rem 2rem; }

.message-list { display: flex; flex-direction: column; gap: 1rem; }
.message-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.message-card.message-unread {
    border-left-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, var(--bg-card));
}
.message-card-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem;
}
.message-card-from { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; }
.message-card-subject { color: var(--text-muted); font-size: 0.9rem; font-weight: normal; }
.message-card-meta { font-size: 0.8rem; color: var(--text-muted); }
.message-badge-new {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.5rem;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.message-card-body {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    margin-bottom: 1rem;
}
.message-card-actions {
    display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
}

/* Messages sub-tabs (Inbox | Friends) */
.messages-tabs {
    display: flex; gap: 0.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border);
}
.messages-tab {
    padding: 0.5rem 1rem; font-size: 0.9rem; font-weight: 500;
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-secondary); cursor: pointer; margin-bottom: -1px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.messages-tab:hover { color: var(--text); }
.messages-tab.active {
    color: var(--primary); border-bottom-color: var(--primary);
}

/* Friends panel */
.messages-panel { min-height: 12rem; }
.friends-section {
    margin-bottom: 2rem; padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.friends-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.friends-section-title {
    font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text);
}
.friends-search-row {
    display: flex; gap: 0.5rem; margin-bottom: 0.75rem;
}
.friends-search-row .form-control,
.friends-search-row input[type="text"] {
    flex: 1; padding: 0.5rem 0.75rem;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.9rem;
}
.friend-search-results { min-height: 2rem; }
.friends-search-hint { font-size: 0.85rem; color: var(--text-muted); margin: 0.5rem 0; }
.friend-search-results-list,
.friend-requests-list,
.friends-list {
    list-style: none; padding: 0; margin: 0;
}
.friend-search-item,
.friend-request-item,
.friend-item {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.friend-search-item:last-child,
.friend-request-item:last-child,
.friend-item:last-child { border-bottom: none; }
.friends-empty { font-size: 0.9rem; color: var(--text-muted); margin: 0; }

/* New message modal select (form-control used for consistency) */
.form-control {
    width: 100%; padding: 0.6rem 0.85rem;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: var(--font); font-size: 0.9rem;
}

/* ── Nav Wallet & XP Badge ── */
.nav-wallet {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    border-radius: 99px;
    color: var(--success);
    font-weight: 700; font-size: 0.85rem;
    white-space: nowrap;
}
.nav-wallet svg { opacity: 0.8; }
.nav-wallet-amount { font-family: var(--font-mono); letter-spacing: -0.02em; }
.nav-wallet .price-ref { display: block; }

.nav-xp-badge {
    display: flex; align-items: center; gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    background: var(--primary-bg);
    border: 1px solid var(--primary-border);
    border-radius: 99px;
    font-size: 0.75rem; font-weight: 700;
    white-space: nowrap;
}
.nav-xp-level {
    color: var(--primary);
    font-family: var(--font-mono);
}
.nav-xp-amount {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ── XP Summary Card ── */
.xp-goals-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.xp-summary-card {
    display: flex; align-items: center; gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--bg-card), color-mix(in srgb, var(--primary) 5%, var(--bg-card)));
    border: 1px solid var(--primary-border);
    border-radius: var(--radius);
}
.xp-level-ring { flex-shrink: 0; }
.xp-info { flex: 1; min-width: 0; }
.xp-rank-title {
    font-size: 0.8rem; font-weight: 700; color: var(--primary);
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.15rem;
}
.xp-total { font-size: 1.5rem; font-weight: 800; color: var(--text); margin-bottom: 0.5rem; }
.xp-level-bar {
    height: 6px; background: var(--bg-input);
    border-radius: 3px; overflow: hidden; margin-bottom: 0.3rem;
}
.xp-level-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.5s ease;
}
.xp-level-labels {
    display: flex; justify-content: space-between;
    font-size: 0.7rem; color: var(--text-muted);
}
.xp-today {
    text-align: center;
    padding: 0.75rem 1rem;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.xp-today-num { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.xp-today-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }

/* ── Daily Goals Card ── */
.daily-goals-card {
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.dg-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.75rem;
}
.dg-title {
    display: flex; align-items: center; gap: 0.5rem;
    font-weight: 700; font-size: 1rem;
}
.dg-counter {
    font-size: 0.85rem; font-weight: 700; color: var(--primary);
    font-family: var(--font-mono);
}
.dg-progress-wrap {
    height: 4px; background: var(--bg-input); border-radius: 2px;
    overflow: hidden; margin-bottom: 0.85rem;
}
.dg-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--accent));
    border-radius: 2px; transition: width 0.4s ease;
}
.dg-list { display: flex; flex-direction: column; gap: 0.4rem; }
.dg-item {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-xs);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    transition: var(--transition);
}
.dg-item.done {
    background: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.2);
}
.dg-check {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; flex-shrink: 0;
    color: var(--text-muted);
}
.dg-item.done .dg-check {
    background: var(--success); border-color: var(--success); color: #fff;
}
.dg-label { flex: 1; font-size: 0.85rem; font-weight: 500; }
.dg-item.done .dg-label { color: var(--text-muted); text-decoration: line-through; }
.dg-xp {
    font-size: 0.75rem; font-weight: 700; color: var(--primary);
    font-family: var(--font-mono);
}
.dg-item.done .dg-xp { color: var(--success); }
.dg-perfect {
    margin-top: 0.75rem; padding: 0.5rem;
    text-align: center; font-size: 0.82rem;
    font-weight: 600; color: var(--success);
    background: rgba(16, 185, 129, 0.08);
    border-radius: var(--radius-xs);
}

/* ── XP Toast ── */
.xp-toast {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(34, 211, 238, 0.1)) !important;
    color: var(--primary) !important;
    border-color: var(--primary-border) !important;
    font-weight: 700;
    display: flex; align-items: center; gap: 0.4rem;
}
.xp-toast-icon { color: var(--gold); font-size: 1.1rem; }
.xp-toast-label { font-weight: 500; font-size: 0.78rem; color: var(--text-secondary); margin-left: 0.25rem; }

/* ── Visual Roadmap ── */
/* Saved notes hub on course detail */
.course-saved-notes {
    margin-top: 2rem; padding: 1.25rem 1.5rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius);
}
.course-saved-notes h2 { font-size: 1.15rem; margin: 0 0 0.35rem 0; }
.course-saved-notes-desc { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 1rem 0; line-height: 1.5; }
.course-saved-notes-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.course-saved-notes-link {
    display: block; padding: 0.65rem 0.85rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-input);
    text-decoration: none; color: inherit; transition: var(--transition);
}
.course-saved-notes-link:hover { border-color: var(--primary); background: var(--primary-bg); }
.course-saved-notes-mod {
    display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary);
}
.course-saved-notes-title { display: block; font-weight: 600; font-size: 0.9rem; margin: 0.15rem 0 0.25rem 0; }
.course-saved-notes-snippet { display: block; font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }

.roadmap-section { margin-top: 2rem; }
.roadmap-section h2 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.roadmap-subtitle { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1rem; }
.roadmap-stats-row {
    display: flex; gap: 1.5rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.rm-stat {
    font-size: 0.82rem; color: var(--text-muted); font-weight: 500;
}
.rm-stat-val { font-weight: 800; color: var(--text); margin-right: 0.25rem; }
.roadmap {
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    max-width: 520px; margin: 0 auto; padding: 0 1rem;
}
.rm-start, .rm-finish {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.7rem; letter-spacing: 0.05em;
    text-transform: uppercase; z-index: 2; position: relative;
}
.rm-start {
    background: var(--primary); color: #fff;
    box-shadow: 0 0 0 4px var(--primary-bg), 0 2px 8px rgba(107, 83, 68, 0.25);
}
.rm-finish {
    background: linear-gradient(135deg, var(--gold), var(--warning));
    color: #1a1a1a;
    box-shadow: 0 0 0 4px var(--warning-bg), 0 2px 8px rgba(184, 134, 11, 0.25);
    font-size: 1.1rem;
}
.rm-step {
    display: flex; align-items: center; gap: 1rem;
    width: 85%; padding: 0.5rem 0; position: relative;
    cursor: pointer; transition: var(--transition); z-index: 2;
}
.rm-step.left { align-self: flex-start; margin-left: 2%; }
.rm-step.right { align-self: flex-end; margin-right: 2%; flex-direction: row-reverse; text-align: right; }
.rm-step.locked { cursor: not-allowed; opacity: 0.55; }
.rm-step::before {
    content: ''; position: absolute;
    left: 50%; width: 3px; top: -18px; height: 18px;
    border-left: 3px dashed var(--border);
    transform: translateX(-50%); z-index: 0;
}
.rm-step:first-of-type::before { display: none; }
.roadmap > .rm-step + .rm-step::before,
.rm-start + .rm-step::before { display: block; }
.rm-dot {
    width: 44px; height: 44px; min-width: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1rem; border: 3px solid var(--border);
    background: var(--bg-elevated); color: var(--text-muted);
    transition: var(--transition); position: relative; z-index: 2;
}
.rm-step.done .rm-dot {
    background: var(--success); border-color: var(--success); color: #fff;
    box-shadow: 0 0 0 4px var(--success-bg);
}
.rm-step.active .rm-dot {
    background: var(--primary); border-color: var(--primary); color: #fff;
    box-shadow: 0 0 0 4px var(--primary-bg);
    animation: rmPulse 2s ease-in-out infinite;
}
@keyframes rmPulse {
    0%, 100% { box-shadow: 0 0 0 4px var(--primary-bg); }
    50% { box-shadow: 0 0 0 8px rgba(99,102,241,0.08); }
}
/* Roadmap: each step is a small 3D book */
.roadmap { perspective: 700px; }
.rm-card {
    flex: 1;
    padding: 0.7rem 1rem 0.7rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.25s ease;
    min-width: 0;
    transform-style: preserve-3d;
    transform: translateZ(0);
    box-shadow: 0 2px 6px rgba(44, 40, 37, 0.06);
    position: relative;
    overflow: hidden;
}
.rm-card::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    width: 5px;
    background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 50%, var(--primary-hover) 100%);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    pointer-events: none;
    box-shadow: 1px 0 3px rgba(0,0,0,0.08);
}
.rm-step.left .rm-card::before { left: 0; }
.rm-step.right .rm-card::before { left: auto; right: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 50%, var(--primary-hover) 100%); }
.rm-step:hover:not(.locked) .rm-card {
    border-color: var(--primary-border);
    background: var(--bg-elevated);
    transform: translateZ(6px) translateY(-1px);
    box-shadow: 0 4px 14px rgba(44, 40, 37, 0.09);
}
.rm-step.done .rm-card { border-left: none; }
.rm-step.done .rm-card::before { background: linear-gradient(180deg, var(--success) 0%, #3d9960 50%, var(--success) 100%); }
.rm-step.active .rm-card { border-color: var(--primary); background: var(--primary-bg); }
.rm-step.right .rm-card { border-left: 1px solid var(--border); }
.rm-step.right.done .rm-card { border-right: none; }
.rm-step.right.done .rm-card::before { background: linear-gradient(180deg, var(--success) 0%, #3d9960 50%, var(--success) 100%); }
.rm-step.right.active .rm-card { border-right: none; border-left: 1px solid var(--primary); }
.rm-step.right.active .rm-card::before { background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 50%, var(--primary-hover) 100%); }
.rm-card-title { font-weight: 600; font-size: 0.88rem; line-height: 1.3; margin-bottom: 0.2rem; }
.rm-card-meta { font-size: 0.75rem; color: var(--text-muted); }
.rm-done-tag { color: var(--success); font-weight: 600; }
.rm-note-pill {
    display: inline-block; margin-right: 0.35rem; padding: 0.1rem 0.4rem; border-radius: 4px;
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
    background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary);
}
.rm-card-xp {
    display: inline-flex; align-items: center; gap: 0.25rem;
    margin-top: 0.3rem; font-size: 0.72rem; font-weight: 700;
    color: var(--primary); font-family: var(--font-mono);
}
.rm-step.done .rm-card-xp { color: var(--success); }
.rm-card.rm-opening {
    animation: rmCardOpen 0.4s ease-out forwards;
    pointer-events: none;
}
@keyframes rmCardOpen {
    0% { transform: translateZ(6px) translateY(-1px) rotateY(0deg); }
    50% { transform: translateZ(2px) rotateY(-14deg); }
    100% { transform: translateZ(0) rotateY(-22deg); opacity: 0.94; }
}
.roadmap > .rm-start + .rm-step { margin-top: 1.5rem; }
.roadmap > .rm-step:last-of-type { margin-bottom: 1.5rem; }

/* Connector lines */
.roadmap::before {
    content: ''; position: absolute;
    left: 50%; top: 48px; bottom: 48px;
    width: 3px; border-left: 3px dashed color-mix(in srgb, var(--border) 60%, transparent);
    transform: translateX(-50%); z-index: 0;
}

/* ── Sidebar XP Card ── */
.sidebar-xp-card {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.sidebar-xp-header {
    display: flex; align-items: center; gap: 0.65rem;
    margin-bottom: 0.5rem;
}
.sidebar-xp-ring { flex-shrink: 0; }
.sidebar-xp-title {
    font-size: 0.72rem; font-weight: 700; color: var(--primary);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.sidebar-xp-total { font-size: 0.85rem; font-weight: 800; }
.sidebar-goals-row {
    display: flex; align-items: center; gap: 0.35rem;
}
.sidebar-goal-pip {
    width: 10px; height: 10px; border-radius: 50%;
    border: 2px solid var(--border);
}
.sidebar-goal-pip.done {
    background: var(--success); border-color: var(--success);
}
.sidebar-goals-label {
    font-size: 0.7rem; color: var(--text-muted); margin-left: 0.25rem;
    font-weight: 500;
}

/* ── Refund & Held Amounts ── */
.wallet-held {
    display: flex; align-items: center; gap: 0.3rem;
    font-size: 0.7rem; color: var(--warning);
    font-weight: 600; margin-top: 0.15rem;
}
.refund-btn {
    padding: 0.35rem 0.85rem; border-radius: var(--radius-sm);
    background: transparent; border: 1px solid var(--danger);
    color: var(--danger); font-size: 0.75rem; font-weight: 600;
    cursor: pointer; transition: var(--transition);
}
.refund-btn:hover { background: var(--danger-bg); }
.refund-notice {
    padding: 0.75rem 1rem; margin-bottom: 1rem;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.82rem; color: var(--text-secondary);
    line-height: 1.5;
}
.refund-notice strong { color: var(--warning); }

/* ── Terms of Service Page ── */
.tos-page { padding: 2rem 0 4rem; }
.tos-page h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.tos-page .tos-updated { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 2rem; }
.tos-page h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; color: var(--primary); }
.tos-page h3 { font-size: 1rem; margin: 1.5rem 0 0.5rem; }
.tos-page p, .tos-page li { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 0.75rem; }
.tos-page ul { margin: 0.5rem 0 1rem 1.5rem; }
.tos-page .tos-highlight {
    padding: 1rem 1.25rem; margin: 1rem 0;
    background: var(--primary-bg); border: 1px solid var(--primary-border);
    border-radius: var(--radius-sm);
}

/* ── Church By-Laws (long-form) ── */
.bylaws-subtitle {
    max-width: 40rem;
    margin: 0.75rem auto 0;
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.65;
}
.bylaws-page {
    max-width: 42rem;
    margin: 0 auto;
    padding: 0 0 3rem;
}
.bylaws-page .bylaws-meta {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}
.bylaws-page h2 {
    font-size: 1.2rem;
    margin: 2.25rem 0 0.75rem;
    color: var(--primary);
    scroll-margin-top: 4.5rem;
}
.bylaws-page h2:first-of-type {
    margin-top: 0;
}
.bylaws-preamble h2 {
    margin-top: 0;
}
.bylaws-page p,
.bylaws-page li {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: 0.85rem;
}
.bylaws-page .bylaws-footer {
    margin-top: 2.5rem;
}

/* ── Newsletter Page ── */
.nl-hero {
    text-align: center;
    padding: 3rem 1.5rem;
    background: linear-gradient(135deg, var(--bg-card), color-mix(in srgb, var(--primary) 5%, var(--bg-card)));
    border: 1px solid var(--primary-border);
    border-radius: var(--radius);
    margin-bottom: 2rem;
}
.nl-hero-icon { color: var(--primary); margin-bottom: 1rem; }
.nl-hero h1 { font-size: 1.8rem; margin-bottom: 0.75rem; }
.nl-hero-sub { color: var(--text-secondary); max-width: 520px; margin: 0 auto 1.5rem; line-height: 1.6; }
.nl-cta-box {
    padding: 1.5rem; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    display: inline-block;
}
.nl-subscribe-box { display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.nl-subscribed-badge {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 1rem; background: var(--success-bg);
    border: 1px solid var(--success-border);
    border-radius: 99px; color: var(--success);
    font-weight: 700; font-size: 0.9rem;
}
.nl-free-course-box {
    margin-top: 1.5rem; padding: 1.5rem;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-sm); text-align: left;
}
.nl-free-course-box h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.nl-free-course-box p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1rem; }
.nl-free-claimed-box {
    display: inline-flex; align-items: center; gap: 0.4rem;
    margin-top: 1rem; padding: 0.5rem 1rem;
    background: var(--success-bg); border: 1px solid var(--success-border);
    border-radius: var(--radius-sm); color: var(--success);
    font-size: 0.85rem; font-weight: 600;
}
.free-course-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}
.free-course-option {
    padding: 0.75rem; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: var(--transition); text-align: center;
}
.free-course-option:hover {
    border-color: var(--primary); background: var(--primary-bg);
    transform: translateY(-2px);
}
.nl-archive-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}
.nl-archive-card {
    padding: 1.25rem; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: var(--transition);
}
.nl-archive-card:hover {
    border-color: var(--primary-border);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.nl-archive-date { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.4rem; }
.nl-archive-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.5rem; line-height: 1.3; }
.nl-archive-summary { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 0.75rem; }
.nl-archive-link { font-size: 0.82rem; color: var(--primary); font-weight: 600; }
.nl-body-content { max-width: 640px; margin: 0 auto; }
.nl-body-content img { max-width: 100%; border-radius: 6px; }

/* ── Toast ── */
.toast-container { position: fixed; top: 80px; right: 1.5rem; z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    padding: 0.75rem 1.25rem; border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500; animation: slideIn 0.3s ease;
    background: var(--success-bg); color: var(--success);
    border: 1px solid var(--success-border);
}
.toast.error { background: var(--danger-bg); color: var(--danger); border-color: rgba(166, 61, 61, 0.35); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Footer ── */
.footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem 2rem; border-top: 1px solid var(--border);
    font-size: 0.8rem; color: var(--text-muted);
}
.footer-brand { font-weight: 700; color: var(--text-secondary); }
.footer-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.78rem;
    cursor: pointer;
    pointer-events: auto;
    transition: var(--transition);
}
.footer-link:hover { color: var(--primary); }

/* ── Responsive ── */
@media (max-width: 900px) {
    .cd-header { grid-template-columns: 1fr; }
    .lesson-layout {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        height: auto;
        min-height: calc(100vh - 64px);
    }
    .lesson-layout-spacer,
    .lesson-layout-spacer--right { display: none !important; }
    .lesson-gutter {
        display: none !important;
    }
    .lesson-floating-col-tabs {
        display: none !important;
    }
    .lesson-col-collapse-btn {
        display: none !important;
    }
    .lesson-layout--sidebar-collapsed .lesson-sidebar,
    .lesson-layout--filler-collapsed .lesson-right-filler {
        opacity: 1 !important;
        pointer-events: auto !important;
        overflow-y: auto !important;
        min-width: 0 !important;
    }
    .lesson-sidebar {
        position: static; height: auto;
        border-right: none; border-bottom: 1px solid var(--border);
        max-height: 300px;
        padding: 1.25rem 0 !important;
    }
    .lesson-main {
        min-height: auto;
        overflow: visible;
    }
    .lesson-main__scroll {
        padding: 1.5rem;
        min-height: auto;
        overflow: visible;
    }
    .lesson-split {
        flex-direction: column;
        gap: 1.25rem;
    }
    .lesson-split-resizer {
        display: none;
    }
    .lesson-split.lesson-split--tools-collapsed .lesson-tools-rail {
        width: 100% !important;
        flex: none !important;
        max-width: none !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        overflow: visible !important;
        padding-right: 0 !important;
    }
    .lesson-tools-rail {
        position: static;
        width: 100%;
        flex: none;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }
    .lesson-chat-slot .chat-panel {
        max-height: 600px;
    }
    .lesson-right-filler {
        position: static;
        height: auto;
        max-width: none;
        justify-self: stretch;
        border-left: none;
        border-top: 1px solid var(--border-light);
        padding: 1.5rem 1.25rem;
    }
    .hero h1 { font-size: 2rem; }
    .hero-stats { gap: 1.5rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .xp-goals-row { grid-template-columns: 1fr; }
    .xp-summary-card { flex-wrap: wrap; }
}
@media (max-width: 600px) {
    .navbar { padding: 0 1rem; }
    .nav-links { gap: 0.5rem; }
    .nav-wallet { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
    .nav-xp-badge { display: none; }
    .courses-grid { grid-template-columns: 1fr; }
    .my-courses-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.6rem; }
    .hero-stats { flex-direction: column; gap: 0.75rem; }
    .lesson-main { padding: 1rem; }
    .admin-tabs { overflow-x: auto; }
    .flashcard-grid { grid-template-columns: 1fr; }
}

/* ── Content Protection ── */
.rendered-md, .lesson-main, .flashcards-section, .quiz-section {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.rendered-md img {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}
.notes-textarea, .essay-textarea, .notes-panel input, .notes-panel textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}
@media print {
    body * { display: none !important; }
    body::after {
        display: block !important;
        content: "Printing is disabled to protect course content.";
        font-size: 2rem;
        text-align: center;
        padding: 4rem;
        color: #666;
    }
}

/* ── Admin-Specific Layout ── */
:root {
    --admin-accent: #f59e0b;
    --admin-accent-dim: rgba(245, 158, 11, 0.12);
    --admin-accent-border: rgba(245, 158, 11, 0.25);
    --admin-bg: rgba(245, 158, 11, 0.04);
}

.admin-navbar {
    border-bottom-color: var(--admin-accent-border) !important;
    background: linear-gradient(180deg, rgba(245,158,11,0.06) 0%, var(--bg) 100%) !important;
}
.nav-role-tag {
    display: inline-flex;
    align-items: center;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--admin-accent);
    color: #1a1d27;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.4rem;
    vertical-align: middle;
}
.admin-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--admin-accent) !important;
    font-weight: 600 !important;
}
.admin-nav-link:hover {
    color: #fbbf24 !important;
}

.admin-hero {
    background: linear-gradient(135deg, rgba(245,158,11,0.08) 0%, var(--bg) 50%, rgba(90,125,90,0.06) 100%) !important;
    border-bottom: 1px solid var(--admin-accent-border);
}
.admin-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--admin-accent);
    color: #1a1d27;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.35rem 0.9rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
}

.admin-page-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    margin-bottom: 1.5rem;
    background: var(--admin-accent-dim);
    border: 1px solid var(--admin-accent-border);
    border-radius: var(--radius-sm);
    color: var(--admin-accent);
    font-size: 0.82rem;
    font-weight: 600;
}

.admin-course-detail .cd-header { border-color: var(--admin-accent-border); }

.admin-sidebar-card {
    padding: 1rem;
    background: var(--admin-accent-dim);
    border: 1px solid var(--admin-accent-border);
    border-radius: var(--radius-sm);
    margin-top: 1rem;
}
.admin-card-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--admin-accent);
    margin-bottom: 0.5rem;
}

.admin-module-card {
    border-left: 3px solid var(--admin-accent-border) !important;
    cursor: pointer !important;
}
.admin-module-card:hover {
    border-left-color: var(--admin-accent) !important;
    background: var(--admin-accent-dim) !important;
}

.admin-sidebar-banner {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    background: var(--admin-accent);
    color: #1a1d27;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.admin-sidebar .sidebar-header h3 {
    border-left: 3px solid var(--admin-accent);
    padding-left: 0.5rem;
}

.admin-lesson-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    margin-bottom: 1rem;
    background: var(--admin-accent-dim);
    border: 1px solid var(--admin-accent-border);
    border-radius: var(--radius-sm);
    color: var(--admin-accent);
    font-size: 0.8rem;
    font-weight: 600;
}
.admin-banner-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.admin-banner-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-view .lesson-nav .lesson-nav-btn.primary {
    border-color: var(--admin-accent) !important;
    color: var(--admin-accent) !important;
}
.admin-view .lesson-nav .lesson-nav-btn.primary:hover {
    background: var(--admin-accent-dim) !important;
}
.admin-view .sidebar-module.active {
    border-left-color: var(--admin-accent) !important;
    background: var(--admin-accent-dim) !important;
}
.admin-view .lesson-module-num {
    color: var(--admin-accent) !important;
}

/* ── AI Tutor Chat Panel ── */
.chat-panel {
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: 600px;
    min-height: 0;
    font-family: Georgia, 'Times New Roman', serif;
}
.chat-panel.collapsed .chat-body { display: none; }
.chat-panel.collapsed .chat-chevron { transform: rotate(180deg); }

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    cursor: pointer;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    user-select: none;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 2;
}
.chat-header:hover { background: var(--bg); }
.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
}
.chat-header-left small {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.7rem;
}
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.chat-clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}
.chat-clear-btn:hover { color: var(--danger, #ef4444); background: rgba(239,68,68,0.08); }
.chat-chevron {
    color: var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chat-tabs {
    display: flex;
    gap: 0;
    padding: 0 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.chat-tab:hover { color: var(--text); }
.chat-tab.active {
    color: var(--primary);
    font-weight: 600;
    border-bottom-color: var(--primary);
}

.chat-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.chat-pane.chat-pane-admin {
    display: flex;
    flex-direction: column;
}
.chat-pane-admin .chat-input-row {
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 180px;
    max-height: 420px;
}

.chat-welcome {
    text-align: center;
    padding: 1.25rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}
.chat-welcome-icon {
    margin-bottom: 0.5rem;
    color: var(--primary);
    opacity: 0.5;
}

.chat-msg-user, .chat-msg-bot {
    max-width: 92%;
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    font-size: 0.92rem;
    line-height: 1.65;
    word-wrap: break-word;
}
.chat-msg-user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.chat-msg-bot {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 3px;
}
.chat-msg-label {
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-family: var(--font);
}
.chat-msg-user .chat-msg-label { color: rgba(255,255,255,0.7); }
.chat-msg-bot .chat-msg-label { color: var(--primary); }

.chat-msg-bot p { margin: 0.3rem 0; }
.chat-msg-bot p:first-child { margin-top: 0; }
.chat-msg-bot p:last-child { margin-bottom: 0; }
.chat-msg-bot strong { color: var(--primary); }
.chat-msg-bot code {
    background: rgba(99,102,241,0.08);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.85rem;
    font-family: var(--font-mono);
}
.chat-msg-bot blockquote {
    margin: 0.4rem 0;
    padding: 0.3rem 0.6rem;
    border-left: 3px solid var(--primary);
    background: rgba(99,102,241,0.04);
    font-size: 0.8rem;
}

.chat-typing {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.chat-typing-dots {
    display: flex;
    gap: 3px;
}
.chat-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.4;
    animation: chatBounce 1.4s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    padding: 0.5rem 0.6rem;
    border-top: 1px solid var(--border);
    background: var(--card);
}
.chat-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
    font-family: Georgia, 'Times New Roman', serif;
    resize: none;
    min-height: 38px;
    max-height: 120px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}
.chat-input:focus { border-color: var(--primary); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
}
.chat-send-btn:hover { background: var(--primary-dark, #4f46e5); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-unavailable .chat-body { padding: 1rem; }
.chat-unavailable-msg {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

.chat-config-banner {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
    padding: 0.6rem 0.65rem;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-secondary);
    background: var(--warning-bg, rgba(184, 134, 11, 0.12));
    border: 1px solid var(--warning-border, rgba(184, 134, 11, 0.35));
    border-radius: 8px;
}
.chat-config-banner p { margin: 0; }
.chat-config-banner code {
    font-size: 0.72rem;
    padding: 0.05rem 0.25rem;
    border-radius: 4px;
    background: var(--bg-input);
}

@media (max-width: 900px) {
    .chat-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 50vh;
        z-index: 100;
        background: var(--card);
        border-top: 2px solid var(--primary);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    }
    .chat-messages { max-height: 45vh; }
}

/* ══════════════════════════════════════════
   Landing Page
   ══════════════════════════════════════════ */

.hero-landing {
    padding: 6rem 2rem 5rem;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(90, 125, 90, 0.08), transparent),
        radial-gradient(ellipse 60% 50% at 80% 50%, rgba(107, 83, 68, 0.05), transparent),
        linear-gradient(180deg, var(--bg-warm) 0%, var(--bg) 100%);
    border-bottom: 1px solid var(--border);
}
.hero-landing h1 { font-size: 3.2rem; max-width: 800px; margin: 0 auto 1.25rem; }
.hero-landing > .hero-content > p { max-width: 640px; font-size: 1.15rem; }
.hero-eyebrow {
    display: inline-block;
    font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--primary); margin-bottom: 1rem;
    background: var(--primary-bg); padding: 0.35rem 1rem; border-radius: 99px;
    border: 1px solid var(--primary-border);
}
.hero-actions {
    display: flex; gap: 1rem; margin-top: 2rem; flex-wrap: wrap;
    justify-content: center;
}
.hero-btn-outline {
    background: var(--bg-card) !important;
    border: 2px solid var(--border) !important;
    color: var(--text) !important;
    box-shadow: var(--shadow-sm);
}
.hero-btn-outline:hover {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    background: var(--primary-bg) !important;
    box-shadow: var(--shadow);
}
.hero-about { padding: 5rem 2rem 4rem; }
.hero-about h1 { font-size: 2.6rem; }

.hero-briefs { padding: 4rem 2rem 3rem; }
.hero-briefs h1 { font-size: 2.4rem; }
.hero-briefs > .hero-content > p { max-width: 640px; }

/* Public Case Briefs page */
.case-briefs-page { padding: 2rem 0 4rem; }
.case-briefs-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 2.5rem;
    align-items: start;
}
.case-briefs-index {
    position: sticky;
    top: 88px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
.case-briefs-index-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.case-briefs-subject {
    margin-top: 1rem;
}
.case-briefs-subject:first-of-type {
    margin-top: 0;
}
.case-briefs-subject-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
    line-height: 1.3;
}
.case-briefs-index-list {
    list-style: none;
}
.case-briefs-index-list li { margin-bottom: 0.35rem; }
.case-briefs-index-list a {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 0.25rem 0;
    border-radius: var(--radius-xs);
    line-height: 1.35;
}
.case-briefs-index-list a:hover { color: var(--primary); background: var(--primary-bg); }
.case-briefs-content {
    min-width: 0;
    font-size: 1rem;
    line-height: 1.7;
}
.case-briefs-content h2 { margin-top: 2rem; margin-bottom: 0.75rem; font-size: 1.35rem; }
.case-briefs-content h3 { margin-top: 1.5rem; margin-bottom: 0.5rem; font-size: 1.15rem; }
.case-briefs-content h4 {
    margin-top: 2rem; margin-bottom: 0.5rem; font-size: 1.1rem;
    scroll-margin-top: 100px;
}
.case-briefs-content p { margin-bottom: 0.75rem; }
.case-briefs-content ul, .case-briefs-content ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.case-briefs-content strong { color: var(--text); }
@media (max-width: 900px) {
    .case-briefs-layout { grid-template-columns: 1fr; }
    .case-briefs-index { position: static; max-height: none; }
}

/* Case Briefs: toolbar, cards, reader (new index + single-case UI) */
.case-briefs-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}
.case-briefs-search {
    flex: 1;
    min-width: 200px;
    max-width: 360px;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
}
.case-briefs-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-bg);
}
.case-briefs-module-filter {
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    min-width: 180px;
}
.case-briefs-count {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-left: auto;
}
.case-briefs-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.case-briefs-card {
    display: block;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}
.case-briefs-card:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}
.case-briefs-card:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-bg);
}
.case-briefs-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.35rem 0;
    line-height: 1.35;
}
.case-briefs-card-cited {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}
.case-briefs-empty,
.case-briefs-not-found {
    color: var(--text-muted);
    padding: 2rem;
    text-align: center;
}
.case-briefs-not-found {
    background: var(--primary-bg);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.case-briefs-reader .case-briefs-reader-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.case-briefs-back {
    display: inline-block;
    font-size: 0.9rem;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 0.5rem;
}
.case-briefs-back:hover {
    text-decoration: underline;
}
.case-briefs-reader-title {
    font-size: 1.35rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
}
.case-briefs-reader-scroll {
    margin-bottom: 2rem;
}
.case-briefs-reader .case-briefs-content {
    max-width: 720px;
}
@media (max-width: 640px) {
    .case-briefs-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .case-briefs-search { max-width: none; }
    .case-briefs-count { margin-left: 0; }
    .case-briefs-cards { grid-template-columns: 1fr; }
}

/* Features Grid */
.lp-features-section {
    padding: 4rem 0;
    background: var(--bg);
}
.lp-features-grid {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 1.5rem;
    margin-top: 2rem;
}
.lp-features-grid > .lp-feature-card { flex: 0 1 calc(33.333% - 1rem); min-width: 280px; }
.lp-feature-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem 1.5rem;
    transition: var(--transition);
}
.lp-feature-card:hover {
    border-color: var(--primary-border);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.lp-feature-icon {
    width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-bg); border-radius: var(--radius-sm);
    color: var(--primary); margin-bottom: 1.25rem;
}
.lp-feature-card h3 {
    font-size: 1.05rem; font-weight: 700; margin-bottom: 0.6rem; color: var(--text);
}
.lp-feature-card p {
    font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6;
}

/* Quotes Section */
.lp-quotes-section {
    padding: 4.5rem 0;
    background: linear-gradient(180deg, var(--bg-warm) 0%, var(--bg) 100%);
}
.lp-quotes-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem;
    margin-top: 2rem;
}
.lp-quote-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem 1.5rem 1.5rem;
    position: relative;
    transition: var(--transition);
}
.lp-quote-card:hover {
    border-color: var(--primary-border);
    box-shadow: var(--shadow);
}
.lp-quote-mark {
    font-size: 3.5rem; line-height: 1; font-family: var(--font-book);
    color: var(--primary); opacity: 0.5; position: absolute;
    top: 0.75rem; left: 1.25rem;
}
.lp-quote-card blockquote {
    font-size: 0.9rem; color: var(--text-secondary); line-height: 1.7;
    font-style: italic; margin: 0.5rem 0 1.25rem; padding: 0;
    border: none;
}
.lp-quote-source {
    display: flex; flex-direction: column; gap: 0.15rem;
    border-top: 1px solid var(--border); padding-top: 0.75rem;
}
.lp-quote-source strong {
    font-size: 0.85rem; color: var(--text); font-weight: 700;
}
.lp-quote-source span {
    font-size: 0.75rem; color: var(--text-muted);
}

/* Quote card variants */
.lp-quotes-grid-3 { grid-template-columns: repeat(3, 1fr); }
.lp-quote-card-lg blockquote { font-size: 0.95rem; }
.lp-quotes-grid:not(.lp-quotes-grid-3) {
    grid-template-columns: repeat(2, 1fr);
}

/* Eleventh Amendment Callout */
.lp-amendment-box {
    margin-top: 2rem;
    background: linear-gradient(135deg, rgba(245,158,11,0.06) 0%, rgba(239,68,68,0.04) 100%);
    border: 1px solid rgba(245,158,11,0.25);
    border-left: 4px solid var(--warning);
    border-radius: var(--radius);
    padding: 1.75rem 2rem;
}
.lp-amendment-header {
    display: flex; align-items: center; gap: 0.6rem;
    margin-bottom: 0.75rem; color: var(--warning);
}
.lp-amendment-header strong {
    font-size: 1rem; color: var(--text);
}
.lp-amendment-box p {
    font-size: 0.9rem; color: var(--text-secondary); line-height: 1.75;
    margin-bottom: 0.75rem;
}
.lp-amendment-box p strong { color: var(--text); }
.lp-amendment-cite {
    font-size: 0.82rem; color: var(--text-muted);
}
.lp-amendment-cite a {
    color: var(--primary); text-decoration: underline;
}

/* Common Law Maxims Row */
.lp-maxims-row {
    display: flex; justify-content: center; gap: 2rem;
    margin-top: 2.5rem; flex-wrap: wrap;
}
.lp-maxim {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; gap: 0.3rem;
    padding: 1rem 1.5rem;
    background: var(--primary-bg); border: 1px solid var(--primary-border);
    border-radius: var(--radius-sm);
}
.lp-maxim-latin {
    font-size: 0.9rem; font-weight: 700; color: var(--primary);
    font-style: italic;
}
.lp-maxim-eng {
    font-size: 0.78rem; color: var(--text-muted);
}

/* How It Works */
.lp-how-section { padding: 4rem 0; }
.lp-steps {
    display: flex; align-items: flex-start; justify-content: center;
    gap: 0; margin-top: 2.5rem;
}
.lp-step {
    flex: 1; max-width: 220px; text-align: center;
    padding: 0 1rem;
}
.lp-step-num {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 800; margin: 0 auto 1rem;
    background: var(--primary);
    color: #fff;
}
.lp-step h3 {
    font-size: 0.95rem; font-weight: 700; margin-bottom: 0.5rem;
    color: var(--text);
}
.lp-step p {
    font-size: 0.82rem; color: var(--text-secondary); line-height: 1.6;
}
.lp-step-connector {
    flex-shrink: 0; width: 40px; height: 2px;
    background: var(--border); margin-top: 24px;
}

/* Disciplines Grid */
.lp-disciplines-section { padding: 4rem 0; }
.lp-disciplines-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
    margin-top: 2rem;
}
.lp-discipline {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer; transition: var(--transition);
}
.lp-discipline:hover {
    border-color: var(--primary-border);
    background: var(--bg-elevated);
    transform: translateX(4px);
}
.lp-discipline svg { color: var(--primary); flex-shrink: 0; }
.lp-discipline span {
    font-size: 0.88rem; font-weight: 600; color: var(--text);
}

/* Clickable cards: clear button/card affordance (Church, About, etc.) */
.clickable-card {
    position: relative;
    border-left: 4px solid var(--primary) !important;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.clickable-card:hover {
    box-shadow: var(--shadow);
    border-left-color: var(--primary-hover) !important;
}
.clickable-card::after {
    content: "→";
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    opacity: 0.85;
}
.clickable-card:hover::after {
    color: var(--primary-hover);
    opacity: 1;
}

/* Full-Width Quote Highlight */
.lp-quote-highlight {
    padding: 3.5rem 0;
    background: linear-gradient(135deg, rgba(99,102,241,0.06) 0%, rgba(34,211,238,0.04) 100%);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.lp-quote-highlight-inner {
    max-width: 780px; margin: 0 auto; text-align: center;
    position: relative;
}
.lp-quote-highlight-mark {
    font-size: 5rem; line-height: 1; font-family: Georgia, serif;
    color: var(--primary); opacity: 0.25;
    position: absolute; top: -2rem; left: 50%; transform: translateX(-50%);
}
.lp-quote-highlight blockquote {
    font-size: 1.15rem; color: var(--text); line-height: 1.8;
    font-style: italic; margin: 0; padding: 1rem 0 1.25rem;
    border: none;
}
.lp-quote-highlight-source {
    font-size: 0.88rem; color: var(--text-muted);
}

/* Featured Courses Preview */
.lp-preview-section {
    padding: 4rem 0;
    background: linear-gradient(180deg, var(--bg) 0%, rgba(26,29,39,0.5) 100%);
}
.lp-preview-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem;
}
.lp-preview-header .section-subtitle { margin-bottom: 0; }

/* Stats Section */
.lp-stats-section {
    padding: 4rem 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.lp-stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 2rem;
    text-align: center;
}
.lp-stat-block { padding: 1.5rem; }
.lp-stat-number {
    font-size: 2.4rem; font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.5rem;
}
.lp-stat-label {
    font-size: 1rem; font-weight: 700; color: var(--text);
    margin-bottom: 0.35rem;
}
.lp-stat-desc {
    font-size: 0.82rem; color: var(--text-muted); line-height: 1.5;
}

/* CTA Section */
.lp-cta-section { padding: 4rem 0; }
.lp-cta-card {
    text-align: center;
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--accent-bg) 100%);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius);
    padding: 3.5rem 2rem;
}
.lp-cta-card h2 {
    font-size: 1.8rem; font-weight: 800; margin-bottom: 0.75rem;
}
.lp-cta-card p {
    color: var(--text-secondary); font-size: 1.05rem;
    max-width: 550px; margin: 0 auto 2rem;
}

/* Courses Page Header */
.courses-page-header { padding-top: 2.5rem; }
.courses-page-title {
    font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem;
}

/* About Page */
.about-content { padding: 2rem 0 3rem; }
.about-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 3rem;
    margin-bottom: 3rem;
}
.about-text-block h2 {
    font-size: 1.4rem; font-weight: 700; margin-bottom: 1rem;
    color: var(--text);
}
.about-text-block p {
    font-size: 0.95rem; color: var(--text-secondary); line-height: 1.7;
    margin-bottom: 1rem;
}
.about-blockquote {
    font-size: 1.05rem; line-height: 1.75; color: var(--text-secondary);
    margin: 1rem 0; padding: 1rem 0; border-left: 3px solid var(--primary); padding-left: 1.25rem;
}
.about-list {
    list-style: none; padding: 0; margin: 0.5rem 0 0;
}
.about-list li {
    font-size: 0.92rem; color: var(--text-secondary); line-height: 1.6;
    padding: 0.6rem 0 0.6rem 1.5rem; position: relative;
    border-bottom: 1px solid var(--border);
}
.about-list li:last-child { border-bottom: none; }
.about-list li::before {
    content: ''; position: absolute; left: 0; top: 1.1rem;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--primary);
}
.about-list li strong { color: var(--text); }

.about-values-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem;
    margin-bottom: 3rem;
}
.about-value {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem 1.5rem;
}
.about-value h3 {
    font-size: 1.05rem; font-weight: 700; margin-bottom: 0.6rem;
    color: var(--primary);
}
.about-value p {
    font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6;
}
.about-cta {
    text-align: center; padding: 3rem 2rem;
    background: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(34,211,238,0.04) 100%);
    border: 1px solid var(--border); border-radius: var(--radius);
}
.about-cta h2 {
    font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem;
}
.about-cta p {
    color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.95rem;
}

/* Landing Responsive */
@media (max-width: 900px) {
    .hero-landing { padding: 4rem 1.5rem 3rem; }
    .hero-landing h1 { font-size: 2.2rem; }
    .lp-features-grid { grid-template-columns: 1fr; }
    .lp-quotes-grid,
    .lp-quotes-grid-3,
    .lp-quotes-grid:not(.lp-quotes-grid-3) { grid-template-columns: 1fr; }
    .lp-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .lp-steps { flex-direction: column; align-items: center; }
    .lp-step { max-width: 100%; }
    .lp-step-connector { width: 2px; height: 24px; margin: 0; }
    .lp-disciplines-grid { grid-template-columns: repeat(2, 1fr); }
    .about-grid { grid-template-columns: 1fr; }
    .about-values-grid { grid-template-columns: 1fr; }
    .lp-maxims-row { gap: 1rem; }
}
@media (max-width: 600px) {
    .hero-landing h1 { font-size: 1.8rem; }
    .lp-stats-grid { grid-template-columns: 1fr; }
    .lp-disciplines-grid { grid-template-columns: 1fr; }
    .hero-actions { flex-direction: column; align-items: center; }
    .lp-maxims-row { flex-direction: column; align-items: center; }
    .lp-quote-highlight blockquote { font-size: 1rem; }
}

/* Forum + messages extras */
.nav-at { color: var(--primary); font-weight: 600; font-size: 0.85em; }
.messages-encrypted-subtabs { margin-bottom: 0.5rem; }
.message-encrypted-card .dm-decrypted-body { white-space: pre-wrap; word-break: break-word; }
.forum-page .forum-list {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.forum-community-card {
    padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); cursor: pointer;
}
.forum-community-card:hover { border-color: var(--primary); }
.forum-community-card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.forum-slug { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 0.5rem; }
.forum-posts-list { display: flex; flex-direction: column; gap: 0.5rem; }
.forum-post-row {
    display: flex; gap: 1rem; align-items: flex-start; padding: 0.75rem;
    border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.forum-post-row:hover { background: var(--surface-elevated); }
.forum-post-score { font-weight: 700; min-width: 2rem; text-align: center; color: var(--primary); }
.forum-post-title { font-weight: 600; }
.forum-post-meta { font-size: 0.85rem; color: var(--text-muted); }
.forum-post-article .forum-post-body { line-height: 1.6; }
.forum-post-images {
    display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem;
}
.forum-post-img {
    max-width: 100%; max-height: 420px; border-radius: 8px; border: 1px solid var(--border);
    object-fit: contain; background: var(--surface-elevated);
}
.forum-has-img { opacity: 0.85; }

/* Social */
.social-page .social-tabs { margin-bottom: 0.5rem; }
.social-feed-list { display: flex; flex-direction: column; gap: 1rem; }
.social-feed-card {
    padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card);
}
.social-feed-head { margin-bottom: 0.5rem; font-size: 0.95rem; }
.social-feed-time { color: var(--text-muted); font-size: 0.85rem; margin-left: 0.35rem; }
.social-feed-body { line-height: 1.55; margin-bottom: 0.75rem; word-break: break-word; }
.social-feed-images {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.social-feed-img {
    width: 100%; max-height: 320px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
}
.social-feed-video-wrap video.social-feed-video { max-width: 100%; border-radius: 8px; max-height: 480px; }
.social-feed-actions {
    margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
}
.social-like-btn.liked { color: var(--primary); border-color: var(--primary); }
.social-comments-panel {
    margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border);
}
.social-comments-panel.social-comments-short { border-top-color: var(--border); }
.social-comment-row { margin: 0.5rem 0; font-size: 0.9rem; line-height: 1.45; word-break: break-word; }
.social-comment-compose { margin-top: 0.5rem; }
.social-comment-compose .btn-sm { margin-top: 0.35rem; }
.social-comments-empty,
.social-comments-err { font-size: 0.9rem; color: var(--text-muted); margin: 0.25rem 0; }
.social-load-more-wrap { margin: 1.25rem 0; text-align: center; }
.username-setup-banner {
    background: var(--surface-elevated, #f5f0e8); border-bottom: 1px solid var(--border);
    padding: 0.65rem 1.25rem;
}
html[data-theme="dark"] .username-setup-banner { background: var(--surface-elevated); }
.username-setup-banner-inner {
    max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap;
    align-items: center; gap: 0.75rem; font-size: 0.9rem;
}

.social-shorts-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem;
}
@media (max-width: 600px) {
    .social-shorts-grid { grid-template-columns: 1fr; }
}
.social-short-card {
    border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #000;
}
.social-short-inner { display: flex; flex-direction: column; }
.social-short-media video.social-short-video {
    width: 100%; aspect-ratio: 9/16; max-height: 70vh; object-fit: contain; background: #111;
}
.social-short-media .social-feed-img { width: 100%; max-height: 70vh; object-fit: cover; }
.social-short-caption {
    padding: 0.75rem; color: var(--text); background: var(--bg-card); font-size: 0.9rem; line-height: 1.4;
}
.social-short-actions {
    padding: 0.5rem 0.75rem; background: var(--bg-card);
    display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
}

/* Social — early Facebook–style layout (registered users only; no course gate) */
.social-fb-page {
    --social-fb-page-bg: #e9ebee;
    --social-fb-publisher-head: #f5f6f7;
    padding: 1rem 0 2rem;
    min-height: 65vh;
    background: var(--social-fb-page-bg);
}
html[data-theme="dark"] .social-fb-page {
    --social-fb-publisher-head: var(--surface-elevated);
    background: var(--bg);
}
.social-fb-guest-empty { max-width: 520px; margin: 2rem auto; text-align: center; }
.social-fb-guest-empty p { line-height: 1.55; }
.social-fb-shell {
    display: grid;
    grid-template-columns: 200px minmax(0, 560px) 260px;
    gap: 1rem 1.25rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    align-items: start;
}
.social-fb-main-title {
    font-family: var(--font-sans, inherit);
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    color: var(--text);
}
.social-fb-access-note {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0 0 1rem;
}
.social-fb-tabs { margin-bottom: 0.75rem; }
.social-fb-profile-card {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    padding: 0.65rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.social-fb-avatar {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    background: linear-gradient(145deg, var(--primary), #4a6fa5);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
html[data-theme="dark"] .social-fb-avatar {
    background: linear-gradient(145deg, var(--primary), var(--accent));
}
.social-fb-profile-name { font-weight: 600; font-size: 0.95rem; line-height: 1.25; }
.social-fb-profile-at { font-size: 0.8rem; margin-top: 0.15rem; line-height: 1.3; }
.social-fb-mute { color: var(--text-muted); font-size: 0.88rem; }
.btn-link-inline {
    background: none; border: none; padding: 0; margin: 0;
    color: var(--primary); text-decoration: underline; cursor: pointer;
    font: inherit;
}
.social-fb-mini-nav {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.social-fb-nav-link {
    display: block;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}
.social-fb-nav-link:hover {
    background: rgba(0, 0, 0, 0.04);
    text-decoration: none;
}
html[data-theme="dark"] .social-fb-nav-link:hover { background: rgba(255, 255, 255, 0.06); }
.social-publisher {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}
.social-publisher-head {
    background: var(--social-fb-publisher-head);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.85rem;
}
.social-publisher-label { font-weight: 600; font-size: 0.9rem; color: var(--text-secondary); }
.social-publisher-body { padding: 0.85rem 1rem 1rem; }
.social-publisher-status textarea {
    min-height: 4.5rem;
    resize: vertical;
}
.social-fb-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: -0.35rem 0 0.75rem;
}
.social-fb-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.social-publisher-submit { margin-top: 0.25rem; }
.social-my-posts-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.social-my-posts-heading {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    color: var(--text);
}
.social-my-posts-sub {
    font-size: 0.85rem;
    margin: 0 0 0.75rem;
    line-height: 1.35;
}
.social-my-posts-inner { min-height: 2rem; }
.social-my-posts-list { display: flex; flex-direction: column; gap: 0.75rem; }
.social-my-posts-empty { margin: 0; padding: 0.25rem 0; line-height: 1.45; }
.social-my-posts-err { margin: 0; color: var(--danger, #b00020); font-size: 0.9rem; }
.social-community-feed-heading {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.65rem;
    color: var(--text);
}
.social-fb-feed-wrap { min-height: 120px; }
.social-fb-widget {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.85rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.social-fb-widget-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.social-fb-friends-list { margin-bottom: 0.65rem; }
.social-fb-friend-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
}
.social-fb-friend-row:last-child { border-bottom: none; }
.social-fb-friend-initial {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: var(--surface-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.social-fb-friend-name { line-height: 1.3; word-break: break-word; }
.social-fb-widget-btn { width: 100%; margin-top: 0.25rem; }
.social-fb-widget-links {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.social-fb-widget-links a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
}
.social-fb-widget-links a:hover { text-decoration: underline; }
.social-feed-card.social-fb-story,
.social-short-card.social-fb-story-short {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.social-feed-card.social-fb-story:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.social-short-card.social-fb-story-short:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
html[data-theme="dark"] .social-feed-card.social-fb-story,
html[data-theme="dark"] .social-short-card.social-fb-story-short {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] .social-feed-card.social-fb-story:hover {
    border-color: var(--primary);
}
.social-share-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.social-publisher-head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}
.social-publisher-as { font-size: 0.82rem; color: var(--text-secondary); }
.social-publisher-tools { margin: 0.5rem 0 0.25rem; }
.social-fb-widget-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-bottom: 0.35rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.social-fb-widget-head .social-fb-widget-title {
    margin: 0;
    padding: 0;
    border: none;
}
.social-fb-widget-title-only {
    margin: 0 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    font-weight: 700;
}
.social-fb-refresh-btn { flex-shrink: 0; padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.social-empty-feed { margin-top: 0.25rem; }
.social-empty-inner { text-align: center; padding: 1.5rem 1rem; }
.social-empty-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.5rem; }
.social-empty-inner .btn-sm { margin-top: 0.75rem; }
.social-feed-error-wrap {
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
}
.social-feed-error-wrap .social-feed-error { margin-bottom: 0.75rem; color: var(--text-muted); }
.social-fb-guest-sub {
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.social-fb-guest-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}
.social-comment-max-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: -0.25rem 0 0.35rem;
}
.social-fb-col-left,
.social-fb-col-right {
    position: sticky;
    top: 4.5rem;
    align-self: start;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
}
.social-fb-tabs.messages-tab:focus-visible,
.social-fb-nav-link:focus-visible,
.social-fb-widget-links a:focus-visible,
.btn-link-inline:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
@media (max-width: 960px) {
    .social-fb-col-left,
    .social-fb-col-right {
        position: static;
        max-height: none;
        overflow: visible;
    }
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
@media (max-width: 960px) {
    .social-fb-shell {
        grid-template-columns: 1fr;
        max-width: 640px;
    }
    .social-fb-col-left {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 0.75rem;
        align-items: start;
    }
    .social-fb-mini-nav {
        flex-direction: row;
        flex-wrap: wrap;
        margin-top: 0;
        justify-content: flex-end;
    }
    .social-fb-nav-link { padding: 0.35rem 0.5rem; }
}
@media (max-width: 520px) {
    .social-fb-col-left { grid-template-columns: 1fr; }
    .social-fb-mini-nav { justify-content: flex-start; }
}

/* ── User profiles (cover, avatar, about) ── */
.profile-page {
    position: relative;
    margin: calc(-1 * var(--navbar-height, 64px) - 1rem) -1.5rem 0;
    padding-bottom: 3rem;
}
@media (min-width: 900px) {
    .profile-page { margin-left: 0; margin-right: 0; }
}
.profile-cover {
    height: 220px;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-warm);
    border-bottom: 1px solid var(--border);
}
.profile-cover-empty {
    background-image: linear-gradient(135deg, var(--primary-bg), var(--accent-bg));
}
.profile-cover-actions {
    position: absolute;
    top: calc(var(--navbar-height, 64px) + 12px);
    right: 1.25rem;
    z-index: 2;
}
.profile-cover-btn {
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.35);
}
[data-theme="dark"] .profile-cover-btn {
    background: rgba(0, 0, 0, 0.55);
}
.profile-inner {
    position: relative;
    padding-top: 0;
}
.profile-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1.25rem;
    margin-top: -72px;
    position: relative;
    z-index: 1;
}
.profile-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.profile-avatar-img,
.profile-avatar-placeholder {
    width: 148px;
    height: 148px;
    border-radius: 50%;
    border: 4px solid var(--bg-card);
    box-shadow: var(--shadow-sm);
    object-fit: cover;
    background: var(--bg-card);
}
.profile-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-muted);
    font-family: var(--font);
}
.profile-avatar-btn {
    display: block;
    margin-top: 0.5rem;
    width: 100%;
}
.profile-head-text {
    flex: 1;
    min-width: 200px;
    padding-bottom: 0.25rem;
}
.profile-display-name {
    font-size: 1.75rem;
    margin: 0 0 0.25rem;
    line-height: 1.2;
}
.profile-at {
    margin: 0;
    color: var(--text-muted);
    font-size: 1rem;
}
.profile-public-link {
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
}
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
    align-items: start;
}
@media (max-width: 900px) {
    .profile-grid { grid-template-columns: 1fr; }
}
.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
}
.profile-card h2 {
    margin: 0 0 1rem;
    font-size: 1.15rem;
}
.profile-save-row {
    margin-top: 1rem;
}
.profile-preview-shell {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-top: 0.75rem;
}
.profile-cover-mini {
    height: 100px;
}
.profile-preview-body {
    padding: 1rem 1rem 1.25rem;
    position: relative;
}
.profile-preview-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border);
    margin: -40px 0 0.5rem;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-muted);
}
.profile-preview-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.profile-bio-preview,
.profile-bio-block {
    font-size: 0.95rem;
    line-height: 1.55;
    margin-top: 0.75rem;
}
.profile-detail-line {
    margin: 0.4rem 0;
    font-size: 0.95rem;
}
.profile-public-actions {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.profile-public-details {
    margin-top: 2rem;
    max-width: 640px;
}
.profile-joined {
    font-size: 0.9rem;
    margin: 0.25rem 0 0;
}
.profile-page-wrap .loading-msg {
    padding: 3rem 0;
    text-align: center;
}
