@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

:root {
    --bg: #f5f0eb;
    --card: #fff;
    --text: #1a1a2e;
    --text2: #4a4a5a;
    --muted: #8e8e9a;
    --divider: rgba(0, 0, 0, .06);
    --math-from: #f9a8c9;
    --math-to: #f472a0;
    --math-text: #b83574;
    --hist-from: #a0c4f1;
    --hist-to: #6fa3e8;
    --hist-text: #2e6ab4;
    --info-from: #7edcbb;
    --info-to: #3cc99c;
    --info-text: #1c8a62;
    --mathlit-from: #f0a3ff;
    --mathlit-to: #d869f0;
    --mathlit-text: #aa3dcc;
    --whist-from: #ffc288;
    --whist-to: #f49b42;
    --whist-text: #cc6d12;
    --streak-from: #ffb347;
    --streak-to: #ff6723;
    --accent: #007aff;
    --shadow: 0 2px 12px rgba(0, 0, 0, .06);
    --shadow-lg: 0 6px 24px rgba(0, 0, 0, .08);
    --radius: 22px;
    --radius-sm: 16px;
    --radius-xs: 12px;
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) {
        --bg: #1c1c1e;
        --card: #2c2c2e;
        --text: #f5f5f7;
        --text2: #a1a1a6;
        --muted: #6e6e73;
        --divider: rgba(255, 255, 255, .08);
        --math-from: #f9a8c9;
        --math-to: #e8609a;
        --math-text: #f9a8c9;
        --hist-from: #8fb8e8;
        --hist-to: #5a93d4;
        --hist-text: #8fb8e8;
        --info-from: #6ed4ad;
        --info-to: #34b88a;
        --info-text: #6ed4ad;
        --mathlit-from: #e28def;
        --mathlit-to: #bd48d8;
        --mathlit-text: #e28def;
        --whist-from: #ffb16b;
        --whist-to: #df8029;
        --whist-text: #ffb16b;
        --shadow: 0 2px 12px rgba(0, 0, 0, .2);
        --shadow-lg: 0 6px 24px rgba(0, 0, 0, .3);
    }
}

:root[data-theme="dark"] {
    --bg: #1c1c1e;
    --card: #2c2c2e;
    --text: #f5f5f7;
    --text2: #a1a1a6;
    --muted: #6e6e73;
    --divider: rgba(255, 255, 255, .08);
    --math-from: #f9a8c9;
    --math-to: #e8609a;
    --math-text: #f9a8c9;
    --hist-from: #8fb8e8;
    --hist-to: #5a93d4;
    --hist-text: #8fb8e8;
    --info-from: #6ed4ad;
    --info-to: #34b88a;
    --info-text: #6ed4ad;
    --mathlit-from: #e28def;
    --mathlit-to: #bd48d8;
    --mathlit-text: #e28def;
    --whist-from: #ffb16b;
    --whist-to: #df8029;
    --whist-text: #ffb16b;
    --shadow: 0 2px 12px rgba(0, 0, 0, .2);
    --shadow-lg: 0 6px 24px rgba(0, 0, 0, .3);
}

html {
    scroll-behavior: smooth
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 50% 60% at 0% 0%, rgba(249, 168, 201, .18), transparent),
        radial-gradient(ellipse 40% 50% at 100% 20%, rgba(160, 196, 241, .15), transparent),
        radial-gradient(ellipse 45% 45% at 60% 100%, rgba(126, 220, 187, .12), transparent);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 72px;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    touch-action: pan-y;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

/* ═══ CONFETTI ═══ */
#confetti-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999
}

/* ═══ PAGES ═══ */
.page {
    display: none;
    animation: pageFade .25s ease
}

.page.active {
    display: block
}

/* ═══ BOTTOM NAV ═══ */
.bottom-nav {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    background: rgba(255, 255, 255, .6);
    border: 1px solid var(--divider);
    padding: 5px;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-radius: 50px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .08), 0 1px 4px rgba(0, 0, 0, .04);
    gap: 4px;
    max-width: 380px;
    width: auto;
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) .bottom-nav {
        background: rgba(44, 44, 46, .75);
        border-color: rgba(255, 255, 255, .08);
        box-shadow: 0 4px 24px rgba(0, 0, 0, .25);
    }
}

:root[data-theme="dark"] .bottom-nav {
    background: rgba(44, 44, 46, .75);
    border-color: rgba(255, 255, 255, .08);
    box-shadow: 0 4px 24px rgba(0, 0, 0, .25);
}

.nav-pill {
    position: absolute;
    top: 5px;
    left: 5px;
    height: calc(100% - 10px);
    width: calc(33.33% - 6px);
    background: var(--accent);
    border-radius: 46px;
    transition: transform .4s cubic-bezier(.34, 1.56, .64, 1);
    z-index: 0;
    box-shadow: 0 2px 8px rgba(0, 122, 255, .25);
    will-change: transform;
}

.nav-pill[data-pos="1"] {
    transform: translateX(calc(100% + 4px));
}

.nav-pill[data-pos="2"] {
    transform: translateX(calc(200% + 8px));
}

.nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    color: var(--muted);
    transition: color .3s ease;
    position: relative;
    z-index: 1;
    border-radius: 46px;
    white-space: nowrap;
}

.nav-btn.active {
    color: #fff;
}

.nav-icon {
    font-size: 1rem;
}

.nav-label {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .2px;
}

