/* ΠΛΗ Studying Workstation — clean, calm, ground-state aesthetic */

:root {
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    --radius: 10px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: 'Noto Serif', Georgia, 'Iowan Old Style', serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    /* live font (defaults to sans; switched by [data-font]) */
    --font-body: var(--font-sans);
}

/* === THEMES (Apple Books-style) === */
/* LIGHT — default, warm cream */
:root,
[data-theme="light"] {
    --bg: #faf8f3;
    --bg-card: #ffffff;
    --bg-soft: #f4efe6;
    --ink: #2a2620;
    --ink-soft: #6b6357;
    --ink-muted: #9a9183;
    --line: #e8e2d4;
    --accent: #b8893a;
    --accent-soft: #f0e2c4;
    --green: #6ba67a;
    --red: #c9665a;
    --warn: #d6a648;
    --code-bg: #1e1f24;
    --code-fg: #f4f1ea;
    --shadow: 0 1px 3px rgba(42, 38, 32, 0.06), 0 4px 12px rgba(42, 38, 32, 0.04);
}

/* SEPIA — warm beige paper, easy on the eyes */
[data-theme="sepia"] {
    --bg: #f4ecd8;
    --bg-card: #faf3df;
    --bg-soft: #ede2c5;
    --ink: #5b4636;
    --ink-soft: #7a614b;
    --ink-muted: #9c8870;
    --line: #d4c5a8;
    --accent: #8b4513;
    --accent-soft: #ebd8b6;
    --green: #6b8e23;
    --red: #a0522d;
    --warn: #b8860b;
    --code-bg: #3a2f23;
    --code-fg: #f4ecd8;
    --shadow: 0 1px 3px rgba(91, 70, 54, 0.08), 0 4px 12px rgba(91, 70, 54, 0.05);
}

/* GREY — focus / quiet paper grey */
[data-theme="grey"] {
    --bg: #ececec;
    --bg-card: #f5f5f5;
    --bg-soft: #e1e1e1;
    --ink: #2a2a2a;
    --ink-soft: #555555;
    --ink-muted: #888888;
    --line: #d0d0d0;
    --accent: #4a4a4a;
    --accent-soft: #d8d8d8;
    --green: #5a7a5a;
    --red: #a05050;
    --warn: #806b3a;
    --code-bg: #1a1a1a;
    --code-fg: #e8e8e8;
    --shadow: 0 1px 2px rgba(0,0,0,0.05), 0 4px 10px rgba(0,0,0,0.04);
}

/* DARK — true dark mode */
[data-theme="dark"] {
    --bg: #15161a;
    --bg-card: #1e2026;
    --bg-soft: #262931;
    --ink: #e8e6e1;
    --ink-soft: #b3b0a8;
    --ink-muted: #7d7a72;
    --line: #34363e;
    --accent: #d97757;
    --accent-soft: #3a2820;
    --green: #7fb98a;
    --red: #d97770;
    --warn: #e6b85c;
    --code-bg: #0d0e11;
    --code-fg: #e8e6e1;
    --shadow: 0 2px 6px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.20);
}

/* === FONTS === */
[data-font="sans"]    { --font-body: var(--font-sans); }
[data-font="serif"]   { --font-body: var(--font-serif); }
[data-font="reading"] { --font-body: 'Charter', 'Iowan Old Style', 'Palatino', Georgia, serif; }

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

html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

/* === TOP NAV === */
.topnav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}
.topnav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}
.brand {
    display: flex; align-items: center; gap: 12px;
    color: var(--ink); text-decoration: none !important;
}
.brand-logo {
    width: 38px; height: 38px;
    background: var(--accent); color: white;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif); font-weight: 700;
    font-size: 22px;
}
.brand-text strong { display: block; font-size: 15px; }
.brand-text small { color: var(--ink-soft); font-size: 12px; }
.topnav-links { display: flex; align-items: center; gap: 4px; }
.navlink {
    padding: 8px 14px; border-radius: 6px;
    color: var(--ink-soft); text-decoration: none !important;
    font-weight: 500; font-size: 14px;
}
.navlink:hover { background: var(--bg-soft); color: var(--ink); }
.navmodules { display: flex; gap: 6px; margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--line); }
.navmod {
    padding: 6px 12px; border-radius: 6px;
    background: var(--bg-soft);
    color: var(--ink); text-decoration: none !important;
    font-weight: 600; font-size: 13px;
    border-left: 3px solid var(--mod-color, var(--accent));
}
.navmod:hover { background: var(--mod-color, var(--accent)); color: white !important; }

/* === HERO === */
.hero {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-soft));
    border-radius: var(--radius);
    padding: 36px 32px;
    margin-bottom: 32px;
    box-shadow: var(--shadow);
    display: flex; justify-content: space-between; gap: 32px;
    flex-wrap: wrap;
}
.hero-left h1 {
    font-family: var(--font-serif);
    font-size: 42px;
    margin-bottom: 8px;
    color: var(--ink);
}
.hero-date { color: var(--ink-soft); font-size: 16px; margin-bottom: 4px; }
.hero-tag { color: var(--ink-muted); font-size: 14px; }
.hero-tag strong { color: var(--accent); }
.hero-right { display: flex; gap: 24px; }
.metric {
    display: flex; flex-direction: column; align-items: flex-start;
    min-width: 110px;
}
.metric-num { font-size: 32px; font-weight: 700; color: var(--ink); font-family: var(--font-serif); }
.metric-label { font-size: 13px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.5px; }
.metric-sub { font-size: 11px; color: var(--ink-muted); margin-top: 4px; }

/* === REMINDER === */
.reminder {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 28px;
    border-left: 4px solid;
    font-size: 14px;
}
.reminder-warn { background: #fdf6e8; border-color: var(--warn); color: #6e5a2a; }
.reminder-ok { background: #f0f7f1; border-color: var(--green); color: #3d6347; }
.reminder strong { display: inline-block; margin-right: 6px; }
.reminder em { color: var(--ink-soft); font-style: italic; }

/* === SECTION === */
.section { margin-bottom: 40px; }
.section h2 {
    font-family: var(--font-serif);
    font-size: 24px;
    color: var(--ink);
    margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
}
.section h2 small { color: var(--ink-muted); font-size: 14px; font-family: var(--font-body); font-weight: 400; }
.empty {
    background: var(--bg-card); padding: 24px;
    border-radius: var(--radius); border: 1px dashed var(--line);
    color: var(--ink-soft); text-align: center;
}

/* === LESSON CARDS (grid) === */
.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.lesson-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--mod-color, var(--accent));
    color: var(--ink);
    text-decoration: none !important;
    display: flex; flex-direction: column;
    transition: transform 0.15s, box-shadow 0.15s;
}
.lesson-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(42, 38, 32, 0.1); }
.lesson-card.completed { opacity: 0.65; }
.lesson-card-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
}
.badge {
    background: var(--mod-color, var(--accent));
    color: white; font-weight: 600; font-size: 11px;
    padding: 3px 9px; border-radius: 4px;
    letter-spacing: 0.5px;
}
.week { color: var(--ink-muted); font-size: 12px; }
.status-completed { color: var(--green); font-size: 18px; }
.status-enrolled { color: var(--accent); font-size: 16px; }
.lesson-card h3 {
    font-size: 16px; font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.35;
}
.lesson-en { color: var(--ink-soft); font-size: 13px; margin-bottom: 10px; font-style: italic; }
.lesson-desc { color: var(--ink-soft); font-size: 13px; margin-bottom: auto; padding-bottom: 10px; }
.lesson-card-foot {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--ink-muted);
}

/* === PHASES === */
.phase {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.phase-A { background: #e8f0e4; color: #4d6f3d; }
.phase-B { background: #e4ecf2; color: #3d5d7c; }
.phase-C { background: #f2e4e6; color: #7c3d4d; }

/* === MODULE GRID (dashboard) === */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.module-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    color: var(--ink); text-decoration: none !important;
    border-left: 5px solid var(--mod-color);
    transition: transform 0.15s;
}
.module-card:hover { transform: translateY(-2px); }
.module-code {
    background: var(--mod-color); color: white;
    padding: 4px 10px; border-radius: 4px;
    font-size: 12px; font-weight: 700;
    display: inline-block; margin-bottom: 10px;
}
.module-card h3 { font-family: var(--font-serif); font-size: 20px; margin-bottom: 4px; }
.module-en { color: var(--ink-soft); font-size: 13px; margin-bottom: 12px; font-style: italic; }
.module-weight { color: var(--ink); font-size: 13px; line-height: 1.5; }

/* === MODULE PAGE === */
.module-head {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-soft));
    border-radius: var(--radius);
    padding: 36px 32px;
    margin-bottom: 32px;
    box-shadow: var(--shadow);
    display: flex; justify-content: space-between; gap: 32px;
    flex-wrap: wrap;
    border-left: 6px solid var(--mod-color);
}
.module-code-big {
    background: var(--mod-color); color: white;
    padding: 6px 14px; border-radius: 6px;
    font-size: 14px; font-weight: 700;
    display: inline-block; margin-bottom: 10px;
}
.module-head h1 { font-family: var(--font-serif); font-size: 36px; margin-bottom: 6px; }
.module-weight-big { font-size: 14px; color: var(--ink); margin-top: 14px; max-width: 600px; }
.module-stats {
    display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start;
}
.module-stats > div {
    display: flex; flex-direction: column; align-items: flex-start; min-width: 90px;
}
.module-stats strong {
    font-size: 28px; font-weight: 700; color: var(--ink); font-family: var(--font-serif);
}
.module-stats span {
    font-size: 12px; color: var(--ink-soft); text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* === Module-wide external resources (παλιά θέματα + βοηθητικά PDFs) === */
.extra-resources {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 18px;
}
.extra-resources .er-group { margin-bottom: 14px; }
.extra-resources .er-group:last-child { margin-bottom: 0; }
.extra-resources .er-group h3 {
    font-size: 14px;
    margin: 0 0 8px;
    color: var(--accent);
    font-weight: 600;
}
.extra-resources ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 4px;
}
.extra-resources li {
    padding: 5px 0;
    font-size: 14px;
    line-height: 1.45;
    border-bottom: 1px dashed var(--line);
}
.extra-resources li:last-child { border-bottom: none; }
.extra-resources li a { color: var(--accent); }
.extra-resources .er-host {
    font-size: 11px;
    color: var(--ink-muted);
    margin-left: 8px;
    padding: 1px 6px;
    background: var(--bg-soft);
    border-radius: 999px;
}
.extra-resources .er-note,
.extra-resources .er-source {
    font-size: 12px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
}
.extra-resources-details summary {
    cursor: pointer;
    padding: 10px 14px;
    background: var(--bg-soft);
    border-radius: 6px;
    font-weight: 600;
    color: var(--ink);
}
.extra-resources-details summary:hover { background: var(--accent-soft); }
.extra-resources-details[open] summary { margin-bottom: 10px; }

/* === Minimal "N✦" discovery-count badge on lesson cards === */
.disc-count {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    background: rgba(107, 166, 122, 0.15);
    color: var(--green);
    border: 1px solid var(--green);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}
.disc-count-mini {
    display: inline-flex;
    align-items: center;
    padding: 0 5px;
    background: rgba(107, 166, 122, 0.18);
    color: var(--green);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
    margin-right: 3px;
}
[data-theme="dark"] .disc-count,
[data-theme="dark"] .disc-count-mini { background: rgba(127, 185, 138, 0.18); }

/* === Lesson page: matched-discoveries banner at top === */
.lesson-disc-banner {
    background: linear-gradient(180deg, rgba(107,166,122,0.10), rgba(107,166,122,0.02));
    border: 1px solid var(--green);
    border-left-width: 4px;
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 18px;
}

/* ΠΛΗ12 typologio banner — official formula sheet excerpts per lesson */
.typologio-banner {
    background: linear-gradient(180deg, rgba(184,137,58,0.10), rgba(184,137,58,0.02));
    border: 1px solid var(--accent);
    border-left-width: 4px;
    padding: 12px 16px 14px;
    border-radius: 10px;
    margin-bottom: 18px;
}
.typologio-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    color: var(--accent);
    font-size: 14px;
}
.typologio-icon { font-size: 20px; }
.typologio-entry {
    border-top: 1px solid rgba(184,137,58,0.20);
    padding: 8px 0;
}
.typologio-entry:first-of-type { border-top: none; padding-top: 4px; }
.typologio-entry-title {
    cursor: pointer;
    font-weight: 600;
    color: var(--ink);
    padding: 4px 0;
    list-style: none;
    user-select: none;
}
.typologio-entry-title::-webkit-details-marker { display: none; }
.typologio-entry-title::before {
    content: "▸ ";
    color: var(--accent);
    transition: transform 0.15s;
    display: inline-block;
}
.typologio-entry[open] .typologio-entry-title::before {
    content: "▾ ";
}
.typologio-entry-body {
    padding: 4px 8px 8px 18px;
    font-size: 14px;
    line-height: 1.55;
}
.typologio-entry-body p { margin: 6px 0; }
.typologio-entry-body ul { margin: 6px 0 6px 18px; }
[data-theme="dark"] .typologio-banner {
    background: linear-gradient(180deg, rgba(214,170,90,0.08), rgba(214,170,90,0.02));
}

.ldb-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--green);
    font-size: 14px;
}
.ldb-icon { font-size: 18px; }
.ldb-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 6px;
}
.ldb-item {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    grid-template-rows: auto auto;
    gap: 2px 8px;
    align-items: baseline;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 13px;
}
.ldb-item.ldb-src-pick { border-color: var(--accent); background: linear-gradient(90deg, rgba(184,137,58,0.10), var(--bg-card) 30%); }
.ldb-item.ldb-src-bridge { border-color: var(--green); }
.ldb-src-tag {
    grid-row: 1 / 3;
    align-self: start;
    font-size: 14px;
    text-align: center;
    padding-top: 2px;
}
.ldb-disc-link {
    color: var(--ink);
    text-decoration: none !important;
    grid-column: 2;
    grid-row: 1;
}
.ldb-disc-link strong { font-weight: 600; }
.ldb-disc-link:hover { color: var(--accent); }
.ldb-disc-statement {
    grid-column: 2;
    grid-row: 2;
    font-size: 12px;
    line-height: 1.4;
    color: var(--ink-soft);
}
.ldb-disc-id {
    grid-column: 3;
    grid-row: 1 / 3;
    align-self: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    color: var(--ink-muted);
    background: var(--bg-soft);
    padding: 2px 7px;
    border-radius: 3px;
    white-space: nowrap;
}

