/* ==========================================================================
   Токены темы
   ========================================================================== */

:root {
  /* Светлая тема — исходная палитра */
  --bg: #F2F9FC;
  --bg-glow: radial-gradient(1100px 520px at 15% -10%, rgba(169, 215, 202, .42), transparent 62%),
             radial-gradient(900px 480px at 110% 0%, rgba(76, 156, 180, .14), transparent 60%);
  --card: #FFFFFF;
  --card-top: #FFFFFF;
  --card-bottom: #F8FCFD;
  --surface: #D7EDF3;
  --surface-2: #E8F4F8;
  --text: #243E50;
  --muted: rgba(36, 62, 80, .6);
  --primary: #4C9CB4;
  --primary-2: #5FB0C8;
  --on-primary: #FFFFFF;
  --accent: #A9D7CA;
  --accent-bg: #D7EDF3;
  --accent-fg: #3A879F;
  --sel-bg: #4C9CB4;
  --sel-fg: #FFFFFF;
  --line: rgba(36, 62, 80, .08);
  --danger: #C2554D;
  --glow: rgba(76, 156, 180, .42);
  --hl: rgba(255, 255, 255, .95);
  --elev-1: inset 0 1px 0 var(--hl), 0 1px 2px rgba(36, 62, 80, .06), 0 8px 20px -10px rgba(36, 62, 80, .18);
  --elev-2: inset 0 1px 0 var(--hl), 0 2px 6px rgba(36, 62, 80, .06), 0 22px 44px -18px rgba(36, 62, 80, .32);
  --press: inset 0 2px 4px rgba(36, 62, 80, .12);
  --backdrop: rgba(36, 62, 80, .38);
  --radius: 22px;

  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  color-scheme: light;
}

:root[data-theme="dark"] {
  /* Тёмная тема — палитра заказчика; --surface, --muted и оттенки рассчитаны от неё */
  --bg: #0B1520;
  --bg-glow: radial-gradient(1000px 520px at 10% -12%, rgba(232, 196, 124, .09), transparent 60%),
             radial-gradient(900px 600px at 110% 10%, rgba(76, 156, 180, .08), transparent 60%);
  --card: #122231;
  --card-top: #172A3C;
  --card-bottom: #112030;
  --surface: #1A2D3F;
  --surface-2: #15273A;
  --text: #F2F7FA;
  --muted: rgba(242, 247, 250, .56);
  --primary: #E8C47C;
  --primary-2: #F2D597;
  --on-primary: #1D1609;
  --accent: #E8C47C;
  --accent-bg: #413A2D;
  --accent-fg: #E8C47C;
  --sel-bg: #413A2D;
  --sel-fg: #F2D597;
  --line: rgba(242, 247, 250, .07);
  --danger: #F08F86;
  --glow: rgba(232, 196, 124, .32);
  --hl: rgba(255, 255, 255, .06);
  --elev-1: inset 0 1px 0 var(--hl), 0 1px 0 rgba(0, 0, 0, .35), 0 10px 24px -12px rgba(0, 0, 0, .7);
  --elev-2: inset 0 1px 0 rgba(255, 255, 255, .08), 0 2px 0 rgba(0, 0, 0, .3), 0 28px 56px -20px rgba(0, 0, 0, .85);
  --press: inset 0 2px 5px rgba(0, 0, 0, .45);
  --backdrop: rgba(3, 8, 13, .66);
  color-scheme: dark;
}

/* ==========================================================================
   База
   ========================================================================== */

* { box-sizing: border-box; margin: 0; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }

.ic, .nav svg, .fab svg {
  width: 24px; height: 24px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

/* Общая «объёмная» поверхность */
.card, .habit, .tile, .day, .ring, .suggest button, .pill, .chip, .icon-grid button, .num-step, .seg {
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
  box-shadow: var(--elev-1);
}

#app {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(20px + var(--safe-top)) 16px calc(150px + var(--safe-bottom));
}

/* ==========================================================================
   Шапка
   ========================================================================== */

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.eyebrow { font-size: 14px; font-weight: 500; color: var(--muted); }
h1 { font-size: 32px; font-weight: 780; letter-spacing: -.025em; line-height: 1.15; }

