/* Бежевая палитра исходных Excel-планеров. Тёмная тема — отдельные значения, а не инверсия. */
:root {
  --bg: #f6f1ec;
  --card: #ffffff;
  --card-2: #faf6f2;
  --ink: #3a2e28;
  --muted: #7d6c62; /* чуть темнее прежнего #8b7a70: мелкие подписи на бежевом теперь ≥4.5:1 */
  --line: #ece2d9;
  --track: #efe6de;
  --accent: #dcc0ad;
  --accent-soft: #f1e3d8;
  --accent-strong: #a8735a;
  --on-accent: #ffffff;
  --ok: #3f8a5f;
  --ok-soft: #e1f1e7;
  --bad: #c2523f;
  --bad-soft: #f8e1dc;
  --warn: #b7791f;
  --warn-soft: #f8ecd6;
  --p-urgent: #b27760;
  --p-high: #d2a185;
  --p-medium: #c9b8ab;
  --p-low: #e2d7cd;
  --p-urgent-bg: #e6cbbd;
  --p-high-bg: #f0dcd0;
  --p-medium-bg: #e8e0d9;
  --p-low-bg: #f3efeb;
  /* Ряды графиков: проверены валидатором dataviz (яркость, насыщенность, различимость при дальтонизме, контраст). */
  --series-income: #0f86a8;
  --series-spent: #c0613d;
  --shadow: 0 1px 2px rgb(80 50 30 / 6%), 0 6px 20px rgb(80 50 30 / 6%);
  --radius: 18px;
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --press: rgb(90 60 40 / 7%);
  --scrim: rgb(40 25 18 / 36%);
  --grip: rgb(90 60 40 / 22%);
  --sheet-shadow: 0 -10px 40px rgb(80 50 30 / 14%);
  --bar-bg: rgb(255 255 255 / 72%);
  --hairline: rgb(90 60 40 / 14%);
  /* Отпускание после нажатия: быстро, без отскока (аналог пружины damping 1, response ~0.3) */
  --ease-out: cubic-bezier(0.2, 0.9, 0.3, 1);
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #1c1816;
  --card: #27211e;
  --card-2: #2f2824;
  --ink: #f2e9e3;
  --muted: #a99a90;
  --line: #3a312c;
  --track: #3a312c;
  --accent: #8a6450;
  --accent-soft: #3b2f29;
  --accent-strong: #dba88c;
  --on-accent: #241c18;
  --ok: #7cc79b;
  --ok-soft: #22362a;
  --bad: #ef8a76;
  --bad-soft: #3e2722;
  --warn: #e3b05c;
  --warn-soft: #3a2f1d;
  --p-urgent: #d0937a;
  --p-high: #b9876c;
  --p-medium: #8f7d71;
  --p-low: #5f534c;
  --p-urgent-bg: #4a3329;
  --p-high-bg: #41322a;
  --p-medium-bg: #3a322d;
  --p-low-bg: #322b27;
  --series-income: #2f9fb2;
  --series-spent: #d0714b;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  --press: rgb(255 240 230 / 7%);
  --scrim: rgb(0 0 0 / 58%);
  --grip: rgb(242 233 227 / 26%);
  --sheet-shadow: 0 -1px 0 rgb(255 240 230 / 7%), 0 -12px 40px rgb(0 0 0 / 45%);
  --bar-bg: rgb(39 33 30 / 74%);
  --hairline: rgb(255 240 230 / 9%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.4 var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.locked { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tab-h) + var(--safe-b) + 88px);
  min-height: 100vh;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.pad { padding: 4px 4px 10px; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.split > b { white-space: nowrap; }

/* Заставка */
.splash { display: grid; place-items: center; gap: 14px; padding-top: 30vh; color: var(--muted); }
.splash-dot { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--track); border-top-color: var(--accent-strong); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Заголовки страниц */
.page-head { padding: 6px 4px 14px; }
/* Трекинг зависит от размера: крупное — плотнее, мелкое — чуть свободнее. */
.page-head h1, .hello h1 { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -0.022em; }
.page-head p { margin-top: 2px; }
.hello { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 6px 4px 16px; }
.hello h1 { margin-top: 2px; font-size: 24px; letter-spacing: -0.02em; }

/* Цифры одной ширины: суммы и счётчики не «прыгают» при изменении */
.hero-num, .tile b, .summary b, .tx-amount, .budget-nums, .hbar-val, .sh-sum b, .sh-table, .cal-day > b,
.day b, .week, .amount-field input, .badge, .ring text, .filter b, .group-head > span { font-variant-numeric: tabular-nums; }
.hero-num, .amount-field input, .amount-field span { letter-spacing: -0.03em; }
.tile b, .welcome h1 { letter-spacing: -0.018em; }
.sheet-head h2, .summary b, .sh-sum b { letter-spacing: -0.012em; }
.tabbar button, .col-label, .week small, .cal-wd, .day small, .summary small, .sh-sum span, .cal-shifts i,
.who, .tag, .badge, .field-hint, .row-meta, .tile span { letter-spacing: 0.012em; }

/* Отклик на нажатие: появляется мгновенно, отпускание — мягкое и быстрое. */
:where(.btn, .filter, .quick button, .brush, .day, .week, .emoji-pick button, .shared-chip, .link, .segmented button,
  .icon-btn, .fab, .check, .cal-day, .chip span, .swatch span, .tabbar button svg, .month-switch .icon-btn) {
  transition: transform 0.32s var(--ease-out), background-color 0.2s, color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
:where(.btn, .filter, .quick button, .brush, .day, .week, .shared-chip, .segmented button, .fab, .cal-day):active:not(:disabled),
.chip:active span, .swatch:active span, .tabbar button:active svg {
  transform: scale(0.96); transition-duration: 0.06s;
}
.btn-block:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:active:not(:disabled) { filter: brightness(0.94); }
.link:active, .add-row:active { opacity: 0.55; transition-duration: 0.06s; }
.tabbar button:active svg { transform: scale(0.88); }
/* Строки-кнопки подсвечиваются целиком, как ячейки списка */
button.row:active, .budget-row:active, .group-toggle:active, .row:has(> .row-main:active) { background-color: var(--press); }
button.row, .budget-row, .group-toggle, .row { transition: background-color 0.25s; }
button.row:active, .budget-row:active, .group-toggle:active, .row:has(> .row-main:active) { transition-duration: 0s; }
button, label, a, [role='checkbox'] { touch-action: manipulation; }

.icon-btn { position: relative; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; font-size: 20px; color: var(--muted); }
.icon-btn:active { background: var(--accent-soft); transform: scale(0.92); transition-duration: 0.06s; }
/* Невидимое расширение зоны нажатия до 44 px, вёрстка не меняется */
.icon-btn::after, .check::after, .filter::after, .segmented button::after, .shared-chip::after, .brush::after {
  content: ''; position: absolute; inset: -4px;
}
.check::after { inset: -8px; }
.icon-btn.big { width: 44px; height: 44px; background: var(--card); box-shadow: var(--shadow); font-size: 20px; }

/* Карточки */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card-title { font-size: 16px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; margin-bottom: 10px; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.card-top .card-title { margin-bottom: 2px; }
.card.group { padding: 0; overflow: hidden; }
.group-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 12px 16px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--card-2); border-bottom: 1px solid var(--line);
}
.group-head > span { margin-left: auto; color: var(--muted); font-weight: 600; white-space: nowrap; text-transform: none; letter-spacing: 0; }
.group-head.split > span { margin-left: auto; }
.group-toggle { text-align: left; }
.prio-bg-urgent { background: var(--p-urgent-bg); }
.prio-bg-high { background: var(--p-high-bg); }
.prio-bg-medium { background: var(--p-medium-bg); }
.prio-bg-low { background: var(--p-low-bg); }
.day-head { padding: 10px 16px 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.chev { font-style: normal; display: inline-block; transition: transform 0.2s; margin-left: 6px; color: var(--muted); }
.chev.up { transform: rotate(180deg); }

.link { display: block; margin: 0 0 -8px; color: var(--accent-strong); font-weight: 600; font-size: 14px; padding: 13px 0; min-height: 44px; }

/* Строки списков */
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; text-align: left; min-height: 56px; }
.card.group .row + .row, .card.group .row + .add-row { border-top: 1px solid var(--line); }
.card:not(.group) .row { padding-left: 0; padding-right: 0; }
.row.compact { min-height: 48px; padding-top: 8px; padding-bottom: 8px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; text-align: left; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; color: var(--muted); }
.task.done .row-title { text-decoration: line-through; color: var(--muted); }
.due.late { color: var(--bad); font-weight: 600; }
.due.soon { color: var(--warn); font-weight: 600; }
.prio-mark { width: 6px; align-self: stretch; border-radius: 3px; flex: none; }
.prio-urgent { background: var(--p-urgent); }
.prio-high { background: var(--p-high); }
.prio-medium { background: var(--p-medium); }
.prio-low { background: var(--p-low); }
.add-row { color: var(--accent-strong); font-weight: 600; min-height: 48px; }

.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--ink); }
.tag-work { background: var(--p-medium-bg); }
.tag-other { background: var(--p-low-bg); }

