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

/* Dark is the default theme. Light is applied via <html data-theme="light">
   (see js/theme.js). Every colour below is a token so the two palettes stay
   in sync; a few base values are shifted by one step so a global find/replace
   of the old literals never rewrites a token's own definition. */
:root {
    --black: #09090B;            /* page background */
    --purple: #8B5CF7;           /* accent */
    --violet: #6D28DA;           /* accent (darker / hover / gradient end) */
    --silver: #CBD5E2;           /* secondary text */
    --white: #FEFEFE;            /* alias of --text, kept for older rules */
    --card: var(--surface);
    --border: rgba(255, 255, 255, 0.095);

    --surface: #111115;          /* raised card surface */
    --surface-sunken: #0C0C0E;   /* inputs, sidebar, sunken panels */
    --surface-raised: #17171C;   /* chips, list items, hovers */
    --surface-glass: rgba(255, 255, 255, 0.033);
    --track: #252528;            /* progress / meter tracks */
    --text: #FDFDFD;             /* primary text */
    --text-muted: #90909A;       /* muted body text */
    --text-faint: #76767F;       /* labels, timestamps, placeholders */
    --border-strong: rgba(255, 255, 255, 0.125);
    --accent-soft: #B49AFF;      /* pale purple accent on dark */
    --on-accent: rgb(255, 255, 255); /* text on a solid purple fill */
    --danger-text: #FCA5A6;
    --success-text: #86EFAD;
    --navbar-bg: rgba(9, 9, 11, 0.86);
    --shadow-strong: rgba(0, 0, 0, 0.52);
}

:root[data-theme="light"] {
    --black: #F5F6F8;
    --purple: var(--violet);
    --violet: #5B21B6;
    --silver: #4B4B52;
    --white: #1B1B1F;
    --card: rgb(255, 255, 255);
    --border: rgba(17, 17, 22, 0.12);

    --surface: rgb(255, 255, 255);
    --surface-sunken: #EDEFF3;
    --surface-raised: #F2F3F6;
    --surface-glass: rgba(17, 17, 22, 0.03);
    --track: #E1E3E9;
    --text: #1B1B1F;
    --text-muted: #55555E;
    --text-faint: #74747D;
    --border-strong: rgba(17, 17, 22, 0.16);
    --accent-soft: var(--violet);
    --on-accent: rgb(255, 255, 255);
    --danger-text: #B42318;
    --success-text: #15803D;
    --navbar-bg: rgba(245, 246, 248, 0.85);
    --shadow-strong: rgba(17, 17, 22, 0.12);
}

:root {
    color-scheme: dark;
}

:root[data-theme="light"] {
    color-scheme: light;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--black);
    color: var(--white);
    font-family: "Inter", sans-serif;
    line-height: 1.6;
}

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

.navbar {
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6%;
    border-bottom: 1px solid var(--border);
    background: var(--navbar-bg);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: "Space Grotesk", sans-serif;
    font-size: 20px;
    font-weight: 700;
}

.logo-placeholder {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--purple), var(--violet));
    color: var(--on-accent);
    font-size: 13px;
    font-weight: 700;
}

.logo {
    width: 100px;
    height: 60px;
    object-fit: contain;
    display: block;
}

nav {
    display: flex;
    gap: 32px;
}

nav a {
    color: var(--silver);
    font-size: 14px;
    transition: 0.2s;
}

nav a:hover {
    color: var(--white);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 600;
    font-size: 14px;
    transition: 0.25s;
    cursor: pointer;
}

.btn-primary {
    background: var(--purple);
    color: var(--on-accent);
}

.btn-primary:hover {
    background: var(--violet);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.25);
}

.btn-secondary {
    border: 1px solid var(--border);
    color: var(--silver);
    background: var(--surface-glass);
}

.btn-secondary:hover {
    color: var(--text);
    border-color: rgba(139, 92, 246, 0.5);
}

.btn-large {
    padding: 14px 22px;
    font-size: 15px;
}

.hero {
    min-height: 720px;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    align-items: center;
    gap: 60px;
    padding: 80px 8%;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    width: 500px;
    height: 500px;
    background: var(--violet);
    opacity: 0.15;
    filter: blur(140px);
    top: -150px;
    right: -100px;
    border-radius: 50%;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.badge {
    display: inline-block;
    padding: 7px 13px;
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 30px;
    color: var(--accent-soft);
    background: rgba(139, 92, 246, 0.08);
    font-size: 13px;
    margin-bottom: 24px;
}

h1,
h2,
h3 {
    font-family: "Space Grotesk", sans-serif;
}

h1 {
    font-size: clamp(48px, 6vw, 78px);
    line-height: 1.03;
    letter-spacing: -3px;
    max-width: 750px;
}

h1 span,
h2 span {
    background: linear-gradient(90deg, var(--purple), var(--accent-soft));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.hero-content > p {
    max-width: 610px;
    color: var(--silver);
    margin: 25px 0;
    font-size: 17px;
}

.hero-buttons {
    display: flex;
    gap: 12px;
}

.hero-stats {
    display: flex;
    gap: 40px;
    margin-top: 45px;
}

.hero-stats div {
    display: flex;
    flex-direction: column;
}

.hero-stats strong {
    font-size: 21px;
}

.hero-stats span {
    color: var(--text-faint);
    font-size: 12px;
}

.hero-card {
    position: relative;
    z-index: 2;
}

.ai-window {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 22px;
    box-shadow: 0 30px 100px var(--shadow-strong);
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.ai-avatar {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--purple), var(--violet));
    color: var(--on-accent);
}

.ai-header strong {
    display: block;
}

.ai-header small {
    color: var(--text-faint);
}

.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22C55E;
    margin-left: auto;
}

