/* «Память»: крупный шрифт и крупные кнопки под аудиторию 45–75, палитра старого альбома. */
:root {
    --bg: #F6EFE3;
    --surface: #FFFBF4;
    --surface-2: #EFE5D4;
    --text: #2A2119;
    --muted: #6B5C4C;
    --line: #DDCDB5;
    --accent: #9C4A26;
    --accent-press: #7F3A1C;
    --accent-soft: #F3DDCF;
    --on-accent: #FFFFFF;
    --gold: #B7852F;
    --ok: #3F6B45;
    --danger: #A33A2E;
    --shadow: 0 2px 10px rgba(60, 40, 20, .10);
    --radius: 18px;
    --tap: 60px;
    --fs: 19px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-scheme="light"]) {
        --bg: #1C1814; --surface: #26201A; --surface-2: #322A22; --text: #F3EADC; --muted: #BFAF99;
        --line: #43382C; --accent: #E08A5E; --accent-press: #F0A07A; --accent-soft: #3D2A1F; --on-accent: #1C1814;
        --gold: #D9AE5C; --shadow: none; color-scheme: dark;
    }
}
:root[data-scheme="dark"] {
    --bg: #1C1814; --surface: #26201A; --surface-2: #322A22; --text: #F3EADC; --muted: #BFAF99;
    --line: #43382C; --accent: #E08A5E; --accent-press: #F0A07A; --accent-soft: #3D2A1F; --on-accent: #1C1814;
    --gold: #D9AE5C; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 400 var(--fs)/1.45 Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .84em; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.title-xl { font-size: 36px; line-height: 1.15; margin: 0 0 12px; font-weight: 700; letter-spacing: -.01em; }
.title-lg { font-size: 25px; line-height: 1.25; margin: 4px 0 16px; font-weight: 700; }
.title-md { font-size: 21px; margin: 24px 0 12px; font-weight: 700; }
.lead { font-size: 20px; margin: 0 0 16px; }
.note { background: var(--surface-2); border-radius: 14px; padding: 14px 16px; margin: 16px 0; }
.tip { color: var(--muted); margin: 12px 4px 0; }

/* ---------- экраны ---------- */
.screen { min-height: 100vh; padding: 24px 16px calc(24px + var(--safe-b)); }
.screen-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.logo-mark svg { width: 84px; height: 84px; color: var(--accent); stroke-width: 2.5; }
.onb-inner { max-width: 520px; margin: 0 auto; padding-top: 24px; display: flex; flex-direction: column; gap: 8px; }
.onb-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 12px; }
.onb-list li { display: flex; gap: 12px; align-items: flex-start; font-size: 20px; }
.onb-ico { color: var(--gold); font-size: 22px; line-height: 1.3; }

.check { display: flex; gap: 14px; align-items: flex-start; margin: 16px 0; font-size: 17px; }
.check input { width: 30px; height: 30px; flex: 0 0 30px; accent-color: var(--accent); margin: 0; }

/* ---------- кнопки ---------- */
.btn {
    display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
    min-height: var(--tap); padding: 12px 20px; border-radius: 16px; border: 2px solid transparent;
    font-weight: 700; font-size: 20px; text-align: center; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn-xl { min-height: 68px; font-size: 21px; width: 100%; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn-accent { background: var(--gold); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); font-weight: 500; }
.btn.is-loading { pointer-events: none; opacity: .7; }
.btn.is-loading::after {
    content: ""; width: 20px; height: 20px; border-radius: 50%;
    border: 3px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite;
}
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 8px 0; }

.input {
    width: 100%; min-height: var(--tap); padding: 14px 16px; border-radius: 14px;
    border: 2px solid var(--line); background: var(--surface); font-size: 20px; margin: 6px 0;
}
.input:focus { outline: none; border-color: var(--accent); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.4; }
.counter { text-align: right; color: var(--muted); font-size: 16px; }