/* ═══ TOP BAR ═══ */
.top-bar {
    padding: 16px 16px 0;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.top-left {
    display: flex;
    flex-direction: column;
    gap: 2px
}

.top-bar h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.5px
}

.quote-text {
    font-size: .65rem;
    color: var(--muted);
    font-weight: 500;
    font-style: italic;
    line-height: 1.3
}

.sync-badge {
    font-size: .65rem;
    color: var(--muted);
    background: var(--card);
    padding: 4px 10px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    flex-shrink: 1;
    transition: background .3s, color .3s;

    /* Truncation for long usernames */
    display: inline-block;
    max-width: 110px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.sync-ok {
    color: #34c759
}

.sync-error {
    color: #ff3b30
}

/* ═══ SEARCH BAR (main page) ═══ */
.search-bar-wrap {
    max-width: 800px;
    margin: 12px auto 0;
    padding: 0 12px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 14px 18px 14px 44px;
    border: 1.5px solid var(--divider);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text);
    outline: none;
    transition: all .25s ease;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .04);
}

.search-input::placeholder {
    color: var(--muted);
    font-weight: 500;
}

.search-input:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, .65);
    box-shadow: 0 2px 12px rgba(0, 122, 255, .1);
}

.ai-advisor-trigger {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.1), rgba(122, 80, 255, 0.1));
    border: 1.5px solid rgba(0, 122, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.1);
}

.ai-advisor-trigger:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.15), rgba(122, 80, 255, 0.15));
    border-color: rgba(0, 122, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

.ai-advisor-trigger:active {
    transform: translateY(0);
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) .search-input {
        background: rgba(255, 255, 255, .06);
        border-color: rgba(255, 255, 255, .1);
    }

    :root:not([data-theme="light"]) .search-input:focus {
        background: rgba(255, 255, 255, .1);
        border-color: var(--accent);
    }
}

:root[data-theme="dark"] .search-input {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .1);
}

:root[data-theme="dark"] .search-input:focus {
    background: rgba(255, 255, 255, .1);
    border-color: var(--accent);
}

.search-results {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 12px;
    display: none;
}

.search-results.visible {
    display: block;
    animation: fadeSlide .2s ease
}

.search-result-group {
    margin-top: 10px
}

.search-group-title {
    font-size: .65rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 6px 4px 4px
}

.search-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 500
}

/* ═══ SUBJECTS GRID ═══ */
.subjects-grid {
    max-width: 800px;
    margin: 10px auto 0;
    padding: 0 12px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.subj-card {
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1), box-shadow .35s;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
    min-height: 110px;
    color: #fff;
    will-change: transform;
}

.subj-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg)
}

.subj-card:active {
    transform: scale(0.96);
}

.subj-card.active {
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(255, 255, 255, .5)
}

.subjects-grid.has-active .subj-card:not(.active) {
    display: none;
}

.subj-card.math {
    background: linear-gradient(135deg, var(--math-from), var(--math-to))
}

.subj-card.history {
    background: linear-gradient(135deg, var(--hist-from), var(--hist-to))
}

.subj-card.info {
    background: linear-gradient(135deg, var(--info-from), var(--info-to))
}

.subj-card.mathlit {
    background: linear-gradient(135deg, var(--mathlit-from), var(--mathlit-to))
}

.subj-card.whistory {
    background: linear-gradient(135deg, var(--whist-from), var(--whist-to))
}

.subj-emoji {
    font-size: 1.6rem;
    min-height: 26px;
    display: flex;
    align-items: center;
}

.subj-name {
    font-size: .95rem;
    font-weight: 700
}

.subj-progress {
    font-size: .7rem;
    font-weight: 500;
    opacity: .85
}

.subj-bar-bg {
    height: 5px;
    background: rgba(255, 255, 255, .3);
    border-radius: 5px;
    overflow: hidden;
    margin-top: auto
}

.subj-bar-fill {
    height: 100%;
    width: 100%;
    border-radius: 5px;
    background: rgba(255, 255, 255, .85);
    transform-origin: left;
    transform: scaleX(var(--pct, 0));
    will-change: transform;
    transition: transform .6s cubic-bezier(.34, 1.56, .64, 1);
}

/* ═══ WEEKS ═══ */
.weeks-section {
    max-width: 800px;
    margin: 18px auto 0;
    padding: 0 12px;
    display: none
}

.weeks-section.visible {
    display: block;
    animation: fadeSlide .35s cubic-bezier(.22, .68, 0, 1.1)
}

.weeks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 0 4px
}

.weeks-title {
    font-size: .9rem;
    font-weight: 700
}

.weeks-back {
    font-size: .72rem;
    font-weight: 600;
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    transition: all .2s;
}

.weeks-back:hover {
    background: var(--divider)
}

.weeks-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 10px;
    padding: 4px 4px 12px 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.weeks-grid::-webkit-scrollbar {
    display: none;
}

.week-tile {
    flex: 0 0 auto;
    width: 105px;
    scroll-snap-align: start;
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px 12px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1), box-shadow .35s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    will-change: transform;
}

.week-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg)
}

.week-tile:active {
    transform: scale(0.94);
}

.week-tile.done {
    opacity: .5
}

.week-tile.selected {
    outline: 2.5px solid var(--accent);
    outline-offset: -2.5px
}

.week-num {
    font-size: .62rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px
}

.week-done-txt {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text2)
}

