:root {
  --bg: #eef1ec;
  --panel: #ffffff;
  --panel-2: #f6f8f4;
  --ink: #1d2320;
  --muted: #5f6b63;
  --line: #d9dfd6;
  --line-strong: #c3ccc0;
  --accent: #1f7a33;
  --accent-hover: #186629;
  --accent-soft: #e2f1e4;
  --accent-ink: #ffffff;
  --err: #c0322b;
  --err-soft: #fdecea;
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --ok: #1f7a33;
  --ok-soft: #e2f1e4;
  --band: rgba(255, 214, 10, 0.28);
  --cur: rgba(255, 196, 0, 0.55);

  --code-bg: #ffffff;
  --code-kw: #1437a8;
  --code-rb: #0b7a4f;
  --code-num: #a2440c;
  --code-cm: #7d887f;

  /* Рисунок: клетчатая бумага, синий след, зелёная Черепаха */
  --f-bg: #fcfdfa;
  --f-minor: #e4e9e0;
  --f-major: #c8d1c3;
  --f-axis: #4c5750;
  --f-dot: #a3ada5;
  --f-trail: #1b4fd1;
  --f-trail-2: #c0322b;
  --f-trail-3: #7a3fb3;
  --f-in: #1f9d4a;
  --f-on: #e08a00;
  --t-shell: #2e8f47;
  --t-skin: #9ad3a6;
  --t-line: #12351d;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 30, 20, 0.06), 0 2px 10px rgba(20, 30, 20, 0.05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "JetBrains Mono", "DejaVu Sans Mono", Menlo, monospace;
  --code-size: 15px;
  --code-line: 23px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111513;
    --panel: #1a1f1c;
    --panel-2: #20261f;
    --ink: #e5ebe6;
    --muted: #9aa69d;
    --line: #2c342f;
    --line-strong: #3b453e;
    --accent: #3fae5a;
    --accent-hover: #4cc068;
    --accent-soft: #1d3324;
    --accent-ink: #07140b;
    --err: #ff7b72;
    --err-soft: #3a1d1b;
    --warn: #f0b44c;
    --warn-soft: #33290f;
    --ok: #5fd07a;
    --ok-soft: #173020;
    --band: rgba(255, 214, 10, 0.16);
    --cur: rgba(255, 196, 0, 0.38);
    --code-bg: #161a18;
    --code-kw: #8fb3ff;
    --code-rb: #62d6a0;
    --code-num: #f0a36b;
    --code-cm: #7f8b82;
    --f-bg: #151a17;
    --f-minor: #212823;
    --f-major: #333d36;
    --f-axis: #a9b5ac;
    --f-dot: #5b685f;
    --f-trail: #7fa8ff;
    --f-trail-2: #ff8a80;
    --f-trail-3: #c9a0ff;
    --f-in: #4fd07a;
    --f-on: #f0b44c;
    --t-shell: #3fae5a;
    --t-skin: #a8dbb3;
    --t-line: #06140a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111513;
  --panel: #1a1f1c;
  --panel-2: #20261f;
  --ink: #e5ebe6;
  --muted: #9aa69d;
  --line: #2c342f;
  --line-strong: #3b453e;
  --accent: #3fae5a;
  --accent-hover: #4cc068;
  --accent-soft: #1d3324;
  --accent-ink: #07140b;
  --err: #ff7b72;
  --err-soft: #3a1d1b;
  --warn: #f0b44c;
  --warn-soft: #33290f;
  --ok: #5fd07a;
  --ok-soft: #173020;
  --band: rgba(255, 214, 10, 0.16);
  --cur: rgba(255, 196, 0, 0.38);
  --code-bg: #161a18;
  --code-kw: #8fb3ff;
  --code-rb: #62d6a0;
  --code-num: #f0a36b;
  --code-cm: #7f8b82;
  --f-bg: #151a17;
  --f-minor: #212823;
  --f-major: #333d36;
  --f-axis: #a9b5ac;
  --f-dot: #5b685f;
  --f-trail: #7fa8ff;
  --f-trail-2: #ff8a80;
  --f-trail-3: #c9a0ff;
  --f-in: #4fd07a;
  --f-on: #f0b44c;
  --t-shell: #3fae5a;
  --t-skin: #a8dbb3;
  --t-line: #06140a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
code, kbd, pre { font-family: var(--mono); }
code { font-size: 0.92em; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
kbd { font-size: 0.85em; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--panel); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- Кнопки ---------- */

.btn {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  min-height: 34px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--panel-2); border-color: var(--muted); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); border-color: var(--line); }
.btn.small { min-height: 26px; padding: 2px 8px; font-size: 13px; }
.btn.icon { min-width: 34px; padding: 4px 8px; font-size: 16px; line-height: 1; }
.btn[aria-pressed="true"], .btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- Шапка ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; border-radius: var(--radius-sm); }
.brand:hover strong { color: var(--accent); }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.brand-logo { width: 32px; height: 32px; flex: none; }
.brand-logo rect { fill: #1f7a33; }
.brand-logo ellipse { fill: #ffffff; stroke: #10301a; stroke-width: 1.6; }
.brand-logo .logo-leg { fill: #cdeed4; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; }
.brand-text span { font-size: 12.5px; color: var(--muted); }
.modes {
  display: flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  margin-left: auto;
}
.modes button {
  font: inherit;
  font-size: 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.modes button[aria-selected="true"] { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- Раскладка ---------- */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(320px, 0.75fr) minmax(420px, 1.25fr);
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 57px);
}

.side, .pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 0;
  min-width: 0;
}
.side { overflow: auto; padding: 14px; }
.pane { display: flex; flex-direction: column; overflow: hidden; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  flex: none;
}
.spacer { flex: 1; }

/* ---------- Боковая панель: задание ---------- */

.panel { display: flex; flex-direction: column; gap: 14px; }
.panel h1 { font-size: 19px; }
.panel h2 { font-size: 15px; margin-bottom: 2px; }
.panel p { margin: 0; }
.task-picker { display: flex; gap: 6px; }
.task-picker select, .panel select {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-height: 34px;
}
.task-card { display: flex; flex-direction: column; gap: 10px; }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.chip.lvl-1 { background: #e8f3ff; border-color: #c9defa; color: #1b4f8f; }
.chip.lvl-2 { background: #f1ecff; border-color: #dcd1fb; color: #4d2f9c; }
.chip.lvl-3 { background: #fff1dc; border-color: #f5d9a8; color: #7a4a00; }
.chip-score.s2 { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.chip-score.s1 { background: var(--panel-2); border-color: var(--line-strong); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip.lvl-1 { background: #16263a; border-color: #24405f; color: #9cc6ff; }
  :root:not([data-theme="light"]) .chip.lvl-2 { background: #231c3a; border-color: #3a2e62; color: #c4b2ff; }
  :root:not([data-theme="light"]) .chip.lvl-3 { background: #33260f; border-color: #54401a; color: #f3c46e; }
}
:root[data-theme="dark"] .chip.lvl-1 { background: #16263a; border-color: #24405f; color: #9cc6ff; }
:root[data-theme="dark"] .chip.lvl-2 { background: #231c3a; border-color: #3a2e62; color: #c4b2ff; }
:root[data-theme="dark"] .chip.lvl-3 { background: #33260f; border-color: #54401a; color: #f3c46e; }

.task-text p { margin: 0 0 8px; }
.task-text p:last-child { margin-bottom: 0; font-weight: 600; }
.algo {
  margin: 0 0 8px;
  padding: 8px 10px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.rules { font-size: 13.5px; color: var(--muted); }
.rules summary { cursor: pointer; color: var(--ink); }
.rules ul { margin: 6px 0 0; padding-left: 18px; }
.rules li { margin-bottom: 4px; }
.rules b { color: var(--ink); }
.task-actions { display: flex; flex-direction: column; gap: 8px; }

.answer-row { display: flex; align-items: center; gap: 8px; }
.answer-row label { font-weight: 600; }
.answer-row input {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-height: 38px;
}
.answer-row .btn { min-height: 38px; }

.note {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
}
.solution {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--panel-2);
  font-size: 14px;
}
.solution p { margin: 0 0 8px; }
.solution p:last-child { margin-bottom: 0; }
.rows-wrap { max-height: 300px; overflow: auto; margin: 0 0 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.rows { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.rows th, .rows td { padding: 3px 8px; text-align: left; border-top: 1px solid var(--line); white-space: nowrap; }
.rows thead th { border-top: 0; position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 600; }

/* Результат проверки */
.check { display: flex; flex-direction: column; gap: 10px; }
.score {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.score-num { font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.score-num small { font-size: 15px; font-weight: 600; color: var(--muted); }
.score p { margin: 2px 0 0; font-size: 13.5px; }
.score.s2 { background: var(--ok-soft); border-color: var(--ok); }
.score.s2 .score-num { color: var(--ok); }
.score.s1 { background: var(--warn-soft); border-color: var(--warn); }
.score.s0 { background: var(--err-soft); border-color: var(--err); }
.score.s0 .score-num { color: var(--err); }

/* Свободный режим */
.form-block { display: flex; flex-direction: column; gap: 8px; }
.form-block > select { width: 100%; flex: none; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-help { margin: 0; padding-left: 18px; }
.tool-help li { margin-bottom: 4px; }
.tool-help b { color: var(--ink); }
.platform-note { display: none; }

/* ---------- Панель программы ---------- */

.speed { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.speed input { width: 90px; accent-color: var(--accent); }
.code-note {
  flex: none;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

/* ---------- Редактор ---------- */

.editor-host { flex: 1; min-height: 0; display: flex; }
.editor { flex: 1; min-width: 0; display: flex; background: var(--code-bg); }
.editor-scroll { flex: 1; overflow: auto; position: relative; }
.editor-body {
  position: relative;
  display: flex;
  min-height: 100%;
  font-family: var(--mono);
  font-size: var(--code-size);
  line-height: var(--code-line);
  padding: 8px 0 40px;
}
.editor-band {
  position: absolute;
  left: 0;
  right: 0;
  top: 8px;
  height: var(--code-line);
  background: var(--band);
  border-left: 3px solid #e0b400;
  pointer-events: none;
  z-index: 0;
}
.editor-gutter {
  flex: none;
  width: 44px;
  text-align: right;
  padding-right: 10px;
  color: var(--code-cm);
  user-select: none;
  font-size: 13px;
  position: relative;
  z-index: 1;
}
.editor-gutter > div { height: var(--code-line); }
.editor-gutter .has-error { color: var(--err); font-weight: 700; }
.editor-code { position: relative; flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; z-index: 1; }
.editor-stack { position: relative; width: max-content; min-width: 100%; }
.editor-hl, .editor-input {
  font: inherit;
  line-height: inherit;
  tab-size: 2;
  margin: 0;
  padding: 0 12px 0 4px;
  white-space: pre;
  border: 0;
  letter-spacing: 0;
}
.editor-hl { color: var(--ink); pointer-events: none; }
.editor-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
  outline: none;
}
.editor-input::selection { background: rgba(60, 130, 255, 0.28); color: transparent; }
.editor.is-readonly .editor-input { caret-color: transparent; }
.t-kw { color: var(--code-kw); font-weight: 700; }
.t-rb { color: var(--code-rb); }
.t-num { color: var(--code-num); }
.t-cm { color: var(--code-cm); font-style: italic; }
.t-cur { background: var(--cur); }
.t-errline { text-decoration: underline wavy var(--err); text-decoration-skip-ink: none; text-underline-offset: 4px; }

/* ---------- Сообщения ---------- */

.console { flex: none; height: 150px; border-top: 1px solid var(--line); display: flex; flex-direction: column; }
.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 10px;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.log { flex: 1; overflow: auto; padding: 6px 10px; font-size: 13.5px; }
.log > div { padding: 2px 0; overflow-wrap: anywhere; }
.log .l-err { color: var(--err); }
.log .l-ok { color: var(--ok); font-weight: 600; }
.log .l-warn { color: var(--warn); }
.log .line-link {
  font: inherit;
  color: inherit;
  text-decoration: underline;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------- Рисунок ---------- */

.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg button {
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--panel);
  border: 0;
  padding: 6px 11px;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.field-status, .points-result {
  flex: none;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.field-status { min-height: 32px; }
.field-status b, .points-result b { color: var(--ink); }
.field-status .bad, .points-result .bad { color: var(--err); font-weight: 600; }
.points-result { background: var(--panel-2); font-size: 13.5px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.dot-in { background: var(--f-in); }
.dot-on { border: 3px solid var(--f-on); }

.field-host {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--f-bg);
}
.field-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; user-select: none; }
.field-svg:active { cursor: grabbing; }
/* Пока масштаб подобран автоматически, палец прокручивает страницу; после «+» и «−» — двигает рисунок */
.field-host.is-zoomed .field-svg { touch-action: none; }

.g-bg { fill: var(--f-bg); }
.g-minor { stroke: var(--f-minor); stroke-width: 1; fill: none; shape-rendering: crispEdges; }
.g-major { stroke: var(--f-major); stroke-width: 1; fill: none; shape-rendering: crispEdges; }
.g-dot { stroke: var(--f-dot); stroke-width: 2.6; stroke-linecap: round; fill: none; }
.g-axis { stroke: var(--f-axis); stroke-width: 1.5; fill: none; shape-rendering: crispEdges; }
.g-arrow { fill: var(--f-axis); }
.g-label, .g-coord {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  paint-order: stroke;
  stroke: var(--f-bg);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}
.g-coord { font-size: 12px; fill: var(--ink); stroke-width: 4px; }
.f-trail { fill: none; stroke: var(--f-trail); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.f-trail.fig-1 { stroke: var(--f-trail-2); }
.f-trail.fig-2 { stroke: var(--f-trail-3); }
.p-in { fill: none; stroke: var(--f-in); stroke-linecap: round; }
.p-on-ring { fill: none; stroke: var(--f-on); stroke-linecap: round; }
.p-on { fill: none; stroke: var(--f-bg); stroke-linecap: round; }

.turtle { opacity: 0.93; pointer-events: none; }
.t-shell { fill: var(--t-shell); stroke: var(--t-line); stroke-width: 1.5; }
.t-head, .t-leg { fill: var(--t-skin); stroke: var(--t-line); stroke-width: 1.2; }
.t-tail { fill: none; stroke: var(--t-line); stroke-width: 2.4; stroke-linecap: round; }
.t-mark { fill: var(--t-line); opacity: 0.45; }
.t-center { fill: #ffffff; stroke: var(--t-line); stroke-width: 1; }
.turtle.is-up .t-shell { fill: var(--t-skin); stroke-dasharray: 3 2; }

/* ---------- Справка ---------- */

.help {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.help::backdrop { background: rgba(10, 20, 12, 0.45); }
.help-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.help-body { padding: 4px 18px 20px; }
.help-body h3 { font-size: 15.5px; margin: 18px 0 8px; }
.help-body p { margin: 6px 0; }
.help-body table { border-collapse: collapse; width: 100%; font-size: 14px; }
.help-body td { border-top: 1px solid var(--line); padding: 6px 8px 6px 0; vertical-align: top; }
.help-body td:first-child { width: 38%; }
.help-body pre.code {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  overflow: auto;
  margin: 10px 0 6px;
}
.help-body ul { padding-left: 20px; margin: 6px 0; }
.help-body li { margin-bottom: 4px; }

/* ---------- Адаптивность ---------- */

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    grid-template-rows: auto 600px;
    height: auto;
    flex: none;
  }
  .side { grid-column: 1 / -1; overflow: visible; min-height: auto; }
  #panel-tasks {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
    grid-template-areas:
      "picker actions"
      "card actions"
      "card check"
      "card hint"
      "card sol";
    grid-template-rows: auto auto auto auto 1fr;
    align-items: start;
    column-gap: 16px;
  }
  .task-picker { grid-area: picker; }
  .task-card { grid-area: card; }
  .task-actions { grid-area: actions; }
  #check-result { grid-area: check; }
  #hint { grid-area: hint; }
  #solution { grid-area: sol; }
  .pane { min-height: 520px; }
}

@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .brand-text span { display: none; }
  .modes { margin-left: 0; order: 3; width: 100%; }
  .modes button { flex: 1; }
  .link-12 { margin-left: auto; }
  .link-12 span:not(.lw), .link-9 span:not(.lw) { display: none; }
  .layout { display: flex; flex-direction: column; padding: 8px; gap: 8px; height: auto; flex: none; }
  .layout > * { flex: none; }
  .side { padding: 12px; overflow: visible; }
  #panel-tasks { display: flex; align-items: stretch; }
  .pane { min-height: 0; overflow: visible; }
  .pane-field { order: 2; }
  .pane-code { order: 3; }
  .pane-code .editor-host { height: 190px; flex: none; }
  .field-host { flex: none; height: clamp(300px, 92vw, 520px); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
  .seg button { padding: 6px 9px; }
  .speed input { width: 70px; }
  .console { height: 130px; }
}

@media (max-width: 520px) {
  .lw { display: none; }
  .topbar { gap: 8px; }
  .topbar .btn { padding: 6px 8px; }
  .points-bar .btn, .points-bar .seg button { font-size: 13px; }
}

/* Внутри платформы репетитора готовое решение не показываем: балл идёт в домашнее задание.
   По той же причине в свободном режиме не считаются точки: это был бы готовый ответ к любому заданию. */
.in-platform #btn-solution, .in-platform #solution { display: none !important; }
.in-platform body[data-mode="sandbox"] #points-bar,
.in-platform body[data-mode="sandbox"] .tool-help { display: none !important; }
.in-platform .platform-note { display: block; }

/* ---------- Школьный режим (?school): полоса с кнопкой «Начать с чистого листа» ---------- */
.school-bar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 12px;
  padding: 6px 12px;
  background: #fff4d6;
  color: #5a4300;
  border-bottom: 1px solid #e6c766;
  font-size: 13px;
  line-height: 1.3;
}

.school-reset {
  font: inherit;
  font-weight: 600;
  padding: 4px 12px;
  border: 1px solid #b98a00;
  border-radius: 6px;
  background: #fff;
  color: #5a4300;
  cursor: pointer;
}

.school-reset:hover {
  background: #ffe9a8;
}
