/* Rust с нуля — стили. Без внешних шрифтов и зависимостей. */
:root {
  --bg: #f7f3ec;
  --surface: #fffdf8;
  --surface-2: #efe8dc;
  --text: #1f1a14;
  --muted: #6b6153;
  --line: #ddd2c1;
  --accent: #b7410e;
  --accent-ink: #ffffff;
  --accent-soft: #f6dccb;
  --ok: #1d7a46;
  --ok-soft: #d9f0e2;
  --bad: #b42318;
  --bad-soft: #fbe1de;
  --info-soft: #e3ecf7;
  --info: #1f4f8a;
  --code-bg: #2a241d;
  --code-text: #f3ebe0;
  --hero-warm: #ffebde;
  --hero-cool: #f1e8ff;
  --sticker-peach: #ffead7;
  --sticker-lilac: #eee5fa;
  --sticker-mint: #e1efe5;
  --shadow: 0 6px 20px rgba(87, 52, 30, .07);
  --radius: 14px;
  --font: "Segoe UI", "PT Sans", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, "DejaVu Sans Mono", monospace;
  --fs: 18px;
  --measure: 40rem;
}
[data-theme="dark"] {
  --bg: #17140f;
  --surface: #211d17;
  --surface-2: #2b261f;
  --text: #ece4d8;
  --muted: #a79c8c;
  --line: #3a342b;
  --accent: #f08a4b;
  --accent-ink: #1a120b;
  --accent-soft: #3d2a1d;
  --ok: #5fd08f;
  --ok-soft: #173325;
  --bad: #ff8a7a;
  --bad-soft: #3d1f1b;
  --info-soft: #1d2a3a;
  --info: #9cc2f0;
  --code-bg: #0f0d0a;
  --code-text: #ece4d8;
  --hero-warm: #37251c;
  --hero-cool: #30243a;
  --sticker-peach: #432e23;
  --sticker-lilac: #3a2d48;
  --sticker-mint: #25392f;
  --shadow: 0 6px 20px rgba(0, 0, 0, .17);
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #17140f; --surface: #211d17; --surface-2: #2b261f; --text: #ece4d8; --muted: #a79c8c;
    --line: #3a342b; --accent: #f08a4b; --accent-ink: #1a120b; --accent-soft: #3d2a1d;
    --ok: #5fd08f; --ok-soft: #173325; --bad: #ff8a7a; --bad-soft: #3d1f1b;
    --info-soft: #1d2a3a; --info: #9cc2f0; --code-bg: #0f0d0a; --code-text: #ece4d8;
    --hero-warm: #37251c; --hero-cool: #30243a;
    --sticker-peach: #432e23; --sticker-lilac: #3a2d48; --sticker-mint: #25392f;
    --shadow: 0 6px 20px rgba(0, 0, 0, .17);
  }
}

* { box-sizing: border-box; }
html { font-size: var(--fs); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem 1rem; z-index: 10; }

/* Верхняя панель */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 1.9rem; height: 1.9rem; flex: none; border-radius: 7px;
}
.topbar nav { margin-left: auto; display: flex; gap: .25rem; flex-wrap: wrap; }
.navlink {
  padding: .3rem .7rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .85rem;
}
.navlink:hover, .navlink[aria-current="page"] { background: var(--surface-2); color: var(--text); }

main { padding: 1.25rem 1rem 5rem; }
.wrap { max-width: var(--measure); margin: 0 auto; }
.wrap-wide { max-width: 56rem; margin: 0 auto; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .9rem; }
ul, ol { margin: 0 0 .9rem; padding-left: 1.3rem; }
li { margin: .2rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.6rem; padding: .45rem 1.1rem;
  border: 2px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--text); }
.btn-sm { min-height: 2.1rem; padding: .25rem .8rem; font-size: .88rem; }

