/* ============================================================================
   Трекер — ambient-редизайн. Дроп-ин замена web/style.css
   Рукописный CSS, ноль зависимостей. Классы и структура DOM — существующие.
   Три места, где нужна правка разметки, помечены ниже как [MARKUP N]
   и расписаны в snippets.html.
   ========================================================================= */

/* ── 1. Токены ─────────────────────────────────────────────────────────── */
:root {
  --bg: #0b0f16;
  --surface: #141a24;
  --surface-2: #1d2532;
  --line: #232c3a;            /* декоративная волосяная линия */
  --edge: #67748a;            /* функциональная граница, ≥3:1 */
  --text: #e9edf4;
  --muted: #9aa4b4;
  --accent: #e6b880;
  --accent-soft: rgba(230, 184, 128, .16);
  --done: #7fc9ae;
  --done-soft: rgba(127, 201, 174, .10);
  --on-accent: #120d06;
  --on-done: #04120d;
  --mood-1: #e0915f;
  --mood-2: #d5b268;
  --mood-3: #9aa4b4;
  --mood-4: #93c88f;
  --mood-5: #7fc9ae;

  --neutral-fill: rgba(154, 164, 180, .12);
  --empty-fill: rgba(154, 164, 180, .07);

  --radius: 16px;
  --radius-sm: 13px;
  --tap: 48px;
  --tabbar: 60px;

  --e-out:  cubic-bezier(.22, .61, .36, 1);
  --e-glow: cubic-bezier(.2, .8, .3, 1);
  --e-fade: cubic-bezier(.4, 0, .2, 1);
  --e-in:   cubic-bezier(.4, 0, 1, 1);
  --e-pop:  cubic-bezier(.2, .9, .3, 1);

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f2ee;
    --surface: #fbfaf8;
    --surface-2: #eae7e1;
    --line: #ddd8d0;
    --edge: #82796c;
    --text: #191d24;
    --muted: #5f6673;
    --accent: #8a5a1e;
    --accent-soft: rgba(138, 90, 30, .12);
    --done: #186b52;
    --done-soft: rgba(24, 107, 82, .10);
    --on-accent: #ffffff;
    --on-done: #ffffff;
    --mood-1: #a4531f;
    --mood-2: #79600f;
    --mood-3: #5f6673;
    --mood-4: #3a7c3f;
    --mood-5: #186b52;
    --neutral-fill: rgba(95, 102, 115, .12);
    --empty-fill: rgba(95, 102, 115, .07);
    color-scheme: light;
  }
}

/* Дуга кольца: локальная, ненаследуемая — иначе её изменение
   инвалидирует стили по всему дереву. [MARKUP 2] */
/* inherits:true обязателен: дугу рисует .headline-ring::before, а псевдоэлемент —
   потомок. С запретом наследования он получал initial-value 0deg, и кольцо
   не заполнялось никогда. Переменная живёт только на самом кольце, поэтому
   наследование ничего лишнего не задевает. */
@property --arc {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

/* ── 2. База ───────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar) + 24px + env(safe-area-inset-bottom));
  /* фокус не должен уезжать под фиксированный таб-бар */
  scroll-padding-bottom: calc(var(--tabbar) + 24px + env(safe-area-inset-bottom));
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

input, textarea, select {
  accent-color: var(--accent);
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--edge); border-radius: 12px; padding: 12px; width: 100%;
  min-height: 44px;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
:focus:not(:focus-visible) { outline: none; }

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

/* viewport-fit=cover отдаёт странице весь экран, включая вырез и «уши»
   в альбомной ориентации, поэтому отступы держим на env(safe-area-*). */
.app {
  max-width: 620px; margin: 0 auto; position: relative;
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 0
           calc(16px + env(safe-area-inset-left));
}
.hidden { display: none !important; }
[hidden] { display: none !important; }
.dim { opacity: .55; }

/* ── 3. Ambient-фон ────────────────────────────────────────────────────────
   Базовый режим — растворение (только opacity). Смещение добавляется
   отдельным блоком ниже и только при no-preference: масштабирование и
   панорамирование крупных объектов — вестибулярный триггер.
   will-change ровно на одном слое: каждый слой — текстура в памяти GPU. */
body::before, body::after, .app::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
}

