/* Цвета берутся из темы Telegram (--tg-theme-*), запасные значения — для браузера. */
:root {
  --fb-bg: #f1f2f6;
  --fb-card: #ffffff;
  --fb-text: #17181c;
  --fb-hint: #8b909a;
  --fb-accent: #2779a7;
  --fb-accent-text: #ffffff;
  --fb-danger: #e5484d;

  --bg: var(--tg-theme-secondary-bg-color, var(--fb-bg));
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-card)));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --accent: var(--tg-theme-button-color, var(--fb-accent));
  --accent-text: var(--tg-theme-button-text-color, var(--fb-accent-text));
  --link: var(--tg-theme-link-color, var(--accent));
  --danger: var(--tg-theme-destructive-text-color, var(--fb-danger));
  --soft: rgba(128, 132, 145, .14);
  --sep: rgba(128, 132, 145, .2);
  --accent-soft: rgba(39, 121, 167, .12);
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --radius: 16px;
  color-scheme: light dark;
}
@supports (color: color-mix(in srgb, red, blue)) {
  :root { --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent); }
}
@media (prefers-color-scheme: dark) {
  :root {
    --fb-bg: #0e0f13;
    --fb-card: #1b1c22;
    --fb-text: #f1f2f5;
    --fb-hint: #8c8f99;
    --fb-accent: #4aa3dc;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; flex: none; }
[hidden] { display: none !important; }

.app { touch-action: pan-y; max-width: 560px; margin: 0 auto; padding-bottom: calc(110px + var(--safe-bottom)); }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 6px;
  background: var(--bg);
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--card); color: var(--hint);
}
.icon-btn svg { width: 20px; height: 20px; }
.month-title {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 21px; font-weight: 700; letter-spacing: -.01em;
  margin-right: auto;
}
.month-title svg { width: 18px; height: 18px; color: var(--hint); }
.pill {
  height: 32px; padding: 0 14px; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 14px; font-weight: 600;
}

/* ---------- неделя ---------- */
.week {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  padding: 6px 12px 10px;
  position: sticky; top: 54px; z-index: 4; background: var(--bg);
  touch-action: pan-y;
}
.day {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 0 6px; border-radius: 14px;
  transition: background .15s, color .15s;
}
.day .dow { font-size: 12px; color: var(--hint); font-weight: 500; }
.day .num { font-size: 18px; font-weight: 600; line-height: 1.15; }
.day .dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.day .num { position: relative; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.day { padding-bottom: 6px; }
.day .dot.todo { background: var(--accent); }
.day .dot.done { background: #22c55e; }
.day.today .num { color: var(--accent); }
.day.sel { background: var(--accent); color: var(--accent-text); }
.day.sel .dow { color: var(--accent-text); opacity: .8; }
.day.sel .num { color: var(--accent-text); }
.day.sel .dot.todo, .day.sel .dot.done { background: var(--accent-text); }
.week.slide-l { animation: slideL .22s ease; }
.week.slide-r { animation: slideR .22s ease; }
@keyframes slideL { from { transform: translateX(24px); opacity: .3; } }
@keyframes slideR { from { transform: translateX(-24px); opacity: .3; } }

/* ---------- списки ---------- */
.section { margin: 0 16px; }
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 4px 8px;
  font-size: 13px; font-weight: 600; color: var(--hint);
  text-transform: uppercase; letter-spacing: .04em;
}
.section-head .count { text-transform: none; letter-spacing: 0; font-weight: 500; }
.section-head.danger { color: var(--danger); }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; position: relative;
  min-height: 54px;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 52px; right: 0;
  height: 1px; background: var(--sep); transform: scaleY(.6);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 16px; word-break: break-word; }
.row-meta {
  display: flex; flex-wrap: wrap; gap: 3px 10px; margin-top: 3px;
  font-size: 13px; color: var(--hint);
}
.meta { display: inline-flex; align-items: center; gap: 4px; }
.meta svg { width: 13px; height: 13px; }
.meta.late { color: var(--danger); }
.row.done .row-title { color: var(--hint); text-decoration: line-through; }
.row.done .row-meta { opacity: .7; }

.check {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 2px solid var(--c, var(--accent));
  display: grid; place-items: center; color: #fff;
  transition: background .15s, transform .15s;
}
.check svg { width: 15px; height: 15px; opacity: 0; transform: scale(.5); transition: .15s; }
.check.on { background: var(--c, var(--accent)); }
.check.on svg { opacity: 1; transform: none; }
.check:active { transform: scale(.88); }

.small-btn {
  height: 30px; padding: 0 12px; border-radius: 15px; flex: none;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600;
}

.done-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 4px 8px; font-size: 13px; font-weight: 600; color: var(--hint);
  text-transform: uppercase; letter-spacing: .04em;
}
.done-toggle svg { width: 14px; height: 14px; transition: transform .2s; }
.done-toggle.open svg { transform: rotate(180deg); }