.chat-preview {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 25px 0;
}

.message {
    max-width: 80%;
    padding: 12px 15px;
    border-radius: 15px;
    font-size: 14px;
}

.message.student {
    align-self: flex-end;
    background: var(--purple);
    color: var(--on-accent);
}

.message.ai {
    background: var(--surface-raised);
    color: var(--silver);
}

.fake-input {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 12px;
    color: var(--text-faint);
}

.fake-input button {
    border: 0;
    background: var(--purple);
    color: var(--on-accent);
    width: 32px;
    height: 32px;
    border-radius: 9px;
}

.section {
    padding: 100px 8%;
}

.section-heading {
    max-width: 650px;
    margin-bottom: 55px;
}

.eyebrow {
    color: var(--purple);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

h2 {
    font-size: clamp(32px, 4vw, 50px);
    line-height: 1.1;
    margin: 12px 0;
}

.section-heading p {
    color: var(--silver);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}

.feature-card {
    padding: 28px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 20px;
    transition: 0.25s;
}

.feature-card:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.4);
}

.feature-icon {
    font-size: 28px;
    margin-bottom: 25px;
}

.feature-card h3 {
    margin-bottom: 10px;
}

.feature-card p {
    color: var(--text-muted);
    font-size: 14px;
}

.steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.step {
    display: flex;
    gap: 18px;
}

.step > span {
    color: var(--purple);
    font-family: "Space Grotesk";
    font-weight: 700;
}

.step h3 {
    margin-bottom: 7px;
}

.step p {
    color: var(--text-muted);
    font-size: 14px;
}

.cta {
    margin: 40px 8% 100px;
    padding: 55px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 25px;
    background:
        radial-gradient(circle at 80% 50%, rgba(109, 40, 217, 0.25), transparent 45%),
        var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cta h2 {
    margin-bottom: 5px;
}

.cta p {
    color: var(--silver);
}

footer {
    border-top: 1px solid var(--border);
    padding: 30px 8%;
    display: flex;
    justify-content: space-between;
    color: var(--text-faint);
}

footer .brand {
    color: var(--text);
}

@media (max-width: 900px) {

    nav {
        display: none;
    }

    .hero {
        grid-template-columns: 1fr;
        padding-top: 60px;
    }

    .feature-grid,
    .steps {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
   .mobile-brand {
    display: flex;
    align-items: center;
}

.dashboard-header .mobile-brand {
    display: flex;
}

.mobile-brand .logo {
    width: 90px;
    height: 50px;
    object-fit: contain;
}
    .navbar {
        padding: 0 5%;
    }

    .nav-actions .btn-secondary {
        display: none;
    }

    .hero {
        padding: 55px 5%;
    }

    h1 {
        font-size: 45px;
        letter-spacing: -2px;
    }

    .hero-buttons {
        flex-direction: column;
    }

    .hero-stats {
        gap: 20px;
    }

    .section {
        padding: 70px 5%;
    }

    .feature-grid,
    .steps {
        grid-template-columns: 1fr;
    }

    .cta {
        margin: 20px 5% 70px;
        padding: 30px;
        flex-direction: column;
        align-items: flex-start;
        gap: 25px;
    }

    footer {
        padding: 25px 5%;
        flex-direction: column;
        gap: 15px;
    }
}

.dashboard-page {
    min-height: 100vh;
    background: var(--black);
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 245px;
    padding: 28px 18px;
    border-right: 1px solid var(--border);
    background: var(--surface-sunken);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar .brand {
    padding: 0 10px;
    margin-bottom: 45px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar .logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 12px 14px;
    border-radius: 11px;
    color: var(--text-muted);
    font-size: 14px;
    transition: 0.2s;
}

.sidebar-link span {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-link:hover {
    background: rgba(139, 92, 246, 0.08);
    color: var(--text);
}

.sidebar-link.active {
    background: rgba(139, 92, 246, 0.14);
    color: var(--text);
}

.sidebar-link.active span {
    color: var(--purple);
}

.sidebar-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.dashboard-main {
    margin-left: 245px;
    min-height: 100vh;
    padding: 0 45px 60px;
}

.dashboard-header {
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.dashboard-header .mobile-brand {
    display: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 22px;
}

.notification-btn {
    position: relative;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--silver);
    width: 40px;
    height: 40px;
    border-radius: 11px;
    cursor: pointer;
}

.notification-btn span {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--purple);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile strong {
    display: block;
    font-size: 13px;
}

.user-profile small {
    display: block;
    color: var(--text-faint);
    font-size: 11px;
    margin-top: 2px;
}

.avatar {
    width: 39px;
    height: 39px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple), var(--violet));
    color: var(--on-accent);
    font-weight: 700;
}

.mobile-brand {
    display: flex;
    align-items: center;
}

.mobile-brand .logo {
    width: 100px;
    height: 60px;
    object-fit: contain;
}

.welcome-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 48px 0 30px;
}

.welcome-section h1 {
    font-size: 38px;
    letter-spacing: -1.5px;
    margin: 7px 0;
}

.welcome-section p {
    color: var(--silver);
    font-size: 15px;
}

.learning-streak {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 17px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.learning-streak > span {
    font-size: 24px;
}

.learning-streak strong {
    display: block;
    font-size: 13px;
}

.learning-streak small {
    color: var(--text-faint);
    font-size: 11px;
}

.topic-search {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px 9px 17px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
    margin-bottom: 55px;
    transition: 0.2s;
}

.topic-search:focus-within {
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.08);
}

.search-icon {
    color: var(--text-faint);
    font-size: 23px;
}

.topic-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
}