.week-ring {
    width: 42px;
    height: 42px;
    position: relative
}

.week-ring svg {
    width: 42px;
    height: 42px;
    transform: rotate(-90deg)
}

.week-ring .ring-track {
    stroke-width: 4
}

.week-ring .ring-fill {
    stroke-width: 4
}

.week-ring-pct {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6rem;
    font-weight: 700
}

/* ═══ TOPICS ═══ */
.topics-section {
    max-width: 800px;
    margin: 14px auto 0;
    padding: 0 12px;
    display: none
}

.topics-section.visible {
    display: block;
    animation: fadeSlide .3s cubic-bezier(.22, .68, 0, 1.1)
}

.topics-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden
}

.topics-hdr {
    padding: 14px 16px;
    font-size: .78rem;
    font-weight: 700;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between
}

.section-sep {
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--muted);
    padding: 10px 16px 4px;
    border-top: 1px solid var(--divider);
    background: rgba(0, 0, 0, .015)
}

.section-sep:first-child {
    border-top: none
}

.topic {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    cursor: pointer;
    border-bottom: .5px solid var(--divider);
    transition: background .15s;
    outline: none;
}

.topic:last-child {
    border-bottom: none
}

.topic:hover {
    background: rgba(0, 0, 0, .025)
}

.topic:active {
    background: rgba(0, 0, 0, .04)
}

.chk {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    border: 2px solid rgba(0, 0, 0, .15);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: transparent;
    transition: all .25s cubic-bezier(.22, .68, 0, 1.1);
}

.topic.done .chk {
    color: #fff;
    border-color: transparent
}

.topic.done .chk {
    animation: checkPop .3s cubic-bezier(.22, .68, 0, 1.1)
}



.topic.done .chk-math {
    background: var(--math-to)
}

.topic.done .chk-history {
    background: var(--hist-to)
}

.topic.done .chk-info {
    background: var(--info-to)
}

.topic.done .chk-mathlit {
    background: var(--mathlit-to)
}

.topic.done .chk-whistory {
    background: var(--whist-to)
}

.topic-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px
}

.topic-txt {
    font-size: .8rem;
    line-height: 1.35;
    font-weight: 500;
    transition: opacity .3s, color .3s
}

.topic.done .topic-txt {
    text-decoration: line-through;
    opacity: .4;
    color: var(--muted)
}

.topic-meta {
    font-size: .62rem;
    color: var(--muted);
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center
}

.ai-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 122, 255, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    margin-left: 4px;
    vertical-align: middle;
}

.ai-btn:hover {
    background: rgba(0, 122, 255, 0.18);
    transform: scale(1.15);
}

.ai-btn:active {
    transform: scale(0.95);
}

.cls-badge {
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: .56rem
}

.cls-badge.b-math {
    background: rgba(244, 114, 160, .15);
    color: #c44a7a
}

.cls-badge.b-hist {
    background: rgba(111, 163, 232, .15);
    color: #3a72b8
}

.cls-badge.b-info {
    background: rgba(60, 201, 156, .15);
    color: #1d8a5f
}

.cls-badge.b-mathlit {
    background: rgba(216, 105, 240, .15);
    color: #922ba8
}

.cls-badge.b-whistory {
    background: rgba(244, 155, 66, .15);
    color: #b35e0a
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) .cls-badge.b-math {
        background: rgba(249, 168, 201, .12);
        color: #f9a8c9
    }

    :root:not([data-theme="light"]) .cls-badge.b-hist {
        background: rgba(143, 184, 232, .12);
        color: #8fb8e8
    }

    :root:not([data-theme="light"]) .cls-badge.b-info {
        background: rgba(110, 212, 173, .12);
        color: #6ed4ad
    }

    :root:not([data-theme="light"]) .cls-badge.b-mathlit {
        background: rgba(226, 141, 239, .12);
        color: #e28def
    }

    :root:not([data-theme="light"]) .cls-badge.b-whistory {
        background: rgba(255, 177, 107, .12);
        color: #ffb16b
    }
}

:root[data-theme="dark"] .cls-badge.b-math {
    background: rgba(249, 168, 201, .12);
    color: #f9a8c9
}

:root[data-theme="dark"] .cls-badge.b-hist {
    background: rgba(143, 184, 232, .12);
    color: #8fb8e8
}

:root[data-theme="dark"] .cls-badge.b-info {
    background: rgba(110, 212, 173, .12);
    color: #6ed4ad
}

:root[data-theme="dark"] .cls-badge.b-mathlit {
    background: rgba(226, 141, 239, .12);
    color: #e28def
}

:root[data-theme="dark"] .cls-badge.b-whistory {
    background: rgba(255, 177, 107, .12);
    color: #ffb16b
}

.meta-pg {
    font-size: .58rem
}

.meta-sep {
    font-size: .56rem;
    margin: 0 1px;
    color: var(--muted)
}

.note {
    font-size: .56rem;
    color: var(--muted);
    font-weight: 600
}

/* ═══ ACTION BUTTONS ═══ */
.actions-row {
    max-width: 800px;
    margin: 12px auto;
    padding: 0 12px;
    display: none;
    gap: 8px
}

.actions-row.visible {
    display: flex;
    animation: fadeIn .25s ease
}

.btn-act {
    flex: 1;
    padding: 10px;
    background: var(--card);
    border: none;
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: .74rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all .2s;
    color: var(--text);
}

.btn-act:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg)
}

