:root {
    --bg: #f5f7fa;
    --bg2: #ffffff;
    --card: #ffffff;
    --border: #e2e8f0;
    --bh: #cbd5e1;
    --t1: #1a202c;
    --t2: #4a5568;
    --t3: #a0aec0;
    --a1: #2b6cb0;
    --a2: #2f855a;
    --a3: #d4a017;
    --a4: #c53030;
    --a5: #3182ce;
    --ok: #2f855a;
    --fail: #c53030;
    --grad: linear-gradient(135deg, #2b6cb0, #2f855a);
    --r: 10px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

html {
    scroll-behavior: smooth
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--t1);
    line-height: 1.7;
    min-height: 100vh;
    font-size: 16px
}

::-webkit-scrollbar {
    width: 8px
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px
}

/* HEADER */
.header {
    background: #1a365d;
    border-bottom: none;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    /* justify-content: space-between; This line is removed as per the instruction's context */
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12)
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    cursor: pointer
}

.logo-icon {
    font-size: 1.4rem
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff
}

.logo-img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: contain
}

.logo-sub {
    font-size: .72rem;
    color: rgba(255, 255, 255, .6);
    display: block;
    margin-top: -2px
}

.nav {
    display: flex;
    gap: 4px;
    align-items: center
}

.nav-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, .75);
    font-family: var(--font);
    font-size: .88rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s, color .2s
}

.nav-btn:hover {
    background: rgba(255, 255, 255, .12);
    color: #fff
}

.nav-btn.active {
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-weight: 600
}

.hamburger {
    display: none;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, .8);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 6px
}

.logo-name {
    color: #fff
}

.btn-sm {
    padding: 6px 14px;
    font-size: .82rem
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .4);
    color: #fff
}

.btn-outline:hover {
    background: rgba(255, 255, 255, .1)
}

/* MAIN */
.main {
    max-width: 960px;
    margin: 0 auto;
    padding: 28px 20px 60px
}

.view {
    display: none
}

.view.active {
    display: block
}

/* CARDS */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 28px;
    box-shadow: var(--shadow)
}

.card+.card {
    margin-top: 16px
}

/* HERO */
.hero {
    text-align: center;
    padding: 48px 20px 40px
}

.badge {
    display: inline-block;
    background: #ebf4ff;
    color: var(--a1);
    font-size: .82rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 20px
}

.hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.2;
    color: #1a365d;
    margin-bottom: 14px
}

.grad {
    color: var(--a1)
}

.hero p {
    font-size: 1.05rem;
    color: var(--t2);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.7
}

.hero-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 28px;
    flex-wrap: wrap
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font);
    font-size: .92rem;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none
}

.btn-primary {
    background: var(--a1);
    color: #fff;
    border-color: var(--a1)
}

.btn-primary:hover {
    background: #2c5282;
    border-color: #2c5282
}

.btn-secondary {
    background: var(--bg2);
    color: var(--t1);
    border: 1px solid var(--border)
}

.btn-secondary:hover {
    background: #edf2f7;
    border-color: var(--bh)
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem
}

.btn-block {
    width: 100%;
    justify-content: center
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed
}

.btn-login {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .35);
    color: #fff;
    font-family: var(--font);
    font-size: .85rem;
    font-weight: 600;
    padding: 7px 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s
}

.btn-login:hover {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .5)
}

/* HOME STATS */
.home-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 0 0 32px
}

.h-stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow)
}

.h-stat .ico {
    font-size: 1.3rem
}

.h-stat b {
    font-size: 1.5rem;
    font-weight: 700;
    display: block;
    color: #1a365d
}

.h-stat small {
    color: var(--t3);
    font-size: .78rem
}

/* BLOCKS */
.blocks-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: #1a365d
}

.blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px
}

.block-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 22px;
    cursor: pointer;
    transition: all .2s;
    box-shadow: var(--shadow)
}

.block-card:hover {
    border-color: var(--a1);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px)
}

.b-icon {
    font-size: 1.6rem;
    margin-bottom: 10px
}

.b-name {
    font-weight: 700;
    font-size: 1rem;
    color: #1a365d;
    margin-bottom: 4px
}

.b-count {
    font-size: .82rem;
    color: var(--t3);
    margin-bottom: 8px
}

.b-topics {
    font-size: .78rem;
    color: var(--t2);
    line-height: 1.5;
    margin-bottom: 12px
}

.b-bar {
    height: 4px;
    background: #edf2f7;
    border-radius: 2px;
    overflow: hidden
}

.b-bar-fill {
    height: 100%;
    background: var(--a1);
    border-radius: 2px;
    transition: width .4s
}

/* TEST CONFIG */
.config-section {
    margin-bottom: 24px
}

.config-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #1a365d
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px
}

.chip {
    background: #edf2f7;
    border: 1px solid var(--border);
    color: var(--t2);
    font-family: var(--font);
    font-size: .82rem;
    font-weight: 500;
    padding: 7px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s
}

.chip:hover {
    background: #e2e8f0;
    border-color: var(--bh)
}