/* === DAILY FUN STATS BANNER (shown when daily minimum reached) === */
.daily-fun-stats {
    margin: 12px 0 24px;
    padding: 18px 22px;
    background: linear-gradient(135deg, rgba(107,166,122,0.10), rgba(184,137,58,0.08));
    border: 1px solid var(--green);
    border-left: 4px solid var(--green);
    border-radius: 10px;
}
.daily-fun-stats h3 {
    margin: 0 0 14px;
    font-size: 15px;
    color: var(--green);
    font-weight: 700;
}
.dfs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.dfs-stat {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    text-align: left;
}
.dfs-num {
    font-size: 22px;
    font-weight: 800;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.dfs-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--ink-soft);
    margin-top: 4px;
}
.dfs-top {
    margin: 12px 0 0;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    font-size: 13px;
}

/* === CONTINUE SHORTCUT (top of module page) === */
.continue-shortcut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    margin-bottom: 18px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--mod-color, var(--accent)) 14%, transparent), var(--bg-card));
    border: 1px solid var(--mod-color, var(--accent));
    border-left-width: 5px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--ink);
    transition: background 0.18s, transform 0.12s;
}
.continue-shortcut:hover {
    background: linear-gradient(90deg, color-mix(in srgb, var(--mod-color, var(--accent)) 22%, transparent), var(--bg-card));
    transform: translateY(-1px);
}
.continue-shortcut-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.continue-shortcut-icon {
    font-size: 22px;
    color: var(--mod-color, var(--accent));
    flex-shrink: 0;
}
.continue-shortcut-left small {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--ink-soft);
    margin-bottom: 2px;
}
.continue-shortcut-left strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
}
.continue-shortcut-arrow {
    font-size: 24px;
    color: var(--mod-color, var(--accent));
    font-weight: 300;
}

/* === BOOK FEED BANNER === */
.book-feed-banner {
    background: var(--accent-soft);
    padding: 22px 24px;
    border-radius: var(--radius);
    border-left: 4px solid var(--accent);
}
.book-feed-banner p { margin-bottom: 12px; }
.book-feed-banner code {
    background: rgba(255,255,255,0.6);
    padding: 2px 6px; border-radius: 3px;
    font-size: 13px; color: #6e5a2a;
}
.book-list {
    list-style: none;
    margin: 12px 0;
}
.book-list li {
    padding: 6px 0;
    color: var(--ink);
    font-size: 14px;
}
.book-icon { margin-right: 8px; }
.hint {
    font-size: 13px; color: var(--ink-soft);
    font-style: italic;
    margin-top: 12px;
}

/* === LESSON ROWS === */
.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-row {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    color: var(--ink); text-decoration: none !important;
    border-left: 4px solid var(--mod-color);
    display: grid;
    grid-template-columns: 110px 1fr 180px;
    gap: 18px;
    align-items: center;
    transition: background 0.15s;
}
.lesson-row:hover { background: var(--bg-soft); }
.lesson-row.completed { opacity: 0.6; }
.lesson-row.enrolled { border-left-width: 6px; }

/* === SOS exam-frequency highlighting === */
.lesson-row.sos-high {
    border-left-width: 5px;
    border-left-color: #c9665a;
    box-shadow: 0 0 0 1px rgba(201, 102, 90, 0.18);
    background: linear-gradient(90deg, rgba(201, 102, 90, 0.06), transparent 35%);
}
.lesson-row.sos-medium {
    border-left-color: #d99a2a;
    background: linear-gradient(90deg, rgba(217, 154, 42, 0.05), transparent 30%);
}
.lesson-card.sos-high {
    border-color: #c9665a;
    box-shadow: 0 2px 8px rgba(201, 102, 90, 0.15);
}
.lesson-card.sos-medium { border-color: #d99a2a; }

.sos-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
}
/* ΣΟΣΑΡΑ!!! — most intense (red, pulsing). Used for ≥70% appearance. */
.sos-tag-high,
.sos-tag-sosara {
    background: rgba(201, 102, 90, 0.20);
    color: #c9665a;
    border: 1px solid #c9665a;
    animation: sosara-pulse 2.4s ease-in-out infinite;
    text-shadow: 0 0 0.4px currentColor;
}
/* ΣΟΣ — moderate (amber). Used for 10-69%. */
.sos-tag-medium,
.sos-tag-sos {
    background: rgba(217, 154, 42, 0.15);
    color: #d99a2a;
    border: 1px solid #d99a2a;
}
@keyframes sosara-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201, 102, 90, 0); }
    50%      { box-shadow: 0 0 0 4px rgba(201, 102, 90, 0.18); }
}
.sos-tag-sosaki {
    background: var(--bg-soft);
    color: var(--ink-soft);
    border: 1px solid var(--ink-muted);
    font-size: 10px;
    padding: 1px 6px;
    opacity: 0.85;
}

.sos-pattern {
    font-size: 12px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--line);
    line-height: 1.45;
    font-style: italic;
}