.topic-search input::placeholder {
    color: var(--text-faint);
}

.dashboard-section {
    margin-bottom: 55px;
}

.section-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 22px;
}

.section-title h2 {
    font-size: 24px;
    margin-top: 5px;
}

.view-all {
    color: var(--purple);
    font-size: 13px;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 13px;
}

.subject-card {
    text-align: left;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: 0.25s;
    font-family: inherit;
}

.subject-card:hover {
    transform: translateY(-4px);
    border-color: rgba(139, 92, 246, 0.45);
    background: var(--surface-raised);
}

.subject-icon {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-soft);
    font-size: 19px;
    margin-bottom: 17px;
}

.subject-card strong {
    display: block;
    font-size: 14px;
    margin-bottom: 5px;
}

.subject-card small {
    color: var(--text-faint);
    font-size: 11px;
}

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 17px;
}

.lesson-card {
    padding: 24px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 18px;
}

.lesson-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-faint);
    font-size: 11px;
}

.lesson-tag {
    color: var(--purple);
    font-weight: 700;
    letter-spacing: 0.8px;
}

.lesson-card h3 {
    font-size: 21px;
    margin: 18px 0 7px;
}

.lesson-card p {
    color: var(--text-muted);
    font-size: 13px;
    max-width: 500px;
}

.progress {
    height: 5px;
    border-radius: 20px;
    background: var(--track);
    margin: 22px 0 17px;
    overflow: hidden;
}

.progress div {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--violet), var(--purple));
}

.continue-btn {
    border: none;
    background: transparent;
    color: var(--purple);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

.dashboard-bottom {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 18px;
}

.performance-card,
.ai-dashboard-card {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 18px;
    padding: 25px;
}

.card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
}

.card-heading h2 {
    font-size: 22px;
    margin-top: 5px;
}

.score-circle {
    width: 55px;
    height: 55px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 3px solid var(--purple);
    font-size: 12px;
    font-weight: 700;
}

.performance-bars {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.performance-bars > div {
    display: grid;
    grid-template-columns: 90px 1fr 35px;
    align-items: center;
    gap: 12px;
    font-size: 12px;
}

.performance-bars > div > span {
    color: var(--silver);
}

.performance-bars strong {
    text-align: right;
    font-size: 11px;
}

.bar {
    height: 6px;
    background: var(--track);
    border-radius: 20px;
    overflow: hidden;
}

.bar div {
    height: 100%;
    background: var(--purple);
    border-radius: inherit;
}

.ai-dashboard-card {
    background:
        radial-gradient(
            circle at 100% 0%,
            rgba(109, 40, 217, 0.25),
            transparent 50%
        ),
        var(--surface);
}

.ai-small-icon {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(139, 92, 246, 0.14);
    color: var(--accent-soft);
    margin-bottom: 20px;
}

.ai-dashboard-card h2 {
    font-size: 22px;
    margin: 7px 0;
}

.ai-dashboard-card p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 25px;
}