.btn-act.danger {
    color: #ff3b30
}

/* Full reset */
.btn-reset-all {
    display: block;
    margin: 16px auto 20px;
    padding: 10px 24px;
    background: none;
    border: 1.5px solid rgba(255, 59, 48, .2);
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: .72rem;
    font-weight: 600;
    color: #ff3b30;
    cursor: pointer;
    transition: all .25s ease;
    opacity: .6;
}

.btn-reset-all:hover {
    opacity: 1;
    background: rgba(255, 59, 48, .06);
    border-color: rgba(255, 59, 48, .4);
}

/* ═══ STATS PAGE ═══ */
.stats-content {
    max-width: 800px;
    margin: 14px auto 0;
    padding: 0 12px
}

/* Big ring */
.big-ring-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.big-ring-wrap {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0
}

.big-ring-wrap svg {
    width: 100px;
    height: 100px;
    transform: rotate(-90deg)
}

.ring-track {
    fill: none;
    stroke: var(--divider);
    stroke-width: 6
}

.ring-fill {
    fill: none;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s cubic-bezier(.22, .68, 0, 1.1)
}

.big-ring-pct {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800
}

.big-ring-info {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.big-ring-title {
    font-size: 1rem;
    font-weight: 700
}

.big-ring-sub {
    font-size: .72rem;
    color: var(--muted);
    font-weight: 500;
    line-height: 1.4
}

/* Mini stats row */
.mini-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 12px
}

.mini-stat {
    background: var(--card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mini-stat-icon {
    font-size: 1.2rem
}

.mini-stat-val {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -.5px
}

.mini-stat-lbl {
    font-size: .58rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .3px
}

.mini-stat.streak {
    background: linear-gradient(135deg, var(--streak-from), var(--streak-to));
    color: #fff
}

.mini-stat.streak .mini-stat-lbl {
    color: rgba(255, 255, 255, .7)
}

/* Forecast */
.forecast-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.forecast-icon {
    font-size: 1.6rem
}

.forecast-body {
    display: flex;
    flex-direction: column;
    gap: 3px
}

.forecast-title {
    font-size: .82rem;
    font-weight: 700
}

.forecast-sub {
    font-size: .68rem;
    color: var(--muted);
    font-weight: 500
}

/* Activity Chart */
.activity-chart-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-top: 12px;
    margin-bottom: 16px;
}

.activity-chart-title {
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.activity-chart-sub {
    font-size: .62rem;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 14px;
}

.activity-chart-wrap {
    position: relative;
    height: 160px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding-bottom: 28px;
    padding-left: 32px;
}

.activity-chart-y {
    position: absolute;
    left: 0;
    bottom: 28px;
    top: 0;
    width: 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding-right: 6px;
}

.activity-chart-y span {
    font-size: .52rem;
    color: var(--muted);
    font-weight: 600;
    line-height: 1;
}

.activity-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.activity-bar {
    width: 100%;
    max-width: 28px;
    border-radius: 6px 6px 3px 3px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    transition: height .6s cubic-bezier(.22, .68, 0, 1.1), opacity .4s ease;
    position: relative;
    min-height: 3px;
    cursor: pointer;
    opacity: 0;
    animation: barGrow .5s ease forwards;
}

.activity-bar:hover {
    filter: brightness(1.15);
    transform: scaleY(1.05);
    transform-origin: bottom;
}

.activity-bar.empty {
    background: var(--divider);
    min-height: 3px;
    border-radius: 6px 6px 3px 3px;
}

.activity-bar.today {
    background: linear-gradient(180deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 0 10px rgba(245, 87, 108, 0.3);
}

@keyframes barGrow {
    0% {
        opacity: 0;
        transform: scaleY(0);
        transform-origin: bottom;
    }

    100% {
        opacity: 1;
        transform: scaleY(1);
        transform-origin: bottom;
    }
}

.activity-bar-label {
    font-size: .5rem;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
    margin-top: 4px;
    overflow: visible;
    text-align: center;
}

.activity-bar-label.today-label {
    color: var(--accent);
    font-weight: 700;
}

.activity-bar-val {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: .5rem;
    font-weight: 700;
    color: var(--text2);
    white-space: nowrap;
    opacity: 0;
    animation: fadeInVal .3s ease .5s forwards;
}

@keyframes fadeInVal {
    to {
        opacity: 1;
    }
}

.activity-chart-grid-line {
    position: absolute;
    left: 32px;
    right: 0;
    height: 1px;
    background: var(--divider);
    pointer-events: none;
}

.activity-chart-total {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 10px;
    font-size: .6rem;
    color: var(--muted);
    font-weight: 600;
}

/* ═══ SEARCH PAGE ═══ */
.search-wrap {
    max-width: 800px;
    margin: 14px auto 0;
    padding: 0 12px
}

.search-group-title {
    font-size: .65rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 8px 4px 4px
}

/* ═══ ANIMATIONS ═══ */
@keyframes popIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(.95)
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1)
    }
}

