/* EduTestSeries student — OceanBlue tokens mirrored from Android ThemeSettings */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap");

:root {
    --bg: #f8fafc;
    --bg-soft: #f1f5f9;
    --panel: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --on-primary: #ffffff;
    --accent-soft: #dbeafe;
    --accent-container: #1e3a8a;
    --secondary: #7c3aed;
    --secondary-soft: #ede9fe;
    --tertiary: #ea580c;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --warning: #ea580c;
    --warning-soft: #ffedd5;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --surface-variant: #f1f5f9;
    --radius-card: 20px;
    --radius-control: 16px;
    --radius-chip: 12px;
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --sidebar-w: 280px;
    --top-h: 64px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.06);
    --shadow-accent: 0 8px 20px rgba(37, 99, 235, 0.22);
    --font: "DM Sans", system-ui, sans-serif;
    --content-max: 960px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background:
        radial-gradient(1100px 480px at 8% -12%, #dbeafe 0%, transparent 55%),
        radial-gradient(800px 360px at 100% 0%, #e2e8f0 0%, transparent 48%),
        linear-gradient(180deg, #f8fafc, #f1f5f9 42%, #e2e8f0);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* —— Shell —— */
.app-shell { display: flex; min-height: 100vh; }
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--top-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: 0 var(--space-lg);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}
.brand {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-size: 1.1rem;
}
.brand:hover { color: var(--accent); text-decoration: none; }
.brand span { color: var(--accent); }

.topbar-actions { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-chip);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    font-size: 0.875rem;
}
.icon-btn:hover { border-color: #93c5fd; background: var(--accent-soft); text-decoration: none; }
.menu-toggle { display: none; }

.primary-nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    padding: 10px var(--space-lg) 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.65);
}
.primary-nav a {
    padding: 10px 14px;
    border-radius: 12px 12px 0 0;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
}
.primary-nav a:hover { color: var(--accent); text-decoration: none; background: var(--accent-soft); }
.primary-nav a.is-active {
    color: var(--accent);
    background: var(--panel);
    border: 1px solid var(--line);
    border-bottom-color: var(--panel);
    margin-bottom: -1px;
}

.content-wrap {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-lg);
    flex: 1;
}

/* —— Sidebar (desktop permanent) —— */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-header {
    padding: var(--space-lg) var(--space-md) var(--space-md);
    border-bottom: 1px solid var(--line);
}
.sidebar-user { font-weight: 700; letter-spacing: -0.02em; }
.sidebar-meta { margin-top: 4px; font-size: 0.85rem; color: var(--muted); }
.sidebar-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent, #2563eb);
}
.forum-rich { line-height: 1.55; }
.forum-rich p { margin: 0 0 0.65rem; }
.sidebar-course {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-container);
    font-size: 0.78rem;
    font-weight: 600;
}
.sidebar-nav { padding: var(--space-md) var(--space-sm) var(--space-xl); }
.nav-group { margin-bottom: var(--space-md); }
.nav-group-label {
    margin: 0 10px 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--ink);
    font-weight: 500;
    font-size: 0.92rem;
}
.nav-link:hover { background: var(--surface-variant); text-decoration: none; }
.nav-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-container);
    font-weight: 600;
}
.nav-link.is-soon { opacity: 0.72; }
.nav-link .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line-strong);
    flex-shrink: 0;
}
.nav-link.is-active .dot { background: var(--accent); }
.sidebar-footer {
    margin-top: auto;
    padding: var(--space-md);
    border-top: 1px solid var(--line);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 50;
}
.sidebar-backdrop.is-open { display: block; }

/* —— Components —— */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
}
h1, h2, h3 { margin-top: 0; letter-spacing: -0.02em; line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 3.5vw, 2.25rem); font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
.muted { color: var(--muted); }
.kicker {
    margin: 0 0 6px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}