@media (max-width: 1100px) {

    .subject-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .dashboard-bottom {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {

    .sidebar {
        width: 70px;
        padding: 22px 10px;
    }

    .sidebar .brand {
        justify-content: center;
        padding: 0;
    }

    .sidebar .logo {
        width: 48px;
        height: 48px;
    }

    .sidebar-link {
        justify-content: center;
        padding: 12px;
    }

    .sidebar-link span {
        font-size: 18px;
    }

    .sidebar-link {
        font-size: 0;
    }

    .dashboard-main {
        margin-left: 70px;
        padding: 0 25px 50px;
    }

    .subject-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {

    .sidebar {
    width: 72px;
    height: 100vh;
    top: 0;
    left: 0;
    bottom: auto;
    padding: 22px 10px;
    flex-direction: column;
    border-right: 1px solid var(--border);
    border-top: none;
}

.sidebar .brand {
    display: flex;
    justify-content: center;
    padding: 0;
    margin-bottom: 35px;
}

.sidebar .brand span {
    display: none;
}

.sidebar .logo {
    width: 42px;
    height: 42px;
}

.sidebar-nav {
    width: 100%;
    flex-direction: column;
    gap: 7px;
}

.sidebar-bottom {
    display: flex;
    margin-top: auto;
}

.sidebar-link {
    justify-content: center;
    padding: 12px;
}

.sidebar-link span {
    font-size: 18px;
}

.sidebar-link {
    font-size: 0;
}

.dashboard-main {
    margin-left: 72px;
    padding: 0 18px 50px;
}

    .dashboard-header {
        height: 70px;
    }

    .welcome-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        padding-top: 35px;
    }

    .welcome-section h1 {
        font-size: 30px;
    }

    .learning-streak {
        width: 100%;
    }

    .topic-search {
        flex-wrap: wrap;
    }

    .topic-search input {
        min-width: 150px;
    }

    .topic-search .btn {
        width: 100%;
    }

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

    .dashboard-bottom {
        grid-template-columns: 1fr;
    }
}

/* ------------------------------------------------------------------ */
/* Dashboard mobile layout (<= 768px).                                 */
/* Appended last so it wins the cascade over the 800px / 600px blocks. */
/* Sidebar rules are scoped to .dashboard-page so other pages that     */
/* share .sidebar are left untouched. Nothing here runs above 768px,   */
/* so desktop is unchanged.                                            */
/* ------------------------------------------------------------------ */
@media (max-width: 768px) {

    /* Sidebar -> slim icon-only rail (dashboard only) */
    .dashboard-page .sidebar {
        width: 58px;
        padding: 20px 7px;
    }

    .dashboard-page .sidebar .brand {
        justify-content: center;
        padding: 0;
        margin-bottom: 26px;
    }

    .dashboard-page .sidebar .brand span {
        display: none;
    }

    .dashboard-page .sidebar .logo {
        width: 34px;
        height: 34px;
    }

    .dashboard-page .sidebar-link {
        justify-content: center;
        gap: 0;
        padding: 12px 0;
        font-size: 0;
    }

    .dashboard-page .sidebar-link span {
        width: auto;
        font-size: 18px;
    }

    /* Main content takes the rest of the viewport and cannot overflow it */
    .dashboard-main {
        margin-left: 58px;
        padding: 0 14px 44px;
        max-width: 100%;
        overflow-x: clip;
    }

    .dashboard-main > * {
        min-width: 0;
        max-width: 100%;
    }

    /* Header: shrink the profile block, truncate the email safely */
    .dashboard-header {
        gap: 12px;
    }

    .user-profile {
        min-width: 0;
        flex: 1 1 auto;
    }

    .user-profile .avatar {
        flex-shrink: 0;
    }

    .user-profile > div {
        min-width: 0;
        flex: 1 1 auto;
    }

    .user-profile strong,
    .user-profile small {
        display: block;
        max-width: 100%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .notification-btn {
        flex-shrink: 0;
    }

    /* Welcome row stacks */
    .welcome-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
        padding: 30px 0 22px;
    }

    .welcome-section h1 {
        font-size: 28px;
    }

    .learning-streak {
        width: 100%;
        max-width: 100%;
    }

    /* Search: wraps to full width, no fixed min-width */
    .topic-search {
        flex-wrap: wrap;
        row-gap: 10px;
        margin-bottom: 36px;
    }

    .topic-search .search-icon {
        order: 1;
    }

    .topic-search input {
        order: 2;
        flex: 1 1 140px;
        min-width: 0;
    }

    .topic-search .btn {
        order: 3;
        width: 100%;
        flex: 1 1 100%;
    }

    /* Section headers wrap instead of squashing */
    .section-title {
        flex-wrap: wrap;
        gap: 4px 12px;
    }

    /* Grids -> two columns here, one column below 520px; cards fill width */
    .subject-grid,
    .lesson-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .subject-card,
    .lesson-card {
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }

    /* Bottom section stacks; both cards fill the width */
    .dashboard-bottom {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .performance-card,
    .ai-dashboard-card {
        min-width: 0;
        width: 100%;
        max-width: 100%;
        padding: 20px;
    }

    /* Quiz-performance card: title + score wrap, chart rows drop fixed columns */
    .card-heading {
        flex-wrap: wrap;
        gap: 10px 14px;
        margin-bottom: 20px;
    }

    .card-heading .score-circle {
        flex-shrink: 0;
    }

    .performance-bars > div {
        grid-template-columns: auto 1fr auto;
        gap: 10px;
    }
}

/* Narrow phones: subject / lesson grids go single-column */
@media (max-width: 520px) {

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

/* Smallest phones: fully stack each quiz-performance chart row */
@media (max-width: 430px) {

    .performance-bars > div {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "label label"
            "bar   value";
        row-gap: 6px;
        column-gap: 10px;
    }

    .performance-bars > div > span {
        grid-area: label;
    }

    .performance-bars > div > .bar {
        grid-area: bar;
        align-self: center;
    }

    .performance-bars > div > strong {
        grid-area: value;
    }
}

.lesson-page {
    min-height: 100vh;
    background: var(--black);
}

.lesson-main {
    margin-left: 245px;
    min-height: 100vh;
    padding: 0 45px 60px;
}

.lesson-heading {
    padding: 42px 0 30px;
}

.back-link {
    display: inline-block;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
    transition: 0.2s;
}

.back-link:hover {
    color: var(--purple);
}

.lesson-heading h1 {
    font-size: 42px;
    letter-spacing: -1.5px;
    margin: 8px 0;
}

.lesson-heading p {
    color: var(--text-muted);
    font-size: 14px;
}

.lesson-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 22px;
    align-items: start;
}

.lesson-content {
    min-width: 0;
}

.lesson-meta {
    display: flex;
    gap: 9px;
    align-items: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 18px;
}

.lesson-meta span:first-child {
    color: var(--purple);
}

.lesson-body {
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
}

.lesson-body h2 {
    font-size: 22px;
    margin: 0 0 13px;
}

.lesson-body h2:not(:first-child) {
    margin-top: 34px;
}

.lesson-body p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 16px;
}

.info-box {
    margin: 25px 0;
    padding: 18px 20px;
    border-left: 3px solid var(--purple);
    background: rgba(139, 92, 246, 0.08);
    border-radius: 0 12px 12px 0;
}

.info-box strong {
    font-size: 13px;
}

.info-box p {
    margin: 7px 0 0;
}

.formula-card {
    margin: 28px 0;
    padding: 25px;
    text-align: center;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.formula-card span {
    display: block;
    color: var(--purple);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
}

.formula-card strong {
    font-size: 15px;
    color: var(--silver);
}

.key-points {
    margin-top: 30px;
    padding: 22px;
    border-radius: 14px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
}

.key-points h3 {
    font-size: 15px;
    margin-bottom: 14px;
}

.key-points ul {
    margin: 0;
    padding-left: 20px;
}

.key-points li {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.8;
    margin-bottom: 5px;
}

.lesson-quiz-cta {
    margin-top: 18px;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 18px;
    background:
        radial-gradient(
            circle at 100% 50%,
            rgba(109, 40, 217, 0.18),
            transparent 55%
        ),
        var(--surface);
}

.lesson-quiz-cta h2 {
    font-size: 19px;
    margin: 6px 0;
}

.lesson-quiz-cta p {
    color: var(--text-muted);
    font-size: 12px;
}

.lesson-tutor {
    position: sticky;
    top: 25px;
    height: 560px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
}

.tutor-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 19px;
    border-bottom: 1px solid var(--border);
}

.tutor-header .ai-small-icon {
    flex-shrink: 0;
    margin: 0;
    width: 38px;
    height: 38px;
}

.tutor-header strong {
    display: block;
    font-size: 13px;
}

.tutor-header small {
    display: block;
    color: var(--text-faint);
    font-size: 10px;
    margin-top: 3px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.ai-message,
.student-message {
    max-width: 90%;
    padding: 11px 13px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.6;
}

.ai-message {
    align-self: flex-start;
    color: var(--silver);
    background: var(--surface-raised);
    border: 1px solid var(--border);
}

.student-message {
    align-self: flex-end;
    color: var(--text);
    background: rgba(139, 92, 246, 0.18);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.chat-input input {
    min-width: 0;
    flex: 1;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    background: var(--surface-sunken);
    color: var(--text);
    font-family: inherit;
    font-size: 11px;
}

.chat-input input:focus {
    border-color: rgba(139, 92, 246, 0.5);
}

.chat-input button {
    width: 38px;
    border: none;
    border-radius: 10px;
    background: var(--purple);
    color: var(--on-accent);
    cursor: pointer;
    font-size: 17px;
}

@media (max-width: 1100px) {

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

    .lesson-tutor {
        position: static;
        height: 430px;
    }
}

@media (max-width: 800px) {

    .lesson-main {
        margin-left: 72px;
        padding: 0 25px 50px;
    }

    .lesson-heading h1 {
        font-size: 34px;
    }
}

@media (max-width: 600px) {

    .lesson-main {
        margin-left: 72px;
        padding: 0 15px 40px;
    }

    .lesson-heading {
        padding-top: 30px;
    }

    .lesson-heading h1 {
        font-size: 28px;
    }

    .lesson-body {
        padding: 22px;
    }

    .lesson-quiz-cta {
        flex-direction: column;
        align-items: flex-start;
    }

    .lesson-quiz-cta .btn {
        width: 100%;
        text-align: center;
    }

    .lesson-tutor {
        height: 450px;
    }
}

.quiz-main {
    margin-left: 245px;
    min-height: 100vh;
    padding: 0 40px 50px;
}

.quiz-heading {
    max-width: 850px;
    margin: 35px auto 25px;
}

.quiz-heading .eyebrow {
    display: block;
    margin-top: 24px;
    margin-bottom: 10px;
}

.quiz-heading h1 {
    font-family: "Space Grotesk", sans-serif;
    font-size: 2.3rem;
    margin-bottom: 8px;
}

.quiz-heading p {
    color: var(--silver);
}

.quiz-container {
    max-width: 850px;
    margin: 0 auto;
}

.quiz-progress-top {
    margin-bottom: 22px;
}

.quiz-progress-top > div:first-child {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px 20px;
    margin-bottom: 12px;
    color: var(--silver);
}

#quizScore {
    color: var(--text);
}

.quiz-progress-bar {
    width: 100%;
    height: 7px;
    border-radius: 20px;
    background: var(--border);
    overflow: hidden;
}

#quizProgress {
    width: 20%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(
        90deg,
        var(--purple),
        var(--violet)
    );
}

.question-card {
    padding: 32px;
    border-radius: 20px;
    background: var(--surface-glass);
    border: 1px solid var(--border);
}

.question-label {
    color: var(--purple);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.question-card h2 {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.5rem;
    line-height: 1.4;
    margin: 14px 0 25px;
}

.answer-options {
    display: grid;
    gap: 13px;
}

.answer-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 15px;

    text-align: left;

    padding: 15px 17px;

    color: var(--text);
    background: var(--surface-glass);

    border: 1px solid var(--border);
    border-radius: 13px;

    cursor: pointer;

    font-family: "Inter", sans-serif;
    font-size: 0.95rem;

    transition: 0.2s ease;
}

.answer-option span {
    width: 35px;
    height: 35px;

    flex-shrink: 0;

    display: grid;
    place-items: center;

    border-radius: 9px;

    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-soft);

    font-weight: 700;
}

.answer-option:hover {
    border-color: var(--purple);
    background: rgba(139, 92, 246, 0.08);
    transform: translateY(-1px);
}

.quiz-actions {
    display: flex;
    justify-content: space-between;
    gap: 15px;

    margin-top: 22px;
}

.quiz-secondary-btn {
    padding: 12px 20px;

    border-radius: 10px;
    border: 1px solid var(--border-strong);

    background: transparent;
    color: var(--silver);

    cursor: pointer;

    font-family: "Inter", sans-serif;
}

@media (max-width: 800px) {

    .quiz-main {
        margin-left: 72px;
        padding: 0 22px 40px;
    }

    .quiz-heading {
        margin-top: 25px;
    }

    .quiz-heading h1 {
        font-size: 2rem;
    }

    .question-card {
        padding: 25px;
    }
}

@media (max-width: 600px) {

    .quiz-main {
        margin-left: 72px;
        padding: 0 14px 35px;
    }

    .quiz-heading {
        margin-top: 20px;
    }

    .quiz-heading h1 {
        font-size: 1.65rem;
    }

    .quiz-heading p {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .quiz-progress-top > div:first-child {
        font-size: 0.8rem;
    }

    .question-card {
        padding: 20px 15px;
        border-radius: 16px;
    }

    .question-card h2 {
        font-size: 1.15rem;
    }

    .answer-option {
        padding: 12px;
        gap: 10px;
        font-size: 0.86rem;
    }

    .answer-option span {
        width: 32px;
        height: 32px;
    }

    .quiz-actions {
        flex-direction: column-reverse;
    }

    .quiz-actions button,
    .quiz-actions .btn {
        width: 100%;
        text-align: center;
    }
}

.answer-option.selected {
    border-color: var(--purple);
    background: rgba(139, 92, 246, 0.15);
}

.result-main {
    margin-left: 245px;
    min-height: 100vh;
    padding: 0 40px 50px;
}

.result-section {
    min-height: calc(100vh - 90px);
    display: grid;
    place-items: center;
}

.result-card {
    width: 100%;
    max-width: 600px;

    text-align: center;

    padding: 45px 35px;

    border-radius: 24px;

    background: var(--surface-glass);

    border: 1px solid var(--border);
}

.result-card h1 {
    font-family: "Space Grotesk", sans-serif;
    font-size: 2.4rem;

    margin: 12px 0 8px;
}

.result-card > p {
    color: var(--text-muted);
}

.score-circle {
    width: 170px;
    height: 170px;

    margin: 35px auto 20px;

    display: flex;
    flex-direction: column;
    justify-content: center;

    border-radius: 50%;

    border: 8px solid rgba(139, 92, 246, 0.2);

    background: rgba(139, 92, 246, 0.08);
}

.score-circle strong {
    font-family: "Space Grotesk", sans-serif;
    font-size: 2.4rem;

    color: var(--accent-soft);
}

.score-circle span {
    margin-top: 5px;

    color: var(--text-muted);

    font-size: 0.85rem;
}

#resultScore {
    font-size: 1.5rem;

    margin-bottom: 10px;
}

#resultFeedback {
    max-width: 420px;

    margin: 0 auto;

    line-height: 1.6;
}

