/* ===================== ТЕМЫ ===================== */

:root, [data-theme="light"] {
    --accent: #1B64F2;
    --accent-hover: #0E4FD1;
    --accent-soft: rgba(27, 100, 242, 0.09);
    --accent-ink: #ffffff;
    --btn-glow: 0 2px 10px rgba(27, 100, 242, 0.35);
    --bg: #FBFBFD;
    --card: #FFFFFF;
    --card-2: #F4F6F9;
    --border: #E5E7EB;
    --border-strong: #B7BFC9;
    --text: #1F2328;
    --muted: #59636E;
    --success: #1A7F37;
    --success-bg: #DAFBE1;
    --error: #CF222E;
    --error-bg: #FFE2E2;
    --known: #BF6300;
    --known-ink: #ffffff;
    --edge: #9AA0B4;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(31, 35, 40, 0.08), 0 4px 16px rgba(31, 35, 40, 0.06);
    color-scheme: light;
}

[data-theme="dark"] {
    --accent: #4493F8;
    --accent-hover: #6CB0FF;
    --accent-soft: rgba(68, 147, 248, 0.14);
    --accent-ink: #0D1117;
    --btn-glow: 0 2px 12px rgba(68, 147, 248, 0.25);
    --bg: #0D1117;
    --card: #161B22;
    --card-2: #1C2128;
    --border: #2D333B;
    --border-strong: #444C56;
    --text: #E6EDF3;
    --muted: #9198A1;
    --success: #3FB950;
    --success-bg: rgba(63, 185, 80, 0.12);
    --error: #F85149;
    --error-bg: rgba(248, 81, 73, 0.12);
    --known: #F0A44B;
    --known-ink: #241a06;
    --edge: #444C56;
    --radius: 14px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
}

/* ===================== БАЗА ===================== */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    transition: background 0.2s, color 0.2s;
}

.container {
    max-width: 1060px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Сайдбар */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 250px;
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    padding: 26px 14px;
    background: var(--card);
    border-right: 1px solid var(--border);
}
.logo {
    display: block;
    font-size: 21px;
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
    padding: 0 12px 20px;
    letter-spacing: 0.4px;
}
.logo span { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-caption {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
    padding: 0 12px 8px;
}
.nav a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav a:hover { color: var(--accent); background: var(--accent-soft); }
.nav a.active {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: var(--accent);
    font-weight: 600;
}

/* Переключатель темы */
.theme-switch {
    margin-top: auto;
    padding: 14px 12px 0;
}
.theme-switch .nav-caption { padding: 0 2px 8px; }
.theme-switch .ts-btns {
    display: flex;
    gap: 6px;
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
}
.theme-switch button {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    padding: 7px 4px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.theme-switch button:hover { color: var(--accent); }
.theme-switch button.active {
    background: var(--accent);
    color: var(--accent-ink);
}

.page { flex: 1; display: flex; flex-direction: column; }
.page .container { flex: 1; width: 100%; }
@media (max-width: 820px) {
    .layout { flex-direction: column; }
    .sidebar { position: static; width: 100%; flex: none; height: auto; padding: 16px; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-caption { width: 100%; }
    .theme-switch { margin-top: 10px; }
}

main { padding: 30px 0 48px; }

/* Главная */
.hero { text-align: center; padding: 40px 0 28px; }
.hero h1 { font-size: 32px; margin: 0 0 10px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--muted); font-size: 17px; margin: 0; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 24px;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 6px 22px rgba(31, 35, 40, 0.12);
}
[data-theme="dark"] .card:hover {
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5);
}
.card-num {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    border-radius: 8px;
    padding: 4px 10px;
    margin-bottom: 12px;
}
.card h2 { margin: 0 0 8px; font-size: 20px; }
.card p { margin: 0 0 14px; color: var(--muted); }
.card-link { color: var(--accent); font-weight: 600; }

/* Страница задания */
.page-title { font-size: 26px; margin: 8px 0 18px; }

.theory {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}
.theory summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 17px;
    padding: 16px 20px;
    list-style: none;
}
.theory summary::before { content: "📗 "; }
.theory-body { padding: 0 20px 18px; }
.theory-body ol { padding-left: 22px; }

