/* ==========================================================
   «Мы» — общий дизайн-систем. Нежный, тёплый стиль.
   Все цвета — через токены. Тёмная тема — автоматически.
   ========================================================== */
:root {
  --bg: #FFF6F2;
  --bg-2: #FFEFE9;
  --surface: #FFFFFF;
  --surface-2: #FFF1EC;
  --surface-3: #FDE7E0;
  --text: #3B2A30;
  --text-2: #6E5960;
  --muted: #A08990;
  --line: #F4E2DC;

  --primary: #EE6F86;        /* розовый — «наше общее» */
  --primary-strong: #E0546E;
  --primary-soft: #FDE3E9;
  --on-primary: #FFFFFF;
  --peach: #FF9F7A;
  --peach-soft: #FFE8DE;
  --lilac: #A98CF0;
  --lilac-soft: #EFE8FF;
  --mint: #5EC4A0;
  --mint-soft: #DFF5EC;
  --sun: #FFBF47;
  --sun-soft: #FFF3D6;
  --danger: #E5484D;
  --danger-soft: #FDE3E3;

  --grad-love: linear-gradient(135deg, #FF9AA8 0%, #FFB592 55%, #FFD3A1 100%);
  --grad-dream: linear-gradient(135deg, #B9A2FF 0%, #F6A6C8 100%);
  --grad-sky: linear-gradient(135deg, #8FC9FF 0%, #C5B5FF 100%);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 8px 28px rgba(222, 104, 124, 0.12), 0 1px 3px rgba(80, 40, 50, 0.05);
  --shadow-sm: 0 2px 10px rgba(222, 104, 124, 0.10);
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1517;
    --bg-2: #221A1D;
    --surface: #2A2024;
    --surface-2: #33282C;
    --surface-3: #3D3035;
    --text: #F8ECEF;
    --text-2: #D9C3C9;
    --muted: #A58E95;
    --line: #3E3035;
    --primary: #FF8DA1;
    --primary-strong: #FF7590;
    --primary-soft: #4A2A33;
    --on-primary: #2A1218;
    --peach-soft: #47302A;
    --lilac-soft: #362D4D;
    --mint-soft: #213B32;
    --sun-soft: #43381F;
    --danger-soft: #4A2526;
    --seg-active: #4E3B42;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1C1517; --bg-2: #221A1D; --surface: #2A2024; --surface-2: #33282C; --surface-3: #3D3035;
  --text: #F8ECEF; --text-2: #D9C3C9; --muted: #A58E95; --line: #3E3035;
  --primary: #FF8DA1; --primary-strong: #FF7590; --primary-soft: #4A2A33; --on-primary: #2A1218;
  --peach-soft: #47302A; --lilac-soft: #362D4D; --mint-soft: #213B32; --sun-soft: #43381F; --danger-soft: #4A2526; --seg-active: #4E3B42;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35); --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--primary-strong); }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 750; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }

/* ---------- boot ---------- */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot-heart { font-size: 56px; animation: beat 1.2s ease-in-out infinite; }
@keyframes beat { 0%,100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(1); } 45% { transform: scale(1.12); } }

/* ---------- layout ---------- */
#app { min-height: 100dvh; }
.page {
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  max-width: 640px;
  margin: 0 auto;
  animation: page-in .22s ease-out;
}
body.no-tabbar .page { padding-bottom: calc(var(--safe-bottom) + 24px); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-header {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 16px;
  min-height: 44px;
}
.page-header h1 { flex: 1; }
.page-header .sub { color: var(--muted); font-size: 14px; font-weight: 500; margin-top: 2px; }

.section { margin-top: 22px; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 4px 10px;
}
.section-title a, .section-title button { text-transform: none; letter-spacing: 0; font-size: 14px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.bold { font-weight: 700; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 12px; }
.card-soft { background: var(--surface-2); border-radius: var(--radius-lg); padding: 16px; }
.card-hero {
  background: var(--grad-love);
  color: #4A1E28;
  border-radius: var(--radius-xl);
  padding: 22px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.card-hero.dream { background: var(--grad-dream); color: #2E1B4A; }
.card-hero.sky { background: var(--grad-sky); color: #1B2A4A; }
.card-tap { cursor: pointer; transition: transform .12s ease; }
.card-tap:active { transform: scale(.98); }

/* ---------- lists ---------- */
.list { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; min-height: 54px;
  border-bottom: 1px solid var(--line);
  background: transparent; width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0;
}
.list-item:last-child { border-bottom: 0; }
button.list-item, .list-item.tap { cursor: pointer; }
button.list-item:active, .list-item.tap:active { background: var(--surface-2); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
.li-emoji {
  width: 40px; height: 40px; border-radius: 13px;
  display: grid; place-items: center; font-size: 22px;
  background: var(--surface-2); flex: none;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border-radius: 999px; border: 0;
  background: var(--surface-2); color: var(--text);
  font-weight: 650; font-size: 16px;
  cursor: pointer; user-select: none;
  transition: transform .1s ease, opacity .15s ease, background .15s ease;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 18px rgba(238, 111, 134, .35); }
.btn-primary:active { background: var(--primary-strong); }
.btn-ghost { background: transparent; color: var(--primary-strong); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-icon {
  width: 42px; height: 42px; min-height: 0; padding: 0;
  border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow-sm); border: 0; color: var(--text); cursor: pointer;
  flex: none;
}
.btn-icon:active { transform: scale(.92); }
.btn-icon.plain { background: transparent; box-shadow: none; }
.btn-icon.primary { background: var(--primary); color: var(--on-primary); }

.fab {
  position: fixed; right: 18px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  border: 0; box-shadow: 0 10px 26px rgba(238, 111, 134, .45);
  display: grid; place-items: center; cursor: pointer; z-index: 30;
}
.fab:active { transform: scale(.94); }
body.no-tabbar .fab { bottom: calc(var(--safe-bottom) + 18px); }

/* ---------- chips / segmented ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line);
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--text-2);
}
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); }
.segmented {
  display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px;
}
.segmented button {
  flex: 1; min-height: 38px; border: 0; border-radius: 11px; background: transparent;
  font-weight: 650; font-size: 15px; color: var(--muted); cursor: pointer;
}
.segmented button.active { background: var(--seg-active, var(--surface)); color: var(--text); box-shadow: var(--shadow-sm); }

.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--primary); color: var(--on-primary);
  font-size: 12px; font-weight: 800;
}
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--text-2); }
.pill.primary { background: var(--primary-soft); color: var(--primary-strong); }
.pill.lilac { background: var(--lilac-soft); color: var(--lilac); }
.pill.mint { background: var(--mint-soft); color: var(--mint); }
.pill.peach { background: var(--peach-soft); color: var(--peach); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field-label { font-size: 13px; font-weight: 700; color: var(--text-2); margin-left: 4px; }
.field .hint { font-size: 12px; color: var(--muted); margin-left: 4px; }
.input, .textarea, .select {
  width: 100%; min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 16px; /* >=16px: no iOS zoom */
  outline: none; appearance: none; -webkit-appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.textarea { resize: none; min-height: 96px; line-height: 1.45; }
.input[type="date"], .input[type="time"], .input[type="datetime-local"] { min-height: 48px; display: flex; align-items: center; }
.input::-webkit-date-and-time-value { text-align: left; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-grid button {
  aspect-ratio: 1; border: 0; background: transparent; border-radius: 12px; font-size: 24px; cursor: pointer; padding: 0;
}
.emoji-grid .emoji-more { font-size: 22px; font-weight: 700; color: var(--muted); background: var(--surface-2); }
.emoji-custom { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.emoji-custom .hint { font-size: 12px; color: var(--muted); margin-left: 4px; }
.emoji-grid button.active { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0; }
.color-dot.active { box-shadow: 0 0 0 2.5px var(--text); }

/* ---------- progress ---------- */
.progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width .5s ease; }
.progress.thick { height: 14px; }

/* ---------- avatar ---------- */
.avatar {
  border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-weight: 800; color: #fff; overflow: hidden; background: var(--primary);
  border: 2px solid var(--surface);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -10px; }

/* ---------- stat ---------- */
.stat-num { font-size: 44px; font-weight: 850; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 14px; font-weight: 600; opacity: .8; }

/* ---------- empty / spinner ---------- */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .e-emoji { font-size: 48px; margin-bottom: 10px; }
.empty .e-title { font-size: 18px; font-weight: 750; color: var(--text); margin-bottom: 6px; }
.empty .e-text { font-size: 14px; max-width: 280px; margin: 0 auto 16px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--primary-soft); border-top-color: var(--primary);
  animation: spin .8s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; justify-content: space-around; align-items: stretch;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
body.no-tabbar .tabbar { display: none; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 650; position: relative;
  max-width: 120px;
}
.tab svg { width: 26px; height: 26px; }
.tab.active { color: var(--primary-strong); }
.tab .tab-badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 800;
  display: grid; place-items: center; border: 2px solid var(--surface);
}
.tab .tab-badge:empty { display: none; }

/* ---------- sheet (bottom modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(40, 18, 26, .38);
  animation: fade-in .2s ease;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.closing { animation: fade-out .2s ease forwards; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh;
  background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 8px 16px calc(var(--safe-bottom) + 18px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: sheet-up .28s cubic-bezier(.2, .9, .3, 1.05);
  box-shadow: 0 -10px 40px rgba(0,0,0,.15);
}
.sheet-backdrop.closing .sheet { animation: sheet-down .2s ease forwards; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-head h2 { flex: 1; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-down { to { transform: translateY(100%); } }

/* ---------- dialog ---------- */
.dialog {
  margin: auto 24px; align-self: center; width: 100%; max-width: 340px;
  background: var(--surface); border-radius: 24px; padding: 22px 20px 16px; text-align: center;
  animation: pop-in .2s ease; box-shadow: var(--shadow);
}
.dialog .d-text { font-size: 17px; font-weight: 650; margin-bottom: 18px; }
.dialog .d-actions { display: flex; gap: 10px; }
.dialog .d-actions .btn { flex: 1; }
@keyframes pop-in { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- toast ---------- */
.toast-wrap {
  position: fixed; left: 0; right: 0; top: calc(var(--safe-top) + 10px); z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px; font-weight: 650; font-size: 15px;
  box-shadow: var(--shadow); animation: toast-in .25s ease;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { animation: fade-out .3s ease forwards; }
@keyframes toast-in { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.link-btn { background: none; border: 0; color: var(--primary-strong); font-weight: 650; cursor: pointer; padding: 6px 4px; font-size: 15px; text-decoration: none; }
.heart-float { position: fixed; pointer-events: none; z-index: 300; font-size: 28px; animation: float-up 1.4s ease-out forwards; }
@keyframes float-up { from { transform: translateY(0) scale(.6); opacity: 1; } to { transform: translateY(-160px) scale(1.4); opacity: 0; } }

@media (min-width: 700px) {
  .tabbar { justify-content: center; gap: 24px; }
}