.ring { position: relative; width: 64px; height: 64px; flex-shrink: 0; border-radius: 50%; padding: 2px; }
.ring svg { width: 60px; height: 60px; transform: rotate(-90deg); display: block; }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--surface); }
.ring .bar { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2, .8, .2, 1); filter: drop-shadow(0 0 4px var(--glow)); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 750; }
.ring.full { box-shadow: var(--elev-1), 0 0 0 4px var(--glow); }

/* ==========================================================================
   Полоса дней
   ========================================================================== */

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; margin-bottom: 8px; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 9px; border-radius: 16px;
  transition: transform .15s, box-shadow .2s;
}
.day:active { transform: scale(.96); }
.day .wd { font-size: 12px; font-weight: 600; color: var(--muted); }
.day .dn { font-size: 18px; font-weight: 700; }
.day .dot { width: 6px; height: 6px; border-radius: 50%; }
.day.part .dot { background: var(--accent); }
.day.full .dot { background: var(--primary); box-shadow: 0 0 6px var(--glow); }
.day.today:not(.selected) .dn { color: var(--accent-fg); }
.day.selected {
  background: linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0)), var(--sel-bg);
  color: var(--sel-fg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 10px 22px -10px var(--glow);
}
.day.selected .wd { color: inherit; opacity: .8; }
.day.selected.part .dot, .day.selected.full .dot { background: var(--sel-fg); }

/* ==========================================================================
   Карточки привычек
   ========================================================================== */

