/* ==========================================================================
   pulsse — дизайн-система
   Направление: «бумага и тушь». Тёплый фон, тонкие линии, серифные цифры,
   один акцент. Без градиентов, теней и декора без функции.
   ========================================================================== */

/* ---------- Токены ---------- */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --fs-micro: 10.5px;
  --fs-sm: 12.5px;
  --fs-md: 14.5px;
  --fs-lg: 18px;
  --fs-xl: 24px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --rail: 236px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Светлая тема — тёплая бумага */
:root,
[data-theme="light"] {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #14140f;
  --ink-2: #45453d;
  --muted: #6b6a60;
  --line: #e4e1d8;
  --line-2: #d2cec3;
  --shadow: 0 0 0 1px rgba(20, 20, 15, 0.04);
}

[data-theme="dark"] {
  --bg: #0b0b0a;
  --surface: #121211;
  --surface-2: #171715;
  --ink: #f3f2ec;
  --ink-2: #c9c7bd;
  --muted: #8b897f;
  --line: #24241f;
  --line-2: #33332c;
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Акценты: один цвет на интерфейс, используется скупо */
[data-accent="cobalt"] { --accent: #2f4bff; --accent-soft: #e9ecff; --accent-ink: #ffffff; }
[data-accent="ember"]  { --accent: #cf4a20; --accent-soft: #fdece5; --accent-ink: #ffffff; }
[data-accent="moss"]   { --accent: #2c6b4d; --accent-soft: #e6f2ea; --accent-ink: #ffffff; }
[data-accent="ink"]    { --accent: #14140f; --accent-soft: #ecebe4; --accent-ink: #ffffff; }

[data-theme="dark"][data-accent="cobalt"] { --accent: #8093ff; --accent-soft: #1a1e33; --accent-ink: #0b0b0a; }
[data-theme="dark"][data-accent="ember"]  { --accent: #ff8a63; --accent-soft: #2a1a14; --accent-ink: #0b0b0a; }
[data-theme="dark"][data-accent="moss"]   { --accent: #74d3a3; --accent-soft: #13241b; --accent-ink: #0b0b0a; }
[data-theme="dark"][data-accent="ink"]    { --accent: #f3f2ec; --accent-soft: #1e1e1a; --accent-ink: #0b0b0a; }

/* ---------- База ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-md) / 1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i--sm { width: 16px; height: 16px; }
.i--lg { width: 24px; height: 24px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-sm);
  transition: top 0.18s var(--ease);
}
.skip:focus { top: 12px; }

/* ---------- Каркас ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding: 26px 18px 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 8px;
}

.brand-mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: lowercase;
}

.nav { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: var(--fs-md);
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.nav-item .i { width: 18px; height: 18px; stroke-width: 1.5; }
.nav-item:hover { color: var(--ink); background: var(--surface-2); }
.nav-item[aria-current="page"] { color: var(--ink); font-weight: 550; }
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 50%;
  width: 2px;
  height: 20px;
  transform: translateY(-50%);
  background: var(--accent);
}

.rail-foot {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.rail-stat { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; border-radius: var(--r-sm); }
.rail-stat:hover { background: var(--surface-2); }
.rail-value { font-family: var(--font-display); font-size: 20px; line-height: 1.1; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 14px 24px;
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}
.brand--mobile { display: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.micro {
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Контент ---------- */
#view {
  width: 100%;
  max-width: 1120px;
  padding: 8px clamp(18px, 4vw, 44px) 120px;
  margin: 0 auto;
  outline: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: 18px 0 26px;
}
.page-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 38px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.page-sub { margin-top: 6px; color: var(--muted); font-size: var(--fs-sm); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
@media (min-width: 1080px) {
  .cols { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; }
}
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack--tight { gap: var(--sp-2); }

/* ---------- Карточки ---------- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: var(--sp-5);
}
.card--flush { padding: 0; overflow: hidden; }
.card--quiet { background: transparent; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.card-title { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.005em; }
.card-note { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-md);
  font-weight: 550;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.12s var(--ease);
}
.btn:active { transform: scale(0.985); }
.btn--primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn--primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn--line { border-color: var(--line-2); }
.btn--line:hover { border-color: var(--ink); }
.btn--quiet { color: var(--muted); padding: 0 10px; }
.btn--quiet:hover { color: var(--ink); background: var(--surface-2); }
.btn--accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--accent:hover { filter: brightness(1.06); }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: var(--fs-sm); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
/* Кнопки в шапке карточки: квадрат 44×44 даже с одной цифрой */
.card-head .btn { min-width: 44px; justify-content: center; }
/* Кнопка с единственной иконкой — квадрат 44×44 */
.btn:has(> .i:only-child) { min-width: 44px; padding-left: 0; padding-right: 0; }

/* ---------- Мелочи ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.chip strong { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
/* Интерактивные чипы — полноценная цель нажатия */
button.chip,
a.chip { min-height: 44px; }
.chip--ghost { background: transparent; color: var(--muted); }
.chip--ghost:hover { color: var(--ink); border-color: var(--line-2); }
.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.hide-sm { display: none; }
@media (min-width: 720px) { .hide-sm { display: inline; } }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Шапка «Сегодня» ---------- */
.greeting {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.4vw, 46px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.greeting-sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: var(--fs-md);
  max-width: 46ch;
}

/* XP-полоса */
.xp { margin-top: var(--sp-5); }
.xp-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: 10px; flex-wrap: wrap; }
.xp-level { font-family: var(--font-display); font-size: clamp(18px, 4.6vw, var(--fs-xl)); line-height: 1.05; overflow-wrap: anywhere; }
.xp-num { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.bar {
  position: relative;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--ink);
  transition: width 0.5s var(--ease);
}
.bar--accent > i { background: var(--accent); }
.bar--thin { height: 2px; }

/* Полоска недели: семь квадратов, крайний — сегодня */
.days { display: flex; align-items: center; gap: 5px; height: 9px; margin-top: 16px; }
.days i { width: 7px; height: 7px; border-radius: 2px; background: var(--line); }
.days i[data-on="1"] { background: var(--ink-2); }
.days i[data-today="1"] { background: var(--accent); }

/* ---------- Привычки ---------- */
.list { display: flex; flex-direction: column; }
.list > li + li { border-top: 1px solid var(--line); }

.item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 56px;
  padding: 10px 4px;
}
.item-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.item-title { font-size: var(--fs-md); font-weight: 500; overflow-wrap: anywhere; }
.item-meta { font-size: var(--fs-sm); color: var(--muted); }
.item-side { display: flex; align-items: center; gap: 6px; flex: none; }
.item-xp { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--muted); }

/* Кружок отметки: цель нажатия 44 px, визуально — 30 px */
.check {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: transparent;
  flex: none;
  margin: -7px;
  padding: 0;
}
.check::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1.5px solid var(--line-2);
  border-radius: 50%;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.check .i { position: relative; width: 15px; height: 15px; stroke-width: 2; transition: color 0.15s var(--ease); }
.check:hover::before { border-color: var(--accent); }
.check[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent); }
.check[aria-pressed="true"] .i { color: var(--accent-ink); }

.item--done .item-title { color: var(--muted); }

/* Точки за 7 дней */
.week { display: flex; gap: 3px; }
.week i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
}
.week i[data-on="1"] { background: var(--accent); }

/* ---------- Чек-ин ---------- */
.mood { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.mood button {
  min-height: 46px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.2;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease);
}
.mood button:hover { border-color: var(--line-2); color: var(--ink); }
.mood button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 550;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field + .field { margin-top: var(--sp-4); }
.field-label { font-size: var(--fs-sm); color: var(--ink-2); }

.input,
.textarea,
.select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-md);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.input:focus,
.textarea:focus,
.select:focus { border-color: var(--accent); background: var(--surface); outline: none; }
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: none; padding-right: 32px; }
.hint { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- Сегмент-переключатель ---------- */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.seg button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 550; box-shadow: var(--shadow); }

/* ---------- Цели ---------- */
.goal { display: flex; flex-direction: column; gap: 10px; }
.goal-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.goal-title { font-size: var(--fs-md); font-weight: 550; overflow-wrap: anywhere; }
a.goal-title { display: inline-flex; align-items: center; min-height: 44px; }
.goal-pct { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--muted); }
.steps { display: flex; flex-direction: column; gap: 2px; }
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 2px 0;
  background: none;
  border: 0;
  text-align: left;
  color: var(--ink-2);
  font-size: var(--fs-md);
}
.step .box {
  width: 18px; height: 18px;
  border: 1.5px solid var(--line-2);
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: transparent;
  flex: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.step .box .i { width: 12px; height: 12px; stroke-width: 2.4; }
.step[aria-pressed="true"] { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.step[aria-pressed="true"] .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Таймер ---------- */
.timer { display: flex; flex-direction: column; align-items: center; gap: var(--sp-5); padding: var(--sp-2) 0; }
.ring { position: relative; width: min(260px, 68vw); aspect-ratio: 1; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--line); stroke-width: 3; }
.ring .fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s linear;
}
.ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.timer-time {
  font-family: var(--font-display);
  font-size: clamp(44px, 9vw, 60px);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.timer-label { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- Практики ---------- */
.practice {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.practice-title { font-size: var(--fs-md); font-weight: 600; }
.practice-desc { font-size: var(--fs-sm); color: var(--muted); line-height: 1.45; }
.breath {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
}
.breath-orb {
  width: min(220px, 60vw);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  transition: transform 0.6s var(--ease), background 0.6s var(--ease), border-color 0.6s var(--ease);
}
.breath-orb[data-phase="in"] { transform: scale(1.18); background: var(--accent-soft); border-color: var(--accent); }
.breath-orb[data-phase="hold"] { transform: scale(1.18); background: transparent; }
.breath-orb[data-phase="out"] { transform: scale(0.82); background: transparent; }
.breath-phase { font-family: var(--font-display); font-size: var(--fs-lg); }
.breath-count { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Дневник ---------- */
.entry { display: flex; flex-direction: column; gap: 8px; padding: var(--sp-4) 0; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.entry-date { font-size: var(--fs-sm); color: var(--muted); }
.entry-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Прогресс ---------- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); padding: var(--sp-4) var(--sp-4) var(--sp-4); display: flex; flex-direction: column; gap: 6px; }
.stat-value { font-family: var(--font-display); font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--fs-sm); color: var(--muted); }

.bars { display: flex; align-items: flex-end; gap: 5px; height: 132px; }
.bars > i {
  flex: 1;
  min-width: 0;
  background: var(--line);
  border-radius: 3px 3px 0 0;
  transition: height 0.4s var(--ease), background 0.15s var(--ease);
}
.bars > i[data-today="1"] { background: var(--accent); }
.bars-x { display: flex; justify-content: space-between; margin-top: 10px; font-size: var(--fs-micro); color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

.heat { display: grid; grid-template-columns: repeat(10, 18px); grid-template-rows: repeat(7, 18px); gap: 3px; }
.heat i { width: 18px; height: 18px; border-radius: 3px; background: var(--line); }
.heat i[data-i="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--line)); }
.heat i[data-i="2"] { background: color-mix(in srgb, var(--accent) 52%, var(--line)); }
.heat i[data-i="3"] { background: color-mix(in srgb, var(--accent) 76%, var(--line)); }
.heat i[data-i="4"] { background: var(--accent); }
.heat-legend { display: flex; align-items: center; gap: 6px; margin-top: 14px; font-size: var(--fs-micro); color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.heat-legend i { width: 9px; height: 9px; border-radius: 2px; background: var(--line); }
.heat-legend i[data-i="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--line)); }
.heat-legend i[data-i="2"] { background: color-mix(in srgb, var(--accent) 52%, var(--line)); }
.heat-legend i[data-i="3"] { background: color-mix(in srgb, var(--accent) 76%, var(--line)); }
.heat-legend i[data-i="4"] { background: var(--accent); }

/* ---------- Настройки ---------- */
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) 0;
  flex-wrap: wrap;
}
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.set-title { font-size: var(--fs-md); font-weight: 500; }
.set-desc { font-size: var(--fs-sm); color: var(--muted); max-width: 46ch; }
.set-control { flex: none; }
.set-row .input,
.set-row .select { max-width: 260px; min-width: 160px; }

.swatches { display: flex; gap: 4px; margin-right: -8px; }
/* 44 px цель нажатия, внутри — сам круг цвета */
.swatch {
  position: relative;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  padding: 0;
}
.swatch::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--sw, #000);
  border: 1px solid var(--line-2);
  transition: transform 0.15s var(--ease);
}
.swatch:hover::after { transform: scale(1.08); }
.swatch[aria-pressed="true"]::after { box-shadow: 0 0 0 2px var(--ink); transform: scale(1.04); }
/* «Тушь» в тёмной теме — светлая, иначе кружок не виден */
.swatch[data-accent-set="ink"]::after { background: var(--ink); }

/* ---------- Пустые состояния ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: var(--sp-5) 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  max-width: 44ch;
}
.empty-title { color: var(--ink); font-size: var(--fs-md); font-weight: 550; }

/* ---------- Модалка ---------- */
.sheet {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 720px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  overflow: auto;
  box-shadow: 0 24px 64px -24px rgba(10, 10, 9, 0.35);
}
.sheet::backdrop { background: rgba(12, 12, 10, 0.44); }
.sheet-inner { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); }
.sheet-title { font-family: var(--font-display); font-size: 22px; font-weight: 500; line-height: 1.15; }
.sheet-desc { font-size: var(--fs-sm); color: var(--muted); margin-top: 6px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Палитра команд */
.palette { width: min(520px, calc(100vw - 32px)); padding: 0; border-radius: var(--r-lg); }
.palette .input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 16px 18px; font-size: var(--fs-md); }
.palette ul { max-height: 320px; overflow: auto; padding: 6px; }
.palette li button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  font-size: var(--fs-md);
}
.palette li button:hover,
.palette li button[data-active="1"] { background: var(--surface-2); }
.palette li button .kbd { margin-left: auto; }
.palette-empty { padding: 18px; color: var(--muted); font-size: var(--fs-sm); }

/* ---------- Тосты ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast[data-open="1"] { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ---------- Нижняя навигация ---------- */
.tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tab .i { width: 20px; height: 20px; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] .i { stroke-width: 1.9; }

/* ---------- Адаптив ---------- */
@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .brand--mobile { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  #view { padding: 4px 16px 104px; }
  .tabbar { display: flex; }
  .page-head { padding: 12px 0 20px; }
  .btn--sm { min-height: 44px; }
  .seg button { min-height: 44px; }
  .card { padding: var(--sp-4); border-radius: var(--r-md); }
  .mood { gap: 4px; }
  .mood button { font-size: 11px; letter-spacing: -0.01em; }
  .sheet { width: 100vw; max-width: 100vw; margin: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .sheet { position: fixed; bottom: 0; top: auto; max-height: 90vh; }
  .sheet-actions .btn { flex: 1; }
}

@media (max-width: 430px) {
  /* На узком экране недельная сетка уходит: остаются серия и XP */
  .item-side .week { display: none; }
  .mood button { font-size: 10px; padding: 2px; letter-spacing: -0.02em; }
}

@media (max-width: 380px) {
  .greeting { font-size: 27px; }
  .btn { padding: 0 13px; }
}

/* Уважение к настройкам движения */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