/* Главная */
.hero {
  padding: clamp(1rem, 3vw, 2.15rem); margin-bottom: 1.4rem;
  background: linear-gradient(120deg, var(--hero-warm), var(--hero-cool));
  border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
}
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(1rem, 3vw, 2rem); align-items: center;
}
.hero-kicker {
  display: inline-block; padding: .15rem .65rem; margin-bottom: .55rem; border-radius: 99px;
  background: var(--surface); color: var(--accent); font-size: .8rem; font-weight: 750;
}
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.65rem); letter-spacing: -.035em; }
.hero p { font-size: 1rem; color: var(--muted); max-width: 34rem; }
.hero-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.hero-actions .btn { text-align: center; }
.hero-companion { min-width: 0; text-align: center; }
.hero-art { position: relative; width: 100%; aspect-ratio: 1.22; transform: rotate(2deg); }
.hero-art img, .fox-pose-slot, .fox-effects { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-art img { object-fit: contain; filter: drop-shadow(0 8px 10px rgba(60, 28, 20, .18)); }
.fox-wave-marks, .fox-hearts, .fox-stretch-stars, .fox-cookie-crumbs, .fox-nap-letters { opacity: 0; }
.hero-art.has-pose .hero-fox-idle { opacity: 0; }
.hero-art[data-fox-reaction="wave"] .fox-wave-marks,
.hero-art[data-fox-reaction="pet"] .fox-hearts,
.hero-art[data-fox-reaction="stretch"] .fox-stretch-stars,
.hero-art[data-fox-reaction="cookie"] .fox-cookie-crumbs,
.hero-art[data-fox-reaction="nap"] .fox-nap-letters { opacity: 1; }
.fox-effects { pointer-events: none; overflow: visible; }
.fox-trigger { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 0; border-radius: 1rem; background: transparent; cursor: pointer; }
.fox-response { display: block; min-height: 1.5em; margin-top: .3rem; color: var(--muted); font-size: .8rem; }
.stats { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: 1rem; font-size: .83rem; color: var(--muted); }
.stats > span { padding: .18rem .65rem; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; }
.stats b { color: var(--text); }

.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .8rem; margin: 0 0 1.8rem; }
.how div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; font-size: .92rem; box-shadow: var(--shadow); }
.how div::before {
  content: ""; display: block; width: 1.55rem; height: .3rem; margin-bottom: .45rem;
  background: var(--sticker-peach); border-radius: 99px;
}
.how div:nth-child(2)::before, .how div:nth-child(4)::before { background: var(--sticker-lilac); }
.how div:nth-child(3)::before { background: var(--sticker-mint); }
.how b { display: block; margin-bottom: .15rem; }

.map-guide {
  display: flex; align-items: center; flex-wrap: wrap; gap: .6rem 1.4rem;
  margin-bottom: .8rem; padding: .45rem 1rem .7rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: linear-gradient(120deg, var(--hero-warm), var(--hero-cool));
}
.map-scene { display: block; width: min(100%, 14rem); height: auto; }
.map-guide-copy { min-width: 0; }
.map-guide-copy span { display: block; color: var(--muted); font-size: .85rem; }
.map-guide-copy a { font-weight: 700; overflow-wrap: anywhere; }
.map-next-flag { display: block; width: 1.1rem; height: 1.1rem; }
.lessons .is-next a { background: var(--hero-cool); }
.lessons .is-next a:hover { background: var(--sticker-lilac); }
.map-spark { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  .anim .map-scene.is-in-view .map-paper {
    transform-box: fill-box; transform-origin: left center; animation: map-unfold .52s ease-out both;
  }
  .anim .map-scene.is-in-view .map-paw { animation: map-paw .52s ease-out; }
  .anim .map-scene.is-in-view .map-crab { animation: map-sidestep .45s .38s ease-out both; }
  .anim .map-scene.is-in-view .map-scene-flag { animation: map-plant .35s .77s ease-out both; }
  .anim .map-scene.is-in-view .map-spark { animation: map-spark .36s 1.04s ease-out; }
  .anim .map-next-flag.is-in-view { animation: map-plant .32s ease-out; }
}
@keyframes map-unfold { from { transform: scaleX(.15); } }
@keyframes map-paw { 50% { transform: translate(3px, -3px); } }
@keyframes map-sidestep {
  from { transform: translateX(-24px); }
  30% { transform: translate(-16px, -3px); }
  65% { transform: translate(-7px, 0); }
  85% { transform: translate(-3px, -2px); }
}
@keyframes map-plant {
  from { opacity: 0; transform: translateY(-9px); }
  75% { opacity: 1; transform: translateY(1px); }
}
@keyframes map-spark { 35% { opacity: 1; } to { opacity: 0; transform: translateY(-4px); } }