/* Calendar mini-view (CSS classes via filter: sos-high=ΣΟΣΑΡΑ, sos-medium=ΣΟΣ, sos-low=ΣΟΣΑΚΙ) */
.week-lesson-link.sos-high { box-shadow: inset 3px 0 0 #c9665a; }    /* ΣΟΣΑΡΑ red */
.week-lesson-link.sos-medium { box-shadow: inset 3px 0 0 #d99a2a; }  /* ΣΟΣ amber */
.week-lesson-link.sos-low { box-shadow: inset 2px 0 0 var(--ink-muted); }   /* ΣΟΣΑΚΙ subtle */
.sos-mini { font-size: 10px; margin-right: 2px; }
.sos-mini-sosara { animation: sosara-pulse 2.4s ease-in-out infinite; padding: 0 2px; border-radius: 4px; }
.sos-mini-sosaki { opacity: 0.6; font-size: 9px; }

/* Lesson page banner */
.sos-banner {
    border-radius: 10px;
    padding: 18px 22px;
    margin-bottom: 18px;
}
.sos-banner.sos-high {
    background: linear-gradient(180deg, rgba(201, 102, 90, 0.08), rgba(201, 102, 90, 0.02));
    border: 2px solid #c9665a;
}
.sos-banner.sos-medium {
    background: rgba(217, 154, 42, 0.06);
    border: 1px solid #d99a2a;
}
.sos-banner.sos-low {
    background: var(--bg-soft);
    border: 1px solid var(--line);
}
.sos-banner-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.sos-banner-icon { font-size: 28px; }
.sos-banner-head h2 {
    margin: 0;
    flex: 1;
    font-size: 18px;
    color: var(--ink);
}
.sos-pct-big {
    font-size: 26px;
    font-weight: 800;
    color: #c9665a;
    font-variant-numeric: tabular-nums;
}
.sos-banner.sos-medium .sos-pct-big { color: #d99a2a; }
.sos-banner.sos-low .sos-pct-big { color: var(--ink-muted); font-size: 20px; }
.sos-banner-stats {
    margin: 0 0 8px;
    color: var(--ink);
    font-size: 14px;
}
.sos-banner-pattern {
    margin: 8px 0 0;
    padding: 10px 14px;
    background: var(--bg-card);
    border-left: 3px solid currentColor;
    border-radius: 4px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink);
}
.sos-banner-source {
    font-size: 11px;
    margin-top: 8px;
    text-align: right;
}
.sos-banner-info {
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--ink-soft);
}
.sos-banner-info > summary {
    cursor: pointer;
    user-select: none;
    color: var(--ink-soft);
    padding: 4px 0;
    font-weight: 600;
}
.sos-banner-info > summary:hover { color: var(--ink); }
.sos-banner-info[open] > summary { color: var(--ink); margin-bottom: 6px; }
.sos-banner-info p { margin: 6px 0; line-height: 1.5; }
.sos-banner-info ul { margin: 6px 0; padding-left: 18px; line-height: 1.7; }
.sos-banner-info li { font-size: 12.5px; }

[data-theme="dark"] .lesson-row.sos-high,
[data-theme="dark"] .lesson-card.sos-high { background: rgba(201, 102, 90, 0.08); }
[data-theme="dark"] .sos-banner.sos-high { background: rgba(201, 102, 90, 0.12); }
.lesson-row-week { display: flex; flex-direction: column; gap: 4px; }
.week-tag {
    background: var(--bg-soft); padding: 4px 8px; border-radius: 4px;
    font-size: 12px; font-weight: 600; color: var(--ink);
    text-align: center;
}
.phase-tag {
    padding: 2px 6px; border-radius: 3px; font-size: 10px;
    font-weight: 600; letter-spacing: 0.4px; text-align: center;
}
/* PRE tag — marks Phase A lessons as prerequisite/preparation. When
   `school_stage` is set on the lesson, the tag also shows the original
   school grade (e.g. "PRE · Β' Λυκείου (Θετικής)"). Color: amber accent
   matching the existing prereq-block banner. */
.pre-tag {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    background: linear-gradient(180deg, #fde9b3 0%, #f7d77d 100%);
    color: #6e5320;
    border: 1px solid #e0b85a;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.35;
    cursor: help;
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
}
.pre-tag-lg {
    font-size: 12px;
    padding: 4px 10px;
    letter-spacing: 0.5px;
}
.pre-mini {
    display: inline-block;
    padding: 0 4px;
    border-radius: 2px;
    background: #f7d77d;
    color: #6e5320;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    margin-right: 2px;
}
/* Calendar mini-view: a thin amber stripe on PRE lessons so the eye
   picks up "this is foundation work" at a glance. */
.week-lesson-link.pre-lesson {
    border-left: 3px solid #e0b85a;
}

.lesson-row-body h3 { font-size: 15px; margin-bottom: 2px; }
.lesson-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.hours { font-size: 13px; color: var(--ink-soft); }
.state {
    font-size: 11px; font-weight: 600;
    padding: 3px 9px; border-radius: 4px; letter-spacing: 0.4px;
}
.state-done { background: #e8f0e4; color: #4d6f3d; }
.state-active { background: var(--accent-soft); color: #6e5a2a; }
.state-pending { background: var(--bg-soft); color: var(--ink-muted); }

/* === CALENDAR === */
.page-head {
    margin-bottom: 28px;
}
.page-head h1 {
    font-family: var(--font-serif);
    font-size: 32px;
    margin-bottom: 6px;
}
.muted { color: var(--ink-soft); font-size: 14px; }
.phase-legend {
    display: flex; gap: 12px; margin-top: 16px;
    flex-wrap: wrap;
}
.phase-header {
    font-family: var(--font-serif);
    font-size: 22px;
    margin: 32px 0 16px;
    padding: 12px 16px;
    border-radius: var(--radius);
}
.phase-h-A { background: #e8f0e4; color: #4d6f3d; }
.phase-h-B { background: #e4ecf2; color: #3d5d7c; }
.phase-h-C { background: #f2e4e6; color: #7c3d4d; }

.week-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 32px;
}
.week-cell {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    color: var(--ink); text-decoration: none !important;
    border-top: 3px solid;
    display: flex; flex-direction: column;
    transition: transform 0.15s;
}
.week-cell:hover { transform: translateY(-2px); }
.week-cell.current { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.week-cell.past { opacity: 0.65; }
.week-cell.phase-bg-A { border-top-color: #6ba67a; }
.week-cell.phase-bg-B { border-top-color: #6b8fbb; }
.week-cell.phase-bg-C { border-top-color: #c9665a; }
.week-num {
    font-weight: 700; color: var(--ink);
    font-size: 14px;
}
.week-dates {
    color: var(--ink-soft); font-size: 11px; margin-bottom: 10px; line-height: 1.4;
}
.week-lessons { list-style: none; }
.week-lessons li { margin-bottom: 6px; }
.week-lesson-link {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 8px;
    background: var(--bg-soft);
    border-radius: 4px;
    border-left: 3px solid var(--mod-color);
    color: var(--ink); text-decoration: none !important;
    font-size: 12px;
    line-height: 1.3;
    transition: background 0.1s;
}
.week-lesson-link:hover { background: var(--mod-color); color: white !important; }
.week-lesson-link:hover .badge-mini { background: white; color: var(--mod-color); }
.week-lesson-link.done { opacity: 0.5; }
.week-lesson-link.enrolled { background: var(--accent-soft); }
.badge-mini {
    background: var(--mod-color); color: white;
    font-size: 9px; font-weight: 700;
    padding: 2px 5px; border-radius: 3px;
    letter-spacing: 0.4px;
    flex-shrink: 0;
}
.lesson-title-mini { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot.done { color: var(--green); }

/* ---------------- Month-view calendar (the actual /calendar page) ---------------- */
.cal-head { margin-bottom: 14px; }
.cal-month-nav {
    display: flex; align-items: stretch; justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.cal-nav-btn {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none !important;
    font-size: 13.5px;
    font-weight: 600;
    transition: background 0.12s, border-color 0.12s;
    display: inline-flex; align-items: center;
    min-width: 0;
    flex: 0 0 auto;
}
.cal-nav-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.cal-nav-btn.disabled {
    color: var(--ink-soft); opacity: 0.45;
    cursor: not-allowed;
}
.cal-month-label {
    flex: 1 1 auto;
    text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.cal-month-label h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.2px;
}
.cal-jump-now {
    font-size: 11.5px;
    color: var(--accent);
    text-decoration: none;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: transparent;
}
.cal-jump-now:hover { background: var(--accent); color: white; }
.cal-empty { text-align: center; padding: 30px; }

.cal-month-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 32px;
}
@media (min-width: 1100px) {
    .cal-month-grid { grid-template-columns: 1fr 1fr; }
}

.cal-week-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--ink-soft);
    padding: 14px 16px 12px;
    display: flex; flex-direction: column; gap: 10px;
    transition: box-shadow 0.15s;
}
.cal-week-card.phase-bg-A { border-left-color: #6ba67a; }
.cal-week-card.phase-bg-B { border-left-color: #6b8fbb; }
.cal-week-card.phase-bg-C { border-left-color: #c9665a; }
.cal-week-card.past { opacity: 0.7; }
.cal-week-card.current {
    box-shadow: 0 0 0 3px var(--accent), var(--shadow);
    background: var(--accent-soft, var(--bg-card));
}

.cal-week-card-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
.cal-week-head-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-week-num {
    font-weight: 800; color: var(--ink);
    font-size: 16px;
    letter-spacing: 0.3px;
}
.cal-week-dates { color: var(--ink-soft); font-size: 12px; }
.cal-now-pill {
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 2px 8px;
    border-radius: 999px;
}

.cal-week-lessons { display: flex; flex-direction: column; gap: 10px; }
.cal-week-empty {
    text-align: center;
    color: var(--ink-soft);
    font-style: italic;
    padding: 14px;
    font-size: 13px;
}

.cal-lesson-chip {
    display: block;
    padding: 12px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-left: 4px solid var(--mod-color);
    border-radius: 8px;
    color: var(--ink); text-decoration: none !important;
    transition: transform 0.1s, box-shadow 0.1s, background 0.12s;
}
.cal-lesson-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    background: var(--bg-card);
}
.cal-lesson-chip.done { opacity: 0.6; }
.cal-lesson-chip.enrolled { background: var(--accent-soft, var(--bg-soft)); }

.cal-chip-line-1 {
    display: flex; align-items: center; gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.cal-chip-mod {
    color: white;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    flex-shrink: 0;
}
.cal-chip-state {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}
.cal-chip-state.done { background: rgba(107, 166, 122, 0.18); color: #4d6f3d; }
.cal-chip-state.inprog { background: var(--accent-soft); color: var(--accent); }

.cal-chip-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.3;
    color: var(--ink);
    margin-bottom: 4px;
}
.cal-chip-desc {
    font-size: 12.5px;
    color: var(--ink-soft);
    line-height: 1.45;
    margin-bottom: 6px;
}
.cal-chip-foot {
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
    font-size: 11.5px;
    flex-wrap: wrap;
}
.cal-chip-pattern {
    flex: 1; min-width: 0;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-theme="dark"] .cal-nav-btn { background: var(--bg-card); }
[data-theme="dark"] .cal-lesson-chip { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .cal-lesson-chip:hover { background: rgba(255,255,255,0.06); }
[data-theme="dark"] .cal-week-card.current { background: rgba(217, 119, 87, 0.10); }

/* ---------------- Announcements ---------------- */
.announcements { margin: 18px 0; }
.ann-h { font-size: 16px; margin: 0 0 8px; color: var(--ink); font-weight: 700; }
.ann {
    border: 1px solid var(--line);
    border-left: 4px solid var(--ink-soft);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--bg-card);
}
.ann-info { border-left-color: #6b8fbb; background: rgba(107,143,187,0.06); }
.ann-warn { border-left-color: #d99a2a; background: rgba(217,154,42,0.07); }
.ann-ok { border-left-color: #6ba67a; background: rgba(107,166,122,0.07); }
.ann-body { font-size: 14px; line-height: 1.5; color: var(--ink); }
.ann-body p:last-child { margin-bottom: 0; }
.ann-foot { font-size: 11px; margin-top: 6px; }

/* ---------------- Free-tier banner ---------------- */
.free-tier-banner {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px;
    background: linear-gradient(180deg, #fff8e6 0%, #fdf0c8 100%);
    border: 1px solid #e8c982;
    border-radius: 10px;
    margin-bottom: 18px;
    color: #6e5320;
}
.ftb-icon { font-size: 28px; }
.ftb-body { flex: 1; font-size: 14px; }
[data-theme="dark"] .free-tier-banner {
    background: rgba(232,201,130,0.10);
    color: #e8c982;
    border-color: rgba(232,201,130,0.35);
}

/* ---------------- Paywall page ---------------- */
.paywall-hero { text-align: center; margin: 20px 0 28px; }
.paywall-hero h1 { font-size: 28px; }
.paywall-locked { display: flex; justify-content: center; margin-bottom: 24px; }
.paywall-lesson {
    max-width: 640px;
    padding: 28px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--line);
}
.paywall-tag {
    display: inline-block;
    background: var(--ink-soft); color: white;
    padding: 4px 10px; border-radius: 4px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
    margin-bottom: 10px;
}
.paywall-cta { display: flex; justify-content: center; gap: 12px; margin: 20px 0 40px; flex-wrap: wrap; }
.btn-large { padding: 14px 22px; font-size: 15px; }

/* ---------------- Subscribe page ---------------- */
.sub-plans {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    margin: 20px 0 28px;
}
@media (min-width: 780px) { .sub-plans { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .sub-plans-3 { grid-template-columns: 1fr 1fr 1fr; } }

.sub-discount-flash {
    display: inline-block;
    background: #c9665a;
    color: white;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    margin-top: 8px;
}
.plan-price-orig {
    display: inline-block;
    color: var(--ink-soft);
    font-size: 18px;
    font-weight: 600;
    text-decoration: line-through;
    margin-right: 8px;
    opacity: 0.7;
}
.plan-lifetime {
    border: 2px solid #b48a3a;
    background: linear-gradient(180deg, var(--bg-card) 0%, color-mix(in srgb, #f7d77d 12%, var(--bg-card)) 100%);
    box-shadow: 0 0 0 3px color-mix(in srgb, #f7d77d 30%, transparent), var(--shadow);
}
.plan-lifetime .plan-price { color: #8a6920; }
.plan-lifetime-badge {
    background: #b48a3a !important;
}

/* ---------------- Source tags (Phase A/B/C origin) ---------------- */
.source-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    border: 1px solid var(--line);
    background: var(--bg-card);
}
.source-workstation {
    background: rgba(107, 166, 122, 0.10);
    border-color: #6ba67a;
    color: #4d6f3d;
}
.source-university {
    background: rgba(107, 143, 187, 0.10);
    border-color: #6b8fbb;
    color: #3d5d7c;
}
.source-exams {
    background: rgba(201, 102, 90, 0.10);
    border-color: #c9665a;
    color: #7c3d4d;
}
[data-theme="dark"] .source-workstation { background: rgba(107, 166, 122, 0.18); color: #94c39e; }
[data-theme="dark"] .source-university  { background: rgba(107, 143, 187, 0.18); color: #9fb5d4; }
[data-theme="dark"] .source-exams       { background: rgba(201, 102, 90, 0.18); color: #d49b91; }

/* ---------------- Phase-nav dashboard at top of lesson page ---------------- */
.phase-nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0 0 18px;
}
@media (min-width: 780px) { .phase-nav { grid-template-columns: 1fr 1fr 1fr; } }

.phase-nav-card {
    display: block;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--ink-soft);
    border-radius: 10px;
    color: var(--ink);
    text-decoration: none !important;
    transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.phase-nav-card.phase-bg-A { border-left-color: #6ba67a; }
.phase-nav-card.phase-bg-B { border-left-color: #6b8fbb; }
.phase-nav-card.phase-bg-C { border-left-color: #c9665a; }
.phase-nav-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,0,0,.06);
    background: var(--accent-soft, var(--bg-card));
}
.phase-nav-card.active {
    box-shadow: 0 0 0 3px var(--accent), 0 1px 4px rgba(0,0,0,.04);
    background: color-mix(in srgb, var(--accent) 6%, var(--bg-card));
}
.phase-nav-card.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.pnc-row-1 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.pnc-icon { font-size: 20px; }
.pnc-label {
    font-weight: 800;
    letter-spacing: 0.6px;
    font-size: 14px;
    color: var(--ink);
}
.pnc-now {
    margin-left: auto;
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pnc-sub {
    font-size: 13.5px;
    color: var(--ink);
    font-weight: 600;
    margin-bottom: 6px;
}
.pnc-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 11.5px;
    color: var(--ink-soft);
}
.pnc-jump {
    font-weight: 600;
    color: var(--accent);
}
[data-theme="dark"] .phase-nav-card.active {
    background: rgba(217, 119, 87, 0.10);
}

/* Phase chip in lesson head was lengthened with descriptive text — give it
   a bit more breathing room and let it wrap on narrow screens. */
.lesson-meta-tags .phase {
    line-height: 1.4;
    white-space: normal;
    max-width: 100%;
}

/* ---------------- Module home — phase-section blocks ---------------- */
.phase-section {
    border-radius: 12px;
    padding: 18px 18px 10px;
    margin: 20px 0;
    background: var(--bg-card);
    border-left: 6px solid var(--ink-soft);
    box-shadow: var(--shadow);
}
.phase-section.phase-bg-A { border-left-color: #6ba67a; background: color-mix(in srgb, #6ba67a 5%, var(--bg-card)); }
.phase-section.phase-bg-B { border-left-color: #6b8fbb; background: color-mix(in srgb, #6b8fbb 5%, var(--bg-card)); }
.phase-section.phase-bg-C { border-left-color: #c9665a; background: color-mix(in srgb, #c9665a 5%, var(--bg-card)); }
.phase-section-h {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
}
.phase-section-icon { font-size: 24px; }
.phase-section-label { color: var(--ink); }
.phase-section-count { font-size: 13px; font-weight: 500; margin-left: auto; }
.phase-section-desc {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.5;
}

/* Each row gets a left stripe in its phase color */
.lesson-row.phase-row-A { border-left: 4px solid #6ba67a; }
.lesson-row.phase-row-B { border-left: 4px solid #6b8fbb; }
.lesson-row.phase-row-C { border-left: 4px solid #c9665a; }
[data-theme="dark"] .phase-section.phase-bg-A { background: rgba(107, 166, 122, 0.08); }
[data-theme="dark"] .phase-section.phase-bg-B { background: rgba(107, 143, 187, 0.08); }
[data-theme="dark"] .phase-section.phase-bg-C { background: rgba(201, 102, 90, 0.08); }

/* ---------------- Locked paragraph-widget button + subscribe popup ---------------- */
.para-int-locked {
    background: linear-gradient(180deg, #fde9b3 0%, #f7d77d 100%);
    border-color: #e0b85a;
    color: #6e5320;
    cursor: pointer;
    font-weight: 700;
}
.para-int-locked:hover { filter: brightness(1.05); }

.sub-popup-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.sub-popup-backdrop.is-open { display: flex; animation: subPopupFade .15s ease; }
@keyframes subPopupFade { from { opacity: 0 } to { opacity: 1 } }
.sub-popup {
    background: var(--bg-card);
    color: var(--ink);
    border-radius: 14px;
    max-width: 480px;
    width: 100%;
    padding: 28px 28px 22px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    position: relative;
    animation: subPopupSlide .18s ease;
}
@keyframes subPopupSlide { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }
.sub-popup-close {
    position: absolute; top: 12px; right: 14px;
    background: transparent; border: none; cursor: pointer;
    font-size: 18px; color: var(--ink-soft);
    padding: 4px 8px; border-radius: 4px;
}
.sub-popup-close:hover { background: var(--bg-soft); }
.sub-popup-title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
}
.sub-popup-body {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
}
.sub-popup-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.plan-card {
    padding: 24px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 12px;
    position: relative;
}
.plan-card h3 { margin: 0; font-size: 20px; }
.plan-price { font-size: 36px; font-weight: 800; margin: 0; color: var(--accent); }
.plan-price small { font-size: 14px; font-weight: 500; color: var(--ink-soft); margin-left: 4px; }
.plan-features { list-style: none; padding: 0; margin: 4px 0; }
.plan-features li { padding: 6px 0 6px 22px; position: relative; line-height: 1.4; font-size: 13.5px; }
.plan-features li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.plan-foot { font-size: 11.5px; line-height: 1.4; }
.plan-best { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow); }
.plan-best-badge {
    position: absolute;
    top: -10px; right: 16px;
    background: var(--accent); color: white;
    padding: 4px 10px; border-radius: 999px;
    font-size: 10.5px; font-weight: 700; letter-spacing: 0.5px;
}
.sub-current {
    background: rgba(107,166,122,0.08);
    border: 1px solid #6ba67a;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 18px;
}
.sub-stats { list-style: none; padding: 0; margin: 6px 0 0; display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; }
.sub-confirm { margin: 28px 0; padding: 18px; background: var(--bg-card); border-radius: 10px; border: 1px solid var(--line); }
.sub-claim-form { display: grid; gap: 10px; max-width: 480px; margin-top: 12px; }
.sub-claim-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.sub-claim-form input, .sub-claim-form select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; background: var(--bg-card); color: var(--ink); }
.sub-faq { margin: 28px 0; }
.sub-faq ul { padding-left: 22px; line-height: 1.7; }

/* ---------------- Donate / kickstarter page ---------------- */
.don-year { margin: 24px 0; }
.don-year-title {
    font-size: 22px;
    border-bottom: 2px solid var(--line);
    padding-bottom: 6px;
    margin: 0 0 14px;
}
.don-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 780px) { .don-grid { grid-template-columns: 1fr 1fr; } }
.don-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 10px;
}
.don-card.built { border-left: 4px solid #6ba67a; }
.don-card-head { display: flex; justify-content: space-between; align-items: center; }
.don-mod-code {
    background: var(--accent); color: white;
    padding: 4px 10px; border-radius: 4px;
    font-size: 12px; font-weight: 700; letter-spacing: 0.4px;
}
.don-built-pill {
    background: #6ba67a; color: white;
    padding: 3px 9px; border-radius: 999px;
    font-size: 10.5px; font-weight: 700;
}
.don-card h3 { margin: 0; font-size: 16px; line-height: 1.3; }
.don-progress { margin: 4px 0; }
.don-bar { background: var(--bg-soft, rgba(0,0,0,.06)); height: 12px; border-radius: 999px; overflow: hidden; }
.don-bar-fill { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 65%, white)); height: 100%; transition: width 0.5s; }
.don-bar-meta { display: flex; align-items: baseline; gap: 6px; font-size: 13px; margin-top: 6px; }
.don-pct { margin-left: auto; font-weight: 700; color: var(--accent); }
.don-note { font-size: 12.5px; line-height: 1.4; }
.don-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.don-amt-btn {
    padding: 6px 12px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.12s;
}
.don-amt-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.don-amt-custom { background: transparent; }
.don-claim summary { cursor: pointer; font-size: 12px; color: var(--ink-soft); padding: 4px 0; }
.don-claim-form { display: grid; gap: 8px; margin-top: 8px; }
.don-claim-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; }
.don-claim-form input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; background: var(--bg-card); color: var(--ink); }
.don-footer { text-align: center; padding: 24px 0; font-size: 12.5px; }

.navlink-sub {
    background: var(--accent); color: white !important;
    padding: 4px 10px; border-radius: 999px;
    font-size: 12.5px;
}
.navlink-sub:hover { filter: brightness(1.1); }

.admin-section {
    margin: 28px 0;
    padding: 18px 20px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.admin-section h2 { margin: 0 0 10px; font-size: 18px; }
.admin-form { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.admin-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.admin-form input, .admin-form textarea, .admin-form select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--ink);
    font-family: inherit;
}
.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    max-width: none;
}
.admin-form-grid button { grid-column: span 2; justify-self: start; }
.don-target-inline { display: inline-flex; gap: 4px; align-items: center; }
.dot.in-progress { color: var(--accent); }
.week-empty { color: var(--ink-muted); font-size: 11px; font-style: italic; padding: 4px 0; }

/* === LESSON DETAIL === */
.lesson-head {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border-top: 5px solid var(--mod-color);
}
.lesson-head h1 {
    font-family: var(--font-serif);
    font-size: 36px;
    margin-bottom: 6px;
    line-height: 1.2;
}
.lesson-en-big { color: var(--ink-soft); font-size: 18px; font-style: italic; }
.lesson-head-meta { margin-bottom: 14px; }
.back-link {
    color: var(--ink-soft); font-size: 14px;
    text-decoration: none !important;
}
.back-link:hover { color: var(--accent); }
.lesson-meta-tags {
    display: flex; gap: 8px; margin-top: 12px;
    flex-wrap: wrap;
}
.tag {
    background: var(--bg-soft);
    padding: 4px 10px; border-radius: 4px;
    font-size: 12px; color: var(--ink-soft);
}

.lesson-actions {
    display: flex; gap: 12px; align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.btn {
    padding: 12px 22px;
    border-radius: 6px;
    border: none;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #a5781f; }
.btn-secondary { background: var(--bg-card); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--bg-soft); }
.btn-success { background: var(--green); color: white; }
.btn-tertiary { background: transparent; color: var(--red); padding: 12px 14px; }
.btn-tertiary:hover { background: rgba(201, 102, 90, 0.1); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.hint-en { font-weight: 400; opacity: 0.85; font-size: 12px; }

.enrolled-info {
    display: flex; gap: 12px; align-items: center;
    padding: 8px 14px;
    background: var(--accent-soft);
    border-radius: 6px;
    font-size: 13px;
    color: #6e5a2a;
}
.enrolled-tag { font-weight: 600; }
.hours-tag { color: var(--ink); font-weight: 600; }

.lesson-body {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
}
@media (max-width: 900px) {
    .lesson-body { grid-template-columns: 1fr; }
    .lesson-row { grid-template-columns: 1fr; }
    .hero { flex-direction: column; }
    .hero-right { flex-wrap: wrap; }
}

.lesson-block {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.lesson-block h2 {
    font-family: var(--font-serif);
    font-size: 20px;
    margin-bottom: 12px;
    color: var(--ink);
}
.lesson-block h2 small { font-family: var(--font-body); color: var(--ink-muted); font-size: 13px; font-weight: 400; }
.bridge-block {
    background: linear-gradient(135deg, var(--accent-soft), #faf2dc);
    border-left: 4px solid var(--accent);
}
.bridge-text {
    font-family: var(--font-serif);
    font-size: 16px;
    line-height: 1.7;
    color: var(--ink);
}
.topics-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
}
.topics-list li {
    padding: 8px 12px;
    background: var(--bg-soft);
    border-radius: 4px;
    font-size: 13px;
    color: var(--ink);
}
.resource-list { list-style: none; }
.resource-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.resource-list li:last-child { border-bottom: none; }
.resource-list a { color: var(--accent); }

/* === SIDE === */
.lesson-side {}
.side-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.side-card h3 { font-family: var(--font-serif); font-size: 17px; margin-bottom: 10px; }
.hint-card { background: var(--accent-soft); border-left: 4px solid var(--accent); }
.log-session-card form { display: flex; flex-direction: column; gap: 12px; }
.log-session-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.log-session-card input,
.log-session-card textarea {
    font-family: var(--font-body);
    font-size: 14px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--bg);
    color: var(--ink);
    resize: vertical;
}
.log-session-card input:focus,
.log-session-card textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.session-list { list-style: none; }
.session-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
}
.session-list li:last-child { border-bottom: none; }
.session-list strong { color: var(--ink); font-size: 13px; }
.session-list span { color: var(--accent); font-weight: 600; }
.session-note { color: var(--ink-soft); font-size: 12px; font-style: italic; margin-top: 4px; }

/* === FOOTER === */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--line);
    padding: 14px 0;
    margin-top: 60px;
}
.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex; justify-content: space-between;
    color: var(--ink-muted);
    font-size: 12px;
}

/* === PREREQUISITES BANNER === */
.prereq-block {
    border: 1px dashed #c9a44c;
    background: linear-gradient(180deg, #fff7e0, #fef3d4);
    border-radius: 10px;
    padding: 18px 22px;
}
.prereq-block h2 {
    margin: 0 0 10px;
    color: #5a4310;
    font-size: 18px;
}
.prereq-block h2 small {
    font-weight: 400;
    font-size: 12px;
    color: #6a5018;
    margin-left: 6px;
}
.prereq-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 6px;
}
.prereq-list li {
    padding: 6px 10px;
    background: rgba(255,255,255,0.55);
    border: 1px solid rgba(201,164,76,0.4);
    border-radius: 5px;
    font-size: 13.5px;
    color: var(--ink);
}
.prereq-list li::before {
    content: "📚";
    margin-right: 8px;
}

/* === CLAUDE LESSON BLOCK === */
.claude-block {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--bg-card), var(--bg));
    border-radius: 10px;
    padding: 24px;
}
.claude-head {
    display: flex; flex-wrap: wrap; gap: 12px;
    justify-content: space-between; align-items: flex-start;
    margin-bottom: 12px;
}
.claude-head h2 { margin: 0; }
.claude-head h2 small { font-weight: 400; color: var(--ink-muted); font-size: 13px; }
.claude-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.claude-status {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    margin: 8px 0 12px;
}
.claude-status.loading { background: #fff5dd; border: 1px solid #e8c97e; color: #6a5018; }
.claude-status.error   { background: #fde6e3; border: 1px solid #e6a39d; color: #7a2118; }
.claude-status.ok      { background: #e3f3df; border: 1px solid #9ec891; color: #285a1f; }
.claude-meta {
    display: flex; flex-wrap: wrap; gap: 14px;
    color: var(--ink-muted); font-size: 12px;
    padding-bottom: 10px; margin-bottom: 14px;
    border-bottom: 1px dashed var(--line);
}
.claude-meta code { background: var(--bg); padding: 2px 6px; border-radius: 3px; }
.claude-md { line-height: 1.65; color: var(--ink); }
.claude-md h2 {
    font-family: Georgia, "Noto Serif", serif;
    font-size: 22px;
    margin: 28px 0 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--line);
}
.claude-md h3 { font-size: 17px; margin: 20px 0 8px; }
.claude-md p  { margin: 10px 0; }
.claude-md ul, .claude-md ol { margin: 10px 0 10px 22px; }
.claude-md li { margin: 4px 0; }
.claude-md code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--bg);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 13px;
}
.claude-md pre {
    background: var(--code-bg);
    color: var(--code-fg);
    padding: 14px 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 14px 0;
    font-size: 13px;
}
.claude-md pre code { background: transparent; color: inherit; padding: 0; }
.claude-md blockquote {
    border-left: 3px solid var(--accent);
    padding: 4px 14px;
    margin: 12px 0;
    color: var(--ink-soft);
    background: var(--bg);
}
.claude-stream {
    background: var(--bg);
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 14px 16px;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    line-height: 1.55;
    max-height: 60vh;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.claude-md table { border-collapse: collapse; margin: 14px 0; width: 100%; }
.claude-md th, .claude-md td {
    border: 1px solid var(--line);
    padding: 6px 10px;
    text-align: left;
    font-size: 13px;
}
.claude-md th { background: var(--bg); font-weight: 600; }

/* === SETTINGS PAGE === */
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 6px; }
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
}
.settings-card {
    border: 1px solid var(--line);
    background: var(--bg-card);
    padding: 22px;
    border-radius: 10px;
}
.settings-card h2 { margin: 0 0 8px; font-size: 19px; }
.settings-card form { margin-top: 14px; }
.settings-card label {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 12px;
    font-size: 14px;
}
.settings-card input {
    font-family: inherit;
    font-size: 14px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--bg);
    color: var(--ink);
}
.settings-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-ok   { color: #285a1f; font-size: 14px; margin: 8px 0; }
.status-warn { color: #6a5018; font-size: 14px; margin: 8px 0; }

/* === TERM CHIP + POPOVER === */
.term-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 8px 1px 9px;
    margin: 0 1px;
    border-radius: 12px;
    background: #fef3d4;
    border: 1px solid #e9c97c;
    color: #5a4310;
    font-weight: 600;
    font-size: 0.92em;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, transform 0.06s;
    white-space: nowrap;
}
.term-chip:hover { background: #fce8a4; border-color: #c9a44c; }
.term-chip:active { transform: translateY(1px); }
.term-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.term-chip-icon { font-size: 0.85em; opacity: 0.7; }

.term-popover {
    position: absolute;
    z-index: 90;
    width: 320px;
    max-width: calc(100vw - 24px);
    background: var(--bg-card);
    border: 1px solid var(--line);
    box-shadow: 0 10px 28px rgba(0,0,0,0.18);
    border-radius: 8px;
    padding: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
}
.term-popover-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: #fef3d4;
    border-top-left-radius: 8px; border-top-right-radius: 8px;
}
.term-popover-head strong { color: #5a4310; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.term-popover-close {
    background: transparent; border: none; cursor: pointer;
    color: #5a4310; font-size: 14px; padding: 0 4px;
}
.term-popover-body { padding: 12px 14px; }

/* === Ollama model chips === */
.ollama-model-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 6px;
}
.ollama-chip {
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    cursor: pointer;
}
.ollama-chip:hover { background: #fef3d4; border-color: #e9c97c; }
.ollama-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.radio-row {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.1s;
}
.radio-row:hover { background: var(--bg); }
.radio-row input[type="radio"] { margin-top: 4px; flex-shrink: 0; }
.radio-row span { display: flex; flex-direction: column; gap: 2px; }
.radio-row small { color: var(--ink-muted); font-size: 12px; }

/* === CHAT POPUP === */
.chat-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 60;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #D97757;             /* Claude warm orange */
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(217,119,87,0.40), 0 2px 6px rgba(0,0,0,0.10);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.chat-fab:hover {
    background: #C96342;
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 10px 26px rgba(217,119,87,0.50), 0 3px 8px rgba(0,0,0,0.12);
}
.chat-fab:active { transform: translateY(0) scale(0.98); }
.chat-fab:focus-visible { outline: 3px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 5px #D97757; }

.chat-fab svg { display: block; pointer-events: none; }

/* Subtle pulse ring */
.chat-fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid #D97757;
    opacity: 0.5;
    animation: chat-fab-pulse 2.4s ease-out infinite;
    pointer-events: none;
}
@keyframes chat-fab-pulse {
    0%   { transform: scale(0.95); opacity: 0.55; }
    70%  { transform: scale(1.25); opacity: 0;    }
    100% { transform: scale(1.25); opacity: 0;    }
}

body.chat-open .chat-fab { display: none; }

/* Chat head — branded accent */
.chat-head-title { display: flex; gap: 10px; align-items: center; min-width: 0; }
.chat-head-mark {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #D97757; color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
}
.chat-head-mark svg { display: block; }
.chat-head-title strong { display: block; font-size: 13px; }
.chat-head-title small { display: block; color: var(--ink-muted); font-size: 11px; margin-top: 1px; }

/* In-chat provider switcher (Claude / OpenAI / Ollama) */
.chat-provider-switch {
    display: flex;
    gap: 4px;
    padding: 6px 12px 8px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--line);
}
.cps-btn {
    flex: 1;
    padding: 5px 8px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-soft);
    cursor: pointer;
    transition: all 0.12s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.cps-btn:hover { border-color: var(--accent); color: var(--ink); }
.cps-btn.is-active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.cps-default {
    font-size: 9.5px;
    opacity: 0.7;
    font-weight: 500;
}
.cps-btn.is-active .cps-default { opacity: 0.85; }

.chat-icon-btn-close {
    color: var(--ink);
    font-weight: 700;
}
.chat-icon-btn-close:hover { background: #fde6e3; color: #7a2118; }

.chat-panel {
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    width: 460px;
    max-width: 95vw;
    background: var(--bg-card);
    border-left: 1px solid var(--line);
    box-shadow: -8px 0 24px rgba(0,0,0,0.1);
    display: none;                  /* default closed — class toggles open */
    flex-direction: column;
    z-index: 70;
}
.chat-panel.is-open { display: flex; }
.chat-panel[hidden] { display: none; }   /* honor hidden attr too */
.chat-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}
.chat-head strong { display: block; }
.chat-head small { display: block; color: var(--ink-muted); font-size: 12px; margin-top: 2px; }
.chat-head-actions { display: flex; gap: 4px; }
.chat-icon-btn {
    background: transparent; border: none; cursor: pointer;
    font-size: 16px; padding: 6px 10px; border-radius: 5px;
    color: var(--ink-muted);
}
.chat-icon-btn:hover { background: var(--bg); color: var(--ink); }

.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.chat-empty { text-align: center; padding: 30px 16px; font-size: 13px; }
.chat-msg { display: flex; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-body {
    max-width: 92%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.chat-msg-assistant .chat-msg-body { max-width: 95%; }
.chat-msg-user .chat-msg-body {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-assistant .chat-msg-body {
    background: var(--bg);
    color: var(--ink);
    border: 1px solid var(--line);
    border-bottom-left-radius: 4px;
}
.chat-msg-assistant .chat-msg-body code {
    background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
}
/* Code blocks in chat: WRAP long lines (no horizontal scroll — chat panel is too narrow) */
.chat-msg-assistant .chat-msg-body pre {
    background: var(--code-bg);
    color: var(--code-fg);
    padding: 10px 12px;
    border-radius: 5px;
    margin: 8px 0;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;       /* preserve newlines + wrap long lines */
    word-break: break-word;       /* break unbroken tokens (URLs, long names) */
    overflow-wrap: anywhere;
    max-width: 100%;
    overflow-x: hidden;
}
.chat-msg-assistant .chat-msg-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    display: block;
}
/* Inline code in chat — also wrap */
.chat-msg-assistant .chat-msg-body code {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chat-form {
    border-top: 1px solid var(--line);
    padding: 12px;
    display: flex; gap: 8px; align-items: flex-end;
    background: var(--bg);
}
.chat-form textarea {
    flex: 1;
    font-family: inherit;
    font-size: 14px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--ink);
    resize: vertical;
    min-height: 42px;
    max-height: 200px;
}
.chat-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* === DISCOVERIES PAGE === */
#disc-search {
    width: 100%;
    margin-top: 10px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-card);
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
}
#disc-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.disc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 20px;
}
.disc-card {
    border: 1px solid var(--line);
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: 8px;
    display: flex; flex-direction: column; gap: 6px;
}
.disc-card-head {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px;
}
.disc-id {
    background: var(--bg);
    padding: 2px 7px;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--ink-soft);
}
.disc-day { color: var(--ink-muted); font-size: 11px; }
.disc-card h3 {
    margin: 4px 0;
    font-size: 15px;
    font-family: Georgia, "Noto Serif", serif;
}
.disc-domain { font-size: 11px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.disc-statement { font-size: 13px; line-height: 1.5; color: var(--ink); }
.disc-chapter { font-size: 11px; }

/* === RESPONSIVE === */
@media (max-width: 700px) {
    .topnav-inner { flex-direction: column; align-items: stretch; }
    .topnav-links { overflow-x: auto; }
    .navmodules { margin-left: 0; padding-left: 0; border-left: none; }
    .container { padding: 20px 14px 60px; }
    .module-head { flex-direction: column; }
    .module-stats { gap: 16px; }
}

/* === DARK MODE OVERRIDES (for hardcoded warm/light status colors) === */
[data-theme="dark"] .claude-status.loading { background: #3a3120; border-color: #6a5018; color: #f0d68a; }
[data-theme="dark"] .claude-status.error   { background: #3a1f1c; border-color: #7a2118; color: #f4a8a0; }
[data-theme="dark"] .claude-status.ok      { background: #1f3220; border-color: #285a1f; color: #a8d8a0; }

[data-theme="dark"] .term-chip {
    background: #3a2820; border-color: #6a4830; color: #f0c890;
}
[data-theme="dark"] .term-chip:hover { background: #4a3528; border-color: #8a5840; }
[data-theme="dark"] .term-popover-head { background: #3a2820; }
[data-theme="dark"] .term-popover-head strong { color: #f0c890; }
[data-theme="dark"] .term-popover-close { color: #f0c890; }

[data-theme="dark"] .prereq-block {
    background: linear-gradient(180deg, #2d2515, #251e10);
    border-color: #6a5018;
}
[data-theme="dark"] .prereq-block h2 { color: #e8c97e; }
[data-theme="dark"] .prereq-block h2 small { color: #c9a44c; }
[data-theme="dark"] .prereq-list li {
    background: rgba(255,255,255,0.04);
    border-color: rgba(232,201,126,0.25);
}

[data-theme="dark"] .phase-A,    [data-theme="dark"] .phase-h-A    { background: #1f2e1c; color: #a8d8a0; }
[data-theme="dark"] .phase-B,    [data-theme="dark"] .phase-h-B    { background: #1c2638; color: #9bb6e0; }
[data-theme="dark"] .phase-C,    [data-theme="dark"] .phase-h-C    { background: #2e1c20; color: #e0a0a8; }
[data-theme="dark"] .pre-tag {
    background: linear-gradient(180deg, #3a2d12, #2c2110);
    color: #e8c97e;
    border-color: #6a5018;
}
[data-theme="dark"] .pre-mini {
    background: #3a2d12;
    color: #e8c97e;
}
[data-theme="dark"] .week-lesson-link.pre-lesson { border-left-color: #6a5018; }
[data-theme="dark"] .state-done   { background: #1f2e1c; color: #a8d8a0; }
[data-theme="dark"] .state-active { background: var(--accent-soft); color: var(--accent); }

[data-theme="dark"] .reminder-warn { background: #2d2515; color: #e8c97e; }
[data-theme="dark"] .reminder-ok   { background: #1f2e1c; color: #a8d8a0; }
[data-theme="dark"] .status-ok     { color: #a8d8a0; }
[data-theme="dark"] .status-warn   { color: #e8c97e; }

[data-theme="dark"] .ollama-chip:hover { background: #3a2820; border-color: #6a4830; }
[data-theme="dark"] .chat-icon-btn-close:hover { background: #3a1f1c; color: #f4a8a0; }
[data-theme="dark"] .week-lesson-link:hover .badge-mini { background: #2a2a2a; }

/* Forms in dark mode */
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select {
    color-scheme: dark;
}

/* === VERSION PICKER === */
.version-picker {
    display: inline-flex; align-items: center; gap: 6px;
    margin-left: auto;
}
.version-picker label { font-size: 12px; color: var(--ink-muted); }
.version-picker select {
    font-family: inherit; font-size: 12px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--ink);
    cursor: pointer;
    max-width: 280px;
}
.version-picker select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn-mini {
    font-size: 11px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink-muted);
    border-radius: 4px;
    cursor: pointer;
}
.btn-mini:hover { background: var(--bg-soft); color: var(--ink); }

/* === THEME / FONT PICKER (top nav) === */
.theme-picker {
    position: relative;
    display: inline-flex;
}
.theme-picker-btn {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 10px;
    color: var(--ink);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}
.theme-picker-btn:hover { background: var(--bg-soft); }
.theme-picker-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 65;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 14px;
    min-width: 240px;
}
.theme-picker-panel[hidden] { display: none; }
.theme-picker-panel h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    margin: 0 0 8px;
}
.theme-picker-panel h4:not(:first-child) { margin-top: 14px; }
.theme-options, .font-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.theme-opt, .font-opt {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--ink);
    cursor: pointer;
    font-size: 12px;
    text-align: center;
    font-family: inherit;
}
.theme-opt:hover, .font-opt:hover { border-color: var(--accent); }
.theme-opt.active, .font-opt.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
/* Mini swatches per theme */
.theme-opt[data-theme="light"]  { background: #faf8f3; color: #2a2620; }
.theme-opt[data-theme="sepia"]  { background: #f4ecd8; color: #5b4636; }
.theme-opt[data-theme="grey"]   { background: #ececec; color: #2a2a2a; }
.theme-opt[data-theme="dark"]   { background: #15161a; color: #e8e6e1; }
.theme-opt.active[data-theme="light"] { box-shadow: 0 0 0 2px var(--accent); }
.theme-opt.active[data-theme="sepia"] { box-shadow: 0 0 0 2px var(--accent); }
.theme-opt.active[data-theme="grey"]  { box-shadow: 0 0 0 2px var(--accent); }
.theme-opt.active[data-theme="dark"]  { box-shadow: 0 0 0 2px var(--accent); }
.font-opt[data-font="serif"]   { font-family: 'Noto Serif', Georgia, serif; }
.font-opt[data-font="reading"] { font-family: 'Charter', 'Iowan Old Style', Georgia, serif; }

/* === READING PROGRESS BAR (top of viewport) === */
.reading-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0;
    background: var(--accent);
    z-index: 80;
    transition: width 0.06s ease-out;
    pointer-events: none;
}

/* === LESSON END BLOCK (timer + complete button at the bottom of every lesson) === */
.lesson-end {
    margin: 48px 0 32px;
    padding: 28px 28px 32px;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--bg-soft), var(--bg-card));
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.lesson-end-timer {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 22px;
    color: var(--ink);
    transition: border-color 0.2s;
}
.lesson-end-timer.is-active { border-color: var(--green); }
.lesson-end-timer.is-paused { opacity: 0.7; border-style: dashed; }

.reading-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--ink-muted);
    flex-shrink: 0;
    transition: background 0.15s, box-shadow 0.6s;
}
.lesson-end-timer.is-active .reading-dot {
    background: var(--green);
    animation: reading-pulse 1.6s ease-in-out infinite;
}
@keyframes reading-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(107,166,122,0.6); }
    50%      { box-shadow: 0 0 0 6px rgba(107,166,122,0); }
}

.lesson-end-timer-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.2;
}
.lesson-end-timer-elapsed {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.02em;
}
.lesson-end-timer-totals {
    font-size: 11.5px;
    color: var(--ink-muted);
    margin-top: 2px;
}
.lesson-end-timer-totals span {
    color: var(--ink-soft);
    font-weight: 600;
}

.lesson-end-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}
.lesson-end-hint { font-size: 12.5px; max-width: 420px; }
.btn-big {
    font-size: 17px;
    padding: 14px 28px;
    border-radius: 10px;
    min-width: 280px;
}

/* === LESSON STATS (end-of-page reading breakdown) === */
.lesson-stats {
    width: 100%;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px 22px;
}
.lesson-stats h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-family: Georgia, serif;
    color: var(--ink);
}
.lesson-stats > p { margin-bottom: 14px; }
.lesson-stats-bars {
    list-style: none;
    padding: 0; margin: 0;
    display: grid;
    gap: 6px;
}
.stat-row {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) 2fr auto;
    gap: 12px;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}
.stat-title {
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stat-bar-wrap {
    height: 8px;
    background: var(--bg-soft);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
.stat-bar {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 4px;
}
.stat-row.stat-hard .stat-bar { background: #c9665a; }   /* longest = harder */
.stat-row.stat-mid  .stat-bar { background: var(--accent); }
.stat-row.stat-fast .stat-bar { background: #6ba67a; opacity: 0.6; }  /* skipped */
.stat-time {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--ink-soft);
    text-align: right;
    min-width: 50px;
}

.lesson-stats-questions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
}
.lesson-stats-questions summary {
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 13px;
    margin-bottom: 8px;
}
.lesson-stats-questions summary:hover { color: var(--ink); }
.lesson-stats-questions ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}
.lesson-stats-questions li {
    padding: 8px 12px;
    background: var(--bg-soft);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.45;
}
.lesson-stats-questions .qsec { display: block; font-size: 11px; margin-bottom: 2px; }
.lesson-stats-questions .qtext { color: var(--ink); }

/* === Quiz mistakes history (in stats panel) === */
.lesson-stats-mistakes {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
}
.lesson-stats-mistakes summary {
    cursor: pointer;
    color: var(--red);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
}
.lesson-stats-mistakes summary:hover { color: var(--ink); }
.lesson-stats-mistakes ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}
.mistake-row {
    padding: 10px 14px;
    background: var(--bg-soft);
    border-left: 3px solid var(--red);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
}
.mistake-q {
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
}
.mistake-line {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin-top: 3px;
}
.mistake-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.mistake-wrong {
    background: rgba(201, 102, 90, 0.15);
    color: var(--red);
    border: 1px solid var(--red);
}
.mistake-right {
    background: rgba(107, 166, 122, 0.18);
    color: var(--green);
    border: 1px solid var(--green);
}
.mistake-text { color: var(--ink); }

/* === Quiz history pill (in quiz block header) === */
.quiz-history-pill {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--ink-soft);
}
.quiz-history-pill .quiz-history-wrong {
    color: var(--red);
    font-weight: 600;
}

.quiz-final-hint {
    margin-top: 10px;
    font-size: 12.5px;
    font-style: italic;
}

.reading-current-section {
    font-style: italic;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
}

/* === LESSON RECAP === */
.lesson-recap {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--bg-card), var(--bg));
    border-radius: 10px;
    padding: 18px 22px;
}
.lesson-recap > .claude-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--line);
    color: var(--ink-soft);
    font-size: 12px;
}
.lesson-recap > #btn-gen-recap {
    margin: 8px 0;
}

/* === LESSON FLASHCARDS (deck-game) === */
/* === EXAM-LIKE TEST (gated on lesson_exam_frequency) === */
.lesson-exam-test {
    width: 100%;
    text-align: left;
    border: 2px solid #c9665a;
    background: linear-gradient(180deg, rgba(201,102,90,0.06), var(--bg-card));
    border-radius: 10px;
    padding: 18px 22px;
    margin-top: 18px;
}
.lesson-exam-test > .claude-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--line);
    color: #c9665a;
    font-weight: 600;
    font-size: 12.5px;
}
.lesson-exam-test > #btn-gen-exam-test {
    margin: 4px 0;
    background: linear-gradient(135deg, #c9665a, #d99a2a);
    color: white;
    border: none;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 12px 22px;
    box-shadow: 0 3px 10px rgba(201,102,90,0.30);
}
.lesson-exam-test > #btn-gen-exam-test:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(201,102,90,0.40);
}
.exam-test-body {
    margin-top: 8px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14.5px;
    line-height: 1.65;
}
.exam-test-body > *:first-child { margin-top: 0; }
.exam-test-body > *:last-child { margin-bottom: 0; }
.exam-test-body h1 {
    color: var(--ink);
    border-bottom: 2px solid #c9665a;
    padding-bottom: 6px;
    margin-top: 18px;
    font-size: 18px;
}
.exam-test-body h1:first-child { margin-top: 0; }
.exam-test-body h2 {
    color: #c9665a;
    font-size: 15.5px;
    margin-top: 14px;
}
.exam-test-body .claude-stream {
    margin: 0;
    background: transparent;
    border: none;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    color: var(--ink-soft);
    white-space: pre-wrap;
}

[data-theme="dark"] .lesson-exam-test {
    background: linear-gradient(180deg, rgba(201,102,90,0.10), var(--bg-card));
}

.lesson-flashcards {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--bg-card), var(--bg));
    border-radius: 10px;
    padding: 18px 22px;
    margin-top: 18px;
}
.lesson-flashcards > .claude-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--line);
    color: var(--ink-soft);
    font-size: 12px;
}
.fc-stage {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 0;
    user-select: none;
}
.fc-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.fc-progress-text {
    font-size: 12.5px;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}
.fc-progress-bar {
    height: 6px;
    background: var(--bg-soft);
    border-radius: 999px;
    overflow: hidden;
}
.fc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    transition: width 0.3s;
}

/* The flippable card: 3D flip via transform */
.fc-card {
    perspective: 1200px;
    cursor: pointer;
    width: 100%;
    max-width: 600px;
    align-self: center;
    height: 280px;
}
.fc-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-style: preserve-3d;
}
.fc-card.is-flipped .fc-card-inner { transform: rotateY(180deg); }
.fc-card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border: 2px solid var(--accent);
    border-radius: 14px;
    padding: 22px 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--bg-card);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.fc-card-front {
    background: linear-gradient(160deg, var(--bg-card) 0%, var(--accent-soft) 100%);
}
.fc-card-back {
    background: linear-gradient(160deg, rgba(107,166,122,0.12) 0%, var(--bg-card) 100%);
    border-color: var(--green);
    transform: rotateY(180deg);
}
.fc-side-label {
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--ink-muted);
    font-weight: 700;
}
.fc-cat {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 10.5px;
    color: var(--ink-soft);
    background: var(--bg-soft);
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.fc-text {
    font-size: 21px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.4;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.fc-card-back .fc-text {
    font-size: 17px;
    font-weight: 500;
}
.fc-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--ink-soft);
    background: var(--bg-soft);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}
.fc-hint summary { cursor: pointer; outline: none; }
.fc-seen {
    position: absolute;
    bottom: 30px;
    font-size: 10.5px;
    color: var(--red);
    font-style: italic;
}
.fc-tap-hint {
    position: absolute;
    bottom: 10px;
    font-size: 11px;
}

.fc-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
.fc-btn {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid;
    transition: transform 0.12s, box-shadow 0.12s;
}
.fc-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.fc-yes {
    background: var(--green);
    color: white;
    border-color: var(--green);
}
.fc-no {
    background: rgba(201,102,90,0.10);
    color: var(--red);
    border-color: var(--red);
}

.fc-shortcuts {
    text-align: center;
    font-size: 11px;
    color: var(--ink-muted);
}
.fc-shortcuts kbd {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 3px;
    padding: 1px 5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    color: var(--ink);
}

.fc-done {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, rgba(107,166,122,0.10), rgba(184,137,58,0.08));
    border: 1px solid var(--green);
    border-radius: 12px;
}
.fc-done-emoji { font-size: 56px; line-height: 1; }
.fc-done h3 { color: var(--green); margin-top: 12px; font-size: 22px; }
.fc-done .btn { margin-top: 16px; }

[data-theme="dark"] .fc-card-front {
    background: linear-gradient(160deg, var(--bg-card) 0%, rgba(184,137,58,0.18) 100%);
}
[data-theme="dark"] .fc-card-back {
    background: linear-gradient(160deg, rgba(107,166,122,0.18) 0%, var(--bg-card) 100%);
}

/* === LESSON QUIZ (multiple choice) === */
.lesson-quiz {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, var(--bg-card), var(--bg));
    border-radius: 10px;
    padding: 18px 22px;
    margin-top: 18px;
}
.lesson-quiz > .claude-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--line);
    color: var(--ink-soft);
    font-size: 12px;
}
.lesson-quiz > #btn-gen-quiz { margin: 8px 0; }

.quiz-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}
.quiz-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
}
.quiz-progress {
    font-size: 14px;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    background: var(--bg-soft);
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
}
.quiz-progress #quiz-score-num { font-weight: 700; color: var(--green); }

.quiz-q {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg-card);
    padding: 14px 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}
.quiz-q.is-answered { border-color: var(--ink-muted); }
.quiz-q-head {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 15px;
    line-height: 1.45;
    color: var(--ink);
}
.quiz-q-num {
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}
.quiz-q-text { font-weight: 500; }

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.quiz-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.quiz-option:hover:not(:disabled) {
    background: var(--bg-soft);
    border-color: var(--accent);
}
.quiz-option:disabled { cursor: default; }
.quiz-option-letter {
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
    min-width: 18px;
}
.quiz-option-text { flex: 1; }

.quiz-option.is-correct {
    background: rgba(107, 166, 122, 0.18);
    border-color: var(--green);
    color: var(--ink);
}
.quiz-option.is-correct .quiz-option-letter { color: var(--green); }
.quiz-option.is-wrong {
    background: rgba(201, 102, 90, 0.15);
    border-color: var(--red);
    color: var(--ink);
}
.quiz-option.is-wrong .quiz-option-letter { color: var(--red); }
.quiz-option.is-picked { box-shadow: 0 0 0 2px rgba(0,0,0,0.04) inset; }

.quiz-explain {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--bg-soft);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink-soft);
}