.chip.active {
    background: var(--a1);
    color: #fff;
    border-color: var(--a1)
}

/* TOGGLES */
.toggle-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    font-size: .92rem
}

.toggle-text {
    flex: 1;
    line-height: 1.4
}

.switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0
}

.slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 24px;
    cursor: pointer;
    transition: .3s
}

.slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15)
}

input:checked+.slider {
    background: var(--a1)
}

input:checked+.slider::before {
    transform: translateX(20px)
}

.avail-info {
    margin-top: 16px;
    padding: 14px 18px;
    background: #ebf4ff;
    border-radius: 8px;
    font-size: .92rem;
    color: var(--a1)
}

.avail-info b {
    font-weight: 700
}

/* QUIZ */
.q-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: .88rem;
    color: var(--t2)
}

.prog-bar {
    height: 4px;
    background: #edf2f7;
    border-radius: 2px;
    margin-bottom: 24px;
    overflow: hidden
}

.prog-fill {
    height: 100%;
    background: var(--a1);
    border-radius: 2px;
    transition: width .3s
}

.q-counter {
    display: flex;
    gap: 10px;
    font-size: .88rem;
    font-weight: 600
}

.c-ok {
    color: var(--ok)
}

.c-fail {
    color: var(--fail)
}

.q-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 28px;
    box-shadow: var(--shadow)
}

.q-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap
}

.m-block,
.m-topic {
    font-size: .75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px
}

.m-block {
    background: #ebf4ff;
    color: var(--a1)
}

.m-topic {
    background: #f0fff4;
    color: var(--a2)
}

.q-text {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.6;
    color: #1a365d
}

.answers-list {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.ans {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 14px 18px;
    font-family: var(--font);
    font-size: .92rem;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
    color: var(--t1)
}

.ans:hover {
    border-color: var(--a1);
    background: #ebf4ff
}

.ans .letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: .82rem;
    background: #e2e8f0;
    color: var(--t2);
    flex-shrink: 0
}

.ans.selected {
    border-color: var(--a1);
    background: #ebf4ff
}

.ans.selected .letter {
    background: var(--a1);
    color: #fff
}

.ans.locked {
    cursor: default;
    pointer-events: none
}

.ans.is-ok {
    border-color: var(--ok);
    background: #f0fff4
}

.ans.is-ok .letter {
    background: var(--ok);
    color: #fff
}

.ans.is-fail {
    border-color: var(--fail);
    background: #fff5f5
}

.ans.is-fail .letter {
    background: var(--fail);
    color: #fff
}

.q-feedback {
    margin-top: 16px;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600
}

.fb-ok {
    background: #f0fff4;
    color: var(--ok);
    border: 1px solid #c6f6d5
}

.fb-fail {
    background: #fff5f5;
    color: var(--fail);
    border: 1px solid #fed7d7
}

.fb-wait {
    background: #ebf4ff;
    color: var(--a1);
    border: 1px solid #bee3f8
}

/* QUIZ NAV */
.q-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    gap: 12px
}

/* MAP */
.q-map {
    margin-top: 16px
}

.q-map summary {
    font-size: .88rem;
    color: var(--t2);
    cursor: pointer;
    margin-bottom: 10px
}

.map-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px
}

.m {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 600;
    border-radius: 4px;
    background: #edf2f7;
    color: var(--t3);
    cursor: pointer;
    transition: .2s
}

.m.cur {
    background: var(--a1);
    color: #fff
}

.m.ok {
    background: #c6f6d5;
    color: var(--ok)
}

.m.fail {
    background: #fed7d7;
    color: var(--fail)
}

.m.answered {
    background: #bee3f8;
    color: var(--a5)
}

/* RESULTS */
.results-card {
    text-align: center;
    padding: 40px 28px
}

.score-ring {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: conic-gradient(var(--a1) var(--pct, 0%), #edf2f7 0%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    position: relative
}

.score-ring::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--card)
}

.score-val {
    position: relative;
    z-index: 1;
    font-size: 2rem;
    font-weight: 800;
    color: #1a365d
}

.res-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a365d;
    margin-bottom: 6px
}

.res-sub {
    color: var(--t2);
    font-size: 1rem;
    margin-bottom: 24px
}

.res-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 28px
}

.rs {
    padding: 16px;
    border-radius: 8px;
    background: #f7fafc;
    border: 1px solid var(--border)
}

.rs b {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 4px
}

.rs small {
    color: var(--t3);
    font-size: .78rem
}

.s-ok b {
    color: var(--ok)
}

.s-fail b {
    color: var(--fail)
}

.s-note b {
    color: var(--a1)
}

.res-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px
}

.breakdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0
}

.bd-name {
    font-size: .85rem;
    min-width: 140px;
    color: var(--t2)
}

.bd-bar {
    flex: 1;
    height: 6px;
    background: #edf2f7;
    border-radius: 3px;
    overflow: hidden
}

.bd-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .4s
}

.bd-val {
    font-size: .85rem;
    font-weight: 700;
    min-width: 44px;
    text-align: right
}

