:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, #16181d);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2b7de9);
  --btn: var(--tg-theme-button-color, #2b7de9);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: var(--tg-theme-accent-text-color, var(--btn));
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --ok: #2fa75f;
  --line: rgba(127, 127, 127, 0.18);
  --soft: rgba(127, 127, 127, 0.1);
  --code-bg: #1d2230;
  --code-text: #e3e8f1;
  --out-bg: #10141c;
  --radius: 14px;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, "Roboto Mono", monospace;
  color-scheme: light dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg2);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

button { font: inherit; color: inherit; cursor: pointer; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 19px; margin: 6px 0; }
p { margin: 6px 0; }

.screen { padding: 12px 12px calc(96px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
body.inner .screen { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.loading { padding: 80px 0; display: flex; justify-content: center; color: var(--hint); }
.loading .ic { width: 34px; height: 34px; }

.card { background: var(--section); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.pad { padding: 2px 4px 10px; }
.stack { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 13px 14px;
  background: var(--btn); color: var(--btn-text); font-weight: 600; text-align: center;
}
.btn.secondary { background: var(--section); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn:disabled { opacity: .55; }
.btn:active, .mini:active, .opt:active, .lesson-row:active { transform: scale(.985); }

/* ── профиль ── */
.profile .avatar {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #22c55e); color: #fff; font-weight: 700; font-size: 20px;
}
.profile .name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile .rating { text-align: right; }
.profile .big { font-weight: 700; font-size: 17px; }
.xpbar { height: 8px; background: var(--soft); border-radius: 8px; margin: 12px 0 8px; overflow: hidden; }
.xpfill { height: 100%; border-radius: 8px; background: linear-gradient(90deg, #f5b100, #ff7a00); transition: width .6s; }

/* ── карта ── */
.tier-title { font-weight: 700; font-size: 16px; margin: 16px 4px 8px; }
.tier-arrow { text-align: center; color: var(--hint); margin: 2px 0 -6px; }
.list { padding: 4px 0; }
.lesson-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px;
  background: none; border: 0; text-align: left;
}
.lesson-row + .lesson-row { border-top: 1px solid var(--line); }
.lesson-row.locked { opacity: .5; }
.lesson-num { font-size: 22px; width: 30px; text-align: center; }
.lesson-title { font-weight: 600; }
.lesson-meta { color: var(--hint); white-space: nowrap; }

/* ── урок ── */
.lesson-head { padding: 6px 4px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--section); border-radius: 20px; padding: 3px 10px; font-size: 13px; color: var(--hint); }
.seg {
  display: flex; border-radius: 12px; padding: 3px; margin-bottom: 12px;
  background: linear-gradient(var(--soft), var(--soft)), var(--bg2);  /* непрозрачный: текст под ним не просвечивает */
  position: sticky; top: 0; z-index: 5;
}
.seg button { flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--hint); }
.seg button.active { background: var(--section); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.page .txt { white-space: pre-line; margin: 6px 0; }
.page .txt:first-child { margin-top: 0; }
.txt b { font-weight: 700; }
code { font-family: var(--mono); font-size: .92em; background: var(--soft); padding: 1px 5px; border-radius: 5px; }

/* ── код ── */
.code { margin: 10px 0; border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.code pre, pre.output, .stdout, .mini-pre { margin: 0; font: 13.5px/1.5 var(--mono); overflow-x: auto; white-space: pre; }
.code pre { padding: 12px 14px; color: var(--code-text); }
.code pre code, .code code.hljs { background: none; padding: 0; color: inherit; font-size: inherit; }
pre.output { background: var(--out-bg); color: #b9f6ca; padding: 10px 14px; border-radius: 12px; margin: 10px 0; border-left: 3px solid var(--ok); }
.badge { font-size: 12px; font-weight: 600; padding: 6px 14px 0; }
.badge.bad { color: #ff8a8f; }
.code-bar { display: flex; gap: 8px; padding: 0 10px 10px; }
.mini { border: 0; border-radius: 9px; padding: 6px 12px; font-size: 13px; font-weight: 600; background: rgba(255,255,255,.1); color: #dfe6f0; }
.mini.primary { background: var(--ok); color: #fff; }
.mini:disabled { opacity: .6; }
.code .stdin, .code .out { margin: 0 10px 10px; }
.code .out:empty { display: none; }

/* подсветка (одинаковая в светлой и тёмной теме — фон кода всегда тёмный) */
.hljs-keyword, .hljs-built_in, .hljs-literal { color: #c792ea; }
.hljs-string { color: #c3e88d; }
.hljs-number { color: #f78c6c; }
.hljs-comment { color: #7f8a9e; font-style: italic; }
.hljs-title, .hljs-title.function_ { color: #82aaff; }
.hljs-params { color: #e3e8f1; }
.hljs-meta, .hljs-subst { color: #89ddff; }

/* ── редактор ── */
.editor-wrap { background: var(--code-bg); border-radius: 12px; overflow: hidden; margin: 10px 0; }
.editor {
  display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--code-text);
  font: 14px/1.5 var(--mono); padding: 12px 14px; white-space: pre; overflow-x: auto; tab-size: 4; caret-color: #ffd166;
}
.keybar { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; border-top: 1px solid rgba(255,255,255,.08); scrollbar-width: none; }
.keybar::-webkit-scrollbar { display: none; }
.keybar button {
  flex: none; min-width: 38px; height: 34px; border: 0; border-radius: 8px;
  background: rgba(255,255,255,.1); color: #fff; font: 15px var(--mono);
}
.stdin {
  display: block; width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px;
  background: var(--bg); color: var(--text); font: 13.5px/1.4 var(--mono); resize: vertical;
}
.field-label { font-size: 13px; color: var(--hint); margin: 10px 2px 4px; }

/* ── вывод программы ── */
.out { margin-top: 10px; }
.stdout { background: var(--out-bg); color: #e8f5e9; padding: 10px 12px; border-radius: 10px; max-height: 360px; overflow: auto; }
.err { background: rgba(229, 72, 77, .12); color: var(--text); padding: 10px 12px; border-radius: 10px; margin-top: 8px; font-size: 14px; }
.err b { color: var(--danger); }
.err .hint { margin-top: 6px; color: var(--text); }
.mini-pre { background: var(--soft); padding: 8px 10px; border-radius: 8px; margin: 4px 0 8px; white-space: pre-wrap; }
.okbox { background: rgba(47, 167, 95, .14); padding: 12px; border-radius: 10px; font-weight: 600; }
.task-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.task-tools { display: flex; gap: 14px; justify-content: center; margin-top: 12px; }
.link-btn { background: none; border: 0; color: var(--link); font-size: 14px; padding: 6px; }
.success { text-align: center; border: 2px solid var(--ok); }

/* ── тест ── */
.quiz-head { padding: 4px 4px 12px; }
.qprogress { display: flex; gap: 5px; margin-top: 8px; }
.qprogress span { flex: 1; height: 6px; border-radius: 6px; background: var(--soft); }
.qprogress .cur { background: var(--btn); }
.qprogress .ok { background: var(--ok); }
.qprogress .bad { background: var(--danger); }
.prompt { font-weight: 700; font-size: 17px; margin: 14px 4px 10px; }
.options { display: grid; gap: 8px; }
.opt {
  border: 0; border-radius: 12px; padding: 14px; text-align: left; background: var(--section);
  font: 15px var(--mono); box-shadow: inset 0 0 0 1.5px var(--line); transition: background .2s;
}
.opt.chosen { box-shadow: inset 0 0 0 2px var(--btn); }
.opt.correct { background: rgba(47, 167, 95, .18); box-shadow: inset 0 0 0 2px var(--ok); }
.opt.wrong { background: rgba(229, 72, 77, .15); box-shadow: inset 0 0 0 2px var(--danger); }
.opt.dim { opacity: .5; }
.verdict { margin-top: 12px; }
.verdict.ok b { color: var(--ok); }
.verdict.bad b { color: var(--danger); }
.verdict div { margin-top: 6px; }

.marks { display: flex; justify-content: center; gap: 6px; margin: 10px 0; }
.marks span { width: 14px; height: 14px; border-radius: 50%; background: var(--danger); }
.marks span.ok { background: var(--ok); }
.xp-gain { display: inline-flex; align-items: center; gap: 6px; background: rgba(245, 177, 0, .18); color: #c77a00; font-weight: 700; padding: 6px 14px; border-radius: 20px; margin: 6px 0; }
[data-theme="dark"] .xp-gain { color: #ffc94d; }
.levelup { font-weight: 700; font-size: 17px; margin: 8px 0; }

/* ── рейтинг ── */
.top-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.top-row + .top-row { border-top: 1px solid var(--line); }
.top-row.me { background: var(--soft); }
.top-place { width: 28px; text-align: center; font-weight: 700; }
.top-rating { font-weight: 700; }

.samples { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.samples::-webkit-scrollbar { display: none; }
.samples button { flex: none; border: 0; border-radius: 20px; padding: 6px 12px; background: var(--section); font-size: 13px; box-shadow: inset 0 0 0 1px var(--line); }

/* ── нижнее меню ── */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--section); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
#tabs button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 20px; color: var(--hint); padding: 2px 0; }
#tabs button span { font-size: 11px; font-weight: 600; }
#tabs button.active { color: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(20, 22, 28, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  z-index: 20; max-width: 90vw; text-align: center;
}

/* тёмная тема Telegram: код темнее карточки, активная вкладка заметнее */
/* Вне Telegram переменных --tg-theme-* нет, а тёмная тема нужна: задаём свои запасные цвета.
   Внутри Telegram его значения по-прежнему главнее — они подставляются в var() первыми. */
[data-theme="dark"] {
  --bg: var(--tg-theme-bg-color, #17181c);
  --bg2: var(--tg-theme-secondary-bg-color, #101216);
  --section: var(--tg-theme-section-bg-color, #1c1e23);
  --text: var(--tg-theme-text-color, #f2f4f7);
  --hint: var(--tg-theme-hint-color, #9aa0aa);
  --line: rgba(255, 255, 255, 0.14);
}
[data-theme="dark"] { --code-bg: #0b0f16; --out-bg: #070a0f; --soft: rgba(255, 255, 255, 0.07); }
[data-theme="dark"] .seg button.active { background: rgba(255, 255, 255, 0.14); }


/* ── иконки (Lucide) ── */
.ic { width: 1.15em; height: 1.15em; flex: none; stroke-width: 2.2; vertical-align: -0.2em; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn, .mini, .link-btn, .samples button, .seg button, .badge, .okbox, .err-title, .hint,
.status, .stat, .icon-line, .verdict-title, .tier-title, .xp-gain, .icon-h1 {
  display: inline-flex; align-items: center; gap: 7px;
}
.btn { display: flex; justify-content: center; }
.seg button { justify-content: center; gap: 5px; }
.seg button .ic { width: 1em; height: 1em; }
.stats { display: inline-flex; flex-wrap: wrap; gap: 12px; }
.center-stats { justify-content: center; display: flex; }
.stat .ic { width: 1em; height: 1em; }
.gold { color: #e0a100; }
.profile .big { display: inline-flex; align-items: center; gap: 6px; }

.hero {
  width: 72px; height: 72px; border-radius: 50%; margin: 6px auto 10px; display: grid; place-items: center;
  background: rgba(43, 125, 233, .14); background: color-mix(in srgb, var(--btn) 14%, transparent); color: var(--btn);
}
.hero .ic { width: 36px; height: 36px; }
.hero.ok { background: rgba(47, 167, 95, .15); color: var(--ok); }
.hero.bad { background: rgba(229, 72, 77, .13); color: var(--danger); }
.icon-line { justify-content: center; display: flex; margin: 6px 0; }
.levelup { font-weight: 700; font-size: 17px; }

.page-title { display: flex; align-items: center; gap: 10px; font-size: 18px; margin: 0 0 10px; }
.page-title .ic { width: 22px; height: 22px; color: var(--accent); }
.page .txt .ic { color: var(--accent); }
.spoiler {
  background: var(--hint); color: transparent; border-radius: 5px; padding: 0 4px; cursor: pointer;
  transition: background .2s, color .2s; -webkit-user-select: none; user-select: none;
}
.spoiler.open { background: var(--soft); color: var(--text); }

.lesson-num { display: grid; place-items: center; }
.lesson-num .ic { width: 24px; height: 24px; }
.lesson-num.ok { color: var(--ok); }
.lesson-num.accent { color: var(--accent); }
.lesson-num.muted { color: var(--hint); }
.lesson-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.tier-title .ic { width: 20px; height: 20px; color: var(--accent); }
.tier-arrow { display: flex; justify-content: center; }

.err-title { align-items: flex-start; }
.err-title .ic { color: var(--danger); margin-top: 2px; }
.hint { align-items: flex-start; margin-top: 6px; }
.hint .ic { color: #e0a100; margin-top: 2px; }
.card.hint { display: flex; }
.okbox { display: flex; color: var(--ok); }
.verdict-title .ic { width: 20px; height: 20px; }
.verdict.ok .verdict-title { color: var(--ok); }
.verdict.bad .verdict-title { color: var(--danger); }
.badge.bad { display: flex; }
.keybar button { display: grid; place-items: center; }

.top-place { display: grid; place-items: center; color: var(--hint); }
.top-place .ic { width: 22px; height: 22px; }
.top-place.gold { color: #e0a100; }
.top-place.silver { color: #9aa4b1; }
.top-place.bronze { color: #c47a3a; }
.icon-h1 .ic { width: 24px; height: 24px; }

#tabs button .ic { width: 22px; height: 22px; }

/* ── карта уроков: дорожка из кружков ── */
:root {
  --u0: #58cc02; --u0d: #46a302;   /* зелёный — самое начало */
  --u1: #1cb0f6; --u1d: #1899d6;   /* синий — решения и повторы */
  --u2: #ce82ff; --u2d: #a568cc;   /* фиолетовый — средний уровень */
  --u3: #ff9600; --u3d: #cd7900;   /* оранжевый — продвинутый */
  --u4: #ffc800; --u4d: #d4a600;   /* золотой — финал */
  --node-off: #e5e7eb; --node-offd: #cfd4da; --node-off-ic: #aab0b8;
}
[data-theme="dark"] { --node-off: #2b333d; --node-offd: #1c222a; --node-off-ic: #5f6b78; }

.unit {
  display: flex; align-items: center; gap: 12px; margin: 20px 0 6px; padding: 14px 16px;
  border-radius: 18px; background: var(--uc); color: #fff; box-shadow: 0 4px 0 var(--ud);
}
.unit.locked { background: var(--node-off); color: var(--hint); box-shadow: 0 4px 0 var(--node-offd); }
.unit-icon {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, .22);
}
.unit.locked .unit-icon { background: rgba(127, 127, 127, .12); }
.unit-icon .ic { width: 26px; height: 26px; }
.unit-label { font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.unit-title { font-size: 17px; font-weight: 800; line-height: 1.2; }
.unit-bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .3); margin-top: 7px; overflow: hidden; }
.unit-bar div { height: 100%; border-radius: 6px; background: #fff; }
.unit.locked .unit-bar { background: rgba(127, 127, 127, .15); }
.unit-count { font-weight: 800; font-size: 14px; padding: 4px 10px; border-radius: 20px; background: rgba(255, 255, 255, .22); }

.path { position: relative; padding: 34px 0 6px; }
.roads { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.road { fill: none; stroke-width: 9; stroke-linecap: round; }
.road.done { stroke: var(--uc); opacity: .55; }
.road.todo { stroke: var(--node-off); stroke-dasharray: 1 17; stroke-width: 10; }

.node-row { display: flex; justify-content: center; margin-bottom: 30px; }
.node-row.is-current { padding-top: 34px; }  /* место для облачка «Начать» (padding, а не margin: отступы схлопываются) */
.node-wrap {
  position: relative; display: flex; flex-direction: column; align-items: center; width: 168px;
  transform: translateX(var(--x));
}
.node {
  position: relative; z-index: 1; width: 72px; height: 72px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: var(--uc); color: #fff; box-shadow: 0 6px 0 var(--ud);
  transition: transform .08s, box-shadow .08s;
}
.node .ic { width: 32px; height: 32px; stroke-width: 2.4; }
.node:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ud); }
.node.locked { background: var(--node-off); color: var(--node-off-ic); box-shadow: 0 6px 0 var(--node-offd); }
.node.final { width: 88px; height: 88px; background: var(--u4); box-shadow: 0 7px 0 var(--u4d); }
.node.final.locked { background: var(--node-off); box-shadow: 0 7px 0 var(--node-offd); }
.node.final .ic { width: 40px; height: 40px; }
.node.current::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 4px solid var(--uc);
  animation: ring 1.8s ease-out infinite;
}
@keyframes ring { 0% { transform: scale(.92); opacity: .6; } 100% { transform: scale(1.3); opacity: 0; } }
.node.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

.node-check {
  position: absolute; z-index: 2; top: -4px; left: calc(50% + 20px); width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: #fff; color: var(--ud); box-shadow: 0 2px 0 rgba(0, 0, 0, .12);
}
.node-check .ic { width: 16px; height: 16px; stroke-width: 3.2; }

.bubble {
  position: absolute; z-index: 3; top: -44px; padding: 7px 14px; border-radius: 12px; white-space: nowrap;
  background: var(--section); color: var(--ud); font-weight: 800; font-size: 14px; letter-spacing: .02em;
  box-shadow: 0 0 0 2px var(--line), 0 3px 0 var(--line); animation: bob 1.5s ease-in-out infinite;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px; margin-left: -6px;
  background: var(--section); transform: rotate(45deg); box-shadow: 2px 2px 0 var(--line);
}
@keyframes bob { 50% { transform: translateY(-5px); } }

.node-title {
  position: relative; z-index: 1; margin-top: 12px; padding: 2px 9px; border-radius: 9px; text-align: center;
  font-size: 13.5px; font-weight: 700; line-height: 1.25; background: var(--bg2);
}
.node-row.locked .node-title { color: var(--hint); font-weight: 600; }
.node-meta {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin-top: 3px; padding: 0 7px;
  border-radius: 8px; font-size: 12px; color: var(--hint); background: var(--bg2);
}
.stars { display: inline-flex; gap: 1px; }
.stars .ic { width: 14px; height: 14px; }
.stars .on { color: #ffc800; fill: #ffc800; }
.stars .off { color: var(--node-off-ic); opacity: .6; }

/* шапка урока: иконка темы в кружке цвета раздела */
.lesson-head.with-icon { display: flex; gap: 14px; align-items: flex-start; }
.lesson-badge {
  width: 56px; height: 56px; border-radius: 50%; flex: none; margin-top: 4px; display: grid; place-items: center;
  background: var(--uc); color: #fff; box-shadow: 0 4px 0 var(--ud);
}
.lesson-badge .ic { width: 28px; height: 28px; stroke-width: 2.4; }

/* ── панель снизу ── */
.sheet {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0); transition: background .2s;
}
.sheet.open { background: rgba(0, 0, 0, .45); }
.sheet-panel {
  width: 100%; max-width: 720px; max-height: 86vh; overflow-y: auto; background: var(--section);
  border-radius: 22px 22px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s ease-out;
}
.sheet.open .sheet-panel { transform: none; }
.sheet-grip { width: 42px; height: 5px; border-radius: 5px; background: var(--line); margin: 0 auto 12px; }
.sheet-body.center { text-align: center; }
.sheet-head { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.sheet-head h2 { margin: 2px 0 4px; }
.sheet-label { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--hint); margin: 14px 4px 8px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.sheet-actions .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-actions .two > :only-child { grid-column: span 2; }
.topic-list { display: flex; flex-direction: column; gap: 6px; }
.topic {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 12px;
  background: var(--bg2); text-align: left; font-weight: 600;
}
.topic .ic { color: var(--uc, var(--accent)); }
.topic .ic:last-child { color: var(--hint); }
.topic-num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 800; color: #fff; background: var(--uc, var(--btn));
}
.hero.tier { background: var(--uc); color: #fff; box-shadow: 0 5px 0 var(--ud); }
.lesson-badge.plain { background: var(--btn); box-shadow: none; }
.page.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* ── лобби битвы ── */
.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.topic-tile {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 12px; border: 0; border-radius: 14px;
  background: var(--section); box-shadow: inset 0 0 0 1.5px var(--line); text-align: left; font-weight: 600; font-size: 14px;
}
.topic-tile .ic { color: var(--accent); flex: none; }
.badge-hot {
  position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: #ff5a36; color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center;
}
.icon-line.hot .ic { color: #ff5a36; }
.card.notice { display: flex; gap: 8px; align-items: flex-start; }
.card.notice .ic { color: var(--accent); margin-top: 2px; }
.link-box {
  margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: var(--bg2); font: 13px var(--mono);
  word-break: break-all; user-select: all; -webkit-user-select: all;
}
.hero.radar { position: relative; }
.hero.radar::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--btn);
  animation: ring 1.6s ease-out infinite;
}

/* ── бой ── */
.scoreboard { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fighter { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 38%; text-align: center; }
.fighter .avatar {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
}
.fighter.rival .avatar { background: linear-gradient(135deg, #f97316, #ef4444); }
.fighter-name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pips { display: flex; gap: 4px; margin-top: 4px; }
.pips span { width: 10px; height: 10px; border-radius: 50%; background: var(--soft); box-shadow: inset 0 0 0 1.5px var(--line); }
.fighter.me .pips .on { background: var(--ok); box-shadow: none; }
.fighter.rival .pips .on { background: #ef4444; box-shadow: none; }
.vs { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.vs b { font-size: 26px; font-weight: 800; }
.countdown { font-size: 64px; font-weight: 800; color: var(--accent); line-height: 1.1; margin: 6px 0; }
.tbar-row { display: flex; align-items: center; gap: 10px; margin: 4px 2px 0; }
.tbar { flex: 1; height: 8px; border-radius: 8px; background: var(--soft); overflow: hidden; }
.tfill { height: 100%; width: 100%; border-radius: 8px; background: var(--ok); transition: background .3s; }
.tfill.hurry { background: #ef4444; }
.tsec { font-weight: 700; font-size: 13px; color: var(--hint); min-width: 30px; text-align: right; }
.final-score { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 8px 0; font-weight: 600; }
.final-score b { font-size: 30px; font-weight: 800; }
.link-btn.danger { color: var(--danger); display: flex; margin: 10px auto 0; }

/* ── профиль игрока ── */
button.top-row { width: 100%; border: 0; background: none; text-align: left; font: inherit; color: inherit; }
button.top-row.me { background: var(--soft); }
.card.profile { cursor: pointer; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.avatar.big {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 32px; font-weight: 800;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
}
.pstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.pstat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 12px; background: var(--bg2); text-align: center; }
.pstat .ic { color: var(--accent); }
.pstat b { font-size: 17px; }
.battle-row.won .ic { color: var(--ok); }
.battle-row.lost .ic { color: var(--hint); }

/* ── редактор-компилятор: номера строк ── */
.editor-main { display: flex; align-items: stretch; }
.editor-main .editor { flex: 1; min-width: 0; padding-left: 10px; }
.gutter {
  margin: 0; padding: 12px 8px 12px 10px; min-width: 2.4em; text-align: right; user-select: none; -webkit-user-select: none;
  font: 14px/1.5 var(--mono); color: rgba(255, 255, 255, .28); border-right: 1px solid rgba(255, 255, 255, .08);
}
.compiler-bar {
  display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 9px 14px; border-radius: 12px 12px 0 0;
  background: var(--code-bg); color: rgba(255, 255, 255, .85); font-size: 13px; font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.compiler-bar .ic { width: 18px; height: 18px; color: #ffd166; }
.compiler-bar .muted { margin-left: auto; color: rgba(255, 255, 255, .45); font-weight: 500; }
.compiler .compiler-bar + .editor-wrap { margin-top: 0; border-radius: 0 0 12px 12px; }

/* ── бета-версия ── */
.beta-sup {
  display: inline-block; margin-left: 2px; padding: 0 5px; border-radius: 6px; font-size: .72em; font-weight: 800;
  line-height: 1.45; vertical-align: super; color: #fff; background: linear-gradient(135deg, #ce82ff, #1cb0f6);
}
.ver-chip {
  display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 8px; font-size: 11px; font-weight: 800;
  color: #fff; background: linear-gradient(135deg, #9b5de5, #1cb0f6); vertical-align: 3px;
}
.warn-box {
  display: flex; gap: 10px; text-align: left; margin: 12px 0 2px; padding: 12px 14px; border-radius: 14px;
  background: rgba(255, 150, 0, .12); box-shadow: inset 0 0 0 1.5px rgba(255, 150, 0, .45);
}
.warn-box .ic { color: #ff9600; flex: none; margin-top: 2px; }
.beta-card {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 12px; padding: 12px 14px; border: 0;
  border-radius: 16px; text-align: left; background: var(--section); color: var(--text);
  box-shadow: inset 0 0 0 2px rgba(206, 130, 255, .45);
}
.beta-card > .ic { flex: none; }
.beta-icon {
  width: 42px; height: 42px; flex: none; border-radius: 13px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #ce82ff, #1cb0f6); font-size: 20px;
}
.beta-icon .ic { width: 24px; height: 24px; }
.hero.beta-hero { color: #fff; background: linear-gradient(135deg, #ce82ff, #1cb0f6); font-size: 34px; }
.beta-points { display: flex; flex-direction: column; gap: 2px; margin: 10px auto; max-width: 340px; text-align: left; }
.beta-points .icon-line { justify-content: flex-start; margin: 4px 0; }
.beta-points .icon-line .ic { color: #9b5de5; flex: none; }
.beta-head h2 { margin: 0; }
.beta-id { cursor: pointer; }
.two-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

/* ── карта уроков: граф тем с развилками ── */
.now-chips, .next-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.next-chips { flex-wrap: wrap; overflow: visible; }
.now-chips::-webkit-scrollbar { display: none; }
.now-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 0; border-radius: 20px;
  background: var(--uc); color: #fff; font-weight: 700; font-size: 13px; box-shadow: 0 3px 0 var(--ud);
}
.now-chip .ic { width: 16px; height: 16px; }
.now-chip.static { box-shadow: none; opacity: .92; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 4px 0; font-size: 12px; color: var(--hint); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 14px; height: 14px; border-radius: 50%; background: #1cb0f6; }
.legend-dot.side { width: 10px; height: 10px; margin: 0 2px; background: #58cc02; box-shadow: 0 0 0 2px var(--bg2), 0 0 0 3.5px #58cc02; }
.legend-dot.cross { border-radius: 3px; transform: rotate(45deg) scale(.85); background: #14b8a6; }

.gmap { position: relative; margin: 6px auto 0; max-width: 560px; }
.gedges { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.gedge { fill: none; stroke-width: 8; stroke-linecap: round; transition: opacity .2s; }
.gedge.lit { stroke: var(--uc); opacity: .6; }
.gedge.dim { stroke: var(--node-off); stroke-dasharray: 1 15; stroke-width: 9; }
.gedge.opt { stroke-width: 5; }
.gedge.opt.lit { stroke-dasharray: 9 9; opacity: .75; }
.gedge.any.lit { stroke-dasharray: 14 8; }
.gmap.focus .gedge:not(.hl) { opacity: .12; }
.gmap.focus .gedge.hl { opacity: 1; }
.gmap.focus .gedge.hl.dim { stroke: var(--hint); }

.gnode-wrap {
  position: absolute; z-index: 1; width: var(--tw, 96px); margin-left: calc(var(--tw, 96px) / -2);
  display: flex; flex-direction: column; align-items: center; transition: opacity .2s;
}
.gmap.focus [data-node]:not(.hl) { opacity: .28; }
.gnode {
  position: relative; display: grid; place-items: center; border: 0; padding: 0; background: none; color: #fff;
  width: 56px; height: 56px; margin-top: -28px; border-radius: 50%;
}
.gnode-face {
  position: relative; z-index: 1; width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center;
  background: var(--uc); box-shadow: 0 5px 0 var(--ud); transition: transform .08s, box-shadow .08s;
}
.gnode:active .gnode-face { transform: translateY(3px); box-shadow: 0 2px 0 var(--ud); }
.gnode .ic { width: 26px; height: 26px; stroke-width: 2.4; }
.gnode.locked .gnode-face { background: var(--node-off); color: var(--node-off-ic); box-shadow: 0 5px 0 var(--node-offd); }
.gnode.g-side { width: 46px; height: 46px; margin-top: -23px; }
.gnode.g-side .ic { width: 21px; height: 21px; }
.gnode.g-cross { width: 50px; height: 50px; margin-top: -25px; }
.gnode.g-cross .gnode-face { border-radius: 14px; transform: rotate(45deg); }
.gnode.g-cross .gnode-face .ic { transform: rotate(-45deg); }
.gnode.g-cross:active .gnode-face { transform: rotate(45deg) translate(2px, 2px); }
.gnode.g-final { width: 76px; height: 76px; margin-top: -38px; }
.gnode.g-final .ic { width: 36px; height: 36px; }
/* кольцо прогресса: сколько задач уже решено из нужных */
/* кольцо прогресса: чуть ниже центра — у кружка толстая нижняя тень */
.gnode-ring {
  position: absolute; left: 50%; top: calc(50% + 2px); width: calc(100% + 18px); height: calc(100% + 18px);
  transform: translate(-50%, -50%); pointer-events: none; overflow: visible;
}
.gnode-ring circle { fill: none; stroke-width: 7; }
.ring-track { stroke: var(--node-off); opacity: .65; }
.ring-fill { stroke: var(--uc); transform: rotate(-90deg); transform-origin: 50% 50%; }
.gnode.current::before {
  content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 4px solid var(--uc);
  animation: ring 1.8s ease-out infinite;
}
.gnode.ping .gnode-face { animation: ping .9s ease-out 2; }
.gnode.g-cross.ping .gnode-face { animation: none; }
@keyframes ping { 30% { transform: scale(1.18); } }
.gnode-wrap .node-check { top: -34px; left: calc(50% + 14px); }
.gnode-wrap.g-final .node-check { top: -44px; left: calc(50% + 22px); }
.kind-badge {
  position: absolute; z-index: 2; top: -30px; left: calc(50% - 34px); width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--section); color: var(--uc); box-shadow: 0 0 0 2px var(--uc);
}
.kind-badge .ic { width: 12px; height: 12px; stroke-width: 3; }
.gnode-wrap.locked .kind-badge { color: var(--node-off-ic); box-shadow: 0 0 0 2px var(--node-off); }
.gnode-title {
  margin-top: 10px; padding: 1px 4px; border-radius: 8px; background: var(--bg2); text-align: center;
  font-size: 11px; font-weight: 700; line-height: 1.2; max-width: 100%;
  overflow-wrap: break-word;
}
.gnode-wrap.locked .gnode-title { color: var(--hint); font-weight: 600; }
.gnode-wrap.g-final .gnode-title { font-size: 13px; }
.gnode-meta { margin-top: 1px; padding: 0 6px; border-radius: 6px; background: var(--bg2); font-size: 11px; color: var(--hint); }
.gnode-wrap .bubble { top: -76px; }
.gnode-wrap.g-final .bubble { top: -86px; }

.gjunction {
  position: absolute; z-index: 1; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px;
  white-space: nowrap; padding: 7px 14px; border-radius: 20px; background: var(--section); color: var(--hint);
  box-shadow: 0 0 0 2px var(--line); font-size: 12.5px; font-weight: 800;
}
.gjunction.done { color: var(--text); box-shadow: 0 0 0 2px #1cb0f6; }
.gjunction .ic { width: 16px; height: 16px; }
.gor {
  position: absolute; z-index: 2; transform: translateX(-50%); padding: 1px 7px; border-radius: 8px;
  background: var(--section); box-shadow: 0 0 0 1.5px var(--line); color: var(--hint);
  font-size: 10.5px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap;
}
.gor.static { position: static; transform: none; display: inline-block; }

/* панель темы на карте */
.node-sheet .lesson-badge { margin-top: 0; }
.ok-text { color: var(--ok); font-weight: 700; }
.node-progress { margin: 10px 0 2px; }
.node-progress .xpbar { margin: 6px 0 0; }
.node-progress .xpfill { background: var(--uc); }
.req-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.req-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--hint); font-weight: 600; }
.req-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 12px;
  background: var(--bg2); text-align: left; font-weight: 600; color: var(--text);
}
.req-item .ic { color: var(--hint); flex: none; }
.req-item.ok .ic { color: var(--ok); }
.req-group.choice .req-item { box-shadow: inset 3px 0 0 var(--uc); }
.gmap.compact .gnode { width: 48px; height: 48px; margin-top: -24px; }
.gmap.compact .gnode .ic { width: 22px; height: 22px; }
.gmap.compact .gnode.g-side { width: 40px; height: 40px; margin-top: -20px; }
.gmap.compact .gnode.g-cross { width: 44px; height: 44px; margin-top: -22px; }
.gmap.compact .gnode.g-final { width: 66px; height: 66px; margin-top: -33px; }
.gmap.compact .gnode-title { font-size: 10.5px; }
.gmap.compact .gnode-wrap .node-check { top: -30px; left: calc(50% + 11px); }

/* ── недельная лига ── */
.league-head { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; text-align: left; color: var(--text); }
.league-head h2 { margin: 0; }
.league-badge {
  width: 52px; height: 52px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--uc); color: #fff; box-shadow: 0 4px 0 var(--ud);
}
.league-badge .ic { width: 26px; height: 26px; }
.league-row.up { box-shadow: inset 3px 0 0 var(--ok); }
.league-row.down { box-shadow: inset 3px 0 0 var(--danger); }
.zone-line {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 10px;
  background: rgba(47, 167, 95, .12); color: var(--ok); font-size: 12px; font-weight: 700;
}
.zone-line .ic { width: 14px; height: 14px; }
.card.rules { display: flex; flex-direction: column; gap: 2px; }
.card.rules .icon-line { justify-content: flex-start; text-align: left; font-size: 13.5px; }
.icon-line.up .ic { color: var(--ok); }
.icon-line.down .ic { color: var(--danger); }
.league-chip {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 2px 8px 2px 4px; border-radius: 10px;
  background: var(--bg2); color: var(--text); font-size: 11.5px; font-weight: 800;
}
/* ── приложения вне Telegram (.apk, .dmg, браузер) ── */
.back-fab { position: fixed; z-index: 30; left: 12px; top: calc(12px + env(safe-area-inset-top, 0px));
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: var(--section); color: var(--text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); }
.back-fab .ic { width: 22px; height: 22px; }
body.standalone.inner .screen { padding-top: 58px; }   /* чтобы заголовок не лез под кнопку */


.code-field { display: block; width: 100%; max-width: 230px; margin: 6px auto 0; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--bg2); color: var(--text);
  font: 700 28px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; letter-spacing: 8px; }
.code-field::placeholder { color: var(--hint); letter-spacing: 8px; }
.code-field:focus { outline: none; border-color: var(--accent); }

.entry-card { display: flex; flex-direction: column; gap: 10px; }
.entry-card .row { gap: 12px; align-items: center; }
.entry-icon {
  display: flex; align-items: center; justify-content: center; flex: none; width: 46px; height: 46px;
  border-radius: 14px; background: var(--bg2); color: var(--hint);
}
.entry-icon .ic { width: 22px; height: 22px; }
.league-img { width: 18px; height: 18px; object-fit: contain; }
.league-img.big { width: 56px; height: 56px; flex: none; }

/* ── ударный режим и цель дня ── */
.daily-card {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 12px; padding: 12px 14px; border: 0;
  border-radius: 16px; background: var(--section); color: var(--text); text-align: left;
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.daily-card.done { box-shadow: inset 0 0 0 2px var(--ok); }
.daily-card .xpbar { margin: 6px 0 4px; }
.xpfill.ok { background: var(--ok); }
.daily-flame {
  display: flex; flex-direction: column; align-items: center; gap: 1px; flex: none; width: 46px; padding: 6px 0;
  border-radius: 14px; background: var(--bg2); color: var(--hint); font-size: 13px;
}
.daily-flame.on { background: rgba(255, 150, 0, .14); color: #ff9600; }
.daily-flame .ic { width: 20px; height: 20px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  padding: 9px 14px; border: 0; border-radius: 12px; background: var(--bg2); color: var(--text);
  font-weight: 700; font-size: 14px;
}
.choice.on { background: var(--accent); color: #fff; }

/* ── значки ── */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.badge-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 14px;
  background: var(--bg2); color: var(--hint); font-size: 11px; font-weight: 700; text-align: center; line-height: 1.2;
}
.badge-tile.got { background: rgba(255, 200, 0, .14); color: var(--text); }
.badge-tile .ic { width: 22px; height: 22px; color: var(--hint); }
.badge-tile.got .ic { color: #ffab00; }
.daily-card.task.done { box-shadow: inset 0 0 0 1.5px var(--ok); }
.daily-head { display: flex; flex-direction: column; gap: 6px; }
.daily-head .icon-line { justify-content: flex-start; }

/* подсказка о синтаксической ошибке прямо в редакторе */
.syntax {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; font-size: 12.5px; line-height: 1.35;
  background: rgba(229, 72, 77, .16); color: #ffb3b3; border-top: 1px solid rgba(255, 255, 255, .08);
}
.syntax .ic { width: 15px; height: 15px; flex: none; margin-top: 2px; color: #ff8080; }
.gutter .bad-line { color: #ff8080; font-weight: 800; }

/* график XP по дням */
.xpchart { display: flex; align-items: flex-end; gap: 4px; height: 84px; padding: 6px 2px 0; }
.xpbar-day { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 3px; }
.xpbar-fill { border-radius: 5px 5px 2px 2px; background: var(--soft); }
.xpbar-day.on .xpbar-fill { background: var(--accent); }
.xpbar-label { text-align: center; font-size: 9.5px; color: var(--hint); height: 12px; }
.lesson-num.star { color: #ffab00; }
.star-note { margin-top: 10px; }
.star-note .ic { color: #ffab00; }
.league-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0 4px; }
.league-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 14px;
  background: var(--bg2); font-size: 11.5px; font-weight: 700; line-height: 1.2; opacity: .75;
}
.league-tile.me { opacity: 1; box-shadow: inset 0 0 0 2px var(--accent); }
.league-img.tile { width: 46px; height: 46px; }
.league-you { font-size: 10px; color: var(--accent); font-weight: 800; }
.league-tile.locked { color: var(--hint); gap: 8px; padding: 18px 4px; }
.league-tile.locked .ic { width: 22px; height: 22px; }

/* ══════════════ широкий экран: приложение для компьютера ══════════════
   На телефоне всё остаётся как было — это дополнение, а не переделка.
   Меню переезжает влево, условие задачи встаёт рядом с компилятором,
   а экранная клавиатура со скобками прячется: на компьютере есть настоящая. */
@media (min-width: 900px) {
  :root { --rail: 212px; }
  body { padding-left: var(--rail); }

  #tabs {
    top: 0; right: auto; bottom: 0; width: var(--rail);
    flex-direction: column; justify-content: flex-start; gap: 2px;
    border-top: 0; border-right: 1px solid var(--line);
    padding: 22px 10px calc(22px + env(safe-area-inset-bottom));
  }
  #tabs button {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 14px; border-radius: 12px;
  }
  #tabs button span { font-size: 15px; }
  #tabs button.active { background: var(--soft); }
  #tabs button:hover:not(.active) { background: var(--soft); }

  .screen { max-width: 860px; padding-bottom: 36px; }
  .back-fab { left: calc(var(--rail) + 16px); }
  #toast { left: calc(50% + var(--rail) / 2); bottom: 28px; }
  .keybar { display: none; }              /* скобки и двоеточие набираются с клавиатуры */

  /* две колонки: слева условие, справа то, где работают руками */
  .work { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px; align-items: start; }
  .screen.work, .screen.wide { max-width: 1100px; }
  .work-code .editor { min-height: 240px; }
  /* карточки, добавленные сверху (например, шапка задачи дня), занимают всю ширину */
  .screen.work > :not(.work-text):not(.work-code):not(.work-out) { grid-column: 1 / -1; }
  .work > .work-text { position: sticky; top: 16px; }
  .work .work-code, .work .work-out { min-width: 0; }
  /* пока программу не запускали, правая колонка не должна выглядеть пустой */
  .work-out .out:empty::before, .work-code .out:empty::before {
    content: "Здесь появится вывод программы";
    display: flex; align-items: center; justify-content: center; min-height: 180px;
    border: 1.5px dashed var(--line); border-radius: 12px; color: var(--hint); font-size: 13px;
  }

  /* карту уроков растягивать не надо — она и так рисуется по ширине окна */
  .screen:not(.work) > .gmap { max-width: 720px; margin: 0 auto; }
}

/* совсем широкие окна: колонки не должны разъезжаться до неудобного */
@media (min-width: 1500px) {
  .screen.work, .screen.wide { max-width: 1240px; }
}
