/* Аудитория — люди 45+: крупный текст (не меньше 16px), кнопки от 52px, один вопрос на экран.
   Интерфейс спокойный и нейтральный, чтобы яркой была сама открытка; акцентный цвет — только
   у главного действия и у выбранного варианта. Отступы кратны 4px: 8 / 12 / 16 / 24. */
:root {
    --bg: #f7f3ee;
    --surface: #fff;
    --stage: #ebe5dd;
    --text: #221c19;
    --muted: #6b625c;
    --line: #e0d8cf;
    --field: #b9ada2;
    --accent: #c8324a;
    --accent-ink: #fff;
    --accent-soft: #fbe9ec;
    --radius: 16px;
    --gap: 12px;
    --side: 16px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #171413; --surface: #231f1d; --stage: #0f0d0c; --text: #f4efea; --muted: #b9afa8; --line: #3d3632; --field: #6b6058;
        --accent: #ff7182; --accent-ink: #1a1011; --accent-soft: #3a2226;
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 19px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
canvas, img { display: block; }

button {
    font: inherit; font-weight: 700; color: inherit; cursor: pointer; touch-action: manipulation;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 52px; padding: 12px 16px; border: 2px solid transparent; border-radius: 14px;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .5; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.ghost { background: none; color: var(--accent); }
.wide { width: 100%; }
/* иконки — свои, а не эмодзи: одинаково выглядят на любом телефоне */
.ico { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.big { width: 100%; font-size: 21px; min-height: 64px; }

/* ---------- главный экран ---------- */
.screen { max-width: 520px; margin: 0 auto; padding: 16px var(--side) calc(32px + env(safe-area-inset-bottom)); }
.top { text-align: center; padding: 12px 0 0; }
.top h1 { font-family: Lobster, cursive; font-weight: 400; font-size: 44px; line-height: 1.1; margin: 0; color: var(--accent); }
.top p { margin: 8px 0 0; color: var(--muted); }
h2 { font-size: 21px; line-height: 1.2; margin: 24px 0 12px; }

/* получатель открытки: сразу предлагаем ответить */
.reply { margin-top: 20px; padding: 16px; border-radius: var(--radius); background: var(--accent-soft); border: 2px solid var(--accent); text-align: center; }
.reply-kicker { margin: 0; font-size: 17px; font-weight: 700; color: var(--accent); }
.reply h2 { margin: 14px 0 12px; font-size: 22px; }
.reply-card { width: min(78%, 320px); aspect-ratio: 1; margin: 12px auto 0; border-radius: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .18); }
.reply .big + .big { margin-top: 10px; }
.reply .big { flex-direction: column; gap: 2px; line-height: 1.2; padding: 10px 16px; }
.reply .big small { font-size: 17px; font-weight: 600; opacity: .9; }

/* повод — строка: слева как выглядит открытка, справа название и дата */
.tiles { display: flex; flex-direction: column; gap: var(--gap); }
.tile {
    justify-content: flex-start; gap: 16px; width: 100%; padding: 8px 12px 8px 8px; text-align: left; line-height: 1.25;
    background: var(--surface); border-color: var(--line); border-radius: var(--radius); font-size: 21px;
}
.tile canvas { width: 88px; height: 88px; flex: none; border-radius: 10px; }
.tile .text { flex: 1; min-width: 0; }
.tile small { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; font-size: 16px; }
.tile .go { flex: none; color: var(--muted); font-size: 28px; font-weight: 400; line-height: 1; }
.tile.soon small { color: var(--accent); font-weight: 700; }
#show-all { margin-top: 24px; }
#later { margin-top: var(--gap); }

/* ---------- редактор: на весь видимый экран; шаги, открытка, вопрос, кнопки — одной ширины ---------- */
.editor {
    max-width: 520px; margin: 0 auto; height: var(--vvh, 100dvh); min-height: 500px;
    display: flex; flex-direction: column; gap: var(--gap);
    padding: calc(8px + env(safe-area-inset-top)) var(--side) calc(12px + env(safe-area-inset-bottom));
}

.steps { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); }
.steps button { position: relative; flex-direction: column; gap: 2px; min-height: 56px; padding: 4px 0; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.steps .n { position: relative; z-index: 1; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line); font-size: 15px; font-weight: 700; }
/* линия между кружками */
.steps button + button::before { content: ""; position: absolute; top: 18px; right: 50%; width: 100%; height: 2px; background: var(--line); }
.steps button.past::before, .steps button.on::before { background: var(--accent); }
.steps .past .n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.steps .on { color: var(--text); font-weight: 700; }
.steps .on .n { border-color: var(--accent); color: var(--accent); }

.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; background: var(--stage); border-radius: var(--radius); }
#card { max-width: 100%; max-height: 100%; width: auto; height: auto; border-radius: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, .18); }