.result-actions {
    display: flex;
    justify-content: center;

    gap: 14px;

    margin-top: 30px;
}

@media (max-width: 800px) {

    .result-main {
        margin-left: 72px;
        padding: 0 22px 40px;
    }
}

@media (max-width: 600px) {

    .result-main {
        margin-left: 72px;
        padding: 0 14px 35px;
    }

    .result-card {
        padding: 32px 18px;
    }

    .result-card h1 {
        font-size: 1.8rem;
    }

    .score-circle {
        width: 145px;
        height: 145px;
    }

    .score-circle strong {
        font-size: 2rem;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions a {
        width: 100%;
        text-align: center;
    }
}

.subject-card.selected {
    border-color: var(--purple);
    background: rgba(139, 92, 246, 0.12);
    transform: translateY(-2px);
}

.tutor-page {
    min-height: 100vh;
    background: var(--black);
}

.tutor-main {
    margin-left: 245px;
    min-height: 100vh;
    padding: 0 45px 40px;
    display: flex;
    flex-direction: column;
}

.tutor-main .dashboard-header {
    flex-shrink: 0;
}

.tutor-heading {
    flex-shrink: 0;
    padding: 34px 0 22px;
}

.tutor-heading h1 {
    font-family: "Space Grotesk", sans-serif;
    font-size: 34px;
    letter-spacing: -1.5px;
    margin: 8px 0 12px;
}

.tutor-topic-chip {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 7px 14px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 30px;
    background: rgba(139, 92, 246, 0.08);
    color: var(--accent-soft);
    font-size: 12px;
}

.tutor-topic-chip strong {
    color: var(--text);
    font-weight: 600;
}

.tutor-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 18px;
    padding-bottom: 18px;
}