.module {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: .8rem; overflow: hidden; box-shadow: var(--shadow);
}
.module > summary {
  list-style: none; cursor: pointer; padding: .9rem 1rem; display: grid;
  grid-template-columns: 2.4rem 1fr auto; gap: .8rem; align-items: center;
}
.module > summary::-webkit-details-marker { display: none; }
.module > summary:hover { background: var(--surface-2); }
.module > summary:focus-visible { outline-offset: -3px; border-radius: var(--radius); }
.mod-num {
  width: 2.4rem; height: 2.4rem; border-radius: 8px; display: grid; place-items: center;
  background: var(--sticker-peach); font-family: var(--mono); font-weight: 700;
}
.module:nth-of-type(3n) .mod-num { background: var(--sticker-lilac); }
.module:nth-of-type(3n + 1) .mod-num { background: var(--sticker-mint); }
.module.done .mod-num { background: var(--ok-soft); color: var(--ok); }
.mod-title { font-weight: 650; }
.mod-sub { font-size: .85rem; color: var(--muted); }
.mod-meter { font-size: .8rem; color: var(--muted); text-align: right; white-space: nowrap; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: .3rem; width: 5.5rem; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; }
.lessons { list-style: none; margin: 0; padding: 0 1rem .8rem 4.2rem; }
.lessons li { margin: 0; }
.lessons a {
  display: flex; gap: .6rem; align-items: baseline; padding: .4rem .5rem; border-radius: 6px;
  text-decoration: none; color: var(--text);
}
.lessons a:hover { background: var(--surface-2); }
.tick { width: 1.1rem; flex: none; color: var(--muted); font-weight: 700; }
.lessons .is-done .tick { color: var(--ok); }
.lessons .mins { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* Урок */
.lesson-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .9rem; }
.lesson-head .crumbs { font-size: .82rem; color: var(--muted); }
.lesson-head h1 { font-size: 1.35rem; margin: 0; }
.progress { display: flex; gap: 4px; margin: 0 0 1.1rem; }
.progress span { flex: 1; height: 7px; border-radius: 99px; background: var(--surface-2); }
.progress span.on { background: var(--accent); }
.progress span.cur { background: var(--accent); opacity: .5; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.3rem 1.3rem 1.1rem; min-height: 12rem; box-shadow: var(--shadow);
}
.card-kind {
  display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: .5rem; font-weight: 700;
}
.card strong { color: var(--text); background: linear-gradient(transparent 62%, var(--accent-soft) 62%); }

.lesson-nav { display: flex; gap: .6rem; justify-content: space-between; margin-top: 1rem; align-items: center; }
.lesson-nav .hint { font-size: .82rem; color: var(--muted); }

/* Плашки */
.note, .warn, .tip {
  border-radius: 8px; padding: .65rem .9rem; margin: 0 0 .9rem; font-size: .95rem;
  border-left: 4px solid;
}
.tip { background: var(--info-soft); border-color: var(--info); }
.warn { background: var(--bad-soft); border-color: var(--bad); }
.note { background: var(--surface-2); border-color: var(--line); }

