:root {
  --bg: #f6efe7;
  --card: #fffaf5;
  --card-2: #f3e7db;
  --text: #3a2a21;
  --muted: #8b7567;
  --line: #eadccf;
  --accent: #a8714a;
  --accent-ink: #ffffff;
  --rose: #d9707a;
  --rose-soft: #f8dfe1;
  --green: #4f9a6a;
  --dark-tile: #4a362b;
  --shadow: 0 6px 20px rgba(90, 60, 40, 0.08);
  --radius: 20px;
}
:root[data-theme="dark"] {
  --bg: #1b1512;
  --card: #261e1a;
  --card-2: #312620;
  --text: #f3e8de;
  --muted: #a8968a;
  --line: #3b2f28;
  --accent: #d09a6e;
  --accent-ink: #1b1512;
  --rose: #e88b94;
  --rose-soft: #4a2a2e;
  --green: #6cc08b;
  --dark-tile: #3a2b23;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }

/* ---------- верхняя панель ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.brand { font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -0.3px; }
.brand-heart { color: var(--rose); font-size: 14px; vertical-align: super; margin-left: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; background: var(--card);
  box-shadow: var(--shadow); color: var(--accent); font-size: 18px;
}
.avatars { display: flex; }
.avatars .av + .av { margin-left: -10px; }

.av {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #e0806c, #c95d6b); border: 2px solid var(--card);
  background-size: cover; background-position: center; font-size: 14px;
}
.av.p { background: linear-gradient(135deg, #b88a5f, #8f6444); }
.av.lg { width: 72px; height: 72px; font-size: 28px; border-width: 3px; }
.av.xs { width: 22px; height: 22px; font-size: 11px; border-width: 0; }

/* ---------- экран ---------- */
#screen { padding: 4px 16px 16px; max-width: 560px; margin: 0 auto; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.card h3, .section-title { margin: 0 0 10px; font-size: 17px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.page-title { font-size: 24px; font-weight: 800; margin: 6px 0 2px; }
.page-sub { color: var(--muted); margin: 0 0 14px; }
.back { color: var(--muted); font-weight: 600; margin: 6px 0 4px; display: inline-block; }

.couple { text-align: center; padding: 20px 16px; }
.couple .pair { display: flex; justify-content: center; align-items: center; }
.couple .pair .av + .av { margin-left: -14px; }
.couple .heart {
  width: 30px; height: 30px; border-radius: 50%; background: var(--card); color: var(--rose);
  display: grid; place-items: center; margin: 0 -10px; z-index: 1; box-shadow: var(--shadow);
}
.couple .names { font-size: 22px; font-weight: 800; margin: 10px 0 4px; }
.together { color: var(--accent); font-weight: 700; }

.moods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mood {
  background: var(--card-2); border-radius: 14px; padding: 10px 4px; text-align: center;
  border: 2px solid transparent; font-size: 12px; color: var(--muted);
}
.mood .e { font-size: 24px; display: block; margin-bottom: 2px; }
.mood.on { border-color: var(--accent); color: var(--text); background: var(--card); }
.partner-mood { margin-top: 10px; font-size: 13px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tile {
  border-radius: var(--radius); padding: 16px; min-height: 110px; text-align: left;
  background: var(--card); box-shadow: var(--shadow); position: relative;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
}
.tile.dark { background: var(--dark-tile); color: #fff; }
.tile .t-icon { display: block; font-size: 22px; margin-bottom: auto; padding-bottom: 10px; }
.tile .t-title { font-weight: 800; font-size: 17px; }
.tile .t-sub { font-size: 12px; opacity: .75; }
.badge {
  position: absolute; top: 12px; right: 12px; background: var(--rose); color: #fff;
  border-radius: 10px; font-size: 12px; font-weight: 700; padding: 1px 8px;
}

/* ---------- списки ---------- */
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; word-break: break-word; }
.row .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row.done .title { text-decoration: line-through; color: var(--muted); }
.check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--accent); flex: none;
  display: grid; place-items: center; color: var(--accent-ink); font-size: 14px;
}
.check.on { background: var(--accent); }
.x { color: var(--muted); font-size: 18px; padding: 4px 6px; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700;
  background: var(--card-2); color: var(--muted); margin-right: 4px;
}
.pill.rose { background: var(--rose-soft); color: var(--rose); }
.pill.warn { background: #fde6d2; color: #b8632c; }
.when { font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.when.over { color: #c0533b; }
.empty {
  border: 2px dashed var(--line); border-radius: 16px; padding: 20px; text-align: center;
  color: var(--muted); margin: 4px 0 14px;
}

/* ---------- элементы управления ---------- */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  background: var(--card-2); border-radius: 14px; padding: 4px; margin-bottom: 12px;
}
.seg button {
  padding: 9px 2px; border-radius: 11px; font-weight: 600; color: var(--muted);
  white-space: nowrap; font-size: 14px; overflow: hidden; text-overflow: ellipsis;
}
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; padding: 7px 12px; border-radius: 16px; background: var(--card);
  border: 1px solid var(--line); font-size: 13px; font-weight: 600;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  padding: 12px 18px; border-radius: 14px;
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--card-2); color: var(--text); }
.btn.sm { padding: 7px 12px; border-radius: 11px; font-size: 13px; }
.btn:disabled { opacity: .5; }

