/* ===========================================================
   EGEplay — Design System
   Direction: "Focused Dark Arcade"
   - Base: zinc near-black (NOT slate-blue)
   - ONE locked accent: lime (#c6f135) for action + progress
   - Semantic-only secondaries: gold = rewards, red = error
   - Shape rule: soft/pill system (cards 20-24px, buttons + inputs pill)
   - Type: Space Grotesk (display/numbers) + Outfit (body)
   =========================================================== */

:root {
    /* Base — zinc near-black */
    --bg: #0a0a0c;
    --surface: #131316;
    --surface-2: #1a1a1f;
    --surface-3: #222229;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);

    /* Text */
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-dim: #6b6b76;

    /* Accent — lime (LOCKED for the whole page) */
    --accent: #c6f135;
    --accent-bright: #d8ff52;
    --accent-soft: rgba(198, 241, 53, 0.12);
    --accent-line: rgba(198, 241, 53, 0.35);
    --on-accent: #0a0a0c;

    /* Semantic statuses (intentional, not decorative) */
    --gold: #fbbf24;       /* rewards: score star, streak */
    --error: #f87171;      /* wrong answer */
    --success: var(--accent);

    /* Radii — soft system */
    --r-sm: 12px;
    --r-md: 18px;
    --r-lg: 24px;
    --r-pill: 999px;

    /* Layout */
    --max: 1180px;
    --gutter: clamp(1.25rem, 5vw, 4rem);

    /* Motion */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Outfit', system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

h1, h2, h3, h4, .num {
    font-family: 'Space Grotesk', system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

/* ---------- Background: subtle dot-grid + restrained accent glow ---------- */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
}

.bg-glow {
    position: fixed;
    top: -260px;
    left: 50%;
    transform: translateX(-50%);
    width: 720px;
    height: 520px;
    z-index: -1;
    background: radial-gradient(circle, var(--accent) 0%, transparent 65%);
    opacity: 0.10;
    filter: blur(40px);
    pointer-events: none;
}

/* ---------- Layout helpers ---------- */
.container {
    width: 100%;
    max-width: var(--max);
    margin: 0 auto;
    padding-inline: var(--gutter);
}

.page {
    display: none;
    padding-block: 3rem 5rem;
    animation: fadeUp 0.5s var(--ease);
}
.page.active { display: block; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===========================================================
   NAVIGATION
   =========================================================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 68px;
    background: rgba(10, 10, 12, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    height: 100%;
    max-width: var(--max);
    margin: 0 auto;
    padding-inline: var(--gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    cursor: pointer;
    color: var(--text);
}
.logo span { color: var(--accent); }

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.4rem;
}
.nav-links li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border-radius: var(--r-pill);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}
.nav-links li:hover,
.nav-links li:focus-visible {
    color: var(--text);
    background: var(--surface-2);
    outline: none;
}
.nav-links i { font-size: 0.9rem; }

.nav-controls { display: flex; align-items: center; gap: 1rem; }

.user-stats {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    cursor: pointer;
    padding: 0.3rem 0.3rem 0.3rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    transition: border-color 0.2s;
}
.user-stats:hover { border-color: var(--border-strong); }

.streak {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--gold);
}
.streak i { filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.4)); }

.avatar-box {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
}
.avatar-box img { width: 100%; height: 100%; object-fit: cover; }

/* ===========================================================
   BUTTONS — pill system, tactile :active
   =========================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    padding: 0.95rem 1.6rem;
    border-radius: var(--r-pill);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.12s var(--ease), background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
}
.btn-primary:hover {
    background: var(--accent-bright);
    box-shadow: 0 8px 24px -8px var(--accent-line);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-muted); }

.btn-login {
    background: transparent;
    color: var(--text);
    border-color: var(--border-strong);
    padding: 0.6rem 1.3rem;
    font-size: 0.95rem;
}
.btn-login:hover { border-color: var(--accent); color: var(--accent); }

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: color 0.2s;
}
.btn-back:hover { color: var(--text); }

/* ===========================================================
   HERO
   =========================================================== */
.hero {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    align-items: center;
    gap: clamp(2rem, 5vw, 4.5rem);
    padding-top: clamp(1.5rem, 4vw, 3.5rem);
    min-height: min(78vh, 640px);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    margin-bottom: 1.5rem;
}
.eyebrow .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 4.25rem);
    margin-bottom: 1.3rem;
}
.hero h1 span { color: var(--accent); }

.lead {
    font-size: clamp(1.05rem, 2vw, 1.2rem);
    color: var(--text-muted);
    max-width: 46ch;
    margin-bottom: 2.2rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.92rem;
    color: var(--text-dim);
}
.hero-meta i { color: var(--accent); }

