/* Оболочка «Примерки» — в бренде Томера (design/DECISIONS.md iukhvidov): бумага #ECEAE4, графит #1A1C1B, сирень #3F3A6B,
   сигнальный жёлтый #EBCB3E, патина #357562; IBM Plex Sans / Sans Hebrew, цифры — Plex Mono. Черновик заказчика живёт в iframe и своих тем. */
:root {
  --paper: #ECEAE4; --tint: #E1DED5; --surface: #F6F5F1; --ink: #1A1C1B; --muted: #57544D; --quiet: #635F56;
  --lilac: #3F3A6B; --lilac-deep: #2B274C; --lilac-soft: #CECAE3; --signal: #EBCB3E; --signal-soft: #F6ECC0; --signal-ink: #5E500E; --live: #357562;
  --line: rgba(26,28,27,.12); --r: 14px; --r-s: 10px;
  --f: 'IBM Plex Sans', 'IBM Plex Sans Hebrew', system-ui, sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --bar: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { overflow-x: clip; }
body { background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--f); -webkit-font-smoothing: antialiased; overflow-x: clip; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; }

.app { height: 100svh; display: grid; grid-template-rows: var(--bar) auto 1fr; }
.bar { display: flex; align-items: center; gap: 12px; padding-inline: 16px; border-block-end: 1px solid var(--line); background: var(--paper); z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 17px; }
.mark { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.mark i { width: 9px; height: 9px; border-radius: 2px; background: var(--ink); }
.mark i:last-child { background: var(--live); }
.bsub { color: var(--quiet); font-size: 13px; display: none; }
.gap { flex: 1; }
.uil { display: flex; background: var(--tint); border-radius: 99px; padding: 3px; }
.uil button { border: 0; background: none; padding: 5px 10px; border-radius: 99px; font-size: 13px; cursor: pointer; color: var(--muted); }
.uil button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.back { font-size: 13px; color: var(--lilac); text-decoration: none; white-space: nowrap; }
.back::before { content: '← '; }
[dir="rtl"] .back::before { content: '→ '; }

/* превью */
.stage { position: relative; background: var(--tint); border-block-end: 1px solid var(--line); display: grid; grid-template-rows: auto 1fr; min-height: 0; height: 42svh; }
.tools { display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 48px; position: relative; }
.dev { display: none; background: var(--surface); border-radius: 99px; padding: 3px; }
.dev button { border: 0; background: none; padding: 6px 12px; border-radius: 99px; font-size: 13px; cursor: pointer; color: var(--muted); }
.dev button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.est { border: 0; background: var(--signal); color: #2b2508; font: 600 14px/1 var(--mono); padding: 8px 12px; border-radius: 99px; cursor: pointer; white-space: nowrap; transition: transform .3s cubic-bezier(.3,1.6,.5,1); }
.est.bump { transform: scale(1.12); }
.expand { margin-inline-start: auto; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.toast { position: absolute; left: 50%; translate: -50% 0; top: auto; bottom: -38px; z-index: 4; margin: 0; background: var(--ink); color: var(--paper); font-size: 13px; padding: 7px 12px; border-radius: 99px; opacity: 0; transform: translateY(-6px); transition: opacity .3s, transform .3s; pointer-events: none; max-width: calc(100% - 24px); }
.toast.on { opacity: 1; transform: none; }
.viewport { position: relative; overflow: hidden; min-height: 0; }
.device { position: absolute; top: 0; inset-inline-start: 50%; transform-origin: top center; background: #fff; overflow: hidden; }
[dir="rtl"] .device { inset-inline-start: auto; right: 50%; }
.device iframe { display: block; border: 0; width: 100%; height: 100%; background: #F1EFEA; }
.stage.is-phone .device { border-radius: 26px; box-shadow: 0 0 0 9px #1A1C1B, 0 30px 60px -24px rgba(0,0,0,.45); }
.stage.is-desk .device { border-radius: 10px; box-shadow: 0 0 0 1px rgba(0,0,0,.18), 0 30px 60px -24px rgba(0,0,0,.4); }

/* чат */
.chat { display: grid; grid-template-rows: 1fr auto auto auto; min-height: 0; background: var(--paper); }
.log { overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 15.5px; line-height: 1.45; animation: pop .35s cubic-bezier(.2,.8,.2,1) both; }
.msg.q { background: var(--surface); align-self: flex-start; border-end-start-radius: 4px; box-shadow: 0 1px 0 var(--line); }
.msg.a { background: var(--lilac); color: #F7F6F2; align-self: flex-end; border-end-end-radius: 4px; }
.msg.typing { color: var(--muted); }
.msg.typing i { display: inline-block; width: 6px; height: 6px; margin-inline: 2px; border-radius: 50%; background: currentColor; animation: dot 1s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; } .msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { opacity: .2; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ask { padding: 4px 16px 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.ask:empty { display: none; }
.opt { border: 1.5px solid var(--lilac); background: var(--surface); color: var(--lilac); border-radius: 99px; padding: 9px 15px; font-size: 15px; cursor: pointer; transition: background .2s, color .2s, transform .15s; min-height: 42px; }
.opt:hover { background: var(--lilac-soft); }
.opt:active { transform: scale(.97); }
.opt[aria-pressed="true"] { background: var(--lilac); color: #F7F6F2; }
.opt.go { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.opt:disabled { opacity: .5; cursor: default; }
.sw { border: 1.5px solid transparent; background: none; padding: 0; border-radius: 14px; cursor: pointer; width: calc(33.333% - 6px); max-width: 150px; text-align: start; }
.sw .card { display: block; border-radius: 12px; padding: 12px 10px; height: 96px; position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.sw .card b { display: block; font-size: 22px; line-height: 1; }
.sw .card i { position: absolute; inset-inline-start: 10px; bottom: 12px; width: 44px; height: 14px; border-radius: 4px; }
.sw .card s { position: absolute; inset-inline-end: 10px; bottom: 12px; width: 30%; height: 4px; border-radius: 2px; opacity: .35; background: currentColor; text-decoration: none; }
.sw span { display: block; font-size: 14px; padding: 6px 4px 0; color: var(--muted); }
.sw:hover .card { box-shadow: inset 0 0 0 2px var(--lilac); }
.input { display: flex; gap: 8px; padding: 6px 12px 8px; }
.input input { flex: 1; min-width: 0; border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px; padding: 11px 16px; font: inherit; font-size: 16px; color: var(--ink); }
.input input:focus { outline: none; border-color: var(--lilac); }
.send { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--lilac); color: #fff; cursor: pointer; display: grid; place-items: center; }
[dir="rtl"] .send svg { transform: scaleX(-1); }
.enough { justify-self: center; border: 0; background: none; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; padding: 2px 10px 12px; cursor: pointer; }

/* финал */
.finalbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-block-start: 1px solid var(--line); }
.finalbar[hidden] { display: none; }
.finalbar button, .finalbar a { flex: none; border: 1.5px solid var(--ink); background: var(--surface); color: var(--ink); border-radius: 99px; padding: 9px 14px; font-size: 14.5px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.finalbar .primary { background: var(--lilac); border-color: var(--lilac); color: #F7F6F2; font-weight: 600; }
.finalbar .wa { background: #1F7A4D; border-color: #1F7A4D; color: #fff; }
body.is-final .app { grid-template-rows: var(--bar) 1fr auto; }
body.is-final .chat { display: none; }
body.is-final .stage { height: auto; border: 0; }
body.is-final .expand { display: none; }

/* лист */
.sheet { position: fixed; inset: 0; z-index: 40; display: grid; align-items: end; }
.sheet[hidden] { display: none; }
.sheet-back { position: absolute; inset: 0; background: rgba(26,28,27,.45); }
.sheet-panel { position: relative; background: var(--paper); border-radius: 22px 22px 0 0; max-height: 88svh; overflow-y: auto; padding: 0 18px calc(22px + env(safe-area-inset-bottom)); animation: up .35s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-panel header { display: flex; align-items: center; position: sticky; top: 0; background: var(--paper); padding-block: 16px 10px; }
.sheet-panel h2 { margin: 0; font-size: 20px; flex: 1; }
.x { border: 0; background: var(--tint); width: 36px; height: 36px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.lines { display: grid; gap: 0; margin: 0 0 12px; }
.lines div { display: flex; justify-content: space-between; gap: 12px; padding-block: 11px; border-block-end: 1px solid var(--line); }
.lines .v { font: 500 15px/1.3 var(--mono); white-space: nowrap; }
.lines .ask .v { font-family: var(--f); color: var(--muted); font-size: 14px; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding-block: 14px 4px; font-weight: 700; font-size: 18px; }
.total .v { font: 600 24px/1 var(--mono); }
.monthly { display: flex; justify-content: space-between; color: var(--muted); }
.monthly .v { font-family: var(--mono); }
.friday { background: var(--signal-soft); color: var(--signal-ink); padding: 12px 14px; border-radius: var(--r-s); margin-block: 14px; font-weight: 500; }
.sub { color: var(--muted); font-size: 14px; margin-block: 6px 0; }
.sheet-body h3 { font-size: 15px; margin: 18px 0 6px; }
.sheet-body ul { margin: 0; padding-inline-start: 20px; color: var(--muted); font-size: 14.5px; }
.ctl { margin-block: 14px; }
.ctl > b { display: block; font-size: 14px; margin-block-end: 8px; color: var(--muted); font-weight: 500; }
.ctl .row { display: flex; flex-wrap: wrap; gap: 8px; }
.form { display: grid; gap: 12px; margin-block: 8px; }
.form label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.form input { border: 1.5px solid var(--line); background: var(--surface); border-radius: var(--r-s); padding: 12px 14px; font: inherit; font-size: 16px; color: var(--ink); }
.form input:focus { outline: none; border-color: var(--lilac); }
.form .hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form .go { background: var(--lilac); color: #fff; border: 0; border-radius: 99px; padding: 14px; font-weight: 600; font-size: 16px; cursor: pointer; }
.form .go:disabled { opacity: .6; }
.note { font-size: 13px; color: var(--quiet); }
.ok { background: #DDEBE5; color: #1E4A3D; padding: 14px; border-radius: var(--r-s); }
.err { background: #F6E3DF; color: #6B2A1E; padding: 12px; border-radius: var(--r-s); }
.copyrow { display: flex; gap: 8px; } .copyrow input { flex: 1; min-width: 0; }

/* полноэкранное превью на телефоне */
body.is-full .stage { position: fixed; inset: 0; z-index: 30; height: 100svh; }
body.is-full .expand { display: inline-block; }

@media (min-width: 1000px) {
  .bsub { display: inline; }
  .app { grid-template-columns: minmax(360px, 420px) 1fr; grid-template-rows: var(--bar) 1fr; }
  .bar { grid-column: 1 / -1; }
  .chat { grid-column: 1; grid-row: 2; border-inline-end: 1px solid var(--line); }
  .stage { grid-column: 2; grid-row: 2; height: auto; border: 0; }
  .dev { display: flex; }
  .expand { display: none; }
  .sheet { align-items: center; justify-items: center; }
  .sheet-panel { border-radius: 22px; width: min(560px, 92vw); }
  body.is-final .app { grid-template-columns: 1fr; grid-template-rows: var(--bar) 1fr auto; }
  body.is-final .stage { grid-column: 1; grid-row: 2; }
  body.is-final .finalbar { grid-column: 1; grid-row: 3; justify-content: center; }
  .toast { bottom: auto; top: 60px; }
}

/* финал: строка лестницы, два ряда кнопок, панель «Дизайн» (каталог 01.12.2026) */
.finalbar { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.fb-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.fb-row.sec button { padding: 7px 13px; font-size: 13.5px; border-width: 1px; border-color: var(--line); background: var(--surface); }
.fb-row.main .primary { flex: 1 1 auto; max-width: 340px; }
.finalbar .ladder { justify-self: center; white-space: normal; overflow-wrap: anywhere; border: 0; background: var(--signal-soft); color: var(--signal-ink); font: 500 13.5px/1.35 var(--f); padding: 8px 14px; border-radius: 12px; cursor: pointer; text-align: center; max-width: 100%; }
.ladder[hidden] { display: none; }
.packname { margin: 0 0 6px; color: var(--muted); }
.packname b { color: var(--ink); }
.nextup { width: 100%; margin-block: 4px 6px; border-color: var(--signal-ink); color: var(--signal-ink); background: var(--signal-soft); font-size: 14px; }
.dock { position: fixed; inset-inline: 0; bottom: 0; z-index: 35; background: var(--paper); border-radius: 20px 20px 0 0; box-shadow: 0 -18px 40px -18px rgba(0,0,0,.35); max-height: 44svh; overflow-y: auto; padding: 0 16px calc(14px + env(safe-area-inset-bottom)); animation: up .35s cubic-bezier(.2,.8,.2,1); }
.dock[hidden] { display: none; }
.dock header { display: flex; align-items: center; position: sticky; top: 0; background: var(--paper); padding-block: 12px 4px; z-index: 1; }
.dock header b { flex: 1; font-size: 16px; }
.dock .ctl { margin-block: 10px; }
.chips { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; padding-block-end: 2px; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px 6px 8px; font-size: 13.5px; cursor: pointer; min-height: 40px; }
[dir="rtl"] .chip { padding: 6px 8px 6px 12px; }
.chip[aria-pressed="true"] { border-color: var(--lilac); box-shadow: inset 0 0 0 1px var(--lilac); }
.chip .pal { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.chip .aa { font-style: normal; font-size: 18px; line-height: 1; width: 26px; text-align: center; }
.chip .rq { width: 18px; height: 18px; border: 2px solid var(--ink); border-end-start-radius: 0 !important; }
body.is-dock .finalbar { visibility: hidden; }
@media (min-width: 1000px) {
  .finalbar { grid-template-columns: 1fr auto auto 1fr; align-items: center; }
  .ladder { grid-column: 1 / -1; }
  .fb-row.sec { grid-column: 2; }
  .fb-row.main { grid-column: 3; }
  .dock { inset-inline: auto 24px; bottom: 76px; width: 420px; border-radius: 20px; max-height: calc(100svh - 120px); }
  body.is-dock .finalbar { visibility: visible; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
