:root {
    color-scheme: dark;
    --bg: #020617;
    --panel: rgba(15, 23, 42, 0.82);
    --panel-border: rgba(148, 163, 184, 0.18);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #4f46e5;
    --accent-2: #22d3ee;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, sans-serif;
    background: linear-gradient(180deg, #020617 0%, #0f172a 100%);
    color: #e2e8f0;
}

.floating-enroll-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #3b82f6, #2dd4bf);
    color: white;
    padding: 14px 28px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 800;
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4);
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: none;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.floating-enroll-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 36px rgba(59, 130, 246, 0.5);
}

button {
    font: inherit;
}

.page-shell {
    width: min(1180px, calc(100% - 24px));
    margin: 0 auto;
    padding: 24px 0 80px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    color: var(--text);
    text-decoration: none;
}

.hero,
.tabs,
.metric-card,
.question-card,
.level-card,
.feedback-panel,
.theory-card,
.stats-panel {
    border: 1px solid var(--panel-border);
    background: var(--panel);
    border-radius: 24px;
    box-shadow: 0 18px 56px rgba(2, 6, 23, 0.34);
}

.hero {
    padding: 28px;
    margin-bottom: 20px;
}

.hero-badge {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.18);
    color: #c7d2fe;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.hero h1 {
    margin: 16px 0 12px;
    font-size: clamp(2rem, 4vw, 3.5rem);
}

.hero-lead {
    margin: 0;
    max-width: 760px;
    color: var(--muted);
    line-height: 1.65;
}

.tabs {
    display: flex;
    gap: 10px;
    padding: 10px;
    margin-bottom: 20px;
}

.tab-btn,
.grade-btn {
    border: 1px solid rgba(99, 102, 241, 0.24);
    background: rgba(15, 23, 42, 0.72);
    color: var(--text);
    border-radius: 16px;
    padding: 12px 16px;
    cursor: pointer;
}

.tab-btn.is-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.metric-card {
    padding: 18px;
}

.metric-card span {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.metric-card strong {
    font-size: 1.3rem;
}

.trainer-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 0.9fr);
    gap: 20px;
}

.question-card,
.level-card,
.feedback-panel,
.theory-card,
.stats-panel {
    padding: 24px;
}

.question-label {
    margin: 0 0 14px;
    color: var(--muted);
}

.math-expression {
    min-height: 140px;
    margin-bottom: 18px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 20px;
    background: rgba(2, 6, 23, 0.42);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    text-align: center;
    padding: 28px 24px 18px;
    overflow-x: auto;
    overflow-y: hidden;
    font-size: clamp(2rem, 4vw, 3rem);
}

.math-expression .katex {
    font-size: 1em;
}

.choices-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.answer-btn {
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.88);
    color: var(--text);
    border-radius: 16px;
    padding: 16px;
    text-align: left;
}

.answer-btn.is-correct {
    border-color: #22c55e;
}

.answer-btn.is-wrong {
    border-color: #ef4444;
}

.side-panel {
    display: block;
}

.level-card h2 {
    margin: 0 0 16px;
}

#category-list-element {
    display: grid;
    gap: 12px;
}

.level-progress-card {
    border: 1px solid rgba(71, 85, 105, 0.78);
    background: rgba(15, 23, 42, 0.74);
    border-radius: 18px;
    padding: 14px 14px 12px;
}

.level-progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.level-progress-head strong {
    color: #f8fafc;
    font-size: 1rem;
}

.level-progress-head span {
    color: #cbd5e1;
    font-size: 0.92rem;
    font-weight: 700;
}

.level-progress {
    height: 10px;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.22);
    overflow: hidden;
}

.level-progress-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #64748b, #94a3b8);
    transition: width 0.25s ease, background 0.25s ease;
}

.level-progress-fill.is-mid {
    background: linear-gradient(90deg, #2563eb, #38bdf8);
}

.level-progress-fill.is-complete {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.feedback-panel {
    margin-top: 20px;
}

.grade-btn {
    font-weight: 700;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.grade-btn:hover {
    transform: translateY(-1px);
}

.grade-again {
    background: rgba(127, 29, 29, 0.35);
    border-color: rgba(248, 113, 113, 0.35);
    color: #fca5a5;
}

.grade-hard {
    background: rgba(120, 53, 15, 0.35);
    border-color: rgba(251, 191, 36, 0.35);
    color: #fcd34d;
}

.grade-good {
    background: rgba(49, 46, 129, 0.35);
    border-color: rgba(129, 140, 248, 0.35);
    color: #c7d2fe;
}

.grade-easy {
    background: rgba(6, 95, 70, 0.35);
    border-color: rgba(52, 211, 153, 0.35);
    color: #a7f3d0;
}

.grade-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.tab-content {
    display: block;
}

.theory-card + .theory-card {
    margin-top: 16px;
}

.theory-card h2 {
    margin-top: 0;
}

.theory-card p,
.stats-panel {
    color: var(--muted);
    line-height: 1.65;
}

.theory-math {
    color: #e2e8f0;
}

.task-list-panel {
    display: grid;
    gap: 14px;
}

.task-list-card {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.72);
    padding: 18px;
}

.task-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.task-list-index {
    font-size: 0.95rem;
    font-weight: 800;
    color: #f8fafc;
}

.task-level-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.14);
    color: #bfdbfe;
    font-size: 0.8rem;
    font-weight: 700;
}

.task-list-question {
    margin: 0 0 12px;
    color: #e2e8f0;
    line-height: 1.6;
}

.task-list-expression {
    margin-top: 8px;
}

.hidden {
    display: none;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 640px) {
    .page-shell {
        width: min(100% - 16px, 1180px);
        padding-top: 16px;
    }

    .floating-enroll-btn {
        bottom: 20px;
        right: 20px;
        padding: 12px 20px;
        font-size: 14px;
    }

    .tabs,
    .choices-grid,
    .grade-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-direction: column;
    }
}