label {
    display: block;
    margin: 0.75rem 0 0.35rem;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 500;
}
input, select, textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--ink);
    font: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid #93c5fd;
    outline-offset: 1px;
    border-color: var(--accent);
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    padding: 0.72rem 1.15rem;
    background: var(--accent);
    color: var(--on-primary);
    font-weight: 600;
    font: inherit;
    text-decoration: none;
    box-shadow: var(--shadow-accent);
}
.btn:hover { text-decoration: none; background: var(--accent-hover); }
.btn.secondary {
    background: var(--surface-variant);
    color: var(--ink);
    box-shadow: none;
    border: 1px solid var(--line);
}
.btn.secondary:hover { background: #e2e8f0; }
.btn.danger { background: var(--danger); box-shadow: none; }
.btn.ghost {
    background: transparent;
    color: var(--accent);
    box-shadow: none;
    border: 1px solid transparent;
}
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.flash {
    background: var(--success-soft);
    border: 1px solid #a7f3d0;
    color: var(--success);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}
.errors {
    background: var(--danger-soft);
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-variant);
    color: var(--muted);
    text-transform: capitalize;
}
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.soon { background: #fff7ed; color: #c2410c; }
.option {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 0.5rem;
    background: var(--bg);
}
.option input { width: auto; margin-top: 0.2rem; }
.timer {
    position: sticky;
    top: calc(var(--top-h) + 8px);
    z-index: 5;
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.65rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-family: ui-monospace, monospace;
}
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 0.7rem 0.4rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

/* —— Hub (Android HomeDashboard structure) —— */
.hub-hero { margin: 0.25rem 0 1.5rem; }
.hub-lead { margin: 0; max-width: 36rem; color: var(--muted); font-size: 1.05rem; }
.hub-greeting {
    font-size: clamp(1.6rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0 0 0.35rem;
}
.goal-card {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.15rem;
    border-radius: var(--radius-card);
    background: linear-gradient(135deg, #eff6ff, #fff);
    border: 1px solid #bfdbfe;
    margin-bottom: var(--space-lg);
}
.goal-card strong { display: block; font-size: 1rem; }
.goal-progress {
    margin-top: 0.65rem;
    height: 8px;
    border-radius: 999px;
    background: #dbeafe;
    overflow: hidden;
}
.goal-progress-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #38bdf8);
    transition: width 0.25s ease;
}
.goal-items {
    list-style: none;
    margin: 0.55rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
    font-size: 0.8rem;
    color: var(--muted);
}
.spotlight-block {
    cursor: default;
}
.spotlight-block .quiz-preview {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.spotlight-block .quiz-preview-line {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: unset;
}
.quiz-history-q {
    display: block;
    max-width: 14rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.spotlight.spotlight-result {
    border-color: #86efac;
    background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
}
.spotlight.spotlight-result strong { color: #166534; }
.spotlight.spotlight-result span { color: #15803d; }
.quiz-history {
    margin-top: 0.35rem;
}
.quiz-history summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: rgba(248, 250, 252, 0.9);
}
.quiz-history ul {
    list-style: none;
    margin: 0.65rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}
.quiz-history li {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8rem;
    align-items: center;
}
.announce-list {
    display: grid;
    gap: 0.65rem;
    margin-bottom: var(--space-lg);
}
.announce-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-card);
    border: 1px solid var(--line);
    background: var(--panel);
    text-decoration: none;
    color: var(--ink);
}
.announce-row:hover {
    text-decoration: none;
    border-color: #93c5fd;
}
.announce-row strong { font-size: 0.95rem; }
.announce-row .muted { font-size: 0.82rem; }
.spotlight-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}
.spotlight {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.2rem;
    border-radius: var(--radius-card);
    text-decoration: none;
    color: var(--ink);
    border: 1px solid var(--line);
    background: var(--panel);
    min-height: 132px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.spotlight:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #93c5fd;
}
.spotlight.featured {
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    color: #fff;
    border-color: transparent;
}
.spotlight.featured .muted,
.spotlight.featured span { color: rgba(248, 250, 252, 0.85); }
.spotlight.amber {
    background: linear-gradient(145deg, #f59e0b, #d97706);
    color: #fff;
    border-color: transparent;
}
.spotlight.amber span { color: rgba(255, 255, 255, 0.9); }
.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 0.85rem;
}
.section-title h2 { margin: 0; font-size: 1.1rem; }
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: var(--space-lg);
}
.tile {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    min-height: 96px;
}
.tile:hover {
    text-decoration: none;
    border-color: #93c5fd;
    box-shadow: var(--shadow-sm);
}
.tile strong { font-size: 0.95rem; }
.tile span { font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.tile.is-soon { opacity: 0.75; }
.continue-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 1fr);
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: var(--space-lg);
}
.continue-card {
    padding: 1rem;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
}
.continue-card:hover { text-decoration: none; border-color: #93c5fd; }

/* Coming soon */
.soon-hero {
    text-align: center;
    padding: 3rem 1.5rem;
    border-radius: var(--radius-card);
    background: var(--panel);
    border: 1px solid var(--line);
}
.soon-hero h1 { margin-bottom: 0.5rem; }
.soon-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    font-weight: 700;
}