.quiz-final {
    margin-top: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: 8px;
    text-align: center;
}
.quiz-final-score {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}
.quiz-final-verdict {
    font-size: 14px;
    color: var(--ink);
}

[data-theme="dark"] .quiz-option.is-correct {
    background: rgba(107, 166, 122, 0.22);
}
[data-theme="dark"] .quiz-option.is-wrong {
    background: rgba(201, 102, 90, 0.2);
}

/* === DANGER LINK (destructive, low-emphasis) === */
.lesson-end-danger {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px dashed var(--line);
    width: 100%;
    text-align: center;
}
.btn-danger-link {
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-muted);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-underline-offset: 3px;
    font-family: inherit;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-danger-link:hover {
    color: var(--red);
    border-color: var(--red);
    background: rgba(201,102,90,0.05);
    text-decoration-color: var(--red);
}

/* === DISCOVERIES — matched cards (green frame) + lesson links === */
.disc-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}
.disc-controls #disc-search { flex: 1; }
.disc-filter-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.disc-filter-toggle input { cursor: pointer; }

.disc-card.is-matched {
    border-color: var(--green);
    box-shadow: 0 0 0 1px var(--green) inset, var(--shadow);
    background: linear-gradient(180deg, var(--bg-card), rgba(107,166,122,0.06));
}
.disc-card-head-right {
    display: inline-flex; align-items: center; gap: 6px;
}
.disc-match-badge {
    background: var(--green);
    color: #fff;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.disc-matches {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(107,166,122,0.4);
}
.disc-matches-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--green);
    font-weight: 600;
    margin-bottom: 6px;
}
.disc-matches ul {
    list-style: none;
    padding: 0; margin: 0;
    display: grid; gap: 4px;
}
.disc-matches li a {
    display: block;
    padding: 5px 8px;
    border-radius: 5px;
    background: var(--bg);
    color: var(--ink);
    font-size: 12px;
    line-height: 1.35;
    text-decoration: none !important;
    transition: background 0.12s;
}
.disc-matches li a:hover {
    background: var(--accent-soft);
}
.disc-match-mod {
    display: inline-block;
    background: var(--bg-soft);
    color: var(--ink-soft);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    font-weight: 600;
    margin-right: 6px;
}