.addline { display: flex; gap: 8px; margin-bottom: 10px; }
.input, .addline input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 12px 14px; outline: none;
}
.input:focus, .addline input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 80px; }
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.checkline input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- записки ---------- */
.bubbles { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 18px; background: var(--card);
  box-shadow: var(--shadow); white-space: pre-wrap; word-break: break-word;
}
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.bubble .ts { display: block; font-size: 11px; opacity: .6; margin-top: 3px; }

/* ---------- чек-ин ---------- */
.q { margin-bottom: 18px; }
.q .qt { font-weight: 600; margin-bottom: 8px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button {
  padding: 10px 0; border-radius: 12px; background: var(--card-2); font-weight: 700;
}
.scale button.on { background: var(--accent); color: var(--accent-ink); }
.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.score { background: var(--card-2); border-radius: 14px; padding: 10px 12px; }
.score b { font-size: 26px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr 18px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.bar { height: 7px; border-radius: 4px; background: var(--card-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar.p > i { background: var(--rose); }

/* ---------- вишлист ---------- */
.wish-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wish {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 14px;
  display: flex; flex-direction: column; gap: 6px; min-height: 120px;
}
.wish.done { opacity: .55; }
.wish.wide { grid-column: 1 / -1; }
.wish .wt { font-weight: 700; word-break: break-word; }
.wish .price { color: var(--accent); font-weight: 800; }
.wish .note { font-size: 13px; color: var(--muted); word-break: break-word; }
.wish a { color: var(--accent); font-size: 13px; font-weight: 600; }
.wish .actions { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.secret {
  font-size: 12px; color: var(--muted); background: var(--card-2); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px;
}
.reserved-box { background: var(--rose-soft); border-radius: 12px; padding: 8px; font-size: 12px; }
.random-card { background: var(--dark-tile); color: #fff; text-align: left; width: 100%; }
.random-card .t-sub { opacity: .75; font-size: 13px; }

/* ---------- нижнее меню ---------- */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 6;
  max-width: 536px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px);
  border-radius: 24px; box-shadow: var(--shadow); padding: 6px;
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px;
  color: var(--muted); padding: 6px 0; border-radius: 18px; font-weight: 600;
}
.tabbar .ti { font-size: 20px; line-height: 24px; filter: grayscale(1); opacity: .7; }
.tabbar button.on { color: var(--accent); background: var(--card-2); }
.tabbar button.on .ti { filter: none; opacity: 1; }
.tabbar .tab-main .ti { color: var(--rose); filter: none; font-size: 24px; }

/* ---------- нижний лист (форма) ---------- */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(20, 10, 5, 0.45); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto;
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 0 0 14px; font-size: 20px; display: flex; justify-content: space-between; align-items: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 14px; z-index: 30;
  font-weight: 600; max-width: 90vw; text-align: center; box-shadow: var(--shadow);
}

/* ---------- второй этап ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.page-head > div { min-width: 0; }
.fab {
  flex: none; width: 48px; height: 48px; border-radius: 16px; background: var(--accent); color: var(--accent-ink);
  font-size: 26px; font-weight: 600; box-shadow: var(--shadow); margin-top: 6px;
}
.link { color: var(--accent); font-weight: 700; font-size: 13px; }
.counters { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.counter {
  background: var(--card-2); border-radius: 14px; padding: 8px 14px; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; min-width: 96px;
}
.counter b { font-size: 20px; color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 .field { margin-bottom: 12px; }
.search { margin-bottom: 12px; }
.dash-btn {
  width: 100%; border: 2px dashed var(--accent); border-radius: 18px; padding: 16px; color: var(--accent);
  font-weight: 700; margin: 8px 0 12px; background: transparent;
}
.card.place, .card.recipe, .card.trip-card { display: flex; flex-direction: column; gap: 4px; text-align: left; width: 100%; }
.card.done { opacity: .6; }
.place-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.card .wt { font-weight: 700; font-size: 16px; word-break: break-word; }
.card .note { font-size: 13px; color: var(--muted); word-break: break-word; }
.card a { color: var(--accent); font-weight: 600; }
.blind.mine { border: 1px dashed var(--accent); }

.progress { height: 10px; border-radius: 6px; background: var(--card-2); overflow: hidden; margin: 10px 0 6px; }
.progress.sm { height: 6px; margin: 8px 0 4px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--rose)); border-radius: 6px; }
.goal-head { display: flex; align-items: center; gap: 10px; }
.goal-emoji { font-size: 30px; }
.goal-pct { font-size: 20px; color: var(--accent); }
.goal-sum { font-size: 15px; }
.history summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 10px; }
.title.neg { color: #c0533b; }

.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-grid.head div { font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: 50%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; font-size: 15px; position: relative;
}
.cal-cell.today span:first-child { color: var(--accent); font-weight: 800; }
.cal-cell.sel { background: linear-gradient(135deg, var(--accent), var(--rose)); color: #fff; }
.cal-cell.sel span:first-child { color: #fff; }
.dots { display: flex; gap: 2px; height: 5px; margin-top: 2px; }
.dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.dot.task { background: #8b7567; } .dot.event { background: #5b8def; } .dot.place { background: #4f9a6a; }
.dot.trip { background: #2bb3c0; } .dot.date { background: var(--rose); } .dot.blind { background: #a35bd6; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 4px; }

.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.more-tile {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; text-align: left;
  display: flex; flex-direction: column; gap: 4px; min-height: 130px;
}
.more-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; margin-bottom: 8px; }
.more-icon.blue { background: linear-gradient(135deg, #3fb5e8, #3a7bea); }
.more-icon.red { background: linear-gradient(135deg, #f0705a, #e8505b); }
.more-icon.orange { background: linear-gradient(135deg, #f4a23a, #ee6a4a); }
.more-icon.purple { background: linear-gradient(135deg, #c15ae0, #8b5cf6); }
.more-tile .t-title { font-weight: 800; font-size: 16px; }
.more-tile .t-sub { font-size: 12px; }
.menu-row { width: 100%; text-align: left; }
.menu-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--card-2); display: grid; place-items: center; font-size: 18px; }

.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch { appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 21px; }

ul.ing { margin: 6px 0 0; padding-left: 18px; }
ul.ing li { margin: 3px 0; }
.steps { white-space: pre-wrap; margin-top: 6px; }