.panel { flex: none; height: 236px; overflow: hidden; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; }
.step-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 21px; margin: 0 0 12px; }
.step-title small { font-weight: 400; color: var(--muted); font-size: 16px; white-space: nowrap; }

/* поле ввода должно выглядеть полем, а не кнопкой: белое, с тёмной рамкой и тенью внутрь */
input, textarea {
    display: block; width: 100%; font: inherit; color: var(--text); background: var(--surface);
    border: 2px solid var(--field); border-radius: 12px; padding: 12px 14px; margin: 0 0 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, .06);
}
input { height: 52px; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.field { position: relative; }
.field input, .field textarea { padding-right: 52px; }
.field .clear {
    position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; min-height: 0; padding: 0;
    border-radius: 50%; background: var(--line); color: var(--text);
}
.field .clear .ico { width: 20px; height: 20px; stroke-width: 2.5; }
input::placeholder { color: var(--muted); opacity: .8; }
textarea { resize: none; font-size: 18px; line-height: 1.3; padding: 10px 14px; }

/* горизонтальная лента: листается пальцем, следующий вариант виден краем */
.strip { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip > * { flex: none; scroll-snap-align: start; }
.strip + .strip { margin-top: 8px; }
/* сетка 2 колонки: все варианты сразу на экране, без прокрутки */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid2 .chip { min-height: 44px; padding: 4px 6px; font-size: 17px; white-space: normal; line-height: 1.15; text-align: center; }
.grid2 .chip.on:not(.emoji)::before { content: none; }
.grid2 .chip.emoji { font-size: 22px; letter-spacing: 2px; white-space: nowrap; }
.grid2 .shuffle { color: var(--accent); }
.grid2 .shuffle .ico { width: 20px; height: 20px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .chip { flex: none; justify-content: flex-start; white-space: normal; text-align: left; line-height: 1.2; min-height: 44px; padding: 6px 14px; }

/* картинки — в два ряда, листаются вбок; край следующих виден, по бокам круглые стрелки и затухание */
.scroller { position: relative; }
.strip.rows2 { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 76px); grid-auto-columns: 76px; gap: 8px; }
.rows2 .thumb { width: 76px; height: 76px; border-radius: 12px; }
.rows2 .thumb canvas { border-radius: 8px; }
.rows2 .thumb.photo { font-size: 14px; }
.scroller::before, .scroller::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40px; pointer-events: none; z-index: 1; transition: opacity .2s; }
.scroller::before { left: 0; background: linear-gradient(90deg, var(--surface), transparent); }
.scroller::after { right: 0; background: linear-gradient(-90deg, var(--surface), transparent); }
.scroller:not(.can-prev)::before, .scroller:not(.can-next)::after { opacity: 0; }
.arrow {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 44px; height: 44px; min-height: 0; padding: 0;
    border-radius: 50%; background: var(--surface); color: var(--text); border: 2px solid var(--line); box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.arrow:active { transform: translateY(-50%) scale(.94); }
.arrow.prev { left: -4px; }
.arrow.next { right: -4px; }
.arrow .ico { width: 24px; height: 24px; stroke-width: 2.5; }

.thumb { width: 92px; height: 92px; min-height: 0; padding: 0; border: 3px solid transparent; background: none; border-radius: 14px; overflow: hidden; }
.thumb.on { border-color: var(--accent); }
.thumb canvas { width: 100%; height: 100%; border-radius: 10px; }
.thumb.photo { flex-direction: column; gap: 2px; background: var(--bg); border: 2px dashed var(--muted); color: var(--muted); font-size: 16px; line-height: 1.15; font-weight: 600; }
.thumb.photo .ico { width: 30px; height: 30px; }

/* вариант выбора: выбранный — рамка и мягкая заливка, а не сплошной цвет, чтобы не спорить с главной кнопкой */
.chip { background: var(--bg); color: var(--text); border-color: var(--line); padding: 8px 16px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); }
.chip.on:not(.emoji)::before { content: "✓"; color: var(--accent); font-weight: 700; }
.chip.emoji { font-size: 24px; letter-spacing: 3px; }

.nav { flex: none; display: grid; grid-template-columns: 2fr 3fr; gap: var(--gap); }
.nav button { font-size: 21px; min-height: 60px; padding: 12px 8px; white-space: nowrap; }

/* клавиатура открыта: оставляем открытку, поле ввода и кнопки */
.editor.kb { min-height: 0; gap: 8px; }
.editor.kb .steps, .editor.kb .step-title, .editor.kb #next-wish { display: none; }
.editor.kb .panel { height: auto; }
.editor.kb .nav button { min-height: 52px; }

/* ---------- готово: колонка шириной с открытку, всё по одной линии ---------- */
.done { max-width: min(420px, 46dvh + 2 * var(--side)); min-width: 280px; min-height: 100dvh; display: flex; flex-direction: column; gap: var(--gap); padding-top: calc(16px + env(safe-area-inset-top)); }
.done-title { text-align: center; font-size: 26px; margin: 4px 0; }
#done-img { width: 100%; aspect-ratio: 1; border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0, 0, 0, .18); background: var(--stage); }
.hint { margin: 0; color: var(--muted); font-size: 17px; text-align: center; }
.done-links { display: flex; justify-content: space-between; margin-top: auto; }
.done-links button { padding: 12px 0; white-space: nowrap; }

/* ---------- «Написать нам» ---------- */
.feedback-card { margin-top: 32px; padding: 16px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); }
.feedback-card h2 { margin: 0 0 8px; }
.feedback-card p { margin: 0 0 12px; color: var(--muted); font-size: 17px; }
.feedback-link { align-self: center; font-size: 17px; font-weight: 600; }
.feedback-link .ico, .feedback-card .ico { width: 22px; height: 22px; }