body::before {
  background: radial-gradient(42% 34% at 28% 20%, rgba(64, 96, 168, .40), transparent 70%);
  animation: amb-1 19s ease-in-out infinite alternate;
  will-change: opacity;
}
body::after {
  background: radial-gradient(46% 36% at 78% 66%, rgba(226, 168, 102, .18), transparent 72%);
  animation: amb-2 23s ease-in-out infinite alternate;
}
.app::before {
  background: radial-gradient(60% 44% at 50% 104%, rgba(96, 150, 180, .22), transparent 70%);
  animation: amb-3 31s ease-in-out infinite alternate;
}

@media (prefers-color-scheme: light) {
  body::before { background: radial-gradient(42% 34% at 26% 20%, rgba(120, 150, 205, .22), transparent 70%); }
  body::after  { background: radial-gradient(46% 36% at 80% 70%, rgba(214, 168, 110, .26), transparent 72%); }
  .app::before { background: radial-gradient(60% 44% at 50% 106%, rgba(150, 175, 185, .22), transparent 70%); }
}

@keyframes amb-1 { from { opacity: .70 } to { opacity: 1 } }
@keyframes amb-2 { from { opacity: .50 } to { opacity: .85 } }
@keyframes amb-3 { from { opacity: .35 } to { opacity: .60 } }

/* Усиление движением — только если пользователь не просил его убрать.
   Амплитуда ≤2.5% смещения и ≤1.06 масштаба. */
@media (prefers-reduced-motion: no-preference) {
  body::before, body::after, .app::before { inset: -8%; }
  @keyframes amb-1 {
    from { opacity: .70; transform: translate3d(-2%, -1.5%, 0) scale(1.02) }
    to   { opacity: 1;   transform: translate3d(2.5%, 2%, 0)  scale(1.06) }
  }
  @keyframes amb-2 {
    from { opacity: .50; transform: translate3d(2%, 2.5%, 0)   scale(1.05) }
    to   { opacity: .85; transform: translate3d(-2.5%, -2%, 0) scale(1) }
  }
  @keyframes amb-3 {
    from { opacity: .35; transform: translate3d(0, 1.5%, 0)   scale(1) }
    to   { opacity: .60; transform: translate3d(1%, -2%, 0)   scale(1.04) }
  }
}

/* Пауза при скрытой вкладке — класс ставит motion.js */
html.is-hidden body::before,
html.is-hidden body::after,
html.is-hidden .app::before { animation-play-state: paused; }