.conversation-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    overflow: hidden;
}

.conversation-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 15px 16px;
    border-bottom: 1px solid var(--border);
}

.conversation-panel-head strong {
    font-size: 13px;
}

.new-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 9px;
    background: var(--purple);
    color: var(--on-accent);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.new-chat-btn:hover {
    background: var(--violet);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.conversation-item {
    display: grid;
    gap: 4px;
    width: 100%;
    text-align: left;
    padding: 12px 13px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: var(--surface-raised);
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    transition: 0.2s;
}

.conversation-item:hover {
    border-color: rgba(139, 92, 246, 0.35);
}

.conversation-item.active {
    background: rgba(139, 92, 246, 0.14);
    border-color: rgba(139, 92, 246, 0.4);
}

.conversation-item .c-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .c-preview {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .c-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 10px;
    color: var(--text-faint);
}

.conversation-item .c-meta > span:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-delete {
    flex-shrink: 0;
    padding: 0 3px;
    color: var(--text-faint);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.conversation-delete:hover {
    color: var(--danger-text);
}

.conversation-empty {
    padding: 22px 14px;
    color: var(--text-faint);
    font-size: 12px;
    text-align: center;
}

.chat-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    overflow: hidden;
}

.chat-panel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.chat-panel-topic {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.chat-panel-topic .ai-small-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    margin: 0;
}

.chat-panel-topic strong {
    display: block;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-panel-topic small {
    display: block;
    color: var(--text-faint);
    font-size: 11px;
    margin-top: 2px;
}

.clear-chat-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--silver);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.clear-chat-btn:hover {
    color: var(--text);
    border-color: rgba(248, 113, 113, 0.5);
}

.tutor-page .chat-messages {
    flex: 1;
    padding: 22px;
    gap: 15px;
}

.tutor-page .ai-message,
.tutor-page .student-message {
    max-width: 78%;
    padding: 13px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.7;
}

.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 22px 10px;
}