/* форма — лист снизу на телефоне, окно по центру на компьютере */
.sheet { width: 100%; max-width: 520px; max-height: 100dvh; margin: auto auto 0; padding: 16px var(--side) calc(16px + env(safe-area-inset-bottom)); border: 0; border-radius: 20px 20px 0 0; background: var(--surface); color: var(--text); overflow-y: auto; }
@media (min-width: 600px) { .sheet { margin: auto; border-radius: 20px; } }
.sheet::backdrop { background: rgba(20, 14, 12, .55); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; }
.sheet .close { min-width: 52px; font-size: 22px; color: var(--muted); }
.sheet label { display: block; font-weight: 700; margin: 12px 0 8px; }
.sheet label small { font-weight: 400; color: var(--muted); font-size: 16px; }
.sheet textarea { font-size: 19px; }
.sheet .big { margin-top: 12px; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fb-error { margin: 8px 0 0; color: var(--accent); font-weight: 600; }
.fb-thanks { text-align: center; padding: 16px 0 0; }
.fb-thanks p { margin: 0 0 8px; color: var(--muted); }
.fb-thanks .fb-big { font-size: 26px; font-weight: 700; color: var(--text); }
body:has(.sheet[open]) { overflow: hidden; }

#toast {
    position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    background: #221c19; color: #fff; padding: 14px 20px; border-radius: 14px; font-weight: 600; z-index: 10;
    width: max-content; max-width: calc(100% - 32px); text-align: center;
}