/* === Discovery match groups (per-module within each category) === */
.dmm-group {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 8px;
    align-items: start;
    margin-top: 6px;
}
.dmm-mod {
    background: var(--mod-color, var(--accent));
    color: #fff;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
}
.dmm-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 5px;
    background: var(--bg);
    transition: background 0.12s, box-shadow 0.12s;
}
.dmm-item:hover { background: var(--bg-soft); }
.dmm-item.is-picked {
    background: rgba(184, 137, 58, 0.12);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.dmm-item a {
    flex: 1;
    color: var(--ink);
    font-size: 12.5px;
    text-decoration: none !important;
    line-height: 1.35;
    min-width: 0;
}
.dmm-item a:hover { color: var(--accent); }
.dmm-pick-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    padding: 0;
    cursor: pointer;
    font-size: 13px;
    line-height: 20px;
    text-align: center;
    color: var(--ink-muted);
    flex-shrink: 0;
    transition: all 0.12s;
    opacity: 0.5;
}
.dmm-pick-btn:hover {
    background: rgba(184, 137, 58, 0.18);
    border-color: var(--accent);
    color: var(--accent);
    opacity: 1;
    transform: scale(1.15);
}
.dmm-item.is-picked .dmm-pick-btn {
    color: var(--accent);
    background: var(--accent-soft);
    opacity: 1;
}
.dmm-score {
    font-size: 10px;
    flex-shrink: 0;
    background: var(--bg-soft);
    padding: 1px 6px;
    border-radius: 3px;
}

