/* MAESTRO — стили 1:1 по макетам Figma (файл lM8Umm4v9W6g0miVBoGSdZ, страница «креативные технологии»:
   «главная страница маэстро», «каталог», «карточка работы», «редактор», «результат», «мои работы», «MAESTRO · компоненты»).
   Кадр макета — 1440 px, поля 80 px (в редакторе 40 px). Межстрочный интервал везде «normal», как в Figma.
   Шрифты: BIPs — кнопки, фильтры, заголовок главной; Onest — всё остальное (заголовки страниц — Onest Bold). */
@font-face { font-family: 'BIPs'; src: url('../fonts/BIPs.ttf') format('truetype'); font-display: swap; }

:root {
  --ink: #000; --paper: #fff; --brown: #655438; --gold: #FEDA0C; --dark-brown: #3B2E1F;
  --muted: #6B6B6B; --line: #E6E6E6; --field: #F7F6F2; --placeholder: #EBE5D9;
  --hand: 'BIPs', 'Onest', system-ui, sans-serif;
  --body: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --pad: clamp(20px, 5.56vw, 80px);
  --shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/normal var(--body); }
h1, h2, h3, p { margin: 0; font-weight: inherit; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
#app { overflow-x: clip; } /* наклонённые картины не должны давать горизонтальную прокрутку */
.muted { color: var(--muted); }

/* Типографика (стили MAESTRO/… из макета) */
.h1 { font: 700 64px/normal var(--body); }                 /* H1 64 */
.h2 { font: 700 40px/normal var(--body); }                 /* H2 40 */
.h3 { font: 700 28px/normal var(--body); }                 /* H3 28 */
.lead { font: 400 24px/normal var(--body); }               /* Body L 24 */
.body18 { font: 400 18px/normal var(--body); }             /* Body 18 */
.m16 { font: 500 16px/normal var(--body); }                /* Body M 16 */
.small { font: 400 14px/normal var(--body); }              /* Small 14 */
.link { background: none; border: 0; padding: 0; cursor: pointer; font: 500 16px/normal var(--body); text-decoration: underline; text-underline-position: from-font; color: var(--ink); }
.link.muted { color: var(--muted); }

/* Рваная обводка рисуется SVG-контуром (assets/js/rough.js) под содержимым элемента */
[data-rough] { position: relative; isolation: isolate; }
svg.rough { position: absolute; z-index: -1; overflow: visible; pointer-events: none; }

/* Кнопки: L — 32 px, отступы 16/64, обводка 6; S — 20 px, отступы 12/40, обводка 5; скругление 30 */
.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; cursor: pointer; white-space: nowrap;
  font: 400 32px/normal var(--hand); padding: 16px 64px; color: var(--ink); flex: none; transition: transform .15s; }
.btn.solid { color: var(--paper); }
.btn.small { font-size: 20px; padding: 12px 40px; }
.btn:hover { transform: rotate(-1deg); } .btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn:focus-visible, .chip:focus-visible, .tool:focus-visible, .dot:focus-visible { outline: 2px solid var(--gold); outline-offset: 8px; border-radius: 30px; }

/* Фильтры: 16 px, отступы 8/20, обводка 5 снаружи, скругление 20 */
.chip { display: inline-flex; align-items: flex-start; border: 0; background: none; cursor: pointer; white-space: nowrap;
  font: 400 16px/normal var(--hand); padding: 8px 20px; color: var(--ink); flex: none; }
.chip.on { color: var(--paper); }
.chip:disabled { opacity: .35; cursor: default; }
.chip.static { cursor: default; }
/* обводка фильтров 5 px снаружи + волна ≈1.5 px: чтобы между ними было видно 8 px, зазор 21 px */
.chips { display: flex; flex-wrap: wrap; gap: 21px; }

/* Картина: белая рваная рамка 6 px поверх края, скругление, тень, наклон */
.pic { position: relative; margin: 0; transform: rotate(var(--rot, 0deg)); border-radius: var(--r, 32px); background: var(--placeholder); box-shadow: var(--shadow); }
.pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; border-radius: inherit; }
.pic > svg.rough { z-index: 1; }
.pic-ph { position: absolute; inset: 0; display: none; place-items: center; text-align: center; padding: 20px; color: var(--muted); font: 400 14px var(--body); }
.pic.noimg img { visibility: hidden; } .pic.noimg .pic-ph { display: grid; }

/* Шапка: логотип Onest Bold 28, меню Onest Medium 16 через 32, справа «login» (S) */
.top { display: flex; align-items: center; gap: 24px; height: 46px; max-width: 1440px; margin: 40px auto 0; padding: 0 var(--pad); }
.top.wide { gap: 40px; }
.logo { font: 700 28px/normal var(--body); text-decoration: none; }
.top nav { display: flex; gap: 32px; flex: 1; font: 500 16px/normal var(--body); white-space: nowrap; }
.top nav a { text-decoration: none; }
.top nav a.on { text-decoration: underline; text-underline-position: from-font; }
.top-right { display: flex; align-items: center; gap: 20px; margin-left: auto; }
.lang { background: none; border: 0; cursor: pointer; font: 500 14px var(--body); color: var(--muted); }
.lang b { color: var(--ink); font-weight: 500; }