.group {
  margin: 24px 6px 10px; font-size: 12px; font-weight: 750;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.habits { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.habit {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 12px;
  border-radius: var(--radius);
  animation: rise .3s both;
  transition: transform .2s, box-shadow .2s;
}
.habit.off { opacity: .5; }
.habit-main { flex: 1; display: flex; align-items: center; gap: 13px; text-align: left; min-width: 0; }
.info { min-width: 0; display: flex; flex-direction: column; flex: 1; gap: 1px; }
.name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { font-size: 13px; color: var(--muted); }
.habit.done .name { color: var(--muted); }

/* Колодец со значком */
.well {
  width: 48px; height: 48px; border-radius: 15px; flex-shrink: 0;
  display: grid; place-items: center; color: var(--c);
  background: linear-gradient(150deg, var(--tint2), var(--tint));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -2px 6px rgba(0, 0, 0, .06);
}
:root[data-theme="dark"] .well { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 -2px 8px rgba(0, 0, 0, .25); }
.well .ic { width: 25px; height: 25px; stroke-width: 2; }
.well.sm { width: 38px; height: 38px; border-radius: 12px; }
.well.sm .ic { width: 20px; height: 20px; }
.glyph { font-size: 22px; font-weight: 700; line-height: 1; }
.well.sm .glyph { font-size: 17px; }

/* Кнопка отметки */
.check {
  position: relative; width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(180deg, var(--card-top), var(--surface-2));
  box-shadow: inset 0 0 0 2px var(--ring), inset 0 1px 0 var(--hl), 0 3px 8px -3px rgba(0, 0, 0, .25);
  transition: transform .15s, background .2s, box-shadow .2s;
}
.check:active { transform: scale(.92); }
.check > * { grid-area: 1 / 1; }
.check .tick { width: 22px; height: 22px; stroke: var(--on-c); stroke-width: 2.6; opacity: 0; transform: scale(.4); transition: .2s; }
.habit.done .check {
  background: linear-gradient(180deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, 0) 60%), var(--c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 8px 18px -6px var(--glow-c);
}
.habit.done .check .tick { opacity: 1; transform: none; }
.habit.met .check { box-shadow: inset 0 0 0 2px var(--c), inset 0 1px 0 var(--hl); }
.habit.met .check .tick { opacity: 1; transform: none; stroke: var(--c); }
.check.count { box-shadow: inset 0 1px 0 var(--hl), 0 3px 8px -3px rgba(0, 0, 0, .25); }
.check .mini { position: absolute; inset: 0; width: 44px; height: 44px; transform: rotate(-90deg); }
.check .mini circle { fill: none; stroke-width: 3; }
.check .mini .t { stroke: var(--ring); }
.check .mini .b { stroke: var(--c); stroke-linecap: round; transition: stroke-dashoffset .3s; }
.check .num { font-size: 13px; font-weight: 750; }
.habit.done .check .mini, .habit.done .check .num { display: none; }
.check.pop { animation: pop .38s; }

@keyframes pop { 40% { transform: scale(1.2); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ==========================================================================
   Пустое состояние
   ========================================================================== */

.empty { text-align: center; padding: 28px 8px; }
.empty-mark {
  width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 26px;
  display: grid; place-items: center; color: var(--accent-fg);
  background: linear-gradient(150deg, var(--accent-bg), var(--surface-2));
  box-shadow: var(--elev-2);
}
.empty-mark .ic { width: 40px; height: 40px; stroke-width: 1.7; }
.empty h3 { font-size: 21px; margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 auto 22px; max-width: 380px; }
.suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 22px; }
.suggest button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px 10px 11px; border-radius: 14px; font-size: 15px; font-weight: 550;
}
.suggest .ic { width: 20px; height: 20px; color: var(--c); }
.empty .btn { max-width: 340px; margin: 0 auto; }

/* ==========================================================================
   Кнопки
   ========================================================================== */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px; border-radius: 16px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: var(--on-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 10px 22px -10px var(--glow);
  font-weight: 700; font-size: 16px; text-align: center; text-decoration: none;
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.btn .ic { width: 20px; height: 20px; }
.btn:active { transform: scale(.98); }
.btn.secondary {
  background: linear-gradient(180deg, var(--card-top), var(--surface-2));
  color: var(--text); box-shadow: var(--elev-1);
}
.btn.danger { background: transparent; color: var(--danger); box-shadow: none; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.fab {
  position: fixed; z-index: 5;
  right: max(16px, calc(50% - 284px));
  bottom: calc(92px + var(--safe-bottom));
  width: 60px; height: 60px; border-radius: 20px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  color: var(--on-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 14px 30px -10px var(--glow), 0 4px 10px -4px rgba(0, 0, 0, .3);
  display: grid; place-items: center;
  transition: transform .15s;
}
.fab svg { width: 28px; height: 28px; stroke-width: 2.4; }
.fab:active { transform: scale(.93); }

/* ==========================================================================
   Навигация: снизу на телефоне, слева на компьютере
   ========================================================================== */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: center; gap: 6px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px -18px rgba(0, 0, 0, .35);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) and (background: color-mix(in srgb, red 50%, blue)) {
  .nav { background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); }
}
.brand, .nav-add { display: none !important; }
.tab {
  flex: 1; max-width: 170px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 14px; font-size: 12px; font-weight: 650; color: var(--muted);
  transition: color .2s, background .2s;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent-fg); background: var(--accent-bg); box-shadow: inset 0 1px 0 var(--hl); }

/* ==========================================================================
   Нижний лист / модальное окно
   ========================================================================== */

.backdrop { position: fixed; inset: 0; z-index: 10; background: var(--backdrop); opacity: 0; transition: opacity .25s; }
.backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 600px; margin: 0 auto; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg-glow), var(--bg);
  border-radius: 26px 26px 0 0;
  box-shadow: var(--elev-2), 0 -1px 0 var(--line);
  padding: 8px 20px calc(24px + var(--safe-bottom));
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open { transform: none; }
.handle { width: 40px; height: 5px; border-radius: 3px; background: var(--surface); margin: 0 auto 14px; }
.sheet-title { font-size: 24px; font-weight: 780; letter-spacing: -.02em; margin-bottom: 18px; }
.sheet-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.sheet-head h2 { font-size: 22px; font-weight: 750; line-height: 1.2; word-break: break-word; }

/* ==========================================================================
   Форма
   ========================================================================== */

.field { display: block; margin-bottom: 22px; }
.label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.label.sub { margin: 14px 0 8px; font-weight: 600; }
.name-row { display: flex; gap: 10px; align-items: center; }
.input {
  width: 100%; padding: 14px 15px; border-radius: 14px;
  border: 1.5px solid transparent; background: var(--surface-2);
  box-shadow: var(--press);
  font: inherit; color: var(--text); outline: none; transition: border-color .15s, background .15s;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--primary); background: var(--card); }