/* Код */
code {
  font-family: var(--mono); font-size: .86em; background: var(--surface-2);
  padding: .08em .35em; border-radius: 5px;
}
pre.code, .editor {
  font-family: var(--mono); font-size: .86rem; line-height: 1.55;
  background: var(--code-bg); color: var(--code-text);
  border-radius: 10px; margin: 0 0 .9rem; tab-size: 4;
}
pre.code { padding: .85rem 1rem; overflow-x: auto; white-space: pre; }
pre.code code { background: none; padding: 0; font-size: inherit; }
.editor { position: relative; overflow: hidden; }
.editor pre, .editor textarea {
  margin: 0; padding: .85rem 1rem; border: 0; font: inherit; line-height: inherit; tab-size: 4;
  white-space: pre; overflow-wrap: normal; word-wrap: normal; letter-spacing: normal;
}
.editor pre { pointer-events: none; overflow: hidden; min-height: 3rem; }
.editor textarea {
  position: absolute; inset: 0; width: 100%; height: 100%; resize: none;
  background: transparent; color: transparent; caret-color: #ffb27a; overflow: auto;
}
.editor textarea::selection { background: rgba(255, 178, 122, .35); color: transparent; }
.editor-label { font-size: .78rem; color: var(--muted); margin: -.4rem 0 .4rem; }
.tok-kw { color: #ff9e64; }
.tok-ty { color: #7dcfb6; }
.tok-str { color: #c3e88d; }
.tok-num { color: #f7c66b; }
.tok-com { color: #8a8070; font-style: italic; }
.tok-mac { color: #82aaff; }
.tok-fn { color: #ffd479; }
.tok-life { color: #e0a3ff; }
.tok-attr { color: #a0a0a0; }

.runbar { display: flex; gap: .5rem; flex-wrap: wrap; margin: -.4rem 0 .9rem; }
.output {
  font-family: var(--mono); font-size: .84rem; white-space: pre-wrap; word-break: break-word;
  border-radius: 10px; padding: .7rem .9rem; margin: 0 0 .9rem; border: 1px solid var(--line);
  background: var(--surface-2); max-height: 22rem; overflow: auto;
}
.output .lbl { display: block; font-family: var(--font); font-size: .75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .2rem; }
.output.err { border-color: var(--bad); }
.output.ok { border-color: var(--ok); }
.explain-err { font-family: var(--font); background: var(--bad-soft); border-radius: 8px; padding: .55rem .8rem; margin-top: .5rem; white-space: normal; }

/* Квизы */
.options { display: grid; gap: .5rem; margin: .4rem 0 .9rem; }
.opt {
  text-align: left; padding: .65rem .9rem; border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
  display: flex; gap: .7rem; align-items: baseline;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .letter { font-family: var(--mono); font-weight: 700; color: var(--muted); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.opt code { white-space: pre-wrap; }
.feedback { border-radius: 8px; padding: .6rem .9rem; margin: 0 0 .8rem; }
.feedback.good { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }

.fill-code { line-height: 2.1; }
.fill-code input {
  font: inherit; width: 7ch; min-width: 3ch; padding: 0 .3rem; border-radius: 5px;
  border: 2px dashed #ffb27a; background: rgba(255,255,255,.08); color: #fff;
}
.fill-code input.right { border: 2px solid #5fd08f; }
.fill-code input.wrong { border: 2px solid #ff8a7a; }

/* Итоги */
.tldr { list-style: none; padding: 0; margin: 0 0 1rem; }
.tldr li {
  padding: .55rem .8rem .55rem 2.2rem; position: relative; border-radius: 8px; margin-bottom: .4rem;
  background: var(--surface-2);
}
.tldr li::before { content: "✓"; position: absolute; left: .8rem; color: var(--ok); font-weight: 800; }
.finish { text-align: left; }
.finish-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: .8rem; }
.finish-mark { width: 3rem; height: 3rem; border-radius: 10px; }
.finish .big { font-size: 1.6rem; font-weight: 750; margin-bottom: .3rem; }
.break-box { background: var(--info-soft); border-radius: 10px; padding: .8rem 1rem; margin: 1rem 0; }

/* Глоссарий, шпаргалка, настройки */
.search { width: 100%; font: inherit; padding: .6rem .9rem; border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface); color: var(--text); margin-bottom: 1rem; }
.gloss-entry { border-bottom: 1px solid var(--line); }
.gloss-entry summary { padding: .7rem 0; cursor: pointer; font-weight: 700; }
.gloss-entry summary small { font-weight: 400; color: var(--muted); font-family: var(--mono); }
.gloss-definition { display: grid; gap: .65rem 1rem; padding: .15rem 0 1rem; }
.gloss-empty { text-align: center; }
.gloss-empty .section-fox { margin: .4rem auto 0; }
.section-fox { width: min(100%, 16rem); }
.section-fox img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: contain; }
.cheat-recap-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin: 1.3rem 0 .5rem; }
.cheat .cheat-recap-head h3 { margin: 0; }
.cheat-reaction { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; color: var(--muted); }
.cheat-reaction:has(.section-fox:not([hidden])) { margin-bottom: .6rem; }
@media (min-width: 600px) {
  .gloss-definition { grid-template-columns: minmax(0, 1fr) 16rem; align-items: center; }
}
@media (prefers-reduced-motion: no-preference) {
  .anim [data-fox-scene="book"] .ready { animation: fox-shelf .55s ease-out; }
  .anim [data-fox-scene="search"] .ready { animation: fox-look .72s ease-in-out; }
  .anim [data-fox-scene="copy"] .ready { animation: fox-note .52s ease-out; }
}
@keyframes fox-shelf {
  from { opacity: 0; transform: translateX(13px) rotate(3deg); }
  66% { transform: translateX(-3px) rotate(-1deg); }
}
@keyframes fox-look {
  0% { opacity: 0; transform: translateY(-5px); }
  42% { transform: translate(3px, 3px) rotate(2deg); }
  76% { transform: translateX(-3px) rotate(-2deg); }
}
@keyframes fox-note {
  from { opacity: 0; transform: translateY(9px) rotate(-3deg); }
  65% { transform: translateY(-3px) rotate(1deg); }
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--text); padding: .4rem .9rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: .4rem 0; }
.cheat h3 { margin-top: 1.3rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .55rem 1rem; border-radius: 99px; font-size: .9rem; z-index: 20;
}

@media (max-width: 600px) {
  :root { --fs: 17px; }
  .card { padding: 1rem .95rem; }
  .lessons { padding-left: 1rem; }
  .module > summary { grid-template-columns: 2.1rem 1fr; }
  .mod-meter { grid-column: 2; text-align: left; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-companion { width: min(100%, 19rem); justify-self: center; }
  .topbar nav .navlink.optional { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .anim:not(.focus) .card, .anim:not(.focus) .feedback.good { animation: rise .22s ease-out; }
  .anim .hero-art { animation: postcard-in .42s ease-out; }
  .anim .hero-art[data-fox-reaction="wave"] .hero-fox-pose { animation: fox-wave .76s ease-in-out; }
  .anim .hero-art[data-fox-reaction="wave"] .fox-wave-marks { animation: fox-wave-marks .76s ease-out; }
  .anim .hero-art[data-fox-reaction="pet"] .hero-fox-idle { animation: fox-hop .66s ease-out; }
  .anim .hero-art[data-fox-reaction="pet"] .fox-hearts path { animation: fox-heart .65s ease-out both; }
  .anim .hero-art[data-fox-reaction="pet"] .fox-hearts path:nth-child(2) { animation-delay: .09s; }
  .anim .hero-art[data-fox-reaction="pet"] .fox-hearts path:nth-child(3) { animation-delay: .17s; }
  .anim .hero-art[data-fox-reaction="stretch"] .hero-fox-pose { transform-origin: center bottom; animation: fox-stretch .9s ease-in-out; }
  .anim .hero-art[data-fox-reaction="stretch"] .fox-stretch-stars { animation: fox-twinkle .9s ease-out; }
  .anim .hero-art[data-fox-reaction="cookie"] .hero-fox-pose { transform-origin: 60% 88%; animation: fox-nibble .95s ease-in-out; }
  .anim .hero-art[data-fox-reaction="cookie"] .fox-cookie-crumbs circle { animation: fox-crumb .82s .1s ease-out both; }
  .anim .hero-art[data-fox-reaction="cookie"] .fox-cookie-crumbs circle:nth-child(2) { animation-delay: .22s; }
  .anim .hero-art[data-fox-reaction="cookie"] .fox-cookie-crumbs circle:nth-child(3) { animation-delay: .3s; }
  .anim .hero-art[data-fox-reaction="nap"] .hero-fox-pose { transform-origin: center bottom; animation: fox-breathe 1.55s ease-in-out; }
  .anim .hero-art[data-fox-reaction="nap"] .fox-nap-letters path { animation: fox-doze 1.1s ease-out both; }
  .anim .hero-art[data-fox-reaction="nap"] .fox-nap-letters path:nth-child(2) { animation-delay: .22s; }
  .anim .hero-art[data-fox-reaction="nap"] .fox-nap-letters path:nth-child(3) { animation-delay: .44s; }
  .anim:not(.focus) .finish-new .finish-mark,
  .anim:not(.focus) .brand:focus-visible .brand-mark { animation: crab-hop .38s ease-in-out; }
  .anim:not(.focus) .btn { transition: filter .15s, transform .15s; }
  .anim:not(.focus) .btn:active:not(:disabled) { transform: translateY(1px); }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .anim:not(.focus) .brand:hover .brand-mark { animation: crab-hop .38s ease-in-out; }
  .anim .hero-art:not([data-fox-reaction]) .hero-fox-idle { transition: transform .22s ease-out; }
  .anim .hero-art:not([data-fox-reaction]):hover .hero-fox-idle { transform: translateY(-4px) rotate(-2deg); }
}
@keyframes rise {
  from { opacity: .45; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@keyframes postcard-in {
  from { opacity: .45; transform: translateY(5px) rotate(-1deg); }
  to { opacity: 1; transform: rotate(2deg); }
}
@keyframes fox-wave {
  18%, 62% { transform: rotate(-2deg); }
  42%, 80% { transform: rotate(1deg); }
}
@keyframes fox-wave-marks {
  0%, 100% { opacity: 0; }
  25%, 62% { opacity: 1; }
  42% { opacity: .4; }
}
@keyframes fox-hop {
  15% { transform: scale(1.02, .96); }
  42% { transform: translateY(-12px) scale(.98, 1.03); }
  72% { transform: translateY(0) scale(1.02, .98); }
}
@keyframes fox-heart {
  0% { opacity: 0; transform: translateY(9px); }
  30% { opacity: 1; }
  78% { opacity: .9; }
  100% { opacity: 0; transform: translateY(-9px); }
}
@keyframes fox-stretch {
  22% { transform: scale(1.01, .985); }
  52% { transform: translateY(-5px) scale(.98, 1.035); }
}
@keyframes fox-twinkle {
  0%, 100% { opacity: 0; }
  45% { opacity: 1; }
  75% { opacity: .55; }
}
@keyframes fox-nibble {
  25%, 64% { transform: rotate(1.2deg); }
  44%, 80% { transform: rotate(-.55deg); }
}
@keyframes fox-crumb {
  0% { opacity: 0; transform: translateY(-3px); }
  28% { opacity: 1; }
  100% { opacity: 0; transform: translate(7px, 12px); }
}
@keyframes fox-breathe {
  50% { transform: scaleY(.985); }
}
@keyframes fox-doze {
  0% { opacity: 0; transform: translateY(9px); }
  33%, 68% { opacity: 1; }
  100% { opacity: 0; transform: translate(5px, -6px); }
}
@keyframes crab-hop {
  50% { transform: translateY(-4px) rotate(-8deg); }
}
body.focus .topbar nav { display: none; }
#card:focus, #app:focus { outline: none; }
@media (max-width: 600px) {
  .topbar { gap: .4rem; padding: .45rem .6rem; }
  .brand > span:last-child {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .topbar nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .navlink { padding: .3rem .55rem; white-space: nowrap; }
}
.editor pre code { background: none; padding: 0; font-size: inherit; border-radius: 0; }
.out-wrap .explain-err { margin: 0 0 .6rem; }
.langbtn {
  border: 2px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: .2rem .65rem; font-size: .8rem; font-weight: 700; cursor: pointer; font-family: var(--mono);
}
.langbtn:hover { border-color: var(--accent); }
.tag { display: inline-block; font-size: .7rem; padding: 0 .45rem; border-radius: 99px; background: var(--info-soft); color: var(--info); vertical-align: middle; font-weight: 600; }
.plan { background: var(--surface-2); border-radius: 8px; padding: .5rem .8rem; font-size: .92rem; }
.progress span.optional { background-image: repeating-linear-gradient(90deg, transparent 0 4px, rgba(0,0,0,.12) 4px 6px); }
.card.deep { border-style: dashed; }
.deep-body { border: 1px solid var(--line); border-radius: 10px; padding: .2rem .9rem; margin-top: .4rem; background: var(--surface); }
.deep-body > summary { cursor: pointer; padding: .55rem 0; list-style: none; display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.deep-body > summary::-webkit-details-marker { display: none; }
.deep-title { font-weight: 700; }
.deep-toggle { font-size: .82rem; color: var(--accent); text-decoration: underline; }
.deep-content { padding: .3rem 0 .6rem; }
.lesson-nav .hint { text-align: center; }
@media (max-width: 600px) { .lesson-nav .hint { display: none; } }

/* Реакции маскотов */
.mascot { display: block; width: 3.65rem; height: auto; overflow: visible; }
.mascot-bubble { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .6rem; align-items: center; }
.mascot-bubble > div { overflow-wrap: anywhere; }
.mascot-hint { overflow: hidden; }
.resume-note { margin-top: .7rem; color: var(--muted); font-size: .85rem; }
.resume-note .mascot { width: 3rem; }
.mod-num .mascot { width: 1.9rem; }
.compiler-tip { margin: 0; }
.compiler-tip + .compiler-tip { margin-top: .35rem; }
.theme-panel { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.theme-mascot .mascot { width: 4.6rem; }
.mascot .fox-head, .mascot .fox-ear, .mascot .laptop-lid, .mascot .curtain-left, .mascot .curtain-right { transform-box: fill-box; }
.mascot .fox-head { transform-origin: center; }
.mascot .fox-ear, .mascot .laptop-lid { transform-origin: center bottom; }
.mascot .laptop-lid { transform: scaleY(.16); }
.mascot .curtain-left { transform-origin: left; transform: scaleX(.24); }
.mascot .curtain-right { transform-origin: right; transform: scaleX(.24); }

@media (prefers-reduced-motion: no-preference) {
  .anim:not(.focus) .mascot-hint .fox-head { animation: mascot-peek .32s ease-out; }
  .anim:not(.focus) .mascot-success .fox-ear { animation: mascot-ear .42s ease-out; }
  .anim:not(.focus) .mascot-success .crab-claws { animation: mascot-claws .42s ease-out; }
  .anim:not(.focus) .mascot-error .fox-head { animation: mascot-tilt .42s ease-in-out; }
  .anim:not(.focus) .mascot-run .key-claw { animation: mascot-press .32s ease-out; }
  .anim:not(.focus) .mascot-run .screen-led { animation: mascot-light .35s .08s ease-out backwards; }
  .anim:not(.focus) .finish-new .laptop-lid { animation: mascot-close .48s ease-in-out; }
  .anim:not(.focus) .stamp-new .mascot-paw { animation: mascot-stamp .35s ease-out; }
  .anim:not(.focus) .mascot-bookmark .ribbon { animation: mascot-bookmark .36s ease-out; }
  .anim:not(.focus) .theme-mascot.is-new .lamp-light { animation: mascot-light .4s ease-out; }
  .anim:not(.focus) .theme-mascot.is-new :is(.curtain-left, .curtain-right) { animation: mascot-open .4s ease-out; }
}
@keyframes mascot-peek { from { opacity: 0; transform: translateY(18px); } }
@keyframes mascot-ear { 35% { transform: rotate(-12deg); } 68% { transform: rotate(8deg); } }
@keyframes mascot-claws { 45% { transform: translateY(-5px); } }
@keyframes mascot-tilt { 50% { transform: rotate(-11deg); } }
@keyframes mascot-press { from { transform: translateY(-7px); } 45% { transform: translateY(2px); } }
@keyframes mascot-light { from { opacity: 0; } }
@keyframes mascot-close { from { transform: scaleY(1); } }
@keyframes mascot-stamp { from { opacity: 0; transform: scale(1.5) rotate(-14deg); } }
@keyframes mascot-bookmark { from { opacity: 0; transform: translateY(10px); } }
@keyframes mascot-open { from { transform: scaleX(1); } }

/* Диплом */
.diploma-award { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.25rem; margin: 1.1rem 0; }
.diploma-award img { display: block; width: min(100%, 12rem); }
.diploma-award p { margin: 0 0 .65rem; }
.diploma-tools { margin-bottom: 1.2rem; }
.diploma-actions { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem 1rem; margin-top: 1rem; }
.diploma-actions label { display: grid; gap: .25rem; width: min(100%, 21rem); }
.diploma-actions input {
  width: 100%; min-height: 2.7rem; padding: .45rem .7rem; font: inherit;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: .6rem;
}
.course-diploma {
  position: relative; margin: 0 auto; padding: 2.3rem clamp(.85rem, 5vw, 3.8rem);
  border: 7px double #a96b52; background: #fffaf2; color: #4a302b;
  text-align: center; font-family: Georgia, "Times New Roman", serif; line-height: 1.25;
}
.course-diploma::before { content: ""; position: absolute; inset: .38rem; border: 1px solid #c3a7cb; pointer-events: none; }
.course-diploma p { margin: 0; }
.diploma-brand {
  display: flex; align-items: center; justify-content: center; gap: .65em;
  color: #75478c; font-weight: 700; letter-spacing: .19em; text-transform: uppercase; font-size: .8em;
}
.diploma-brand::before, .diploma-brand::after { content: ""; width: 2.25em; border-top: 1px solid #b187b6; }
.course-diploma h1 { margin: .22em 0 .18em; color: #773f35; font-size: clamp(2.1rem, 8vw, 4.15rem); line-height: 1.02; }
.diploma-subtitle { font-size: 1.12em; }
.course-diploma .diploma-recipient {
  margin: .6em auto .37em; padding-bottom: .14em; max-width: 100%; width: fit-content;
  border-bottom: 1px solid #b187b6; color: #673b7a; font-size: clamp(1.25rem, 5vw, 2.5rem);
  font-weight: 700; overflow-wrap: anywhere;
}
.diploma-scope { color: #78574f; font-size: .86em; letter-spacing: .04em; }
.diploma-art { display: block; width: min(100%, 20rem); height: 12rem; object-fit: contain; margin: .65rem auto .18rem; }
.diploma-signature { color: #75478c; font-style: italic; font-size: .9em; }

@media print {
  @page diploma { size: A4 landscape; margin: 10mm; }
  body:has(.course-diploma) { background: white; color: #4a302b; }
  body:has(.course-diploma) > :not(#app), .diploma-tools { display: none !important; }
  body:has(.course-diploma) #app { padding: 0; }
  .diploma-page { max-width: none; }
  .course-diploma {
    page: diploma; break-inside: avoid; width: 100%; margin: 0; padding: 9mm 13mm 7mm;
    background: white; border-width: 1.8mm; font-size: 15pt;
  }
  .course-diploma::before { inset: 1.6mm; }
  .course-diploma h1 { font-size: 43pt; }
  .course-diploma .diploma-recipient { font-size: 27pt; }
  .diploma-art { width: 104mm; max-width: 100%; height: 61mm; margin: 4mm auto 1mm; }
}
