:root {
  /* тёмная тема (по умолчанию) */
  --bg: #0a0e14;
  --panel: #111823;
  --panel-2: #182230;
  --panel-3: #232f40;
  --panel-on: #1d2330;
  --panel-bad: #231a1c;
  --inset: #0c121a;
  --line: #2a3747;
  --line-2: #5a6b82;
  --wire: #3d4b5e;
  --dot: #223043;
  --text: #e9eff7;
  --text-2: #cfd8e4;
  --muted: #93a1b5;
  --on: #ffc83d;
  --on-text: #ffc83d;
  --on-soft: rgba(255, 200, 61, .16);
  --on-ink: #1c1503;
  --flow: #fff6d6;
  --ok: #4ade80;
  --bad: #ff7b72;
  --bad-text: #ffb4ae;
  --and: #5eead4;
  --or: #b39dfa;
  --not: #fb8fa4;
  --xor: #7cb7ff;
  --bar-bg: rgba(10, 14, 20, .94);
  --shadow: rgba(0, 0, 0, .5);
  --dim: rgba(5, 8, 12, .5);
  --dim-2: rgba(5, 8, 12, .7);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #edf0f4;
  --panel-3: #e1e6ed;
  --panel-on: #fff3d1;
  --panel-bad: #fde6e6;
  --inset: #e6eaf0;
  --line: #d8dde5;
  --line-2: #98a5b6;
  --wire: #b3bcc8;
  --dot: #d6dbe3;
  --text: #121924;
  --text-2: #344152;
  --muted: #5d6a7c;
  --on: #f5a400;
  --on-text: #9a5a00;
  --on-soft: rgba(245, 164, 0, .17);
  --on-ink: #1c1503;
  --flow: #ffffff;
  --ok: #15a34a;
  --bad: #dc2626;
  --bad-text: #b91c1c;
  --and: #0d9488;
  --or: #7c3aed;
  --not: #e11d48;
  --xor: #2563eb;
  --bar-bg: rgba(255, 255, 255, .94);
  --shadow: rgba(20, 30, 50, .18);
  --dim: rgba(20, 30, 50, .32);
  --dim-2: rgba(20, 30, 50, .5);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

[hidden] { display: none !important; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
#view { flex: 1 1 auto; min-width: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------- шапка и вкладки ---------- */
.top {
  height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .2px; font-size: 17px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--on);
  box-shadow: 0 0 10px var(--on), 0 0 2px #fff inset;
}
.top-right { display: flex; align-items: center; gap: 8px; }
.lang {
  min-width: 44px; height: 34px; padding: 0 10px;
  border-radius: 11px; border: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.lang:active { background: var(--panel-2); }
.chip {
  height: 34px; padding: 0 10px 0 4px; border-radius: 17px;
  border: 1px solid var(--line); background: var(--panel);
  display: flex; align-items: center; gap: 6px; font-size: 13px;
}
.chip b { color: var(--on-text); font-weight: 800; }
.chip span:last-child { color: var(--muted); }
.ava {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--on-ink); font-weight: 800; font-size: 13px;
}
.ava.big { width: 64px; height: 64px; font-size: 28px; }

.tabs {
  position: sticky; bottom: 0; z-index: 5; flex: none;
  display: flex; background: var(--bar-bg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11.5px; font-weight: 700;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.cur { color: var(--on-text); }
body.in-lesson .top, body.in-lesson .tabs { display: none; }

/* ---------- страницы: карта, словарь, профиль ---------- */
.page { padding: 6px 14px 24px; display: flex; flex-direction: column; gap: 14px; }
.kicker { color: var(--on-text); font-size: 12px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.note { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }

.hero {
  border: 1px solid var(--line); border-radius: 22px; padding: 18px 16px 16px;
  background: radial-gradient(120% 90% at 100% 0%, rgba(255, 200, 61, .13), transparent 60%), var(--panel);
}
.hero h1 { margin: 6px 0 8px; font-size: 25px; line-height: 1.14; font-weight: 800; }
.hero p { margin: 0 0 14px; font-size: 14.5px; line-height: 1.45; color: var(--text-2); }
.miles { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.miles li { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 700; color: var(--muted); }
.miles .n {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
}
.miles li.cur { color: var(--text); }
.miles li.cur .n { border-color: var(--on); color: var(--on-text); }
.miles li.done { color: var(--text); }
.miles li.done .n { border-color: transparent; background: rgba(74, 222, 128, .15); color: var(--ok); }

.sec { border: 1px solid var(--line); border-radius: 22px; padding: 16px 14px 14px; background: var(--panel); display: flex; flex-direction: column; }
.sec-head { display: flex; align-items: center; gap: 8px; }
.sec-n { font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.sec-count { margin-left: auto; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tag { font-size: 10.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; padding: 3px 7px; border-radius: 7px; }
.tag.free { color: var(--ok); background: rgba(74, 222, 128, .12); }
.tag.paid { color: var(--on-text); background: var(--on-soft); }
.sec h2 { margin: 8px 0 4px; font-size: 19px; line-height: 1.2; font-weight: 800; }
.sec-goal { margin: 0 0 10px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--inset); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--ok); transition: width .5s ease; }
.bar.big { height: 10px; border-radius: 5px; }
.bar.big i { background: var(--on); border-radius: 5px; }
.rows { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.sec .btn.ghost { margin-top: 12px; }
.row {
  min-height: 52px; padding: 8px 12px; border-radius: 15px; border: 1.5px solid transparent;
  background: var(--panel-2); display: flex; align-items: center; gap: 11px;
}
.row .st {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800;
  border: 1.5px solid var(--line); color: var(--muted);
}
.row .st svg { width: 13px; height: 13px; }
.row .nm { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; line-height: 1.25; }
.row .meta { flex: none; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.row.done .st { border-color: transparent; background: rgba(74, 222, 128, .15); color: var(--ok); }
.row.open { border-color: var(--on); background: var(--panel-on); }
.row.open .st { border-color: var(--on); background: var(--on); color: var(--on-ink); }
.row.open .meta { color: var(--on-text); }
.row.locked .nm, .row.soon .nm { color: var(--muted); }
.row.soon { background: transparent; border: 1.5px dashed var(--line); }
.lock { flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; width: 14px; height: 14px; }
.play { fill: currentColor; }

.page-head h1 { margin: 6px 0 4px; font-size: 25px; font-weight: 800; }
.page-head p { margin: 0; color: var(--muted); font-size: 14.5px; }
.terms { display: flex; flex-direction: column; gap: 8px; }
.term { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; background: var(--panel); }
.term h3 { margin: 0 0 4px; font-size: 16px; font-weight: 800; }
.term p { margin: 0; font-size: 14px; line-height: 1.42; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.term.closed h3 { color: var(--muted); }
.term.closed p { color: var(--muted); font-size: 13px; }
.term.closed { background: transparent; border-style: dashed; }

.pcard { display: flex; align-items: center; gap: 14px; padding-top: 6px; }
.pmain { flex: 1; min-width: 0; }
.pmain h1 { margin: 0 0 2px; font-size: 23px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank { color: var(--on-text); font-size: 14px; font-weight: 700; }
.rank-note { margin: -6px 0 0; font-size: 13px; color: var(--muted); }
.link { background: none; border: 0; color: var(--muted); font-size: 13.5px; font-weight: 700; text-decoration: underline; padding: 8px 4px; cursor: pointer; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 10px 6px; text-align: center; }
.stats b { display: block; font-size: 20px; font-weight: 800; }
.stats span { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.box { border: 1px solid var(--line); border-radius: 20px; background: var(--panel); padding: 16px 14px; }
.box h2 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.box p { margin: 0 0 12px; font-size: 14px; line-height: 1.42; }
.box.up { background: radial-gradient(120% 100% at 100% 0%, rgba(255, 200, 61, .13), transparent 60%), var(--panel); }
.pform { display: flex; flex-direction: column; gap: 12px; }
.pform input {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--inset); color: var(--text);
  font: inherit; font-size: 16px; -webkit-user-select: text; user-select: text;
}
.pform input:focus { outline: none; border-color: var(--on); }
.colors { display: flex; gap: 10px; }
.color { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; }
.color.cur { border-color: var(--text); }
.h-sec { margin: 6px 0 -4px; font-size: 17px; font-weight: 800; }
.badges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.badge-it {
  border: 1px dashed var(--line); border-radius: 16px; padding: 12px 10px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.badge-it .b-ic { font-size: 28px; line-height: 1; filter: grayscale(1); opacity: .35; }
.badge-it b { font-size: 13.5px; color: var(--muted); }
.badge-it .b-how { font-size: 11.5px; line-height: 1.3; color: var(--muted); }
.badge-it.got { border: 1px solid rgba(255, 200, 61, .45); background: var(--on-soft); }
.badge-it.got .b-ic { filter: none; opacity: 1; }
.badge-it.got b { color: var(--text); }
.set { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--panel); }
.set-row {
  width: 100%; min-height: 50px; padding: 0 14px; background: none; border: 0; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; font-size: 15px; font-weight: 700; cursor: pointer; text-align: left;
}
.set-row:last-child { border-bottom: 0; }
.set-row b { color: var(--muted); }
.set-row.danger { color: var(--bad); }

/* ---------- урок: карточки, вопрос, награда ---------- */
.lesson {
  height: 100vh; height: 100dvh; min-height: 540px;
  display: flex; flex-direction: column;
}
.l-top { flex: none; height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 14px 0 6px; }
.l-top .bar { flex: 1; height: 8px; border-radius: 4px; }
.l-top .bar i { background: var(--on); border-radius: 4px; }
.l-x { width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.l-xp { flex: none; font-size: 13px; font-weight: 800; color: var(--on-text); }
.unit { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 4px 16px calc(14px + env(safe-area-inset-bottom)); animation: slide .28s ease both; }
.unit-foot { flex: none; margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.reward + .unit-foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
.card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; }
.art {
  border: 1px solid var(--line); border-radius: 24px; background: var(--panel);
  padding: 18px 12px; margin-bottom: 20px; display: flex; align-items: center; justify-content: center; min-height: 190px;
}
.art-svg { width: 100%; max-width: 300px; height: auto; display: block; }
.card h2, .quiz h2 { margin: 0 0 10px; font-size: 25px; line-height: 1.16; font-weight: 800; }
.card p { margin: 0; font-size: 17px; line-height: 1.5; color: var(--text-2); }
.card p.w-note { min-height: 1.5em; margin-top: 10px; font-size: 14.5px; font-weight: 700; color: var(--ok); }

.art-svg text { font-family: inherit; font-weight: 800; }
.a-s { fill: none; stroke: var(--line-2); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.a-f { fill: var(--panel-2); stroke: var(--line-2); stroke-width: 2; }
.a-mf { fill: var(--line-2); }
.a-on { fill: none; stroke: var(--on); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.a-onf { fill: var(--on); }
.a-togon { fill: var(--on-soft); stroke: var(--on); stroke-width: 2; }
.a-glow { filter: drop-shadow(0 0 8px rgba(255, 200, 61, .75)); }
.a-ok { fill: none; stroke: var(--ok); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.a-wire { stroke: var(--wire); stroke-width: 6; stroke-linecap: round; }
.a-wire-on { stroke: var(--on); stroke-width: 6; stroke-linecap: round; fill: none; filter: drop-shadow(0 0 6px rgba(255, 200, 61, .7)); }
.a-t { fill: var(--text); }
.a-tm { fill: var(--muted); }
.a-ton { fill: var(--on-text); }

.w-toggle, .w-combos { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.w-lamp { width: 64px; height: 64px; border-radius: 50%; background: var(--inset); border: 2.5px solid var(--line-2); transition: all .2s; }
.w-lamp.on { background: var(--on); border-color: var(--on); box-shadow: 0 0 34px rgba(255, 200, 61, .8); }
.w-digit { font-size: 44px; line-height: 1; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 4px; transition: color .2s; }
.w-digit.on { color: var(--on-text); }
.w-switch {
  width: 64px; height: 36px; border-radius: 18px; border: 2px solid var(--line-2); background: var(--inset); padding: 0; position: relative; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.w-switch i { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.w-switch[aria-pressed="true"] { background: var(--on-soft); border-color: var(--on); }
.w-switch[aria-pressed="true"] i { transform: translateX(28px); background: var(--on); }
.w-switch.big { width: 96px; height: 52px; border-radius: 26px; animation: nudge 1.4s ease-in-out infinite; }
.w-switch.big i { width: 38px; height: 38px; top: 5px; left: 5px; }
.w-switch.big[aria-pressed="true"] { animation: none; }
.w-switch.big[aria-pressed="true"] i { transform: translateX(44px); }
.w-pair { display: flex; align-items: flex-end; gap: 18px; }
.w-col { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.w-cells { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.quiz { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; }
.opts { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.opt {
  min-height: 56px; padding: 12px 16px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--panel);
  font-size: 17px; font-weight: 700; text-align: left; cursor: pointer; transition: border-color .15s, background .15s, opacity .15s;
}
.opt:active { background: var(--panel-2); }
.opt.right { border-color: var(--ok); background: rgba(74, 222, 128, .12); }
.opt.wrong { border-color: var(--bad); background: rgba(255, 123, 114, .1); color: var(--muted); }
.opt[disabled] { cursor: default; }
.opt[disabled]:not(.right):not(.wrong) { opacity: .45; }
.why { min-height: 3em; margin: 14px 0 0; font-size: 15px; line-height: 1.42; }
.why.good { color: var(--ok); }
.why.bad { color: var(--bad-text); }

.reward { flex: 1 1 auto; padding: 26px 16px 0; text-align: center; overflow-y: auto; animation: slide .3s ease both; }
.burst {
  width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 50%;
  background: rgba(74, 222, 128, .14); color: var(--ok); font-size: 40px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
.reward h1 { margin: 0 0 6px; font-size: 27px; font-weight: 800; }
.gain { font-size: 21px; line-height: 1.25; font-weight: 800; color: var(--on-text); }
.reward .muted { margin: 4px 0 0; font-size: 13.5px; }
.r-rank { margin: 18px 0 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 12px 14px; text-align: left; }
.r-line { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 14px; }
.r-line span { color: var(--muted); font-weight: 700; font-size: 13px; }
.up-note { margin: 10px 0 0; font-size: 14px; font-weight: 800; color: var(--on-text); }
.new-badge {
  display: flex; align-items: center; gap: 12px; text-align: left; margin-bottom: 8px;
  border: 1px solid rgba(255, 200, 61, .45); background: var(--on-soft); border-radius: 18px; padding: 10px 14px;
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: .25s;
}
.new-badge .b-ic { font-size: 30px; line-height: 1; }
.new-badge small { display: block; font-size: 11px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--on-text); }
.new-badge b { font-size: 16px; }
.streak { margin: 10px 0 14px; font-size: 14px; color: var(--muted); }
.reward .box { text-align: left; margin-bottom: 8px; }
.saved { display: flex; align-items: center; gap: 10px; font-size: 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  width: max-content; max-width: min(92vw, 440px); padding: 11px 16px; border-radius: 14px;
  background: var(--panel-3); border: 1px solid var(--line); font-size: 14px; font-weight: 700; line-height: 1.35;
  box-shadow: 0 10px 30px var(--shadow);
}
.dialog-btns { display: flex; gap: 10px; }

/* без сдвига вбок: сдвиг на телефоне на миг расширяет страницу */
@keyframes slide { from { opacity: 0; transform: scale(.975); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 200, 61, .5); } 50% { box-shadow: 0 0 0 10px rgba(255, 200, 61, 0); } }

/* ---------- задание ---------- */
.stage {
  animation: slide .28s ease both;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px calc(14px + env(safe-area-inset-bottom));
}
.task { flex: none; }
.task h1 { margin: 2px 0 4px; font-size: 23px; line-height: 1.15; font-weight: 800; }
.task p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.38; }

/* ---------- поле ---------- */
.board-wrap { flex: 0 1 auto; width: 100%; min-height: 250px; position: relative; }
.board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.bg { fill: var(--panel); stroke: var(--line); stroke-width: 1; }
.grid-dot { fill: var(--dot); }

.stub { stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.box { fill: var(--panel-2); stroke: var(--line); stroke-width: 1.5; transition: stroke .2s, fill .2s; }

.p-in { cursor: pointer; }
.p-in .lbl { fill: var(--muted); font-size: 11.5px; font-weight: 700; }
.p-in .bit { fill: var(--muted); font-size: 22px; font-weight: 800; transition: fill .15s; }
.tog-track { fill: var(--inset); stroke: var(--line); stroke-width: 1.5; transition: fill .2s, stroke .2s; }
.tog-knob { fill: var(--muted); transition: transform .18s ease, fill .18s; }
.p-in.on .box { stroke: var(--on); fill: var(--panel-on); }
.p-in.on .bit { fill: var(--on-text); }
.p-in.on .tog-track { fill: var(--on-soft); stroke: var(--on); }
.p-in.on .tog-knob { fill: var(--on); transform: translateX(14px); }
.p-in.guide .box { stroke: var(--on); animation: breathe 1.1s ease-in-out infinite; }

.p-gate .g-main { font-size: 21px; font-weight: 800; text-anchor: middle; dominant-baseline: middle; }
.p-gate .g-sub { font-size: 9.5px; font-weight: 700; text-anchor: middle; fill: var(--muted); letter-spacing: 1px; }
.p-gate .g-bar { opacity: .9; }
.p-gate.t-AND .g-main, .p-gate.t-AND .g-bar { fill: var(--and); }
.p-gate.t-OR .g-main, .p-gate.t-OR .g-bar { fill: var(--or); }
.p-gate.t-NOT .g-main, .p-gate.t-NOT .g-bar { fill: var(--not); }
.p-gate.t-XOR .g-main, .p-gate.t-XOR .g-bar { fill: var(--xor); }
.p-gate.on .box { stroke: var(--on); }

.p-out .lbl { fill: var(--muted); font-size: 12px; font-weight: 700; text-anchor: middle; transition: fill .2s; }
.p-out.on .box { stroke: var(--on); fill: var(--panel-on); }
.p-out.on .lbl { fill: var(--on-text); }
.p-out .ic-on { opacity: 0; transition: opacity .25s; }
.p-out .ic-off { opacity: 1; transition: opacity .25s; }
.p-out.on .ic-on { opacity: 1; }
.p-out.on .ic-off { opacity: 0; }
.ic-line { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-fill { fill: var(--inset); stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; transition: fill .25s, stroke .25s; }
.p-out.on .ic-fill.glow { fill: var(--on); stroke: var(--on); filter: drop-shadow(0 0 7px var(--on)); }
.ic-ray { stroke: var(--on); stroke-width: 2; stroke-linecap: round; }
.ic-gold { fill: var(--on); filter: drop-shadow(0 0 5px var(--on)); }
.p-out.on .ic-fill.alarm { fill: var(--bad); stroke: var(--bad); filter: drop-shadow(0 0 8px var(--bad)); animation: blink .5s steps(2, jump-none) infinite; }
.p-out.on .ic-ray.alarm { stroke: var(--bad); }
.p-out.icon-siren.on .box { stroke: var(--bad); fill: var(--panel-bad); }
.p-out.icon-siren.on .lbl { fill: var(--bad); }

/* провода */
.wire-hit { fill: none; stroke: transparent; stroke-width: 20; cursor: pointer; }
.wire { fill: none; stroke: var(--wire); stroke-width: 4; stroke-linecap: round; transition: stroke .15s; pointer-events: none; }
.wire.on { stroke: var(--on); filter: drop-shadow(0 0 4px rgba(255, 200, 61, .7)); }
.wire-flow { fill: none; stroke: var(--flow); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 2 16; animation: flow .7s linear infinite; pointer-events: none; }
.wire-temp { fill: none; stroke: var(--on); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 6 7; opacity: .8; pointer-events: none; }

/* точки подключения */
.pin { transition: fill .15s, stroke .15s; pointer-events: none; }
.pin.out { fill: var(--line-2); stroke: none; }
.pin.in { fill: var(--panel); stroke: var(--line-2); stroke-width: 2.5; }
.pin.in.wired { fill: var(--line-2); }
.pin.hot { fill: var(--on); stroke: var(--on); }
.pin.sel { fill: var(--on); stroke: var(--text); stroke-width: 2.5; }
.pin-ring { fill: none; stroke: var(--on); stroke-width: 2; opacity: 0; pointer-events: none; transform-box: fill-box; transform-origin: center; }
.pin-ring.cand, .pin-ring.guide { animation: ring 1.1s ease-out infinite; }
.pin-ring.bad { stroke: var(--bad); animation: ring .7s ease-out 3; }

@keyframes ring { 0% { transform: scale(1); opacity: .95; } 100% { transform: scale(2.7); opacity: 0; } }
@keyframes flow { to { stroke-dashoffset: -18; } }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: .45; } }
@keyframes breathe { 0%, 100% { stroke-width: 1.5; } 50% { stroke-width: 3.5; } }

/* ---------- низ: подсказка, варианты, кнопка ---------- */
.dock { flex: none; margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.hint { flex: none; margin: 0; min-height: 2.7em; font-size: 14px; line-height: 1.35; color: var(--muted); display: flex; align-items: center; }
.hint.bad { color: var(--bad); }
.hint.good { color: var(--ok); }

.strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.strip:empty { display: none; }
.cell {
  height: 30px; border-radius: 9px; border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 3px;
  font: 700 13px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--muted); transition: border-color .2s, background .2s, color .2s;
}
.cell.idle { opacity: .45; }
.cell.cur { border-color: var(--on); opacity: 1; }
.cell.pass { border-color: rgba(74, 222, 128, .55); background: rgba(74, 222, 128, .09); color: var(--text); }
.cell.fail { border-color: var(--bad); background: rgba(255, 123, 114, .12); color: var(--text); }
.cell .mark { font-family: inherit; }
.cell.pass .mark { color: var(--ok); }
.cell.fail .mark { color: var(--bad); }

.btn {
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: 100%; min-height: 52px; padding: 12px 16px;
  border-radius: 16px; border: 0;
  font: inherit; font-size: 17px; font-weight: 800;
  cursor: pointer; transition: transform .08s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--on); color: var(--on-ink); box-shadow: 0 6px 22px rgba(255, 200, 61, .22); }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); font-weight: 700; font-size: 15.5px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- лист «получилось» ---------- */
.backdrop { position: fixed; inset: 0; background: var(--dim); z-index: 10; animation: fade .25s both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 480px; margin: 0 auto;
  max-height: 86vh; max-height: 86dvh; overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 50px var(--shadow);
  animation: rise .32s cubic-bezier(.2, .9, .3, 1) both;
}
.sheet .badge {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(74, 222, 128, .14); color: var(--ok);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; margin-bottom: 10px;
}
.sheet h2 { margin: 0 0 8px; font-size: 21px; line-height: 1.2; font-weight: 800; }
.sheet p { margin: 0 0 12px; font-size: 15px; line-height: 1.45; color: var(--text-2); }
.sheet .fact { font-size: 13.5px; color: var(--muted); border-left: 3px solid var(--on); padding-left: 10px; }
/* кнопка всегда на виду, даже если таблица длинная и лист прокручивается */
.sheet .btn { margin-top: 4px; position: sticky; bottom: 0; box-shadow: 0 -14px 18px 6px var(--panel-2); }

.tt { width: 100%; border-collapse: collapse; margin: 2px 0 14px; font-size: 13.5px; }
.tt caption { text-align: left; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; padding-bottom: 6px; }
.tt th { color: var(--muted); font-weight: 700; padding: 4px 6px; text-align: center; border-bottom: 1px solid var(--line); }
.tt td { text-align: center; padding: 4px 6px; font: 700 14px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); border-bottom: 1px solid var(--line); }
.tt td.one { color: var(--on-text); }
.tt th.res, .tt td.res { border-left: 1px solid var(--line); }

/* ---------- экран покупки ---------- */
.offer { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; animation: fade .3s both; }
.offer-in {
  max-width: 480px; min-height: 100%; margin: 0 auto;
  padding: 28px 20px calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.offer h2 { margin: 0 0 8px; font-size: 27px; line-height: 1.15; font-weight: 800; }
.offer .lead { margin: 0 0 18px; font-size: 15.5px; line-height: 1.45; color: var(--text-2); }
.road { list-style: none; margin: 0 0 18px; padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); overflow: hidden; }
.road li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 14.5px; border-bottom: 1px solid var(--line); color: var(--muted); }
.road li:last-child { border-bottom: 0; }
.road .n {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; border: 1.5px solid var(--line); color: var(--muted);
}
.road li.done { color: var(--text); }
.road li.done .n { background: rgba(74, 222, 128, .15); border-color: transparent; color: var(--ok); }
.road li.open { color: var(--text); }
.road li.open .n { border-color: var(--on); color: var(--on-text); }
.road .name { flex: 1; min-width: 0; }
.road .tag { flex: none; font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--on-text); }
.road .lock { flex: none; opacity: .6; }
.offer .price { margin: 0 0 8px; font-size: 16px; font-weight: 800; }
.offer .honest { margin: 0 0 18px; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.offer .actions { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

/* ---------- окно-заглушка ---------- */
.dialog-wrap { position: fixed; inset: 0; z-index: 30; background: var(--dim-2); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .2s both; }
.dialog { width: 100%; max-width: 360px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 22px; padding: 22px 18px 18px; }
.dialog h3 { margin: 0 0 8px; font-size: 19px; font-weight: 800; }
.dialog p { margin: 0 0 16px; font-size: 15px; line-height: 1.45; color: var(--text-2); }

/* ---------- программа из curriculum: вход, игры, итог, «Твой чип», неделя ---------- */
.hero.entry h1 { font-size: 29px; margin-top: 2px; }
.hero.entry p { font-size: 15.5px; }
.entry-note { margin: 12px 0 0 !important; font-size: 12.5px !important; color: var(--muted) !important; text-align: center; }
.goal-text { margin-top: 6px !important; }

.mini { margin-top: 2px; }
.mini summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted); padding: 6px 0; }
.mini ol { margin: 4px 0 0; padding-left: 22px; color: var(--muted); font-size: 14px; line-height: 1.7; }

.chip-ic { flex: none; width: 15px; height: 15px; fill: none; stroke: var(--on); stroke-width: 1.4; stroke-linecap: round; }
.chipbox .chip-num { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 6px; }
.chipbox .chip-ic { width: 26px; height: 26px; align-self: center; }
.chip-num b { font-size: 40px; line-height: 1; font-weight: 800; color: var(--on-text); }
.chip-num span { font-size: 15px; font-weight: 700; color: var(--muted); }
.box .kicker { margin-bottom: 4px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 8px 0 10px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--muted); }
.wd i { width: 24px; height: 24px; border-radius: 50%; background: var(--inset); border: 2px solid var(--line); transition: all .3s; }
.wd.lit i { background: var(--on); border-color: var(--on); box-shadow: 0 0 12px rgba(255, 200, 61, .7); }
.wd.today span { color: var(--text); }
.wd.today:not(.lit) i { border-color: var(--line-2); }
.week-now { margin: 0 0 10px !important; font-weight: 700; }
.goals { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.goal { min-height: 42px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: transparent; text-align: left; font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer; }
.goal.cur { border-color: var(--on); color: var(--text); background: var(--on-soft); }
.week-box { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 12px 14px 4px; margin: 10px 0; text-align: left; }

.card.noart p { font-size: 22px; line-height: 1.38; font-weight: 700; color: var(--text); }
.a-dark { fill: var(--inset); stroke: var(--line); stroke-width: 1.5; }

.p-in .bit.word { font-size: 10px; font-weight: 700; }
.wbit { fill: var(--muted); font-size: 26px; font-weight: 800; pointer-events: none; }
.wbit.on { fill: var(--on-text); }
.p-gate.t-Q .g-main, .p-gate.t-Q .g-bar { fill: var(--on-text); }
.p-gate.t-Q .g-main { font-size: 26px; }

.game { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; }
.game h2 { margin: 2px 0 12px; font-size: 22px; line-height: 1.2; font-weight: 800; }
.game .art { min-height: 0; padding: 16px 14px; margin-bottom: 4px; }
.g-count { font-size: 12.5px; font-weight: 800; color: var(--muted); letter-spacing: .6px; margin-bottom: 8px; }
.g-item {
  min-height: 108px; padding: 16px; border-radius: 22px; border: 1.5px solid var(--line); background: var(--panel);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 21px; line-height: 1.25; font-weight: 800; transition: border-color .15s, background .15s, transform .15s;
}
.g-item.hit { border-color: var(--ok); background: rgba(74, 222, 128, .12); transform: scale(.97); }
.g-item.miss { border-color: var(--bad); animation: shake .3s; }
.g-item.done { border-color: var(--ok); color: var(--ok); font-size: 44px; }
.g-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.g-btn, .g-bin {
  min-height: 60px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--panel-2);
  font-size: 28px; font-weight: 800; cursor: pointer; transition: transform .08s, background .15s;
}
.g-bin { font-size: 18px; margin: 10px 0; }
.g-btn:active, .g-bin:active { transform: scale(.97); background: var(--panel-3); }
.g-btn[disabled], .g-bin[disabled] { opacity: .4; }
.game .why { min-height: 2.9em; }

.w-rows { width: 100%; display: flex; flex-direction: column; gap: 5px; }
.w-rowc {
  height: 32px; border-radius: 10px; border: 1.5px solid var(--line); padding: 0 14px;
  display: grid; grid-template-columns: 34px 34px 1fr; align-items: center;
  font: 800 15px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted);
}
.w-rowc span { text-align: right; color: var(--ok); }
.w-rowc.idle b { opacity: .25; }
.w-rowc.found { border-color: rgba(74, 222, 128, .5); background: rgba(74, 222, 128, .08); color: var(--text); }
.w-rowc.cur { border-color: var(--on); }

.tt.qt { margin: 0 0 12px; }
.tt.qt td, .tt.qt th { padding: 3px 6px; }

.sum { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 14px; margin: 16px 0 10px; text-align: left; }
.sum:empty { display: none; }
.sum-k { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--on-text); margin-top: 10px; }
.sum-k:first-child { margin-top: 0; }
.sum p { margin: 3px 0 0; font-size: 15px; line-height: 1.42; color: var(--text-2); }
.recap { margin: 0; padding: 0; list-style: none; }
.recap li { position: relative; padding: 5px 0 5px 26px; font-size: 15px; line-height: 1.35; }
.recap li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 800; }
.sum-next { margin-top: 10px !important; font-weight: 700; color: var(--on-text) !important; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-5px); } 70% { transform: translateX(5px); } }

@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ====================================================================
   Наполнение главной, переключатель темы, подсказка клавиш
   ==================================================================== */
.icon-btn {
  width: 38px; height: 34px; padding: 0; border-radius: 11px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { background: var(--panel-2); }
.t-light { display: none; }
:root[data-theme="light"] .t-light { display: block; }
:root[data-theme="light"] .t-dark { display: none; }

.side-extra, .hero-demo, .kbd-hint { display: none; }

.secs { display: flex; flex-direction: column; gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 12px 10px; text-align: center; }
.stat b { display: block; font-size: 22px; line-height: 1.1; font-weight: 800; color: var(--on-text); }
.stat span { font-size: 12px; font-weight: 700; color: var(--muted); }

.block-title { margin: 14px 0 0; font-size: 21px; line-height: 1.2; font-weight: 800; }
.block-lead { margin: -8px 0 0; font-size: 14.5px; line-height: 1.4; color: var(--muted); }
.how { display: grid; grid-template-columns: 1fr; gap: 8px; }
.how-it { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 14px; display: flex; gap: 12px; align-items: flex-start; }
.how-n { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--on-soft); color: var(--on-text); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.how-it b { display: block; font-size: 15.5px; margin-bottom: 2px; }
.how-it span { font-size: 14px; line-height: 1.4; color: var(--muted); }

.builds { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.build-it { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 10px 12px 12px; }
.build-it .art-svg { max-width: 150px; margin: 0 auto 6px; }
.build-it b { display: block; font-size: 14.5px; line-height: 1.25; }
.build-it span { display: block; margin-top: 2px; font-size: 12px; font-weight: 700; color: var(--muted); }
.build-it.later { border-style: dashed; background: transparent; }

.faq { display: flex; flex-direction: column; gap: 6px; }
.faq details { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 0 14px; }
.faq summary { cursor: pointer; padding: 13px 0; font-size: 15px; font-weight: 700; }
.faq p { margin: 0 0 14px; font-size: 14.5px; line-height: 1.45; color: var(--text-2); }
.foot { margin-top: 8px; padding: 18px 0 4px; border-top: 1px solid var(--line); font-size: 12.5px; line-height: 1.5; color: var(--muted); text-align: center; }

.row, .opt, .btn, .tab, .goal, .set-row, .g-btn, .g-bin { transition-property: background, border-color, transform, opacity, color; transition-duration: .15s; }
@media (hover: hover) {
  .row.open:hover, .row.done:hover { border-color: var(--on); }
  .btn.primary:hover { filter: brightness(1.06); }
  .btn.ghost:hover, .opt:not([disabled]):hover, .g-btn:not([disabled]):hover, .g-bin:not([disabled]):hover, .goal:hover, .set-row:hover { background: var(--panel-3); }
  .tab:hover { color: var(--text); }
  .lang:hover, .icon-btn:hover { background: var(--panel-2); color: var(--text); }
}

/* ====================================================================
   Раскладка для ноутбука и ПК (от 960 px)
   ==================================================================== */
@media (min-width: 960px) {
  #app {
    max-width: 1200px; padding: 0 32px;
    display: grid; grid-template-columns: 228px minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 36px;
  }
  .top { grid-column: 1 / -1; height: 72px; padding: 0; }
  .brand { font-size: 22px; gap: 10px; }
  .brand-dot { width: 13px; height: 13px; }
  .lang, .icon-btn, .chip { height: 38px; }
  .chip { font-size: 14px; padding-right: 12px; }

  .tabs {
    grid-column: 1; grid-row: 2; position: sticky; top: 18px; align-self: start;
    flex-direction: column; gap: 4px; padding: 0; border-top: 0; background: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .tab { flex: none; height: 48px; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 14px; font-size: 15.5px; }
  .tab:hover { background: var(--panel-2); }
  .tab.cur { background: var(--on-soft); color: var(--text); }
  .tab.cur svg { color: var(--on-text); }
  .side-extra { display: block; margin-top: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 14px; }
  .side-extra .kicker { margin-bottom: 2px; }
  .side-extra .chip-num { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; }
  .side-extra .chip-num b { font-size: 30px; }
  .side-extra .chip-num span { font-size: 13px; }
  .side-extra .week { margin: 6px 0 0; gap: 2px; }
  .side-extra .wd i { width: 18px; height: 18px; }
  .side-extra .wd span { font-size: 10px; }

  #view { grid-column: 2; grid-row: 2; }
  .page { padding: 4px 0 64px; gap: 20px; }

  /* главная */
  .hero { padding: 30px 32px; border-radius: 28px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; column-gap: 36px; align-items: center; }
  .hero > * { grid-column: 1; }
  .hero h1, .hero.entry h1 { font-size: 40px; line-height: 1.1; margin: 4px 0 12px; }
  .hero p, .hero.entry p { font-size: 17px; line-height: 1.5; }
  .hero .btn { max-width: 340px; }
  .entry-note { text-align: left !important; }
  .hero-demo {
    display: flex; grid-column: 2; grid-row: 1 / span 6; flex-direction: column; align-items: center; gap: 14px;
    border: 1px solid var(--line); border-radius: 24px; background: var(--panel-2); padding: 26px 18px 20px;
  }
  .hero-demo .w-word { font-size: 15px; font-weight: 800; color: var(--muted); }
  .hero-demo .w-word.on { color: var(--on-text); }
  .hero-demo small { font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.35; }
  .miles { flex-direction: row; flex-wrap: wrap; gap: 8px 22px; }

  .stats { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .stat b { font-size: 28px; }
  .stat span { font-size: 13px; }

  .secs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .sec { padding: 20px; }
  .sec.has-rows { grid-column: 1 / -1; }
  .sec.has-rows h2 { font-size: 24px; }
  .sec.has-rows .rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .sec .btn.ghost { max-width: 280px; }
  .row { min-height: 56px; }

  .block-title { font-size: 28px; margin-top: 26px; }
  .block-lead { font-size: 16px; }
  .how { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .how-it { flex-direction: column; padding: 20px; }
  .how-it b { font-size: 17px; }
  .how-it span { font-size: 15px; }
  .builds { grid-template-columns: repeat(5, 1fr); gap: 12px; }
  .build-it { padding: 14px; }
  .faq { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }

  /* словарь и профиль */
  .page-head h1 { font-size: 34px; }
  .terms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .p-profile { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .p-profile > .pcard, .p-profile > .h-sec, .p-profile > .badges, .p-profile > .set, .p-profile > .up { grid-column: 1 / -1; }
  .badges { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .pmain h1 { font-size: 30px; }
  .ava.big { width: 80px; height: 80px; font-size: 34px; }
  .box .btn { max-width: 320px; }
  .set { max-width: 520px; }

  /* урок: на весь экран, без бокового меню */
  body.in-lesson #app { display: block; max-width: none; padding: 0; }
  .lesson { max-width: 1120px; margin: 0 auto; min-height: 600px; }
  .l-top { height: 68px; padding: 0 28px 0 16px; gap: 16px; }
  .kbd-hint { display: block; flex: none; font-size: 12.5px; font-weight: 700; color: var(--muted); }
  .kbd-hint kbd { font: inherit; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
  .unit { width: 100%; max-width: 700px; margin: 0 auto; padding: 4px 24px 32px; }
  .art { min-height: 290px; border-radius: 28px; margin-bottom: 26px; }
  .art-svg { max-width: 430px; }
  .card h2, .quiz h2 { font-size: 32px; }
  .card p { font-size: 20px; }
  .card.noart p { font-size: 28px; }
  .game h2 { font-size: 26px; }
  .opt { font-size: 18px; min-height: 60px; cursor: pointer; }
  .why { font-size: 16px; }
  .unit-foot { align-items: center; }
  .unit-foot .btn { max-width: 380px; }

  /* схема слева, задание и кнопка справа */
  .stage {
    display: grid; width: 100%; max-width: 1120px; margin: 0 auto; padding: 8px 32px 32px;
    grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto auto 1fr auto;
    grid-template-areas: "board task" "board hint" "board ." "board dock"; column-gap: 44px; row-gap: 14px;
  }
  .stage .task { grid-area: task; padding-top: 12px; }
  .stage .task h1 { font-size: 30px; }
  .stage .task p { font-size: 16.5px; }
  .stage .board-wrap { grid-area: board; align-self: center; justify-self: center; width: min(100%, calc((100vh - 140px) * var(--ar, 1))); }
  .stage .hint { grid-area: hint; font-size: 15.5px; min-height: 3.4em; align-items: flex-start; }
  .stage .dock { grid-area: dock; margin-top: 0; }

  .reward, .reward + .unit-foot { width: 100%; max-width: 580px; margin-left: auto; margin-right: auto; }
  .reward h1 { font-size: 34px; }

  .sheet { max-width: 580px; bottom: 28px; border-radius: 26px; border-bottom: 1px solid var(--line); padding: 26px 26px 24px; }
  .offer-in { max-width: 600px; padding-top: 56px; }
  .offer h2 { font-size: 36px; }
  .toast { bottom: 36px; }
}

@media (min-width: 960px) and (max-width: 1100px) {
  .secs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .builds { grid-template-columns: repeat(3, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr) 250px; }
}

/* ====================================================================
   Справочник вентилей и «Мои схемы»
   ==================================================================== */
.block-title.sm { font-size: 19px; margin-top: 6px; }
.gates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gate-card { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.gate-card b { font-size: 19px; font-weight: 800; }
.gate-card b small, .d-right h1 small { font-size: 11px; letter-spacing: 1px; color: var(--muted); margin-left: 4px; }
.gate-card span { font-size: 13px; line-height: 1.35; color: var(--muted); display: flex; gap: 6px; align-items: flex-start; }
.gate-card.closed { border-style: dashed; background: transparent; }
.gate-card.closed .g-sym, .gate-card.closed b { opacity: .45; }
.g-sym .art-svg { max-width: 150px; margin: 0 auto; }
.a-sym { fill: var(--panel-2); stroke: var(--text); stroke-width: 3; stroke-linejoin: round; }
b.t-AND, h1.t-AND, .gate-chip.t-AND { color: var(--and); }
b.t-OR, h1.t-OR, .gate-chip.t-OR { color: var(--or); }
b.t-NOT, h1.t-NOT, .gate-chip.t-NOT { color: var(--not); }
b.t-XOR, h1.t-XOR, .gate-chip.t-XOR { color: var(--xor); }

.back { font-size: 14px; font-weight: 700; color: var(--muted); padding: 6px 0; align-self: flex-start; }
.detail { display: flex; flex-direction: column; gap: 14px; }
.pstage { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); padding: 14px; }
.pstage .task h1 { font-size: 13px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--on-text); margin: 0; }
.pstage .board-wrap { min-height: 0; }
.pstage .hint { min-height: 1.4em; }
.pstage .dock { margin-top: 0; }
.d-right h1 { margin: 0 0 6px; font-size: 27px; line-height: 1.15; font-weight: 800; }
.d-right p { margin: 0 0 4px; font-size: 15px; line-height: 1.5; color: var(--text-2); }
.d-rule { font-size: 17px !important; font-weight: 700; color: var(--text) !important; }
.d-k { margin: 16px 0 4px; font-size: 11.5px; font-weight: 800; letter-spacing: 1.1px; text-transform: uppercase; color: var(--on-text); }
.d-right .tt { margin: 14px 0 2px; }
.lifes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.life-it { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 8px 10px 10px; }
.life-it .art-svg { max-width: 150px; margin: 0 auto 4px; }
.life-it span { display: block; font-size: 13px; line-height: 1.35; color: var(--text-2); }
.d-sym { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 6px; max-width: 260px; }
.code { border: 1px solid var(--line); border-radius: 16px; background: var(--inset); padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.code div { display: flex; align-items: baseline; gap: 12px; }
.code i { flex: none; width: 58px; font-style: normal; font-size: 11.5px; font-weight: 800; color: var(--muted); }
.code code { font: 700 15px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--text); -webkit-user-select: text; user-select: text; }
.gate-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.gate-chip { padding: 5px 12px; border-radius: 10px; border: 1.5px solid currentColor; font-size: 14px; font-weight: 800; }
.gate-chip small { font-size: 10px; color: var(--muted); margin-left: 3px; }
.d-right .btn { margin-top: 12px; }

.circs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.circ { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.circ b { font-size: 15px; line-height: 1.25; }
.circ span { font-size: 12px; line-height: 1.35; font-weight: 700; color: var(--muted); }
.circ-pic { height: 132px; border-radius: 12px; background: var(--panel-2); margin-bottom: 6px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.circ-pic svg.lock, .circ-pic svg.play { width: 26px; height: 26px; }
.circ.closed { border-style: dashed; background: transparent; }
.circ.closed .circ-pic { background: transparent; border: 1px dashed var(--line); }
.thumb { height: 100%; width: auto; max-width: 100%; display: block; }
.th-wire { fill: none; stroke: var(--on); stroke-width: 6; stroke-linecap: round; }
.th-in { fill: var(--panel-3); stroke: var(--line-2); stroke-width: 3; }
.th-out { fill: var(--on-soft); stroke: var(--on); stroke-width: 3; }
.th-gate { fill: var(--panel); stroke-width: 4; }
.th-gate.t-AND { stroke: var(--and); } .th-gate.t-OR { stroke: var(--or); } .th-gate.t-NOT { stroke: var(--not); } .th-gate.t-XOR { stroke: var(--xor); }
.th-t { font-size: 24px; font-weight: 800; }
.th-t.t-AND { fill: var(--and); } .th-t.t-OR { fill: var(--or); } .th-t.t-NOT { fill: var(--not); } .th-t.t-XOR { fill: var(--xor); }
.th-off { opacity: .28; }
@media (hover: hover) {
  .gate-card:not(.closed):hover, .circ:not(.soon):hover { border-color: var(--on); }
  .back:hover { color: var(--text); }
}

@media (min-width: 960px) {
  .block-title.sm { font-size: 22px; margin-top: 10px; }
  .gates { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .gate-card { padding: 14px 16px 16px; }
  .circs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .circ-pic { height: 170px; }
  .detail { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); column-gap: 36px; align-items: start; }
  .d-left { position: sticky; top: 18px; }
  .d-right h1 { font-size: 34px; }
  .d-right p { font-size: 16px; }
  .d-rule { font-size: 19px !important; }
  .lifes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .d-right .btn { max-width: 300px; }
}

/* ====================================================================
   Третья редакция программы: направления, статусы уроков, «ещё задачи»,
   карточки-объяснения, схема на картинке в вопросе
   ==================================================================== */
.tracks { display: grid; grid-template-columns: 1fr; gap: 8px; }
.track { border: 1px solid var(--line); border-radius: 20px; background: var(--panel); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.tr-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.tr-l {
  width: 30px; height: 30px; border-radius: 10px; background: var(--on-soft); color: var(--on-text);
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800;
}
.track b { font-size: 17px; line-height: 1.2; font-weight: 800; }
.tr-about { font-size: 13.5px; line-height: 1.4; color: var(--muted); }
.tr-count { margin-top: 4px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tr-status { margin-top: 6px !important; font-weight: 700; font-size: 13.5px !important; }
.note.boxed { border: 1px dashed var(--line); border-radius: 14px; padding: 10px 12px; font-size: 13.5px; }

.row .nm small { display: block; margin-top: 2px; font-size: 12px; line-height: 1.35; font-weight: 500; color: var(--muted); }
.row.soon { cursor: default; }
.row.soon .st { border-style: dashed; font-size: 12px; }
.row.extra { margin-left: 18px; min-height: 44px; background: transparent; border: 1.5px solid var(--line); }
.row.extra .nm { font-size: 14px; }
.row.extra .st { width: 24px; height: 24px; }
.row.extra.open { border-color: var(--line-2); background: transparent; }
.row.extra.open .st { background: transparent; color: var(--on-text); border-color: var(--on); }
.row.extra.open .meta, .row.extra .meta { color: var(--muted); }

/* карточка «что это и зачем»: текста больше, картинка меньше */
.card.explain { justify-content: center; }
.card.explain .art { min-height: 0; padding: 10px; margin-bottom: 14px; }
.card.explain .art-svg { max-width: 190px; }
.card.explain h2 { font-size: 13px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--on-text); margin-bottom: 8px; }
.card.explain p { font-size: 15.5px; line-height: 1.5; color: var(--text); }

.q-art, .q-circ { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 8px; margin: 0 0 10px; display: flex; justify-content: center; }
.q-art .art-svg { max-width: 180px; }
.q-circ .thumb { height: 190px; }
.thumb.q .th-wire { stroke: var(--wire); }
.th-lbl { font-size: 15px; font-weight: 800; fill: var(--muted); }
.th-bit { font-size: 26px; font-weight: 800; fill: var(--muted); }
.th-bit.on { fill: var(--on-text); }
.thumb.q .th-out { fill: var(--panel-2); stroke: var(--line-2); }

.p-gate.t-XOR .g-main { font-size: 14px; }
.th-t.t-XOR { font-size: 15px; }

.new-badge.part .b-ic { width: 76px; flex: none; }
.new-badge.part .b-ic .art-svg { width: 76px; }
.more { text-align: left; margin: 12px 0 4px; }
.more .rows { margin-top: 8px; }
.road .name small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.road .n { font-size: 12px; }

@media (min-width: 960px) {
  .tracks { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .track { padding: 18px; }
  .track b { font-size: 19px; }
  .card.explain .art-svg { max-width: 260px; }
  .card.explain .art { padding: 18px; margin-bottom: 20px; }
  .card.explain h2 { font-size: 14px; }
  .card.explain p { font-size: 19px; }
  .q-circ .thumb { height: 240px; }
  .row.extra { margin-left: 0; }
}
@media (min-width: 960px) and (max-width: 1100px) {
  .tracks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Вопрос, карточка и игра не выталкивают кнопку за экран: при нехватке места прокручивается само содержимое.
   Центрирование через авто-отступы, чтобы при прокрутке не обрезался верх. */
.quiz, .card, .game { min-height: 0; overflow-y: auto; justify-content: flex-start; }
.quiz > :first-child, .card > :first-child, .game > :first-child { margin-top: auto; }
.quiz > :last-child, .card > :last-child, .game > :last-child { margin-bottom: auto; }
.q-art .art-svg { max-width: 130px; }
.q-art { padding: 4px; }
.card.explain { justify-content: flex-start; }

/* Невысокий экран (маленький телефон): всё плотнее, чтобы вопрос со схемой и высокие схемы помещались. */
@media (max-height: 700px) and (max-width: 959px) {
  .l-top { height: 42px; }
  .l-x { height: 38px; }
  .quiz h2 { font-size: 19px; margin-bottom: 6px; }
  .q-art { display: none; }
  .q-circ { padding: 4px; margin-bottom: 6px; }
  .q-circ .thumb { height: 128px; }
  .opts { gap: 6px; margin-top: 4px; }
  .opt { min-height: 44px; padding: 8px 14px; font-size: 15.5px; }
  .why { min-height: 2.6em; margin-top: 8px; font-size: 14px; }
  .tt.qt td, .tt.qt th { padding: 2px 6px; }
  .stage { gap: 6px; }
  .stage .task h1 { font-size: 19px; margin: 0 0 2px; }
  .stage .task p { font-size: 13px; line-height: 1.3; }
  .stage .hint { min-height: 2.5em; font-size: 13px; line-height: 1.25; }
  .stage .dock { gap: 6px; }
  .stage .cell { height: 26px; }
  .stage .btn { min-height: 46px; padding: 8px 16px; }
  .card.explain p { font-size: 14.5px; line-height: 1.45; }
  .card.explain .art-svg { max-width: 150px; }
}

/* Схема в вопросе «что на выходе?»: подписи и цифры крупнее, чтобы читались на телефоне. */
.thumb.q .th-lbl { font-size: 16px; }
.thumb.q .th-bit { font-size: 30px; }
.thumb.q .th-t { font-size: 30px; }
.q-circ .thumb { height: 220px; }
@media (min-width: 960px) { .q-circ .thumb { height: 230px; } .quiz h2 { font-size: 27px; } }
@media (max-height: 700px) and (max-width: 959px) { .q-circ .thumb { height: 140px; } }

/* На широком экране вопрос со схемой: схема слева, варианты справа. */
@media (min-width: 960px) {
  .quiz.has-circ { display: grid; grid-template-columns: 300px minmax(0, 1fr); column-gap: 28px; align-content: center; }
  .quiz.has-circ > .kicker, .quiz.has-circ > h2 { grid-column: 1 / -1; margin-top: 0; }
  .quiz.has-circ > .q-circ { grid-column: 1; grid-row: 3 / span 2; margin: 0; align-self: start; }
  .quiz.has-circ > .opts { grid-column: 2; grid-row: 3; margin-top: 0; }
  .quiz.has-circ > .why { grid-column: 2; grid-row: 4; margin-bottom: 0; }
  .quiz.has-circ .q-circ .thumb { height: 350px; }
}
@media (min-height: 701px) and (max-width: 959px) { .q-circ .thumb { height: 250px; } }

/* Телефон: вопрос со схемой целиком на экране вместе с пояснением к ответу. */
@media (max-width: 959px) {
  .quiz.has-circ h2 { font-size: 20px; line-height: 1.2; margin-bottom: 8px; }
  .quiz.has-circ .opt { min-height: 48px; padding: 9px 14px; }
  .quiz.has-circ .opts { gap: 7px; margin-top: 2px; }
  .quiz.has-circ .why { margin-top: 8px; min-height: 2.8em; }
}
@media (min-height: 701px) and (max-width: 959px) { .q-circ .thumb { height: 205px; } }
.thumb.q .th-lbl { font-size: 15px; }

/* ====================================================================
   Помощь в уроке: готовая подсказка и вопрос наставнику
   ==================================================================== */
.help-row { display: flex; gap: 8px; }
.help-row[hidden], .btn-help[hidden] { display: none; }
.btn-help {
  flex: 1 1 0; min-height: 44px; padding: 6px 12px; border-radius: 13px; border: 1.5px solid var(--line-2);
  background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-help.ask { color: var(--on-text); border-color: var(--on); }
.hint.tip { color: var(--on-text); }
.quiz .help-row { margin-top: 8px; }

.mentor-wrap { position: fixed; inset: 0; z-index: 25; background: var(--dim-2); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s both; }
.mentor-wrap[hidden] { display: none; }
.mentor {
  width: 100%; max-width: 520px; max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px;
}
.m-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: -14px; z-index: 1; margin: -14px -16px 0; padding: 12px 16px 6px; background: var(--panel-2); }
.m-top h3 { margin: 0; font-size: 19px; font-weight: 800; }
.m-left { margin: 0; min-height: 1.3em; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.m-hint { border-left: 3px solid var(--on); padding: 2px 0 2px 10px; }
.m-hint p { margin: 2px 0 0; font-size: 14px; line-height: 1.4; color: var(--text-2); }
.m-q, .m-a { padding: 8px 12px; font-size: 14.5px; line-height: 1.42; overflow-wrap: anywhere; }
.m-q { align-self: flex-end; max-width: 88%; background: var(--on-soft); border-radius: 14px 14px 4px 14px; }
.m-a { align-self: flex-start; max-width: 94%; background: var(--panel); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; white-space: pre-wrap; }
.m-a small { display: block; margin-top: 4px; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.m-a.wait { color: var(--muted); }
.m-err { margin: 0; font-size: 14px; line-height: 1.4; color: var(--bad-text); }
.m-form { display: flex; flex-direction: column; gap: 8px; }
.m-form textarea {
  width: 100%; min-height: 76px; resize: none; border-radius: 14px; border: 1.5px solid var(--line-2);
  background: var(--panel); color: var(--text); font: inherit; font-size: 16px; line-height: 1.4; padding: 10px 12px;
}
.m-form textarea:focus { outline: none; border-color: var(--on); }
.m-foot { display: flex; align-items: center; gap: 12px; }
.m-count { flex: none; font-size: 12.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.m-foot .btn { flex: 1; }
@media (min-width: 960px) {
  .mentor-wrap { align-items: center; padding: 20px; }
  .mentor { border-radius: 22px; max-height: 82vh; padding: 18px 20px 20px; }
  .quiz.has-circ > .help-row { grid-column: 2; }
}

/* Экран покупки: цена — главная строка; абзацы под ней плотнее, чтобы кнопка была ближе */
.offer .price { font-size: 21px; line-height: 1.25; margin-bottom: 8px; }
.offer .honest { margin-bottom: 12px; }
.offer .actions { padding-top: 6px; }
