:root {
  --bg: #f7f1e6;
  --card: #fffdf8;
  --ink: #233057;
  --muted: #7a7f93;
  --accent: #b8433f;
  --accent-2: #2f6b4f;
  --gold: #c99a3b;
  --line: #eadfcc;
  --radius: 18px;
  --script: "Marck Script", "Segoe Script", cursive;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 "Nunito", system-ui, sans-serif;
  max-width: 100%; overflow-x: hidden; overflow-x: clip; overscroll-behavior-x: none; }
/* экран не должен сдвигаться вбок: ничего шире экрана */
img, video { max-width: 100%; }
body { padding-bottom: 84px; }
main { max-width: 560px; margin: 0 auto; padding: 16px 14px 24px; position: relative; z-index: 1; overflow-x: clip; }

.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: radial-gradient(#fff 1.4px, transparent 1.6px), radial-gradient(#fff 1px, transparent 1.2px);
  background-size: 46px 46px, 28px 28px; background-position: 0 0, 14px 20px; animation: snow 18s linear infinite; }
@keyframes snow { to { background-position: 0 460px, 14px 300px; } }

h1 { font-family: var(--script); font-weight: 400; font-size: 40px; text-align: center; margin: 6px 0 2px; color: var(--accent); }
h2 { font-size: 20px; margin: 22px 0 10px; font-weight: 800; }
.sub { text-align: center; color: var(--muted); margin: 0 0 16px; line-height: 1.5; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0;
  box-shadow: 0 2px 10px rgba(60, 40, 10, .05); }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }

