/* «Ельза контролює» — стиль у дусі iOS. Світла і темна тема, мобільний та десктопний макети. */
:root {
  --bg: #f4f1ef;
  --bg2: #fde8e4;
  --card: #ffffff;
  --card2: #f7f5f3;
  --text: #1c1c1e;
  --muted: #8a8a8e;
  --line: rgba(60, 60, 67, .12);
  --accent: #ff6b8a;
  --accent2: #ff9f6b;
  --ok: #30b957;
  --warn: #ff9500;
  --danger: #ff453a;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --nav-h: 64px;
  --select: #0a84ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e10;
    --bg2: #1a1214;
    --card: #1c1c1f;
    --card2: #262629;
    --text: #f2f2f7;
    --muted: #98989f;
    --line: rgba(235, 235, 245, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[x-cloak] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg2), var(--bg) 40%) fixed;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h3 { font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); font-size: 14px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.center { text-align: center; }

/* ---------- каркас ---------- */
.shell { max-width: 560px; overflow-x: clip; margin: 0 auto; min-height: 100vh; padding: 0 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top)) 2px 12px; }
.top h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.icon-btn { border: 0; background: var(--card); box-shadow: var(--shadow); width: 38px; height: 38px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.tab { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.nav button {
  flex: 1; border: 0; background: none; cursor: pointer; padding: 6px 0; border-radius: 12px;
  display: grid; gap: 2px; justify-items: center; color: var(--muted); font-size: 11px; font-weight: 600;
}
.nav button .ic { font-size: 22px; filter: grayscale(1) opacity(.7); transition: .15s; }
.nav button.on { color: var(--accent); }
.nav button.on .ic { filter: none; transform: scale(1.1); }

/* ---------- картки та елементи ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.hero { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; }
.hero .muted { color: rgba(255, 255, 255, .85); }
.hero h2 { font-size: 24px; }

.btn {
  border: 0; cursor: pointer; border-radius: 14px; padding: 12px 16px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent2), var(--accent)); transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.ghost { background: var(--card2); color: var(--text); }
.btn.danger { background: none; color: var(--danger); padding: 6px 10px; }
.btn.block { width: 100%; }
.btn.big { padding: 16px; font-size: 17px; border-radius: 18px; }

input[type=text], input[type=date], input[type=number], textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card2); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; cursor: pointer; padding: 9px 14px; border-radius: 999px; font-weight: 600; font-size: 14px;
  background: var(--card); color: var(--text); box-shadow: var(--shadow);
}
.chip.on { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--card2); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; padding: 8px; border-radius: 10px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.person { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.person + .person { border-top: 1px solid var(--line); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 18px;
  background: var(--card2); color: var(--muted);
}
.avatar.me { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; }
.pill { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--card2); white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.opts { display: grid; gap: 8px; margin-top: 10px; }
.opt { text-align: left; border: 2px solid transparent; background: var(--card2); padding: 12px 14px; border-radius: 14px; cursor: pointer; font-weight: 600; }
.opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card2)); }

.twin { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-number { font-size: 40px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- списки ---------- */
.item {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; border: 0; background: none;
  padding: 13px 4px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 17px;
}
.item:last-child { border-bottom: 0; }
.check { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 15px; color: transparent; transition: .15s; }
.item.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.item.done .txt { text-decoration: line-through; color: var(--muted); }
.shop .item { font-size: 20px; padding: 18px 4px; }
.switch span { white-space: nowrap; }
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; user-select: none; }
.switch i { width: 46px; height: 28px; border-radius: 999px; background: var(--card2); position: relative; transition: .2s; border: 1px solid var(--line); }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: .2s; }
.switch.on i { background: var(--ok); }
.switch.on i::after { transform: translateX(18px); }

/* ---------- моменти ---------- */
.moment img { width: 100%; border-radius: 14px; display: block; background: var(--card2); min-height: 120px; object-fit: cover; }
.moment .quote { font-size: 18px; font-style: italic; padding: 8px 4px; }
.preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; }