/* ---------- привычки ---------- */
.habits {
  touch-action: pan-x pan-y;
  display: flex; gap: 10px; overflow-x: auto;
  padding: 0 16px 2px; margin: 0 -16px;
  scroll-snap-type: x proximity; scroll-padding: 0 16px; scrollbar-width: none;
}
.habits::-webkit-scrollbar { display: none; }
.habit {
  flex: 0 0 108px; scroll-snap-align: start;
  background: var(--card); border-radius: var(--radius);
  padding: 12px 8px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  text-align: center;
}
.habit-ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid var(--c); display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: var(--c);
  transition: background .18s, transform .15s;
  position: relative;
}
.habit-ring svg { width: 26px; height: 26px; color: #fff; }
.habit.done .habit-ring { background: var(--c); }
.habit-ring:active { transform: scale(.9); }
.habit-title {
  font-size: 13px; font-weight: 500; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.5em; word-break: break-word;
}
.habit-streak { font-size: 12px; color: var(--hint); min-height: 15px; }

/* ---------- баннер / пусто / загрузка ---------- */
.banner {
  margin: 10px 16px 0; padding: 12px 14px;
  border-radius: var(--radius); background: var(--accent-soft);
  display: flex; align-items: center; gap: 12px;
  font-size: 14px;
}
.banner b { display: block; font-size: 15px; margin-bottom: 2px; }
.banner .small-btn { background: var(--accent); color: var(--accent-text); }
.empty { padding: 56px 32px 24px; text-align: center; color: var(--hint); }
.empty svg { width: 84px; height: 84px; margin: 0 auto 14px; color: var(--accent); opacity: .85; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.loading { display: grid; place-items: center; padding: 80px 0; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.fatal { padding: 80px 32px; text-align: center; color: var(--hint); }
.fatal b { display: block; font-size: 18px; color: var(--text); margin-bottom: 6px; }

/* ---------- кнопка добавления ---------- */
.fab {
  position: fixed; z-index: 10;
  right: max(18px, calc(50% - 280px + 18px));
  bottom: calc(22px + var(--safe-bottom));
  width: 58px; height: 58px; border-radius: 29px;
  background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  transition: transform .15s;
}
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: scale(.92); }

/* ---------- шторки ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .42);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 560px; margin: 0 auto;
  background: var(--bg); border-radius: 20px 20px 0 0;
  max-height: 92vh; display: flex; flex-direction: column;
  transform: translateY(105%); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  visibility: hidden;
}
.sheet.open { transform: none; visibility: visible; }
.sheet-full { height: 94vh; }
.sheet-head {
  display: grid; grid-template-columns: 84px 1fr 84px; align-items: center;
  padding: 14px 12px 8px; flex: none;
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; }
.link-btn { color: var(--link); font-size: 16px; justify-self: start; padding: 4px; }
.link-btn.end { justify-self: end; font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 4px 16px 20px; flex: 1; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-foot { padding: 10px 16px calc(12px + var(--safe-bottom)); flex: none; }

.btn-primary {
  width: 100%; height: 50px; border-radius: 14px;
  background: var(--accent); color: var(--accent-text);
  font-size: 16px; font-weight: 600;
}
.btn-primary:disabled { opacity: .55; }
.btn-plain {
  width: 100%; padding: 14px; border-radius: 14px;
  background: var(--card); font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-plain.accent { color: var(--link); font-weight: 600; }
.btn-plain.danger { color: var(--danger); }
.btn-plain svg { width: 18px; height: 18px; }

/* ---------- форма ---------- */
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  background: var(--soft); border-radius: 12px; padding: 3px;
  margin-bottom: 12px;
}
.seg button { height: 34px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--hint); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.input-card { background: var(--card); border-radius: var(--radius); }
.title-input, .note-input {
  width: 100%; border: 0; outline: none; background: transparent; display: block;
  padding: 14px 14px 6px; font-size: 18px; font-weight: 600;
}
.note-input { font-size: 15px; font-weight: 400; padding: 6px 14px 14px; resize: none; min-height: 44px; color: var(--text); }
.title-input::placeholder, .note-input::placeholder { color: var(--hint); font-weight: 400; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.colors { display: flex; gap: 12px; padding: 14px 4px 4px; flex-wrap: wrap; }
.color { width: 30px; height: 30px; border-radius: 50%; background: var(--c); transition: box-shadow .15s; }
.color.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c); }

.group-label {
  padding: 18px 4px 8px; font-size: 13px; font-weight: 600; color: var(--hint);
  text-transform: uppercase; letter-spacing: .04em;
}
.field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px; min-height: 50px; position: relative;
}
.field + .field::before, .card > * + .chips::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--sep); transform: scaleY(.6);
}
.field-label { font-size: 16px; }
.field-label small { display: block; font-size: 12px; color: var(--hint); }
.field-control { display: flex; align-items: center; gap: 6px; }
.ctl {
  -webkit-appearance: none; appearance: none;
  border: 0; outline: none; border-radius: 9px;
  background: var(--soft); padding: 7px 10px; font-size: 15px; min-height: 34px;
  min-width: 0; text-align: center;
}
select.ctl { padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--hint) 50%), linear-gradient(135deg, var(--hint) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat; text-align: left; }
.clear-btn { width: 26px; height: 26px; border-radius: 13px; background: var(--soft); color: var(--hint); display: grid; place-items: center; }
.clear-btn svg { width: 12px; height: 12px; }
.ghost { color: var(--link); font-size: 15px; font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; position: relative; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 17px;
  background: var(--soft); font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.chip.on { background: var(--accent); color: var(--accent-text); }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 0 14px 12px; }
.wd { height: 38px; border-radius: 11px; background: var(--soft); font-size: 14px; font-weight: 600; }
.wd.on { background: var(--accent); color: var(--accent-text); }