/* Progress card (real UI component, not a fake screenshot) */
.progress-card {
    background: linear-gradient(160deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.8rem;
    box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
    position: relative;
    overflow: hidden;
}
.progress-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
}

.pc-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.6rem;
}
.level-circle {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--on-accent);
    background: var(--accent);
    box-shadow: 0 0 0 6px var(--accent-soft);
}
.pc-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
}
.pc-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.pc-bar-wrap { margin-bottom: 1.6rem; }
.pc-xp {
    margin-top: 0.6rem;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.pc-foot {
    display: flex;
    gap: 1.5rem;
    padding-top: 1.3rem;
    border-top: 1px solid var(--border);
}
.pc-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.pc-stat i { color: var(--accent); }

/* XP bar */
.xp-bar {
    width: 100%;
    height: 10px;
    background: var(--surface-3);
    border-radius: var(--r-pill);
    overflow: hidden;
}
.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-bright));
    border-radius: var(--r-pill);
    transition: width 0.9s var(--ease);
}

/* ===========================================================
   SECTION TITLES
   =========================================================== */
.section-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    margin-bottom: 0.7rem;
}
.section-sub {
    color: var(--text-muted);
    max-width: 56ch;
    font-size: 1.05rem;
}
.page-head { margin-bottom: 2.8rem; }

/* ===========================================================
   HOME — "How it works" steps (asymmetric, not equal cards)
   =========================================================== */
.steps { margin-top: clamp(4rem, 9vw, 7rem); }
.steps .section-title { margin-bottom: 2.5rem; }

.steps-flow {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    counter-reset: step;
}
.step {
    position: relative;
    padding: 1.8rem 0;
    border-top: 2px solid var(--border-strong);
}
.step:first-child { border-top-color: var(--accent); }
.step-num {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--surface-3);
    -webkit-text-stroke: 1px var(--text-dim);
    margin-bottom: 0.9rem;
    line-height: 1;
}
.step h3 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.step p { color: var(--text-muted); font-size: 0.98rem; }

/* CTA band */
.cta-band {
    margin-top: clamp(4rem, 9vw, 7rem);
    text-align: center;
    padding: clamp(2.5rem, 6vw, 4.5rem) var(--gutter);
    background:
        radial-gradient(circle at 50% 0%, var(--accent-soft), transparent 60%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}
.cta-band h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); margin-bottom: 0.9rem; }
.cta-band p { color: var(--text-muted); max-width: 48ch; margin: 0 auto 2rem; }

/* ===========================================================
   SUBJECTS
   =========================================================== */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}
.subject-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 2rem;
    cursor: pointer;
    transition: transform 0.25s var(--ease), border-color 0.25s, background 0.25s;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-height: 230px;
}
.subject-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent-line);
    background: var(--surface-2);
}
.subject-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.sc-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sc-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--r-md);
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    color: var(--accent);
    background: var(--accent-soft);
}
.sc-tag {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.3rem 0.7rem;
    border-radius: var(--r-pill);
    background: var(--accent-soft);
    color: var(--accent);
}
.subject-card.is-soon .sc-icon { color: var(--text-dim); background: var(--surface-3); }
.subject-card.is-soon .sc-tag { color: var(--text-dim); background: var(--surface-3); }

.subject-card h3 { font-size: 1.5rem; }
.subject-card p { color: var(--text-muted); flex-grow: 1; }
.sc-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.92rem;
}
.sc-foot i { color: var(--accent); transition: transform 0.2s; }
.subject-card:hover .sc-foot i { transform: translateX(4px); }

/* ===========================================================
   QUEST LIST
   =========================================================== */
.quest-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.quest-card {
    display: flex;
    align-items: center;
    gap: 1.3rem;
    padding: 1.2rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    transition: border-color 0.2s, background 0.2s;
}
.quest-card:hover { border-color: var(--accent-line); background: var(--surface-2); }

.quest-num {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
}
.quest-body { flex-grow: 1; }
.quest-body h4 { font-size: 1.1rem; margin-bottom: 0.15rem; font-weight: 600; }
.quest-body p { color: var(--text-muted); font-size: 0.92rem; }
.quest-card .btn { padding: 0.7rem 1.3rem; font-size: 0.92rem; }

/* ===========================================================
   SOLVER
   =========================================================== */
.solver-header {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 2.5rem;
}
.solver-header .btn-back { margin-bottom: 0; }

.score-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--r-pill);
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--gold);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    min-width: 84px;
    justify-content: center;
}
.score-box i { color: var(--gold); filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.5)); }

.quest-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--surface-3);
    border-radius: var(--r-pill);
    overflow: hidden;
}
#quest-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--r-pill);
    transition: width 0.5s var(--ease);
}