/* Chat / Code Lab (preserved) */
.chat-panel { display: flex; flex-direction: column; gap: 0.75rem; }
.chat-bubble {
    max-width: 92%;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--bg);
}
.chat-bubble.user {
    align-self: flex-end;
    background: var(--accent-soft);
    border-color: #bfdbfe;
    border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
    align-self: flex-start;
    background: #fff;
    border-bottom-left-radius: 4px;
}
.chat-bubble.refusal { border-color: #fecaca; background: #fef2f2; }
.chat-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.35rem; }
.chat-text { white-space: pre-wrap; line-height: 1.45; }
.code-editor, .console-out, .console-err {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88rem;
    line-height: 1.45;
}
.code-editor {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
    min-height: 280px;
    tab-size: 4;
    width: 100%;
    resize: vertical;
}
.ide-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}
.ide-file-label { margin: 0; font-weight: 600; }
.console-out, .console-err {
    margin: 0;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    overflow-x: auto;
    white-space: pre-wrap;
}
.console-out { background: #0f172a; color: #bbf7d0; }
.console-err { background: #450a0a; color: #fecaca; }
.ide-card { max-width: 100%; }
.ide-card .badge.ok,
.badge.ok { background: #dcfce7; color: #166534; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; }

/* Mobile bottom nav — primary only */
.mobile-tabs {
    display: none;
    position: sticky;
    bottom: 0;
    z-index: 30;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    backdrop-filter: blur(10px);
}
.mobile-tabs a {
    flex: 1;
    text-align: center;
    padding: 10px 4px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    border-radius: 10px;
}
.mobile-tabs a.is-active { color: var(--accent); background: var(--accent-soft); }
.mobile-tabs a:hover { text-decoration: none; }

/* —— Responsive —— */
@media (max-width: 839px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 60;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-md);
    }
    .sidebar.is-open { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .primary-nav { display: none; }
    .mobile-tabs { display: flex; }
    .spotlight-grid { grid-template-columns: 1fr; }
    .content-wrap { padding: var(--space-md); }
    .topbar { padding: 0 var(--space-md); }
}

@media (min-width: 840px) {
    .mobile-tabs { display: none !important; }
}

/* —— Landing / auth / courses catalog —— */
.landing-hero {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: var(--space-xl);
    align-items: center;
    min-height: min(68vh, 640px);
    padding: 0.5rem 0 1.5rem;
}
.landing-title {
    margin: 0 0 0.75rem;
    font-size: clamp(2rem, 4.5vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.1;
}
.landing-lead {
    margin: 0;
    max-width: 34rem;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.55;
}
.landing-panel {
    border-radius: 28px;
    padding: 1.5rem;
    background:
        linear-gradient(160deg, rgba(37, 99, 235, 0.92), rgba(29, 78, 216, 0.88)),
        #1d4ed8;
    color: #fff;
    min-height: 280px;
    box-shadow: 0 24px 48px rgba(37, 99, 235, 0.28);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.landing-chip {
    display: inline-flex;
    width: fit-content;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 0.78rem;
    font-weight: 600;
}
.landing-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.landing-stat-grid div {
    padding: 0.85rem 0.9rem;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.landing-stat-grid strong { display: block; font-size: 1rem; }
.landing-stat-grid span { font-size: 0.82rem; opacity: 0.85; }

.auth-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    align-items: start;
    padding: 1rem 0 2rem;
}
.auth-form-card { margin: 0; max-width: 440px; }
.auth-brand { padding-top: 0.5rem; }

.page-intro {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1.35rem;
}
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}
.course-card {
    display: flex;
    flex-direction: column;
    min-height: 220px;
    padding: 1.25rem;
    border-radius: var(--radius-card);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}
.course-card h2 {
    margin: 0.75rem 0 0.4rem;
    font-size: 1.2rem;
}
.course-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 839px) {
    .landing-hero,
    .auth-split {
        grid-template-columns: 1fr;
        min-height: 0;
    }
    .landing-panel { min-height: 220px; }
    .auth-form-card { max-width: none; }
}

/* —— Rich tutorial content —— */
.rich-content { margin-top: 1rem; line-height: 1.65; }
.rich-content .rich-lesson { display: grid; gap: 1.25rem; }
.rich-content .lesson-section {
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-chip);
    background: var(--bg-soft);
}
.rich-content .lesson-section h2 {
    margin: 0 0 .65rem;
    font-size: 1.05rem;
    color: var(--accent-container);
}
.rich-content .lesson-section h3 {
    margin: 0 0 .5rem;
    font-size: 1rem;
}
.rich-content .lesson-section h4 {
    margin: .75rem 0 .35rem;
    font-size: .92rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.rich-content .lesson-section p { margin: 0 0 .75rem; }
.rich-content .lesson-section p:last-child { margin-bottom: 0; }
.rich-content .lesson-section ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.rich-content .subtopic-card {
    margin-top: .85rem;
    padding: .85rem 1rem;
    border-radius: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
}
.rich-content .subtopic-card + .subtopic-card { margin-top: .75rem; }
.rich-content .code-block {
    margin: .5rem 0 0;
    padding: .9rem 1rem;
    overflow-x: auto;
    border-radius: 12px;
    background: #0f172a;
    color: #e2e8f0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .86rem;
    line-height: 1.55;
}
.rich-content .code-example {
    margin: .5rem 0 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #0f172a;
}
.rich-content .code-example .code-block {
    margin: 0;
    border-radius: 0;
    border: 0;
}
.rich-content .try-yourself-bar {
    display: flex;
    justify-content: flex-end;
    padding: .65rem .85rem;
    background: #111827;
    border-top: 1px solid #1f2937;
}
.rich-content .try-yourself-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .9rem;
    border-radius: 999px;
    background: #04aa6d;
    color: #fff !important;
    font-weight: 700;
    font-size: .86rem;
    text-decoration: none;
    border: 0;
    cursor: pointer;
}
.rich-content .try-yourself-btn:hover {
    background: #059669;
    color: #fff !important;
}
.rich-content .code-block[data-lang="output"] {
    background: #1e293b;
    border-left: 3px solid var(--success);
}
.rich-content .lesson-figure {
    margin: 1rem 0 0;
    text-align: center;
}
.rich-content .lesson-figure img {
    max-width: min(100%, 560px);
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
}
.rich-content .lesson-figure figcaption {
    margin-top: .45rem;
    font-size: .85rem;
    color: var(--muted);
}
.video-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    border-radius: 14px;
    overflow: hidden;
    background: #0f172a;
    border: 1px solid var(--line);
}
.video-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* —— AI Speaker (Android-parity live conversation) —— */
.speaker-app {
    max-width: 560px;
    margin: 0 auto;
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    background: #f7faff;
    border-radius: 20px;
    padding: 12px 12px 20px;
    border: 1px solid #d7e6ff;
}
.speaker-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.speaker-brand { color: #1e6bff; font-size: 1.15rem; }
.speaker-back { color: #1e6bff; font-weight: 700; text-decoration: none; font-size: 1.2rem; }
.speaker-timer { color: #1e6bff; font-weight: 700; font-variant-numeric: tabular-nums; }
.speaker-timer.is-low { color: #dc2626; }
.speaker-stage { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.speaker-avatar-wrap {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 4px auto 10px;
    display: grid;
    place-items: center;
}
.speaker-rings::before,
.speaker-rings::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    border: 2px solid rgba(142, 197, 255, 0.55);
    border-radius: 50%;
    width: 150px;
    height: 150px;
    opacity: 0.55;
}
.speaker-rings.is-active::before {
    animation: speakerPulse 0.9s ease-in-out infinite alternate;
}
.speaker-rings.is-active::after {
    width: 132px;
    height: 132px;
    opacity: 0.85;
    animation: speakerPulse 0.9s ease-in-out infinite alternate-reverse;
}
@keyframes speakerPulse {
    from { transform: scale(1); opacity: 0.45; }
    to { transform: scale(1.1); opacity: 0.9; }
}
.speaker-avatar {
    width: 108px;
    height: 108px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(145deg, #1e6bff, #0b4ed9);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.4rem;
    z-index: 1;
    box-shadow: 0 10px 24px rgba(30, 107, 255, 0.28);
}
.speaker-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.speaker-status {
    position: absolute;
    bottom: 2px;
    z-index: 2;
    background: #0b4ed9;
    color: #fff;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 700;
}
.speaker-voice-toggle {
    display: flex;
    width: fit-content;
    margin: 0 auto 12px;
    padding: 4px;
    border: 1px solid #d7e6ff;
    border-radius: 999px;
    background: #fff;
    gap: 4px;
}
.voice-chip {
    border: 0;
    background: transparent;
    border-radius: 999px;
    padding: 8px 14px;
    font: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    color: #4b5563;
    cursor: pointer;
}
.voice-chip.is-active { background: #1e6bff; color: #fff; }
.speaker-chat {
    flex: 1;
    overflow-y: auto;
    padding: 0 4px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 220px;
    max-height: min(42vh, 420px);
}
.speak-bubble {
    background: #fff;
    border: 1px solid #d7e6ff;
    border-radius: 18px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.speak-line.user .speak-bubble {
    background: #f0f2f5;
    border-color: transparent;
}
.speak-main { font-weight: 650; color: #1f2937; line-height: 1.45; white-space: pre-wrap; }
.speak-sub { margin-top: 8px; color: #6b7280; font-style: italic; font-size: 0.92rem; }
.speak-metrics {
    display: flex;
    justify-content: space-evenly;
    color: #4b5563;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0 8px;
}
.speaker-dock {
    margin-top: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 28px 28px 16px 16px;
    padding: 14px 12px 10px;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
}
.speaker-hint {
    margin: 0 0 12px;
    text-align: center;
    color: #1e6bff;
    font-weight: 700;
    font-size: 0.92rem;
}
.speaker-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 22px;
}
.speaker-fab {
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
}
.speaker-fab.mic {
    width: 72px;
    height: 72px;
    background: #0b4ed9;
    color: #fff;
    font-size: 1.55rem;
}
.speaker-fab.mic.listening { background: #16a34a; }
.speaker-fab.mic { position: relative; overflow: visible; }
.mic-glow {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.45);
    opacity: 0;
}
.speaker-fab.mic.listening .mic-glow {
    opacity: 1;
    animation: micGlowPulse 1.2s ease-out infinite;
}
@keyframes micGlowPulse {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); opacity: 0.9; }
    70% { box-shadow: 0 0 0 14px rgba(22, 163, 74, 0); opacity: 0; }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); opacity: 0; }
}
.speaker-fab.pause { background: #f59e0b; color: #fff; }
.speaker-fab.pause.resume { background: #16a34a; }
.speaker-fab.end { background: #f3f4f6; color: #6b7280; }
.speaker-control-caption {
    margin: 8px 0 0;
    text-align: center;
    color: #6b7280;
    font-size: 0.8rem;
    font-weight: 700;
}
.speaker-dock-actions {
    display: flex;
    border-top: 1px solid #e5e7eb;
    margin-top: 12px;
    padding-top: 4px;
}
.speaker-text-btn {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 10px;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #6b7280;
    cursor: pointer;
}
.speaker-dialog {
    border: 0;
    border-radius: 16px;
    padding: 1.25rem;
    width: min(420px, 92vw);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}
.speaker-dialog textarea { width: 100%; }
.speaker-prestart { margin-top: 1rem; }

.speaker-top-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; flex: 1; }
.speaker-progress { width: min(220px, 55vw); text-align: center; }
.speaker-progress-track {
  height: 6px; border-radius: 999px; background: #dbe7ff; overflow: hidden; margin-bottom: 4px;
}
.speaker-progress-track i {
  display: block; height: 100%; width: 0; background: linear-gradient(90deg, #1e6bff, #38bdf8); border-radius: inherit;
  transition: width .35s ease;
}
#speaker-progress-label { font-size: .72rem; color: #64748b; font-weight: 600; }

.speaker-howto { margin: 0 0 1rem 1.1rem; color: #475569; line-height: 1.55; }
.speaker-prompt-card {
  margin: 0 1rem .75rem; padding: .85rem 1rem; border-radius: 16px;
  background: linear-gradient(180deg, #eff6ff, #f8fbff); border: 1px solid #d7e6ff;
}
.speaker-prompt-label { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #1e6bff; }
.speaker-prompt-text { margin: .35rem 0 0; font-size: 1.15rem; font-weight: 700; color: #0f172a; line-height: 1.35; }
.speaker-prompt-help { margin: .35rem 0 0; color: #64748b; font-style: italic; }
.speaker-hint-btn {
  margin-top: .65rem; border: 0; background: transparent; color: #1e6bff; font-weight: 700; cursor: pointer; padding: 0;
}
.speaker-model-answer { margin: .4rem 0 0; color: #0f766e; font-weight: 650; }

.speaker-sheet {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(15, 23, 42, .42); padding: 1rem;
}
.speaker-sheet[hidden] { display: none !important; }
.speaker-sheet-card {
  width: min(440px, 100%); background: #fff; border-radius: 22px 22px 16px 16px;
  padding: 1.25rem 1.2rem 1.1rem; box-shadow: 0 -8px 40px rgba(15, 23, 42, .18);
  animation: speakSheetIn .28s ease;
}
@keyframes speakSheetIn {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.speaker-stars { margin: 0; text-align: center; font-size: 1.6rem; letter-spacing: .15em; color: #f59e0b; }
.speaker-sheet-card h2 { margin: .35rem 0 0; text-align: center; font-size: 1.35rem; }
.speaker-score-big { margin: .2rem 0 .8rem; text-align: center; font-size: 2.4rem; font-weight: 800; color: #1e6bff; }
.speaker-meters { display: grid; gap: .45rem; margin-bottom: .75rem; }
.speaker-meter { display: grid; grid-template-columns: 64px 1fr 36px; gap: .5rem; align-items: center; font-size: .85rem; }
.speaker-meter-track { height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.speaker-meter-track i { display: block; height: 100%; background: #22c55e; border-radius: inherit; }
.speaker-words { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .65rem; }
.word-chip {
  padding: .25rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 650; background: #f1f5f9; color: #334155;
}
.word-chip.status-good { background: #dcfce7; color: #166534; }
.word-chip.status-needs_work { background: #fee2e2; color: #991b1b; }
.word-chip.status-ok { background: #e0f2fe; color: #075985; }
.grammar-tip { margin-bottom: .45rem; padding: .55rem .7rem; border-radius: 12px; background: #fff7ed; border: 1px solid #fed7aa; }
.grammar-tip strong { display: block; color: #9a3412; }
.grammar-tip span { color: #78716c; font-size: .88rem; }
.speaker-coach-line { margin: .5rem 0; text-align: center; color: #334155; font-weight: 600; }
.speaker-model-line { margin: 0 0 .75rem; text-align: center; font-size: .9rem; }
.speaker-sheet-actions { display: flex; gap: .65rem; }
.speaker-sheet-actions .btn { flex: 1; text-align: center; }
.speaker-xp-pill {
  display: inline-block; margin: .5rem auto 1rem; padding: .35rem .9rem; border-radius: 999px;
  background: #fef3c7; color: #92400e; font-weight: 800;
}
.speaker-results-card { text-align: center; }

/* Hub */
.speak-hub-hero { margin-bottom: 1rem; }
.speak-hub-stats {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem;
}
@media (min-width: 720px) {
  .speak-hub-stats { grid-template-columns: 1fr 1.4fr 1fr 1fr; }
}
.speak-stat {
  background: #fff; border: 1px solid var(--line, #e5e7eb); border-radius: 16px; padding: .85rem 1rem;
}
.speak-stat-value { display: block; font-size: 1.25rem; font-weight: 800; color: #0f172a; }
.speak-stat-label { color: #64748b; font-size: .82rem; }
.speak-goal-bar { margin-top: .55rem; height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.speak-goal-bar i { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #84cc16); }
.speak-continue {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(135deg, #eff6ff, #f0fdf4); border: 1px solid #bfdbfe; border-radius: 16px;
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.speak-lesson-list h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.speak-lesson-card {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line, #e5e7eb); border-radius: 16px; padding: .9rem 1rem; margin-bottom: .65rem;
}
.speak-lesson-card.status-locked { opacity: .55; }
.speak-lesson-main { display: flex; gap: .75rem; align-items: flex-start; min-width: 0; }
.speak-lesson-rank {
  width: 34px; height: 34px; border-radius: 12px; background: #eff6ff; color: #1e6bff;
  display: grid; place-items: center; font-weight: 800; flex: 0 0 auto;
}
.speak-lesson-actions { display: flex; gap: .55rem; align-items: center; }
.speak-history-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .65rem 0; border-bottom: 1px solid var(--line, #e5e7eb);
}
.speak-history-row:last-child { border-bottom: 0; }
.speak-history-score { font-weight: 800; color: #1e6bff; }
.speak-vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .65rem; }
.speak-vocab-chip {
  border-radius: 14px; border: 1px solid #e2e8f0; padding: .7rem .8rem; background: #f8fafc;
}
.speak-vocab-chip strong { display: block; }
.speak-vocab-chip span { color: #64748b; font-size: .85rem; }

.hub-pulse {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.pulse-item {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.85rem 0.75rem;
    text-align: center;
}
.pulse-value { display: block; font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.pulse-label { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.hub-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.hub-action {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.85rem;
    background: var(--bg-soft);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.hub-action span { color: var(--muted); font-size: 0.82rem; }
@media (max-width: 639px) {
    .hub-pulse { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
