/* Mini App «Кровное обещание». Стиль — по макету арт-директора (screen-donor): тёмный фон с живыми каплями,
   стеклянные плашки, кнопки со светящимся краем, белый талон договора.
   Шкала: кегли 40 / 32 / 24 / 20 / 18 / 14, отступы 8 / 12 / 16 / 24 / 32 / 48.
   Шрифты: Artegra Sans Extended — заголовки, главная кнопка, имя; Artegra Sans — всё остальное. */
@font-face { font-family: "Artegra Ext"; font-weight: 400; font-display: swap; src: url(fonts/ArtegraSansExtended-Regular.woff2) format("woff2"); }
@font-face { font-family: "Artegra Ext"; font-weight: 600; font-display: swap; src: url(fonts/ArtegraSansExtended-SemiBold.woff2) format("woff2"); }
@font-face { font-family: "Artegra Ext"; font-weight: 700; font-display: swap; src: url(fonts/ArtegraSansExtended-Bold.woff2) format("woff2"); }
@font-face { font-family: "Artegra"; font-weight: 400; font-display: swap; src: url(fonts/ArtegraSans-Regular.woff2) format("woff2"); }
@font-face { font-family: "Artegra"; font-weight: 500; font-display: swap; src: url(fonts/ArtegraSans-Medium.woff2) format("woff2"); }