/* ---------- каркас ---------- */
#app { min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--line); min-height: 64px;
}
.topbar-title { flex: 1; min-width: 0; font-weight: 700; font-size: 19px; padding-left: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-back { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; background: none; border: 0; min-height: 48px; padding: 0 4px 0 0; font-weight: 600; color: var(--accent); }
.topbar-back svg { width: 26px; height: 26px; stroke-width: 2.5; }
.balance-chip {
    border: 0; background: var(--accent-soft); color: var(--text); border-radius: 999px;
    padding: 10px 16px; font-weight: 700; font-size: 17px; min-height: 46px; white-space: nowrap; flex: 0 0 auto;
}
#views { padding: 16px 16px calc(110px + var(--safe-b)); max-width: 640px; margin: 0 auto; }

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: 0; padding: 10px 0 12px; min-height: 72px; color: var(--muted); font-size: 16px; font-weight: 600;
}
.tab svg { width: 30px; height: 30px; }
.tab.active { color: var(--accent); }

/* ---------- главная ---------- */
.free-banner {
    display: flex; gap: 12px; align-items: center; background: var(--accent-soft);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
}
.free-banner div { display: flex; flex-direction: column; }
.free-banner span { color: var(--muted); font-size: 16px; }
.modes { display: flex; flex-direction: column; gap: 14px; }
.mode-card {
    display: flex; gap: 16px; align-items: center; text-align: left; width: 100%;
    background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
    padding: 18px 16px; min-height: 108px; box-shadow: var(--shadow);
}
.mode-card:active { border-color: var(--accent); }
.mode-ico { flex: 0 0 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; }
.mode-ico svg { width: 38px; height: 38px; }
.ico-restore { background: #E7DCC8; color: #6B4A1E; }
.ico-color { background: #F1D9C7; color: #9C4A26; }
.ico-animate { background: #DDE6D3; color: #3F6B45; }
.ico-talk { background: #DCE1EC; color: #3B4F7A; }
.mode-text { display: flex; flex-direction: column; gap: 2px; }
.mode-text b { font-size: 22px; }
.mode-text span { color: var(--muted); font-size: 17px; line-height: 1.35; }
.row-between { display: flex; justify-content: space-between; align-items: center; }

/* ---------- фото и опции ---------- */
.photo-drop {
    position: relative; width: 100%; min-height: 260px; border-radius: var(--radius);
    border: 3px dashed var(--line); background: var(--surface); overflow: hidden;
    display: grid; place-items: center;
}
.photo-drop.has-photo { border-style: solid; border-color: var(--surface-2); min-height: 0; }
.photo-drop img { width: 100%; max-height: 60vh; object-fit: contain; display: block; background: var(--surface-2); }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 16px; color: var(--accent); text-align: center; }
.photo-empty svg { width: 64px; height: 64px; }
.photo-empty b { font-size: 23px; }
.photo-empty span { color: var(--muted); }
.photo-busy { position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-weight: 600; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.options { margin-top: 8px; }
details.options { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 4px 16px; margin-top: 20px; }
details.options summary { min-height: var(--tap); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.person-colors { padding-bottom: 12px; }
.person-colors label { display: block; font-weight: 600; margin-top: 8px; }

.choice-list { display: flex; flex-direction: column; gap: 10px; }
.choice {
    display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
    padding: 14px 16px; min-height: var(--tap); border-radius: 14px;
    border: 2px solid var(--line); background: var(--surface); font-size: 20px;
}
.choice .dot { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.selected .dot { border-color: var(--accent); }
.choice.selected .dot::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }
.choice .grow { flex: 1; }
.choice .play { border: 0; background: var(--surface-2); border-radius: 999px; min-width: 48px; min-height: 48px; display: grid; place-items: center; color: var(--accent); }
.choice .play svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip { border: 2px solid var(--line); background: var(--surface); border-radius: 999px; padding: 10px 16px; min-height: 48px; font-size: 17px; }

.actions { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }

/* ---------- прогресс ---------- */
.progress-card { text-align: center; padding-top: 8px; }
.progress-photo { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; background: var(--surface-2); }
.progress-photo img { width: 100%; max-height: 50vh; object-fit: contain; display: block; filter: saturate(.7); }
.scan {
    position: absolute; left: 0; right: 0; height: 30%; top: -30%;
    background: linear-gradient(180deg, transparent, rgba(255, 236, 200, .55), transparent);
    animation: scan 2.4s ease-in-out infinite;
}
@keyframes scan { to { top: 100%; } }
@media (prefers-reduced-motion: reduce) { .scan { animation: none; display: none; } }
.bar { height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0 16px; }
.bar-fill { height: 100%; width: 5%; background: var(--accent); border-radius: 999px; transition: width .6s ease; }

/* ---------- результат ---------- */
.compare { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); user-select: none; touch-action: pan-y; }
.compare > img { width: 100%; display: block; max-height: 65vh; object-fit: contain; }
.cmp-before-wrap { position: absolute; inset: 0; overflow: hidden; clip-path: inset(0 50% 0 0); }
.cmp-before-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cmp-handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; margin-left: -2px; background: #fff; pointer-events: none; box-shadow: 0 0 6px rgba(0,0,0,.4); }
.cmp-handle span { position: absolute; top: 50%; left: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.cmp-handle span::before { content: "‹ ›"; position: absolute; inset: 0; display: grid; place-items: center; color: #6B4A1E; font-weight: 700; font-size: 22px; }
.compare input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: ew-resize; }
.cmp-label { position: absolute; top: 12px; background: rgba(0,0,0,.55); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 16px; pointer-events: none; }
.cmp-label-l { left: 12px; }
.cmp-label-r { right: 12px; }
.result-video { width: 100%; max-height: 70vh; border-radius: var(--radius); background: #000; display: block; }

/* ---------- альбом ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 0; padding: 0; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; border-radius: 999px; padding: 4px 10px; font-size: 15px; }
.tile .state { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; font-weight: 600; text-align: center; padding: 8px; }
.empty { text-align: center; padding: 32px 8px; color: var(--muted); }
.recent { margin-top: 28px; }

/* ---------- баланс ---------- */
.balance-card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.balance-big { font-size: 48px; font-weight: 800; line-height: 1; margin-bottom: 8px; }
.balance-big small { font-size: 20px; font-weight: 600; margin-left: 8px; color: var(--muted); }
.pack-list { display: flex; flex-direction: column; gap: 12px; }
.pack {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 16px; min-height: 84px;
}
.pack .grow { flex: 1; display: flex; flex-direction: column; }
.pack .grow b { font-size: 21px; }
.pack .grow span { color: var(--muted); font-size: 16px; }
.pack .price { font-size: 22px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.pack.best { border-color: var(--gold); position: relative; }
.pack.best::before { content: "Выгодно"; position: absolute; top: -12px; right: 16px; background: var(--gold); color: #fff; font-size: 14px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.pack.is-loading { opacity: .6; pointer-events: none; }
.sub-card { border: 2px solid var(--accent); }
.legal-links { text-align: center; margin: 16px 0; color: var(--muted); }

/* ---------- модальные окна ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 12, 5, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
    width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--bg);
    border-radius: 24px 24px 0 0; padding: 24px 16px calc(20px + var(--safe-b));
    display: flex; flex-direction: column; gap: 10px;
}
.rec-box { display: flex; align-items: center; gap: 20px; justify-content: center; padding: 12px 0; }
.rec-btn { width: 88px; height: 88px; border-radius: 50%; border: 4px solid var(--danger); background: var(--surface); display: grid; place-items: center; }
.rec-btn span { width: 40px; height: 40px; border-radius: 50%; background: var(--danger); transition: all .2s; }
.rec-btn.recording span { width: 30px; height: 30px; border-radius: 6px; }
.rec-time { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 90px; }
#rec-audio { width: 100%; }

.toast {
    position: fixed; left: 16px; right: 16px; bottom: calc(92px + var(--safe-b)); z-index: 100;
    background: var(--text); color: var(--bg); padding: 16px 18px; border-radius: 16px; font-size: 18px;
    box-shadow: 0 6px 20px rgba(0,0,0,.25); text-align: center;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--ok); color: #fff; }