.stepper { display: inline-flex; align-items: center; background: var(--soft); border-radius: 10px; }
.stepper button { width: 38px; height: 34px; font-size: 21px; color: var(--accent); font-weight: 500; }
.stepper button:disabled { color: var(--hint); opacity: .5; }
.stepper span { min-width: 26px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.rem-card { background: var(--card); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.rem-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 2px; font-size: 13px; color: var(--hint); font-weight: 600;
}
.rem-head .clear-btn { width: 24px; height: 24px; }
.rem-summary {
  margin: 2px 14px 12px; padding: 9px 12px; border-radius: 11px;
  background: var(--accent-soft); color: var(--text); font-size: 13px; line-height: 1.4;
}
.rem-summary b { font-weight: 600; }
.hint-text { padding: 6px 4px 0; font-size: 13px; color: var(--hint); }
.warn {
  padding: 10px 12px; border-radius: 12px; margin-bottom: 10px;
  background: rgba(245, 158, 11, .14); font-size: 13px;
}

/* ---------- календарь ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px; }
.cal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.cal-nav { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--accent); }
.cal-nav svg { width: 20px; height: 20px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 4px 12px 8px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--hint); padding: 4px 0; font-weight: 500; }
.cal-day {
  aspect-ratio: 1 / 1; border-radius: 12px; font-size: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.cal-day.out { opacity: .35; }
.cal-day.today { color: var(--accent); font-weight: 700; }
.cal-day.sel { background: var(--accent); color: var(--accent-text); }
.cal-day .dot { width: 5px; height: 5px; border-radius: 50%; }
.cal-day .dot.todo { background: var(--accent); }
.cal-day .dot.done { background: #22c55e; }
.cal-day.sel .dot { background: var(--accent-text); }

/* ---------- меню добавления ---------- */
.add-options { display: grid; gap: 10px; padding: 4px 16px 8px; }
.add-opt {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--card); border-radius: var(--radius); padding: 14px;
}
.add-opt .ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: #fff; flex: none; }
.add-opt .ico svg { width: 22px; height: 22px; }
.add-opt b { display: block; font-size: 16px; font-weight: 600; color: var(--text); }
.add-opt .sub { font-size: 13px; color: var(--hint); }

