:root {
  /* light app */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-ring: rgba(79, 70, 229, 0.18);
  --ok: #12b76a;
  --ok-text: #067647;
  --ok-soft: #ecfdf3;
  --bad: #f04438;
  --bad-soft: #fef3f2;
  --flame: #f97316;

  /* dark work area */
  --ed-bg: #0d1117;
  --ed-panel: #0a0d12;
  --ed-raised: #161b22;
  --ed-border: #21262d;
  --ed-border-strong: #30363d;
  --ed-text: #e6edf3;
  --ed-muted: #8b949e;
  --ed-gutter: #484f58;
  --ed-gutter-active: #8b949e;
  --ed-active: rgba(110, 118, 129, 0.1);
  --ed-selection: rgba(56, 139, 253, 0.3);
  --ed-bracket: rgba(56, 139, 253, 0.25);
  --ed-caret: #e6edf3;
  --ed-ok: #3fb950;
  --ed-bad: #f85149;
  --ed-accent: #6366f1;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --topbar: 56px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.icon { width: 18px; height: 18px; flex: none; }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- syntax colors (editor + lesson code) ---------- */
.tk-kw { color: #ff7b72; }
.tk-str { color: #a5d6ff; }
.tk-num { color: #79c0ff; }
.tk-com { color: #8b949e; font-style: italic; }
.tk-fn, .tk-def { color: #d2a8ff; }
.tk-cls { color: #ffa657; }
.tk-prop { color: #79c0ff; }
.tk-op { color: #ff7b72; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -0.01em; }
.logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff;
  font: 700 13px/1 var(--mono);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 14px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--border-strong); }
.crumbs .here { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-arrows { display: flex; align-items: center; gap: 4px; margin-right: 4px; }
.nav-arrows .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: center; }
.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff4ed;
  color: #c4320a;
  font-weight: 700;
  font-size: 14px;
}
.streak-chip .icon { width: 16px; height: 16px; color: var(--flame); }
.streak-chip.off { background: var(--surface-2); color: var(--muted); }
.streak-chip.off .icon { color: var(--muted); }
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: 42px;
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.12);
}
.menu .who { padding: 8px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu .who strong { display: block; color: var(--text); font-size: 14px; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; color: var(--text); font-size: 14px; text-decoration: none; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }

/* ---------- sign in ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, 0.08);
}
.auth-card .logo { width: 44px; height: 44px; border-radius: 12px; font-size: 17px; margin-bottom: 20px; text-decoration: none; }
.auth-buttons { display: grid; gap: 10px; margin-bottom: 8px; }
.brand-logo { display: inline-flex; width: 22px; height: 22px; }
.brand-logo svg { width: 100%; height: 100%; }
.btn-telegram { background: #2aabee; border-color: #2aabee; color: #fff; }
.btn-telegram:hover { background: #229ed9; border-color: #229ed9; }
.btn-google { background: #fff; }
.btn-ghost-bordered { background: transparent; color: var(--text-2); border-style: dashed; }
.btn.loading { opacity: 0.75; cursor: progress; }
.auth-card h1 { font-size: 24px; line-height: 1.25; letter-spacing: -0.02em; margin: 0 0 6px; }
.auth-card .lead { color: var(--text-2); margin: 0 0 24px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.field input.pin { letter-spacing: 0.5em; font-family: var(--mono); }
.form-error { min-height: 22px; margin: -4px 0 12px; color: var(--bad); font-size: 14px; }
.auth-note { margin: 16px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- dashboard ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.hero { display: flex; align-items: center; gap: 32px; padding: 28px 32px; margin-bottom: 24px; }
.hero-main { flex: 1; min-width: 0; }
.hero h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 6px; }
.hero .sub { color: var(--text-2); margin: 0 0 18px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.4s ease; }
.hero .progress { max-width: 420px; }
.hero-meta { margin-top: 8px; font-size: 13px; color: var(--muted); }
.hero-next { flex: none; text-align: right; }
.hero-next .label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.hero-next .title { font-weight: 600; margin-bottom: 12px; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.stack { display: grid; gap: 24px; }

.chapter { padding: 8px; }
.chapter-head { display: flex; align-items: center; gap: 16px; padding: 14px 14px 12px; }
.chapter-head .num { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.chapter-head h2 { font-size: 18px; letter-spacing: -0.01em; margin: 0; }
.chapter-head .meta { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); min-width: 110px; }
.chapter-head .meta .progress { height: 6px; margin-top: 6px; }
.lesson-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s;
}
.lesson-row:hover { background: var(--surface-2); }
.lesson-row .n { width: 28px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson-row .t { font-weight: 500; }
.lesson-row .tags { margin-left: auto; display: flex; gap: 6px; }
.lesson-row.current { background: var(--accent-soft); }
.lesson-row.current .t { color: var(--accent); font-weight: 600; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.status { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 2px solid var(--border-strong); }
.status.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.status.done .icon { width: 13px; height: 13px; stroke-width: 3; }
.status.current { border-color: var(--accent); box-shadow: inset 0 0 0 4px #fff; background: var(--accent); }

.side-card { padding: 20px; }
.side-card h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 0 0 14px; }
.side-card h3 .icon { color: var(--muted); }
.streak-big { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.streak-big strong { font-size: 32px; line-height: 1; letter-spacing: -0.02em; }
.streak-big span { color: var(--text-2); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week .d { font-size: 11px; color: var(--muted); }
.week .dot { height: 28px; border-radius: 8px; background: var(--surface-2); margin-top: 4px; display: grid; place-items: center; }
.week .dot.on { background: #fff4ed; color: var(--flame); }
.week .dot.on .icon { width: 14px; height: 14px; }
.week .dot.today { box-shadow: inset 0 0 0 2px var(--border-strong); }
.skill { margin-bottom: 14px; }
.skill:last-child { margin-bottom: 0; }
.skill-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.skill-top .lvl { color: var(--muted); font-size: 13px; }
.skill .progress { height: 6px; }
.skill .progress > div { background: linear-gradient(90deg, #818cf8, #4f46e5); }
.review-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--text); text-decoration: none; border-top: 1px solid var(--border); font-size: 14px; }
.review-row:first-of-type { border-top: 0; }
.review-row .why { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.empty-note { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- lesson page ---------- */
.lesson-page { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.lesson-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 45%) minmax(0, 1fr); }
.mobile-tabs { display: none; }

.lesson-pane { overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); }
.lesson-inner { max-width: 660px; margin: 0 auto; padding: 32px 40px 64px; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 8px; }
.lesson-inner h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 12px; }
.lesson-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 24px; }
.lesson-done { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ok-text); background: var(--ok-soft); padding: 2px 10px; border-radius: 99px; }
.lesson-done .icon { width: 14px; height: 14px; }