/* Страницы */
.page { max-width: 1440px; margin: 0 auto; padding: 64px var(--pad) 96px; }
.intro { display: flex; flex-direction: column; gap: 16px; }
.intro .lead { max-width: 760px; }
.intro.tight { gap: 12px; } .intro.tight .lead { max-width: none; }

/* ---------- Главная (кадр 1440×1024) ---------- */
.home { position: relative; max-width: 1440px; margin: 0 auto; min-height: 1024px; }
.home .top-right { position: absolute; top: 40px; right: var(--pad); }
.hero-text { position: absolute; left: var(--pad); top: 348px; width: 640px; }
.hero-text h1 { font: 400 96px/normal var(--hand); }
.hero-text .lead { width: 630px; margin-top: 24px; }
.hero-text .actions { margin-top: 60px; gap: 32px; }
/* русские подписи длиннее: кнопки остаются в одну строку и могут заходить в промежуток до картины */
@media (min-width: 1200px) { .hero-text .actions { flex-wrap: nowrap; width: max-content; } }
@media (min-width: 1200px) and (max-width: 1439px) { .hero-text .actions .btn { padding-inline: clamp(32px, calc((100vw - 1440px) * .14 + 64px), 64px); } .hero-text .actions { gap: 24px; } }
@media (min-width: 961px) and (max-width: 1199px) { .hero-text .actions .btn { padding-inline: 36px; } .hero-text .actions { gap: 20px; } }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; }
.stage { position: absolute; left: 790px; top: 232px; width: 644px; aspect-ratio: 644 / 626; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.anim-toggle { position: absolute; right: 6%; bottom: 2%; border: 0; background: none; cursor: pointer; opacity: .35; font-size: 12px; }
.anim-toggle:hover { opacity: 1; }

/* ---------- Каталог ---------- */
.filters { display: flex; flex-direction: column; gap: 20px; margin-top: 51px; }
.frow { display: flex; align-items: center; gap: 16px; }
.flabel { font: 700 16px/normal var(--body); width: 170px; flex: none; }
.more-row { gap: 24px; white-space: nowrap; }
.more { display: flex; flex-direction: column; gap: 20px; }
.dd { position: relative; }
.dd-list { position: absolute; z-index: 5; top: calc(100% + 14px); left: -5px; min-width: calc(100% + 10px); padding: 10px; }
.dd-scroll { max-height: 320px; overflow: auto; display: flex; flex-direction: column; }
.dd-opt { border: 0; background: none; cursor: pointer; text-align: left; white-space: nowrap; font: 400 16px/normal var(--hand); padding: 8px 12px; border-radius: 12px; }
.dd-opt:hover { background: rgba(254, 218, 12, .35); }
.dd-opt.on { background: var(--gold); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 56px 40px; margin-top: 70px; }
.card { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; text-decoration: none; min-width: 0; }
.card-link { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; text-decoration: none; width: 100%; }
.card .frame { width: 100%; aspect-ratio: 400 / 300; padding: 7px 8px; }
.card .pic { width: 100%; height: 100%; transition: transform .35s cubic-bezier(.34,1.56,.64,1); }
.card:hover .pic { transform: rotate(0deg) scale(1.02); }
.finish-line { display: flex; flex-wrap: wrap; gap: 8px; font: 400 14px/normal var(--body); }
.empty { padding: 60px 0; display: grid; justify-items: start; gap: 16px; }

/* ---------- Карточка работы ---------- */
/* всё помещается в один экран: высота картины зависит от высоты окна */
/* обе колонки по центру страницы и по ширине, и по высоте окна (под шапкой) */
.work { display: grid; grid-template-columns: minmax(0, 620px) minmax(0, 580px); justify-content: center; align-items: center; column-gap: 72px;
  min-height: calc(100vh - 86px); padding-top: 24px; padding-bottom: 24px; }
.work-pic { padding: 8px; }
.work-pic .pic { width: 100%; max-height: calc(100vh - 160px); aspect-ratio: 620 / 467; --r: 44px; }
/* ритм справа: базовый шаг g; мета → описание 2g, описание → «что дорисовать» 1.5g, теги → кнопки 3g */
.work-info { --g: clamp(8px, calc((100vh - 640px) / 18), 14px); display: flex; flex-direction: column; gap: var(--g); align-items: flex-start; }
.work-info .meta + .body18 { margin-top: var(--g); }
.work-info .to-finish { margin-top: calc(var(--g) * .5); }
.work-info .actions { margin-top: calc(var(--g) * 2); }
.work-title { font: 700 clamp(30px, calc(100vh / 24), 40px)/1.05 var(--body); }
.meta { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; font: 500 16px/normal var(--body); }
.meta dt { color: var(--muted); } .meta dd { margin: 0; }
.to-finish { display: flex; flex-direction: column; gap: 6px; }
.work-info .chips { padding: 5px; margin: -5px; }
.heart { flex: none; margin-right: 8px; vertical-align: -2px; }
.work-info .actions { gap: 20px; }

/* ---------- Редактор (кадр 1440×1024, поля 40) ---------- */
.editor { max-width: 1440px; margin: 0 auto; padding: 28px 40px 40px; display: grid;
  grid-template-columns: 80px 50px minmax(0, 1fr) 38px 332px; grid-template-rows: 46px 38px auto clamp(380px, calc(100vh - 334px), 690px) auto; }
.ed-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 24px; }
.ed-title { flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: center; gap: 10px; white-space: nowrap; }
.ed-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ed-title .muted { flex: none; }
.ed-top > .link { white-space: nowrap; }
.ed-history { display: flex; align-items: center; gap: 16px; }
.icon { background: none; border: 0; cursor: pointer; padding: 0; line-height: 0; color: var(--ink); }
.icon img { width: 24px; height: 24px; }
.icon.off { opacity: .35; }
.tools { grid-column: 1; grid-row: 3 / 5; align-self: start; margin-top: 38px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 10px; }
.tool { width: 52px; height: 52px; border: 0; border-radius: 16px; background: none; display: grid; place-items: center; cursor: pointer; }
.tool img { width: 28px; height: 28px; }
.tool.on { background: var(--gold); }
.sizes { display: flex; flex-direction: column; align-items: center; gap: 0; width: 52px; }
.size { width: 52px; height: 18px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; padding: 0; }
.size i { border-radius: 50%; background: var(--muted); }
.size.on i { background: var(--ink); }
.tip-row { grid-column: 3; grid-row: 3; display: flex; justify-content: center; padding-bottom: 16px; }
.tip { display: flex; align-items: center; gap: 12px; background: rgba(254, 218, 12, .25); padding: 8px 12px 8px 16px; border-radius: 14px; font: 500 16px/normal var(--body); }
.tip .icon { color: var(--muted); font: 500 16px/normal var(--body); }
.ed-host { grid-column: 3; grid-row: 4; position: relative; border-radius: 24px; overflow: hidden; background: var(--field); border: 2px dashed var(--line); }
.ed-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; transition: opacity .4s; }
.ed-canvas.dim { opacity: .65; }
.zoom { position: absolute; z-index: 1; right: 40px; bottom: 30px; display: flex; align-items: center; gap: 12px; }
.zoom .icon { font: 400 18px/normal var(--body); }
.zoom span { font: 400 14px/normal var(--body); color: var(--muted); }
.palette { grid-column: 3; grid-row: 5; justify-self: center; display: flex; align-items: center; gap: 12px; margin-top: 26px; }
.dot { position: relative; width: 38px; height: 38px; border: 0; background: none; cursor: pointer; padding: 0; transition: width .15s, height .15s; }
.dot img { width: 100%; height: 100%; }
.dot.on { width: 47.5px; height: 47.5px; }
.dot.custom .cur { position: absolute; inset: 11px; border-radius: 50%; border: 2px solid var(--paper); display: none; }
.dot.custom.on .cur { display: block; }
.pick.on { color: var(--ink); text-decoration: underline; }
.palette { position: relative; }
.cpop { position: absolute; z-index: 6; bottom: calc(100% + 18px); left: 50%; transform: translateX(-50%); width: 316px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.spectrum { width: 280px; height: 194px; border-radius: 16px; cursor: crosshair; touch-action: none; display: block; }
.cpop-row { display: flex; align-items: center; gap: 10px; }
.cpop-now { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0,0,0,.15); }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0,0,0,.12); transition: transform .15s; }
.swatch:hover { transform: scale(1.1); }
.swatch.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--ink); }
.pick { display: flex; align-items: center; gap: 6px; background: none; border: 0; cursor: pointer; padding: 0; font: 400 14px/normal var(--body); color: var(--muted); }
.pick img { width: 28px; height: 28px; }
.ai { grid-column: 5; grid-row: 4 / 6; display: flex; flex-direction: column; gap: clamp(10px, calc((100vh - 700px) / 8), 22px); padding: clamp(18px, 2.7vh, 28px) 26px; min-height: 0; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font: 400 18px/normal var(--body); }
.switch input { position: absolute; opacity: 0; }
.switch i { width: 52px; height: 30px; border-radius: 15px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ''; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--paper); transition: left .25s cubic-bezier(.34,1.56,.64,1); }
.switch input:checked + i { background: var(--ink); } .switch input:checked + i::after { left: 26px; }
.switch input:focus-visible + i { outline: 2px solid var(--gold); outline-offset: 3px; }
.slider { display: flex; flex-direction: column; gap: 10px; font: 500 16px/normal var(--body); }
.slider.dim, .desc.dim { opacity: .4; }
.range { position: relative; height: 20px; }
.range input { position: absolute; inset: 0; width: 100%; margin: 0; opacity: 0; cursor: pointer; }
.range .track { position: absolute; left: 0; right: 0; top: 7px; height: 6px; border-radius: 3px; background: var(--line); pointer-events: none; }
.range .fill { position: absolute; left: 0; top: 7px; height: 6px; border-radius: 3px; background: var(--ink); width: var(--v); pointer-events: none; }
.range .knob { position: absolute; top: 0; left: calc(var(--v) - 10px); width: 20px; height: 20px; border-radius: 50%; background: var(--gold); box-shadow: inset 0 0 0 3px var(--ink); pointer-events: none; }
.slider .ends { display: flex; justify-content: space-between; font: 400 14px/normal var(--body); color: var(--muted); }
.desc { display: flex; flex-direction: column; gap: 8px; font: 500 16px/normal var(--body); }
.field { height: clamp(64px, calc(100vh - 860px + 90px), 110px); flex: none; }
textarea { width: 100%; height: 100%; font: 500 16px/normal var(--body); padding: 12px 14px; border: 0; border-radius: 16px; resize: none; background: transparent; }
textarea::placeholder { color: var(--muted); }
textarea:focus { outline: none; }
.grow { flex: 1; }
.ai .btn { width: 100%; padding-left: 0; padding-right: 0; }
.ai .h2 { font-size: clamp(30px, calc(100vh / 25), 40px); }