/* ── 4. Шапка ──────────────────────────────────────────────────────────── */
header { padding: 8px 0 16px; }
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-nav h1 { font-size: 1.25rem; margin: 0; flex: 1; font-weight: 600; line-height: 1.2; }
.date-nav h1:focus-visible { outline-offset: 4px; }
.date-nav h1[data-quiet]:focus-visible { outline: none; }
.date-nav h1 span { color: var(--muted); font-weight: 400; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  color: var(--text); font-size: 1.375rem; flex-shrink: 0; position: relative; overflow: hidden;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn:disabled { color: var(--muted); opacity: .4; cursor: default; }

/* ── 5. Счётчик вечеров: кольцо вместо полосок ─────────────────────────── */
.headline {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.headline-top { display: grid; gap: 3px; min-width: 0; }
.headline-label { color: var(--muted); font-size: .8125rem; }
.headline-value { font-size: 1.625rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.headline-value small { font-size: .8125rem; color: var(--muted); font-weight: 400; }

.pips { display: none; }   /* полоски заменены дугой */

.headline-ring {           /* [MARKUP 2] */
  position: relative; width: 84px; height: 84px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
}
.headline-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--accent) 0 var(--arc), var(--surface-2) var(--arc) 360deg);
  -webkit-mask: radial-gradient(circle, transparent 33px, #000 33.5px);
          mask: radial-gradient(circle, transparent 33px, #000 33.5px);
  animation: ring-breath 17s ease-in-out infinite alternate;
}
.headline-ring.is-offscreen::before { animation-play-state: paused; }
.headline-ring .headline-value { position: relative; }
@keyframes ring-breath { from { opacity: .55 } to { opacity: .95 } }

/* пустое состояние: кольца ещё нет */
.headline-ring.is-empty::before {
  background: none; border: 1px solid var(--edge); animation: none; opacity: .7;
  -webkit-mask: none; mask: none;
}

.countdown {
  color: var(--muted); font-size: .8125rem; padding: 0 2px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.countdown button {
  color: var(--muted); text-decoration: underline dotted; font-size: .8125rem;
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px;
}

/* ── 6. Карточка трека ─────────────────────────────────────────────────── */
.track {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 9px; overflow: hidden;
}
.track.done {
  border-color: var(--done);
  background: linear-gradient(var(--done-soft), var(--done-soft)), var(--surface);
}
.track.zero  { border-color: var(--edge); }         /* отмечено нулём — данные, не провал */
.track.off   { opacity: .55; }                       /* вне расписания */

.track-row { display: flex; align-items: center; padding-right: 6px; }
.track-main {
  flex: 1; display: flex; align-items: center; gap: 12px;
  padding: 0 4px 0 14px; min-height: 64px; text-align: left; min-width: 0;
  position: relative; overflow: hidden;
}
.track-title { flex: 1; font-weight: 500; font-size: .97rem; min-width: 0; }
.track-sub { display: block; font-size: .8125rem; color: var(--muted); font-weight: 400; margin-top: 1px; }
.track-value { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9375rem; }
.track.done .track-value { color: var(--done); font-weight: 600; }

.chevron {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px;
  display: grid; place-items: center; color: var(--muted); font-size: 1.125rem;
  transition: transform .16s var(--e-fade);
}
.chevron[aria-expanded="true"] { transform: rotate(180deg); }
.chevron:active { background: var(--surface-2); }

.check {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--edge);
  display: grid; place-items: center; flex-shrink: 0; color: transparent; font-size: .9375rem;
}
.track.done .check { border-color: var(--done); background: var(--done); color: var(--on-done); }
.track.zero .check { color: var(--muted); }

/* тело: высоту анимирует WAAPI (motion.js), содержимое — opacity/translateY */
.track-body {
  padding: 0 14px 14px; display: flex; gap: 8px; flex-wrap: wrap;
  transition: opacity .14s var(--e-out) 60ms, transform .14s var(--e-out) 60ms;
}
.track-body.is-collapsing { opacity: 0; transform: translateY(4px); transition-delay: 0s; }

/* ── 7. Пресеты, счётчик, поля ─────────────────────────────────────────── */
.preset {
  min-height: var(--tap); min-width: 58px; padding: 0 15px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--edge);
  font-variant-numeric: tabular-nums; position: relative; overflow: hidden;
}
.preset.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.preset.wide { flex: 1; max-width: 140px; }

/* Ноль — нейтральное состояние, а не достижение */
.preset.zero { color: var(--muted); min-width: 56px; }
.preset.zero.on, .preset.zero[aria-pressed="true"] {
  background: var(--surface-2); border-color: var(--muted); color: var(--text); font-weight: 600;
}

.counter { display: flex; align-items: center; gap: 12px; }
.counter .preset { min-width: var(--tap); font-size: 1.25rem; }
.counter-box { display: grid; justify-items: center; min-width: 64px; }
.counter-value { font-size: 1.375rem; font-variant-numeric: tabular-nums; text-align: center; }
.counter-unit { font-size: .75rem; color: var(--muted); }

.manual-input { display: flex; gap: 8px; width: 100%; align-items: stretch; }
.manual-input input { flex: 1; }
.note-input { min-height: 76px; resize: vertical; width: 100%; }

/* ── 8. Шкала самочувствия: формы, а не только цвет ────────────────────── */
.mood-row { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.mood {
  flex: 1 1 44px; min-height: 52px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--edge);
  display: grid; place-items: center; position: relative; overflow: hidden;
}
.mood[aria-pressed="true"] { border-width: 2px; }

/* фигуры рисуются border'ами: ноль SVG, ноль зависимости от эмодзи-шрифта */
.mood i {
  display: block; background: var(--muted); font-style: normal;
  transition: none;
}
.mood[data-mood="1"] i { width: 0; height: 0; background: none;
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 14px solid var(--muted); }
.mood[data-mood="2"] i { width: 16px; height: 8px; border-radius: 0 0 16px 16px; }
.mood[data-mood="3"] i { width: 18px; height: 3px; border-radius: 2px; }
.mood[data-mood="4"] i { width: 16px; height: 8px; border-radius: 16px 16px 0 0; }
.mood[data-mood="5"] i { width: 0; height: 0; background: none;
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 14px solid var(--muted); }

.mood[data-mood="1"][aria-pressed="true"] { border-color: var(--mood-1); background: color-mix(in srgb, var(--mood-1) 18%, var(--surface-2)); }
.mood[data-mood="2"][aria-pressed="true"] { border-color: var(--mood-2); background: color-mix(in srgb, var(--mood-2) 18%, var(--surface-2)); }
.mood[data-mood="3"][aria-pressed="true"] { border-color: var(--mood-3); background: color-mix(in srgb, var(--mood-3) 18%, var(--surface-2)); }
.mood[data-mood="4"][aria-pressed="true"] { border-color: var(--mood-4); background: color-mix(in srgb, var(--mood-4) 18%, var(--surface-2)); }
.mood[data-mood="5"][aria-pressed="true"] { border-color: var(--mood-5); background: color-mix(in srgb, var(--mood-5) 18%, var(--surface-2)); }

.mood[data-mood="1"][aria-pressed="true"] i { border-top-color: var(--mood-1); }
.mood[data-mood="2"][aria-pressed="true"] i { background: var(--mood-2); }
.mood[data-mood="3"][aria-pressed="true"] i { background: var(--mood-3); }
.mood[data-mood="4"][aria-pressed="true"] i { background: var(--mood-4); }
.mood[data-mood="5"][aria-pressed="true"] i { border-bottom-color: var(--mood-5); }

.mood-label { width: 100%; font-size: .8125rem; color: var(--muted); }
.mood-label b { font-weight: 600; color: var(--text); }
.mood-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 7px; }