/* REVIEW */
.review-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap
}

.r-q {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 20px;
    margin-bottom: 12px;
    box-shadow: var(--shadow)
}

.rq-ok {
    border-left: 4px solid var(--ok)
}

.rq-fail {
    border-left: 4px solid var(--fail)
}

.rq-skip {
    border-left: 4px solid var(--t3)
}

.r-num {
    font-size: .78rem;
    color: var(--t3);
    margin-bottom: 6px
}

.r-text {
    font-weight: 600;
    margin-bottom: 12px;
    color: #1a365d;
    font-size: .95rem
}

.review-answers {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.r-ans {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: .88rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0
}

.ra-ok {
    background: #f0fff4;
    border-color: #c6f6d5;
    font-weight: 600;
    color: var(--ok)
}

.ra-fail {
    background: #fff5f5;
    border-color: #fed7d7;
    color: var(--fail)
}

/* STATS */
.stats-card {
    margin-bottom: 20px
}

.stats-card h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: #1a365d
}

.h-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0
}

.h-score {
    font-size: 1.2rem;
    font-weight: 800;
    min-width: 50px
}

.h-info {
    flex: 1;
    font-size: .88rem;
    color: var(--t2)
}

.h-info small {
    color: var(--t3);
    font-size: .78rem
}

.h-detail {
    font-size: .82rem;
    color: var(--t3);
    white-space: nowrap
}

.topic-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0
}

.ts-name {
    font-size: .85rem;
    min-width: 160px;
    color: var(--t2)
}

.ts-bar {
    flex: 1;
    height: 6px;
    background: #edf2f7;
    border-radius: 3px;
    overflow: hidden
}

.ts-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .4s
}

.ts-val {
    font-size: .85rem;
    font-weight: 700;
    min-width: 44px;
    text-align: right
}

/* TOAST */
.toast-wrap {
    position: fixed;
    top: 72px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px
}

.toast {
    background: #1a365d;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 500;
    animation: toastIn .3s ease-out;
    box-shadow: var(--shadow-md)
}

.t-ok {
    background: #276749;
    border-left: 3px solid #68d391
}

.t-fail {
    background: #9b2c2c;
    border-left: 3px solid #fc8181
}

.t-info {
    background: #2a4365;
    border-left: 3px solid #63b3ed
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

/* RESPONSIVE */
@media(max-width:768px) {
    .nav {
        display: none;
        position: fixed;
        top: 60px;
        right: 0;
        background: #1a365d;
        flex-direction: column;
        width: 220px;
        padding: 16px;
        gap: 4px;
        border-radius: 0 0 0 12px;
        border: 1px solid rgba(255, 255, 255, .1);
        z-index: 200;
        box-shadow: var(--shadow-md)
    }

    .nav.open {
        display: flex
    }

    .hamburger {
        display: block
    }

    .home-stats {
        grid-template-columns: 1fr 1fr
    }

    .blocks-grid {
        grid-template-columns: 1fr
    }

    .q-nav {
        flex-wrap: wrap
    }

    .q-nav .btn {
        flex: 1;
        justify-content: center;
        min-width: 90px
    }

    .res-stats {
        grid-template-columns: 1fr 1fr
    }

    .hero h1 {
        font-size: 1.6rem
    }
}

/* AUTH */
.auth-card {
    max-width: 440px;
    margin: 40px auto;
    text-align: center
}

.auth-card h2 {
    font-size: 1.5rem;
    color: #1a365d;
    margin-bottom: 6px
}

.subtitle {
    color: var(--t3);
    font-size: .9rem;
    margin-bottom: 24px
}

.field {
    text-align: left;
    margin-bottom: 16px
}

.field label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--t2)
}

.input {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font);
    font-size: .92rem;
    background: #f7fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--t1);
    transition: border .2s
}

.input:focus {
    outline: none;
    border-color: var(--a1);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, .12)
}

.auth-error {
    display: none;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    background: #fff5f5;
    color: var(--fail);
    font-size: .88rem;
    border: 1px solid #fed7d7;
    text-align: left
}

.auth-error.visible {
    display: block
}

.auth-msg {
    display: none;
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 8px;
    background: #f0fff4;
    color: var(--ok);
    font-size: .9rem;
    line-height: 1.5;
    text-align: center;
    border: 1px solid #c6f6d5
}

.auth-switch {
    margin-top: 20px;
    font-size: .88rem;
    color: var(--t3)
}

.auth-switch a {
    color: var(--a1);
    text-decoration: none;
    font-weight: 600
}

.auth-switch a:hover {
    text-decoration: underline
}

/* Header user */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px
}

.user-badge {
    font-size: .82rem;
    color: #fff;
    font-weight: 600;
    padding: 5px 12px;
    background: rgba(255, 255, 255, .15);
    border-radius: 6px
}

/* Google Ads - Non-intrusive */
.ad-container {
    max-width: 720px;
    margin: 20px auto;
    padding: 8px;
    text-align: center;
    background: var(--bg);
    border-radius: 10px;
    min-height: 90px;
    overflow: hidden
}