@keyframes fadeSlide {
    from {
        opacity: 0;
        transform: translateY(12px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

@keyframes checkPop {
    0% {
        transform: scale(1)
    }

    40% {
        transform: scale(1.25)
    }

    100% {
        transform: scale(1)
    }
}

@keyframes pageFade {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

.animate-in .subj-card {
    animation: popIn .4s cubic-bezier(.22, .68, 0, 1.1) backwards
}

.animate-in .subj-card:nth-child(1) {
    animation-delay: .05s
}

.animate-in .subj-card:nth-child(2) {
    animation-delay: .12s
}

.animate-in .subj-card:nth-child(3) {
    animation-delay: .19s
}

/* ═══ RESPONSIVE ═══ */
@media(max-width:400px) {
    .top-bar h1 {
        font-size: 1.3rem
    }

    .subjects-grid {
        gap: 8px;
        padding: 0 8px
    }

    .subj-card {
        padding: 14px;
        min-height: 100px
    }

    .mini-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px
    }

    .mini-stat {
        padding: 10px
    }

    .heatmap-grid {
        gap: 2px
    }
}

@media(min-width:480px) {
    .subjects-grid {
        grid-template-columns: repeat(3, 1fr)
    }
}

@media(min-width:600px) {
    .heatmap-grid {
        grid-template-columns: repeat(12, 1fr)
    }
}

@media(min-width:800px) {
    .subjects-grid.has-active .subj-card:not(.active) {
        display: flex;
    }

    .subjects-grid {
        gap: 12px
    }

    .weeks-grid {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        overflow-x: visible;
        padding-bottom: 0;
    }

    .week-tile {
        width: auto;
    }
}

@media(min-width:1000px) {

    .top-bar,
    .subjects-grid,
    .weeks-section,
    .topics-section,
    .actions-row,
    .stats-content,
    .search-wrap,
    .search-results {
        max-width: 960px
    }

    .weeks-grid {
        grid-template-columns: repeat(8, 1fr)
    }
}

@media(prefers-reduced-motion:reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important
    }
}

::-webkit-scrollbar {
    width: 4px
}

::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, .2);
    border-radius: 2px
}

/* =========================================
   AI EXPLAINER MODAL & BUTTON
   ========================================= */

.ai-btn {
    background: transparent;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, filter 0.2s;
    opacity: 0.7;
}

.ai-btn:hover {
    transform: scale(1.15);
    opacity: 1;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--card);
    border: 1px solid var(--divider);
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    max-height: 80vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--secondary);
    cursor: pointer;
    padding: 4px;
}

.modal-body {
    padding: 24px 20px;
    overflow-y: auto;
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--text);
    font-weight: 500;
}





.icon-glass {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 6px;
    padding: 2px;
    transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), background 0.2s ease, filter 0.2s ease;
    background: rgba(120, 120, 120, 0.08);
    pointer-events: none;
}

.icon-glass:hover {
    transform: scale(1.15);
    background: rgba(120, 120, 120, 0.18);
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.1));
}

/* ═══ Quiz Stats (on stats page) ═══ */
.qs-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.qs-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.qs-title {
    font-size: .92rem;
    font-weight: 800;
    color: var(--text);
}

.qs-summary {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 20px;
    padding: 14px;
    background: rgba(0, 122, 255, .04);
    border-radius: 12px;
}

.qs-summary-item {
    text-align: center;
}

.qs-summary-val {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
}

.qs-summary-lbl {
    font-size: .65rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.qs-subjects {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qs-subj-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.qs-subj-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.qs-subj-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.qs-subj-name {
    font-size: .8rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qs-subj-meta {
    font-size: .65rem;
    color: var(--muted);
    font-weight: 500;
}

.qs-subj-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    width: 140px;
}

.qs-subj-pct {
    font-size: .82rem;
    font-weight: 800;
    color: var(--text);
    min-width: 34px;
    text-align: right;
}

.qs-subj-bar-bg {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--divider);
    overflow: hidden;
}

.qs-subj-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .6s ease;
}

/* ═══════════════════ QUIZ PAGE ═══════════════════ */
.quiz-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 12px 14px 100px;
}

/* ═══════════════════ AI STUDY ADVISOR ═══════════════════ */

/* Advisor Banner on Stats Page */
.advisor-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--accent), #7a50ff);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.25);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    color: white;
}

.advisor-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 122, 255, 0.35);
}

.advisor-banner-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.advisor-banner-text {
    flex: 1;
}

.advisor-banner-title {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.advisor-banner-sub {
    font-size: .75rem;
    font-weight: 500;
    opacity: 0.9;
    line-height: 1.3;
}

/* Advisor Modal */
.adv-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.adv-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.adv-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%) scale(0.95);
    width: min(600px, 95vw);
    height: min(680px, 90vh);
    background: var(--card);
    border: 1px solid var(--divider);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--text);
}

.adv-modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.adv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
}

.adv-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.adv-header-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.25), rgba(122, 80, 255, 0.2));
    border: 1px solid rgba(0, 122, 255, 0.4);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6bb0ff;
    box-shadow: 0 0 20px rgba(0, 122, 255, 0.15);
}

.adv-header-title {
    font-size: .95rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.2px;
}

.adv-header-sub {
    font-size: .7rem;
    color: var(--muted);
    margin-top: 2px;
    font-weight: 500;
}

.adv-close-btn {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--divider);
    color: var(--muted);
    border-radius: 10px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.adv-close-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text);
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) .adv-close-btn {
        background: rgba(255, 255, 255, 0.06);
    }

    :root:not([data-theme="light"]) .adv-close-btn:hover {
        background: rgba(255, 255, 255, 0.15);
    }
}

:root[data-theme="dark"] .adv-close-btn {
    background: rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] .adv-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.adv-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--divider), transparent);
    margin: 0 22px;
}

