:root {
  --bg: #170e13;
  --surface: #23161d;
  --surface-2: #2f1e28;
  --line: #3b2833;
  --text: #f6ebf0;
  --muted: #b39aa7;
  --accent: #e5607f;
  --accent-2: #b8487a;
  --accent-ink: #fff;
  --accent-soft: rgba(229, 96, 127, 0.16);
  --gold: #e8b86a;
  --ok: #6fcf97;
  --warn: #f2c94c;
  --cat-s: 70%;
  --cat-l: 66%;
  --tint: .20;
  --chip-ink: #1b1016;
  --radius: 16px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fbf6f4; --surface: #fff; --surface-2: #f5ebe8; --line: #ead9d4; --text: #2a1a21; --muted: #806a72;
    --accent: #c8405f; --accent-2: #a23565; --accent-soft: rgba(200, 64, 95, 0.1); --gold: #b07a1f;
    --cat-s: 60%; --cat-l: 44%; --tint: .12; --chip-ink: #fff; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #fbf6f4; --surface: #fff; --surface-2: #f5ebe8; --line: #ead9d4; --text: #2a1a21; --muted: #806a72;
  --accent: #c8405f; --accent-2: #a23565; --accent-soft: rgba(200, 64, 95, 0.1); --gold: #b07a1f;
  --cat-s: 60%; --cat-l: 44%; --tint: .12; --chip-ink: #fff; color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; }
[hidden] { display: none !important; }

/* Цвет раздела: у элемента задаётся --h (оттенок) */
[style*="--h"] { --cat: hsl(var(--h) var(--cat-s) var(--cat-l)); }

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 16px 6px; }
.brand { font-family: var(--serif); font-size: 28px; letter-spacing: .5px; color: var(--accent);
  background: linear-gradient(100deg, var(--accent), var(--gold)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.brand-heart { font-size: .55em; margin-left: 4px; vertical-align: super; }
.brand.big { font-size: 48px; }
.since { color: var(--muted); font-size: 14px; }

.tab { display: none; padding: 0 16px; }
.tab.active { display: block; }

/* Поиск и фильтры */
.searchbar { display: flex; gap: 8px; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
.searchbar input { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 11px 14px; outline: none; }
.searchbar input:focus { border-color: var(--accent); }
.icon-btn { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  min-width: 46px; height: 46px; display: grid; place-items: center; font-size: 22px; }
.dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent);
  color: var(--accent-ink); font-size: 11px; line-height: 16px; padding: 0 4px; }

/* Анкета желаний: баннер */
.quiz-banner { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; margin: 4px 0 10px;
  border: 1px solid transparent; border-radius: var(--radius); padding: 12px 14px; color: var(--accent-ink);
  background: linear-gradient(120deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 22px rgba(229, 96, 127, .22); }
.quiz-title { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.quiz-sub { font-size: 13px; opacity: .9; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.cat.on { background: var(--cat); border-color: var(--cat); color: var(--chip-ink); }
.chip small { opacity: .7; margin-left: 4px; }

.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 6px; border-radius: 9px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }

.resultbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 0 6px; color: var(--muted); font-size: 14px; gap: 8px; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; font-size: 14px; color: var(--text); }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; }

/* Список */
.group-title { font-family: var(--serif); font-size: 20px; margin: 24px 0 4px; display: flex; align-items: center; gap: 8px; }
.dot-cat { width: 10px; height: 10px; border-radius: 50%; background: var(--cat); flex: none; }
.sub-title { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; margin: 14px 0 6px; }
.item { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--cat, var(--line));
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; transition: transform .08s ease; }
.item:active { transform: scale(.99); }
.item-top { display: flex; align-items: center; gap: 8px; }
.item-title { font-weight: 600; flex: 1; }
.item-short { color: var(--muted); font-size: 14px; margin-top: 2px; }
.item-meta { color: var(--muted); font-size: 12px; margin-top: 6px; opacity: .85; }
.badges { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.badge { border-radius: 999px; padding: 1px 8px; background: var(--surface-2); white-space: nowrap; }
.badge.tried { background: rgba(111, 207, 151, .15); color: var(--ok); }
.badge.match { background: var(--accent-soft); }
.flame { letter-spacing: -2px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Нижнее меню */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px; background: var(--surface);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.tabs button { flex: 1; max-width: 200px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; font-size: 12px;
  color: var(--muted); padding: 4px; border-radius: 10px; }
.tabs button span { font-size: 20px; }
.tabs button.on { color: var(--text); background: var(--surface-2); }

/* Комбо */
.combo-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(72px + env(safe-area-inset-bottom)); width: calc(100% - 24px); max-width: 696px;
  background: var(--surface-2); border: 1px solid var(--accent); border-radius: 14px; padding: 8px 8px 8px 14px; display: flex; gap: 8px; align-items: center; z-index: 11;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.combo-bar span { flex: 1; font-size: 14px; }
.combo-bar .primary { padding: 9px 14px; }

/* Шторки */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet-body { position: relative; background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
.sheet-body.tinted[style*="--h"] { background:
  radial-gradient(130% 55% at 0% 0%, hsl(var(--h) 75% 55% / var(--tint)), transparent 62%), var(--bg); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.card-meta { color: var(--muted); font-size: 14px; }
.card-cat { display: inline-block; font-size: 13px; font-weight: 600; color: var(--cat, var(--muted)); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; margin-top: 2px; }
.card-title { font-family: var(--serif); font-size: 30px; line-height: 1.15; margin: 8px 0 8px; }
.card-short { font-size: 17px; margin: 0 0 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 16px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 13px; color: var(--muted); }
.fact.wide { grid-column: 1 / -1; }
.fact b { display: block; color: var(--text); font-size: 15px; font-weight: 600; }
.sheet-body h4 { font-family: var(--serif); font-size: 19px; margin: 18px 0 8px; font-weight: 600; }
.steps { padding-left: 0; margin: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 10px 36px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.tips { padding-left: 18px; margin: 0; }
.tips li { margin-bottom: 6px; }
.note { border-radius: 12px; padding: 10px 12px; margin-top: 14px; font-size: 15px; }
.note.safety { background: rgba(242, 201, 76, .12); border: 1px solid rgba(242, 201, 76, .35); }
.note.props { background: var(--surface); border: 1px solid var(--line); }
.note.match { background: var(--accent-soft); border: 1px solid var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tag { font-size: 13px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 3px 10px; border: 1px solid var(--line); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.actions .wide { grid-column: 1 / -1; }
.actions button { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.actions .primary { border: 0; background: var(--accent); }
.actions .on { border-color: var(--accent); background: var(--accent-soft); }
.done-row { display: flex; gap: 8px; margin-top: 8px; }
.done-row input { flex: 1; min-width: 0; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.history { color: var(--muted); font-size: 14px; margin-top: 12px; }

/* Хочу / может быть / не моё */
.want-box { margin-top: 8px; }
.want { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.want button { padding: 11px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; }
.want button.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.want.big button { padding: 16px 8px; font-size: 16px; }
.muted.small { font-size: 12px; margin: 8px 0 0; }
.role-pick .muted { margin-bottom: 8px; }

/* Анкета: шторка */
.quiz-progress { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.quiz-progress .bar { margin: 0; }
.quiz-card { min-height: 240px; padding: 6px 0 12px; }
.quiz-more summary { color: var(--accent); cursor: pointer; margin-top: 12px; font-size: 15px; }
.quiz-more .steps { margin-top: 10px; }
.skip { display: block; margin: 12px auto 0; }

/* Фильтры */
.fgroup { margin-bottom: 16px; }
.fgroup h4 { margin: 0 0 8px !important; font-size: 16px !important; }
.fgroup .chips { flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; }

/* Календарь */
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 12px; }
#monthTitle { font-family: var(--serif); font-size: 22px; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
#calWeek div { text-align: center; color: var(--muted); font-size: 12px; padding-bottom: 4px; }
.day { aspect-ratio: 1; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 15px; position: relative; padding: 0; }
.day.out { visibility: hidden; }
.day.future { opacity: .4; }
.day.today { border-color: var(--text); }
.day.has { background: linear-gradient(140deg, var(--accent), var(--accent-2)); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.day.sel { outline: 2px solid var(--gold); outline-offset: 1px; }
.day i { font-style: normal; font-size: 10px; position: absolute; bottom: 3px; }
.day-title { font-family: var(--serif); }
.cal-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; font-family: var(--serif); }
.stat span { font-size: 12px; color: var(--muted); }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.entry-head { display: flex; justify-content: space-between; gap: 8px; }
.entry a { color: var(--accent); text-decoration: none; cursor: pointer; }
.entry .del { border: 0; background: none; color: var(--muted); font-size: 13px; }
.add-form { display: grid; gap: 8px; margin-top: 8px; }
.text { width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; }

/* Мы */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; }
.panel h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 19px; font-weight: 600; }
.panel .seg { margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.row { display: flex; align-items: center; gap: 10px; padding: 6px 0; justify-content: space-between; }
.row input[type=time] { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.checks label { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 4px 0 10px; }
.bar div { height: 100%; background: var(--cat, var(--accent)); }
.progress-row { display: flex; justify-content: space-between; font-size: 14px; }

.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  padding: 10px 16px; border-radius: 12px; z-index: 30; font-size: 15px; max-width: 90vw; text-align: center; }
.gate { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--muted); }

@media (max-width: 380px) {
  .checks { grid-template-columns: 1fr; }
  .card-title { font-size: 26px; }
}