/* ---------- уведомление ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); /* инверсия — читается в любой теме */
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; max-width: 86vw; text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- полноэкранные экраны: выбор языка, оплата ---------- */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.screen-inner {
  width: 100%; max-width: 420px; padding: 32px 20px calc(24px + var(--safe-bottom));
  display: flex; flex-direction: column; align-items: stretch; text-align: center;
}
.screen-inner h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.screen-icon {
  width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 18px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.screen-icon svg { width: 36px; height: 36px; }
.screen-icon.star { background: rgba(245, 158, 11, .16); color: #f59e0b; }
.screen-text { margin: 0 0 18px; color: var(--hint); font-size: 15px; line-height: 1.45; }
.lang-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.lang-opt {
  height: 52px; border-radius: 14px; background: var(--card);
  font-size: 16px; font-weight: 500; transition: background .15s, color .15s;
}
.lang-opt.on { background: var(--accent); color: var(--accent-text); }
.features {
  list-style: none; margin: 0 0 20px; padding: 6px 14px;
  background: var(--card); border-radius: var(--radius); text-align: start;
}
.features li { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 15px; }
.features li + li { border-top: 1px solid var(--sep); }
.features svg { width: 18px; height: 18px; color: #22c55e; }
.price { font-size: 30px; font-weight: 700; margin-bottom: 14px; }
.price span { font-size: 16px; font-weight: 500; color: var(--hint); }
.hint-text.center { text-align: center; padding-top: 12px; }
.terms-link { color: var(--link, var(--accent)); text-decoration: none; white-space: nowrap; }
.btn-primary { display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary svg { width: 18px; height: 18px; }
.banner.trial { background: rgba(245, 158, 11, .14); }
.banner.trial .small-btn { background: #f59e0b; color: #fff; }

/* ---------- письмо справа налево (арабский) ---------- */
[dir="rtl"] .fab { right: auto; left: max(18px, calc(50% - 280px + 18px)); }
[dir="rtl"] .row + .row::before { left: 0; right: 52px; }
[dir="rtl"] .field + .field::before, [dir="rtl"] .card > * + .chips::before { left: 0; right: 14px; }
[dir="rtl"] .add-opt { text-align: right; }
[dir="rtl"] select.ctl { padding-right: 10px; padding-left: 26px; background-position: 9px 50%, 14px 50%; text-align: right; }
[dir="rtl"] .link-btn { justify-self: end; }
[dir="rtl"] .link-btn.end { justify-self: start; }
[dir="rtl"] .cal-nav svg, [dir="rtl"] .done-toggle svg { transform: scaleX(-1); }

/* промокод и приглашения */
.promo-row { display: flex; gap: 8px; align-items: center; }
.promo-card { padding: 10px 12px; }
.promo-input { flex: 1; min-width: 0; text-transform: uppercase; text-align: start; }
.promo-link { display: block; margin: 12px auto 0; }
.promo-pw { margin-top: 12px; }
.promo-input::placeholder { text-transform: none; }

/* ---------- серия и прогресс дня ---------- */
:root { --ring: var(--accent); --ring-track: rgba(127, 127, 127, .18); --fire: #f97316; }
.ring::before, .big-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--ring-track) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  transition: background .3s;
}
.ring.full { --ring: #22c55e; }
.day.sel .ring { --ring: var(--accent-text); --ring-track: rgba(255, 255, 255, .3); }
.day.sel .ring.full { --ring: #bbf7d0; }

.streak-chip {
  height: 32px; padding: 0 12px 0 9px; border-radius: 16px; display: inline-flex; align-items: center; gap: 3px;
  background: var(--card); color: var(--hint); font-size: 15px; font-weight: 700;
}
.streak-chip .flame { filter: grayscale(1); opacity: .55; transition: filter .3s, opacity .3s; }
.streak-chip.on { color: var(--fire); background: rgba(249, 115, 22, .14); }
.streak-chip.on .flame { filter: none; opacity: 1; }
.streak-chip.pop { animation: pop .6s ease; }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.3); } 100% { transform: scale(1); } }

.day-card {
  position: relative; width: calc(100% - 32px); display: flex; align-items: center; gap: 14px; text-align: start;
  background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin: 10px 16px 0;
}
.big-ring {
  position: relative; flex: none; width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center; font-size: 17px; --ring-track: rgba(127, 127, 127, .16); white-space: nowrap;
}
.big-ring::before {
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5.5px));
}
.big-ring small { color: var(--hint); font-size: 12px; font-weight: 500; }
.big-ring svg { width: 24px; height: 24px; color: #22c55e; }
.day-card.complete .big-ring { --ring: #22c55e; }
.day-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.day-card-text b { font-size: 16px; }
.day-card-text span { font-size: 13px; color: var(--hint); }
.day-card-flame { font-weight: 700; color: var(--hint); font-size: 15px; white-space: nowrap; }
.day-card-flame:not(.on) { filter: grayscale(1); opacity: .6; }
.day-card-flame.on { color: var(--fire); }
.day-card.celebrate .big-ring { animation: pop .6s ease; }
.spark {
  position: absolute; left: 41px; top: 50%; pointer-events: none; font-size: 16px; opacity: 0;
  animation: spark .9s ease-out forwards;
}
@keyframes spark {
  0% { transform: translate(0, 0) scale(.4); opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) scale(1.1); opacity: 0; }
}

.streak-hero { text-align: center; padding: 8px 0 18px; }
.hero-flame { font-size: 64px; line-height: 1; filter: grayscale(1); opacity: .5; }
.streak-hero.on .hero-flame { filter: none; opacity: 1; animation: flicker 2.4s ease-in-out infinite; }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.06) rotate(-2deg); } }
.hero-num { font-size: 44px; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.streak-hero.on .hero-num { color: var(--fire); }
.hero-label { font-size: 15px; color: var(--hint); }
.hero-hint { font-size: 14px; margin-top: 8px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 22px; }
.stat span { font-size: 13px; color: var(--hint); }
.heat-card { padding: 14px; }
.heat { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(7, auto); grid-auto-flow: column; gap: 4px; }
.cell { display: block; aspect-ratio: 1; border-radius: 4px; background: var(--ring-track); }
.cell.blank { background: transparent; }
.cell.c-none, .cell.c-empty { background: var(--ring-track); opacity: .6; }
.cell.c-done { background: #22c55e; }
.cell.c-frozen { background: #60a5fa; }
.cell.c-missed { background: rgba(239, 68, 68, .45); }
.cell.c-today { box-shadow: inset 0 0 0 2px var(--accent); background: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 12px; color: var(--hint); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .cell { width: 11px; height: 11px; }

/* ---------- темы: акцентный цвет и лёгкий оттенок фона (светлая схема) ---------- */
html[data-theme] { --accent: var(--th); --link: var(--th); --accent-text: #fff; }
html[data-theme][data-scheme="light"] { --bg: var(--th-bg); }
html[data-theme="ocean"]    { --th: #0284c7; --th-bg: #eef5fa; }
html[data-theme="sunset"]   { --th: #ea580c; --th-bg: #fbf3ee; }
html[data-theme="forest"]   { --th: #15803d; --th-bg: #eff6f0; }
html[data-theme="lavender"] { --th: #7c3aed; --th-bg: #f4f1fb; }
html[data-theme="mint"]     { --th: #0d9488; --th-bg: #edf7f6; }
html[data-theme="rose"]     { --th: #e11d48; --th-bg: #fbf0f2; }
html[data-theme="graphite"] { --th: #334155; --th-bg: #f1f3f6; }
html[data-scheme="dark"][data-theme="ocean"]    { --th: #38bdf8; --accent-text: #06263a; }
html[data-scheme="dark"][data-theme="sunset"]   { --th: #fb923c; --accent-text: #3a1505; }
html[data-scheme="dark"][data-theme="forest"]   { --th: #4ade80; --accent-text: #052e16; }
html[data-scheme="dark"][data-theme="lavender"] { --th: #a78bfa; --accent-text: #1e0b4b; }
html[data-scheme="dark"][data-theme="mint"]     { --th: #2dd4bf; --accent-text: #042f2e; }
html[data-scheme="dark"][data-theme="rose"]     { --th: #fb7185; --accent-text: #3f0613; }
html[data-scheme="dark"][data-theme="graphite"] { --th: #cbd5e1; --accent-text: #0f172a; }
.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 12px 10px; }
.theme-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--hint); padding: 4px 0; }
.theme-opt span { width: 36px; height: 36px; border-radius: 50%; background: var(--sw); transition: box-shadow .15s, transform .15s; }
.theme-opt.on { color: var(--text); font-weight: 600; }
.theme-opt.on span { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); transform: scale(.92); }

/* ---------- иконки привычек ---------- */
.habit-emoji { font-size: 26px; line-height: 1; }
.habit.done .habit-emoji { display: none; }
.icons { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; background: var(--card); border-radius: var(--radius); padding: 10px; }
.icon-opt { aspect-ratio: 1; border-radius: 12px; font-size: 21px; display: grid; place-items: center; transition: background .15s; }
.icon-opt:first-child { font-size: 14px; font-weight: 700; color: var(--hint); }
.icon-opt.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- подзадачи ---------- */
.subs { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.sub { display: flex; align-items: center; gap: 8px; font-size: 14px; text-align: start; padding: 3px 0; color: var(--text); }
.sub.on span:last-child { color: var(--hint); text-decoration: line-through; }
.sub-box { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--sep); display: grid; place-items: center; flex: none; transition: .15s; }
.sub.on .sub-box { background: var(--accent); border-color: var(--accent); }
.sub-box svg { width: 11px; height: 11px; color: var(--accent-text); }
.checklist-ed { padding: 4px 0; }
.cl-row { display: flex; align-items: center; gap: 10px; padding: 6px 14px; }
.cl-input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 15px; padding: 6px 0; }
.cl-add { display: flex; align-items: center; gap: 8px; color: var(--link); font-size: 15px; padding: 10px 14px; width: 100%; }
.cl-add svg { width: 18px; height: 18px; }

/* ---------- свайпы ---------- */
.swipe { position: relative; overflow: hidden; }
.swipe + .swipe .row::before {
  content: ""; position: absolute; top: 0; left: 52px; right: 0; height: 1px; background: var(--sep); transform: scaleY(.6);
}
.swipe .row { background: var(--card); transition: transform .25s cubic-bezier(.2, .8, .2, 1); z-index: 1; }
.swipe.swiping .row { transition: none; }
.swipe-bg { position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: center; padding: 0 18px;
  font-size: 14px; font-weight: 600; color: #fff; opacity: 0; }
.swipe-bg span { display: inline-flex; align-items: center; gap: 6px; opacity: .55; transition: opacity .15s, transform .15s; }
.swipe-bg svg { width: 18px; height: 18px; }
.swipe.to-l .swipe-bg { opacity: 1; background: #22a06b; }
.swipe.to-r .swipe-bg { opacity: 1; background: var(--danger); }
.swipe.to-l .sw-r, .swipe.to-r .sw-l { visibility: hidden; }
.swipe.armed .swipe-bg span { opacity: 1; transform: scale(1.06); }

/* ---------- анимации ---------- */
#list.appear > * { animation: fadeUp .28s ease both; }
#list.appear > *:nth-child(2) { animation-delay: .04s; }
#list.appear > *:nth-child(3) { animation-delay: .08s; }
#list.appear > *:nth-child(4) { animation-delay: .12s; }
#list.appear > *:nth-child(n+5) { animation-delay: .16s; }
#list.slide-l { animation: slideL .24s ease; }
#list.slide-r { animation: slideR .24s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }
.row-title { background: linear-gradient(currentColor, currentColor) 0 55% / 0 1.5px no-repeat; transition: background-size .3s ease, color .3s; }
.row.done .row-title { text-decoration: none; background-size: 100% 1.5px; }
.habit, .card, .day-card { transition: transform .15s; }
.habit:active, .art-card:active { transform: scale(.97); }
.check.on { animation: pop .35s ease; }

/* ---------- пустой день ---------- */
.empty-btn { width: auto; display: inline-flex; align-items: center; gap: 8px; padding: 0 22px; margin-top: 18px; }
.empty-btn svg { width: 20px; height: 20px; }
.empty-tip { display: flex; gap: 8px; align-items: flex-start; text-align: start; margin: 22px auto 0; max-width: 320px;
  background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 13px; color: var(--hint); }
.empty-tip svg { width: 18px; height: 18px; color: var(--accent); margin-top: 1px; }

/* ---------- быстрое добавление ---------- */
.quick { display: flex; gap: 8px; margin: 2px 16px 0; background: var(--card); border-radius: 14px; padding: 6px 6px 6px 14px; }
.quick-input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 15px; }
.quick-go { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.quick-go svg { width: 18px; height: 18px; }
.quick-hint { font-size: 12px; color: var(--hint); margin: 6px 20px 12px; }

/* ---------- онбординг ---------- */
.ob-ico { font-size: 72px; line-height: 1; margin-bottom: 18px; animation: fadeUp .4s ease both; }
.ob h1, .ob .screen-text { animation: fadeUp .4s ease both; animation-delay: .05s; }
.ob-dots { display: flex; justify-content: center; gap: 6px; margin: 4px 0 22px; }
.ob-dots i { width: 7px; height: 7px; border-radius: 4px; background: var(--sep); transition: width .2s, background .2s; }
.ob-dots i.on { width: 22px; background: var(--accent); }
.ob-skip { display: block; margin: 12px auto 0; font-size: 15px; color: var(--hint); }

/* ---------- достижения ---------- */
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badge { background: var(--card); border-radius: 14px; padding: 12px 8px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.badge-ico { font-size: 30px; line-height: 1.1; filter: grayscale(1); opacity: .35; }
.badge.on .badge-ico { filter: none; opacity: 1; }
.badge b { font-size: 12.5px; line-height: 1.2; }
.badge span { font-size: 11px; color: var(--hint); line-height: 1.25; }
.badge small { font-size: 11px; color: var(--hint); }
.badge-bar { width: 80%; height: 4px; border-radius: 2px; background: var(--ring-track); overflow: hidden; margin-top: 4px; }
.badge-bar i { display: block; height: 100%; background: var(--accent); }

/* ---------- статьи ---------- */
.art-btn {
  position: fixed; z-index: 10;
  left: max(18px, calc(50% - 280px + 18px));
  bottom: calc(29px + var(--safe-bottom));
  height: 44px; padding: 0 16px 0 13px; border-radius: 22px;
  background: var(--card); color: var(--text); font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}
.art-btn svg { width: 20px; height: 20px; color: var(--accent); }
.art-btn:active { transform: scale(.95); }
.art-intro { color: var(--hint); font-size: 14px; margin: 0 4px 12px; }
.art-list { display: grid; gap: 10px; }
.art-card { display: flex; gap: 14px; align-items: flex-start; text-align: start; background: var(--card); border-radius: var(--radius); padding: 14px; transition: transform .15s; }
.art-emoji { width: 48px; height: 48px; flex: none; border-radius: 14px; display: grid; place-items: center; font-size: 26px;
  background: color-mix(in srgb, var(--c) 16%, transparent); }
.art-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.art-text b { font-size: 16px; line-height: 1.25; }
.art-text span { font-size: 13.5px; color: var(--hint); line-height: 1.35; }
.art-text small { font-size: 12px; color: var(--c); font-weight: 600; margin-top: 2px; }
.article { padding-bottom: 12px; }
.art-hero { height: 120px; border-radius: 20px; display: grid; place-items: center; font-size: 60px; margin-bottom: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 30%, transparent), color-mix(in srgb, var(--c) 8%, transparent)); }
.article h1 { font-size: 24px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
.art-meta { color: var(--c); font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.art-lead { font-size: 17px; line-height: 1.5; font-weight: 500; margin: 0 0 14px; }
.article p, .article li { font-size: 16px; line-height: 1.6; }
.article p { margin: 0 0 14px; }
.article h3 { font-size: 18px; margin: 22px 0 8px; }
.article ul { margin: 0 0 14px; padding-inline-start: 20px; }
.article li { margin-bottom: 6px; }
.article blockquote { margin: 0 0 14px; padding: 12px 16px; border-radius: 14px; background: var(--card);
  border-inline-start: 4px solid var(--c); font-style: italic; }
.art-try { display: flex; flex-direction: column; gap: 4px; background: color-mix(in srgb, var(--c) 12%, var(--card));
  border-radius: 16px; padding: 14px 16px; margin: 20px 0 16px; font-size: 15px; line-height: 1.45; }
.art-try b { color: var(--c); }
.sheet-head .link-btn svg { width: 22px; height: 22px; }

/* ---------- сторис и готовые наборы ---------- */
.share-btn { margin-top: 14px; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px;
  border-radius: 20px; background: linear-gradient(135deg, #ff8a1f, #e8457a); color: #fff; font-weight: 600; font-size: 15px; }
.share-btn svg { width: 18px; height: 18px; }
.share-btn:disabled { opacity: .6; }
.empty-tpl { display: block; margin: 12px auto 0; font-weight: 600; }
.tpl-list { display: flex; flex-direction: column; gap: 10px; }
.tpl-card { display: flex; gap: 14px; align-items: center; text-align: start; background: var(--card); border-radius: var(--radius);
  padding: 14px; transition: transform .15s; }
.tpl-card:active { transform: scale(.97); }
.tpl-emoji { width: 48px; height: 48px; flex: none; border-radius: 14px; display: grid; place-items: center; font-size: 26px;
  background: color-mix(in srgb, var(--c) 16%, transparent); }
.tpl-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tpl-text b { font-size: 16px; }
.tpl-text span { font-size: 13.5px; color: var(--hint); line-height: 1.35; }
.tpl-text small { font-size: 18px; letter-spacing: 2px; margin-top: 2px; }
.tpl-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.tpl-item + .tpl-item { border-top: .5px solid var(--sep, rgba(127, 127, 127, .2)); }
.tpl-item input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }
.tpl-ico { font-size: 24px; width: 30px; text-align: center; }
.tpl-name { display: flex; flex-direction: column; gap: 2px; }
.tpl-name b { font-weight: 500; font-size: 15.5px; }
.tpl-name small { color: var(--hint); font-size: 13px; }
.tpl-go { margin-top: 16px; }

/* ---------- питомец ---------- */
.pet-svg { display: block; overflow: visible; transform-origin: 50% 100%; animation: petIdle 3.2s ease-in-out infinite; }
.pet-svg.mood-sad { animation-duration: 5s; }
.pet-svg.jump { animation: petJump .9s cubic-bezier(.3, 1.6, .5, 1) 1, petIdle 3.2s ease-in-out .9s infinite; }
@keyframes petIdle { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-3px) scale(1.02, .98); } }
@keyframes petJump { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-22px) scale(.94, 1.08); } 60% { transform: translateY(0) scale(1.08, .92); } 100% { transform: none; } }
.pet-card { background: linear-gradient(135deg, color-mix(in srgb, #ff8a1f 10%, var(--card)), color-mix(in srgb, #ff8a1f 20%, var(--card))); align-items: center; overflow: hidden; }
.pet-slot { flex: none; width: 78px; display: grid; place-items: center; margin: -6px 0; }
.pet-name { font-size: 12px; font-weight: 700; color: #ea580c; text-transform: uppercase; letter-spacing: .04em; }
.pet-say { font-size: 13.5px; color: var(--hint); }
.pet-bar { display: block; height: 6px; border-radius: 3px; background: rgba(249, 115, 22, .18); overflow: hidden; margin-top: 6px; }
.pet-bar i { display: block; height: 100%; background: #f97316; border-radius: 3px; transition: width .4s; }
.pet-hero { text-align: center; background: linear-gradient(180deg, color-mix(in srgb, #ff8a1f 14%, var(--card)), var(--card));
  border-radius: 24px; padding: 14px 16px 16px; }
.pet-big { display: grid; place-items: center; }
.pet-title { font-size: 24px; font-weight: 800; color: var(--text); margin-top: 2px; }
.pet-title span { font-size: 15px; opacity: .55; }
.pet-name-input { font: inherit; font-size: 22px; font-weight: 800; text-align: center; width: 70%; padding: 4px 10px;
  border-radius: 12px; border: 2px solid #f97316; background: var(--card); color: var(--text); margin-top: 2px; }
.pet-stage { color: #c2410c; font-size: 14.5px; margin-top: 2px; }
.pet-xp { margin: 12px 18px 0; }
.pet-xp .pet-bar { height: 9px; }
.pet-xp small { display: flex; justify-content: space-between; font-size: 12px; color: var(--hint); margin-top: 5px; }
.pet-bubble { margin: 14px 6px 0; background: var(--bg); border-radius: 16px; padding: 10px 12px; font-size: 14px; position: relative; }
.pet-bubble::before { content: ''; position: absolute; top: -7px; left: 50%; margin-left: -7px; border: 7px solid transparent;
  border-top: 0; border-bottom-color: var(--bg); }
.wardrobe { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wear { background: var(--card); border-radius: 16px; min-height: 86px; padding: 8px 6px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; transition: transform .15s; }
.wear:active { transform: scale(.95); }
.wear span { font-size: 30px; line-height: 1; }
.wear small { font-size: 11px; color: var(--hint); text-align: center; line-height: 1.2; }
.wear.lock span { filter: grayscale(1); opacity: .45; }
.wear.on { box-shadow: inset 0 0 0 2px #f97316; }

/* ---------- экран продуктивности: вкладки и графики ---------- */
.stats-tabs { margin: 14px 0 4px; }
.stats-tabs button { font-size: 13.5px; white-space: nowrap; }
.tab-body { animation: fadeUp .25s ease both; }
.stat-grid.three { grid-template-columns: repeat(3, 1fr); }
.stat-grid.three .stat b { font-size: 20px; }
.stat-grid.three .stat span { font-size: 12px; }
.chart-card { padding: 14px; }
.bars7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.bar-col small { font-size: 11px; color: var(--hint); }
.bar-v { width: 100%; max-width: 30px; height: 96px; border-radius: 9px; background: rgba(127, 127, 127, .12);
  display: flex; align-items: flex-end; overflow: hidden; }
.bar-v i { display: block; width: 100%; background: color-mix(in srgb, var(--accent) 70%, transparent); border-radius: 9px; transition: height .5s; }
.bar-col.full .bar-v i { background: #22c55e; }
.bar-col span { font-size: 12px; color: var(--hint); }
.bar-col.today span { color: var(--accent); font-weight: 700; }
.wd-row { display: grid; grid-template-columns: 34px 1fr 54px; align-items: center; gap: 10px; padding: 5px 0; }
.wd-name { font-size: 13.5px; color: var(--hint); }
.wd-val { font-size: 13.5px; text-align: end; font-variant-numeric: tabular-nums; }
.wd-row.best .wd-name, .wd-row.best .wd-val { color: var(--text); font-weight: 700; }
.hbar { display: block; height: 8px; border-radius: 4px; background: rgba(127, 127, 127, .14); overflow: hidden; }
.hbar i { display: block; height: 100%; border-radius: 4px; background: var(--c, var(--accent)); transition: width .5s; }
.wd-row.best .hbar i { background: #22c55e; }
.hab-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.hab-row + .hab-row { border-top: .5px solid rgba(127, 127, 127, .18); }
.hab-ico { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 20px;
  background: color-mix(in srgb, var(--c) 16%, transparent); }
.hab-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hab-main b { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hab-val { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.hab-val b { font-size: 15px; }
.hab-val small { font-size: 11.5px; color: var(--hint); white-space: nowrap; }
.hab-empty { color: var(--hint); font-size: 14px; text-align: center; padding: 6px 0; }
.pet-hero .share-btn { margin-top: 14px; }
.stats-tabs { grid-template-columns: repeat(3, 1fr); }

/* ---------- Искорка 2.0: в кольце дня, анимации, календарь месяца ---------- */
.pet-ring { width: 112px; height: 112px; overflow: visible; flex-shrink: 0; }
.pet-ring::before {
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6.5px));
}
.pet-ring .pet-svg { width: 104px; height: auto; margin-top: -14px; }
.pet-ring em { position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px;
  font-weight: 700; background: var(--card); color: var(--text); padding: 1px 7px; border-radius: 9px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.day-card.complete .pet-ring em { color: #16a34a; }
.pet-card .day-card-text { gap: 1px; }
.pet-card .pet-say { font-size: 13px; line-height: 1.3; }
.day-card.celebrate .pet-ring { animation: none; }
.pet-svg .pet-embers circle { animation: ember 2.6s ease-in infinite; transform-box: fill-box; }
.pet-svg .pet-embers circle:nth-child(2) { animation-delay: .9s; }
.pet-svg .pet-embers circle:nth-child(3) { animation-delay: 1.7s; }
@keyframes ember { 0% { opacity: 0; transform: translateY(8px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.pet-svg .pet-wing { transform-box: fill-box; animation: wing 1.8s ease-in-out infinite; }
.pet-svg .pet-wing.l { transform-origin: 100% 100%; }
.pet-svg .pet-wing.r { transform-origin: 0 100%; animation-name: wingR; }
@keyframes wing { 50% { transform: rotate(-8deg); } }
@keyframes wingR { 50% { transform: rotate(8deg); } }
.pet-svg.mood-happy .pet-arm { transform-box: fill-box; transform-origin: 50% 100%; animation: wave 1.4s ease-in-out infinite; }
@keyframes wave { 50% { translate: 0 -2px; } }
.pet-svg .pet-tear { animation: tear 2.4s ease-in infinite; }
@keyframes tear { 0%, 40% { opacity: 0; transform: translateY(-3px); } 60% { opacity: 1; } 100% { opacity: 0; transform: translateY(6px); } }
.pet-svg .pet-orbit { transform-box: fill-box; transform-origin: center; animation: orbit 6s linear infinite; }
@keyframes orbit { to { transform: rotate(360deg); } }
.pet-svg .pet-wisp { transform-box: fill-box; transform-origin: 50% 100%; animation: flick 1.6s ease-in-out infinite; }
@keyframes flick { 50% { transform: scaleY(1.08); } }
@media (prefers-reduced-motion: reduce) { .pet-svg, .pet-svg * { animation: none !important; } }

.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.mdow { font-size: 11px; color: var(--hint); text-align: center; padding-bottom: 2px; }
.mday { aspect-ratio: 1; border-radius: 9px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-style: normal; background: var(--ring-track, rgba(127, 127, 127, .14)); line-height: 1.05; }
.mday b { font-size: 14px; font-weight: 700; }
.mday small { font-size: 9.5px; opacity: .75; }
.mday.blank { background: none; }
.mday.c-done { background: #22c55e; color: #fff; }
.mday.c-frozen { background: #60a5fa; color: #fff; }
.mday.c-missed { background: rgba(239, 68, 68, .5); color: #fff; }
.mday.c-none, .mday.c-empty { background: rgba(127, 127, 127, .12); color: var(--text); }
.mday.c-today { background: rgba(127, 127, 127, .12); }
.mday.c-future { background: none; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .25); color: var(--hint); }
.mday.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.mday.is-today.c-done { box-shadow: inset 0 0 0 2px #15803d; }

/* ---------- категории готовых наборов ---------- */
.tpl-cats { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 4px; scrollbar-width: none; }
.tpl-cats::-webkit-scrollbar { display: none; }
.tpl-cat { flex: none; border: 0; border-radius: 18px; padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 600;
  background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .06); cursor: pointer; }
.tpl-cat i { font-style: normal; font-weight: 500; color: var(--hint); margin-inline-start: 2px; }
.tpl-cat.on { background: var(--accent); color: #fff; }
.tpl-cat.on i { color: rgba(255, 255, 255, .8); }

/* ---------- сравнение с другими и итоги месяца ---------- */
.beat-card { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, #f5b301 16%, var(--card)), color-mix(in srgb, #ff8a1f 14%, var(--card))); }
.beat-ico { font-size: 30px; }
.beat-card b { display: block; font-size: 15.5px; }
.beat-card small { color: var(--hint); font-size: 13px; }
.recap-btn { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 12px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--card); color: var(--text); font-weight: 600; font-size: 15.5px; }
.recap-btn span { color: var(--hint); font-size: 22px; line-height: 1; }
.recap-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.recap-nav b { font-size: 18px; }
.recap-nav .link-btn { font-size: 28px; width: 44px; height: 36px; }
.recap-nav .link-btn:disabled { opacity: .25; }
.recap-card { position: relative; overflow: hidden; border-radius: 24px; padding: 18px 16px 20px; text-align: center; color: #fff;
  background: radial-gradient(circle at 50% 22%, rgba(255, 140, 40, .45), transparent 60%), linear-gradient(160deg, #1d1233, #3a1340 55%, #5c1a1a); }
.recap-pet { display: grid; place-items: center; }
.recap-pet .pet-svg { width: 140px; height: auto; }
.recap-tag { position: absolute; top: 14px; inset-inline-end: 14px; font-size: 12px; font-weight: 600; padding: 3px 9px;
  border-radius: 10px; background: rgba(255, 255, 255, .16); }
.recap-big { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: 4px; }
.recap-big b { font-size: 64px; line-height: 1; font-weight: 800; }
.recap-big span { font-size: 26px; font-weight: 700; opacity: .6; }
.recap-big-l { font-size: 15px; opacity: .85; margin-top: 4px; }
.recap-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.recap-tiles div { background: rgba(255, 255, 255, .1); border-radius: 14px; padding: 10px 4px; }
.recap-tiles b { display: block; font-size: 20px; }
.recap-tiles span { font-size: 12px; opacity: .7; }
.recap-row { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; font-size: 13px; }
.recap-row span { opacity: .7; }
.recap-row b { font-size: 16px; }
.recap-row.beat { flex-direction: row; justify-content: center; gap: 6px; color: #ffd36b; }
.recap-row.beat span { opacity: 1; }
.recap-empty { margin: 12px 0 4px; opacity: .85; }
.recap-share { display: flex; margin: 16px auto 0; }

/* ---------- привычки со счётчиком ---------- */
.habit-ring.cnt { border-color: color-mix(in srgb, var(--c) 22%, transparent); }
.habit-ring.cnt::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  transition: background .3s; }
.habit-ring { -webkit-touch-callout: none; user-select: none; }
.habit-cnt { font-size: 12px; font-weight: 700; color: var(--c); margin-top: -3px; white-space: nowrap; }
.habit-cnt small { color: var(--hint); font-weight: 500; font-size: 11.5px; }
.plus-pop { position: absolute; top: -8px; right: -12px; background: var(--c); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 9px; padding: 1px 6px; pointer-events: none; animation: plusPop .8s ease forwards; }
@keyframes plusPop { 0% { opacity: 0; transform: translateY(6px) scale(.7); } 25% { opacity: 1; transform: none; }
  75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
.amount-body { text-align: center; padding-bottom: 24px; }
.amount-goal { color: var(--hint); font-size: 14px; margin-bottom: 14px; }
.amount-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.amount-btn { min-width: 64px; height: 48px; border-radius: 14px; background: var(--card); color: var(--accent); font-size: 18px; font-weight: 700; }
.amount-input { width: 120px; height: 56px; border: 0; border-radius: 14px; background: var(--card); color: var(--text);
  text-align: center; font: inherit; font-size: 28px; font-weight: 800; }
.amount-unit { color: var(--hint); margin-top: 6px; min-height: 18px; }
.amount-actions { display: flex; justify-content: center; gap: 10px; margin: 12px 0 16px; }
.amount-actions .btn-plain { width: auto; padding: 8px 16px; }
.goal-card .chips { padding: 12px 14px 4px; }
.goal-card .ctl.num { width: 110px; text-align: center; }
.goal-card .ctl.unit { width: 130px; }

/* ---------- правка привычки внутри набора ---------- */
.tpl-row + .tpl-row { border-top: .5px solid var(--sep, rgba(127, 127, 127, .2)); }
.tpl-row .tpl-item + .tpl-item { border-top: 0; }
.tpl-name { flex: 1; min-width: 0; }
.tpl-edit { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--hint);
  background: color-mix(in srgb, var(--hint) 12%, transparent); }
.tpl-edit svg { width: 18px; height: 18px; }
.tpl-edit.on { color: #fff; background: var(--accent); }
.tpl-form { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.tpl-form .ctl.tpl-title { width: 100%; text-align: start; }
.tpl-form .chips, .tpl-form .weekdays { padding: 0; margin: 0; }
.tpl-form .field { padding: 0; border: 0; }
.tpl-form .field-control { gap: 8px; }
.tpl-form .ctl.num { width: 90px; text-align: center; }
.tpl-form .ctl.unit { width: 110px; }
.tpl-form-done { align-self: flex-end; width: auto; padding: 8px 18px; }