.adv-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.adv-messages::-webkit-scrollbar {
    width: 4px;
}

.adv-messages::-webkit-scrollbar-track {
    background: transparent;
}

.adv-messages::-webkit-scrollbar-thumb {
    background: var(--divider);
    border-radius: 2px;
}

.adv-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: fadeSlideIn 0.3s ease forwards;
}

.adv-msg-row.ai {
    justify-content: flex-start;
}

.adv-msg-row.user {
    justify-content: flex-end;
}

.adv-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.2), rgba(122, 80, 255, 0.15));
    border: 1px solid rgba(0, 122, 255, 0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6bb0ff;
}

.adv-bubble {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: .88rem;
    line-height: 1.5;
    letter-spacing: 0.1px;
    word-wrap: break-word;
}

.adv-bubble strong {
    font-weight: 800;
}

.adv-bubble-ai {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--divider);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) .adv-bubble-ai {
        background: rgba(255, 255, 255, 0.05);
    }
}

:root[data-theme="dark"] .adv-bubble-ai {
    background: rgba(255, 255, 255, 0.05);
}

.adv-bubble-user {
    background: linear-gradient(135deg, var(--accent), #7a50ff);
    border: 1px solid rgba(0, 122, 255, 0.25);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.adv-bubble-user strong {
    color: #fff;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.adv-typing {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--divider);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
    height: 38px;
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) .adv-typing {
        background: rgba(255, 255, 255, 0.05);
    }
}

:root[data-theme="dark"] .adv-typing {
    background: rgba(255, 255, 255, 0.05);
}

.adv-dot {
    width: 6px;
    height: 6px;
    background: var(--muted);
    border-radius: 50%;
    animation: dotPulse 1.2s infinite ease-in-out;
}

@keyframes dotPulse {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.adv-input-area {
    padding: 10px 22px 18px;
    border-top: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.adv-context-actions {
    display: flex;
    justify-content: flex-start;
}

.adv-context-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 122, 255, 0.08);
    border: 1px solid rgba(0, 122, 255, 0.15);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.adv-context-btn:hover {
    background: rgba(0, 122, 255, 0.15);
    border-color: rgba(0, 122, 255, 0.25);
    transform: translateY(-1px);
}

.adv-context-btn:active {
    transform: translateY(0);
}

.adv-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--divider);
    border-radius: 14px;
    padding: 8px 8px 8px 14px;
    transition: border-color 0.2s, background 0.2s;
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) .adv-input-wrap {
        background: rgba(255, 255, 255, 0.06);
    }
}

:root[data-theme="dark"] .adv-input-wrap {
    background: rgba(255, 255, 255, 0.06);
}

.adv-input-wrap:focus-within {
    border-color: var(--accent);
    background: transparent;
}

.adv-textarea {
    flex: 1;
    background: transparent;
    border: none;
    resize: none;
    color: var(--text);
    font-size: .88rem;
    line-height: 1.5;
    font-family: inherit;
    max-height: 120px;
    padding: 4px 0;
    outline: none;
}

.adv-textarea::placeholder {
    color: var(--muted);
}

.adv-send-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.adv-send-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.adv-send-btn:active {
    transform: scale(0.92);
}

.adv-hint {
    font-size: .65rem;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    margin-top: 10px;
    letter-spacing: 0.2px;
}

@media (max-width: 600px) {
    .adv-modal {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }
}

.quiz-state {
    animation: fadeSlide .25s ease;
}

.quiz-prompt {
    font-size: .92rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
}

.quiz-limit-badge {
    font-size: .65rem;
    color: var(--muted);
    background: var(--card);
    padding: 4px 12px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    font-weight: 600;
}

/* Subject selection */
.quiz-subjects {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.quiz-subj-card {
    border-radius: var(--radius);
    padding: 18px;
    cursor: pointer;
    transition: all .25s cubic-bezier(.22, .68, 0, 1.1);
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: .88rem;
    position: relative;
    overflow: hidden;
}

.quiz-subj-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.quiz-subj-card.selected {
    transform: scale(1.03);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15), 0 0 0 3.5px var(--accent);
}

.quiz-subj-card.math {
    background: linear-gradient(135deg, var(--math-from), var(--math-to));
}

.quiz-subj-card.history {
    background: linear-gradient(135deg, var(--hist-from), var(--hist-to));
}

.quiz-subj-card.info {
    background: linear-gradient(135deg, var(--info-from), var(--info-to));
}

.quiz-subj-card.mathlit {
    background: linear-gradient(135deg, var(--mathlit-from), var(--mathlit-to));
}

.quiz-subj-card.whistory {
    background: linear-gradient(135deg, var(--whist-from), var(--whist-to));
}

/* Count chips */
.quiz-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.quiz-chip {
    padding: 8px 20px;
    border-radius: 20px;
    border: 2px solid var(--divider);
    background: var(--card);
    font-family: inherit;
    font-size: .78rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: all .2s ease;
}

.quiz-chip:hover {
    border-color: var(--accent);
}

.quiz-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Start button */
.quiz-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s ease;
    box-shadow: 0 4px 16px rgba(102, 126, 234, .3);
}

.quiz-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(102, 126, 234, .4);
}

.quiz-start-btn:active {
    transform: scale(0.97);
}

.quiz-btn-outline {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
    box-shadow: none;
}

.quiz-btn-outline:hover {
    background: rgba(0, 122, 255, .06);
    box-shadow: none;
}