.btn { display: block; width: 100%; border: 0; border-radius: 14px; padding: 14px 16px; font: 700 16px "Nunito", sans-serif;
  background: var(--ink); color: #fff; cursor: pointer; margin-top: 10px; }
.btn.red { background: var(--accent); }
.btn.green { background: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn.small { display: inline-block; width: auto; padding: 8px 12px; font-size: 14px; margin: 0; }
.btn:disabled { opacity: .45; cursor: default; }

.product { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.product .thumb { width: 74px; height: 96px; border-radius: 10px; flex: none; }
.product b { font-size: 16px; }
.price { font-weight: 800; color: var(--accent); white-space: nowrap; font-size: 17px; }

.thumb { background: linear-gradient(160deg, #2d4a7a, #8fb3d9 60%, #f5efe4); display: flex; align-items: center;
  justify-content: center; font-size: 34px; overflow: hidden; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.opt { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; position: relative; }
.opt.sel { border-color: var(--ink); }
.opt.sel::after { content: "✓"; position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center; z-index: 2; }
.opt .t { font-weight: 800; }
.scene { padding: 5px; text-align: center; font-size: 12.5px; font-weight: 700; }
.scene .thumb { aspect-ratio: 3/4; border-radius: 10px; margin-bottom: 5px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 700; }
.chip.sel { border-color: var(--ink); background: var(--ink); color: #fff; }

.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.ph { width: 78px; height: 98px; border-radius: 12px; overflow: hidden; position: relative; background: #eee; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph button { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 50%; width: 22px; height: 22px;
  background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
.add { width: 78px; height: 98px; border: 2px dashed var(--line); border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--muted); cursor: pointer; font-weight: 700; font-size: 12px; }
.add span { font-size: 26px; line-height: 1; }

.result img { width: 100%; border-radius: 12px; display: block; }
.pages { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pages .pg img { width: 100%; border-radius: 10px; display: block; }
.pages .pg .row { margin-top: 4px; font-size: 13px; font-weight: 700; }

.spinner { width: 44px; height: 44px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite; margin: 16px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: #efe7d6; }
.badge.ok { background: #dcefe3; color: var(--accent-2); }
.badge.err { background: #f6dcdb; color: var(--accent); }
.err { color: var(--accent); font-size: 13px; margin-top: 6px; }
.feat { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.feat i { font-style: normal; font-size: 20px; }
.loader { text-align: center; padding: 60px 0; color: var(--muted); }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); z-index: 5; }
.tabs button { flex: 1; border: 0; background: transparent; font: 800 14px "Nunito", sans-serif; color: var(--muted); padding: 10px; border-radius: 12px; cursor: pointer; }
.tabs button.active { background: var(--bg); color: var(--ink); }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 12px; font-weight: 700; opacity: 0; transition: opacity .2s; z-index: 9; max-width: 90%; text-align: center; pointer-events: none; }
#toast.show { opacity: 1; }

/* ---- шаблоны, баланс ---- */
.center { text-align: center; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.logo { font-family: var(--script); font-weight: 400; font-size: 30px; color: var(--accent); }
.balance { border: 0; background: var(--ink); color: #fff; font: 800 15px "Nunito", sans-serif; border-radius: 999px;
  padding: 8px 8px 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.balance span { background: var(--accent); border-radius: 50%; width: 24px; height: 24px; display: inline-flex;
  align-items: center; justify-content: center; }
.hero { position: relative; border-radius: var(--radius); overflow: hidden; min-height: 170px; cursor: pointer;
  background: linear-gradient(135deg, #5a1d1d, #b8433f); color: #fff; }
.hero img { width: 100%; height: 200px; object-fit: cover; object-position: center 35%; display: block; }
.hero-t { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 14px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); display: flex; flex-direction: column; gap: 4px; }
.hero-t b { font-size: 21px; }
.hero-t small { opacity: .85; }
.tgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tcard { cursor: pointer; }
.tthumb, .bigprev { position: relative; aspect-ratio: 3/4; border-radius: 14px; overflow: hidden;
  background: linear-gradient(160deg, #2d4a7a, #8fb3d9 60%, #f5efe4); display: flex; align-items: center;
  justify-content: center; font-size: 40px; }
.tthumb img, .bigprev img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bigprev { aspect-ratio: auto; height: 380px; margin-top: 12px; font-size: 70px; }
.tbadge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font: 800 11px "Nunito", sans-serif;
  padding: 3px 8px; border-radius: 999px; font-style: normal; z-index: 2; }
.hero .tbadge { position: static; align-self: flex-start; }
.play { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,.55);
  color: #fff; font-size: 12px; font-style: normal; display: flex; align-items: center; justify-content: center; z-index: 2; }
.example { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.6); color: #fff; font: 700 11px "Nunito", sans-serif;
  font-style: normal; padding: 4px 6px; text-align: center; z-index: 2; }
.tname { font-weight: 800; margin-top: 6px; line-height: 1.2; }
.tmeta { color: var(--muted); font-size: 13px; }
.ttl { font-family: "Nunito", sans-serif; font-weight: 800; font-size: 24px; color: var(--ink); text-align: left; margin: 14px 0 4px; }
.ttl + .sub { text-align: left; }
.fld { display: block; margin-top: 16px; font-weight: 800; font-size: 15px; color: var(--ink); line-height: 1.3; }
.fld input { display: block; width: 100%; margin-top: 8px; padding: 14px 14px; min-height: 52px; border-radius: 14px;
  border: 2px solid #d9cbb0; font: 700 18px "Nunito", sans-serif; color: var(--ink); background: #fff;
  box-shadow: inset 0 1px 3px rgba(60, 40, 10, .06); -webkit-appearance: none; appearance: none; }
.fld input::placeholder { color: #b5ad9c; font-weight: 600; }
.fld input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(35, 48, 87, .12); }
.say { margin-top: 16px; background: #f3ecdf; border-radius: 14px; padding: 12px 14px; font-style: italic; line-height: 1.5; }
.pack { display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; }
.pack.off { opacity: .45; cursor: default; }
.pp { text-align: right; white-space: nowrap; }
.badge.hot { background: var(--accent); color: #fff; }
.result video { width: 100%; border-radius: 12px; display: block; background: #000; }

/* видео-сценарии: реплики по клипам */
.say .sayline { margin: 8px 0; }
.say .saytitle { margin-bottom: 8px; opacity: .85; }
.say .cnt { font-size: 11px; opacity: .6; white-space: nowrap; }
.say .cnt.over { color: #c0392b; opacity: 1; font-weight: 700; }
.say .sayerr { color: #c0392b; margin-top: 6px; font-weight: 600; }
.chips.mini { margin: 10px 0 4px; gap: 8px; }
.chips.mini .chip { font-size: 13px; padding: 7px 12px; line-height: 1.25; }
.muted.small { font-size: 12.5px; margin: 6px 0 4px; line-height: 1.45; }
.tabs button { white-space: nowrap; }
.tlabel { position: relative; display: inline-block; }
.tabbadge { position: absolute; top: -9px; right: -16px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #e53935; color: #fff; font-size: 11px; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--card);
  animation: tpop .4s ease; }
@keyframes tpop { 0% { transform: scale(.3); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* пример видео в карточке шаблона */
.bigprev.hasvid { cursor: pointer; }
.bigplay { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); width: 74px; height: 74px; border-radius: 50%;
  background: rgba(184, 67, 63, .92); color: #fff; font: normal 30px/74px "Nunito", sans-serif; text-align: center;
  padding-left: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.35); z-index: 2; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translate(-50%, -50%) scale(1.08); } }
.bigprev.playing { background: #000; height: auto; aspect-ratio: 9/16; max-height: 78vh; }
.bigprev video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }

/* галочка «надпись с именем» */
.check { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; font-size: 16px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: #c8102e; margin: 0; flex: none; }
