/* Мини-приложение «Друг по вере». Один экран на всю высоту окна Telegram; темы переключаются переменными
   (палитра — app.js) и атрибутом data-style на корне (бумага, сгибы, карандаш). */
:root {
  --page: #E6E7EE;
  --app: #F7F6F9;
  --surface: #FFFFFF;
  --ink: #20212B;
  --muted: #6C6E7E;
  --line: #E4E2EA;
  --accent: #74406C;
  --accent-ink: #FFFFFF;
  --night: #1E1B3A;
  --soft: #F2E7EF;
  --soft-ink: #5D3157;
  --sage: #3C7560;
  --sage-soft: #E3F0EA;
  --warn: #9A4E26;
  --warn-soft: #FBEDE4;
  --chat: #D9E3EA;
  --bubble-in: #FFFFFF;
  --bubble-out: #EADCE6;
  --shadow: 0 1px 2px rgba(32, 33, 43, .06), 0 8px 24px rgba(32, 33, 43, .06);
  --display: "Commissioner", "Segoe UI", system-ui, sans-serif;
  --body: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --r: 16px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --page: #0C0D11; --app: #14151B; --surface: #1D1F27; --ink: #ECECF1; --muted: #9B9DAD; --line: #2B2D38;
  --accent: #D49AC8; --accent-ink: #2A1026; --soft: #3A2537; --soft-ink: #F0D3E9; --sage: #86C7AB; --sage-soft: #1E3029;
  --warn: #E8A57F; --warn-soft: #3A2A20; --chat: #11161C; --bubble-in: #1F2530; --bubble-out: #4A2F46;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
} }
:root[data-theme="dark"] {
  --page: #0C0D11; --app: #14151B; --surface: #1D1F27; --ink: #ECECF1; --muted: #9B9DAD; --line: #2B2D38;
  --accent: #D49AC8; --accent-ink: #2A1026; --soft: #3A2537; --soft-ink: #F0D3E9; --sage: #86C7AB; --sage-soft: #1E3029;
  --warn: #E8A57F; --warn-soft: #3A2A20; --chat: #11161C; --bubble-in: #1F2530; --bubble-out: #4A2F46;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--app); color: var(--ink); font: 15px/1.45 var(--body); overflow: hidden; }
#phone { position: relative; height: 100%; max-width: 560px; margin: 0 auto; background-color: var(--app); display: flex; flex-direction: column; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; }


/* ---- общий вид ---- */
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.top { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.top h2 { font-size: 17px; font-weight: 600; flex: 1; min-width: 0; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; font-size: 20px; color: var(--muted); }
.icon-btn:hover { background: var(--soft); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.btn { border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 600; background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn[disabled] { opacity: .4; cursor: default; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.soft { background: var(--soft); color: var(--soft-ink); }
.btn.danger { background: var(--warn-soft); color: var(--warn); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.bar { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.note { background: var(--soft); color: var(--soft-ink); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.ok { background: var(--sage-soft); color: var(--sage); }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 4px 0; text-align: left; }

/* ---- анкета ---- */
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .25s; }
.field { display: flex; flex-direction: column; gap: 6px; }
.input { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; width: 100%; }
textarea.input { min-height: 84px; resize: vertical; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 13px 14px; }
.choice .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; }
.choice.on { border-color: var(--accent); }
.choice.on .dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--surface); }
.choice.box .dot { border-radius: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 13px; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tag { border-radius: 999px; padding: 4px 10px; font-size: 13px; background: var(--soft); color: var(--soft-ink); }
.tag.plain { background: var(--app); color: var(--muted); border: 1px solid var(--line); }
.prompt { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.prompt.on { border-color: var(--accent); }
.prompt-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: none; border: 0; padding: 0; text-align: left; font-weight: 600; width: 100%; }
.err { color: var(--warn); font-size: 13px; }
.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-pick img, .photo-empty { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--soft); display: grid; place-items: center; color: var(--soft-ink); font-size: 26px; flex: none; }

/* ---- карточки ---- */
.ava { border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--display); font-weight: 600; flex: none; }
.card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.who { display: flex; align-items: center; gap: 12px; }
.who h3 { font-size: 20px; font-weight: 600; }
.answer { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.answer p { margin: 0; font-size: 16px; }
.answer button { align-self: flex-start; }
.incoming { background: var(--sage-soft); color: var(--sage); border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.incoming q { display: block; color: var(--ink); margin-top: 4px; quotes: "«" "»"; }
.counts { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.counts b { color: var(--ink); font-variant-numeric: tabular-nums; }
.actions { display: grid; grid-template-columns: 1fr auto 1.4fr; gap: 8px; }
.actions .btn { padding: 13px 10px; }

/* ---- нижние вкладки ---- */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: var(--surface); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tab { border: 0; background: none; padding: 9px 0 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--accent); font-weight: 600; }
.badge { position: absolute; top: 5px; left: calc(50% + 6px); background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; min-width: 18px; padding: 0 5px; line-height: 18px; }

/* ---- список знакомств ---- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; border: 0; background: none; text-align: left; }
.item + .item { border-top: 1px solid var(--line); }
.item .txt { flex: 1; min-width: 0; }
.item .txt div:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--soft); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.request { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.request + .request { border-top: 1px solid var(--line); }

/* ---- чат ---- */
.chat { flex: 1; min-height: 0; overflow-y: auto; background: var(--chat); padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 16px; background: var(--bubble-in); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.msg.me { align-self: flex-end; background: var(--bubble-out); }
.msg time { display: block; font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.sys { align-self: center; background: var(--surface); border-radius: 16px; padding: 12px 14px; font-size: 14px; max-width: 94%; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.sys ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.composer { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 18px; padding: 9px 14px; resize: none; background: var(--app); max-height: 120px; }
.send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 18px; flex: none; }
.composer-err { padding: 8px 14px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }

/* ---- чат с ботом (вид Telegram) ---- */

/* ---- шторки, совпадение, подсказки ---- */
.shade { position: absolute; inset: 0; background: rgba(15, 15, 22, .45); display: flex; align-items: flex-end; z-index: 5; }
.sheet { background: var(--surface); width: 100%; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; max-height: 88%; overflow-y: auto; }
.sheet h3 { font-size: 18px; font-weight: 600; }
.quote { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; font-size: 14px; }
.quote .label { margin-bottom: 2px; }
.match { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 18px; padding: 24px 20px; }
.pairava { display: flex; }
.pairava .ava + .ava { margin-left: -16px; box-shadow: 0 0 0 4px var(--app); }
.match h1 { font-size: 26px; font-weight: 700; }
.toast { position: absolute; left: 16px; right: 16px; bottom: 78px; background: var(--ink); color: var(--app); padding: 11px 14px; border-radius: 12px; font-size: 14px; z-index: 6; }
.menu { position: absolute; inset: 0; background: rgba(15, 15, 22, .45); z-index: 7; display: flex; align-items: flex-start; justify-content: center; padding-top: 12px; }
.menu .sheet { border-radius: 20px; width: calc(100% - 24px); max-height: calc(100% - 24px); }
.menu .item { border-radius: 12px; }
.menu .item:hover { background: var(--soft); }
.switch { width: 44px; height: 26px; border-radius: 999px; background: var(--line); border: 0; position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); transition: left .2s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 21px; }
.invite { display: flex; gap: 8px; align-items: center; }
.invite code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; background: var(--app); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 13px; }
.invite button { flex: none; width: auto; }
/* ---- два огонька: загрузка и приветствие ---- */
.lights { position: relative; width: 180px; height: 120px; margin: 0 auto; }
.lights i { position: absolute; top: 50%; width: 26px; height: 26px; margin-top: -13px; border-radius: 50%;
  background: radial-gradient(circle, #fff6e0 0%, #f6c66b 45%, rgba(246, 198, 107, 0) 72%); filter: blur(.3px); }
.lights i:nth-child(1) { left: 10px; animation: meetL 2.4s cubic-bezier(.5, 0, .3, 1) forwards; }
.lights i:nth-child(2) { right: 10px; animation: meetR 2.4s cubic-bezier(.5, 0, .3, 1) forwards; }
.lights b { position: absolute; left: 50%; top: 50%; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 233, 180, .95) 0%, rgba(246, 190, 110, .55) 28%, rgba(214, 140, 180, .18) 55%, rgba(214, 140, 180, 0) 70%);
  opacity: 0; transform: scale(.3); animation: glow 2.4s ease-out forwards; }
.lights.loop i:nth-child(1) { animation: meetL 2.2s cubic-bezier(.5, 0, .3, 1) infinite; }
.lights.loop i:nth-child(2) { animation: meetR 2.2s cubic-bezier(.5, 0, .3, 1) infinite; }
.lights.loop b { animation: glowLoop 2.2s ease-out infinite; }
@keyframes meetL { 0% { transform: translateX(0); opacity: .3; } 20% { opacity: 1; } 70%, 100% { transform: translateX(67px); opacity: 0; } }
@keyframes meetR { 0% { transform: translateX(0); opacity: .3; } 20% { opacity: 1; } 70%, 100% { transform: translateX(-67px); opacity: 0; } }
@keyframes glow { 0%, 55% { opacity: 0; transform: scale(.3); } 80% { opacity: 1; transform: scale(1.05); } 100% { opacity: .9; transform: scale(1); } }
@keyframes glowLoop { 0%, 55% { opacity: 0; transform: scale(.3); } 75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.15); } }
.welcome { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 28px 22px calc(22px + env(safe-area-inset-bottom, 0px));
  background: radial-gradient(120% 70% at 50% 18%, var(--soft) 0%, var(--app) 62%); }
.welcome h1 { font-size: 32px; line-height: 1.12; font-weight: 700; opacity: 0; animation: rise .7s 1.6s ease-out forwards; }
.welcome p { margin: 0; color: var(--muted); font-size: 16px; opacity: 0; animation: rise .7s 1.85s ease-out forwards; }
.welcome .go { display: flex; flex-direction: column; gap: 10px; align-items: center; opacity: 0; animation: rise .7s 2.1s ease-out forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: var(--app); }
.loading .name { font-family: var(--display); font-weight: 600; font-size: 18px; }
.sug { display: flex; flex-wrap: wrap; gap: 6px; }
.sug button { border: 0; background: var(--soft); color: var(--soft-ink); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.city-list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.city-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 14px; }
.city-list button + button { border-top: 1px solid var(--line); }
.city-list button:hover { background: var(--soft); }
.blog { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--app); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 8px 6px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
/* ---- стиль «Оригами»: бумага, сгибы, загнутые уголки ---- */
[data-style="origami"] #phone { background-image: linear-gradient(135deg, transparent 49.85%, rgba(0, 0, 0, .035) 50%, transparent 50.15%), linear-gradient(45deg, transparent 49.85%, rgba(0, 0, 0, .025) 50%, transparent 50.15%); }
[data-style="origami"] .card, [data-style="origami"] .list, [data-style="origami"] .choice, [data-style="origami"] .prompt,
[data-style="origami"] .note, [data-style="origami"] .input, [data-style="origami"] .blog { border-radius: 3px; box-shadow: 2px 2px 0 rgba(0, 0, 0, .06); }
[data-style="origami"] .card { position: relative; }
[data-style="origami"] .card::after { content: ""; position: absolute; top: -1px; right: -1px; width: 26px; height: 26px;
  background: linear-gradient(225deg, var(--app) 50%, color-mix(in srgb, var(--accent) 22%, var(--surface)) 50%); box-shadow: -2px 2px 2px rgba(0, 0, 0, .06); }
[data-style="origami"] .btn { border-radius: 3px; }
[data-style="origami"] .btn:not(.ghost):not(.soft):not(.danger) { background: linear-gradient(135deg, var(--accent) 0 50%, color-mix(in srgb, var(--accent) 82%, #000) 50% 100%); }
[data-style="origami"] .chip, [data-style="origami"] .tag { border-radius: 3px; }
[data-style="origami"] .chip.on { background: linear-gradient(135deg, var(--accent) 0 50%, color-mix(in srgb, var(--accent) 82%, #000) 50% 100%); }
[data-style="origami"] .ava { border-radius: 3px; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%); }
[data-style="origami"] .msg { border-radius: 3px; }
/* ---- стиль «Ватман и карандаш»: зерно бумаги, графитовые линии, рукописные заголовки ---- */
[data-style="pencil"] #phone { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
[data-style="pencil"] h1, [data-style="pencil"] h2, [data-style="pencil"] h3, [data-style="pencil"] .loading .name { font-family: "Caveat", "Segoe Print", cursive !important; font-weight: 700; }
[data-style="pencil"] h1 { font-size: 36px !important; line-height: 1.05; }
[data-style="pencil"] h2 { font-size: 26px !important; }
[data-style="pencil"] h3 { font-size: 26px !important; }
[data-style="pencil"] .card, [data-style="pencil"] .list, [data-style="pencil"] .choice, [data-style="pencil"] .prompt, [data-style="pencil"] .input,
[data-style="pencil"] .chip, [data-style="pencil"] .btn, [data-style="pencil"] .note, [data-style="pencil"] .blog, [data-style="pencil"] .tag, [data-style="pencil"] .seg {
  border: 1.5px solid color-mix(in srgb, var(--ink) 70%, transparent) !important; border-radius: 255px 14px 225px 14px / 14px 225px 14px 255px !important; box-shadow: none !important; }
[data-style="pencil"] .btn:not(.ghost):not(.soft):not(.danger), [data-style="pencil"] .chip.on, [data-style="pencil"] .send {
  background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--ink) 22%, transparent) 0 1.5px, transparent 1.5px 6px), var(--surface); color: var(--ink); }
[data-style="pencil"] .choice.on .dot { background: var(--ink); border-color: var(--ink); }
[data-style="pencil"] .msg, [data-style="pencil"] .sys { border: 1.2px solid color-mix(in srgb, var(--ink) 55%, transparent); box-shadow: none; }
[data-style="pencil"] .tabs, [data-style="pencil"] .top, [data-style="pencil"] .bar, [data-style="pencil"] .composer { border-color: color-mix(in srgb, var(--ink) 50%, transparent); }
[data-style="pencil"] .progress i { background: repeating-linear-gradient(-45deg, var(--ink) 0 2px, transparent 2px 4px); }
/* ---- бумажные анимации карточки ---- */
.card.fly-away { animation: flyAway .55s cubic-bezier(.4, 0, .9, .6) forwards; }
@keyframes flyAway { 30% { transform: translate(-8%, -6px) rotate(-5deg); } 100% { transform: translate(-135%, -60px) rotate(-32deg); opacity: 0; } }
.card.fold { animation: fold .6s ease-in forwards; transform-origin: 50% 45%; }
@keyframes fold {
  0% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
  45% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); transform: scale(.55) rotate(-4deg); }
  100% { clip-path: polygon(0 52%, 100% 8%, 58% 100%, 46% 62%); transform: scale(.22) rotate(-18deg); opacity: .9; } }
.plane { position: absolute; left: calc(50% - 34px); top: 42%; width: 68px; z-index: 8; opacity: 0; pointer-events: none; animation: planeFly 1.1s .55s ease-in forwards; }
@keyframes planeFly { 0% { opacity: 1; transform: translate(0, 0) rotate(-8deg) scale(.9); } 100% { opacity: 0; transform: translate(240px, -360px) rotate(-24deg) scale(.55); } }
@media (prefers-reduced-motion: reduce) { .card.fly-away, .card.fold, .plane { animation-duration: .01s !important; animation-delay: 0s !important; } }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .lights i { animation: none !important; opacity: 0; }
  .lights b, .welcome h1, .welcome p, .welcome .go { animation: none !important; opacity: 1; transform: none; }
}