/* Loading */
.quiz-loading-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 12px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 600;
}

.quiz-loading-sub {
    font-size: .68rem;
    opacity: .6;
}

/* Intro */
.quiz-intro-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 24px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: fadeSlide .3s ease;
}

.quiz-intro-card h2 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.quiz-intro-count {
    font-size: .85rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 16px;
}

.quiz-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 179, 0, .08);
    color: #b38600;
    font-size: .72rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 20px;
    max-width: 380px;
}

/* Progress bar */
.quiz-progress-bar {
    height: 6px;
    background: var(--divider);
    border-radius: 3px;
    margin-bottom: 20px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 3px;
    transition: width .4s cubic-bezier(.22, .68, 0, 1.1);
}

/* Question */
.quiz-q-header {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
    animation: fadeSlide .25s ease;
}

.quiz-q-num {
    font-size: .92rem;
    font-weight: 800;
    color: var(--text);
    min-width: 28px;
}

.quiz-q-text {
    font-size: .92rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.45;
}

/* Options (card style like screenshots) */
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeSlide .25s ease;
}

.quiz-option {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background: rgba(0, 122, 255, .04);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all .2s ease;
    overflow: hidden;
}

.quiz-option:hover:not(.answered) {
    background: rgba(0, 122, 255, .08);
    border-color: rgba(0, 122, 255, .15);
}

.quiz-option-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}

.quiz-option-letter {
    font-size: .85rem;
    font-weight: 700;
    color: var(--muted);
    min-width: 20px;
}

.quiz-option-text {
    font-size: .88rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
}

/* Answer states */
.quiz-option.correct {
    background: rgba(52, 199, 89, .1);
    border-color: rgba(52, 199, 89, .4);
}

.quiz-option.correct .quiz-option-letter {
    color: #22863a;
}

.quiz-option.wrong {
    background: rgba(255, 59, 48, .08);
    border-color: rgba(255, 59, 48, .3);
}

.quiz-option.wrong .quiz-option-letter {
    color: #d32f2f;
}

.quiz-option.answered {
    cursor: default;
    pointer-events: none;
}

/* Explanation revealed under each option */
.quiz-option-explain {
    padding: 0 16px 12px 48px;
    display: none;
    animation: fadeSlide .2s ease;
}

.quiz-option.correct .quiz-option-explain,
.quiz-option.wrong .quiz-option-explain {
    display: block;
}

.quiz-explain-status {
    font-size: .72rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.quiz-explain-status.right {
    color: #22863a;
}

.quiz-explain-status.wrong-label {
    color: #d32f2f;
}

.quiz-explain-text {
    font-size: .72rem;
    color: var(--muted);
    line-height: 1.4;
}

/* Quiz navigation bar */
.quiz-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--divider);
}

.quiz-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    background: var(--card);
    box-shadow: var(--shadow);
    font-family: inherit;
    font-size: .78rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: all .2s;
}

.quiz-nav-btn:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 122, 255, .25);
}

.quiz-nav-btn:disabled {
    cursor: default;
}

.quiz-nav-finish {
    background: linear-gradient(135deg, #34c759, #30d158) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(52, 199, 89, .3) !important;
}

.quiz-nav-counter {
    font-size: .78rem;
    font-weight: 700;
    color: var(--muted);
}

/* Result */
.quiz-result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 24px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: fadeSlide .3s ease;
}

.quiz-result-score {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.quiz-result-label {
    font-size: .85rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 16px;
}

.quiz-result-bar-bg {
    width: 100%;
    max-width: 300px;
    height: 10px;
    background: var(--divider);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 20px;
}

.quiz-result-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 5px;
    transition: width 1s cubic-bezier(.22, .68, 0, 1.1);
}

.quiz-result-tips {
    background: rgba(0, 122, 255, .05);
    border-radius: 12px;
    padding: 16px;
    font-size: .78rem;
    color: var(--text2);
    line-height: 1.5;
    max-width: 400px;
    margin-bottom: 20px;
    text-align: left;
}

.quiz-result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* History */
.quiz-history-section {
    margin-top: 8px;
}

.quiz-history-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all .2s ease;
}

.quiz-history-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.quiz-history-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quiz-history-title {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text);
}

.quiz-history-meta {
    font-size: .62rem;
    color: var(--muted);
    font-weight: 500;
}

.quiz-history-score {
    font-size: .85rem;
    font-weight: 800;
    color: var(--accent);
}

.quiz-no-history {
    text-align: center;
    padding: 20px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 500;
}

/* Back button (ghost) */
.quiz-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--muted);
    font-family: inherit;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    margin-bottom: 12px;
    transition: color .2s;
}

.quiz-back-btn:hover {
    color: var(--accent);
}

/* ═══ Quiz Wizard Modal ═══ */
.quiz-wizard-modal {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 16px 20px 12px;
}

.wizard-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 800;
    background: var(--divider);
    color: var(--muted);
    transition: all .3s ease;
}

.wizard-dot.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 122, 255, .3);
}

.wizard-dot.current {
    transform: scale(1.15);
}

.wizard-line {
    width: 32px;
    height: 2px;
    background: var(--divider);
    margin: 0 4px;
}

.wizard-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    animation: fadeSlide .2s ease;
}

