:root {
  --paper: #fffaf0;
  --ink: #233e32;
  --muted: #536557;
  --rose: #f5c4c5;
  --sage: #e4ebd8;
  --line: #d5d7c8;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.55 system-ui, -apple-system, sans-serif;
}
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid #8b3953; outline-offset: 4px; }
h1, h2, p, figure, dl { margin: 0; }
h1, h2, .wordmark { font-family: Georgia, "Times New Roman", serif; }
h1, h2 { font-weight: 500; line-height: 1.02; }
h2 { font-size: clamp(2.45rem, 4.2vw, 3.9rem); letter-spacing: -.05em; }
p + p { margin-top: .7rem; }
.wrap { width: min(70rem, calc(100% - 3rem)); margin-inline: auto; }
.skip { position: absolute; left: .75rem; top: -5rem; background: white; padding: .5rem 1rem; z-index: 2; }
.skip:focus { top: .5rem; }
.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner, .top-links, .wordmark, .footer-inner { display: flex; align-items: center; }
.masthead-inner { min-height: 4.8rem; gap: 2rem; }
.wordmark { gap: .6rem; font-size: 1.5rem; font-weight: 700; text-decoration: none; }
.top-links { margin-left: auto; gap: 1.5rem; }
.top-links a, .return { font-size: .93rem; font-weight: 600; text-decoration: none; }
.top-links a:hover { text-decoration: underline; }
.return, .read { border-radius: 3rem; font-weight: 650; }
.return { border: 1px solid var(--ink); padding: .5rem 1rem; }
.return:hover { background: var(--sage); }
.cover {
  background-color: #f0f2e5;
  background-image: linear-gradient(#dce1cf65 1px, transparent 1px), linear-gradient(90deg, #dce1cf65 1px, transparent 1px);
  background-size: 1.3rem 1.3rem;
  border-bottom: 1px solid var(--line);
}
.cover-grid {
  display: grid;
  grid-template-columns: 1.18fr .82fr;
  align-items: center;
  gap: clamp(2rem, 5vw, 6rem);
  padding-block: clamp(3rem, 5.5vw, 5.5rem);
}
.eyebrow { font-size: .79rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 1rem 0 1.25rem; font-size: clamp(3.8rem, 6.9vw, 6.3rem); letter-spacing: -.065em; }
h1 em { display: block; font-weight: 500; color: #8a4156; }
.intro-text { max-width: 32rem; color: var(--muted); font-size: 1.12rem; }
.read { display: inline-block; margin-top: 1.6rem; padding: .7rem 1.2rem; background: var(--ink); color: white; text-decoration: none; }
.read:hover { background: #385c4a; }
.experiment {
  min-width: 0;
  background: #fffcf5;
  border: 1px solid #b5b9a9;
  border-radius: 1.1rem;
  padding: clamp(1.2rem, 2.5vw, 1.85rem);
  box-shadow: .35rem .35rem 0 #d3dcc8;
}
.sample-title, .range-label { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.sample-title h2 { font-size: clamp(1.55rem, 2.5vw, 2.1rem); }
.sample-title { flex-wrap: wrap; }
.mode-picker {
  display: inline-flex;
  position: relative;
  margin: 0;
  padding: 3px;
  border: 1px solid #aec0a7;
  border-radius: 12px;
  color: var(--ink);
}
.visually-hidden, .mode-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.mode-picker label { cursor: pointer; padding: .3rem .55rem; border-radius: 8px; font: 650 .78rem var(--mono); }
.mode-picker input:checked + label { background: var(--ink); color: white; }
.mode-picker input:focus-visible + label { outline: 2px solid #8b3953; outline-offset: 2px; }
.experiment-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(.7rem, 1.5vw, 1.3rem);
  margin: 1.2rem 0;
}
.sample-card {
  overflow: hidden;
  border-radius: 16px;
  min-width: 0;
  background: var(--rose);
}
.sample-card img { display: block; width: 100%; height: 6.8rem; object-fit: cover; }
.sample-card figcaption { padding: .28rem .75rem .36rem; font-family: Georgia, serif; font-weight: bold; }
.sample-card h3 { min-height: 1.4em; margin: 0; font: inherit; overflow-wrap: anywhere; }
.sample-code { background: var(--ink); color: #eef2e5; border-radius: .55rem; display: grid; align-content: center; padding: .65rem; }
.sample-code code { font: .82rem/1.5 var(--mono); overflow-wrap: anywhere; }
.sample-code strong { color: #ffbec7; }
.range-label { font-size: .9rem; font-weight: 650; }
.range-label output { font-family: var(--mono); }
#name-input {
  width: 100%;
  margin: .4rem 0 .5rem;
  padding: .4rem .7rem;
  border: 1px solid #96a48d;
  border-radius: 6px;
  background: #fffef9;
  color: var(--ink);
  font: inherit;
}
input[type="range"] { display: block; width: 100%; min-height: 1.9rem; margin: .15rem 0; padding: 0; accent-color: var(--ink); cursor: pointer; }
.lab-note { color: var(--muted); font-size: .9rem; }
.reading { padding-bottom: 4rem; }
.chapter {
  scroll-margin: 1rem;
  display: grid;
  grid-template-columns: minmax(12rem,.8fr) minmax(0,1.45fr);
  gap: clamp(2rem, 7vw, 6rem);
  padding: clamp(3rem, 6vw, 5.5rem) 0;
  border-bottom: 1px solid var(--line);
}
.chapter-intro h2, .rehearsal h2 { margin: .8rem 0 1rem; }
.chapter-intro p:not(.eyebrow), .key-note { color: var(--muted); }
.chapter p code, .chapter dd code, .rehearsal li code, .chapter li code {
  padding: .08rem .28rem;
  border-radius: .22rem;
  background: #e7eadf;
  font: .88em var(--mono);
  overflow-wrap: anywhere;
}
kbd { font: .83em var(--mono); padding: .1rem .25rem; border: 1px solid var(--line); border-radius: .2rem; background: #fff; color: var(--ink); }
.file-list > div {
  display: grid;
  grid-template-columns: minmax(7.4rem,.56fr) 1.44fr;
  gap: 1rem;
  border-top: 1px solid var(--line);
  padding: .72rem 0;
}
.file-list dt { align-self: start; padding-top: .15rem; font: 650 .9rem/1.4 var(--mono); }
.file-list dd { margin: 0; }
.file-list a { white-space: normal; }
.blocks { min-width: 0; }
.inspector {
  margin-bottom: 1.35rem;
  padding: 1rem 1.1rem;
  border: 1px solid #c3ccb8;
  border-radius: .65rem;
  background: #eef1e5;
}
.inspector-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.inspector-head label { font-weight: 650; }
.inspector-head select {
  min-height: 2.5rem;
  padding: .2rem 2rem .2rem .65rem;
  border: 1px solid #96a48d;
  border-radius: .45rem;
  background-color: #fffcf5;
  color: var(--ink);
  font: inherit;
}
.source-result { margin-top: 1rem; }
.source-file { font: 650 .87rem var(--mono); color: var(--muted); }
.source-result pre, .answer pre {
  margin: .7rem 0;
  padding: .75rem 1rem;
  border-radius: .4rem;
  background: var(--ink);
  color: #fff9ec;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.source-result pre code, .answer pre code { font: .9rem/1.5 var(--mono); }
.blocks > details { border-top: 1px solid var(--line); }
.blocks > details:last-of-type { border-bottom: 1px solid var(--line); }
summary {
  cursor: pointer;
  font-size: 1.12rem;
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem .2rem 1.1rem 0;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-weight: 450; font-size: 1.3rem; }
details[open] > summary::after { content: "−"; }
summary:hover { color: #774155; }
.answer { padding: 0 .55rem 1.2rem 0; }
ol { margin: 0; padding-left: 1.5rem; }
li { padding-left: .35rem; }
li + li { margin-top: .7rem; }
li::marker { font-weight: 700; color: #784456; }
.key-note { margin-top: 1.05rem; }
.rehearsal {
  margin-top: clamp(3rem, 6vw, 5.5rem);
  padding: clamp(1.5rem, 4vw, 3.4rem);
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: clamp(2rem, 5vw, 4rem);
  background: #f6d7d6;
  border-radius: 1.1rem;
}
.rehearsal .eyebrow { color: #754454; }
.rehearsal li code { background: #fff4e9; }
.footer { background: var(--ink); color: #f1efdf; }
.footer-inner { min-height: 4.2rem; justify-content: space-between; gap: 1rem; font-size: .9rem; }
.footer a { color: inherit; }
@media (max-width: 48rem) {
  .cover-grid, .chapter, .rehearsal { grid-template-columns: minmax(0, 1fr); }
  .cover-grid, .chapter { gap: 1.6rem; }
  .cover-grid { align-items: start; }
  h1 em { display: inline; }
  .experiment { max-width: 32rem; }
  .experiment-body { grid-template-columns: minmax(0, 1fr) minmax(9.15rem, 1fr); }
  .sample-card img { height: 8rem; }
  .chapter-intro { max-width: 34rem; }
  .masthead-inner { gap: 1rem; }
  .top-links { gap: .8rem; }
}
@media (max-width: 34rem) {
  .wrap { width: calc(100% - 2.2rem); }
  .masthead-inner { flex-wrap: wrap; justify-content: space-between; padding: .85rem 0 .6rem; row-gap: .55rem; }
  .top-links { width: 100%; order: 3; margin: 0; gap: 1.4rem; }
  h1 { font-size: clamp(3rem, 12.5vw, 4rem); }
  .cover-grid { padding-block: 2.4rem; }
  .chapter, .rehearsal { gap: 1.2rem; }
  .file-list > div { grid-template-columns: 1fr; gap: .25rem; }
  .sample-card img { height: 6.2rem; }
  .sample-code { padding: .5rem; }
  .sample-code code { font-size: .77rem; }
  .footer-inner { flex-wrap: wrap; padding: 1rem 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Оглавление и короткие уроки по технологиям. */
.guide-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem 1.2rem; }
.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.topic-grid a {
  padding: 1rem 1.2rem;
  border: 1px solid #b9c5ae;
  border-radius: .8rem;
  background: #f0f3e8;
  text-decoration: none;
}
.topic-grid a:hover { border-color: var(--ink); }
.topic-grid strong { display: block; margin-bottom: .2rem; }
.topic-grid span { color: var(--muted); }
.lesson-return { margin-left: auto; }
.lesson-layout { display: grid; grid-template-columns: minmax(9rem, 1fr) minmax(0, 3.5fr); gap: 5%; padding-block: clamp(2rem, 5vw, 4.5rem); }
.lesson-menu nav { display: grid; gap: .25rem; margin-top: .8rem; }
.lesson-menu a { padding: .45rem .6rem; border-radius: .4rem; text-decoration: none; }
.lesson-menu a:hover, .lesson-menu [aria-current] { background: var(--sage); }
.lesson-menu [aria-current] { font-weight: 700; }
.lesson-text { max-width: 48rem; min-width: 0; }
.lesson-text h1 { font-size: clamp(2.6rem, 5vw, 4.5rem); margin: .65rem 0 1rem; }
.lesson-text section { margin-top: 2rem; }
.lesson-text h2 { font-size: clamp(1.7rem, 3vw, 2.45rem); margin-bottom: .75rem; }
.lesson-text pre { padding: 1rem; border-radius: .5rem; background: var(--ink); color: var(--paper); white-space: pre-wrap; overflow-wrap: anywhere; }
.lesson-text p code { font: .9em var(--mono); background: #e7eadf; padding: .1em .28em; overflow-wrap: anywhere; }
.lesson-task { background: #f6d7d6; padding: clamp(1rem, 3vw, 2rem); border-radius: .8rem; }
.lesson-task details { margin-top: .8rem; border-top: 1px solid #ba9599; }
@media (max-width: 44rem) {
  .lesson-layout { grid-template-columns: minmax(0, 1fr); gap: 1.8rem; }
  .lesson-menu nav { display: flex; flex-wrap: wrap; }
}
@media (max-width: 34rem) {
  .topic-grid { grid-template-columns: 1fr; }
}