.md { font-size: 16px; line-height: 1.7; color: #1d2939; }
.md p { margin: 0 0 16px; }
.md h3 { font-size: 18px; margin: 28px 0 10px; }
.md ul, .md ol { margin: 0 0 16px; padding-left: 22px; }
.md li { margin-bottom: 6px; }
.md code { font-family: var(--mono); font-size: 0.86em; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: #b42318; }
.md strong { font-weight: 650; }
.md-code { margin: 0 0 16px; padding: 16px 18px; border-radius: 12px; background: var(--ed-bg); color: var(--ed-text); font: 14px/1.6 var(--mono); overflow-x: auto; }
.md-code code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.md-output { margin: -8px 0 16px; border: 1px solid var(--border); border-radius: 12px; background: #fafbfc; overflow: hidden; }
.md-output-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px 14px 0; }
.md-output pre { margin: 0; padding: 4px 14px 12px; font: 14px/1.6 var(--mono); color: var(--text); white-space: pre-wrap; }
.md-code + .md-output { margin-top: -8px; }
.md-tip { display: flex; gap: 10px; margin: 0 0 16px; padding: 14px 16px; border-radius: 12px; background: #f5f7ff; border: 1px solid #e0e5ff; font-size: 15px; line-height: 1.6; color: #27306b; }
.md-tip::before { content: "💡"; flex: none; }
.md-table { margin: 0 0 16px; overflow-x: auto; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.md th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
.md-task { margin: 32px 0 0; padding: 20px 22px 6px; border-radius: 14px; background: linear-gradient(180deg, #f5f5ff, #fbfbff); border: 1px solid #dfe1ff; }
.md-task h2 { display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); margin: 0 0 12px; }
.md-task h2::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.md-task .md-output { background: #fff; }
.to-code { display: none; }

/* work area */
.work-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--ed-bg); color: var(--ed-text); }
.ed-wrap { flex: 1 1 auto; min-height: 140px; display: flex; flex-direction: column; }
.ed-head { flex: none; display: flex; align-items: center; height: 42px; padding: 0 8px 0 0; border-bottom: 1px solid var(--ed-border); background: var(--ed-panel); }
.file-tab { display: flex; align-items: center; gap: 8px; height: 100%; padding: 0 16px; font: 13px var(--mono); color: var(--ed-text); background: var(--ed-bg); border-right: 1px solid var(--ed-border); box-shadow: inset 0 2px 0 var(--ed-accent); }
.file-tab .py { color: #ffd43b; }
.ed-head .spacer { flex: 1; }
.btn-dark-ghost { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ed-muted); font-size: 13px; cursor: pointer; }
.btn-dark-ghost:hover { background: var(--ed-raised); color: var(--ed-text); }
.btn-dark-ghost .icon { width: 15px; height: 15px; }
.editor-host { flex: 1; min-height: 0; overflow: hidden; }
.editor-host .cm-editor { height: 100%; }

.stdin { flex: none; border-top: 1px solid var(--ed-border); background: var(--ed-panel); padding: 10px 14px; }
.stdin label { display: flex; align-items: baseline; gap: 8px; font-size: 12px; color: var(--ed-muted); margin-bottom: 6px; }
.stdin label strong { color: var(--ed-text); font-weight: 600; }
.stdin textarea {
  display: block;
  width: 100%;
  min-height: 34px;
  max-height: 110px;
  resize: vertical;
  padding: 6px 10px;
  font: 13px/1.5 var(--mono);
  color: var(--ed-text);
  background: var(--ed-bg);
  border: 1px solid var(--ed-border-strong);
  border-radius: 8px;
}
.stdin textarea:focus { outline: none; border-color: var(--ed-accent); }

.keys { display: none; }

.actions { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--ed-border); background: var(--ed-panel); }
.actions .btn { height: 38px; }
.btn-run { background: var(--ed-raised); border-color: var(--ed-border-strong); color: var(--ed-text); }
.btn-run:hover { background: #1f2630; }
.btn-check { background: var(--ed-accent); border-color: var(--ed-accent); color: #fff; }
.btn-check:hover { background: #5458ea; }
.actions .hint { margin-left: auto; font-size: 12px; color: var(--ed-muted); }
.actions kbd { font: 11px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--ed-border-strong); color: var(--ed-muted); }

.out-panel { flex: 0 0 38%; min-height: 160px; display: flex; flex-direction: column; border-top: 1px solid var(--ed-border); background: var(--ed-panel); }
.out-tabs { flex: none; display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 8px; border-bottom: 1px solid var(--ed-border); }
.out-tab { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ed-muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.out-tab .icon { width: 15px; height: 15px; }
.out-tab.active { background: var(--ed-raised); color: var(--ed-text); }
.out-tab .badge { font-size: 11px; padding: 0 6px; border-radius: 99px; background: var(--ed-border-strong); color: var(--ed-text); }
.out-tab .badge.ok { background: rgba(63, 185, 80, 0.2); color: var(--ed-ok); }
.out-tab .badge.bad { background: rgba(248, 81, 73, 0.18); color: var(--ed-bad); }
.out-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; }
.console { margin: 0; font: 14px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--ed-text); }
.placeholder-dark { color: var(--ed-muted); font-size: 14px; margin: 0; }
.running { display: flex; align-items: center; gap: 10px; color: var(--ed-muted); font-size: 14px; }

.summary + .err-card { margin: 0 0 12px; }
.err-card { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: rgba(248, 81, 73, 0.08); border: 1px solid rgba(248, 81, 73, 0.35); }
.err-card .title { font-weight: 600; color: #ffa198; margin-bottom: 4px; }
.err-card .title .line { color: var(--ed-muted); font-weight: 500; }
.err-card p { margin: 0 0 6px; color: var(--ed-text); font-size: 14px; }
.err-card .raw { font: 12px var(--mono); color: var(--ed-muted); }
.err-card code, .test code { font-family: var(--mono); font-size: 0.9em; padding: 1px 5px; border-radius: 5px; background: var(--ed-raised); }

.success { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding: 14px 16px; border-radius: 12px; background: rgba(63, 185, 80, 0.1); border: 1px solid rgba(63, 185, 80, 0.4); animation: pop 0.35s ease; }
.success .big { font-size: 26px; }
.success strong { display: block; color: #7ee787; }
.success span { color: var(--ed-muted); font-size: 14px; }
.success .btn { margin-left: auto; background: #238636; border-color: #2ea043; color: #fff; }
.success .btn:hover { background: #2ea043; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }

.summary { font-size: 13px; color: var(--ed-muted); margin: 0 0 10px; }
.test { border: 1px solid var(--ed-border); border-radius: 10px; margin-bottom: 8px; background: var(--ed-bg); overflow: hidden; }
.test-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 14px; }
.test-head .mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.test-head .mark .icon { width: 12px; height: 12px; stroke-width: 3; }
.test.ok .mark { background: rgba(63, 185, 80, 0.18); color: var(--ed-ok); }
.test.bad .mark { background: rgba(248, 81, 73, 0.18); color: var(--ed-bad); }
.test.bad { border-color: rgba(248, 81, 73, 0.35); }
.test-head .name { font-family: var(--mono); font-size: 13px; }
.test-head .name.plain { font-family: var(--font); font-size: 14px; }
.test-body { padding: 0 12px 12px 42px; font-size: 14px; }
.test-body p { margin: 0 0 8px; color: var(--ed-text); }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cmp div { min-width: 0; }
.cmp .cap { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ed-muted); margin-bottom: 4px; }
.cmp pre { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--ed-panel); border: 1px solid var(--ed-border); font: 13px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; min-height: 34px; }
.cmp .want pre { border-color: rgba(63, 185, 80, 0.35); }
.cmp .have pre { border-color: rgba(248, 81, 73, 0.35); }

/* ---------- phones and small tablets ---------- */
@media (max-width: 999px) {
  .dash-grid { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: stretch; gap: 20px; }
  .hero-next { text-align: left; }
  .crumbs .course, .crumbs .sep, .nav-arrows .count { display: none; }

  .mobile-tabs {
    display: flex;
    flex: none;
    gap: 4px;
    padding: 6px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .mobile-tabs button { flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-weight: 600; font-size: 14px; cursor: pointer; }
  .mobile-tabs button.active { background: var(--accent-soft); color: var(--accent); }
  .mobile-tabs .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
  .mobile-tabs .dot.ok { background: var(--ok); }
  .mobile-tabs .dot.bad { background: var(--bad); }

  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-pane { border-right: 0; }
  .lesson-inner { padding: 20px 16px 40px; }
  .lesson-inner h1 { font-size: 24px; }
  .lesson-layout[data-view="task"] .work-pane { display: none; }
  .lesson-layout:not([data-view="task"]) .lesson-pane { display: none; }
  .lesson-layout[data-view="code"] .out-panel { display: none; }
  .lesson-layout[data-view="result"] .ed-wrap { display: none; }
  .lesson-layout[data-view="result"] .out-panel { flex: 1; }
  .to-code { display: flex; margin-top: 20px; }
  .actions .hint { display: none; }
  .actions .btn { flex: 1; }

  .keys { display: flex; flex: none; gap: 6px; padding: 8px 10px; overflow-x: auto; background: var(--ed-panel); border-top: 1px solid var(--ed-border); scrollbar-width: none; }
  .keys button { flex: none; min-width: 40px; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--ed-border-strong); background: var(--ed-raised); color: var(--ed-text); font: 15px var(--mono); }
  .cmp { grid-template-columns: 1fr; }
  .test-body { padding-left: 12px; }
  .md { font-size: 16px; }
}

@media (max-width: 560px) {
  .page { padding: 20px 14px 48px; }
  .hero { padding: 22px 20px; }
  .hero h1 { font-size: 24px; }
  .lesson-row .tags { display: none; }
  .topbar { padding: 0 12px; gap: 10px; }
  .brand .name { display: none; }
}
