/* Учебник Python (/python, /python/<урок>): страница-оглавление, текст урока, анимированные сцены (.pyscene + «сцена» .ps),
   песочницы (.pyplay) и тесты (.pyquiz). Подключается только на этих страницах (pages/python.php, pages/python-lesson.php).
   Механика — assets/js/python.js. Цвета типов данных: int — бирюзовый, float — жёлтый, str — розовый, bool — лаймовый,
   list — сиреневый, None — серый пунктир. Шрифты и переменные (--navy, --cyan, --mono…) — из style.css. */

.page-python { --t-int: var(--cyan); --t-float: var(--yellow); --t-str: var(--pink); --t-bool: var(--lime); --t-list: var(--violet-light); --t-none: #8f8ab8; }

/* ---------- Шапка ---------- */
.pyhero__cta { margin: 24px 0 0; }
.pysteps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.pysteps a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 7px; border-radius: 999px; border: 1px solid rgba(34, 228, 255, .35);
  color: #fff; text-decoration: none; font-weight: 700; font-size: .92rem; transition: background .2s, border-color .2s; }
.pysteps a span { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(34, 228, 255, .15); color: var(--cyan); font: 700 .8rem var(--mono); }
.pysteps a:hover { background: rgba(34, 228, 255, .1); }
.pysteps a.is-on { background: var(--lime); border-color: var(--lime); color: var(--navy); }
.pysteps a.is-on span { background: var(--navy); color: var(--lime); }

/* ---------- Оглавление учебника ---------- */
.pycards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; counter-reset: none; }
.pycard { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 26px 24px 22px; border-radius: var(--radius); background: #fff;
  border: 2px solid #ece8ff; box-shadow: var(--shadow); transition: transform .2s, border-color .2s; }
.pycard:hover { transform: translateY(-4px); border-color: var(--violet-light); }
.pycard__num { position: absolute; top: 18px; right: 20px; font: 800 2.4rem 'Rubik', sans-serif; color: #ece8ff; line-height: 1; }
.pycard__icon { font-size: 2.2rem; line-height: 1; }
.pycard h3 { margin: 0; font-size: 1.25rem; }
.pycard h3 a { text-decoration: none; color: var(--navy); }
.pycard h3 a::after { content: ''; position: absolute; inset: 0; border-radius: inherit; } /* вся карточка — ссылка */
.pycard h3 a:focus-visible { outline: none; }
.pycard:focus-within { outline: 3px solid var(--yellow); outline-offset: 3px; }
.pycard__analogy { margin: 0; color: var(--violet); font-weight: 700; }
.pycard__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pycard__tags li { padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: .82rem; }
.pycard__time { margin-top: auto; color: var(--muted); font-size: .9rem; font-weight: 700; }

.pydict { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.pydict__item { padding: 22px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.pydict__item h3 { margin: 14px 0 6px; font-size: 1.15rem; color: var(--navy); }
.pydict__item p { margin: 0; color: var(--muted); }
.pydict__pic { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; min-height: 120px; padding: 14px; border-radius: 16px;
  background: var(--grid), radial-gradient(ellipse at 20% 0%, #33268a, var(--navy) 70%); background-size: 28px 28px, 28px 28px, auto; }
.pydict__emoji { font-size: 3.4rem; line-height: 1; filter: drop-shadow(0 6px 16px rgba(34, 228, 255, .35)); }
.pydict__pic .ps-box__name { color: #fff; }

/* ---------- Урок: сетка, оглавление, текст ---------- */
.pylesson { padding-top: 48px; }
.pylesson__grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; align-items: start; }
.pytoc { position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow: auto; }
.pytoc summary { font: 800 .95rem 'Rubik', sans-serif; color: var(--navy); cursor: pointer; margin-bottom: 10px; }
.pytoc ol { margin: 0; padding: 0 0 0 4px; list-style: none; counter-reset: toc; border-left: 2px solid #ece8ff; }
.pytoc li { counter-increment: toc; }
.pytoc a { display: block; padding: 5px 0 5px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; font-size: .92rem; line-height: 1.35; }
.pytoc a:hover { color: var(--violet); border-left-color: var(--violet); }

.pyart { max-width: 800px; min-width: 0; }
.pyart--wide { max-width: none; }
.pyart h2 { margin: 2.2em 0 .6em; font-size: clamp(1.45rem, 3vw, 1.9rem); font-weight: 900; color: var(--navy); scroll-margin-top: 90px; }
.pyart h2:first-child, .pyart__lead + h2 { margin-top: 1.4em; }
.pyart p, .pyart li { font-size: 1.05rem; }
.pyart a { color: var(--violet); font-weight: 700; }
.pyart__lead { font-size: 1.18rem !important; padding: 20px 24px; border-radius: 18px; background: var(--bg); border-left: 5px solid var(--lime); }
.pyart :not(pre) > code, .pyquiz :not(pre) > code, .pyplay :not(pre) > code, .pydict code, .faq code {
  padding: .1em .35em; border-radius: 6px; background: #efebff; color: #4b2fc4; font: 600 .9em var(--mono); overflow-wrap: anywhere; }
/* внутри тёмных сцен и песочниц — свой вид кода */
.pyart .ps code { padding: 0; background: none; color: #fff; white-space: normal; font-size: inherit; }
.pyart .pyscene__say code { background: rgba(34, 228, 255, .14); color: #fff; }
/* без лигатур: новичок должен видеть >= и !=, а не ≥ и ≠ */
.page-python code, .page-python pre, .page-python .ps, .page-python .pyplay { font-variant-ligatures: none; font-feature-settings: 'liga' 0, 'calt' 0; }
.pylist { margin: 0 0 1.2em; padding-left: 0; }
.pylist li { position: relative; padding-left: 28px; margin-bottom: .5em; }
.pylist li::before { content: ''; position: absolute; left: 6px; top: .62em; width: 9px; height: 9px; border-radius: 3px; background: var(--violet); transform: rotate(45deg); }
ol.pylist { counter-reset: pl; }
ol.pylist li { counter-increment: pl; padding-left: 38px; }
ol.pylist li::before { content: counter(pl); top: .05em; left: 0; width: 26px; height: 26px; border-radius: 50%; transform: none; display: grid; place-items: center;
  color: #fff; font: 800 .8rem var(--mono); }
.pylist--check li::before { content: '✓'; background: none; transform: none; top: 0; left: 2px; width: auto; height: auto; color: var(--lime-dark); font-weight: 900; }

/* код и вывод */
.py-code { margin: 0 0 1em; padding: 16px 18px; border-radius: 14px; background: var(--navy); color: #e6e3ff; font: 500 .92rem/1.6 var(--mono);
  overflow-x: auto; tab-size: 4; box-shadow: inset 0 0 0 1px rgba(34, 228, 255, .2); }
.py-code code { font: inherit; }
.py-ln { display: inline-block; min-width: 100%; padding: 0 8px; margin: 0 -8px; border-radius: 6px; transition: background .3s, box-shadow .3s; }
.py-k { color: #ff7ab0; font-weight: 700; }
.py-s { color: #b7f34a; }
.py-n { color: #ffc933; }
.py-c { color: #8f8ab8; font-style: italic; }
.py-b { color: #22e4ff; }
.py-out { position: relative; margin: -.4em 0 1.2em; padding: 30px 18px 14px; border-radius: 14px; background: #0f0b2b; color: #d8ffe0; font: 500 .9rem/1.55 var(--mono); overflow-x: auto; }
.py-out::before { content: 'Вывод'; position: absolute; top: 8px; left: 18px; font: 700 .68rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #8f8ab8; }
.py-out code { font: inherit; }

.pynote { margin: 0 0 1.2em; padding: 16px 20px; border-radius: 16px; background: #fff8e0; border: 2px solid #ffe7a1; }
.pytable-wrap { overflow-x: auto; margin: 0 0 1.2em; }
.pytable { width: 100%; border-collapse: collapse; font-size: .98rem; }
.pytable th, .pytable td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #ece8ff; }
.pytable th { font: 800 .85rem 'Rubik', sans-serif; color: var(--muted); }
.pytypes { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 0 0 1.2em; }
.pytypes__item { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 16px; background: var(--navy); color: #fff; }
.pytypes__item small { color: #c9c4f0; font-size: .85rem; line-height: 1.4; display: block; }
.pytypes__item .ps-tok { flex: none; }
.pyerrs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0 0 1.2em; }
.pyerr { padding: 14px 18px 14px 48px; position: relative; border-radius: 14px; background: #fff0f4; border: 1px solid #ffd0dd; }
.pyerr::before { content: '⚠'; position: absolute; left: 18px; top: 13px; color: #d6265a; font-weight: 900; }

.pynext { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 48px 0 0; }
.pynext__link { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border-radius: 18px; border: 2px solid #ece8ff; text-decoration: none;
  color: var(--navy) !important; font: 800 1.02rem 'Rubik', sans-serif; transition: border-color .2s, transform .2s; }
.pynext__link small { font: 700 .82rem var(--mono); color: var(--muted); }
.pynext__link:hover { border-color: var(--violet); transform: translateY(-2px); }
.pynext__link--next { text-align: right; grid-column: 2; }

/* ---------- Сцена ---------- */
.pyscene { margin: 1.4em 0 1.8em; padding: 16px; border-radius: 20px; color: #e6e3ff;
  background: var(--grid), radial-gradient(ellipse at 20% 0%, #33268a, var(--navy) 70%); background-size: 28px 28px, 28px 28px, auto;
  box-shadow: inset 0 0 0 1px rgba(34, 228, 255, .25), 0 14px 36px rgba(27, 20, 70, .25); }
.pyscene__head { margin: 0 0 12px; font: 800 1.02rem 'Rubik', sans-serif; color: #fff; }
.pyscene__tag { display: inline-block; margin-right: 8px; padding: 3px 9px; border-radius: 999px; background: rgba(34, 228, 255, .14); color: var(--cyan); font: 700 .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase; vertical-align: 2px; }
.pyscene__body { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 14px; align-items: stretch; }
.pyscene .py-code { margin: 0; background: rgba(10, 6, 34, .55); }
.pyscene .py-ln.is-on { background: rgba(34, 228, 255, .16); box-shadow: inset 3px 0 0 var(--cyan); }
.pyscene__stage { position: relative; min-height: 240px; border-radius: 14px; background: rgba(10, 6, 34, .35); padding: 10px; }
.pyscene:not(.is-live) .pyscene__stage { display: none; }
.pyscene:not(.is-live) .pyscene__body { grid-template-columns: 1fr; }
.pyscene__steps { margin: 14px 0 0; padding-left: 1.4em; color: #c9c4f0; font-size: .95rem; }
.pyscene__steps li { margin-bottom: .4em; }
.pyscene.is-live .pyscene__steps { display: none; }
.pyscene__steps code, .pyscene__say code { padding: .05em .35em; border-radius: 5px; background: rgba(34, 228, 255, .14); color: #fff; font: 600 .9em var(--mono); overflow-wrap: anywhere; }
.pyscene__ui { margin-top: 12px; }
.pyscene__say { min-height: 3.2em; margin: 0 0 12px; font-size: 1rem; line-height: 1.5; color: #fff; }
.pyscene__hint { color: #c9c4f0; }
.pyscene__n { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px; background: var(--lime); color: var(--navy); font: 800 .72rem var(--mono); vertical-align: 2px; }
.pyscene__ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pyscene__btn { padding: .5em 1em; border: 1px solid rgba(34, 228, 255, .55); border-radius: 999px; background: transparent; color: var(--cyan); font: 700 .82rem var(--mono); cursor: pointer; transition: background .2s; }
.pyscene__btn:hover { background: rgba(34, 228, 255, .12); }
.pyscene__btn:focus-visible, .pyscene__dots button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.pyscene__btn--play { min-width: 9.5em; background: var(--cyan); color: var(--navy); border-color: var(--cyan); }
.pyscene__btn--play:hover { background: #7ff0ff; }
.pyscene__dots { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 0 auto; padding: 0; list-style: none; }
.pyscene__dots button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; position: relative; }
.pyscene__dots button::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; border: 1px solid rgba(34, 228, 255, .6); transition: background .3s, transform .3s; }
.pyscene__dots .is-done::before { background: var(--violet-light); border-color: var(--violet-light); }
.pyscene__dots .is-on::before { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); transform: scale(1.25); }

/* зоны сцены */
.ps { display: flex; flex-direction: column; gap: 10px; }
.ps.is-shake { animation: ps-shake .5s; }
.ps-zone { padding: 8px 10px 10px; border-radius: 12px; border: 1px dashed rgba(167, 139, 255, .3); }
.ps-zone.is-new { animation: ps-fade .4s ease-out both; }
.ps-label { display: block; margin-bottom: 6px; font: 700 .66rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: #a49fd6; }
.ps-mem { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-end; min-height: 96px; padding-top: 26px; }
.ps-out { min-height: 30px; font: 600 .9rem/1.5 var(--mono); color: #d8ffe0; }
.ps-line { padding: 1px 0; overflow-wrap: anywhere; }
.ps-line::before { content: '› '; color: #6e6a99; }
.ps-line.is-new { animation: ps-type .5s ease-out both; }
.ps-line--err { color: #ff8fae; }
.ps-line--err::before { content: '✘ '; color: #ff5c8a; }

/* коробка-переменная: форма зависит от типа */
.ps-box { --c: var(--t-none); position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ps-box.is-new { animation: ps-pop .5s cubic-bezier(.3, 1.6, .5, 1) both; }
.ps-box.is-gone { animation: ps-gone .5s ease-in both; }
.ps-box__lid { width: 72px; height: 7px; margin-bottom: -3px; border-radius: 4px 4px 2px 2px; background: color-mix(in srgb, var(--c) 70%, #fff); opacity: .9; transition: width .4s, opacity .3s; }
.ps-box__body { position: relative; display: grid; place-items: center; width: 64px; height: 58px; overflow: hidden; border: 2px solid var(--c); border-radius: 8px;
  background: color-mix(in srgb, var(--c) 18%, transparent); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 35%, transparent);
  transition: width .45s, height .45s, border-radius .45s, border-color .45s, background .45s, clip-path .45s; }
.ps-val { max-width: 100%; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 .95rem var(--mono); color: #fff; }
.ps-val.is-in { animation: ps-drop .45s cubic-bezier(.3, 1.4, .5, 1) both; }
.ps-val--old { position: absolute; animation: ps-out .65s ease-in both; }
.ps-box__name { font: 800 .85rem var(--mono); color: #fff; padding: 1px 8px; border-radius: 6px; background: rgba(255, 255, 255, .1); }
.ps-box__type { font: 600 .68rem var(--mono); color: var(--c); min-height: 1em; }
.ps-box.is-read .ps-box__body { animation: ps-glow 1.2s ease-out; }
.ps-box.is-empty .ps-box__body { border-style: dashed; }
.ps-box.is-error { --c: #ff5c8a; }
.ps-box__note { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); padding: 3px 9px; border-radius: 8px; background: #fff; color: var(--navy);
  font: 700 .8rem var(--mono); white-space: nowrap; animation: ps-fade .3s ease-out both; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); z-index: 2; }
.ps-box__note::after { content: ''; position: absolute; top: 100%; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: #fff; }
.ps-box__note.is-done { animation: ps-note-out .45s ease-in both; }

.t-int { --c: var(--t-int); }
.t-float { --c: var(--t-float); }
.t-str { --c: var(--t-str); }
.t-bool { --c: var(--t-bool); }
.t-list { --c: var(--t-list); }
.t-none { --c: var(--t-none); }
.ps-box.t-float .ps-box__body { clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%); }
.ps-box.t-str .ps-box__body { width: 118px; height: 46px; border-radius: 23px; }
.ps-box.t-str .ps-box__lid { width: 0; opacity: 0; }
.ps-box.t-bool .ps-box__body { width: 60px; height: 60px; border-radius: 50%; }
.ps-box.t-bool .ps-box__lid { width: 0; opacity: 0; }
.ps-box.t-list .ps-box__body { width: 118px; background: repeating-linear-gradient(90deg, transparent 0 36px, color-mix(in srgb, var(--c) 55%, transparent) 36px 38px), color-mix(in srgb, var(--c) 18%, transparent); }
.ps-box.t-list .ps-box__lid { width: 126px; }
.ps-box.t-none .ps-box__body { border-style: dashed; background: transparent; box-shadow: none; }
.ps-box.t-none .ps-val { color: #a49fd6; }

/* фишка-значение (летит между коробками, лежит на конвейере, в таблице типов) */
.ps-tok { --c: var(--t-int); display: inline-grid; place-items: center; min-width: 40px; height: 34px; padding: 0 10px; border-radius: 8px; border: 2px solid var(--c);
  background: color-mix(in srgb, var(--c) 25%, var(--navy)); color: #fff; font: 700 .88rem var(--mono); white-space: nowrap; }
.ps-tok.t-str { border-radius: 17px; }
.ps-tok.t-bool { border-radius: 17px; }
.ps-tok.t-float { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%); }
.ps-tok.t-none { border-style: dashed; background: transparent; }
.ps-tok--fly { position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none; box-shadow: 0 0 18px var(--c); }

/* фабрика (функция) */
.ps-fac-wrap, .ps-fac { width: 100%; }
.ps-fac { --c: var(--violet-light); border-radius: 12px; border: 2px solid var(--c); background: rgba(167, 139, 255, .08); overflow: hidden; }
.ps-fac + .ps-fac { margin-top: 8px; }
.ps-fac.is-new { animation: ps-pop .5s cubic-bezier(.3, 1.4, .5, 1) both; }
.ps-fac__roof { padding: 6px 12px; background: repeating-linear-gradient(-45deg, rgba(167, 139, 255, .28) 0 10px, rgba(167, 139, 255, .16) 10px 20px); font: 700 .88rem var(--mono); color: #fff; }
.ps-fac__def { color: #ff7ab0; }
.ps-fac__row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; }
.ps-fac__in, .ps-fac__out { position: relative; padding: 6px 8px; border-radius: 8px; border: 1px dashed rgba(34, 228, 255, .55); font: 700 .7rem var(--mono); color: var(--cyan); text-align: center; white-space: nowrap; }
.ps-fac__out.is-read { animation: ps-glow 1.2s ease-out; }
.ps-fac__ret { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 4px); animation: ps-drop .45s both; z-index: 2; }
.ps-fac__body { display: flex; align-items: center; gap: 12px; min-height: 92px; padding: 18px 8px 4px; border-radius: 10px; background: rgba(10, 6, 34, .35); }
.ps-fac__gear { font-size: 1.8rem; line-height: 1; color: var(--c); }
.ps-fac.is-on .ps-fac__gear { animation: ps-spin 1.6s linear infinite; color: var(--cyan); }
.ps-fac__locals { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.ps-fac__locals .ps-box__body { width: 52px; height: 44px; }
.ps-fac__locals .ps-box.t-str .ps-box__body { width: 96px; }
.ps-fac__locals .ps-box__lid { width: 58px; }

/* развилка (if / elif / else) */
.ps-fork { position: relative; padding-top: 4px; }
.ps-fork__start { display: flex; justify-content: center; height: 34px; }
.ps-car { display: inline-block; font-size: 1.6rem; line-height: 1; transition: transform .85s cubic-bezier(.45, .05, .35, 1); z-index: 3; position: relative; }
.ps-fork__roads { display: grid; grid-template-columns: repeat(var(--roads, 2), minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.ps-road { display: flex; flex-direction: column; align-items: center; gap: 6px; transition: opacity .4s; }
.ps-road__gate { width: 100%; padding: 6px 6px 5px; border-radius: 8px; border: 2px solid rgba(255, 201, 51, .6); background: rgba(255, 201, 51, .08); text-align: center; transition: border-color .3s, background .3s; }
.ps-road__gate code { display: block; font: 700 .76rem var(--mono); color: #fff; overflow-wrap: anywhere; }
.ps-road__res { display: block; min-height: 1.1em; font: 600 .7rem var(--mono); color: #c9c4f0; }
.ps-road__res b { color: inherit; }
.ps-road.is-true .ps-road__gate { border-color: var(--lime); background: rgba(183, 243, 74, .14); }
.ps-road.is-true .ps-road__res { color: var(--lime); }
.ps-road.is-false .ps-road__gate { border-color: #ff5c8a; background: rgba(255, 92, 138, .12); }
.ps-road.is-false .ps-road__res { color: #ff8fae; }
.ps-road.is-false .ps-road__res span, .ps-road.is-true .ps-road__res span { color: #c9c4f0; }
.ps-road__path { width: 6px; height: 34px; border-radius: 3px; background: repeating-linear-gradient(180deg, rgba(255, 255, 255, .25) 0 6px, transparent 6px 12px); }
.ps-road.is-go .ps-road__path { background: repeating-linear-gradient(180deg, var(--lime) 0 6px, transparent 6px 12px); background-size: 6px 12px; animation: ps-road .5s linear infinite; box-shadow: 0 0 10px var(--lime); }
.ps-road__end { font: 600 .72rem var(--mono); color: #c9c4f0; text-align: center; overflow-wrap: anywhere; }
.ps-road.is-go .ps-road__end { color: #fff; }
.ps-road.is-off { opacity: .32; }

/* конвейер (for) */
.ps-belt__title { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ps-belt__title code { font: 700 .82rem var(--mono); color: #fff; }
.ps-belt__lap { font: 600 .72rem var(--mono); color: var(--lime); }
.ps-belt__track { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 10px 14px; border-radius: 10px;
  background: linear-gradient(transparent calc(100% - 6px), rgba(255, 255, 255, .18) 0) , repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 14px, transparent 14px 28px); }
.ps-belt__item { transition: transform .4s, opacity .4s, box-shadow .4s; }
.ps-belt__item.is-cur { transform: translateY(-4px); box-shadow: 0 0 16px var(--c); }
.ps-belt__item.is-done { opacity: .3; }
.ps-belt.is-end .ps-belt__track { opacity: .6; }

/* условие while */
.ps-cond { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font: 600 .85rem var(--mono); color: #fff; }
.ps-cond b { font-weight: 700; font-size: .78rem; color: #c9c4f0; }
.ps-cond.is-read { animation: ps-fade .4s; }
.ps-lamp { width: 20px; height: 20px; border-radius: 50%; flex: none; }
.ps-lamp.is-true { background: var(--lime); box-shadow: 0 0 14px var(--lime); }
.ps-lamp.is-false { background: #ff5c8a; box-shadow: 0 0 14px #ff5c8a; }

@keyframes ps-pop { from { opacity: 0; transform: scale(.4) translateY(10px); } }
@keyframes ps-gone { to { opacity: 0; transform: scale(.4) translateY(10px); } }
@keyframes ps-fade { from { opacity: 0; transform: translateY(6px); } }
@keyframes ps-type { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
@keyframes ps-drop { from { opacity: 0; transform: translateY(-26px); } }
@keyframes ps-out { to { opacity: 0; transform: translate(26px, 34px) rotate(40deg); } }
@keyframes ps-glow { 0%, 100% { box-shadow: 0 0 14px color-mix(in srgb, var(--c, #22e4ff) 35%, transparent); } 30% { box-shadow: 0 0 0 4px #fff, 0 0 28px var(--c, #22e4ff); } }
@keyframes ps-note-out { to { opacity: 0; transform: translate(-50%, 18px) scale(.6); } }
@keyframes ps-spin { to { transform: rotate(360deg); } }
@keyframes ps-road { to { background-position: 0 12px; } }
@keyframes ps-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- Песочница ---------- */
.pyplay { margin: 1.4em 0 1.8em; padding: 20px; border-radius: 20px; background: #fff; border: 2px solid var(--violet-light); box-shadow: var(--shadow); }
.pyplay__title { margin: 0 0 14px; font: 800 1.05rem 'Rubik', sans-serif; color: var(--navy); }
.pyplay__tag { display: inline-block; margin-right: 6px; padding: 3px 10px; border-radius: 999px; background: var(--lime); color: var(--navy); font: 700 .75rem var(--mono); vertical-align: 2px; }
.pyplay__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: center; }
.pyplay__field { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-weight: 700; }
.pyplay__field input[type=text], .pyplay__field input[type=number], .pyplay__field select { flex: 1; min-width: 0; padding: 10px 12px; border: 2px solid #ddd6ff; border-radius: 12px;
  font: 600 1rem var(--mono); color: var(--navy); background: #fff; }
.pyplay__field input:focus, .pyplay__field select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(107, 76, 237, .2); }
.pyplay__field--range { flex-direction: column; align-items: stretch; }
.pyplay__field input[type=range] { width: 100%; accent-color: var(--violet); }
.pyplay__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pyplay__chips button { padding: 5px 10px; border: 1px solid #ddd6ff; border-radius: 999px; background: var(--bg); font: 600 .85rem var(--mono); color: var(--navy); cursor: pointer; }
.pyplay__chips button:hover { border-color: var(--violet); }
.pyplay__out { margin: 0; color: var(--text); min-height: 1.6em; }
.pyplay__out--big { font-weight: 800; font-size: 1.1rem; }
.pyplay__err { color: #c41d4f; font-weight: 700; }
.pyplay__stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 170px; padding: 20px; border-radius: 16px;
  background: var(--grid), radial-gradient(ellipse at 20% 0%, #33268a, var(--navy) 70%); background-size: 28px 28px, 28px 28px, auto; }
.pyplay__stage .pyplay__out { color: #fff; }
.pyplay__stage .ps-box { transform: scale(1.3); margin: 12px 0; }
.pyplay__gates { display: grid; gap: 8px; margin: 4px 0 14px; }
.pyplay__gate { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 2px solid #ece8ff; transition: border-color .25s, background .25s, opacity .25s; }
.pyplay__gate code { min-width: 9.5em; }
.pyplay__cmp { color: var(--muted); font: 600 .9rem var(--mono); }
.pyplay__res { margin-left: auto; font: 800 .85rem var(--mono); }
.pyplay__gate.is-hit { border-color: var(--lime-dark); background: #f3ffe0; }
.pyplay__gate.is-hit .pyplay__res { color: #3d7a00; }
.pyplay__gate.is-false .pyplay__res { color: #c41d4f; }
.pyplay__gate.is-skip { opacity: .45; }
.pyplay__nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pyplay__nums .pyplay__field { flex-direction: column; align-items: stretch; gap: 4px; font: 700 .85rem var(--mono); }
.pyplay__code { margin: 0 0 10px; white-space: pre; }
.pyplay__belt { display: flex; flex-wrap: wrap; gap: 6px; min-height: 52px; margin-bottom: 12px; padding: 10px; border-radius: 14px; background: var(--navy); }
.pyplay__belt .ps-tok { animation: ps-drop .35s ease-out both; }
.pyplay .ps-fac { width: 100%; }
.pyplay .ps-fac__locals .ps-tok { height: 30px; }
.pyplay .pyplay__out .ps-tok { height: 30px; }

/* ---------- Тест ---------- */
.pyquiz-list { display: grid; gap: 16px; }
.pyquiz { padding: 20px; border-radius: 18px; background: var(--bg); border: 2px solid #ece8ff; }
.pyquiz__q { margin: 0 0 12px; font-weight: 800; }
.pyquiz__n { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 6px; border-radius: 50%; background: var(--violet); color: #fff; font: 800 .85rem var(--mono); }
.pyquiz .py-code { margin-bottom: 12px; }
.pyquiz__opts { display: flex; flex-wrap: wrap; gap: 8px; }
.pyquiz__opt { padding: 10px 16px; border: 2px solid #ddd6ff; border-radius: 12px; background: #fff; font: 700 .98rem 'Nunito', sans-serif; color: var(--text); cursor: pointer; transition: border-color .2s, background .2s, transform .15s; }
.pyquiz__opt:hover:not(:disabled) { border-color: var(--violet); transform: translateY(-1px); }
.pyquiz__opt:disabled { cursor: default; opacity: .6; }
.pyquiz__opt.is-ok { border-color: var(--lime-dark); background: #ecffd0; opacity: 1; }
.pyquiz__opt.is-no { border-color: #ff5c8a; background: #ffe3eb; opacity: 1; }
.pyquiz__why { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: #fff; animation: ps-fade .35s ease-out both; }

/* ---------- Адаптив ---------- */
@media (max-width: 1000px) {
  .pylesson__grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .pytoc { position: static; max-height: none; padding: 14px 18px; border-radius: 16px; background: var(--bg); }
  .pytoc summary { margin: 0; }
  .pytoc details[open] summary { margin-bottom: 10px; }
}
@media (max-width: 760px) {
  .pyscene { padding: 12px; margin-inline: -8px; }
  .pyscene__body, .pyplay__grid { grid-template-columns: minmax(0, 1fr); }
  .pyplay__field select { width: 100%; }
  .pyscene .py-code { font-size: .84rem; }
  .pyscene__stage { min-height: 200px; }
  .pyscene__dots { margin-left: 0; width: 100%; }
  .pynext { grid-template-columns: 1fr; }
  .pynext__link--next { grid-column: 1; }
  .ps-road__gate code { font-size: .68rem; }
  .pyplay { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .ps-car { transition: none; }
}