/* Per-category coloring on the matches label */
.disc-matches-bridge .disc-matches-label { color: var(--green); }
.disc-matches-generated .disc-matches-label { color: #d99a2a; }
.disc-matches-keyword summary {
    cursor: pointer;
    padding: 4px 0;
    color: #4a90e2;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    list-style: none;
}
.disc-matches-keyword summary::-webkit-details-marker { display: none; }
.disc-matches-keyword summary::before { content: "▶ "; font-size: 9px; }
.disc-matches-keyword[open] summary::before { content: "▼ "; }

/* Active pick row at top of each card */
.disc-pick {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(184,137,58,0.18), rgba(184,137,58,0.05));
    border: 1px solid var(--accent);
    border-radius: 8px;
}
.disc-pick-icon {
    font-size: 22px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 4px rgba(255, 200, 0, 0.6));
}
.disc-pick-body { flex: 1; min-width: 0; }
.disc-pick-body small { display: block; font-size: 10.5px; margin-bottom: 1px; }
.disc-pick-body a {
    color: var(--ink);
    text-decoration: none !important;
    font-size: 13.5px;
    line-height: 1.35;
}
.disc-pick-body a:hover { color: var(--accent); }
.disc-pick-clear {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    color: var(--ink-muted);
    font-size: 12px;
}
.disc-pick-clear:hover { background: rgba(201,102,90,0.12); color: var(--red); border-color: var(--red); }

.disc-card.is-picked {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent) inset, 0 4px 14px rgba(184,137,58,0.18);
}

/* Manual lesson search */
.disc-pick-manual { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.disc-pick-manual summary {
    cursor: pointer;
    font-size: 11.5px;
    color: var(--ink-soft);
    padding: 4px 0;
    list-style: none;
}
.disc-pick-manual summary::-webkit-details-marker { display: none; }
.disc-pick-manual summary:hover { color: var(--ink); }
.disc-pick-manual-body { margin-top: 6px; }
.dmm-search {
    width: 100%;
    padding: 6px 10px;
    font-size: 12.5px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--bg);
    color: var(--ink);
}
.dmm-search-results {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    max-height: 240px;
    overflow-y: auto;
    display: grid;
    gap: 3px;
}
.dmm-search-results li.muted { padding: 6px 8px; font-size: 11.5px; }

/* Dark theme tweaks */
[data-theme="dark"] .disc-card.is-matched {
    background: linear-gradient(180deg, var(--bg-card), rgba(127,185,138,0.10));
}
[data-theme="dark"] .disc-matches li a:hover {
    background: var(--accent-soft);
}
[data-theme="dark"] .dmm-item.is-picked {
    background: rgba(184, 137, 58, 0.18);
}
[data-theme="dark"] .disc-pick {
    background: linear-gradient(135deg, rgba(184,137,58,0.22), rgba(184,137,58,0.08));
}

/* === INLINE DISCOVERY REFERENCE (✦ marker, hover for popover) === */
.disc-ref {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    color: var(--green);
    font-size: 0.78em;
    line-height: 1;
    margin: 0 1px;
    padding: 0 1px;
    border-radius: 3px;
    vertical-align: super;
    transition: background 0.12s, transform 0.08s;
    user-select: none;
}
.disc-ref:hover {
    background: rgba(107,166,122,0.2);
    transform: scale(1.2);
}
.disc-ref:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 1px;
    background: rgba(107,166,122,0.15);
}
.disc-ref-mark { font-weight: 700; pointer-events: none; }

[data-theme="dark"] .disc-ref { color: var(--green); }
[data-theme="dark"] .disc-ref:hover { background: rgba(127,185,138,0.18); }

/* === CONCEPT CHIP (math principles, theorems, definitions) === */
.concept-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 8px 1px 9px;
    margin: 0 1px;
    border-radius: 12px;
    background: #e2ecf6;
    border: 1px solid #92b8de;
    color: #234e7a;
    font-weight: 600;
    font-size: 0.92em;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, transform 0.06s;
    white-space: nowrap;
}
.concept-chip:hover {
    background: #cfdef0;
    border-color: #5e8cc1;
}
.concept-chip:active { transform: translateY(1px); }
.concept-chip:focus-visible {
    outline: 2px solid #5e8cc1;
    outline-offset: 1px;
}
.concept-chip-icon {
    font-size: 0.78em;
    opacity: 0.65;
}

