:root {
  --bg: #FBEDEB;
  --card: #FFFFFF;
  --ink: #3B2430;
  --muted: #7A5B67;
  --accent: #A8325E;
  --accent-ink: #842447;
  --accent-soft: #F7DCE2;
  --rose: #F2C6CF;
  --line: #F3D9DE;
  --field: #EBCBD2;
  --danger: #A3291B;
  --serif: 'Playfair Display', Georgia, serif;
  --sans: Manrope, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.splash { flex: 1; display: flex; align-items: center; justify-content: center; }
.splash svg { animation: breathe 1.6s ease-in-out infinite; }

/* ---------- экраны входа и онбординга ---------- */
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: calc(56px + var(--safe-top)) 24px calc(28px + var(--safe-bottom)); }
.screen.compact { padding-top: calc(20px + var(--safe-top)); }
.title { margin: 0; font-family: var(--serif); font-size: 44px; font-weight: 600; letter-spacing: -.01em; }
.h2 { margin: 0; font-family: var(--serif); font-size: 31px; line-height: 1.15; font-weight: 600; }
.lead { margin: 0; font-size: 16px; line-height: 1.5; color: var(--muted); }
.small { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.center { text-align: center; }
.spacer { flex: 1; }
.label { font-size: 13px; font-weight: 700; color: var(--muted); }
.input { height: 52px; width: 100%; border: 1px solid var(--field); border-radius: 16px; padding: 0 16px; font-size: 17px; background: var(--card); }
.input.code { height: 64px; font-size: 30px; letter-spacing: .4em; text-align: center; }
.textarea { width: 100%; min-height: 132px; border: 1px solid var(--field); border-radius: 18px; padding: 14px 16px; font-size: 16px; line-height: 1.45; resize: none; background: var(--card); }
.btn { height: 54px; width: 100%; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 700; }
.btn:not(:disabled):active { transform: scale(.98); }
.btn.secondary { background: var(--card); color: var(--accent); }
.btn.danger { background: var(--danger); }
.btn-text { height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 15px; font-weight: 600; }
.icon-btn { width: 44px; height: 44px; margin-left: -10px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; align-self: flex-start; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.45; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.link-box { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 18px; background: var(--card); word-break: break-all; }
.link-box b { font-size: 12px; color: var(--muted); }
.ok-line { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 700; color: var(--accent-ink); }
.waiting { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; animation: pulse 1.6s ease-in-out infinite; }
.error { padding: 12px 14px; border-radius: 14px; background: #FDE2E0; color: var(--danger); font-size: 14px; font-weight: 600; }

/* ---------- приложение ---------- */
.content { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: calc(24px + var(--safe-top)) 20px 20px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatars { display: flex; flex-shrink: 0; }
.av { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; border: 2px solid var(--bg); }
.av.me { background: var(--rose); color: var(--accent-ink); }
.av.them { background: var(--accent); color: #fff; margin-left: -10px; }
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-text b { font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text span { font-size: 13px; color: var(--muted); }
.streak { display: flex; align-items: center; gap: 5px; padding: 8px 13px; border-radius: 999px; background: var(--card); color: var(--accent); font-size: 15px; font-weight: 800; flex-shrink: 0; }

.q-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 24px 22px; border-radius: 28px; background: var(--card); overflow: hidden; }
.q-card .bg-heart { position: absolute; right: -50px; bottom: -64px; color: var(--accent-soft); }
.q-label { position: relative; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.q-text { position: relative; margin: 0; font-family: var(--serif); font-size: 24px; line-height: 1.28; font-weight: 500; }

.notice { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--card); color: var(--accent-ink); font-size: 15px; font-weight: 700; }
.answer-form { display: flex; flex-direction: column; gap: 10px; }

.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; gap: 4px; max-width: 88%; }
.msg.left { align-self: flex-start; }
.msg.right { align-self: flex-end; align-items: flex-end; }
.msg .name { padding: 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.bubble { padding: 14px 16px; font-size: 16px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.left .bubble { border-radius: 22px 22px 22px 6px; background: var(--card); }
.msg.right .bubble { border-radius: 22px 22px 6px 22px; background: var(--accent); color: #fff; }
.locked { position: relative; width: 100%; min-height: 96px; border-radius: 22px 22px 22px 6px; background: var(--card); border: 1.5px dashed #E2B9C4; overflow: hidden; }
.locked .blur { padding: 16px; filter: blur(7px); user-select: none; color: var(--muted); }
.locked .over { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 3px; align-items: center; justify-content: center; text-align: center; padding: 10px; color: var(--accent); }
.locked .over b { font-size: 14px; color: var(--ink); }
.locked .over span { font-size: 12px; color: var(--muted); }
.msg.left.wide { width: 88%; }

.next { align-self: center; margin-top: 6px; padding: 9px 16px; border-radius: 999px; background: var(--accent-soft); font-size: 14px; font-weight: 600; color: #6B3A4E; text-align: center; }

.banner { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 20px; background: var(--accent); color: #fff; }
.banner p { margin: 0; display: flex; gap: 10px; font-size: 15px; line-height: 1.4; font-weight: 600; }
.banner .row { display: flex; gap: 8px; }
.banner button { height: 40px; padding: 0 16px; border: 0; border-radius: 999px; font-size: 14px; font-weight: 700; }
.banner .yes { background: #fff; color: var(--accent-ink); }
.banner .no { background: transparent; color: var(--accent-soft); }

/* раскрытие ответов */
.burst { position: relative; height: 92px; display: flex; align-items: center; justify-content: center; }
.burst .av { width: 58px; height: 58px; font-size: 22px; border-width: 3px; }
.burst .av.them { margin-left: -14px; }
.burst .ring, .burst .h { display: none; }
.reveal-title { margin: -4px 0 0; text-align: center; font-family: var(--serif); font-style: italic; font-size: 22px; font-weight: 500; color: var(--accent-ink); }
.play .burst .ring { display: block; position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%; border: 2px solid var(--accent); animation: ring 1.1s .55s ease-out both; }
.play .burst .h { display: block; position: absolute; left: 50%; top: 50%; margin: -7px 0 0 -7px; animation: fly 1s .6s cubic-bezier(.2,.8,.2,1) both; }
.play .burst .av.me { animation: avL .9s cubic-bezier(.3,1.3,.5,1) both; }
.play .burst .av.them { animation: avR .9s cubic-bezier(.3,1.3,.5,1) both; }
.play .reveal-title { animation: fadein .5s .75s ease-out both; }
.play .msg.left { animation: unblur 1s 1.2s cubic-bezier(.2,.8,.2,1) both; }
.play .msg.right { animation: rise .6s .95s cubic-bezier(.2,.8,.2,1) both; }
.play .next { animation: fadein .5s 2s ease-out both; }

/* история */
.page-title { margin: 0; font-family: var(--serif); font-size: 30px; font-weight: 600; }
.hist { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 22px; background: var(--card); }
.hist.dim { background: #F7E9EA; }
.hist .date { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hist .q { font-family: var(--serif); font-size: 18px; line-height: 1.3; }
.hist .a { display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.hist .note { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.empty { padding: 40px 12px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.5; }

/* настройки */
.group { display: flex; flex-direction: column; gap: 8px; }
.group-title { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.list { display: flex; flex-direction: column; border-radius: 20px; background: var(--card); overflow: hidden; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 54px; padding: 8px 16px; font-size: 16px; border-bottom: 1px solid #F7E4E8; }
.row:last-child, .row:has(+ .status) { border-bottom: 0; }
.row > span:first-child { flex-shrink: 0; }
.row select { max-width: 62%; }
.row input, .row select { border: 0; background: transparent; color: var(--muted); font-size: 16px; text-align: right; min-width: 0; }
.row input[type=text] { width: 55%; }
.row .sub { display: flex; flex-direction: column; gap: 2px; }
.row .sub span { font-size: 13px; color: var(--muted); }
.row-btn { width: 100%; min-height: 54px; padding: 0 16px; border: 0; border-bottom: 1px solid #F7E4E8; background: transparent; text-align: left; font-size: 16px; color: var(--ink); text-decoration: none; display: flex; align-items: center; }
.row-btn:last-child { border-bottom: 0; }
.row-btn.danger { color: var(--danger); }
.toggle { width: 52px; height: 32px; flex-shrink: 0; border: 0; border-radius: 999px; padding: 3px; display: flex; background: #E3CDD3; transition: background .2s; }
.toggle::after { content: ''; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.toggle[aria-pressed=true] { background: var(--accent); }
.toggle[aria-pressed=true]::after { transform: translateX(20px); }
.status { font-size: 13px; line-height: 1.4; color: var(--muted); padding: 0 16px 14px; margin-top: -4px; }

/* нижнее меню */
.tabs { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 6px 16px calc(14px + var(--safe-bottom)); padding: 6px; border-radius: 26px; background: var(--card); box-shadow: 0 4px 18px rgba(132,36,71,.10); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 50px; border: 0; border-radius: 18px; background: transparent; font-size: 12px; font-weight: 800; color: #8A6B77; }
.tab[aria-current=page] { background: var(--bg); color: var(--accent); }

/* шторки */
.backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(40,20,30,.45); display: flex; flex-direction: column; justify-content: flex-end; animation: fadein .2s ease-out both; }
.sheet { width: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; padding: 24px 22px calc(28px + var(--safe-bottom)); border-radius: 28px 28px 0 0; background: var(--bg); animation: up .28s cubic-bezier(.2,.8,.2,1) both; }
.sheet h3 { margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); z-index: 20; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600; animation: fadein .2s ease-out both; }

/* ---------- страница политики ---------- */
.doc { max-width: 720px; margin: 0 auto; padding: 40px 20px 80px; font-size: 16px; line-height: 1.6; }
.doc h1 { font-family: var(--serif); font-size: 34px; line-height: 1.2; margin: 0 0 8px; }
.doc h2 { font-family: var(--serif); font-size: 22px; margin: 32px 0 8px; }
.doc .muted { color: var(--muted); }

@keyframes breathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes ring { 0% { transform: scale(.4); opacity: 0; } 30% { opacity: .6; } 100% { transform: scale(2.6); opacity: 0; } }
@keyframes fly { 0% { transform: translate(0, 0) scale(.3); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(var(--x), var(--y)) scale(1); opacity: 0; } }
@keyframes unblur { 0% { opacity: 0; filter: blur(12px); transform: translateY(10px); } 35% { opacity: 1; } 100% { opacity: 1; filter: blur(0); transform: none; } }
@keyframes avL { from { transform: translateX(-80px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes avR { from { transform: translateX(80px); opacity: 0; } to { transform: none; opacity: 1; } }

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