.suggested-questions button {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface-raised);
    color: var(--silver);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.suggested-questions button:hover {
    color: var(--text);
    border-color: rgba(139, 92, 246, 0.45);
}

.tutor-page .chat-input {
    padding: 14px;
    gap: 10px;
}

.tutor-page .chat-input input {
    padding: 13px 15px;
    font-size: 13px;
}

.tutor-page .chat-input button {
    width: 44px;
    font-size: 18px;
}

@media (max-width: 1000px) {

    .tutor-layout {
        grid-template-columns: 1fr;
    }

    .conversation-panel {
        max-height: 220px;
    }

    .chat-panel {
        min-height: 460px;
    }
}

@media (max-width: 800px) {

    .tutor-main {
        margin-left: 72px;
        padding: 0 25px 40px;
    }
}

@media (max-width: 600px) {

    .tutor-main {
        margin-left: 72px;
        padding: 0 14px 30px;
    }

    .tutor-heading {
        padding-top: 26px;
    }

    .tutor-heading h1 {
        font-size: 26px;
    }

    .chat-panel-top {
        flex-wrap: wrap;
    }

    .tutor-page .chat-messages {
        padding: 16px;
    }

    .tutor-page .ai-message,
    .tutor-page .student-message {
        max-width: 88%;
    }

    .suggested-questions {
        padding: 0 15px 10px;
    }
}

.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% 0%, rgba(109, 40, 217, 0.18), transparent 55%),
        var(--black);
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 38px 34px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
}

.auth-brand {
    margin-bottom: 26px;
}

.auth-card h1 {
    font-family: "Space Grotesk", sans-serif;
    font-size: 26px;
    letter-spacing: -1px;
    margin: 8px 0 6px;
}

.auth-sub {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 22px;
}

.auth-notice {
    padding: 11px 14px;
    border-radius: 11px;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--silver);
}

.auth-notice.error {
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.08);
    color: var(--danger-text);
}

.auth-notice.success {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.08);
    color: var(--success-text);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.auth-field span {
    font-size: 12px;
    font-weight: 600;
    color: var(--silver);
}