.ops-table, .data-table {
    border-collapse: collapse;
    margin: 12px 0;
}
.ops-table th, .ops-table td,
.data-table th, .data-table td {
    border: 1px solid var(--border);
    padding: 7px 14px;
    text-align: center;
}
.ops-table th, .data-table th { background: var(--accent-soft); color: var(--accent); }

.trainer {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}
.task-statement {
    font-size: 16.5px;
    white-space: pre-line;
    background: var(--accent-soft);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
}
.task-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 860px) {
    .task-grid { grid-template-columns: 1fr; }
}
.panel h3 { margin: 0 0 4px; font-size: 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

/* Граф */
#graph {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    touch-action: none;
}
#graph .edge { stroke: var(--edge); stroke-width: 2; }
#graph .edge.hl { stroke: var(--accent); stroke-width: 4; }
#graph .edge-label {
    font-size: 13px;
    font-weight: 700;
    fill: var(--accent);
    paint-order: stroke;
    stroke: var(--card-2);
    stroke-width: 4px;
}
#graph .node { cursor: grab; }
#graph .node circle {
    fill: var(--card);
    stroke: var(--accent);
    stroke-width: 2;
}
#graph .node.hl circle { fill: var(--accent); }
#graph .node text {
    fill: var(--accent);
    font-weight: 700;
    font-size: 14px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}
#graph .node.hl text { fill: var(--accent-ink); }

/* Таблицы тренажёров */
.data-table td.empty { color: var(--border-strong); }
.data-table th.row-head { background: var(--accent-soft); }
.data-table tr.hl td { background: var(--success-bg); }

/* Фишки переменных (задание 2) */
.chips { display: flex; gap: 10px; margin-bottom: 12px; }
.chip {
    background: var(--accent-soft);
    color: var(--accent);
    border: 2px solid var(--accent);
    border-radius: 10px;
    font-size: 18px;
    font-weight: 700;
    padding: 6px 18px;
    cursor: pointer;
    user-select: none;
    font-family: inherit;
}
.chip.selected { background: var(--accent); color: var(--accent-ink); }
.chip.used { opacity: 0.35; pointer-events: none; }
.slot {
    display: inline-block;
    min-width: 34px;
    cursor: pointer;
    color: var(--muted);
    border-bottom: 2px dashed var(--border-strong);
}
.slot.filled { color: var(--accent); border-bottom-style: solid; font-weight: 700; }

/* Ответ и кнопки */
.answer-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}
.answer-bar label { font-weight: 600; }
.btn {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); box-shadow: var(--btn-glow); }
.btn-ghost { color: var(--muted); }

.feedback {
    margin-top: 16px;
    font-weight: 600;
    border-radius: 10px;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s, padding 0.2s;
}
.feedback.show { max-height: 120px; padding: 12px 16px; }
.feedback.ok { background: var(--success-bg); color: var(--success); }
.feedback.bad { background: var(--error-bg); color: var(--error); }

/* Решение */
.solution { margin-top: 16px; }
.solution ol { padding-left: 22px; margin: 10px 0 0; }
.solution li {
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--card-2);
    border: 1px solid var(--border);
}
.solution li.clickable { cursor: pointer; }
.solution li.clickable:hover { background: var(--accent-soft); }

/* Подвал */
.site-footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 14px;
    padding: 18px 0;
    text-align: center;
}

/* Вкладки типов заданий */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.tab {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

/* Шаги урока (Теория / Пример / Практика) */
.steps {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
}
.step {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.step .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}
.step:hover { border-color: var(--accent); color: var(--accent); }
.step.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}
.step.active .step-num { background: var(--accent-ink); color: var(--accent); }
.step-body[hidden] { display: none; }
.step-body .theory-body { padding-top: 16px; }

/* Бейдж назначенного номера на вершине графа */
.node-badge circle {
    fill: var(--bg);
    stroke: var(--accent);
    stroke-width: 2;
}
.node-badge text {
    fill: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

/* Звёздочки в таблице задания №1 */
.data-table td.star { font-weight: 700; color: var(--accent); }

/* Текстовое поле ответа */
#answer-input, #n-input {
    width: 140px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text);
    border-radius: 10px;
    font-size: 16px;
}
#n-input { width: 130px; }
#answer-input:focus, #n-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Задание №3: база данных */
#question {
    margin-top: 14px;
    font-weight: 700;
    font-size: 16.5px;
}
.db-headers {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 14px 0;
}
.db-headers .panel h3 { margin: 0 0 8px; font-size: 15px; }
.db-headers .data-table { margin: 0; }
.db-headers .data-table th { font-size: 13px; padding: 6px 10px; white-space: normal; }