textarea.input { min-height: 140px; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; resize: vertical; }

.presets { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 13px; border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--text);
}
.pill .ic { width: 19px; height: 19px; color: var(--accent-fg); }
.pill.wide { width: 100%; justify-content: flex-start; padding: 13px 14px; font-weight: 600; color: var(--muted); }
.pill[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent-fg); box-shadow: inset 0 0 0 1.5px var(--accent-fg); }

.rep { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 16px; font-weight: 650; margin-bottom: 10px; }
.num-step { display: inline-flex; align-items: center; border-radius: 14px; padding: 3px; }
.num-step button { width: 36px; height: 36px; border-radius: 11px; font-size: 20px; font-weight: 600; color: var(--accent-fg); }
.num-step button:active { background: var(--accent-bg); }
.num-step b { min-width: 30px; text-align: center; font-size: 18px; }
.num-step.disabled { opacity: .4; pointer-events: none; }
.rep-sum {
  margin-top: 12px; padding: 11px 14px; border-radius: 12px;
  background: var(--accent-bg); color: var(--accent-fg); font-weight: 700; font-size: 15px;
}

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; }
.seg { background: var(--surface-2); box-shadow: var(--press); }
.seg button { padding: 10px 6px; border-radius: 10px; font-size: 14px; font-weight: 650; color: var(--muted); transition: .15s; }
.seg button[aria-pressed="true"] { background: linear-gradient(180deg, var(--card-top), var(--card-bottom)); color: var(--text); box-shadow: var(--elev-1); }

.chips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.chip { padding: 10px 0; border-radius: 12px; font-size: 14px; font-weight: 650; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--sel-bg); color: var(--sel-fg); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 6px 14px -8px var(--glow); }

.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; }
.icon-grid button { aspect-ratio: 1; border-radius: 13px; display: grid; place-items: center; color: var(--muted); transition: .15s; }
.icon-grid .ic { width: 22px; height: 22px; }
.icon-grid button[aria-pressed="true"] { color: var(--accent-fg); background: var(--accent-bg); box-shadow: inset 0 0 0 1.5px var(--accent-fg); }
.glyph-in { grid-column: span 2; aspect-ratio: auto; padding: 0 10px; text-align: center; font-size: 18px; }

.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .45), transparent 55%), var(--c);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .15), 0 3px 8px -3px var(--c);
  transition: box-shadow .15s, transform .15s;
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--c); transform: scale(1.05); }

/* ==========================================================================
   Ввод количества
   ========================================================================== */

.stepper { display: flex; align-items: center; gap: 12px; margin: 8px 0 8px; }
.stepper button {
  width: 58px; height: 58px; border-radius: 18px; flex-shrink: 0; font-size: 28px; font-weight: 500; color: var(--accent-fg);
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom)); box-shadow: var(--elev-1);
}
.stepper input { text-align: center; font-size: 34px; font-weight: 780; padding: 8px; }
.center { text-align: center; }

/* ==========================================================================
   Статистика и боковая панель
   ========================================================================== */

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.tile { border-radius: 18px; padding: 14px 13px; }
.tile b { display: block; font-size: 24px; font-weight: 780; letter-spacing: -.02em; }
.tile span { display: block; font-size: 12px; line-height: 1.25; color: var(--muted); margin-top: 2px; }

