/* ============================================================
   Скорокуб — дизайн-система
   Две темы через CSS-переменные: :root — тёмная (fallback),
   html[data-theme="light"] — светлая. Выбор — в шапке сайта.
   ============================================================ */

:root {
    color-scheme: dark;
    --topbar-bg: rgba(11, 14, 20, 0.82);
    --on-accent: #06251c;
    --bg: #0b0e14;
    --bg-soft: #10141d;
    --bg-card: #141926;
    --bg-card-2: #1a2032;
    --bg-hover: #202840;
    --line: #232c42;
    --line-soft: #1b2236;
    --text: #e8ecf5;
    --text-dim: #98a2b8;
    --text-faint: #667089;
    --accent: #22d3a7;
    --accent-2: #38bdf8;
    --accent-soft: rgba(34, 211, 167, 0.12);
    --warn: #fbbf24;
    --danger: #f87171;
    --ok: #34d399;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --cube-white: #f4f6fb;
    --cube-yellow: #ffd21f;
    --cube-green: #0aa860;
    --cube-blue: #1e6fe0;
    --cube-red: #e5484d;
    --cube-orange: #f97316;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5em; font-weight: 700; letter-spacing: -0.015em; }
p { margin: 0 0 1em; }
img { max-width: 100%; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 22px; }
.container-narrow { max-width: 860px; margin: 0 auto; padding: 0 22px; }

/* ---------- Шапка ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: var(--topbar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-soft);
}
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background:
        linear-gradient(135deg, var(--cube-green) 0 50%, transparent 50%),
        conic-gradient(from 90deg, var(--cube-red), var(--cube-white), var(--cube-blue), var(--cube-yellow));
    box-shadow: inset 0 0 0 2px rgba(0,0,0,.45);
}
.topnav { display: flex; align-items: center; gap: 4px; margin-left: 12px; }
.topnav a {
    color: var(--text-dim); padding: 8px 13px; border-radius: 9px; font-weight: 550; font-size: 15px;
}
.topnav a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.topnav a.active { color: var(--accent); background: var(--accent-soft); }
.topbar-spacer { flex: 1; }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: 11px; border: 1px solid transparent;
    font-weight: 650; font-size: 15px; cursor: pointer; font-family: inherit;
    transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
    text-decoration: none !important; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #14b8a0 100%);
    color: var(--on-accent); box-shadow: 0 6px 20px rgba(34, 211, 167, 0.28);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(34, 211, 167, 0.4); }
.btn-secondary { background: var(--bg-card-2); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--line); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-lg { padding: 14px 28px; font-size: 16.5px; border-radius: 13px; }
.btn-sm { padding: 7px 14px; font-size: 13.5px; border-radius: 9px; }
.btn-danger { background: rgba(248, 113, 113, .12); color: var(--danger); border-color: rgba(248, 113, 113, .3); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Карточки ---------- */
.card {
    background: var(--bg-card); border: 1px solid var(--line-soft);
    border-radius: var(--radius); padding: 22px;
}
.card-2 { background: var(--bg-card-2); border-color: var(--line); }
.card-hover { transition: border-color .15s, transform .15s, box-shadow .15s; }
.card-hover:hover { border-color: #2e3a58; transform: translateY(-2px); box-shadow: var(--shadow); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Бейджи, метки ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 650;
    background: var(--bg-hover); color: var(--text-dim); border: 1px solid var(--line);
}
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: rgba(34, 211, 167, .3); }
.badge-blue { background: rgba(56, 189, 248, .1); color: var(--accent-2); border-color: rgba(56, 189, 248, .3); }
.badge-warn { background: rgba(251, 191, 36, .1); color: var(--warn); border-color: rgba(251, 191, 36, .3); }