/* ── 9. Ореол тапа: только opacity ─────────────────────────── [MARKUP 1] */
.preset .ripple, .track-main .ripple, .mood .ripple, .icon-btn .ripple {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: currentColor; opacity: 0;
}
.is-tapped .ripple { animation: glow .41s var(--e-glow) 1; }
@keyframes glow { 0% { opacity: 0 } 22% { opacity: .16 } 100% { opacity: 0 } }

/* ── 10. Неделя: капли вместо таблицы ──────────────────────────────────── */
.grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.week { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: .8125rem; }
table.week th, table.week td { padding: 3px 2px; text-align: center; border-bottom: 0; }
table.week th { padding: 7px 2px; color: var(--muted); font-weight: 400; font-size: .6875rem; }
table.week th.name, table.week td.name {
  text-align: left; white-space: nowrap; color: var(--text); font-weight: 500;
  position: sticky; left: 0; background: var(--bg); padding-right: 8px; width: 88px;
}
table.week .name span { display: block; max-width: 78px; overflow: hidden; text-overflow: ellipsis; }
table.week th.today { color: var(--accent); font-weight: 700; }

/* Цель нажатия: 32×44 проходит SC 2.5.8 (24×24) с запасом.
   Зазор между каплями держим ≥2px по горизонтали: s + g ≥ 24. */
.cell {
  display: grid; place-items: center; width: 100%; min-width: 28px; height: 44px;
  color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums;
  background: transparent;
}
.cell > span {                       /* сама «капля» */
  min-width: 28px; height: 34px; padding: 0 2px; border-radius: 17px;
  display: grid; place-items: center;
}
.cell.on   > span { background: var(--done-soft); color: var(--done); font-weight: 600; }
.cell.zero > span { background: var(--neutral-fill); color: var(--muted); font-weight: 600; }
.cell.mood > span { background: var(--neutral-fill); font-size: 1rem; }
.cell.none > span, .cell:empty { background: transparent; }   /* пусто — пустое место */