#db-schema {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 6px 0 4px;
}
.schema-table rect {
    fill: var(--card);
    stroke: var(--accent);
    stroke-width: 1.5;
}
.schema-table text {
    font-size: 13px;
    fill: var(--text);
}
.schema-table .schema-title {
    font-weight: 700;
    font-size: 15px;
    text-anchor: middle;
    fill: var(--accent);
}
.schema-table .schema-key {
    font-weight: 700;
    text-decoration: underline;
}
.schema-link {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
}

.download-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 14px 0 6px;
    padding: 14px 16px;
    background: var(--accent-soft);
    border-radius: 10px;
}
.download-bar .hint { margin: 0; }

/* Задание №4: кодовое дерево */
#code-tree {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    touch-action: manipulation;
}
.tree-edge { stroke: var(--edge); stroke-width: 1.5; }
.tree-node circle {
    fill: var(--card);
    stroke: var(--border-strong);
    stroke-width: 1.5;
}
.tree-node text {
    font-size: 12px;
    font-weight: 700;
    fill: var(--muted);
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}
.tree-node:not(.root):not(.blocked) { cursor: pointer; }
.tree-node:not(.root):not(.blocked):hover circle { stroke: var(--accent); }
.tree-node.known circle { fill: var(--known); stroke: var(--known); }
.tree-node.known text { fill: var(--known-ink); }
.tree-node.assigned circle { fill: var(--success); stroke: var(--success); }
.tree-node.assigned text { fill: #ffffff; }
[data-theme="dark"] .tree-node.assigned text { fill: #0D1117; }
.tree-node.blocked { opacity: 0.25; }
.tree-node.hl circle {
    fill: var(--known);
    stroke: var(--known);
}
.tree-node.hl text { fill: var(--known-ink); }
.tree-node .node-letter {
    font-size: 14px;
    fill: var(--text);
}
.assign-info {
    margin: 6px 0 12px;
    font-size: 14px;
    color: var(--muted);
    font-weight: 600;
}

/* Задание №5: лаборатория алгоритма */
.algo-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}
.algo-bar label { font-weight: 700; }
.algo-trace { display: flex; flex-direction: column; gap: 8px; }
.trace-step {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 10px 14px;
    animation: trace-in 0.25s ease;
}
.trace-step b { color: var(--accent); }
.trace-num { color: var(--muted); font-weight: 700; margin-right: 4px; }
@keyframes trace-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

/* Редактор кода (задание №5) */
#editor {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
}
#editor .CodeMirror {
    height: auto;
    min-height: 260px;
    font-size: 14px;
    line-height: 1.5;
}
.editor-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}
.editor-status {
    color: var(--muted);
    font-size: 13px;
}
.editor-output {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    margin: 0;
    min-height: 90px;
    max-height: 260px;
    overflow: auto;
    font-family: Consolas, "Courier New", monospace;
    font-size: 14px;
    color: var(--text);
    white-space: pre-wrap;
}
.theory-body h4 { margin: 18px 0 6px; color: var(--accent); }
.theory-body pre {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    overflow-x: auto;
    font-size: 13.5px;
}
.theory-body code {
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 13.5px;
}
.theory-body pre code { background: none; color: var(--text); padding: 0; }

/* Флеш-сообщения */
.flash {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 14px;
    border: 1px solid var(--border);
}
.flash-ok { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.flash-error { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
[data-theme="dark"] .flash-error { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }

/* Авторизация */
.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    max-width: 420px;
    margin: 40px auto 0;
}
.form label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
}
.form input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
}
.form input:focus { outline: none; border-color: var(--accent); }
.form .btn { margin-top: 4px; }

/* Профиль */
.profile-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 18px;
    align-items: start;
}
@media (max-width: 900px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-card { padding: 20px; }
.avatar { margin-bottom: 16px; }
.avatar img, .avatar-placeholder {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
}
.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 40px;
    font-weight: 700;
}
.stats-cards { display: flex; gap: 12px; margin: 12px 0 20px; flex-wrap: wrap; }
.stat-card {
    background: var(--accent-soft);
    border-radius: 10px;
    padding: 14px 22px;
    text-align: center;
}
.stat-num { font-size: 26px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--muted); }

