/* Черновой стиль, вариант A «Мастерская»: тёплый жёлтый, почти чёрный текст,
   светлый фон, рукописные пометки. Это ещё не дизайн-система.
   Шрифты системные: ничего не грузим из интернета. */
:root {
  --yellow: #ffd54a;
  --yellow-soft: #fff3c4;
  --ink: #1d1b16;
  --paper: #fffaf0;
  --card: #ffffff;
  --green: #2f6b45;
  --red: #d64533;
  --shadow: 4px 4px 0 var(--ink);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font: 18px/1.55 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 12px; }
p { margin: 0 0 12px; }

.hand { font-family: "Segoe Print", "Comic Sans MS", cursive; color: var(--green); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* Шапка */
.site-header { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 2px solid var(--ink); }
.site-header .wrap { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; padding-top: 10px; padding-bottom: 10px; }
.logo { display: flex; gap: 8px; align-items: center; font-size: 24px; font-weight: 800; color: var(--ink); text-decoration: none; }
.logo svg { width: 34px; height: 34px; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 18px; flex: 1; }
.site-header nav a { color: var(--ink); text-decoration: none; font-weight: 600; }
.site-header nav a:hover { text-decoration: underline; }

/* Кнопки: крупные, чтобы ребёнок попадал пальцем */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 60px;
  padding: 12px 28px;
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow);
  text-decoration: none;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  user-select: none;
}
.button:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.button.dark { color: #fff; background: var(--ink); box-shadow: 4px 4px 0 var(--yellow); }
.button.light { background: var(--card); }
.button.small { min-height: 0; padding: 8px 18px; font-size: 17px; }
.button:disabled, .button[aria-disabled="true"] { opacity: .4; cursor: default; transform: none; box-shadow: var(--shadow); }
:focus-visible { outline: 4px solid var(--green); outline-offset: 3px; }

.buttons { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 20px; }
.buttons .main { margin-left: auto; }

.card { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }

.placeholder {
  display: grid;
  place-items: center;
  min-height: 200px;
  padding: 16px;
  text-align: center;
  border: 3px dashed var(--ink);
  border-radius: var(--radius);
  background: var(--yellow-soft);
}

.badge { display: inline-block; padding: 4px 12px; font-size: 14px; font-weight: 700; background: var(--card); border: 2px solid var(--ink); border-radius: 999px; }

/* Главная: первый экран со снегом */
.hero { position: relative; overflow: hidden; background: var(--yellow); border-bottom: 3px solid var(--ink); }
.hero::before {
  content: "";
  position: absolute;
  inset: -200px 0 0;
  background-image: radial-gradient(#fff 2px, transparent 3px), radial-gradient(#fff 1.5px, transparent 2.5px);
  background-size: 90px 90px, 60px 60px;
  background-position: 0 0, 30px 40px;
  opacity: .8;
  animation: snow 14s linear infinite;
  pointer-events: none;
}
@keyframes snow { to { transform: translateY(180px); } }
.hero .wrap { position: relative; display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center; padding-top: 48px; padding-bottom: 48px; }
.hero h1 { font-size: clamp(36px, 6vw, 64px); font-weight: 900; }
.hero .lead { font-size: 22px; max-width: 30em; }
.hero-art { justify-self: center; width: min(360px, 80vw); padding: 18px; background: var(--card); border: 3px solid var(--ink); border-radius: 28px; box-shadow: 8px 8px 0 var(--ink); }
.hero-art .hand { text-align: center; margin: 8px 0 0; font-size: 20px; }

section { padding: 56px 0; scroll-margin-top: 70px; }
section h2 { font-size: clamp(28px, 4vw, 40px); }
.section-lead { font-size: 20px; margin-bottom: 24px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 22px; }

.how .card { text-align: center; }
.how h2, .how .section-lead { text-align: center; }
.how .emoji { font-size: 56px; line-height: 1; margin-bottom: 10px; }

.booking { background: var(--green); color: #fff; border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink); }
.booking .card { color: var(--ink); }

.site-footer { padding: 28px 0; font-size: 15px; }

/* ---------- Урок ---------- */
.lesson-page { min-height: 100vh; }
.lesson-main { max-width: 1400px; margin: 0 auto; padding: 16px 20px 24px; }

.prepare { max-width: 760px; margin: 24px auto; text-align: center; }
.prepare .buttons { justify-content: center; }
.prepare h1 { font-size: clamp(32px, 5vw, 48px); }
.checklist li { display: flex; }
.checklist { display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: 1fr; gap: 12px; margin: 16px 0; padding: 0; list-style: none; }
.check {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  height: 100%;
  min-height: 64px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  text-align: left;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 16px;
  cursor: pointer;
}
.check .box { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border: 3px solid var(--ink); border-radius: 8px; font-size: 20px; }
.check[aria-pressed="true"] { background: var(--yellow-soft); }
.check[aria-pressed="true"] .box::after { content: "✓"; font-weight: 900; color: var(--green); }

.lesson-top { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.progress { position: relative; flex: 1; height: 18px; background: #eee3c6; border: 2px solid var(--ink); border-radius: 99px; }
.progress .fill { height: 100%; width: 0; background: var(--green); border-radius: 99px; transition: width .6s; }
.progress .pencil { position: absolute; top: 50%; left: 0; font-size: 30px; transform: translate(-50%, -60%) rotate(-10deg); transition: left .6s; }
.icon-button {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: none;
  font-size: 26px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.stage {
  position: relative;
  height: calc(100vh - 240px);
  min-height: 380px;
  overflow: hidden;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 6px 6px 0 var(--ink);
}
.stage .tree { display: block; height: 100%; width: 100%; }

.watch { height: 100%; padding: 24px 24px 50px; }
.watch .badge { position: absolute; top: 14px; left: 14px; }

.draw { display: grid; grid-template-columns: 1fr 1.1fr; gap: 20px; align-items: center; height: 100%; padding: 24px 170px 24px 24px; background: var(--yellow-soft); }
#watchArt { height: 100%; }
.draw .step-pic { display: flex; flex-direction: column; height: 100%; max-height: 520px; padding: 12px; background: var(--card); border: 3px dashed var(--ink); border-radius: 20px; }
#stepArt { flex: 1; min-height: 0; }
.draw .step-pic p { text-align: center; font-weight: 700; margin: 4px 0 0; }
.draw h2 { font-size: clamp(34px, 5vw, 60px); }
.tip { margin-top: 18px; font-size: clamp(17px, 1.6vw, 21px); }
.listen { min-height: 72px; font-size: 24px; background: var(--card); }

/* Окно с готовым рисунком: угол → пол-окна → весь экран */
.finished {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  width: 140px;
  padding: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.finished .tree { height: auto; }
.finished[data-size="half"] { position: fixed; top: 0; bottom: 0; right: 0; width: 50vw; z-index: 20; border-radius: 0; box-shadow: none; }
.finished[data-size="full"] { position: fixed; inset: 0; width: 100vw; z-index: 20; border-radius: 0; box-shadow: none; }
.finished[data-size="half"] .tree, .finished[data-size="full"] .tree { height: calc(100% - 30px); }

/* Видео и фото учителя в уроке */
.watch video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; border-radius: 16px; }
.watch.has-video { padding: 12px; }
/* Пока идёт видео, готовый рисунок наверху: иначе он закрывает кнопки видео */
.stage:has(.watch.has-video:not([hidden])) .finished[data-size="corner"] { top: 24px; bottom: auto; }
#stepArt img { display: block; width: 100%; height: 100%; object-fit: contain; }
#stepArt { position: relative; }
#stepArt img { position: absolute; inset: 0; }
#finishedArt img, #endArt img { display: block; width: 100%; height: auto; border-radius: 8px; }
.finished[data-size="half"] #finishedArt img, .finished[data-size="full"] #finishedArt img { height: calc(100vh - 60px); object-fit: contain; }
#endArt img { max-width: 320px; margin: 0 auto 12px; }
.art-placeholder { height: 100%; min-height: 0; font-size: 22px; font-weight: 700; }
.card-link { margin-top: auto; }

/* Ёлка рисуется на глазах (вместо видео) */
.new path, .new circle { stroke-dasharray: 1; stroke-dashoffset: 1; fill-opacity: 0; animation: draw 2.4s ease forwards, fill-in .7s 2.1s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fill-in { to { fill-opacity: 1; } }

/* Конец урока */
.end-hero { text-align: center; margin: 12px 0 24px; }
.end-hero h1 { font-size: clamp(40px, 7vw, 72px); }
.end-hero .tree { width: 200px; height: auto; }
.end { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; align-items: start; }
.note { font-size: 15px; opacity: .75; }
#postcard { display: block; width: 100%; max-width: 420px; height: auto; margin: 16px 0; border: 3px solid var(--ink); border-radius: 12px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.work { padding: 8px; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; }
.work .tree { display: block; width: 100%; height: auto; }
.work:nth-child(2) .tree { filter: hue-rotate(40deg); }
.work:nth-child(3) .tree { filter: hue-rotate(-30deg) saturate(1.3); }
.work:nth-child(4) .tree { filter: hue-rotate(160deg); }
.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.reaction { min-height: 42px; padding: 4px 10px; font: inherit; font-size: 16px; background: var(--card); border: 2px solid var(--ink); border-radius: 999px; cursor: pointer; }
.reaction[aria-pressed="true"] { background: var(--yellow); }

#confetti { position: fixed; inset: 0; z-index: 30; pointer-events: none; }

/* ---------- Студия учителя ---------- */
.header-spacer { flex: 1; }
.studio { padding-top: 32px; padding-bottom: 56px; }
.studio h1 { font-size: clamp(30px, 4vw, 40px); margin-bottom: 8px; }
.studio .card { padding: 28px; box-shadow: 0 2px 10px rgba(29, 27, 22, .08); border-width: 2px; border-radius: 18px; }

/* Взрослый интерфейс: ровные кнопки без «мультяшных» теней */
.studio-page .button { min-height: 48px; padding: 10px 22px; font-size: 17px; font-weight: 700; line-height: 1.2; border-width: 2px; border-radius: 12px; box-shadow: none; }
.studio-page .button:hover { transform: none; box-shadow: none; filter: brightness(.96); }
.studio-page .button:active { transform: translateY(1px); box-shadow: none; }
.studio-page .button:disabled { box-shadow: none; }
.studio-page .button.yellow { background: var(--yellow); }
.studio-page .button.dark { color: #fff; background: var(--ink); }
.studio-page .button.danger { color: #a32d1f; background: var(--card); border-color: #a32d1f; }
.studio-page .button.wide { width: 100%; }

.hint { font-size: 19px; color: #4a463c; }
.error { margin: 0 0 16px; font-weight: 700; color: var(--red); }
.error:empty { display: none; }
.saved { flex: 1; font-weight: 700; color: var(--green); }

/* Все поля ввода выглядят одинаково */
.field { display: grid; gap: 8px; margin-bottom: 20px; font-size: 17px; font-weight: 700; }
.field input, .field textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 14px 18px;
  font: 400 19px/1.5 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--card);
  border: 2px solid #8a8474;
  border-radius: 12px;
}
.field textarea { min-height: 130px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 4px solid var(--yellow); outline-offset: 0; border-color: var(--ink); }
.field ::placeholder { color: #8a8474; }

.login { max-width: 460px; margin: 28px auto; }

.lesson-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); grid-auto-rows: 1fr; gap: 24px; margin: 20px 0 32px; }
.lesson-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-height: 230px; }
.lesson-card h3 { margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.card-actions { display: flex; gap: 14px; width: 100%; margin-top: auto; }
.card-actions .button.dark { flex: 1; }
.studio button.create-card { align-items: center; justify-content: center; font: inherit; font-size: 21px; background: var(--yellow-soft); border-style: dashed; cursor: pointer; }
.big-plus { font-size: 52px; line-height: 1; }
.badge.published { background: #d9f0df; }
.link-button { padding: 0; font: inherit; text-align: left; color: var(--ink); text-decoration: underline; background: none; border: 0; cursor: pointer; }

.guide { max-width: 820px; margin: 40px 0 16px; }
.guide h2 { margin-bottom: 8px; }
.guide h3 { margin: 24px 0 10px; font-size: 21px; }
.guide ol { margin: 0 0 8px; padding-left: 26px; }
.guide li { margin-bottom: 12px; }

.editor-bar { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 24px; }
.problems { display: grid; gap: 10px; justify-items: start; margin-bottom: 24px; padding: 18px 22px; background: #fde3df; border: 2px solid var(--red); border-radius: 14px; }
.studio .about { margin-bottom: 24px; padding-top: 18px; padding-bottom: 18px; }
.about-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; }
.about-head h2 { margin: 0; font-size: 24px; overflow-wrap: anywhere; }
.about-grid { display: grid; grid-template-columns: 1fr 240px; gap: 0 20px; margin-top: 24px; }
.about-grid .span { grid-column: 1 / -1; margin: 0; }

/* Слева компактное меню частей, справа одна открытая часть */
.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; }
.studio .parts { position: sticky; top: 82px; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 106px); padding: 18px; }
.parts-head { display: flex; justify-content: space-between; align-items: baseline; }
.parts-head span { font-size: 15px; opacity: .7; }
.part-list { flex: 1; min-height: 60px; margin: 0; padding: 4px; overflow-y: auto; list-style: none; }
.part-list li + li { margin-top: 10px; }
.part-item { display: grid; grid-template-columns: 30px 1fr 24px; gap: 12px; align-items: center; width: 100%; height: 52px; padding: 0 12px; font: inherit; font-size: 16px; font-weight: 700; text-align: left; background: var(--card); border: 2px solid #cfc8b4; border-radius: 12px; cursor: pointer; }
.part-item[aria-current="true"] { background: var(--yellow-soft); border-color: var(--ink); }
.part-number { display: grid; place-items: center; width: 30px; height: 30px; font-size: 14px; background: var(--paper); border: 2px solid #8a8474; border-radius: 50%; }
.part-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.part-state { display: grid; place-items: center; width: 24px; height: 24px; font-size: 14px; color: #fff; border-radius: 50%; }
.part-state.ok { background: var(--green); }
.part-state.warn { background: var(--red); }

.part-editor { scroll-margin-top: 82px; }
.part-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 8px; }
.part-head h2 { margin: 0; font-size: 28px; }
.part-tools { display: flex; gap: 14px; }

/* Шаги части: сверху вниз, между ними линия и воздух */
.block { padding: 28px 0 8px; border-top: 2px solid #e6dfca; }
.part-head + .block { margin-top: 20px; }
.block h3 { display: flex; gap: 12px; align-items: center; margin: 0 0 16px; font-size: 21px; }
.num { display: grid; place-items: center; width: 34px; height: 34px; flex: none; font-size: 17px; background: var(--yellow); border-radius: 50%; }
.media { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr); gap: 24px; align-items: start; margin-bottom: 20px; }
.media-box { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 10; padding: 10px; overflow: hidden; text-align: center; background: var(--paper); border: 2px dashed #8a8474; border-radius: 14px; }
.media-box img, .media-box video, .media-box .tree { position: absolute; top: 10px; left: 10px; width: calc(100% - 20px); height: calc(100% - 20px); object-fit: contain; border-radius: 8px; }
.media-box .tree { height: calc(100% - 40px); }
.media-box video { background: #000; }
.media-empty { padding: 10px; font-weight: 700; color: #6b6658; }
.media-caption { position: absolute; bottom: 6px; left: 0; width: 100%; font-size: 14px; color: #6b6658; }
.media-side { display: grid; gap: 14px; justify-items: stretch; }
.media-side p { margin: 0; }
.part-footer { display: flex; justify-content: flex-end; padding-top: 24px; border-top: 2px solid #e6dfca; }

.home-photo { max-width: 820px; margin-top: 40px; }
.home-photo h2 { margin-bottom: 16px; }
.warning { padding: 10px 14px; font-weight: 700; background: var(--yellow-soft); border-radius: 10px; }

/* Работа ученика на главной */
.hero-work { display: grid; place-items: center; aspect-ratio: 4 / 5; padding: 12px; overflow: hidden; font-weight: 700; text-align: center; background: var(--yellow-soft); border: 3px dashed var(--ink); border-radius: 16px; }
.hero-work:has(img) { padding: 0; border-style: solid; }
.hero-work img { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--card); }

/* Переключатель «да/нет» */
.switch { display: flex; gap: 14px; align-items: center; min-height: 52px; margin-bottom: 8px; font-size: 19px; font-weight: 700; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: relative; flex: none; width: 60px; height: 34px; background: #ddd5bf; border: 3px solid var(--ink); border-radius: 99px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: var(--card); border: 2px solid var(--ink); border-radius: 50%; transition: left .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { left: 27px; }
.switch input:focus-visible + span { outline: 4px solid var(--green); outline-offset: 3px; }

/* Узкий экран (телефон, планшет вертикально) */
@media (max-width: 760px) {
  .workspace, .about-grid, .media { grid-template-columns: minmax(0, 1fr); }
  .studio .parts { position: static; max-height: 300px; }
  .hero .wrap { grid-template-columns: 1fr; }
  .stage { height: auto; min-height: 0; }
  .watch { height: 60vh; }
  .draw { grid-template-columns: 1fr; padding: 20px 20px 190px; }
  .draw .step-pic { height: 40vh; }
}

/* Если человек просит меньше движения: без снега, анимаций и конфетти */
@media (prefers-reduced-motion: reduce) {
  .hero::before { animation: none; }
  .new path, .new circle { animation: none; stroke-dashoffset: 0; fill-opacity: 1; }
  .button, .progress .fill, .progress .pencil { transition: none; }
}