@media (max-width: 360px) {
  .app { padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); }
  table.week .name span { max-width: 62px; }
  table.week th.name, table.week td.name { width: 76px; }
  table.week th, table.week td { padding-left: 1px; padding-right: 1px; }
  table.week .name { padding-right: 6px; }
  .cell, .cell > span { min-width: 30px; }   /* 30 + 2 зазор = 32 ≥ 24 */
}

/* Фигура самочувствия в капле недели — та же форма, что и на шкале */
.cell i { display: block; font-style: normal; background: currentColor; }
.cell i[data-mood="1"] { width: 0; height: 0; background: none;
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 9px solid currentColor; }
.cell i[data-mood="2"] { width: 12px; height: 6px; border-radius: 0 0 12px 12px; }
.cell i[data-mood="3"] { width: 13px; height: 3px; border-radius: 2px; }
.cell i[data-mood="4"] { width: 12px; height: 6px; border-radius: 12px 12px 0 0; }
.cell i[data-mood="5"] { width: 0; height: 0; background: none;
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 9px solid currentColor; }
.cell.mood[data-mood="1"] > span { color: var(--mood-1); }
.cell.mood[data-mood="2"] > span { color: var(--mood-2); }
.cell.mood[data-mood="3"] > span { color: var(--mood-3); }
.cell.mood[data-mood="4"] > span { color: var(--mood-4); }
.cell.mood[data-mood="5"] > span { color: var(--mood-5); }

/* ── 11. Вехи ──────────────────────────────────────────────────────────── */
.ach { padding: 14px; }
.ach.done { border-color: var(--done); }
.ach-row { display: flex; align-items: flex-start; gap: 12px; }
.ach-mark {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid var(--edge); display: grid; place-items: center;
  color: var(--muted); font-size: .875rem;
}
.ach-mark.on { border-color: var(--done); background: var(--done); color: var(--on-done); }
.ach-text { flex: 1; min-width: 0; }
.ach-title { display: block; font-weight: 500; }
.ach-status {
  color: var(--muted); font-size: .8125rem; white-space: nowrap;
  font-variant-numeric: tabular-nums; padding-top: 2px;
}
.ach.done .ach-status { color: var(--done); }
.bar { margin-top: 12px; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar span {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), var(--accent));
}

/* ── 12. Настройка треков и кнопки ─────────────────────────────────────── */
.section-title {
  color: var(--muted); font-size: .6875rem; text-transform: uppercase;
  letter-spacing: .1em; margin: 22px 0 10px; font-weight: 600;
}
.form-grid { display: grid; gap: 12px; }
.form-grid label { display: grid; gap: 5px; font-size: .8125rem; color: var(--muted); }
.form-grid label.inline {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  color: var(--text); font-size: .9375rem; min-height: 44px;
}
.form-grid label.inline input { width: 24px; height: 24px; min-height: 24px; flex-shrink: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  min-height: var(--tap); padding: 0 18px; border-radius: 14px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
  position: relative; overflow: hidden;
}
.btn.ghost { background: none; color: var(--text); border: 1px solid var(--edge); }
.btn.danger { background: var(--mood-1); color: var(--on-accent); }
.btn.danger:disabled { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); cursor: default; }
.btn.link {
  background: none; color: var(--muted); text-decoration: underline dotted;
  min-height: 44px; padding: 0 4px; font-weight: 400;
}
.track-admin {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px;
  width: 100%; min-height: 60px; text-align: left;
}

/* ── 13. Нижняя навигация ──────────────────────────────────────────────── */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
nav.tabs button {
  flex: 1; min-height: var(--tabbar); padding: 9px 0 10px; padding-bottom: 10px; color: var(--muted); font-size: .6875rem;
  display: grid; gap: 3px; justify-items: center; align-content: center;
}
nav.tabs button b { font-size: 1.0625rem; font-weight: 400; line-height: 1; }
nav.tabs button[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* смена экрана: только opacity, макет не двигается */
main > section { animation: view-in .18s var(--e-fade) 1; }
@keyframes view-in { from { opacity: 0 } to { opacity: 1 } }

/* ── 14. Экран токена, toast, диалоги ──────────────────────────────────── */
.gate {
  max-width: 340px; margin: 14vh auto; display: grid; gap: 14px;
  padding: env(safe-area-inset-top) calc(20px + env(safe-area-inset-right)) 0
           calc(20px + env(safe-area-inset-left));
}
.gate h1 { font-size: 1.375rem; margin: 0; }
.gate p { color: var(--muted); font-size: .875rem; margin: 0; }
.gate .error:not(:empty) {
  color: var(--text); background: var(--surface-2); border: 1px solid var(--mood-1);
  border-radius: 12px; padding: 10px 12px; font-size: .875rem;
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: var(--surface-2); border: 1px solid var(--edge); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-size: .8125rem; opacity: 0;
  transition: opacity .15s var(--e-in), transform .15s var(--e-in);
  pointer-events: none; z-index: 10; max-width: 90vw;
}
.toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
  transition: opacity .2s var(--e-pop), transform .2s var(--e-pop);
}