/* Чекбокс */
.check {
  position: relative; flex: none; width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--accent);
  display: grid; place-items: center; transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.check svg { width: 18px; height: 18px; fill: none; stroke: var(--on-accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check.on { background: var(--accent-strong); border-color: var(--accent-strong); }
.check.on svg { opacity: 1; }
.check:active { transform: scale(0.9); }

/* Переключатели */
.segmented { display: flex; background: var(--track); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.segmented button { position: relative; flex: 1; min-width: 0; padding: 9px 4px; border-radius: 10px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.segmented button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px 2px; }
.card .filters { margin: 0; padding: 0; }
.filters::-webkit-scrollbar { display: none; }
.filter { position: relative; flex: none; padding: 8px 14px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; }
.filter b { color: var(--muted); font-weight: 600; margin-left: 2px; }
.filter.on { background: var(--accent-strong); color: var(--on-accent); }
.filter.on b { color: inherit; opacity: 0.8; }

.month-switch { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 4px; margin-bottom: 12px; }
.month-switch strong { font-size: 15px; }
.month-switch .icon-btn { font-size: 26px; color: var(--ink); }

/* Сводки и плитки */
.hero-card { display: flex; align-items: center; gap: 18px; }
.hero-num { font-size: 30px; font-weight: 700; line-height: 1.15; }
.hero-num small { font-size: 15px; color: var(--muted); font-weight: 600; }
.ring text { font-size: 15px; font-weight: 700; fill: var(--ink); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.tile span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tile b { font-size: 24px; }
.tile-warn b { color: var(--warn); }
.tile-bad b { color: var(--bad); }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.summary span { font-size: 12.5px; }
.summary b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary small { font-size: 11.5px; }
.summary.compact { margin-bottom: 12px; }

.badges { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

/* Полосы прогресса */
.bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; margin: 8px 0 6px; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent-strong); transition: width 0.3s; }
.bar.bar-ok i { background: var(--ok); }
.bar.bar-bad i { background: var(--bad); }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 10px; font-size: 13.5px; }
.hbar-label { display: flex; align-items: center; gap: 6px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 14px; border-radius: 4px; background: var(--track); overflow: hidden; }
.hbar-track i { display: block; height: 100%; background: var(--accent-strong); border-radius: 4px; min-width: 2px; }
.hbar-val { font-weight: 700; text-align: right; min-width: 24px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.cols { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 2px; align-items: end; height: 110px; }
.col { display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; }
.col-bar { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.col-bar i { display: block; width: 100%; background: var(--accent-strong); border-radius: 3px 3px 0 0; min-height: 2px; }
.col.muted .col-bar i { background: var(--track); }
.col-label { font-size: 10.5px; color: var(--muted); height: 12px; }

/* Финансы */
.budget-cat + .budget-cat { border-top: 1px solid var(--line); }
.budget-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; padding: 12px 0; text-align: left; }
.budget-row .bar { grid-column: 1 / -1; margin: 6px 0 2px; }
.budget-name { font-weight: 600; }
.budget-nums { font-size: 14px; text-align: right; }
.budget-nums .muted { font-size: 12.5px; }
.budget-status { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; }
.sub-rows { padding: 0 0 12px 26px; display: flex; flex-direction: column; gap: 8px; }
.sub-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.tx-icon { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); font-size: 18px; }
.tx-amount { font-weight: 700; white-space: nowrap; }
.sub-edit { justify-content: space-between; min-height: 50px; }
.amount-field { display: flex; align-items: baseline; justify-content: center; gap: 8px; padding: 6px 0 16px; }
.amount-field input { width: 100%; max-width: 240px; border: 0; background: none; text-align: center; font-size: 40px; font-weight: 700; outline: none; padding: 0; }
.amount-field span { font-size: 28px; font-weight: 700; color: var(--muted); }

/* Привычки */
.days { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 2px 16px 4px; scroll-snap-type: x proximity; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: none; width: 46px; padding: 8px 0 6px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 1px; scroll-snap-align: center;
}
.day small { font-size: 11px; color: var(--muted); font-weight: 600; }
.day b { font-size: 16px; }
.day-dot { width: 22px; height: 4px; border-radius: 2px; margin-top: 3px; background: linear-gradient(90deg, var(--accent-strong) var(--p), var(--track) var(--p)); }
.day.today b { color: var(--accent-strong); }
.day.on { background: var(--accent-strong); color: var(--on-accent); }
.day.on small, .day.on.today b { color: inherit; }
.day.on .day-dot { background: linear-gradient(90deg, var(--on-accent) var(--p), rgb(255 255 255 / 30%) var(--p)); }
.day:disabled { opacity: 0.45; box-shadow: none; }

.habit .row-main { gap: 4px; }
.streak { color: var(--warn); font-weight: 700; }
.heat { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 2px; margin-top: 4px; max-width: 320px; }
.heat i { height: 7px; border-radius: 2px; background: var(--track); }
.heat i.on { background: var(--accent-strong); }
.heat i.future { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.habit-weekly { flex-wrap: wrap; }
.habit-weekly .row-main { flex-basis: 100%; }
.weeks { display: flex; gap: 6px; width: 100%; }
.week { flex: 1; padding: 6px 0; border-radius: 12px; border: 2px solid var(--accent); display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.week small { font-size: 10.5px; color: var(--muted); }
.week.on { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.week.on small { color: inherit; opacity: 0.85; }
.week:disabled { opacity: 0.4; }
.notes { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); padding: 10px 12px; resize: vertical; }

.area .habit-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--line); }
.area .habit-tags .tag { padding: 5px 10px; gap: 6px; }
.goal-icon { font-size: 18px; }

/* Главная */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.quick button { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; }
.quick button span { font-size: 22px; }
.quick button:active { transform: scale(0.96); }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-icon { font-size: 44px; margin-bottom: 10px; }

/* Плавающая кнопка */
.fab {
  position: fixed; right: max(16px, calc(50% - 280px + 16px)); bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px; border-radius: 18px; background: var(--accent-strong); color: var(--on-accent);
  font-size: 30px; font-weight: 400; line-height: 1; box-shadow: 0 8px 24px rgb(120 70 40 / 30%); z-index: 5;
}
.fab:active { transform: scale(0.94); }

/* Нижнее меню */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  /* Полупрозрачный материал: контент проплывает под панелью, светлая кромка вместо жёсткой линии */
  background: var(--bar-bg);
  backdrop-filter: blur(22px) saturate(170%); -webkit-backdrop-filter: blur(22px) saturate(170%);
  box-shadow: 0 -0.5px 0 var(--hairline);
  padding-bottom: var(--safe-b);
  opacity: 0; transition: opacity 0.2s;
}
body.ready .tabbar { opacity: 1; }
.tabbar button { flex: 1; max-width: 140px; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.on { color: var(--accent-strong); }

/* Шторки */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
/* Положение шторки и затемнение ведёт пружина в ui.js (sheetMotion), а не CSS-transition:
   так её можно схватить на лету, смахнуть вниз и бросить с инерцией. */
.sheet-wrap:not(.open) { pointer-events: none; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--scrim); opacity: 0; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: calc(var(--tg-viewport-stable-height, 100vh) - 24px);
  display: flex; flex-direction: column; background: var(--card); border-radius: 22px 22px 0 0;
  box-shadow: var(--sheet-shadow); transform: translateY(100%); will-change: transform; padding-bottom: var(--safe-b);
}
/* Зона захвата: ручка + шапка. touch-action: none — жест достаётся нам, а не прокрутке страницы */
.sheet-grip { width: 100%; height: 22px; margin-bottom: -10px; touch-action: none; cursor: grab; }
.sheet-grip::before { content: ''; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--grip); margin: 7px auto 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px 4px 20px; touch-action: none; }
.sheet.dragging, .sheet.dragging .sheet-grip { cursor: grabbing; }
.sheet.dragging { user-select: none; -webkit-user-select: none; }
.sheet-head h2 { font-size: 18px; font-weight: 700; }
.sheet-head .icon-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--track); font-size: 14px; font-weight: 700; color: var(--muted); }
.sheet-head .icon-btn::after { inset: -6px; }
.sheet-body { overflow-y: auto; padding: 8px 20px 12px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.sheet-foot { padding: 10px 20px 14px; border-top: 1px solid var(--line); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
.field input, .field textarea, textarea.mono {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card-2);
  padding: 12px 14px; font-size: 16px; outline: none; min-height: 48px;
}
.field input:focus, .field textarea:focus { border-color: var(--accent-strong); }
.field textarea { resize: vertical; }
textarea.mono { font: 12px/1.4 ui-monospace, Consolas, monospace; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 9px 14px; border-radius: 12px; background: var(--card-2); border: 1.5px solid var(--line); font-weight: 600; font-size: 14px; cursor: pointer; }
.chip input:checked + span { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.prio-chip-urgent span { border-left: 5px solid var(--p-urgent); }
.prio-chip-high span { border-left: 5px solid var(--p-high); }
.prio-chip-medium span { border-left: 5px solid var(--p-medium); }
.prio-chip-low span { border-left: 5px solid var(--p-low); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px; border-radius: 14px; font-weight: 700; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent-strong); color: var(--on-accent); }
.btn-ghost { background: var(--accent-soft); }
.btn-danger-ghost { background: var(--bad-soft); color: var(--bad); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.note-box { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 13.5px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 84px); transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; z-index: 30;
  box-shadow: 0 8px 24px rgb(0 0 0 / 18%); transition: opacity 0.2s, transform 0.4s var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast:not(.show) { transform: translate(-50%, 14px) scale(0.96); }

[hidden] { display: none !important; }
.warn { color: var(--warn); }

/* Смены */
.sh-badge {
  flex: none; width: 34px; height: 34px; border-radius: 11px; display: inline-grid; place-items: center; font-size: 17px;
  background: color-mix(in srgb, var(--c) 28%, var(--card)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 70%, transparent);
}
.sh-badge.off { --c: var(--muted); color: var(--muted); }
.sh-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sh-sum > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sh-sum span { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-sum b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-income { margin-top: 12px; }

.cal-card { padding: 12px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.cal-wd.we, .cal-day.we > b { color: var(--accent-strong); }
.cal-day {
  min-height: 62px; border-radius: 12px; background: var(--card-2); padding: 4px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform 0.08s;
}
.cal-day:active { transform: scale(0.94); }
.cal-day > b { font-size: 12.5px; font-weight: 700; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent-strong); }
.cal-shifts { display: flex; flex-direction: column; gap: 2px; width: 100%; align-items: center; }
.cal-shifts i {
  font-style: normal; width: 100%; max-width: 38px; height: 15px; border-radius: 5px; font-size: 11px; line-height: 15px; text-align: center;
  background: color-mix(in srgb, var(--c) 40%, var(--card));
}
.cal-shifts i.more { background: none; color: var(--muted); height: 10px; line-height: 10px; }
.cal-hint { margin: 10px 4px 8px; }
.cal-hint.active { color: var(--ink); font-weight: 600; }
.brushes { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.brushes::-webkit-scrollbar { display: none; }
.brush {
  position: relative; flex: none; padding: 8px 12px; border-radius: 12px; font-weight: 600; font-size: 13.5px; white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--muted)) 18%, var(--card)); border: 1.5px solid color-mix(in srgb, var(--c, var(--muted)) 55%, transparent);
}
.brush.on { background: color-mix(in srgb, var(--c, var(--muted)) 55%, var(--card)); border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.brush.eraser { --c: #9c8f86; }

.sh-table { display: flex; flex-direction: column; font-size: 13.5px; margin-bottom: 8px; }
.sh-tr { display: grid; grid-template-columns: 1fr 52px 64px 92px; gap: 6px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); }
.sh-tr > span:not(:first-child) { text-align: right; }
.sh-tr > span:first-child { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sh-tr .sh-badge { width: 26px; height: 26px; font-size: 14px; border-radius: 8px; }
.sh-tr.head { border-top: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.sh-tr.total { font-weight: 700; }

.sheet-list { display: flex; flex-direction: column; background: var(--card-2); border-radius: 14px; }
.sheet-list .row { padding-left: 12px; padding-right: 12px; }
.sheet-list .row + .row { border-top: 1px solid var(--line); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-name { display: grid; grid-template-columns: 76px 1fr; gap: 12px; }
.field input.emoji-input { text-align: center; font-size: 22px; padding: 8px; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -6px; }
.emoji-pick button { width: 44px; height: 44px; border-radius: 10px; font-size: 20px; }
.emoji-pick button:active { background: var(--accent-soft); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { display: block; padding: 5px; margin: -5px; } /* зона нажатия 44 px при кружке 34 px */
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 2px rgb(0 0 0 / 8%); }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ink); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent-strong); outline-offset: 4px; }
.switch-row { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent-strong); flex: none; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.input-row .btn { min-height: 48px; padding: 0 14px; font-size: 18px; }
.link-inline { color: var(--accent-strong); font-weight: 600; text-decoration: underline; }
.pattern { display: inline-flex; flex-wrap: wrap; gap: 3px; vertical-align: middle; }
.pattern .sh-badge { width: 24px; height: 24px; font-size: 13px; border-radius: 7px; }
.pattern-box { min-height: 44px; padding: 10px; border-radius: 12px; background: var(--card-2); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sh-home { align-items: flex-start; }
.sh-when { width: 64px; flex: none; font-size: 13px; padding-top: 7px; }
.sh-line { display: flex; align-items: center; gap: 10px; }
.sh-line .sh-badge { width: 30px; height: 30px; font-size: 15px; }
.sh-line + .sh-line { margin-top: 6px; }

/* Приветствие и приглашение */
.overlay { position: fixed; inset: 0; z-index: 15; background: var(--bg); overflow-y: auto; }
body.with-overlay { overflow: hidden; }
body.with-overlay .tabbar { visibility: hidden; }
.welcome {
  max-width: 480px; min-height: 100%; margin: 0 auto; padding: 48px 24px calc(24px + var(--safe-b));
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.welcome h1 { font-size: 24px; font-weight: 700; line-height: 1.25; }
.welcome-hero {
  width: 96px; height: 96px; margin: 0 auto 6px; border-radius: 30px; display: grid; place-items: center; font-size: 50px;
  background: linear-gradient(145deg, var(--accent-soft), var(--accent)); box-shadow: var(--shadow);
}
.features { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.features li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.features li > span { font-size: 24px; width: 32px; text-align: center; flex: none; }
.features b { display: block; }
.features small { color: var(--muted); font-size: 13px; }
.welcome-actions { margin-top: auto; padding-top: 8px; display: flex; flex-direction: column; gap: 8px; }

/* Совместный доступ */
.shared-chip { position: relative; margin-top: 8px; padding: 5px 12px; border-radius: 999px; background: var(--accent-soft); font-size: 13px; font-weight: 600; }
.shared-chip.ghost { background: none; box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent-strong); }
.who { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; background: var(--p-medium-bg); color: var(--ink); font-size: 11.5px; font-weight: 600; }
.settings-block { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px; background: var(--card-2); }
.member { display: flex; align-items: center; gap: 10px; }
.member-name { flex: 1; font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-weight: 700; flex: none; }
.invite-box { display: flex; flex-direction: column; gap: 8px; }
.field select {
  width: 100%; min-height: 48px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card-2); font-size: 16px;
}
.row.paused { opacity: 0.55; }
.next-pay { margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); }

/* Смены: деньги, выплаты, цель */
.sh-money { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.sh-money > div { display: flex; flex-direction: column; gap: 2px; }
.sh-money b { font-size: 19px; font-variant-numeric: tabular-nums; }
.payout { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px 0; }
.payout + .payout { border-top: 1px solid var(--line); }
.payout > b { white-space: nowrap; font-size: 16px; font-variant-numeric: tabular-nums; }
.goal-bar { display: flex; height: 12px; border-radius: 999px; background: var(--track); overflow: hidden; margin: 6px 0 8px; }
.goal-bar i { display: block; height: 100%; }
.goal-bar .done, .legend i.done { background: var(--accent-strong); }
.goal-bar .planned, .legend i.planned { background: color-mix(in srgb, var(--accent-strong) 38%, var(--track)); }
.goal-empty .split { flex-wrap: wrap; }

.legal-links { text-align: center; color: var(--muted); margin: 4px 0 0; }
.legal-links .link-inline { font-size: inherit; }

/* Графики */
.chart { display: block; width: 100%; height: auto; margin: 4px 0 2px; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.base { stroke: var(--muted); stroke-opacity: 0.45; }
.chart .axis { font-size: 9.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .axis.on { fill: var(--ink); font-weight: 700; }
.chart .pick-bg { fill: var(--accent-soft); }
.chart [data-act], .chart [data-sact] { cursor: pointer; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.legend span, .readout span { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .readout i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.readout { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13.5px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.readout b { width: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 8px; }
.data-table th { text-align: right; color: var(--muted); font-weight: 600; padding: 4px 2px; }
.data-table td { text-align: right; padding: 5px 2px; border-top: 1px solid var(--line); }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
details.settings-block summary { cursor: pointer; }

/* Кто сколько потратил */
.couple-row { padding: 6px 0 2px; }
.couple-row .member-name { display: flex; align-items: center; gap: 8px; }
.avatar.sm { width: 26px; height: 26px; font-size: 13px; }
.couple-balance {
  display: flex; flex-direction: column; gap: 2px; margin: 10px 0 12px; padding: 12px 14px;
  border-radius: 14px; background: var(--warn-soft); font-size: 15px;
}
.couple-balance.ok { background: var(--ok-soft); }
.stack-fields { display: flex; flex-direction: column; gap: 14px; }
.stack-fields:empty { display: none; }
.icon-btn.sm { width: 24px; height: 24px; font-size: 12px; display: inline-grid; vertical-align: middle; }
.notify-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.notify-row input[type='time'] { flex: none; width: 104px; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-size: 15px; }
.invite-box input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font: 12px/1.4 ui-monospace, Consolas, monospace; }
.gap { margin-bottom: 12px; }

body.offline::before {
  content: 'Нет связи с сервером — изменения сохранятся, когда появится интернет';
  position: fixed; top: 0; left: 0; right: 0; z-index: 25; padding: 6px 12px; text-align: center;
  font-size: 12.5px; font-weight: 600; background: var(--warn-soft); color: var(--warn);
}

@media (hover: hover) {
  .row-main:hover .row-title, .budget-row:hover .budget-name { color: var(--accent-strong); }
}
/* Меньше движения — не значит без отклика: убираем сдвиги и масштаб, оставляем мягкие смены цвета и прозрачности.
   Шторки в этом режиме проявляются через прозрачность (см. sheetMotion в ui.js). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  *:active, *:active svg, .chip:active span, .swatch:active span { transform: none !important; }
  .toast, .toast:not(.show), .toast.show { transform: translate(-50%, 0); }
  .bar i, .chev { transition: none; }
}
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.35s; animation-timing-function: ease; }

/* Меньше прозрачности — плотные поверхности без размытия */
@media (prefers-reduced-transparency: reduce) {
  .tabbar { background: var(--card); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: 0 -1px 0 var(--line); }
}
@media (prefers-contrast: more) {
  .tabbar { background: var(--card); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: 0 -1px 0 var(--ink); }
  .sheet { box-shadow: 0 -1px 0 var(--ink); }
}