/* Токены объявлены на самом приложении: страница-хозяин (демо или чужая вёрстка) не может их перебить. */
.ko-app {
  --night: #050915;
  --sheet: #060a19;
  --ink: #060917;
  --grey: #93959e;
  --red: #ff0000;
  --pink: #f94da6;
  --muted: rgba(255, 250, 251, .76);
  --err: #ff8aa2;
  --grad: linear-gradient(90deg, #fb346f 4.5%, #ff0000 28.9%, #f94da6 71.6%, #fe1226 103%);
  --ext: "Artegra Ext", "Artegra", system-ui, sans-serif;
  --txt: "Artegra", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --pad: 24px;
  --tag-h: 60px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
.ko-app { position: relative; height: 100%; overflow: hidden; background: #000; color: #fff; font: 400 18px/1.4 var(--txt); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; font-synthesis: none; }
.ko-app ::selection { background: rgba(249, 77, 166, .4); color: inherit; }
.ko-app textarea, .ko-app input { caret-color: var(--pink); }

/* ---------- живой фон ---------- */
/* Каждая капля — две вложенные анимации с разной длительностью: обёртка плывёт по осям, картинка пульсирует.
   Периоды не кратны, поэтому рисунок не повторяется. Двигаются только готовые слои (transform). */
.bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: linear-gradient(180deg, #000 0%, var(--night) 76%); }
/* Капли рисует goo.js на canvas с сеткой в 3 раза мельче экрана, браузер растягивает его с мягкими краями. */
.goo { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .95; }
.shade { position: absolute; left: -10%; right: -10%; top: -40px; height: 92px; background: #060a19; filter: blur(50px); mix-blend-mode: multiply; }
/* Притемнение поверх капель: текст белый, фон под ним должен оставаться тёмным. */
.dim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5, 9, 21, .2) 0%, rgba(5, 9, 21, .08) 40%, rgba(5, 9, 21, .5) 100%); }
/* Свечение у нижнего края живёт так же, как капли: три размытых пятна плывут вдоль края и дышат. */
/* Без обрезки контейнера: пятна размыты сильно и сами растворяются в тёмном фоне, границы не видно.
   Режим «экран» подсвечивает только тёмное: белый текст и кнопки свечение не выцветает. */
.glow { position: absolute; z-index: 3; mix-blend-mode: screen; left: 0; right: 0; bottom: 0; height: 0; pointer-events: none; }
.glow i { position: absolute; bottom: -78px; width: 70%; height: 150px; border-radius: 50%; filter: blur(56px); opacity: 1; will-change: transform; animation: ko-glow-a 11s ease-in-out infinite alternate; }
.glow .g1 { left: -12%; background: #ff0000; }
.glow .g2 { left: 22%; background: #f94da6; animation-name: ko-glow-b; animation-duration: 8.5s; }
.glow .g3 { right: -14%; background: #fe1226; animation-name: ko-glow-c; animation-duration: 13s; }
@keyframes ko-glow-a { 0% { transform: translate(0, 0) scale(1, 1); } 50% { transform: translate(28%, -10px) scale(1.25, .85); } 100% { transform: translate(8%, 14px) scale(.9, 1.2); } }
@keyframes ko-glow-b { 0% { transform: translate(0, 6px) scale(.95, 1); } 50% { transform: translate(-30%, -14px) scale(1.15, 1.25); } 100% { transform: translate(24%, 10px) scale(1.2, .9); } }
@keyframes ko-glow-c { 0% { transform: translate(0, 0) scale(1, 1.1); } 50% { transform: translate(-26%, 12px) scale(.85, .9); } 100% { transform: translate(-6%, -12px) scale(1.25, 1.15); } }
/* Хэштег прибит к низу экрана поверх всего и не спорит с кнопками. */
.tag { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; margin: 0; padding: 0 0 calc(20px + env(safe-area-inset-bottom, 0px)); font: 400 12px/1 var(--ext); letter-spacing: .16em; text-transform: uppercase; text-align: center; padding-left: 0; color: rgba(255, 255, 255, .72); pointer-events: none; }

.view { position: absolute; inset: 0; z-index: 1; overflow-y: auto; overflow-x: hidden; container-type: size; }
.scr { position: relative; min-height: 100%; display: flex; flex-direction: column; animation: ko-in .28s var(--ease-out); }
.scr.back { animation-name: ko-back; }
.scr.still { animation: none; }
@keyframes ko-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes ko-back { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.pad { position: relative; flex: 1; display: flex; flex-direction: column; padding: 12px var(--pad) calc(var(--tag-h) + env(safe-area-inset-bottom, 0px)); }
.grow { flex: 1 1 0; min-height: 32px; }

/* ---------- типографика ---------- */
h1 { margin: 32px 0 0; font: 600 min(32px, 8.2cqi)/1.1 var(--ext); text-wrap: balance; }
h1.hero { font-size: min(42px, 10.4cqi); line-height: 1; }
.lead { margin: 16px 0 0; font: 400 18px/1.4 var(--txt); text-wrap: pretty; max-width: 34em; }
.lead + .lead { margin-top: 12px; }
.muted { color: var(--muted); }
/* Тёмный ореол под текстом на фоне: буквы читаются и поверх яркой капли. */
.pad > h1, .pad > .lead, .consent, .hint, .sign label, .thanks-line { text-shadow: 0 1px 14px rgba(5, 9, 21, .85), 0 0 2px rgba(5, 9, 21, .6); }
.hl { color: #ff2a3a; }

/* Шаги: три тонких полосы, пройденные — красные. */
.steps { display: flex; gap: 12px; }
.steps i { flex: 1; height: 3px; border-radius: 100px; background: rgba(255, 255, 255, .3); }
.steps i.on { background: var(--red); }

/* Логотипы партнёров через тонкие разделители. */
.brands { display: flex; align-items: center; justify-content: space-between; height: 23px; margin: 24px 4px 0; }
.brands img { display: block; height: auto; filter: brightness(0) invert(1); }
.brand-gr { width: 38px; }
.brand-ds { width: 86px; }
.brand-nn { width: 44px; }
.brand-ob { width: 66px; }
.brands i { width: 1px; height: 18px; background: rgba(255, 255, 255, .6); }

/* ---------- кнопки ---------- */
/* Главная — тёмная капсула со светящимся краем, она одна на экране. Второстепенная — тонкий контур. Третья — текст. */
.actions { display: flex; flex-direction: column; gap: 12px; }
.btn { appearance: none; position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 56px; padding: 0 16px; border: 0; border-radius: 100px; background: var(--night); color: #fff; box-shadow: inset 0 0 12px #ff0207, inset 0 1px 22px rgba(239, 67, 147, .9); font: 600 20px/1 var(--ext); font-feature-settings: "lnum", "pnum"; text-transform: lowercase; white-space: nowrap; cursor: pointer; transition: transform .16s var(--ease-out), opacity .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.btn.alt { background: rgba(5, 9, 21, .55); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .32); font: 400 17px/1 var(--ext); }
.btn.link { height: 44px; background: none; box-shadow: none; font: 400 16px/1 var(--ext); letter-spacing: .06em; color: var(--muted); }
/* Кнопка первого экрана: крупнее и ярче, с мягким ореолом. */
.btn.big { height: 64px; font-size: min(24px, 6cqi); box-shadow: inset 0 0 16px #ff0207, inset 0 1px 28px #ef4393, 0 0 32px rgba(255, 20, 70, .35); }
.cta { margin-top: 0; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn:not([disabled]):active { transform: scale(.97); }
.btn:focus-visible, .chip:focus-visible, .inline:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; }

/* ---------- форма клятвы ---------- */
/* Стеклянная плашка рисуется SVG по размеру поля: тонкий светящийся край, лёгкий розовый отсвет сверху. */
.glassbox { position: relative; }
.glassbox > svg.glass { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.field { margin-top: 24px; }
.scr-vow h1 { margin-top: 20px; }
.scr-vow .field { margin-top: 20px; }
.scr-vow .fgroup { margin-top: 14px; }
.scr-vow .consent { margin: 20px 0 12px; }
.field textarea { position: relative; display: block; width: 100%; min-height: calc(24px * 1.3 * 2 + 40px); border: 0; background: transparent; padding: 20px; margin: 0; resize: none; overflow: hidden; color: #fff; font: 400 24px/1.3 var(--txt); }
.field textarea::placeholder { color: rgba(255, 255, 255, .5); opacity: 1; }
.field textarea:focus { outline: none; }
.fgroup { margin-top: 24px; }
.fgroup > .err, .field + .err { margin-top: 8px; }
/* Сроки — капсулы в ряд от левого края. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { appearance: none; position: relative; height: 36px; border: 0; padding: 0 14px; border-radius: 100px; background: rgba(13, 15, 29, .6); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 92, 150, .55); font: 400 14px/1 var(--txt); cursor: pointer; transition: box-shadow .2s var(--ease-out), background-color .2s var(--ease-out), transform .16s var(--ease-out); }
.chip::after { content: ""; position: absolute; inset: -4px -2px; }
/* Видимая высота 36 px, нажимается 44 px. */
.chip.on { background: #0b0d18; box-shadow: inset 0 0 0 1px #ff3b6b, inset 0 0 12px #ff0207, inset 0 0 22px rgba(251, 3, 136, .9); }
.chip:active { transform: scale(.95); }
.hint { display: block; margin-top: 8px; font: 400 14px/1.3 var(--txt); color: var(--muted); }
.hint:empty { display: none; }
/* Имя на договоре: подпись над полем, тонкая градиентная линия. */
.sign-row { display: flex; align-items: baseline; gap: 16px; padding-bottom: 8px; border-bottom: 1px solid transparent; border-image: var(--grad) 1; }
.sign label { flex: none; font: 400 14px/1.3 var(--txt); color: var(--muted); }
.sign input { display: block; flex: 1; min-width: 0; margin: 0; padding: 0; border: 0; background: transparent; text-align: right; color: #fff; font: 600 24px/1.2 var(--ext); -webkit-appearance: none; border-radius: 0; }
.sign input:focus { outline: none; }
.stage[hidden] { display: none; }
.stage.in { animation: ko-reveal .36s var(--ease-out); }
@keyframes ko-reveal { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.err { margin: 0; color: var(--err); font: 400 14px/1.3 var(--txt); }
.err.on-dark { margin-top: 16px; }
.consent { margin: 24px 0 16px; font: 400 14px/1.4 var(--txt); color: var(--muted); }
.inline { appearance: none; border: 0; background: none; padding: 0; font: inherit; color: #fff; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, .45); text-underline-offset: 3px; cursor: pointer; }

/* Чужая клятва: одна стеклянная плашка, срок мельче текста клятвы. */
.oath { margin-top: 24px; }
.oath .o-in { position: relative; padding: 20px; }
.oath .o-text { font: 400 24px/1.3 var(--txt); overflow-wrap: anywhere; }
.oath .o-term { margin-top: 12px; font: 400 14px/1.3 var(--txt); color: var(--muted); }

/* ---------- превью договора ---------- */
/* Та же картинка, что уходит в чат. Тёмная рамка картинки срезается, остаётся лист с вырубками.
   --mw уменьшает превью, если экран не помещается по высоте. */
.art { position: relative; display: flex; justify-content: center; padding: 24px 0 16px; }
.preview { --mw: 100%; position: relative; width: min(var(--mw), 100%); filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .45)); }
.preview.mini { --mw: min(300px, 80cqi); transform: rotate(-3deg); }
.preview canvas { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; clip-path: inset(2.22% round 2.6%); opacity: 0; transition: opacity .3s ease; }
.preview canvas.ready { opacity: 1; }
/* Печать: оттиск падает и вдавливается, договор вздрагивает, затем стекает кровь. */
.seal { position: absolute; pointer-events: none; }
.seal canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.seal .ring { transform-origin: 50% 33.3%; opacity: 0; transform: scale(1.7) rotate(-10deg); }
.seal .drips { clip-path: inset(0 0 100% 0); }
.seal.go .ring { animation: ko-seal .52s var(--ease-out) .25s forwards; }
.seal.go .drips { animation: ko-drip 1.1s cubic-bezier(.5, 0, .75, 0) .8s forwards; }
@keyframes ko-seal { 0% { opacity: 0; transform: scale(1.7) rotate(-10deg); } 55% { opacity: 1; transform: scale(.93) rotate(0); } 100% { opacity: 1; transform: none; } }
@keyframes ko-drip { to { clip-path: inset(0 0 0 0); } }
.preview.thud { animation: ko-thud .3s var(--ease-out) .53s; }
.preview.mini.thud { animation-name: ko-thud-mini; }
@keyframes ko-thud { 40% { transform: scale(.985); } }
@keyframes ko-thud-mini { 40% { transform: rotate(-3deg) scale(.985); } }

/* ---------- нижняя панель ---------- */
/* Закреплена снизу: кнопки видны всегда, содержимое прокручивается под ней. */
.dock { position: sticky; bottom: 0; z-index: 2; margin: 0 calc(-1 * var(--pad)) calc(-1 * (var(--tag-h) + env(safe-area-inset-bottom, 0px))); padding: 24px var(--pad) calc(var(--tag-h) + env(safe-area-inset-bottom, 0px)); background: var(--sheet); border-radius: 30px 30px 0 0; }
.foot { margin-top: auto; }
/* На экране договора панель идёт в потоке: печать на договоре — главный момент, она не прячется под панелью. */
.dock.flow { position: relative; }
.scr-binv h1 { margin-top: 24px; }
.scr-binv .oath { margin-top: 20px; }
/* Клятва напарника: стеклянная табличка с ярлыком сверху. Текст широким шрифтом по центру, срок — как выбранный чип. */
.oath.tabbed { padding-top: 46px; }
.oath .o-tab { position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 1; height: 36px; padding: 0 18px; display: flex; align-items: center; white-space: nowrap; font: 400 15px/1 var(--ext); color: rgba(255, 250, 251, .86); }
.oath.tabbed .o-in { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px 18px 16px; text-align: center; }
.scr-binv .oath.tabbed .o-text { font: 600 22px/1.25 var(--ext); text-wrap: balance; }
.oath .o-term { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 100px; background: #0b0d18; box-shadow: inset 0 0 0 1px #ff3b6b, inset 0 0 12px #ff0207, inset 0 0 22px rgba(251, 3, 136, .9); font: 400 14px/1 var(--txt); color: #fff; margin: 0; }
.scr-binv .bar { padding-top: 20px; }
.scr-binv .oath .o-text { font-size: 20px; }
.scr-binv .lead { font-size: 16px; line-height: 1.35; }
/* Экран договора плотнее остальных, чтобы договор, текст и все три кнопки поместились в один экран. */
.scr-pact h1 { margin-top: 24px; }
.scr-pact .lead { font-size: 16px; margin-top: 12px; }
.scr-pact .art { padding: 16px 0 12px; }
.scr-pact .grow { min-height: 0; }
.scr-pact .dock { padding-top: 20px; }
/* Экраны с приглашением: договор во всю ширину экрана, без боковых полей. */
.art.big { flex: 1 1 0; min-height: 0; align-items: flex-start; overflow: hidden; margin: 0 calc(-1 * var(--pad) + 8px); padding: 18px 0 0; }
/* На экранах с крупным договором текст сверху чуть плотнее, чтобы договору досталось больше места. */
.scr-invite h1, .scr-wait h1 { margin-top: 24px; }
.scr-invite .dock, .scr-wait .dock { padding-top: 16px; }
.no-tag .tag { display: none; }
.no-tag .scr-invite, .no-tag .scr-wait, .no-tag .scr-pact { --tag-h: 16px; }
.skip { align-self: flex-end; height: 32px; margin: -4px -8px -12px 0; padding: 0 8px; border: 0; background: none; color: var(--muted); font: 400 16px/1 var(--ext); cursor: pointer; }
.skip:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 8px; }
.scr-pact .steps { margin-top: 10px; }
.lead.ask { margin-top: 20px; }
.lead.ask b { display: block; margin-bottom: 6px; font: 600 20px/1.25 var(--ext); }
.art.big:not(.small) .preview { width: 100%; }
.art.big.cut { -webkit-mask-image: linear-gradient(#000 calc(100% - 56px), transparent); mask-image: linear-gradient(#000 calc(100% - 56px), transparent); }
.art.big.small { flex: none; overflow: visible; margin: 0; padding: 24px 0 16px; justify-content: center; }
/* Последний экран: две тихие ссылки в одну строку под кнопками. */
.links { display: flex; justify-content: space-between; gap: 8px; margin-top: -2px; }
.links .btn.link { width: auto; flex: 1; padding: 0 4px; }
.scr-thanks h1.hero { margin-top: 24px; }
.scr-thanks .blood { margin: 20px 0 0; }
.scr-thanks .blood + .blood { margin-top: 12px; }
.scr-pact .blood { font-size: 16px; line-height: 1.35; margin-bottom: 16px; }
.scr-pact .actions { gap: 10px; }
.scr-pact .btn.link { height: 36px; }
/* Кнопки экранов без панели тоже закреплены снизу; текст уходит под них в затухание. */
.bar { position: sticky; bottom: 0; z-index: 2; margin: 0 calc(-1 * var(--pad)) calc(-1 * (var(--tag-h) + env(safe-area-inset-bottom, 0px))); padding: 32px var(--pad) calc(var(--tag-h) + env(safe-area-inset-bottom, 0px)); background: linear-gradient(0deg, rgba(5, 9, 21, .35) 0, rgba(5, 9, 21, .92) 90px, rgba(5, 9, 21, .92) 60%, rgba(5, 9, 21, 0)); }
/* Затухание под хэштегом: прокрученный текст не налезает на него. */
.fade { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; height: 0; background: none; pointer-events: none; }

/* ---------- экраны ---------- */
.scr-start .pad { padding-top: 0; }
.scr-start h1 { margin-top: 0; }
.scr-start .lead { font-size: 16px; }
.blood { margin: 0 0 24px; font: 400 18px/1.4 var(--txt); }
.thanks-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; font: 400 20px/1.3 var(--txt); }
.heart { display: block; width: 62px; height: auto; flex: none; animation: ko-beat 2.8s ease-in-out .6s 2; }
@keyframes ko-beat { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.08); } 28% { transform: scale(.98); } 42% { transform: scale(1.05); } }

.toast { position: absolute; left: 16px; right: 16px; bottom: calc(56px + env(safe-area-inset-bottom, 0px)); z-index: 5; background: rgba(255, 255, 255, .96); color: var(--ink); padding: 12px 16px; border-radius: 16px; font: 400 16px/1.3 var(--txt); }

@media (prefers-reduced-motion: reduce) {
  .glow i, .heart, .stage.in, .scr, .scr.back { animation: none; }
  .btn, .chip { transition: none; }
  .btn:active, .chip:active { transform: none; }
  .seal .ring { transform: none; }
  .seal .drips { clip-path: none; opacity: 0; }
  .seal.go .ring, .seal.go .drips { animation: ko-fade .3s ease .1s forwards; }
  .preview.thud { animation: none; }
}
@keyframes ko-fade { from { opacity: 0; } to { opacity: 1; } }
/* «Расскажите о клятве»: заголовок в одну строку и плотнее отступы — всё освободившееся место уходит договору. */
.scr-pact h1 { margin-top: 16px; font-size: min(32px, 7.3cqi); white-space: nowrap; }
.scr-pact .art.big { padding-top: 14px; }
.scr-pact .dock { padding-top: 14px; }