dialog {
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text);
  padding: 18px; width: min(92vw, 420px);
}
dialog[open] { animation: dlg-in .24s var(--e-pop) 40ms both; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog[open]::backdrop { animation: fade-in .2s var(--e-fade) 1; }
@keyframes dlg-in { from { opacity: 0; transform: scale(.98) } to { opacity: 1; transform: scale(1) } }
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }

dialog h2 { font-size: 1.125rem; margin: 0 0 2px; }
.fieldset {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 12px 10px; margin: 0;
  display: grid; gap: 2px;
}
.fieldset legend { font-size: .8125rem; color: var(--muted); padding: 0 4px; }
.fieldset label.inline { font-size: .9375rem; }

/* ── 15. Пустые состояния и возвращение после паузы ────────────────────── */
.empty {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 16px; text-align: center;
}
.empty-title { font-weight: 500; font-size: .9375rem; }
.empty-sub { color: var(--muted); font-size: .8125rem; margin-top: 5px; }
.empty-ring { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--edge); margin: 0 auto 14px; opacity: .7; }

/* строка «вернулся после паузы»: факт и ссылка, ни одной оценки */
.resume {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 9px; font-size: .875rem; color: var(--muted);
}
.resume b { color: var(--text); font-weight: 500; }
.resume .btn.link { color: var(--accent); }

.week-empty .cell > span { background: var(--empty-fill); }   /* ряд капель без данных */

/* ── 15b. Полоска последних дней: отметить прошедший день одним тапом ──── */
.date-strip {
  display: flex; gap: 6px; margin: 0 0 10px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.date-strip::-webkit-scrollbar { display: none; }
.day-chip {
  flex: 1 0 auto; min-width: 44px; min-height: 52px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; gap: 2px; padding: 4px 6px;
  color: var(--muted); font-size: .6875rem; position: relative; overflow: hidden;
}
.day-chip b { font-size: .9375rem; font-weight: 600; color: var(--text); line-height: 1; }
.day-chip[aria-current="date"] { border-color: var(--accent); color: var(--accent); }
.day-chip[aria-current="date"] b { color: var(--accent); }
.day-chip .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--edge); }
.day-chip.filled .dot { background: var(--done); }

/* ── 16. Reduced motion ────────────────────────────────────────────────────
   .001s, а НЕ none: иначе не приходит animationend, на котором висит
   сворачивание карточки. Ambient превращается в статичную композицию. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001s !important;
    scroll-behavior: auto !important;
  }
  body::before {
    background:
      radial-gradient(42% 34% at 30% 28%, rgba(64, 96, 168, .42), transparent 70%),
      radial-gradient(46% 36% at 74% 70%, rgba(226, 168, 102, .18), transparent 72%),
      radial-gradient(60% 44% at 50% 106%, rgba(96, 150, 180, .22), transparent 70%);
    opacity: 1;
  }
  body::after, .app::before { display: none; }
}

@media (prefers-reduced-motion: reduce) and (prefers-color-scheme: light) {
  body::before {
    background:
      radial-gradient(42% 34% at 30% 28%, rgba(120, 150, 205, .22), transparent 70%),
      radial-gradient(46% 36% at 74% 70%, rgba(214, 168, 110, .26), transparent 72%),
      radial-gradient(60% 44% at 50% 106%, rgba(150, 175, 185, .22), transparent 70%);
  }
}