/* Concept chip linked to another lesson — extra subtle indicator */
.concept-chip[data-lesson-id] {
    border-bottom: 2px solid #5e8cc1;
}

/* Lesson link inside the popover */
.term-popover-lesson-link {
    display: block;
    margin-top: 10px;
    padding: 7px 10px;
    background: #e2ecf6;
    color: #234e7a !important;
    border-radius: 5px;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none !important;
    border-left: 3px solid #5e8cc1;
    transition: background 0.12s;
}
.term-popover-lesson-link:hover {
    background: #cfdef0;
}

/* Dark theme overrides */
[data-theme="dark"] .concept-chip {
    background: #1f2c3d;
    border-color: #3a5d8a;
    color: #a8c5e6;
}
[data-theme="dark"] .concept-chip:hover {
    background: #2a3a52;
    border-color: #5e8cc1;
}
[data-theme="dark"] .term-popover-lesson-link {
    background: #1f2c3d;
    color: #a8c5e6 !important;
    border-left-color: #5e8cc1;
}
[data-theme="dark"] .term-popover-lesson-link:hover {
    background: #2a3a52;
}

/* === STATS LEVEL INDENT (h2 vs h3 vs h4) === */
.stat-row.stat-level-2 .stat-title {
    font-weight: 600;
    color: var(--ink);
}
.stat-row.stat-level-3 .stat-title {
    font-weight: 500;
    color: var(--ink-soft);
    padding-left: 14px;
    font-size: 12.5px;
}
.stat-row.stat-level-4 .stat-title,
.stat-row.stat-level-5 .stat-title,
.stat-row.stat-level-6 .stat-title {
    font-weight: 400;
    color: var(--ink-muted);
    padding-left: 28px;
    font-size: 12px;
}
.stat-row.stat-level-3 .stat-bar { opacity: 0.85; }
.stat-row.stat-level-4 .stat-bar,
.stat-row.stat-level-5 .stat-bar,
.stat-row.stat-level-6 .stat-bar { opacity: 0.7; }

/* === MODULE % PROGRESS BARS === */
.overall-progress {
    height: 6px;
    background: var(--bg-soft);
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0 18px;
}
.overall-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--accent));
    transition: width 0.4s ease;
}
.module-progress {
    height: 6px;
    background: var(--bg-soft);
    border-radius: 3px;
    overflow: hidden;
    margin: 10px 0 4px;
}
.module-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.4s ease;
    min-width: 2px;
}
.module-progress-label {
    font-size: 11px;
    color: var(--ink-muted);
    margin: 0;
}
.module-progress-banner {
    margin: 0 0 24px;
    padding: 14px 18px;
    background: var(--bg-card);
    border-left: 3px solid var(--mod-color, var(--accent));
    border-radius: 6px;
}
.module-stat-percent strong { color: var(--accent); }

/* === NEXT LESSON CARD (end of lesson page) === */
.next-lesson-card-wrap { width: 100%; margin-top: 10px; }
.next-lesson-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--mod-color, var(--accent));
    border-radius: 10px;
    padding: 18px 22px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    text-align: left;
}
.next-lesson-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--mod-color, var(--accent));
}
.next-lesson-card-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}
.next-lesson-meta {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.next-lesson-meta code {
    background: var(--bg-soft);
    padding: 2px 7px;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}
.next-lesson-hours {
    font-size: 12px; color: var(--ink-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.next-lesson-title {
    font-family: Georgia, "Noto Serif", serif;
    font-size: 19px;
    margin: 4px 0 6px;
    color: var(--ink);
}
.next-lesson-desc {
    font-size: 13.5px;
    color: var(--ink-soft);
    line-height: 1.5;
    margin: 0 0 12px;
}
.next-lesson-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-mini-action {
    font-size: 13px;
    padding: 7px 14px;
}

/* === CELEBRATION MODAL + CONFETTI === */
.celebration-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.celebration-modal[hidden] { display: none; }
.celebration-modal.is-open { opacity: 1; }

.celebration-confetti {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.confetti-piece {
    position: absolute;
    top: -10px;
    width: 10px;
    height: 14px;
    border-radius: 2px;
    animation: confetti-fall ease-in forwards;
    opacity: 0.95;
}
@keyframes confetti-fall {
    0%   { transform: translateY(-10vh) rotate(0deg);   opacity: 0; }
    10%  { opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 1; }
}

.celebration-card {
    position: relative;
    z-index: 1;
    max-width: 460px;
    width: 100%;
    background: var(--bg-card);
    border-radius: 14px;
    padding: 32px 28px 24px;
    box-shadow: 0 18px 48px rgba(0,0,0,0.35);
    text-align: center;
    transform: scale(0.92);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.celebration-modal.is-open .celebration-card {
    transform: scale(1);
}
.celebration-emoji {
    font-size: 56px;
    line-height: 1;
    margin-bottom: 10px;
    animation: celeb-bounce 0.7s ease-out;
}
@keyframes celeb-bounce {
    0%   { transform: scale(0) rotate(-30deg); }
    60%  { transform: scale(1.25) rotate(15deg); }
    100% { transform: scale(1) rotate(0); }
}
.celebration-card h2 {
    margin: 0 0 8px;
    font-family: Georgia, "Noto Serif", serif;
    font-size: 28px;
    color: var(--ink);
}
.celebration-lesson {
    color: var(--ink-soft);
    font-size: 14px;
    margin-bottom: 22px;
}
.celebration-stats {
    background: var(--bg-soft);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 22px;
    display: flex; flex-direction: column; gap: 12px;
}
.celebration-stat-row {
    display: grid;
    grid-template-columns: minmax(120px, auto) 1fr auto;
    align-items: center;
    gap: 12px;
    text-align: left;
}
.celebration-stat-label {
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.celebration-stat-bar {
    height: 8px;
    background: rgba(0,0,0,0.08);
    border-radius: 4px;
    overflow: hidden;
}
.celebration-stat-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--accent));
    width: 0;
    transition: width 0.7s ease 0.2s;
    border-radius: 4px;
}
.celebration-stat-num {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
    text-align: right;
}
.celebration-actions {
    display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}

[data-theme="dark"] .celebration-modal { background: rgba(0,0,0,0.75); }
[data-theme="dark"] .celebration-stat-bar { background: rgba(255,255,255,0.08); }

/* === MERMAID DIAGRAMS (math/relation graphs in lessons) === */
.mermaid {
    margin: 18px auto;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
    overflow-x: auto;
    max-width: 100%;
}
.mermaid svg {
    max-width: 100%;
    height: auto;
    display: inline-block;
}
/* Pre-render state — pre-Mermaid the inner text is visible. Style it as a code block. */
.mermaid:not([data-processed]) {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    text-align: left;
    color: var(--ink-muted);
    white-space: pre;
}

[data-theme="dark"] .mermaid {
    background: var(--bg-soft);
    border-color: var(--line);
}

/* === FLOATING READING-% BADGE (fades in on scroll, auto-fades after 5s) === */
.reading-pct-badge {
    position: fixed;
    right: 22px;
    bottom: 100px;          /* sits ABOVE the chat-fab so they don't overlap */
    z-index: 55;            /* below chat-panel (70), above scroll-progress bar (80? actually 80 is the progress bar) */
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.06);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.45s ease, transform 0.45s ease;
    pointer-events: none;
}
.reading-pct-badge.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.reading-pct-badge[hidden] { display: none; }

.reading-pct-bar {
    display: inline-block;
    width: 60px;
    height: 6px;
    background: var(--bg-soft);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}
.reading-pct-bar-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--accent));
    transition: width 0.25s ease;
    min-width: 2px;
}
.reading-pct-text {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--ink-soft);
}
.reading-pct-text span:first-child { color: var(--ink); font-weight: 700; }

@media (max-width: 540px) {
    .reading-pct-badge { right: 14px; bottom: 90px; padding: 6px 12px 6px 10px; }
    .reading-pct-bar { width: 44px; }
}

[data-theme="dark"] .reading-pct-badge {
    box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.25);
}

/* === ASCII-ART WARNING (collapses old garbage diagrams) === */
.ascii-warn {
    margin: 14px 0;
    border: 1px dashed var(--warn);
    background: rgba(214,166,72,0.08);
    border-radius: 6px;
    padding: 8px 12px;
}
.ascii-warn summary {
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 12.5px;
    font-style: italic;
    user-select: none;
}
.ascii-warn summary:hover { color: var(--ink); }
.ascii-warn[open] summary { margin-bottom: 8px; border-bottom: 1px dotted var(--line); padding-bottom: 6px; }
.ascii-warn pre { margin: 0; }

/* === DIFFICULTY BADGE (Claude prediction + user rating, in lesson head) === */
.difficulty-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid;
}
.difficulty-claude {
    background: rgba(184,137,58,0.10);
    color: #7a5a25;
    border-color: var(--accent);
}
.difficulty-user {
    background: rgba(107,166,122,0.12);
    color: #2f5934;
    border-color: var(--green);
}
[data-theme="dark"] .difficulty-claude { color: #e6b85c; background: rgba(217,119,87,0.10); }
[data-theme="dark"] .difficulty-user   { color: #a8d8a0; background: rgba(127,185,138,0.10); }

/* Color hint by level (1=easy → 5=hard) */
.difficulty-1 { opacity: 0.85; }
.difficulty-5 { box-shadow: 0 0 0 2px rgba(201,102,90,0.25); }

/* === USER RATING WIDGET (★ block at end of lesson) === */
.user-rating-block {
    width: 100%;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px 22px;
    margin: 8px 0;
}
.user-rating-question {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--ink);
}
.user-rating-question .muted { font-size: 12px; }

.rating-stars {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}
.rating-star {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    color: var(--line);
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.12s, transform 0.08s;
}
.rating-star:hover { transform: scale(1.15); }
.rating-star.is-active,
.rating-star.is-hover {
    color: #d6a648;
}
.rating-star.is-hover { opacity: 0.85; }

.rating-label {
    margin-left: 12px;
    font-size: 13px;
    color: var(--ink-soft);
    font-style: italic;
}
.rating-clear {
    margin-left: 8px;
    font-size: 11px;
    padding: 2px 7px;
}

[data-theme="dark"] .rating-star { color: var(--line); }
[data-theme="dark"] .rating-star.is-active,
[data-theme="dark"] .rating-star.is-hover { color: #e6b85c; }

/* === INLINE SVG MATH VISUALS (parabolas, unit circles, vertical-line tests) === */
.claude-md svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 14px auto;
    color: var(--ink);          /* drives currentColor for axes/text */
}
[data-theme="dark"] .claude-md svg {
    /* Make sure light-blue accents stay readable on dark backgrounds */
    color: var(--ink);
}

/* === PARAGRAPH FEEDBACK (👍 / 👎 per big paragraph) === */
.para-feedback {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 18px;
    padding: 6px 10px;
    border-top: 1px dashed var(--line);
    color: var(--ink-muted);
    font-size: 12px;
    user-select: none;
}
.para-fb-prompt {
    margin-right: auto;
    font-style: italic;
    opacity: 0.7;
}
.para-fb-btn {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 3px 10px;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s, transform 0.08s;
    color: var(--ink);
}
.para-fb-btn:hover {
    background: var(--bg-soft);
    transform: translateY(-1px);
}
.para-fb-btn[data-rating="1"].is-active {
    background: rgba(107,166,122,0.18);
    border-color: var(--green);
}
.para-fb-btn[data-rating="-1"].is-active {
    background: rgba(201,102,90,0.18);
    border-color: var(--red);
}
.para-fb-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

[data-theme="dark"] .para-fb-btn[data-rating="1"].is-active {
    background: rgba(127,185,138,0.20);
}
[data-theme="dark"] .para-fb-btn[data-rating="-1"].is-active {
    background: rgba(217,119,112,0.20);
}

/* === STATS PANEL — feedback per section === */
.stat-fb {
    display: inline-flex; gap: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    margin-left: 8px;
}
.stat-fb-up   { color: var(--green); font-weight: 700; }
.stat-fb-down { color: var(--red);   font-weight: 700; }

/* Stat row — make room for the new feedback chips */
.stat-row {
    grid-template-columns: minmax(140px, 1fr) 2fr auto auto;
}

/* === PARAGRAPH "+" EXTRA EXPLANATION BUTTON + INLINE EXPANSION === */
/* "+" chip lives INSIDE the .para-feedback row, next to 👍/👎 */
.para-expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: transparent;
    border: 1px dashed var(--accent);
    color: var(--accent);
    border-radius: 50%;
    padding: 0;
    font-size: 15px;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    margin: 0 0 0 4px;
    transition: background 0.12s, border-style 0.12s, transform 0.08s, box-shadow 0.12s, color 0.12s;
    vertical-align: middle;
}
.para-expand-btn:hover {
    background: var(--accent);
    color: #fff;
    border-style: solid;
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(184,137,58,0.35);
}
.para-expand-btn:disabled { cursor: wait; opacity: 0.65; }
.para-expand-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* "+ ✓" indicator shown when an expansion already exists below the widget */
.para-expand-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    margin-left: 4px;
    border-radius: 11px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--accent);
}

.para-expansion {
    margin: 6px 0 18px;
    padding: 0;
    border: 1px solid var(--accent);
    border-left-width: 4px;
    border-radius: 8px;
    background: linear-gradient(180deg, var(--accent-soft), var(--bg-card) 80%);
    overflow: hidden;
}
.para-expansion-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--accent-soft);
    border-bottom: 1px solid var(--line);
    font-size: 11.5px;
    font-weight: 700;
    color: var(--accent);
}
.para-expansion-head > span:first-child { letter-spacing: 0.02em; }
.para-expansion-meta {
    margin-left: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--ink-muted);
}
.para-expansion-del {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--ink-muted);
}
.para-expansion-del:hover { background: rgba(201,102,90,0.12); color: var(--red); border-color: var(--red); }