.card { border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.card > .meta { margin-bottom: 12px; }
.period { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; font-size: 14px; color: var(--muted); }
.period b { color: var(--text); font-size: 16px; white-space: nowrap; }

.heat { display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; gap: 3px; }
.hl { font-size: 10px; color: var(--muted); display: flex; align-items: center; }
.cell { aspect-ratio: 1; border-radius: 4px; background: var(--surface); position: relative; display: block; }
:root[data-theme="dark"] .cell { background: #1C3043; }
.cell i { position: absolute; inset: 0; border-radius: inherit; background: var(--c, var(--primary)); box-shadow: 0 0 6px -1px var(--c, var(--glow)); }
.cell.rest { opacity: .4; }
.cell.future { background: transparent !important; }
.cell.today { box-shadow: inset 0 0 0 1.5px var(--text); }
button.cell { cursor: pointer; }
.legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.legend .cell { width: 11px; }

.hrow, .srow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; text-align: left; border-top: 1px solid var(--line); }
.hrow:first-of-type, .srow:first-of-type { border-top: 0; padding-top: 2px; }
.pbar { display: block; height: 7px; border-radius: 4px; background: var(--surface); overflow: hidden; margin-top: 7px; box-shadow: var(--press); }
.pbar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--c), var(--c)); box-shadow: 0 0 8px var(--glow-c); }
.pct { text-align: right; font-weight: 750; font-size: 15px; flex-shrink: 0; }
.pct small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.srow .name { flex: 1; font-size: 15px; }
.streak { display: inline-flex; align-items: center; gap: 3px; font-weight: 750; color: var(--accent-fg); }
.streak .ic { width: 17px; height: 17px; }
.streak small { font-weight: 500; color: var(--muted); font-size: 12px; }