.solver-layout {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

/* Заголовок блока заданий */
.ql-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0 0.5rem;
}
.ql-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}
.ql-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--surface-3);
    padding: 0.25rem 0.75rem;
    border-radius: var(--r-pill);
}

/* Строка с номером вопроса */
.q-num-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.q-num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.88rem;
    flex-shrink: 0;
}

.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: clamp(1.4rem, 3vw, 2rem);
}
.q-meta {
    display: inline-block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}
.q-text {
    font-size: clamp(1.05rem, 2.5vw, 1.25rem);
    line-height: 1.5;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

/* Инлайн-фидбек */
.q-feedback {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.fb-correct {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.fb-wrong {
    color: var(--error);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.fb-exp {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.55;
}

/* Цветная рамка после ответа */
.answer-zone input.input-correct {
    border-color: var(--accent);
    background: rgba(198, 241, 53, 0.06);
}
.answer-zone input.input-wrong {
    border-color: var(--error);
    background: rgba(248, 113, 113, 0.06);
}
.answer-zone button:disabled,
.answer-zone input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.answer-zone { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.answer-zone input {
    flex: 1;
    min-width: 200px;
    padding: 0.95rem 1.3rem;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.answer-zone input::placeholder { color: var(--text-dim); }
.answer-zone input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ===========================================================
   THEORY TABS
   =========================================================== */
.theory-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.theory-tab {
    padding: 0.55rem 1.2rem;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text-muted);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.theory-tab:hover { color: var(--text); border-color: var(--text-muted); }
.theory-tab.active {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
}

/* ===========================================================
   THEORY — MODULE ACCORDION
   =========================================================== */
.theory-modules {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

/* Module card */
.t-module {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    transition: border-color 0.2s;
}
.t-module.open { border-color: var(--accent-line); }

/* Module header (clickable) */
.t-module-head {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    padding: 1.4rem 1.6rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.t-module-head:hover { background: var(--surface-2); }

.t-module-icon {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    color: var(--accent);
    background: var(--accent-soft);
}

.t-module-meta { flex: 1; min-width: 0; }
.t-module-meta h3 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.t-module-range {
    font-size: 0.83rem;
    color: var(--text-dim);
    margin-top: 0.15rem;
    display: block;
}

/* Progress bar inside header */
.t-module-prog {
    flex-shrink: 0;
    width: 140px;
}
.t-prog-bar {
    height: 6px;
    background: var(--surface-3);
    border-radius: var(--r-pill);
    overflow: hidden;
}
.t-prog-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--r-pill);
    transition: width 0.7s var(--ease);
}

/* Chevron rotates when open */
.t-chevron {
    color: var(--text-dim);
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: transform 0.3s var(--ease);
}
.t-module.open .t-chevron { transform: rotate(180deg); }

/* Collapsible body */
.t-module-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s var(--ease);
}
.t-module.open .t-module-body { grid-template-rows: 1fr; }

.t-module-body > .t-cards-grid {
    overflow: hidden;
    padding: 0 1.6rem 0;
    transition: padding 0.35s var(--ease);
}
.t-module.open .t-module-body > .t-cards-grid {
    padding: 0 1.6rem 1.6rem;
    border-top: 1px solid var(--border);
}

/* Inner grid of theory mini-cards */
.t-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 1rem;
    padding-top: 1.4rem;
}

.t-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1.2rem 1.3rem;
    transition: border-color 0.2s;
}
.t-card:hover { border-color: var(--accent-line); }

.t-card-tag {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.55rem;
    letter-spacing: 0.02em;
}
.t-card h4 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}
.t-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.55;
}
.t-formula {
    display: block;
    margin-top: 0.85rem;
    padding: 0.65rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-family: 'Space Grotesk', sans-serif;
    color: var(--accent);
    font-size: 0.88rem;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.7;
}
.t-diagram {
    margin: 0.75rem 0 0.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem;
}
.t-diagram svg {
    width: 100%;
    max-width: 200px;
    height: auto;
}
.t-table-wrap {
    margin-top: 0.75rem;
    overflow-x: auto;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}
.t-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    font-family: 'Space Grotesk', sans-serif;
}
.t-table th {
    background: var(--surface-3);
    color: var(--accent);
    padding: 0.4rem 0.6rem;
    text-align: center;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.t-table td {
    padding: 0.35rem 0.6rem;
    text-align: center;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.t-table tr:last-child td { border-bottom: none; }
.t-table td:first-child { color: var(--text); font-weight: 500; }

/* ===========================================================
   PROFILE
   =========================================================== */
.profile-head {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}
.profile-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--accent);
    background: var(--surface-3);
    flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.profile-role { color: var(--text-muted); }
.profile-role span { color: var(--accent); font-weight: 600; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.2rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1.5rem;
}
.stat-card .stat-icon {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 0.8rem;
}
.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1;
}
.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.4rem;
}