/* ---------- Формы ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; }
.input {
    width: 100%; padding: 11px 14px; border-radius: 11px;
    background: var(--bg-soft); border: 1px solid var(--line);
    color: var(--text); font-size: 15px; font-family: inherit; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-error { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: 13px; margin-top: 5px; }
.hint { color: var(--text-faint); font-size: 13px; }

/* ---------- Лендинг ---------- */
.hero { padding: 76px 0 40px; position: relative; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 40px; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } .hero-cube { order: -1; height: 300px !important; } }
.hero-kicker {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--accent-soft); color: var(--accent);
    padding: 6px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 650;
    border: 1px solid rgba(34, 211, 167, .25); margin-bottom: 22px;
}
.hero h1 { font-size: clamp(34px, 5vw, 54px); margin-bottom: 18px; }
.hero h1 .grad {
    background: linear-gradient(92deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { font-size: 18.5px; color: var(--text-dim); max-width: 540px; margin-bottom: 30px; }
.hero-cube { height: 430px; position: relative; }
.hero-cube::after {
    content: ''; position: absolute; inset: auto 0 -20px 0; height: 120px;
    background: radial-gradient(ellipse at center, rgba(34, 211, 167, .13), transparent 65%);
    pointer-events: none;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 26px; }
.hero-facts { display: flex; gap: 26px; color: var(--text-faint); font-size: 14px; flex-wrap: wrap; }
.hero-facts b { color: var(--text); }

.section { padding: 66px 0; }
.section-alt { background: var(--bg-soft); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.section-title { font-size: clamp(26px, 3.4vw, 36px); text-align: center; margin-bottom: 10px; }
.section-sub { text-align: center; color: var(--text-dim); max-width: 640px; margin: 0 auto 44px; font-size: 16.5px; }

.step-num {
    width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 18px; margin-bottom: 14px;
}
.icon-chip { font-size: 30px; line-height: 1; margin-bottom: 12px; display: block; }

.faq-item { border-bottom: 1px solid var(--line-soft); padding: 18px 4px; }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-weight: 650; cursor: pointer; display: flex; justify-content: space-between; gap: 14px; }
.faq-a { color: var(--text-dim); margin-top: 10px; }

.cta-final {
    text-align: center; padding: 60px 30px; border-radius: 22px;
    background: linear-gradient(160deg, rgba(34,211,167,.1), rgba(56,189,248,.08));
    border: 1px solid rgba(34, 211, 167, .22);
}

/* ---------- Дашборд / приложение ---------- */
.app-main { padding: 30px 0 70px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-title { font-size: 27px; margin: 0; }
.page-sub { color: var(--text-dim); margin: 4px 0 0; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 15px 17px; }
.stat-value { display: block; font-size: 23px; font-weight: 750; letter-spacing: -0.02em; }
.stat-label { color: var(--text-faint); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

.lesson-card { display: flex; gap: 16px; align-items: flex-start; }
.lesson-num {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 750; background: var(--bg-hover); color: var(--text-dim); font-size: 15px;
}
.lesson-card.done .lesson-num { background: var(--accent-soft); color: var(--accent); }
.lesson-card.current .lesson-num { background: linear-gradient(135deg, var(--accent), #14b8a0); color: var(--on-accent); }
.lesson-link { color: var(--text); font-weight: 650; font-size: 16px; }
.lesson-link:hover { color: var(--accent-2); text-decoration: none; }

.progress-track { height: 8px; border-radius: 99px; background: var(--bg-hover); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }

.goal-panel { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }

/* ---------- Урок ---------- */
.lesson-layout { display: grid; grid-template-columns: 1fr 300px; gap: 26px; align-items: start; }
@media (max-width: 980px) { .lesson-layout { grid-template-columns: 1fr; } }
.lesson-toc { position: sticky; top: 84px; }
.lesson-body h2 { font-size: 22.5px; margin: 34px 0 14px; }
.lesson-body h3 { font-size: 18px; margin: 26px 0 10px; }
.lesson-body ul, .lesson-body ol { padding-left: 22px; color: var(--text-dim); }
.lesson-body li { margin-bottom: 7px; }
.lesson-body strong { color: var(--text); }
.lesson-section { margin-bottom: 8px; }
.callout {
    border-left: 3px solid var(--accent); background: var(--accent-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 13px 17px; margin: 16px 0; color: var(--text-dim);
}
.callout b, .callout strong { color: var(--text); }

/* ---------- Виджет кубика ---------- */
.cube-widget { margin: 20px 0; }
.sk-widget {
    background: var(--bg-soft); border: 1px solid var(--line-soft);
    border-radius: var(--radius); overflow: hidden;
}
.sk-stage { position: relative; cursor: grab; }
.sk-stage:active { cursor: grabbing; }
.sk-canvas { display: block; width: 100%; height: 100%; }
.sk-panel { padding: 14px 18px 18px; border-top: 1px solid var(--line-soft); }
.sk-title { font-weight: 700; margin-bottom: 4px; }
.sk-caption { color: var(--text-dim); font-size: 14px; margin-bottom: 10px; }
.sk-alg-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.sk-chip {
    font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 14.5px; font-weight: 650;
    background: var(--bg-card-2); border: 1px solid var(--line); color: var(--text-dim);
    border-radius: 8px; padding: 4px 9px; cursor: pointer; transition: all .12s;
}
.sk-chip.done { color: var(--accent); border-color: rgba(34, 211, 167, .35); background: var(--accent-soft); }
.sk-chip.current { color: var(--on-accent); background: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.sk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.sk-btn {
    width: 36px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
    background: var(--bg-card-2); color: var(--text); cursor: pointer; font-size: 13px;
    display: inline-flex; align-items: center; justify-content: center; transition: background .12s;
}
.sk-btn:hover { background: var(--bg-hover); }
.sk-speed { display: flex; align-items: center; gap: 7px; color: var(--text-faint); font-size: 11.5px; }
.sk-speed input { width: 90px; accent-color: var(--accent); }
.sk-status { color: var(--text-faint); font-size: 13px; margin-left: auto; }
.sk-pad { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.sk-move {
    font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 13px; font-weight: 650;
    background: var(--bg-card-2); border: 1px solid var(--line); color: var(--text-dim);
    border-radius: 7px; padding: 5px 9px; cursor: pointer;
}
.sk-move:hover { color: var(--text); background: var(--bg-hover); border-color: #31405f; }
.sk-hint { color: var(--text-faint); font-size: 12.5px; margin-top: 6px; }
.sk-hint b { color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.sk-drill-status {
    padding: 10px 14px; border-radius: 9px; background: var(--bg-card-2);
    border: 1px dashed var(--line); font-size: 14px; color: var(--text-dim);
}
.sk-drill-status .ok { color: var(--ok); }
.sk-drill-status b { color: var(--text); }

/* 2D-развёртка */
.sk-net { margin-top: 12px; display: flex; justify-content: center; }
.sk-net-grid {
    display: grid; grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: 252px; height: 189px; gap: 2px;
}
.sk-net-face { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px; }
.sk-net-u { grid-column: 4 / 7; grid-row: 1 / 4; }
.sk-net-l { grid-column: 1 / 4; grid-row: 4 / 7; }
.sk-net-f { grid-column: 4 / 7; grid-row: 4 / 7; }
.sk-net-r { grid-column: 7 / 10; grid-row: 4 / 7; }
.sk-net-b { grid-column: 10 / 13; grid-row: 4 / 7; }
.sk-net-d { grid-column: 4 / 7; grid-row: 7 / 10; }
.sk-net-cell { border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.35); }

/* ---------- Тренажёр ---------- */
.trainer { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
@media (max-width: 980px) { .trainer { grid-template-columns: 1fr; } }
.trainer-main { text-align: center; padding: 30px 24px; }
.scramble {
    font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 19px; font-weight: 600;
    background: var(--bg-card-2); border: 1px solid var(--line); border-radius: 12px;
    padding: 15px 18px; margin: 0 auto 22px; max-width: 560px; line-height: 1.9;
}
.scramble-move { display: inline-block; color: var(--text); margin: 0 5px 4px; white-space: nowrap; }
.timer-display {
    font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 58px; font-weight: 700;
    letter-spacing: -0.01em; margin: 8px 0 18px; font-variant-numeric: tabular-nums;
}
.trainer-cube { height: 280px; margin-bottom: 6px; }
.result-bar { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.solve-chip {
    display: inline-block; font-family: 'JetBrains Mono', monospace; font-size: 13.5px;
    background: var(--bg-card-2); border: 1px solid var(--line); border-radius: 8px;
    padding: 4px 10px; margin: 3px 3px 0 0; color: var(--text-dim);
}
.solve-chip.dnf { color: var(--danger); border-color: rgba(248, 113, 113, .4); }
.solve-chip.plus2 { color: var(--warn); }

/* ---------- Квиз ---------- */
.quiz-q { margin: 22px 0; }
.quiz-q h4 { margin-bottom: 12px; font-size: 16.5px; }
.quiz-opt {
    display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; margin-bottom: 9px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 11px; cursor: pointer;
    transition: border-color .12s, background .12s;
}
.quiz-opt:hover { border-color: #31405f; }
.quiz-opt.selected { border-color: var(--accent-2); background: rgba(56, 189, 248, .07); }
.quiz-opt.correct { border-color: var(--ok); background: rgba(52, 211, 153, .09); }
.quiz-opt.wrong { border-color: var(--danger); background: rgba(248, 113, 113, .09); }
.quiz-explain { color: var(--text-dim); font-size: 14px; padding: 10px 15px; background: var(--bg-card-2); border-radius: 9px; margin-top: 8px; }

/* ---------- Шпаргалка ---------- */
.alg-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.alg-table th { text-align: left; color: var(--text-faint); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.alg-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.alg-table tr:last-child td { border-bottom: none; }
.alg-name { font-weight: 650; white-space: nowrap; }
.alg-str { font-family: 'JetBrains Mono', monospace; color: var(--accent-2); }

/* ---------- Прогресс ---------- */
.chart-wrap { background: var(--bg-card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 20px; }
.mastery-row { display: flex; align-items: center; gap: 14px; margin-bottom: 13px; }
.mastery-name { flex: 0 0 190px; font-size: 14.5px; font-weight: 600; }
.mastery-track { flex: 1; }

/* ---------- Онбординг ---------- */
.onboard-steps { display: flex; gap: 8px; margin-bottom: 30px; }
.onboard-step { flex: 1; height: 5px; border-radius: 99px; background: var(--bg-hover); }
.onboard-step.active { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.onboard-step.done { background: var(--accent); }
.choice-card { cursor: pointer; text-align: center; padding: 30px 22px; }
.choice-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice-emoji { font-size: 40px; display: block; margin-bottom: 12px; }
.goal-chip {
    padding: 14px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-soft);
    cursor: pointer; text-align: center; font-weight: 650; transition: all .12s;
}
.goal-chip:hover { border-color: #31405f; }
.goal-chip.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.goal-chip small { display: block; color: var(--text-faint); font-weight: 500; margin-top: 3px; }

/* ---------- Футер ---------- */
.footer { border-top: 1px solid var(--line-soft); padding: 34px 0 44px; color: var(--text-faint); font-size: 14px; }
.footer a { color: var(--text-dim); }

/* ---------- Мелочи ---------- */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 36px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.text-dim { color: var(--text-dim); } .text-faint { color: var(--text-faint); }
.text-accent { color: var(--accent); } .text-ok { color: var(--ok); } .text-danger { color: var(--danger); }
.text-center { text-align: center; }
.fs-13 { font-size: 13px; } .fs-14 { font-size: 14px; } .fs-15 { font-size: 15px; }
.mono { font-family: 'JetBrains Mono', 'Consolas', monospace; }
.divider { height: 1px; background: var(--line-soft); margin: 26px 0; border: none; }

[x-cloak] { display: none !important; }

::selection { background: rgba(34, 211, 167, .3); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2e3a58; }

/* Сеточные раскладки, которые не должны ломаться инлайном */
.dashboard-grid { display: grid; gap: 16px; grid-template-columns: 1.6fr 1fr; align-items: start; }
@media (max-width: 980px) { .dashboard-grid { grid-template-columns: 1fr; } }
.topnav { overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }

/* ---------- Ревизия UX: контраст, мобильная шапка, добор классов ---------- */
:root { --text-faint: #8a94a8; }

@media (max-width: 700px) {
    .topbar-inner { height: auto; flex-wrap: wrap; padding: 8px 0; row-gap: 6px; }
    .topnav { order: 3; width: 100%; margin-left: 0; }
    .topnav a { padding: 7px 10px; font-size: 14px; }
    .brand { font-size: 17px; }
}

.fs-12 { font-size: 12px; }
.fs-16 { font-size: 16px; }
.fs-18 { font-size: 18px; }
.mb-0 { margin-bottom: 0; }

/* Баннер гостя поверх grid-раскладки тренажёра */
.trainer > .callout { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; }
@media (max-width: 700px) {
    .table-wrap table { min-width: 560px; }
}

/* Клавиатурная доступность: видимый фокус на «псевдокнопках» */
.quiz-opt:focus-visible,
.choice-card:focus-visible,
.goal-chip:focus-visible,
.faq-q:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
}

/* Атрибут hidden всегда побеждает display-правила классов
   (иначе .result-bar { display:flex } перебивает hidden и ломает сетку тренажёра) */
[hidden] { display: none !important; }

/* Грид-детям тренажёра разрешаем сжиматься: min-width:auto распирает колонку
   при широком минимальном контенте и выталкивает карточку за контейнер */
.trainer > * { min-width: 0; }

/* ============================================================
   Светлая тема — html[data-theme="light"]
   ============================================================ */
html[data-theme="light"] {
    color-scheme: light;
    --topbar-bg: rgba(255, 255, 255, 0.92);
    --on-accent: #ffffff;
    --bg: #f5f7fb;
    --bg-soft: #edf1f7;
    --bg-card: #ffffff;
    --bg-card-2: #f2f5fa;
    --bg-hover: #e6edf5;
    --line: #d7dfeb;
    --line-soft: #e4eaf3;
    --text: #182233;
    --text-dim: #46536e;
    --text-faint: #6e7a94;
    --accent: #0d9e7c;
    --accent-2: #0b7fc4;
    --accent-soft: rgba(13, 158, 124, 0.12);
    --shadow: 0 10px 30px rgba(20, 40, 80, 0.10);
}

html[data-theme="light"] .topbar { box-shadow: 0 1px 12px rgba(20, 40, 80, 0.06); }
html[data-theme="light"] .btn-primary { color: #ffffff; }
html[data-theme="light"] .brand-mark { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7); }
html[data-theme="light"] .sk-chip.current { color: #ffffff; }
html[data-theme="light"] .lesson-card.current .lesson-num { color: #ffffff; }
html[data-theme="light"] .timer-display { color: var(--text); }
html[data-theme="light"] .cta-final { background: linear-gradient(160deg, rgba(13,158,124,.10), rgba(11,127,196,.08)); border-color: rgba(13, 158, 124, 0.25); }
html[data-theme="light"] ::selection { background: rgba(13, 158, 124, 0.25); }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #bcc7d6; }

/* плавная смена темы */
body, .card, .card-2, .topbar, .input, .btn, .sk-widget, .goal-chip, .quiz-opt {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* светлая тема: hover-акценты */
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #b6c2d4; }
html[data-theme="light"] .quiz-opt:hover,
html[data-theme="light"] .goal-chip:hover,
html[data-theme="light"] .sk-move:hover,
html[data-theme="light"] .sk-chip:hover { border-color: #9fb0c8; }
html[data-theme="light"] .sk-chip.done { color: var(--accent); }

/* Скрамбл: равномерный перенос строк (без «один ход на второй строке») */
.scramble { text-wrap: balance; }

/* Скрамбл: равномерный перенос строк — без «одинокого хода» на второй строке */
.scramble { text-wrap: balance; }

/* ============================================================
   Лаборатория (/lab): сканер камеры, верификация, VR
   ============================================================ */

.text-warn { color: var(--warn); }

.lab-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 14px; }
.lab-tab {
    padding: 9px 16px; border-radius: 11px; border: 1px solid var(--line);
    background: var(--bg-card); color: var(--text-dim); font-size: 14px; cursor: pointer;
}
.lab-tab:hover { color: var(--text); background: var(--bg-hover); }
.lab-tab.active { background: var(--accent-soft, rgba(34,211,167,.12)); color: var(--accent); border-color: rgba(34, 211, 167, .35); }

.lab-capture { padding: 14px; }
.lab-cam-wrap { display: grid; grid-template-columns: minmax(0, 7fr) minmax(240px, 5fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .lab-cam-wrap { grid-template-columns: 1fr; } }

.cam-stage {
    position: relative; width: 100%; background: #07090d; border-radius: 14px;
    overflow: hidden; border: 1px solid var(--line); min-height: 220px;
}
.cam-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.cam-stage.live { box-shadow: 0 0 0 2px rgba(34, 211, 167, .25); }

.cam-grid {
    position: absolute; inset: 0; width: 100%; height: 100%;
    display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
    gap: 5px; padding: 5px;
}
.cam-cell {
    border-radius: 7px; border: 2px solid rgba(255, 255, 255, .38);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; color: rgba(0, 0, 0, .55);
    text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
    background: rgba(127, 127, 127, .12);
}
.cam-cell.uncertain { border-style: dashed; border-color: var(--warn, #fbbf24); }
.cam-grid.editable .cam-cell { cursor: pointer; }
.cam-grid.editable .cam-cell:hover { border-color: var(--accent); }

.cam-off {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
    display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px 14px;
    align-items: center; justify-content: center; text-align: center;
    background: rgba(7, 9, 13, .84); color: var(--text-dim); font-size: 13px; padding: 10px 14px;
}
.cam-off p { margin: 0; }

.cam-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cam-slot {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 8px 4px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--bg-card-2); cursor: pointer; color: var(--text-dim);
}
.cam-slot:hover { background: var(--bg-hover); color: var(--text); }
.cam-slot.selected { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent); }
.cam-slot.done { border-color: rgba(34, 211, 167, .45); }
.cam-slot-label { font-size: 12px; font-weight: 700; }
.cam-slot-grid { display: grid; grid-template-columns: repeat(3, 11px); gap: 2px; }
.cam-mini { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(127, 127, 127, .35); }

.cam-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cam-hint { margin: 10px 0 0; }

.lab-errors { margin: 6px 0 0; padding-left: 20px; }
.lab-errors li { margin: 3px 0; }

.lab-facelets {
    word-break: break-all; background: var(--bg-soft); border: 1px solid var(--line-soft);
    border-radius: 9px; padding: 9px 11px; font-size: 13px; letter-spacing: 1px;
}
.lab-solution { font-size: 16px; margin-top: 4px; }

.lab-timer { font-size: 36px; font-weight: 700; line-height: 1; min-width: 130px; text-align: right; }
.lab-timer-final { font-size: 42px; font-weight: 700; margin: 6px 0; }
.lab-verified { color: var(--ok, #34d399); font-size: 17px; font-weight: 700; }
.lab-history-row {
    display: flex; align-items: center; gap: 12px; padding: 8px 2px;
    border-bottom: 1px solid var(--line-soft); font-size: 15px;
}
.lab-history-row:last-child { border-bottom: none; }
.lab-history-row .mono { min-width: 90px; }

.lab-vr-stage {
    position: relative; height: 460px; border-radius: 16px; overflow: hidden;
    border: 1px solid var(--line);
    background: radial-gradient(1200px 500px at 50% 20%, rgba(34, 211, 167, .08), transparent 60%),
                var(--bg-soft);
}
.lab-vr-stage:fullscreen { height: 100vh; border-radius: 0; border: none; }
.lab-vr-stage.stereo { background: #000; }
.lab-vr-canvas { position: absolute; inset: 0 0 64px; }
.lab-vr-stage:fullscreen .lab-vr-canvas { inset: 0 0 64px; }
.lab-vr-canvas .cube-canvas { width: 100%; height: 100%; }
.lab-vr-tools {
    position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px;
    justify-content: center; flex-wrap: wrap; padding: 12px;
    background: linear-gradient(transparent, rgba(7, 9, 13, .55));
}
.lab-vr-tools .btn.on { border-color: var(--accent); color: var(--accent); }

@media (max-width: 620px) {
    .lab-timer { font-size: 28px; min-width: 105px; }
    .lab-timer-final { font-size: 32px; }
    .lab-vr-stage { height: 380px; }
}

/* Рамка захвата (ROI): перемещаемая и масштабируемая область куба */
.cam-roi {
    position: absolute; border: 2px solid rgba(34, 211, 167, .85); border-radius: 6px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .45), 0 0 18px rgba(34, 211, 167, .18);
    touch-action: none; cursor: move; z-index: 3;
}
.cam-roi:active { cursor: grabbing; }
.cam-roi .cam-grid { position: absolute; inset: 0; width: 100%; height: 100%; }
.cam-handle {
    position: absolute; width: 16px; height: 16px; border-radius: 4px;
    background: var(--accent); border: 2px solid #fff; z-index: 4;
}
.cam-handle-nw { left: -9px; top: -9px; cursor: nwse-resize; }
.cam-handle-ne { right: -9px; top: -9px; cursor: nesw-resize; }
.cam-handle-sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.cam-handle-se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.cam-detect {
    position: absolute; left: 10px; top: 10px; z-index: 5;
    padding: 4px 10px; border-radius: 999px; font-size: 12.5px;
    background: rgba(7, 9, 13, .72); color: var(--text-dim); border: 1px solid var(--line);
}
.cam-detect.on { color: var(--accent); border-color: rgba(34, 211, 167, .5); }
.btn.on { border-color: var(--accent); color: var(--accent); }

/* Отладка детектора: маска классов + рамка */
.cam-debug {
    position: absolute; right: 10px; top: 10px; z-index: 5;
    width: 30%; max-width: 200px; border-radius: 8px; border: 1px solid var(--line);
    image-rendering: pixelated; opacity: 0.92; background: #07090d;
}