.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; }
.bcol { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.btrack { width: 100%; max-width: 26px; height: 96px; border-radius: 9px; background: var(--surface-2); box-shadow: var(--press); display: flex; align-items: flex-end; overflow: hidden; }
.btrack i { display: block; width: 100%; border-radius: 9px; background: linear-gradient(180deg, var(--primary-2), var(--primary)); box-shadow: 0 0 10px var(--glow); transition: height .4s; }
.bcol.now { color: var(--accent-fg); }

.foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ==========================================================================
   Вместе: участники, напоминания, приглашения, аккаунт
   ========================================================================== */

.faces { display: inline-flex; align-items: center; flex-shrink: 0; padding-left: 6px; }
.face {
  position: relative; width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(150deg, var(--fc), color-mix(in srgb, var(--fc) 70%, #000));
  background-color: var(--fc);
  color: #fff; font-size: 11px; font-weight: 750; letter-spacing: .02em;
  box-shadow: 0 0 0 2px var(--card-top), 0 3px 8px -3px rgba(0, 0, 0, .35);
}
.face > * { grid-area: 1 / 1; }
.face img { width: 100%; height: 100%; object-fit: cover; }
.faces .face + .face { margin-left: -8px; }
.face.done { box-shadow: 0 0 0 2px var(--card-top), 0 0 0 4px var(--c, var(--primary)); }
.face.done::after {
  content: ''; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--c, var(--primary)); box-shadow: 0 0 0 2px var(--card-top);
}
.face.more { background: var(--surface); color: var(--muted); }
.face.lg { width: 52px; height: 52px; font-size: 18px; }
.mrow .face { width: 38px; height: 38px; font-size: 14px; }

.members { display: flex; flex-direction: column; }
.mrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.mrow:first-child { border-top: 0; padding-top: 2px; }
.mrow .name { font-size: 15px; }
.ic.inl { width: 13px; height: 13px; vertical-align: -2px; margin-right: 2px; color: var(--accent-fg); }

.pill.sm { padding: 7px 11px; font-size: 13px; gap: 6px; flex-shrink: 0; }
.pill.sm .ic { width: 16px; height: 16px; }
.pill.accent {
  background: linear-gradient(180deg, var(--primary-2), var(--primary)); color: var(--on-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 6px 14px -8px var(--glow);
}
.pill.accent .ic { color: inherit; }
.pill.muted { background: var(--surface-2); color: var(--muted); box-shadow: none; }

.remind-row { display: flex; align-items: center; gap: 10px; }
.remind-row .input { max-width: 150px; font-size: 18px; font-weight: 700; padding: 10px 14px; }
.ic-wrap { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: var(--accent-fg); background: var(--accent-bg); flex-shrink: 0; }

.invite-link {
  margin: 4px 0 16px; padding: 13px 15px; border-radius: 14px; background: var(--surface-2); box-shadow: var(--press);
  font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--muted); word-break: break-all;
}
.btn.link { background: none; box-shadow: none; color: var(--accent-fg); font-weight: 600; font-size: 14px; padding: 10px; }
.btn.link.danger-text { color: var(--danger); }
.btn.fit { width: auto; flex-shrink: 0; padding: 13px 18px; }
.acc-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.code-in { text-align: center; font-size: 30px; font-weight: 780; letter-spacing: .4em; padding: 14px; }

/* ==========================================================================
   Тост
   ========================================================================== */

.toast {
  position: fixed; left: 50%; z-index: 20;
  bottom: calc(166px + var(--safe-bottom));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 650; text-align: center;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .5);
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Компьютер
   ========================================================================== */

@media (hover: hover) {
  .habit:hover { transform: translateY(-2px); box-shadow: var(--elev-2); }
  .day:not(.selected):hover, .pill:hover, .chip:not([aria-pressed="true"]):hover,
  .icon-grid button:hover, .suggest button:hover, .btn.secondary:hover { filter: brightness(1.04); box-shadow: var(--elev-2); }
  .btn:hover { filter: brightness(1.05); }
  .check:hover { box-shadow: inset 0 0 0 2px var(--c), inset 0 1px 0 var(--hl), 0 6px 14px -6px var(--glow-c); }
  .tab:not(.active):hover { color: var(--text); background: var(--surface-2); }
  .hrow:hover .name, .srow:hover .name { color: var(--accent-fg); }
  button.cell:hover { outline: 2px solid var(--c, var(--primary)); outline-offset: 1px; }
}

@media (min-width: 960px) {
  body { padding-left: 248px; }
  #app { padding: 44px 48px 64px; }
  h1 { font-size: 38px; }
  .top { margin-bottom: 26px; }

  .nav {
    top: 0; right: auto; width: 248px; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 28px 16px; border-top: 0; border-right: 1px solid var(--line);
    box-shadow: 10px 0 40px -30px rgba(0, 0, 0, .5);
  }
  .brand {
    display: flex !important; align-items: center; gap: 12px;
    font-size: 19px; font-weight: 780; letter-spacing: -.02em; margin: 0 8px 26px;
  }
  .brand-mark {
    width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
    background: linear-gradient(180deg, var(--primary-2), var(--primary)); color: var(--on-primary);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 18px -8px var(--glow);
  }
  .brand-mark svg { width: 22px; height: 22px; stroke-width: 2.6; }
  .tab { flex: 0 0 auto; max-width: none; flex-direction: row; gap: 12px; padding: 11px 14px; font-size: 15px; justify-content: flex-start; }
  .tab svg { width: 22px; height: 22px; }
  .nav-add { display: flex !important; margin-top: auto; }
  .nav-add svg { width: 20px; height: 20px; stroke-width: 2.4; }
  .fab { display: none; }

  #app { max-width: 760px; }
  .week { gap: 10px; }
  .day { padding: 11px 0; }

  .tiles { gap: 16px; }
  .tile { padding: 18px; }
  .settings { max-width: 560px; }

  .sheet {
    top: 50%; bottom: auto; left: 50%; right: auto; width: min(520px, calc(100vw - 48px));
    margin-left: 124px; border-radius: 26px; max-height: 88vh;
    padding: 28px 28px 28px;
    transform: translate(-50%, -46%) scale(.97); opacity: 0;
    transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .2s;
  }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .handle { display: none; }
  .toast { bottom: 32px; margin-left: 124px; }
}

/* Две колонки — только когда для них есть место */
@media (min-width: 1200px) {
  #app { max-width: 1180px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
  body:not([data-view="today"]) .layout, body.no-habits .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 32px; }
  .stats-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
}
@media (max-width: 1199px) { .side { display: none !important; } }
@media (max-width: 380px) {
  .icon-grid { grid-template-columns: repeat(6, 1fr); }
  .tiles { gap: 8px; }
  .tile b { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