.para-expansion-body {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink);
}
.para-expansion-body > *:first-child { margin-top: 0; }
.para-expansion-body > *:last-child { margin-bottom: 0; }
.para-expansion-body .claude-stream {
    margin: 0;
    background: transparent;
    border: none;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    color: var(--ink-soft);
    white-space: pre-wrap;
}

.para-expansion.is-loading { opacity: 0.95; }
.para-expansion.is-error .para-expansion-head { background: rgba(201,102,90,0.18); color: var(--red); }

/* === 🌍 Real-life button + card (sister of the + expansion, blue/green palette) === */
.para-rl-btn {
    background: rgba(74, 144, 226, 0.10);
    color: #2d6cb8;
    border: 1px dashed #4a90e2;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    margin-left: 4px;
    font-size: 14px;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}
.para-rl-btn:hover {
    background: rgba(74, 144, 226, 0.18);
    border-style: solid;
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(74,144,226,0.35);
}
.para-rl-btn:disabled { cursor: wait; opacity: 0.65; }
.para-rl-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    margin-left: 4px;
    border-radius: 11px;
    background: rgba(74, 144, 226, 0.15);
    color: #2d6cb8;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #4a90e2;
}

.para-real-life {
    margin: 6px 0 18px;
    padding: 0;
    border: 1px solid #4a90e2;
    border-left-width: 4px;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(74,144,226,0.08), var(--bg-card) 80%);
    overflow: hidden;
}
.para-rl-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(74, 144, 226, 0.12);
    border-bottom: 1px solid var(--line);
    font-size: 11.5px;
    font-weight: 700;
    color: #2d6cb8;
}
.para-rl-meta {
    margin-left: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--ink-muted);
}
.para-rl-del {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--ink-muted);
}
.para-rl-del:hover { background: rgba(201,102,90,0.12); color: var(--red); border-color: var(--red); }

.para-rl-body {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink);
}
.para-rl-body > *:first-child { margin-top: 0; }
.para-rl-body > *:last-child { margin-bottom: 0; }
.para-rl-body .claude-stream {
    margin: 0;
    background: transparent;
    border: none;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    color: var(--ink-soft);
    white-space: pre-wrap;
}

.para-real-life.is-loading { opacity: 0.95; }
.para-real-life.is-error .para-rl-head { background: rgba(201,102,90,0.18); color: var(--red); }

/* === 🎨 Comic CTA + rendered image === */
.para-comic-btn {
    display: block;
    margin: 0 16px 12px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #ff6b9d, #ff9933);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(255, 107, 157, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}
.para-comic-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.4);
}
.para-comic-btn:disabled { opacity: 0.7; cursor: wait; }

.para-comic {
    position: relative;
    margin: 0 16px 12px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--bg-card);
}
.para-comic img {
    display: block;
    width: 100%;
    height: auto;
}
.para-comic-del {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.para-comic-del:hover { background: var(--red); }

[data-theme="dark"] .para-rl-btn { background: rgba(74,144,226,0.15); color: #7eb6ee; }
[data-theme="dark"] .para-rl-badge { background: rgba(74,144,226,0.20); color: #7eb6ee; }
[data-theme="dark"] .para-real-life { background: linear-gradient(180deg, rgba(74,144,226,0.10), var(--bg-card) 80%); }
[data-theme="dark"] .para-rl-head { background: rgba(74,144,226,0.18); color: #7eb6ee; }

/* === 🎮 Interactive widget (Claude-generated HTML+JS, purple palette) === */
.para-int-btn {
    background: rgba(155, 81, 224, 0.10);
    color: #7a3eb8;
    border: 1px dashed #9b51e0;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    margin-left: 4px;
    font-size: 14px;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}
.para-int-btn:hover {
    background: rgba(155, 81, 224, 0.18);
    border-style: solid;
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(155,81,224,0.35);
}
.para-int-btn:disabled { cursor: wait; opacity: 0.65; }
.para-int-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    margin-left: 4px;
    border-radius: 11px;
    background: rgba(155, 81, 224, 0.15);
    color: #7a3eb8;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #9b51e0;
}

.para-interactive {
    margin: 6px 0 18px;
    padding: 0;
    border: 1px solid #9b51e0;
    border-left-width: 4px;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(155,81,224,0.08), var(--bg-card) 80%);
    overflow: hidden;
}
.para-int-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(155, 81, 224, 0.12);
    border-bottom: 1px solid var(--line);
    font-size: 11.5px;
    font-weight: 700;
    color: #7a3eb8;
}
.para-int-meta {
    margin-left: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--ink-muted);
}
.para-int-del {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--ink-muted);
}
.para-int-del:hover { background: rgba(201,102,90,0.12); color: var(--red); border-color: var(--red); }

.para-int-explain {
    padding: 10px 16px;
    border-bottom: 1px dashed var(--line);
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink-soft);
}
.para-int-explain > *:first-child { margin-top: 0; }
.para-int-explain > *:last-child { margin-bottom: 0; }

.para-int-stage {
    padding: 14px 16px;
    color: var(--ink);
}
.para-int-stage > *:first-child { margin-top: 0; }
.para-int-stage > *:last-child { margin-bottom: 0; }
.para-int-stage .claude-stream {
    margin: 0;
    background: transparent;
    border: none;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    color: var(--ink-soft);
    white-space: pre-wrap;
}
.para-int-stage input[type="range"] { width: 100%; max-width: 280px; }
.para-int-stage input[type="number"],
.para-int-stage input[type="text"] {
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--bg);
    color: var(--ink);
    font-family: inherit;
}
.para-int-stage button {
    padding: 6px 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.para-int-stage button:hover { opacity: 0.9; }

.para-interactive.is-loading { opacity: 0.95; }
.para-interactive.is-error .para-int-head { background: rgba(201,102,90,0.18); color: var(--red); }

[data-theme="dark"] .para-int-btn { background: rgba(155,81,224,0.18); color: #c89af0; }
[data-theme="dark"] .para-int-badge { background: rgba(155,81,224,0.22); color: #c89af0; }
[data-theme="dark"] .para-interactive { background: linear-gradient(180deg, rgba(155,81,224,0.12), var(--bg-card) 80%); }
[data-theme="dark"] .para-int-head { background: rgba(155,81,224,0.20); color: #c89af0; }

/* ===================================================================== */
/* Auth (login / register) — standalone pages, no top nav                */
/* ===================================================================== */
.auth-body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(800px 400px at 20% 10%, rgba(217,119,87,0.10), transparent 60%),
        radial-gradient(800px 400px at 80% 90%, rgba(126,87,194,0.10), transparent 60%),
        var(--bg);
    color: var(--ink);
    font-family: var(--font-sans, "Inter", system-ui, sans-serif);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.auth-brand .brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, #D97757, #b85f43);
    color: #fff;
    font-weight: 700;
    font-size: 20px;
}
.auth-brand strong {
    display: block;
    font-size: 16px;
    color: var(--ink);
}
.auth-brand small {
    display: block;
    color: var(--ink-soft);
    font-size: 12px;
    margin-top: 1px;
}
.auth-title {
    margin: 8px 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
}
.auth-sub {
    margin: 0 0 22px;
    color: var(--ink-soft);
    font-size: 13.5px;
    line-height: 1.5;
}
.auth-error {
    background: rgba(201,102,90,0.12);
    border: 1px solid rgba(201,102,90,0.35);
    color: var(--red, #c9665a);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 13.5px;
}
.auth-form { display: grid; gap: 12px; }
.auth-form label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-soft);
    font-weight: 600;
}
.auth-form label small {
    font-weight: 400;
    color: var(--ink-soft);
    opacity: 0.7;
    margin-left: 6px;
}
.auth-form .auth-opt {
    font-weight: 400;
    color: var(--ink-soft);
    opacity: 0.7;
}
.auth-form input {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--accent, #D97757);
    box-shadow: 0 0 0 3px rgba(217,119,87,0.18);
}
.auth-btn {
    margin-top: 6px;
    padding: 11px 14px;
    background: linear-gradient(135deg, #D97757, #b85f43);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s, box-shadow 0.15s;
}
.auth-btn:hover { box-shadow: 0 6px 20px rgba(217,119,87,0.35); }
.auth-btn:active { transform: translateY(1px); }
.auth-foot {
    margin: 18px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--ink-soft);
}
.auth-foot a {
    color: var(--accent, #D97757);
    font-weight: 600;
    text-decoration: none;
}
.auth-foot a:hover { text-decoration: underline; }

/* Logout link in topnav */
.navlink-logout {
    color: var(--ink-soft);
    border-left: 1px solid var(--line);
    padding-left: 14px;
    margin-left: 4px;
}
.navlink-logout:hover { color: var(--red, #c9665a); }

/* ===================================================================== */
/* Admin dashboard                                                       */
/* ===================================================================== */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.admin-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
}
.admin-stat-num {
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
}
.admin-stat-label {
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 2px;
}

.admin-module-list {
    list-style: none; padding: 0; margin: 8px 0;
    display: grid; gap: 6px;
}
.admin-module-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px;
    background: var(--bg); border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 13.5px;
}
.admin-mod-chip {
    background: var(--mod-color, var(--accent));
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.admin-mod-title { flex: 1; }
.admin-mod-count { font-weight: 600; color: var(--ink); }

.admin-signup-list { list-style: none; padding: 0; margin: 8px 0; font-size: 14px; }
.admin-signup-list li { padding: 3px 0; color: var(--ink-soft); }

.admin-search {
    display: flex; gap: 8px; align-items: center;
    margin: 12px 0 16px;
}
.admin-search input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
}

.admin-users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.admin-users-table th, .admin-users-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}
.admin-users-table th {
    background: var(--bg);
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.admin-users-table tr:hover { background: var(--bg); }

.admin-avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 6px;
    object-fit: cover;
    border: 1px solid var(--line);
}
.badge-verified {
    background: rgba(76, 175, 80, 0.15);
    color: #2e7d32;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}
.badge-unverified {
    background: rgba(201, 102, 90, 0.15);
    color: #c9665a;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-admin {
    background: linear-gradient(135deg, #6d28d9, #4c1d95);
    color: white;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.admin-toggle {
    font-size: 12px !important;
    white-space: nowrap;
}

[data-theme="dark"] .admin-stat-card { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .admin-mod-chip { color: #fff; }
[data-theme="dark"] .badge-verified { background: rgba(76, 175, 80, 0.22); color: #66bb6a; }

/* User avatar in topnav (next to name) */
.topnav-avatar {
    width: 20px; height: 20px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 4px;
    object-fit: cover;
    border: 1px solid var(--line);
}

/* Auto-build view: default user opened a lesson that has no shared content,
   Claude is writing it live in the background. */
.auto-build {
    margin-top: 12px;
    padding: 20px 22px;
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: 12px;
    box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 0 0 4px color-mix(in srgb, var(--accent) 8%, transparent);
}
.auto-build-head {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 12px;
}
.auto-build-text { flex: 1; }
.auto-build-title {
    margin: 0 0 4px;
    font-size: 15.5px;
    font-weight: 700;
    color: var(--ink);
}
.auto-build-sub {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}
.auto-build-elapsed {
    font-family: var(--mono, ui-monospace, SFMono-Regular, monospace);
    font-size: 12px;
    color: var(--ink-soft);
    background: var(--bg-soft, rgba(0,0,0,.04));
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.auto-build-spinner {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
    border-top-color: var(--accent);
    animation: auto-build-spin 0.9s linear infinite;
    flex-shrink: 0;
}
@keyframes auto-build-spin {
    to { transform: rotate(360deg); }
}
.auto-build-status {
    font-size: 13px;
    color: var(--ink-soft);
    padding: 8px 12px;
    background: var(--bg-soft, rgba(0,0,0,.03));
    border-radius: 8px;
    margin-bottom: 10px;
}
.auto-build-status-error {
    color: #b3261e;
    background: rgba(179, 38, 30, .08);
}
.auto-build-stream {
    max-height: 360px;
    overflow-y: auto;
    background: var(--bg-soft, rgba(0,0,0,.025));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: var(--mono, ui-monospace, SFMono-Regular, monospace);
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--ink);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* Empty state when a default user opens a lesson with no shared content yet */
.empty-shared-lesson {
    padding: 32px 24px;
    background: var(--bg);
    border: 1px dashed var(--line);
    border-radius: 10px;
    text-align: center;
    color: var(--ink);
}
.empty-shared-lesson p:first-child {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}
.empty-shared-lesson p:last-child {
    margin: 0;
    font-size: 13.5px;
}

/* SMTP / email admin card */
.smtp-status-row {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin: 6px 0 12px;
    font-size: 13.5px;
    color: var(--ink-soft);
}
.smtp-tag {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.smtp-tag-ok {
    background: rgba(76,175,80,0.15);
    color: #2e7d32;
}
.smtp-tag-warn {
    background: rgba(217,119,87,0.16);
    color: #c95f3f;
}
[data-theme="dark"] .smtp-tag-ok { background: rgba(76,175,80,0.22); color: #66bb6a; }

.smtp-form .smtp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}
.smtp-form label {
    display: grid; gap: 4px;
    font-size: 12.5px;
    color: var(--ink-soft);
    font-weight: 600;
}
.smtp-form input[type="text"],
.smtp-form input[type="email"],
.smtp-form input[type="number"],
.smtp-form input[type="password"] {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--ink);
    font-size: 13.5px;
    font-family: inherit;
}
.smtp-form input:focus {
    outline: none;
    border-color: var(--accent, #D97757);
    box-shadow: 0 0 0 2px rgba(217,119,87,0.18);
}
.smtp-advanced {
    margin-top: 12px;
    background: var(--bg);
    border: 1px dashed var(--line);
    border-radius: 6px;
    padding: 8px 12px;
}
.smtp-advanced summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
}
.smtp-advanced .smtp-checkbox {
    display: flex; align-items: center; gap: 8px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 400;
    color: var(--ink);
}