.auth-field input {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-sunken);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
}

.auth-field input:focus {
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.08);
}

.auth-field input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-form .btn {
    width: 100%;
    margin-top: 6px;
}

.auth-switch {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.auth-switch a {
    color: var(--purple);
    font-weight: 600;
}

@media (max-width: 600px) {

    .auth-card {
        padding: 30px 22px;
    }
}

/* ------------------------------------------------------------------ */
/* AI states: loading, errors, retry (tutor + lesson + quiz)          */
/* ------------------------------------------------------------------ */

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.35;
    animation: aderaBlink 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes aderaBlink {
    0%, 80%, 100% {
        opacity: 0.25;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.ai-message.is-error {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.08);
    color: var(--danger-text);
}

.chat-error-text {
    margin: 0;
    color: inherit;
    font-size: inherit;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.chat-retry-btn {
    align-self: flex-start;
    padding: 6px 14px;
    border: 1px solid rgba(248, 113, 113, 0.5);
    border-radius: 9px;
    background: transparent;
    color: var(--danger-text);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.chat-retry-btn:hover {
    background: rgba(248, 113, 113, 0.15);
    color: var(--text);
}

/* Disabled state for the retry / generate controls during a rate-limit
   cooldown. Scoped so existing buttons (e.g. auth forms) are untouched. */
.chat-retry-btn:disabled,
.lesson-panel .btn:disabled,
.quiz-panel .btn:disabled,
#generateLessonBtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-note {
    align-self: center;
    max-width: 90%;
    color: var(--text-muted);
    font-size: 11px;
    font-style: italic;
    text-align: center;
}

/* ------------------------------------------------------------------ */
/* lesson page: subject / topic / difficulty controls + AI states     */
/* ------------------------------------------------------------------ */

.lesson-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-sunken);
}

.lesson-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 150px;
    min-width: 0;
    font-size: 12px;
    color: var(--silver);
}

.lesson-control-topic {
    flex: 2 1 220px;
}

.lesson-control select,
.lesson-control input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: 0.2s;
}

.lesson-control select:focus,
.lesson-control input:focus {
    border-color: rgba(139, 92, 246, 0.5);
}

.lesson-controls .btn {
    flex-shrink: 0;
}

.lesson-panel,
.quiz-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: 24px 0;
}

.lesson-panel p,
.quiz-panel p {
    max-width: 42ch;
    overflow-wrap: anywhere;
}

.quiz-panel {
    padding: 48px 20px;
}

.lesson-panel .ai-small-icon,
.quiz-panel .ai-small-icon {
    margin: 0;
}

.lesson-panel.is-error .ai-small-icon,
.quiz-panel.is-error .ai-small-icon {
    background: rgba(248, 113, 113, 0.14);
    color: var(--danger-text);
}

.lesson-panel .btn,
.quiz-panel .btn {
    margin-top: 6px;
}

@media (max-width: 600px) {

    .lesson-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .lesson-controls .btn {
        width: 100%;
        text-align: center;
    }
}

/* ------------------------------------------------------------------ */
/* result page: answer review                                         */
/* ------------------------------------------------------------------ */

.quiz-review {
    display: block;
    margin-top: 30px;
    text-align: left;
}

.quiz-review:empty {
    display: none;
}

.quiz-review-title {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.1rem;
    margin-bottom: 14px;
}

.review-item {
    margin-bottom: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-glass);
}

.review-q-label {
    color: var(--purple);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.review-q {
    margin: 6px 0 12px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.review-options {
    display: grid;
    gap: 8px;
}

.review-option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.88rem;
}

.review-option.is-correct {
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(34, 197, 94, 0.1);
}

.review-option.is-wrong {
    border-color: rgba(248, 113, 113, 0.5);
    background: rgba(248, 113, 113, 0.1);
}

.review-badge {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-soft);
    font-weight: 700;
    font-size: 0.8rem;
}

.review-text {
    flex: 1 1 120px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.review-tag {
    flex-shrink: 0;
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.review-explain {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.review-explain strong {
    color: var(--silver);
}

@media (max-width: 600px) {

    .review-item {
        padding: 14px;
    }

    .review-tag {
        margin-left: 34px; /* line up under the option text, not the badge */
        flex-basis: 100%;
    }
}
/* ------------------------------------------------------------------ */
/* Light / dark theme toggle (button injected by js/theme.js)          */
/* ------------------------------------------------------------------ */

.theme-toggle {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: transparent;
    color: var(--text-faint);
    font-family: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: 0.2s;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: rgba(139, 92, 246, 0.4);
}

/* In the app sidebar, alongside Settings / Log Out */
.sidebar-bottom .theme-toggle {
    width: 100%;
    padding: 12px 14px;
}

/* On the marketing navbar, alongside Sign In / Get Started */
.nav-actions .theme-toggle {
    padding: 10px 14px;
}

/* On pages with neither (auth screens) it floats top-right */
.theme-toggle-floating {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 6px 20px var(--shadow-strong);
}

@media (max-width: 800px) {

    .sidebar-bottom .theme-toggle {
        padding: 12px 0;
    }
}