/* ===========================================================
   MODALS
   =========================================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(5, 5, 7, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 1.5rem;
}
.modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeUp 0.3s var(--ease);
}
.modal-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    padding: 2.2rem;
    text-align: center;
}
.modal-card h2 { font-size: 1.7rem; margin-bottom: 0.4rem; }

/* Кнопка закрытия модалки */
.modal-close {
    position: absolute;
    top: 1.1rem;
    right: 1.1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: var(--r-sm);
    transition: color 0.2s, background 0.2s;
}
.modal-close:hover { color: var(--text); background: var(--surface-3); }

/* ─── AUTH MODAL ─────────────────────────────────────────── */
.auth-card { text-align: left; }
.auth-card h2 { font-size: 1.5rem; }

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.4rem;
}

.auth-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--surface-2);
    border-radius: var(--r-pill);
    padding: 4px;
    margin-bottom: 1.4rem;
}
.auth-tab {
    flex: 1;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--r-pill);
    background: none;
    color: var(--text-muted);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.auth-tab.active { background: var(--surface-3); color: var(--text); }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    color: var(--text-dim);
    font-size: 0.82rem;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-form { display: flex; flex-direction: column; gap: 0.7rem; }

.auth-input {
    width: 100%;
    padding: 0.85rem 1.1rem;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-input::placeholder { color: var(--text-dim); }
.auth-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-error {
    font-size: 0.84rem;
    color: var(--error);
    min-height: 1.1em;
    line-height: 1.4;
}
.auth-error.auth-success { color: var(--accent); }

.auth-link {
    display: block;
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: 'Outfit', sans-serif;
    font-size: 0.84rem;
    cursor: pointer;
    text-align: center;
    padding: 0.3rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
    margin-top: 0.2rem;
}
.auth-link:hover { color: var(--text-muted); }

/* ─── PROFILE ADDITIONS ──────────────────────────────────── */
.profile-info { display: flex; flex-direction: column; gap: 0.1rem; }
.profile-email-text {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0.1rem 0 0.15rem;
}
.profile-actions { margin-top: 2.5rem; }
.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--error);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.btn-logout:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--error);
}

.google-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    padding: 0.95rem 1.5rem;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-strong);
    background: var(--text);
    color: #18181b;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.12s var(--ease), background 0.2s;
    margin-bottom: 0.8rem;
}
.google-btn:hover { background: #fff; }
.google-btn:active { transform: translateY(1px); }

.btn-outline {
    width: 100%;
    padding: 0.8rem 1.5rem;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.btn-outline:hover { color: var(--text); border-color: var(--text-muted); }

/* Result modal */
.explanation-box {
    text-align: left;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1.3rem;
    margin-bottom: 1.4rem;
    font-size: 0.98rem;
}
.explanation-box p { margin-bottom: 0.5rem; }
.explanation-box hr { border: none; border-top: 1px solid var(--border); margin: 0.8rem 0; }

.xp-reward {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1.4rem;
}

/* Completion modal */
.complete-icon {
    width: 76px;
    height: 76px;
    margin: 0 auto 1.3rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 2rem;
    color: var(--gold);
    background: rgba(251, 191, 36, 0.12);
    box-shadow: 0 0 0 8px rgba(251, 191, 36, 0.06);
}
#complete-summary { color: var(--text-muted); margin-bottom: 1.8rem; }
.complete-actions { display: flex; gap: 0.8rem; }
.complete-actions .btn { flex: 1; }

/* ===========================================================
   TOAST
   =========================================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.9rem 1.4rem;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-pill);
    color: var(--text);
    font-size: 0.95rem;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
    transition: transform 0.4s var(--ease);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast i { color: var(--accent); }

/* ===========================================================
   RESPONSIVE
   =========================================================== */
@media (max-width: 860px) {
    .hero {
        grid-template-columns: 1fr;
        text-align: left;
        min-height: auto;
        gap: 2.5rem;
    }
    .steps-flow { grid-template-columns: 1fr; gap: 0.5rem; }
    .subject-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .nav-links li span { display: none; }      /* icons only on small screens */
    .nav-links li { padding: 0.5rem 0.7rem; }
    .nav-links i { font-size: 1.05rem; }
    .solver-header { flex-wrap: wrap; }
    .quest-progress-bar { order: 3; flex-basis: 100%; }
    .answer-zone .btn { width: 100%; }
}

/* ===========================================================
   ACCESSIBILITY
   =========================================================== */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