/* Генерация поверх холста: три прохода света, «generating…», затем «completed ✓» */
.gen-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; transition: opacity .3s; }
.gen-overlay .band { position: absolute; top: -20%; height: 140%; width: 18%; left: -30%; background: #fff; filter: blur(32px); transform: rotate(15.36deg); opacity: 0; }
.gen-overlay.run .band { animation: sweep 1.27s ease-in-out infinite; }
.gen-overlay .b2, .gen-overlay .b3 { display: none; }
.gen-overlay.stop { opacity: 0; }
@keyframes sweep { 0% { left: -30%; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: 115%; opacity: 0; } }
.status-pill { position: absolute; z-index: 3; left: 50%; bottom: 8%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 0; padding: 4px 8px; border-radius: 7px; background: rgba(0,0,0,.25); color: #fff; font: 700 16px/normal var(--body); white-space: nowrap; animation: pillIn .35s ease both; }
.status-pill.out { animation: pillOut .3s ease both; }
.status-pill i { font-style: normal; animation: dot 1.26s steps(1) infinite; }
.status-pill i:nth-of-type(2) { animation-name: dot2; } .status-pill i:nth-of-type(3) { animation-name: dot3; }
@keyframes dot { 0% { opacity: 1; } }
@keyframes dot2 { 0% { opacity: .25; } 33.3% { opacity: 1; } }
@keyframes dot3 { 0% { opacity: .25; } 66.6% { opacity: 1; } }
.status-pill.done { gap: 6px; }
.status-pill.done path { stroke-dasharray: 20; stroke-dashoffset: 20; animation: check .3s .1s ease-out forwards; }
@keyframes check { to { stroke-dashoffset: 0; } }
@keyframes pillIn { from { opacity: 0; } }
@keyframes pillOut { to { opacity: 0; } }
.gen-result { position: absolute; z-index: 1; object-fit: fill; opacity: 0; transition: opacity .4s ease; }
.gen-result.in { opacity: 1; }

/* ---------- Результат: картина почти на весь экран, ползунок «было / стало», тумблер наброска ---------- */
.result { padding-top: 24px; padding-bottom: 24px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.res-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; max-width: 100%; }
#save span, #fav span { display: inline-flex; align-items: center; }
.res-head .switch { flex: none; font-size: 16px; }
.res-title { font: 700 32px/normal var(--body); white-space: nowrap; }
.compare { position: relative; border-radius: 32px; box-shadow: var(--shadow); background: var(--placeholder); width: 100%; aspect-ratio: 4 / 3; }
.compare > svg.rough { z-index: 4; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; border-radius: inherit; }
.compare .before { position: absolute; inset: 0; border-radius: inherit; clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.compare.no-sketch .sketch { opacity: 0; }
.compare .sketch { transition: opacity .25s; }
.compare .handle { position: absolute; z-index: 3; top: 0; bottom: 0; left: var(--pos); width: 4px; margin-left: -2px; background: var(--paper); pointer-events: none; }
.compare .knob { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 52px; height: 52px; display: grid; place-items: center; font: 400 22px/1 var(--hand); }
.compare .tag { position: absolute; z-index: 3; top: 18px; padding: 4px 10px; border-radius: 7px; background: rgba(0, 0, 0, .35); color: #fff; font: 700 16px/normal var(--body); pointer-events: none; }
.compare .tag-l { left: 22px; } .compare .tag-r { right: 22px; }
.compare input { position: absolute; z-index: 5; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.res-bar { justify-content: center; gap: 20px; }
.btn.done, .btn.done:disabled { opacity: 1; cursor: default; }

/* ---------- Покупка генераций ---------- */
.credits { font: 400 14px/normal var(--body); color: var(--muted); text-align: center; margin-top: -8px; }
.credits .link { font-size: 14px; }
.buy .balance { margin-top: 32px; }
.packs { display: grid; grid-template-columns: repeat(3, minmax(0, 300px)); gap: 40px; margin-top: 28px; }
.pack { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 24px 28px; text-align: center; margin: 0; }
.pack-n { font: 400 72px/1 var(--hand); }
.pack-price { font: 700 32px/normal var(--body); margin-top: 14px; }
.pack .btn { margin-top: 18px; }
.pay-note { margin-top: 24px; }
.code-box { margin-top: 48px; display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.code-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.code-row code { font: 500 16px/normal ui-monospace, Menlo, monospace; background: var(--field); padding: 10px 14px; border-radius: 12px; }
.small-field { display: inline-flex; width: 360px; max-width: 100%; }
.small-field input { width: 100%; border: 0; background: transparent; font: 500 16px/normal var(--body); padding: 12px 14px; border-radius: 16px; }
.small-field input:focus { outline: none; }
@media (max-width: 1000px) { .packs { grid-template-columns: 1fr; max-width: 360px; } }

/* ---------- Мои работы ---------- */
.my .grid { margin-top: 64px; gap: 56px 40px; }
.my .card { gap: 12px; }
.my .card .frame { aspect-ratio: 400 / 302; padding: 6px 8px 6px 8px; }
.my .card .pic { --r: 30px; }
.links { display: flex; gap: 18px; flex-wrap: wrap; }

/* Всплывающая подсказка */
.toast { position: fixed; left: 50%; top: calc(20px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -20px); background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 999px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .35s cubic-bezier(.34,1.56,.64,1); z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ---------- Экраны уже 1440 px: те же пропорции, затем перестройка в колонку ---------- */
@media (max-width: 1439px) {
  .home { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 640px) minmax(0, 644px); justify-content: space-between; align-items: center; gap: 40px; padding: 120px var(--pad) 60px; }
  .hero-text, .stage { position: relative; left: auto; top: auto; width: auto; }
  .hero-text h1 { font-size: clamp(52px, 6.67vw, 96px); }
  .hero-text .lead { width: auto; font-size: clamp(17px, 1.67vw, 24px); }
  .stage { width: 100%; }
}
@media (max-width: 1200px) {
  .editor { grid-template-columns: 80px 24px minmax(0, 1fr) 24px 300px; grid-template-rows: 46px 24px auto minmax(420px, 62vh) auto; padding: 20px 24px 32px; }
}
@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .work { grid-template-columns: 1fr; gap: 32px; min-height: 0; }
  .editor { grid-template-columns: 1fr; grid-template-rows: auto; gap: 16px; padding: 16px; }
  .ed-top, .tools, .tip-row, .ed-host, .palette, .ai { grid-column: 1; grid-row: auto; }
  .tools { flex-direction: row; margin-top: 0; justify-self: start; padding: 10px 14px; }
  .sizes { flex-direction: row; width: auto; }
  .ed-host { height: 62vh; }
  .ai { min-height: 0; }
  .ed-title { justify-content: flex-start; }
  .ed-top { flex-wrap: wrap; } .ed-title { order: 3; flex-basis: 100%; max-width: 100%; overflow: hidden; } .ed-title .muted { display: none; }
  .ed-history { margin-left: auto; }
  .res-head { flex-wrap: wrap; } .res-title { font-size: 30px; }
  .tools { flex-wrap: wrap; width: 100%; justify-self: stretch; }
  .size { width: 30px; }
}
@media (max-width: 960px) {
  .home { grid-template-columns: 1fr; padding: 100px 20px 48px; min-height: 0; gap: 8px; }
  .stage { order: -1; max-width: 560px; margin: 0 auto; }
  .frow { flex-wrap: wrap; } .flabel { width: 100%; }
  .more-row { white-space: normal; row-gap: 6px; }
  .top { gap: 16px; flex-wrap: wrap; height: auto; margin-top: 20px; }
  .page { padding-top: 40px; }
  .h1 { font-size: 44px; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .btn { font-size: 24px; padding: 14px 36px; }
  .ed-top { flex-wrap: wrap; }
  .tool { width: 44px; height: 44px; }
}

/* ---------- Редактор для планшета (макет «редактор · вариант 2 · iPad») ----------
   Холст на весь экран, над ним «нарисованные» панели: бумага + рваная обводка от руки.
   Кнопки 52 px (палец), между инструментами 14 px. .focus — режим фокуса: только холст и инструменты. */
.studio { position: fixed; inset: 0; background: #F2F1EC; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  --pad: 24px; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.studio .ed-host { position: absolute; inset: 0; height: auto; border: 0; border-radius: 0; background: transparent; overflow: hidden; grid-column: auto; grid-row: auto; }
.studio .ed-canvas { cursor: crosshair; }
.st-top, .st-side-wrap, .st-ai, .st-zoom, .st-tip, .st-pop { position: absolute; z-index: 3; }
.st-sep { display: block; width: 2px; height: 32px; background: var(--line); flex: none; }
.st-sep.sm { height: 20px; }

/* верхняя полоса */
.st-top { left: var(--pad); right: var(--pad); top: calc(22px + env(safe-area-inset-top)); height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 12px 0 28px; }
.st-left { display: flex; align-items: center; gap: 20px; min-width: 0; }
.st-back { text-decoration: none; white-space: nowrap; }
.st-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.st-name { font: 700 16px/normal var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-title .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-right { display: flex; align-items: center; gap: 22px; flex: none; }
.st-tools { display: flex; align-items: center; gap: 14px; }

/* кнопки-инструменты: активная — жёлтый «нарисованный» кружок, кольцо — белый кружок с обводкой */
.studio .tool { width: 52px; height: 52px; border-radius: 50%; background: none; display: grid; place-items: center; border: 0; padding: 0; cursor: pointer; flex: none; transition: transform .12s; }
.studio .tool.sm { width: 48px; height: 48px; }
.studio .tool img { width: 26px; height: 26px; }
.studio .tool.on { background: none; }
.studio .tool[data-tool]:not(.on):not(.st-ring) > svg.rough { display: none; }
.studio .tool:active { transform: scale(.92); }
.studio .tool.off img { opacity: .35; }
.st-color { width: 52px; height: 52px; display: grid; place-items: center; background: none; border: 0; padding: 0; cursor: pointer; }
.st-dot { display: block; width: 40px; height: 40px; border-radius: 50%; background: var(--brown); }

/* левая панель: толщина, пипетка, прозрачность, отмена/повтор */
.st-side-wrap { left: calc(var(--pad) + env(safe-area-inset-left)); top: 120px; bottom: var(--pad); display: flex; align-items: center; pointer-events: none; }
.st-side { pointer-events: auto; width: 76px; display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 24px 14px; }
.st-ic { width: 20px; height: 20px; }
.st-hr { display: block; width: 30px; height: 2px; background: var(--line); }
.vs { position: relative; width: 36px; height: clamp(110px, calc((100vh - 560px) / 2), 186px); touch-action: none; cursor: pointer; flex: none; }
.vs:focus-visible { outline: 2px solid var(--gold); outline-offset: 6px; border-radius: 12px; }
.studio .vs-track { position: absolute; left: 11px; top: 8px; bottom: 8px; width: 14px; }
.vs-fill { position: absolute; left: 11px; bottom: 8px; width: 14px; height: calc((100% - 16px) * var(--k, 1)); background: var(--ink); border-radius: 7px; }
.studio .vs-knob { position: absolute; left: 3px; width: 30px; height: 30px; bottom: calc(8px + (100% - 16px) * var(--k, 1) - 15px); transition: transform .12s; }
.vs.drag .vs-knob { transform: scale(1.15); }

/* подсказка и масштаб — по центру свободной области холста */
.st-tip { top: calc(126px + env(safe-area-inset-top)); left: 124px; right: 368px; display: flex; justify-content: center; pointer-events: none; }
.st-tip .tip { pointer-events: auto; max-width: 100%; }
.st-zoom { bottom: calc(var(--pad) + env(safe-area-inset-bottom)); left: calc(124px + (100% - 124px - 368px) / 2); transform: translateX(-50%); display: flex; align-items: center; gap: 20px; padding: 10px 22px; }
.st-zoom .icon { font: 400 18px/normal var(--body); min-width: 24px; min-height: 24px; }
.st-zoom #zval { font: 500 16px/normal var(--body); cursor: pointer; min-width: 44px; text-align: center; }
.st-zoom .st-fit { font: 500 16px/normal var(--body); line-height: normal; }

/* колонка ИИ справа на всю высоту */
.st-ai { right: calc(var(--pad) + env(safe-area-inset-right)); top: 120px; bottom: var(--pad); width: 320px; display: flex; flex-direction: column; gap: 20px; padding: 26px; overflow: auto; }
.st-ai .btn { width: 100%; padding-left: 0; padding-right: 0; }
.st-ai .credits:empty { display: none; }

/* окошко цвета под кружком */
.st-pop { position: fixed; z-index: 8; width: 316px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.st-dots { display: flex; gap: 10px; }
.st-dots .swatch { width: 40px; height: 40px; }
/* меню кистей: образец мазка и название */
.st-bpop { width: 340px; }
.st-brushes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.st-brush { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 8px; background: none; border: 2px solid transparent; border-radius: 16px; cursor: pointer; font: 500 14px/normal var(--body); color: var(--ink); }
.st-brush canvas { width: 120px; height: 40px; }
.st-brush:hover { background: var(--field); }
.st-brush.on { border-color: var(--ink); background: rgba(254, 218, 12, .28); }

/* режим фокуса: исчезают название, подсказка и колонка ИИ; инструменты — плавающая полоска справа */
.studio.focus .st-left, .studio.focus .st-norm, .studio.focus .st-ai, .studio.focus .st-tip { display: none; }
.studio.focus .st-top { left: auto; top: calc(22px + env(safe-area-inset-top)); height: 72px; padding: 0 10px 0 14px; }
.studio.focus .st-side-wrap { top: var(--pad); }
.studio.focus .st-zoom { left: 50%; }

/* планшет в книжной ориентации и узкие окна: колонка ИИ уходит вниз компактной полосой */
@media (max-width: 1100px) {
  .st-tools { gap: 6px; } .st-right { gap: 12px; } .st-left { gap: 14px; }
  .st-title .muted { display: none; }
  .st-ai { top: auto; left: calc(124px); width: auto; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 16px 20px; }
  .st-ai .h3, .st-ai .st-hint, .st-ai .desc, .st-ai .grow, .st-ai .slider .ends { display: none; }
  .st-ai .slider { flex: 1; min-width: 160px; }
  .st-ai .btn { width: auto; flex: none; font-size: 24px; padding: 10px 36px; }
  .st-zoom { left: calc(124px + (100% - 148px) / 2); bottom: 130px; }
  .st-tip { right: var(--pad); }
  .studio.focus .st-zoom { bottom: var(--pad); }
}
@media (max-width: 760px) {
  .st-back, .st-left .st-sep { display: none; }
  .st-tools { gap: 2px; } .studio .tool { width: 44px; height: 44px; }
}

/* ---------- Генерации (макет «тарифы»): три карточки-пакета, вопросы ---------- */
/* заголовки и подзаголовки этих страниц — BIPs, как на главной */
.plans-page :is(.h1, .h2, .h3), .how :is(.display, .h2, .h3) { font-family: var(--hand); font-weight: 400; }
.btn.wide { width: 100%; padding-left: 0; padding-right: 0; }
.plans-page { padding-top: 96px; }
.plans-intro { display: flex; align-items: flex-end; gap: 40px; }
.plans-intro .intro { flex: 1; }
.plans-intro .lead { max-width: 700px; }
.plans-intro .balance { white-space: nowrap; margin: 0 0 6px; }
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; margin-top: 96px; }
.plan { display: flex; flex-direction: column; gap: 20px; min-height: 599px; padding: 36px; margin: 0; position: relative; }
.plan-name { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.badge { position: relative; padding: 6px 14px; font: 700 16px/normal var(--body); white-space: nowrap; }
.plan-price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.plan-price b { font: 700 64px/normal var(--body); white-space: nowrap; }
.plan-hr, .qa-hr { display: block; height: 1px; background: var(--line); }
.plan-feats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; white-space: pre-wrap; }
.plan .btn { margin-top: auto; }
.plan .btn:disabled { cursor: default; opacity: .45; }
.plans-note { margin-top: 96px; }
.plans-qa { margin-top: 96px; display: flex; flex-direction: column; }
.plans-qa .h2 { margin-bottom: 24px; }
.qa { display: flex; gap: 40px; padding: 28px 0; }
.qa .h3 { width: 480px; flex: none; }
.qa p { flex: 1; min-width: 0; }
@media (max-width: 1200px) { .plans { grid-template-columns: 1fr; max-width: 460px; } .plans-intro { flex-direction: column; align-items: flex-start; gap: 24px; } }
@media (max-width: 760px) { .plan-price b { font-size: 48px; } .qa { flex-direction: column; gap: 10px; } .qa .h3 { width: auto; font-size: 22px; } .plans-page { padding-top: 40px; } .plans, .plans-note, .plans-qa { margin-top: 48px; } }

/* ---------- Как это работает (макет «как это работает · вариант 3»), координаты — как в макете ---------- */
.how { padding: 0 var(--pad); overflow-x: clip; }
.how-in { width: 1280px; margin: 120px auto 160px; }
.display { font: 700 96px/normal var(--body); }
.hw { position: relative; }
.hw + .hw, .hw + .hw-ba, .hw-ba + .hw, .hw + .hw-turn { margin-top: 120px; }
.hw-hero { height: 600px; }
.hw-hero-text { position: absolute; left: 0; top: 30px; }
.hw-hero-text .display { width: 620px; }
.hw-hero-text .lead { width: 520px; margin-top: 4px; }
.hw-pic, .hw-card, .hw-note, .sticker.or { position: absolute; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); }
.hw-pic .pic { display: block; }
.pic-layer { object-fit: fill !important; height: 103.26% !important; z-index: 2; }
.hw-steps { height: 1491px; }
.hw-path { position: absolute; }
.hw-step { position: absolute; width: 480px; display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.sticker { position: relative; display: grid; place-items: center; width: 96px; height: 96px; border-radius: 48px; font: 700 64px/1 var(--body); color: var(--ink); }
.sticker.or { font-size: 28px; }
.hw-ways { height: 480px; }
.hw-center { text-align: center; }
.hw-card { width: 600px; padding: 32px 36px; display: flex; flex-direction: column; gap: 18px; }
.hw-toggle { display: flex; align-items: center; gap: 12px; }
.hw-slider { display: flex; flex-direction: column; gap: 10px; }
.hw-track { position: relative; height: 6px; border-radius: 3px; background: var(--line); }
.hw-track i { position: absolute; left: 0; top: 0; width: 190px; height: 6px; border-radius: 3px; background: var(--ink); }
.hw-track img { position: absolute; left: 180px; top: -7px; }
.hw-slider .ends { display: flex; justify-content: space-between; }
.hw-ba { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }
.hw-ba .lead { width: 760px; max-width: 100%; }
.hw-cmp { position: relative; width: 900px; max-width: 100%; aspect-ratio: 900 / 760; margin-top: 20px; border-radius: 30px; background: #F2F1EC; box-shadow: 0 6px 24px rgba(0,0,0,.12); touch-action: none; cursor: ew-resize; user-select: none; -webkit-user-select: none; }
.hw-cmp > svg.rough { z-index: 3; }
.hw-cmp .after { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 30px; }
.hw-cmp .before { position: absolute; inset: 0; overflow: hidden; border-radius: 30px; clip-path: inset(0 calc(100% - var(--x)) 0 0); }
.hw-cmp .before img { position: absolute; left: -7.444%; top: -38.947%; width: 112.333%; height: 172.895%; max-width: none; }
.hw-cmp .divider { position: absolute; top: 0; bottom: 0; left: calc(var(--x) - 3px); width: 6px; background: var(--paper); z-index: 2; }
.hw-cmp .handle { position: absolute; left: var(--x); top: 50%; transform: translate(-50%, -50%); width: 64px; height: 64px; border-radius: 32px; box-sizing: border-box; border: 5px solid var(--ink); background: var(--paper); display: grid; place-items: center; font: 700 20px/1 var(--body); z-index: 4; }
.hw-cmp .lbl { position: absolute; top: 28px; padding: 9px 18px; border-radius: 12px; color: var(--paper); font: 700 20px/normal var(--body); z-index: 4; pointer-events: none; }
.hw-cmp .l-before { left: 32px; background: var(--muted); } .hw-cmp .l-after { right: 32px; background: var(--dark-brown); }
.hw-drag { font-weight: 700; }
.hw-notes { height: 500px; }
.hw-note { width: 600px; padding: 28px 32px; display: flex; flex-direction: column; gap: 12px; }
.hw-note p { color: var(--muted); } .hw-note.gold p { color: var(--ink); }
.hw-turn { height: 380px; display: flex; flex-direction: column; align-items: center; padding-top: 20px; }
.hw-turn .display { text-align: center; }
.hw-turn .actions { display: flex; gap: 24px; margin-top: 80px; }

/* узкие экраны: те же блоки в колонку */
@media (max-width: 900px) {
  .how-in { width: auto; margin: 48px 0 80px; }
  .display { font-size: 48px; }
  .hw + .hw, .hw + .hw-ba, .hw-ba + .hw, .hw + .hw-turn { margin-top: 72px; }
  .hw-hero, .hw-steps, .hw-ways, .hw-notes, .hw-turn { height: auto; display: flex; flex-direction: column; gap: 28px; }
  .hw-hero-text, .hw-step, .hw-pic, .hw-card, .hw-note, .sticker.or { position: relative; left: auto !important; top: auto !important; width: auto; transform: rotate(calc(var(--rot, 0deg) / 2)); }
  .hw-hero-text .display, .hw-hero-text .lead, .hw-step { width: auto; }
  .hw-pic .pic { width: min(100%, 460px) !important; height: auto !important; aspect-ratio: 4 / 3; margin: 0 auto; }
  .hw-hero .hw-pic:nth-of-type(2) .pic { aspect-ratio: 290 / 373; width: min(80%, 320px) !important; }
  .hw-hero .hw-pic:nth-of-type(3) .pic { aspect-ratio: 320 / 350; width: min(80%, 340px) !important; }
  .hw-path { display: none; }
  .hw-ways .sticker.or { width: 96px; align-self: center; order: 2; }
  .top nav { flex-wrap: wrap; row-gap: 10px; column-gap: 20px; } .hw-ways .hw-card:last-of-type { order: 3; }
  .hw-card, .hw-note { padding: 24px; }
  .hw-track i { width: 33%; } .hw-track img { left: calc(33% - 10px); }
  .hw-turn .actions { flex-direction: column; margin-top: 32px; }
  .hw-cmp .lbl { top: 14px; font-size: 16px; } .hw-cmp .l-before { left: 14px; } .hw-cmp .l-after { right: 14px; }
}

/* скрытая страница владельца */
.adm-row { margin-top: 32px; }
.adm-state { margin-top: 20px; }

/* пустые «Избранное» и «Мои работы» — экраны из Figma: всё по центру, отступы как в макете (кадр 1440);
   шапка занимает 86 px сверху, заголовок в макете — на 187 / 136 px */
.empty-screen { position: relative; max-width: 1440px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 101px 20px 80px; }
.empty-screen.my { padding-top: 50px; }
.es-title { font: 400 96px/normal var(--hand); margin: 0; }
.es-text { font: 400 24px/normal var(--body); color: var(--ink); margin: 20px 0 0; width: 464px; max-width: 100%; }
.empty-screen.my .es-text { width: 391px; }
.es-art { margin-top: 32px; }
.es-frames { position: relative; width: 851px; height: 293px; }
.es-frames img { position: absolute; }
.empty-screen.my .es-art { margin-top: 57px; }
.empty-screen > .btn { margin-top: 40px; }
.empty-screen.my > .btn { margin-top: 69px; }
/* в макете текст, кнопка и заголовок «Избранного» стоят на 14 px правее центра (рисунки — ровно по центру) */
@media (min-width: 901px) { .es-text, .empty-screen > .btn, .empty-screen.fav .es-title { position: relative; left: 14px; } }
@media (max-width: 900px) {
  .empty-screen, .empty-screen.my { padding-top: 40px; }
  .es-title { font-size: 56px; }
  .es-text { font-size: 18px; }
  .es-frames { zoom: .4; }
  .es-easel { zoom: .7; }
}