@keyframes fadeSlide {
    from {
        opacity: 0;
        transform: translateX(12px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.wizard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0 20px 12px;
}

.wizard-title {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
}

.wizard-subtitle {
    font-size: .72rem;
    color: var(--muted);
    font-weight: 600;
    margin: 2px 0 0;
}

.wizard-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--divider);
    gap: 10px;
}

.wizard-small-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--divider);
    background: var(--card);
    font-family: inherit;
    font-size: .68rem;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    transition: all .2s;
}

.wizard-small-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.wizard-small-btn:hover {
    border-color: var(--accent);
}

.wizard-count-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    flex: 1;
}

.wizard-count-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
    text-align: center;
}

.wizard-chips {
    justify-content: center;
}

.wizard-center-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    flex: 1;
    text-align: center;
}

/* Topic list in wizard */
.quiz-topic-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px 12px;
    flex-wrap: wrap;
}

.quiz-topic-toolbar-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.quiz-topic-search {
    flex: 1;
    min-width: 140px;
    padding: 8px 14px !important;
    font-size: .75rem !important;
    border-radius: 10px !important;
}

.quiz-topic-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
    max-height: 45vh;
}

.quiz-topic-week {
    margin-bottom: 10px;
}

.quiz-topic-week-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .78rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    padding: 6px 0;
    border-bottom: 1px solid var(--divider);
    margin-bottom: 4px;
}

.quiz-topic-week-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.week-label-text {
    font-weight: 700;
}

.week-label-sub {
    font-size: .65rem;
    color: var(--muted);
    font-weight: 500;
    margin-left: 4px;
}

.quiz-topic-items {
    padding-left: 8px;
}

.quiz-topic-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    font-size: .72rem;
    color: var(--text2);
    cursor: pointer;
    border-radius: 6px;
    transition: background .15s;
}

.quiz-topic-item:hover {
    background: rgba(0, 122, 255, .04);
}

.quiz-topic-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.quiz-topic-count {
    font-size: .72rem;
    color: var(--muted);
    font-weight: 600;
}

/* ══════════════════ SETTINGS UI ══════════════════ */
.settings-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 6px;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) .settings-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

:root[data-theme="dark"] .settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--divider);
}

.setting-row:last-child {
    border-bottom: none;
}

/* The switch - the box around the slider */
.switch {
    font-size: 14px;
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--divider);
    transition: .3s;
}

.switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch input:checked+.slider {
    background-color: var(--accent);
}

.switch input:focus+.slider {
    box-shadow: 0 0 1px var(--accent);
}

.switch input:checked+.slider:before {
    transform: translateX(20px);
}

/* Rounded sliders */
.switch .slider.round {
    border-radius: 24px;
}

.switch .slider.round:before {
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ═══════════════════════════════════════════════════ */
/* ══ TEAM MODAL TABS ══════════════════════════════ */
/* ═══════════════════════════════════════════════════ */

.team-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
    white-space: nowrap;
}

.team-tab:hover {
    color: var(--text);
}

.team-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.groups-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ff3b30;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 1;
}

/* ═══════════════════════════════════════════════════ */
/* ══ GROUP FILTER PILLS ═══════════════════════════ */
/* ═══════════════════════════════════════════════════ */

.groups-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--divider);
    background: var(--bg);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.2s;
}

.groups-filter-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.groups-filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ═══════════════════════════════════════════════════ */
/* ══ GROUP CARD ════════════════════════════════════ */
/* ═══════════════════════════════════════════════════ */

.group-card {
    background: var(--card);
    border: 1px solid var(--divider);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow 0.2s;
}

.group-card:hover {
    box-shadow: var(--shadow);
}

.group-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.group-card-info {
    flex: 1;
    min-width: 0;
}

.group-card-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-card-id {
    font-size: 0.7rem;
    color: var(--muted);
    font-family: monospace;
    margin-top: 3px;
}

.group-card-meta {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 4px;
}

.group-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.group-status-badge.pending {
    background: rgba(255, 204, 0, 0.15);
    color: #b38600;
    border: 1px solid rgba(255, 204, 0, 0.3);
}

.group-status-badge.approved {
    background: rgba(52, 199, 89, 0.12);
    color: #1a8f3c;
    border: 1px solid rgba(52, 199, 89, 0.25);
}

.group-status-badge.rejected {
    background: rgba(255, 59, 48, 0.1);
    color: #cc2a22;
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.group-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.group-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--divider);
    background: var(--bg);
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.2s;
}

.group-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.07);
}

.group-action-btn.approve {
    background: rgba(52, 199, 89, 0.1);
    border-color: rgba(52, 199, 89, 0.3);
    color: #1a8f3c;
}

.group-action-btn.approve:hover {
    background: rgba(52, 199, 89, 0.2);
}

.group-action-btn.reject {
    background: rgba(255, 59, 48, 0.08);
    border-color: rgba(255, 59, 48, 0.2);
    color: #cc2a22;
}

.group-action-btn.reject:hover {
    background: rgba(255, 59, 48, 0.15);
}

.group-action-btn.bind {
    background: rgba(0, 122, 255, 0.08);
    border-color: rgba(0, 122, 255, 0.2);
    color: var(--accent);
}

.group-action-btn.bind:hover {
    background: rgba(0, 122, 255, 0.15);
}

.group-subject-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(0, 122, 255, 0.08);
    color: var(--accent);
    border: 1px solid rgba(0, 122, 255, 0.15);
}

.group-empty {
    text-align: center;
    padding: 32px 20px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}