/* ---------- Tinder ---------- */
.deck { position: relative; display: grid; place-items: center; padding: 8px 0 4px; }
.dish-card {
  width: 100%; min-height: 260px; border-radius: 26px; padding: 28px 20px; display: grid; align-content: center; gap: 10px;
  text-align: center; background: linear-gradient(160deg, var(--card), var(--card2)); box-shadow: var(--shadow);
  border: 1px solid var(--line); touch-action: pan-y; cursor: grab; user-select: none; position: relative;
}
.dish-card h2 { font-size: 30px; }
.stamp { position: absolute; top: 18px; font-size: 22px; font-weight: 900; padding: 4px 12px; border: 4px solid; border-radius: 12px; opacity: 0; }
.stamp.yes { left: 18px; color: var(--ok); transform: rotate(-12deg); }
.stamp.no { right: 18px; color: var(--danger); transform: rotate(12deg); }
.vote-row { display: flex; justify-content: center; gap: 22px; margin-top: 14px; }
.vote-row button { width: 72px; height: 72px; border-radius: 50%; border: 0; font-size: 30px; cursor: pointer; background: var(--card); box-shadow: var(--shadow); }
.banner { border-radius: 18px; padding: 16px; text-align: center; font-weight: 700; }
.banner.match { background: linear-gradient(135deg, #34c759, #30b0c7); color: #fff; font-size: 20px; }
.banner.no { background: var(--card2); }
.tagrow { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.tag { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--card2); color: var(--muted); }

.lot { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lot:last-child { border-bottom: 0; }

.spark { width: 100%; height: 56px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark circle { fill: var(--accent); }

/* ---------- toast / login ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(92vw, 460px); z-index: 50; padding: 12px 18px; border-radius: 16px; background: #1c1c1e; color: #fff;
  box-shadow: 0 8px 30px rgba(0,0,0,.3); font-weight: 600; text-align: center;
}
.toast.err { background: var(--danger); }
.busy-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: linear-gradient(90deg, var(--accent2), var(--accent)); animation: bar 1s infinite; }
@keyframes bar { from { transform: scaleX(.05); transform-origin: left; } 50% { transform: scaleX(1); transform-origin: left; } to { transform: scaleX(1); transform-origin: right; } }

/* ---------- великі екрани: центрована картка з бічною навігацією ---------- */
@media (min-width: 900px) {
  body { padding: 28px 0; }
  .shell {
    max-width: 960px; min-height: calc(100vh - 56px); padding: 0 28px 28px 252px; position: relative;
    background: color-mix(in srgb, var(--bg) 55%, transparent); border-radius: 32px; box-shadow: var(--shadow);
    border: 1px solid var(--line);
  }
  .nav {
    position: absolute; left: 16px; top: 16px; bottom: 16px; right: auto; width: 208px; flex-direction: column; justify-content: flex-start;
    gap: 4px; padding: 12px; border: 0; border-radius: 22px; background: var(--card); box-shadow: var(--shadow); backdrop-filter: none;
  }
  .nav button { display: flex; align-items: center; gap: 12px; padding: 12px 14px; font-size: 15px; text-align: left; }
  .nav button.on { background: var(--card2); }
  .nav button .ic { font-size: 20px; }
  .toast { bottom: 32px; }
  .tab.cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .tab.cols .span { grid-column: 1 / -1; }
}

/* ---------- сторінка входу з фото-аватарками ---------- */
.login { max-width: 420px; margin: 0 auto; min-height: 100vh; display: grid; align-content: center; gap: 18px; padding: 24px; }
.login-hero { display: grid; justify-items: center; gap: 8px; text-align: center; }
.login-hero h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; }
.login-hero p { margin: 0; }
.ava {
  position: relative; display: grid; place-items: center; flex: none; overflow: hidden; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; font-weight: 800;
}
.ava::before { content: attr(data-i); }                       /* літера, якщо фото немає */
.ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ava-xl { width: 140px; height: 140px; font-size: 56px; box-shadow: 0 0 0 4px var(--card), 0 0 0 6px var(--accent), var(--shadow); }
.ava-lg { width: 116px; height: 116px; font-size: 46px; box-shadow: 0 0 0 3px var(--line); transition: box-shadow .2s, transform .2s; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; justify-items: center; }
.pick {
  display: grid; justify-items: center; gap: 12px; padding: 10px 6px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 18px; border-radius: 28px; transition: opacity .2s, color .2s;
}
.pick:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }
.pick.on { color: var(--select); }
.pick.on .ava-lg { box-shadow: 0 0 0 4px var(--card), 0 0 0 7px var(--select), 0 8px 24px color-mix(in srgb, var(--select) 40%, transparent); transform: scale(1.06); }
.who:has(.on) .pick:not(.on) { opacity: .6; }
.login-input { width: 100%; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 16px; outline: none; }
.login-input:focus { border-color: var(--select); }
.login-err { color: var(--danger); margin: -6px 0 0; }

/* ---------- довідки у списках та AI Ельзи ---------- */
.item .check { margin-top: 1px; }
.note { display: block; margin-top: 2px; font-size: 13px; line-height: 1.35; color: var(--muted); text-decoration: none; }
.hint { margin: 10px 0 0; font-size: 13px; }
.ai-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 12px; }
.ai-grid:empty { display: none; }
.ai-card { background: var(--card2); border-radius: 16px; padding: 14px; animation: fade .25s ease; }
.ai-card p { margin: 0; }
.ai-err { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 14%, transparent); font-size: 14px; }
.thinking { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-weight: 600; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { display: grid; gap: 10px; margin-top: 12px; }
.skel i { display: block; height: 78px; border-radius: 16px; background: linear-gradient(100deg, var(--card2) 30%, color-mix(in srgb, var(--card2) 55%, var(--card)) 50%, var(--card2) 70%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (min-width: 900px) { .ai-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } }

/* ---------- живе середовище: стрік, плашки, стрічка ---------- */
.streak { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.flame { font-size: 44px; line-height: 1; filter: drop-shadow(0 2px 6px rgba(0,0,0,.25)); }
.streak-n { font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.streak-l { line-height: 1.3; }
.hero .streak-l .muted { color: rgba(255, 255, 255, .85); }
.plaque { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.plaque.wait { border-style: dashed; border-color: var(--line); background: var(--card); }
.plaque .btn { padding: 10px 14px; }
.feed-row { display: flex; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.feed-row:last-child { border-bottom: 0; }
.feed-row .muted { font-size: 12px; white-space: nowrap; }
.nav button { font-size: 10.5px; }

/* ---------- нікнейми, плани, таймлайн, архів ---------- */
.icon-btn.mini { width: 28px; height: 28px; font-size: 13px; flex: none; }
.nick-form { gap: 6px; margin: 4px 0; }
.nick-form .btn { padding: 8px 12px; }
.plan-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.plan-row:last-child { border-bottom: 0; }
.plan-view { margin-top: 2px; }
.wrapchips { flex-wrap: wrap; overflow: visible; }
.age-badge { display: inline-block; padding: 6px 12px; border-radius: 999px; font-weight: 700; margin: 10px 0 4px;
  background: color-mix(in srgb, var(--accent) 14%, var(--card2)); }
.together { text-align: center; padding: 6px 0 12px; }
.together-n { font-size: 24px; font-weight: 800; line-height: 1.25; margin: 4px 0; background: linear-gradient(135deg, var(--accent2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.timeline { position: relative; display: grid; gap: 4px; margin-top: 6px; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 17px; top: 46px; bottom: -4px; width: 2px; background: var(--line); }
.tl-dot { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; background: var(--card2); }
.ms-form { margin-top: 8px; }
.hearts { display: flex; gap: 4px; }
.heart { border: 0; background: none; font-size: 30px; cursor: pointer; padding: 2px; line-height: 1; }
.hearts-view { font-size: 14px; white-space: nowrap; }
.memory-form { border: 2px solid var(--accent); }