/* Админ-панель */
.admin-table { width: 100%; }
.admin-table td, .admin-table th { padding: 8px 10px; }
a.tab { text-decoration: none; display: inline-block; }
.chip-off { opacity: 0.45; text-decoration: line-through; }
.badge {
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 700;
}
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-bad { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .badge-ok { background: #052e16; color: #86efac; }
[data-theme="dark"] .badge-bad { background: #450a0a; color: #fca5a5; }
.points-input { width: 70px; }
.muted { color: var(--muted); font-weight: 400; }

/* Редактор Markdown */
.md-editor {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}
.md-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.step-kind {
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    padding: 3px 12px;
    font-size: 12.5px;
    font-weight: 700;
}
.md-title {
    flex: 1;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
}
.md-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 900px) { .md-grid { grid-template-columns: 1fr; } }
.md-src {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: ui-monospace, monospace;
    font-size: 13px;
    resize: vertical;
}
.md-preview {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 4px 12px;
    overflow: auto;
    max-height: 340px;
}
.md-preview table { border-collapse: collapse; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 4px 10px; }
.md-preview pre {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
}
.code-view {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    overflow-x: auto;
    font-size: 13.5px;
    white-space: pre-wrap;
}
.practice-intro { padding: 0 0 12px; }

/* Таблицы, отрендеренные из Markdown в теории */
.theory-body table { border-collapse: collapse; margin: 12px 0; }
.theory-body th, .theory-body td {
    border: 1px solid var(--border);
    padding: 6px 14px;
    text-align: center;
}
.theory-body th { background: var(--accent-soft); color: var(--accent); }

/* Управление шагами в админке */
.step-actions { display: flex; gap: 6px; }
.btn-danger { color: #b91c1c; }
.btn-danger:hover { border-color: #b91c1c; color: #b91c1c; }
.steps-bar-wrap {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 18px;
}
.steps-bar-wrap .steps-admin {
    flex: 1;
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.step-anchor { text-decoration: none; }
.step-anchor.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step-anchor.active .step-num { background: var(--accent-ink); color: var(--accent); }
.step-add-wrap { position: relative; }
.step-add-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--accent);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    flex: none;
}
.step-add-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.step-add-popover {
    position: absolute;
    top: 44px;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 170px;
    z-index: 50;
}
.step-add-popover[hidden] { display: none; }
.step-add-caption { font-size: 13px; font-weight: 700; color: var(--muted); }
.step-add-popover form .btn { width: 100%; }
@media (max-width: 900px) {
    .steps-bar-wrap { flex-wrap: wrap; }
    .step-add-wrap { order: -1; }
}

/* Верхняя панель аккаунта */
.topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    padding: 14px 24px 0;
    font-size: 14px;
    flex-wrap: wrap;
}
.topbar a { color: var(--accent); font-weight: 600; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.topbar a.btn-primary { color: var(--accent-ink); }
.topbar a.btn-primary:hover { text-decoration: none; }
.topbar-user { color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 10px; }
.topbar-user:hover { text-decoration: none; }
.topbar-user:hover .topbar-name { text-decoration: underline; }
.topbar-avatar, .topbar-avatar img, .topbar-avatar-placeholder {
    width: 34px;
    height: 34px;
    border-radius: 50%;
}
.topbar-avatar img { object-fit: cover; display: block; }
.topbar-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 16px;
    font-weight: 700;
}
.topbar-register { padding: 6px 14px; }

/* Значки шагов (однотонные, currentColor) */
.step-icon { display: block; width: 18px; height: 18px; }
.step { min-width: 40px; justify-content: center; }

/* Страницы входа/регистрации */
.auth-page { text-align: center; }
.auth-page .page-title { margin-top: 40px; }
.auth-page .auth-card { text-align: left; margin-top: 20px; }
.auth-page .form .btn { width: 100%; }
.practice-box {
    margin-top: 12px;
    border-top: 1px dashed var(--border);
    padding-top: 12px;
}
.practice-gen .btn, .practice-task-info .btn { margin: 6px 6px 0 0; }
.practice-task-info .hint { margin: 6px 0; }
