/* Трекер задач: оформление в духе iOS. Цвета берутся из темы Telegram (--tg-theme-*), поэтому приложение само
   становится светлым или тёмным вместе с Telegram. Анимируются только transform и opacity (и штрих у кольца прогресса). */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #efeff4);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --accent: var(--tg-theme-button-color, #007aff);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --red: var(--tg-theme-destructive-text-color, #ff3b30);
  --orange: #ff9500;
  --green: #34c759;
  --violet: #8e5cf7;
  --gold: #f0a30a;
  --gray: #8e8e93;
  --sep: rgba(128, 128, 128, 0.28);
  --press-bg: rgba(128, 128, 128, 0.16);
  --seg-bg: rgba(118, 118, 128, 0.14);
  --seg-thumb: #ffffff;
  --bar-bg: rgba(239, 239, 244, 0.82);
  --red-tint: rgba(255, 59, 48, 0.14);
  --orange-tint: rgba(255, 149, 0, 0.16);
  --green-tint: rgba(52, 199, 89, 0.16);
  --violet-tint: rgba(142, 92, 247, 0.16);
  --gold-tint: rgba(240, 163, 10, 0.18);
  --accent-tint: rgba(0, 122, 255, 0.14);
  --safe-top: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --tabbar: 56px;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-release: cubic-bezier(0.2, 1.25, 0.4, 1);
  color-scheme: light dark;
}
:root[data-scheme="dark"] {
  --seg-bg: rgba(118, 118, 128, 0.28);
  --seg-thumb: #636366;
  --bar-bg: rgba(28, 28, 29, 0.82);
  --press-bg: rgba(255, 255, 255, 0.1);
  --sep: rgba(255, 255, 255, 0.16);
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --bar-bg: color-mix(in srgb, var(--bg2) 80%, transparent);
    --accent-tint: color-mix(in srgb, var(--accent) 16%, transparent);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg2); color: var(--text); }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  font: 17px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button, [role="button"], a { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { cursor: pointer; }
input, textarea { font-size: 16px; } /* меньше 16px iOS увеличивает страницу при вводе */
img { -webkit-user-drag: none; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-s { width: 18px; height: 18px; }
.icon-xs { width: 14px; height: 14px; }
.desc, .comment-body, .link-url, .task-title, .person-title, .access-name { -webkit-user-select: text; user-select: text; } /* текст в карточках выделяется, названия в списках нет: строки нажимаются */

/* ---------- отклик на нажатие ---------- */
/* Класс is-pressed ставится в момент касания (lib/motion.js). Нажатое быстро уменьшается, отпущенное возвращается с лёгким отскоком. */
.pressable { transition: transform 0.4s var(--ease-release), opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease; }
.pressable.is-pressed { transform: scale(var(--press, 0.96)); transition: transform 0.09s ease-out, opacity 0.09s ease-out, background-color 0.09s ease-out, color 0.09s ease-out; }
.press-row.is-pressed { --row-bg: var(--press-bg); }

/* ---------- каркас ---------- */
#app { position: fixed; inset: 0; transform-origin: 50% 0; background: var(--bg2); overflow: hidden; }
.sheet-open #app { will-change: transform; }
.screen {
  position: absolute; inset: 0 0 calc(var(--tabbar) + var(--safe-bottom)) 0;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding-top: var(--safe-top);
}
.screen.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.screen-body { position: relative; } /* едет вниз при «потяни, чтобы обновить» */
.bar {
  position: sticky; top: var(--safe-top); z-index: 4; height: 44px; margin-bottom: -44px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px;
}
.bar::before {
  content: ""; position: absolute; inset: calc(-1 * var(--safe-top)) 0 0 0; z-index: -1; pointer-events: none;
  background: var(--bar-bg); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 0.5px solid var(--sep); opacity: var(--collapse, 0);
}
.bar-title { position: absolute; left: 0; right: 0; text-align: center; pointer-events: none; font-weight: 600; font-size: 17px;
  opacity: var(--collapse, 0); transform: translate3d(0, calc((1 - var(--collapse, 0)) * 6px), 0); }
.bar-side { width: 36px; }
.bar-actions { display: flex; gap: 2px; z-index: 1; margin-left: auto; }
.bar-btn { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--accent); border-radius: 50%; }
.bar-btn.on { background: var(--accent-tint); }
.head { padding: 56px 16px 6px; }
.large-title { margin: 0; font-size: 34px; line-height: 1.08; font-weight: 700; letter-spacing: -0.022em; transform-origin: 0 50%;
  opacity: calc(1 - var(--collapse, 0) * 1.4); transform: translate3d(0, calc(var(--collapse, 0) * -5px), 0); }
.subtitle { margin: 4px 0 0; font-size: 15px; color: var(--hint); letter-spacing: 0; min-height: 1.35em; opacity: calc(1 - var(--collapse, 0) * 1.4); }
.subtitle:empty { display: none; }
.content { padding: 8px 16px calc(var(--tabbar) + 70px); }
.pull-indicator { position: absolute; left: 50%; top: calc(var(--safe-top) + 44px); width: 32px; height: 32px; margin-left: -16px; display: grid; place-items: center; z-index: 3; opacity: 0; color: var(--hint); pointer-events: none; }
.pull-arrow .icon { width: 22px; height: 22px; stroke-width: 2.2; }
.pull-spin { display: none; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--sep); border-top-color: var(--accent); }
.pull-indicator.spinning .pull-arrow { display: none; }
.pull-indicator.spinning .pull-spin, .pull-spin.spinning { display: block; animation: spin 0.8s linear infinite; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  padding: 5px 8px calc(5px + var(--safe-bottom)); background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border-top: 0.5px solid var(--sep);
}
.tab-thumb { position: absolute; top: 5px; bottom: calc(5px + var(--safe-bottom)); left: 8px; width: calc((100% - 16px) / var(--tab-n, 4)); border-radius: 14px; background: var(--accent-tint);
  transform: translate3d(calc(var(--tab-i, 0) * 100%), 0, 0); transition: transform 0.55s var(--ease-pop); pointer-events: none; }
.tab { --press: 0.9; position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 0; border: 0; background: none; color: var(--hint); font-size: 10.5px; font-weight: 500; }
.tab.on { color: var(--accent); font-weight: 600; }
.tab-icon-wrap { position: relative; display: grid; place-items: center; }
.tab-icon { width: 25px; height: 25px; transition: transform 0.5s var(--ease-pop); }
.tab.on .tab-icon { transform: translate3d(0, -1px, 0) scale(1.1); }
.badge { position: absolute; top: -4px; left: calc(100% - 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg2); }

/* ---------- элементы управления ---------- */
.controls { display: grid; gap: 10px; margin: 12px 0 4px; }
.seg { position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); background: var(--seg-bg); border-radius: 10px; padding: 2px; touch-action: pan-y; }
.seg-thumb { position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc((100% - 4px) / var(--n)); border-radius: 8px; background: var(--seg-thumb); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.04); transform: translate3d(calc(var(--i, 0) * 100%), 0, 0); transition: transform 0.5s var(--ease-pop); }
.seg.dragging .seg-thumb { transition: none; }
.seg-btn { --press: 1; position: relative; z-index: 1; border: 0; background: none; padding: 8px 4px; font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--text); transition: color 0.2s ease, opacity 0.2s ease; }
.seg-btn.is-pressed { opacity: 0.55; }
.seg[data-tone="accent"] .seg-btn.on { color: var(--accent); }
.seg[data-tone="green"] .seg-btn.on { color: var(--green); }
.seg[data-tone="red"] .seg-btn.on { color: var(--red); }
.control-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toggle { --press: 0.93; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 7px 13px; background: var(--card); color: var(--hint); font-size: 14px; font-weight: 600; }
.toggle .icon { opacity: 0; width: 0; margin-left: -6px; transition: opacity 0.15s, width 0.2s, margin 0.2s; }
.toggle.on { background: var(--accent-tint); color: var(--accent); }
.toggle.on .icon { opacity: 1; width: 14px; margin-left: 0; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 12px; border-radius: 12px; background: var(--seg-bg); color: var(--hint); }
.search-input { flex: 1; min-width: 0; border: 0; outline: none; background: none; padding: 10px 0; color: var(--text); -webkit-appearance: none; appearance: none; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 32px; height: 32px; background: none; }

.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; font-weight: 600; letter-spacing: -0.005em; overflow: hidden; --press: 0.97; }
.btn-l { min-height: 50px; padding: 12px 18px; border-radius: 14px; font-size: 17px; }
.btn-m { min-height: 42px; padding: 9px 16px; border-radius: 12px; font-size: 15px; }
.btn-s { min-height: 34px; padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.btn-label { display: inline-block; white-space: nowrap; }
.btn-content { display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: opacity 0.18s ease, transform 0.3s var(--ease-out); }
.btn-spin { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; opacity: 0; transform: scale(0.6); transition: opacity 0.18s ease, transform 0.3s var(--ease-out); }
.btn[aria-busy="true"] .btn-content { opacity: 0; transform: scale(0.85); }
.btn[aria-busy="true"] .btn-spin { opacity: 0.9; transform: scale(1); animation: spin 0.7s linear infinite; }
.btn:disabled { opacity: 0.4; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.25); }
.btn-secondary { background: var(--accent-tint); color: var(--accent); }
.btn-gray { background: var(--seg-bg); color: var(--text); }
.btn-danger { background: var(--red-tint); color: var(--red); }
.btn-plain { background: none; color: var(--accent); }
.btn-full { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.btn-row .btn { flex: 1 1 auto; }
.btn-row.compact .btn { min-height: 42px; }
.icon-btn { --press: 0.86; position: relative; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--seg-bg); color: var(--hint); justify-self: end; }
.icon-btn::before { content: ""; position: absolute; inset: -4px; } /* зона нажатия 44 px */
.icon-btn .icon { width: 18px; height: 18px; }
.bar-btn.icon-btn { width: 44px; height: 44px; background: none; color: var(--accent); }
.bar-btn.icon-btn .icon { width: 22px; height: 22px; }
.bar-btn.icon-btn.on { background: var(--accent-tint); }
.fab { --press: 0.88; position: fixed; right: 18px; bottom: calc(var(--tabbar) + var(--safe-bottom) + 16px); z-index: 8; width: 58px; height: 58px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.18), inset 0 0.5px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.5s var(--ease-pop), opacity 0.25s ease; }
.fab.fab-hidden:not(.is-pressed) { transform: translate3d(0, 110px, 0) scale(0.8); opacity: 0; }
.fab .icon { width: 28px; height: 28px; stroke-width: 2.2; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--seg-bg); color: var(--hint); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip-danger { background: var(--red-tint); color: var(--red); }
.chip-accent { background: var(--accent-tint); color: var(--accent); }
.status-pill { display: inline-block; padding: 5px 13px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--seg-bg); margin-bottom: 14px; }
.status-pill.status-doing { background: var(--accent-tint); color: var(--accent); }
.status-pill.status-done { background: var(--green-tint); color: var(--green); }
.role-badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px 1px 5px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.role-owner { background: var(--gold-tint); color: var(--gold); }
.role-admin { background: var(--violet-tint); color: var(--violet); }

.avatar { --s1: 62%; --s2: 56%; --l2: 42%; position: relative; display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; color: #fff; font-weight: 600; letter-spacing: 0; background: linear-gradient(160deg, hsl(var(--hue) var(--s1) 58%), hsl(calc(var(--hue) + 24) var(--s2) var(--l2))); }
:root[data-scheme="dark"] .avatar { --s1: 54%; --s2: 48%; --l2: 44%; }
.avatar-text { position: relative; z-index: 0; }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.3s ease; }
.avatar.has-photo .avatar-img { opacity: 1; }
.avatar.instant .avatar-img { transition: none; }
.avatar-xs { width: 20px; height: 20px; font-size: 9px; }
.avatar-s { width: 28px; height: 28px; font-size: 11px; }
.avatar-m { width: 40px; height: 40px; font-size: 15px; }
.avatar-xl { width: 84px; height: 84px; font-size: 30px; }
.avatar-xxl { width: 112px; height: 112px; font-size: 40px; }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar + .avatar { margin-left: -9px; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--row-bg, var(--card)); }
.avatar-more { background: var(--seg-bg); color: var(--hint); font-size: 10px; font-weight: 700; }
.avatar-empty { background: var(--seg-bg); color: var(--hint); border: 1.5px dashed var(--sep); }
.avatar-all { background: var(--accent-tint); color: var(--accent); }

/* ---------- сводка ---------- */
.summary { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; padding: 14px; border-radius: 18px; background: var(--card); }
.ring { position: relative; flex: none; width: 58px; height: 58px; }
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--seg-bg); stroke-width: 7; }
.ring-value { fill: none; stroke: var(--green); stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease-out); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.sum-stats { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: 2px; min-width: 0; }
.sum-stat { --press: 0.94; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 4px 8px 8px; border: 0; border-radius: 12px; background: transparent; text-align: left; min-width: 0; }
.sum-stat.on { background: var(--accent-tint); }
.sum-num { font-size: 26px; font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sum-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; letter-spacing: -0.01em; color: var(--hint); font-weight: 500; white-space: nowrap; }
.sum-warn .sum-num { color: var(--orange); }
.sum-warn.on { background: var(--orange-tint); }
.sum-danger .sum-num { color: var(--red); }
.sum-danger.on { background: var(--red-tint); }
.sum-stat.zero .sum-num { color: var(--hint); }

/* ---------- лента людей ---------- */
.strip { display: flex; gap: 6px; margin: 0 -16px 6px; padding: 4px 12px 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.strip::-webkit-scrollbar { display: none; }
.strip-item { --press: 0.92; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 62px; padding: 4px 0 2px; border: 0; background: none; color: var(--hint); }
.strip-face { position: relative; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; transition: box-shadow 0.25s ease; }
.strip-item.on .strip-face { box-shadow: 0 0 0 2.5px var(--bg2), 0 0 0 4.5px var(--accent); }
.strip-badge { position: absolute; right: -4px; top: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg2); }
.strip-badge.late { background: var(--red); }
.strip-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 500; }
.strip-item.on .strip-name { color: var(--accent); font-weight: 700; }

/* ---------- списки ---------- */
.groups { display: block; }
.group { margin-top: 22px; }
.group-title { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--hint); }
.group-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count { font-weight: 500; opacity: 0.8; }
.tone-danger .group-title { color: var(--red); }
.tone-warn .group-title { color: var(--orange); }
.tone-done .group-title { color: var(--green); }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row { position: relative; overflow: hidden; cursor: pointer; outline: none; }
.row.leaving { opacity: 0; transform: translate3d(-18px, 0, 0); transition: opacity 0.25s ease, transform 0.25s ease; }
.row-front { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; background: var(--row-bg, var(--card)); touch-action: pan-y; transition: background-color 0.25s ease; }
.row.is-pressed .row-front { transition-duration: 0s; }
.swiping { will-change: transform; }
.row + .row .row-front::before { content: ""; position: absolute; left: 52px; right: 0; top: 0; height: 0.5px; background: var(--sep); }
.row-under { position: absolute; inset: 0; display: flex; align-items: center; visibility: hidden; color: #fff; font-size: 13px; font-weight: 600; --p: 0; }
.under-right { justify-content: flex-start; padding-left: 22px; }
.under-left { justify-content: flex-end; padding-right: 22px; }
.under-in { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; opacity: var(--p); transform: scale(calc(0.6 + 0.4 * var(--p))); transition: transform 0.2s var(--ease-pop); }
.row-under.armed .under-in { transform: scale(1.14); }
.row-under .icon { width: 22px; height: 22px; stroke-width: 2.2; }
.tone-green { background: var(--green); }
.tone-blue { background: var(--accent); }
.tone-gray { background: var(--gray); }
.row-under.armed { filter: brightness(1.08); }
.person-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--row-bg, var(--card)); }
.person-row + .person-row::before { content: ""; position: absolute; left: 66px; right: 0; top: 0; height: 0.5px; background: var(--sep); }
.person-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.person-line-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main { min-width: 0; flex: 1; }
.row-title { font-size: 17px; font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; }
.row-sub { font-size: 13px; color: var(--hint); margin-top: 1px; }
.row-done .row-title, .row.completing .row-title { color: var(--hint); text-decoration: line-through; text-decoration-color: var(--hint); }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 5px; font-size: 13px; color: var(--hint); }
.row-assignee { flex: none; align-self: center; }
.meta-count { display: inline-flex; align-items: center; gap: 4px; }
.meta-muted { font-style: italic; opacity: 0.8; }
.due-pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 6px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--seg-bg); color: var(--hint); }
.due-overdue { background: var(--red-tint); color: var(--red); }
.due-today { background: var(--orange-tint); color: var(--orange); }
.due-done { background: transparent; padding-left: 0; }
.chevron { color: var(--hint); opacity: 0.6; }

.check { --press: 0.8; flex: none; width: 26px; height: 26px; margin-top: -1px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--hint); background: none; color: transparent; }
.check[aria-disabled="true"] { opacity: 0.7; }
.check-doing { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 34%, transparent 38%); }
.check-done { border-color: var(--green); background: var(--green); color: #fff; animation: pop 0.45s var(--ease-pop); }
.check-mark { width: 15px; height: 15px; stroke-width: 3.2; }
.check-mark path { stroke-dasharray: 20; stroke-dashoffset: 20; }
.check-done .check-mark path { stroke-dashoffset: 0; animation: draw 0.4s 0.05s var(--ease-out) backwards; }
@keyframes draw { from { stroke-dashoffset: 20; } to { stroke-dashoffset: 0; } }
@keyframes pop { 0% { transform: scale(0.6); } 100% { transform: scale(1); } }
.enter { animation: rise 0.55s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 26ms); }
@keyframes rise { from { opacity: 0; transform: translate3d(0, 14px, 0); } }

.banner { --press: 0.98; display: flex; align-items: center; gap: 12px; width: 100%; margin: 4px 0 6px; padding: 12px 14px; border: 0; border-radius: var(--radius); background: var(--orange-tint); color: var(--text); text-align: left; font-weight: 600; font-size: 16px; }
.banner-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--orange); color: #fff; flex: none; }
.banner-icon .icon { width: 20px; height: 20px; }
.banner-text { flex: 1; }

.empty { text-align: center; padding: 48px 24px; color: var(--hint); }
.empty-icon { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 14px; border-radius: 50%; background: var(--seg-bg); color: var(--hint); }
.empty-icon .icon { width: 30px; height: 30px; }
.empty-title { font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-text { font-size: 15px; max-width: 300px; margin: 0 auto; }
.empty .btn { margin-top: 16px; }
.spinner { width: 28px; height: 28px; margin: 40px auto; border-radius: 50%; border: 3px solid var(--sep); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton-list { display: grid; gap: 2px; padding: 4px 0; }
.skeleton-row { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--card); margin-bottom: 8px; }
.skeleton-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--seg-bg); flex: none; }
.skeleton-lines { flex: 1; display: grid; gap: 8px; }
.skeleton-line { position: relative; overflow: hidden; display: block; height: 12px; border-radius: 6px; background: var(--seg-bg); }
.skeleton-line.short { width: 55%; }
.skeleton-line::after, .skeleton-dot::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent); transform: translate3d(-100%, 0, 0); animation: shimmer 1.4s var(--ease-out) infinite; animation-delay: calc(var(--i, 0) * 120ms); }
.skeleton-dot { position: relative; overflow: hidden; }
@keyframes shimmer { to { transform: translate3d(100%, 0, 0); } }
.boot { position: absolute; inset: 0; padding: calc(var(--safe-top) + 56px) 16px 0; }
.boot .large-title { margin-bottom: 18px; }
.boot .skeleton-line.title { height: 30px; width: 46%; border-radius: 10px; }
#overlay { position: fixed; inset: 0; z-index: 20; background: var(--bg2); overflow-y: auto; }
.fatal { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 10px; padding: 32px; text-align: center; }
.fatal-title { font-size: 22px; font-weight: 700; }
.fatal-text { color: var(--hint); font-size: 16px; max-width: 320px; margin-bottom: 8px; }

/* ---------- экран без доступа ---------- */
.access-screen { min-height: 100%; display: grid; align-content: center; padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px); }
.access-card { display: grid; justify-items: center; gap: 6px; max-width: 360px; margin: 0 auto; text-align: center; }
.access-card.swap { animation: rise 0.6s var(--ease-out) backwards; }
.access-face { position: relative; margin-bottom: 8px; }
.access-badge { position: absolute; right: -2px; bottom: 0; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--gray); box-shadow: 0 0 0 4px var(--bg2); }
.access-badge .icon { width: 18px; height: 18px; stroke-width: 2.2; }
.access-pending { background: var(--orange); }
.access-blocked { background: var(--red); }
.access-who { display: grid; justify-items: center; gap: 2px; }
.access-name { font-size: 20px; font-weight: 700; }
.access-title { margin: 18px 0 0; font-size: 28px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.access-text { margin: 4px 0 18px; font-size: 16px; color: var(--hint); line-height: 1.4; }
.access-card .btn { margin-top: 4px; }
.access-wait { display: inline-flex; align-items: center; gap: 10px; color: var(--hint); font-size: 15px; font-weight: 500; }

/* ---------- шторка ---------- */
#sheets { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.42); opacity: 0; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: calc(100% - var(--safe-top) - 8px); display: flex; flex-direction: column; background: var(--bg2); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.28); pointer-events: auto; outline: none; will-change: transform; padding-bottom: var(--safe-bottom); }
.sheet.dragging { cursor: grabbing; }
.sheet-head { flex: none; padding: 6px 12px 4px; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.grabber { width: 38px; height: 5px; margin: 0 auto 8px; border-radius: 3px; background: rgba(128, 128, 128, 0.5); }
.sheet-bar { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; min-height: 36px; }
.sheet-title { margin: 0; text-align: center; font-size: 17px; font-weight: 600; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px 20px; -webkit-overflow-scrolling: touch; }

.task-title { margin: 4px 0 14px; font-size: 25px; line-height: 1.2; font-weight: 700; letter-spacing: -0.018em; overflow-wrap: anywhere; }
.task > .seg { margin-bottom: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 4px 14px; margin-bottom: 14px; }
.props { padding: 2px 14px; }
.prop { display: flex; align-items: center; gap: 12px; padding: 11px 0; font-size: 16px; }
.prop + .prop { border-top: 0.5px solid var(--sep); }
.prop-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--seg-bg); color: var(--hint); flex: none; }
.prop-label { color: var(--hint); width: 92px; flex: none; }
.prop-value { flex: 1; min-width: 0; display: flex; justify-content: flex-end; text-align: right; }
.prop-people { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.prop-user, .prop-due { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.prop-due { flex-direction: column; align-items: flex-end; gap: 2px; }
.prop-user-text { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.2; min-width: 0; }
.prop-user .prop-user-text { align-items: flex-start; }
.prop-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.desc { margin: 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.4; }
.section-title { margin: 22px 4px 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--hint); }
.comments { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 14px; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment-main { min-width: 0; flex: 1; background: var(--card); border-radius: 4px 16px 16px 16px; padding: 9px 13px; }
.comment-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; }
.comment-author { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment-nick { font-weight: 400; }
.comment-time { color: var(--hint); flex: none; }
.comment-body { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; }
.comment-empty { color: var(--hint); text-align: center; padding: 12px; font-size: 15px; }
.composer { position: sticky; bottom: 0; display: flex; align-items: flex-end; gap: 8px; margin: 8px -16px -20px; padding: 8px 16px 12px; background: var(--bar-bg); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); border-top: 0.5px solid var(--sep); }
.composer-input { flex: 1; resize: none; max-height: 140px; border: 0; outline: none; border-radius: 19px; padding: 9px 14px; background: var(--card); line-height: 1.3; }
.send { --press: 0.86; flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); }
.send:disabled { opacity: 0.35; }
.send.ready { animation: pop 0.4s var(--ease-pop); }
.send .icon { width: 20px; height: 20px; stroke-width: 2.4; }

/* ---------- формы ---------- */
.field { margin: 16px 0; }
.field-label { display: block; margin: 0 4px 6px; font-size: 13px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--hint); }
.input { display: block; width: 100%; padding: 12px 14px; border: 0; border-radius: 12px; background: var(--card); color: var(--text); outline: none; line-height: 1.3; box-shadow: 0 0 0 0 var(--accent); transition: box-shadow 0.2s var(--ease-out); }
.input:focus { box-shadow: 0 0 0 2px var(--accent); }
.textarea { resize: none; min-height: 84px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { --press: 0.93; border: 0; border-radius: 999px; padding: 9px 15px; background: var(--card); font-size: 15px; font-weight: 500; }
.chip-btn.on { background: var(--accent); color: var(--on-accent); }
.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.people { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.person { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border: 0; background: var(--row-bg, transparent); text-align: left; font-size: 16px; }
.person + .person::before { content: ""; position: absolute; left: 54px; right: 0; top: 0; height: 0.5px; background: var(--sep); }
.person-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-nick { font-size: 13px; }
.person-check { color: var(--accent); }
.form-extra { margin-top: 22px; }
.form-bar { position: sticky; bottom: 0; margin: 14px -16px -20px; padding: 10px 16px 12px; background: var(--bar-bg); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); border-top: 0.5px solid var(--sep); z-index: 2; }

.person-sheet { display: grid; gap: 4px; }
.person-head { display: grid; justify-items: center; gap: 4px; padding: 6px 0 12px; text-align: center; }
.person-title { font-size: 22px; font-weight: 700; margin-top: 6px; }
.chips-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.hint { margin: 8px 4px; font-size: 14px; color: var(--hint); line-height: 1.4; }
.footnote { margin: 22px 4px 0; font-size: 13px; color: var(--hint); text-align: center; }

.access > .seg { margin-bottom: 8px; }
.link-card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; }
.link-card.fresh { box-shadow: 0 0 0 2px var(--accent); animation: rise 0.5s var(--ease-out) backwards; }
.link-title { font-size: 14px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.link-url { font: 13px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; color: var(--text); }
.invite { margin: 12px 0; }
.invite-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.request { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.request-head { display: flex; align-items: center; gap: 12px; }

/* ---------- панель владельца ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
.stat { background: var(--card); border-radius: 16px; padding: 14px; }
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -0.022em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--hint); margin-top: 2px; }
.stat-danger .stat-value { color: var(--red); }
.stat-accent .stat-value { color: var(--accent); }
.role-card { padding: 14px; margin-top: 10px; }
.role-bar { display: flex; gap: 3px; height: 10px; border-radius: 5px; overflow: hidden; }
.role-seg { flex: var(--w, 1) 1 0; min-width: 8px; border-radius: 3px; }
.rc-owner { background: var(--gold); }
.rc-admin { background: var(--violet); }
.rc-commentator { background: var(--accent); }
.rc-viewer { background: var(--gray); }
.role-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 13px; color: var(--hint); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 4px; }
.action-tile { --press: 0.95; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 14px; border: 0; border-radius: 16px; background: var(--card); text-align: left; }
.action-icon { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: #fff; }
.action-icon .badge { top: -5px; left: calc(100% - 10px); }
.tile-violet .action-icon { background: var(--violet); }
.tile-blue .action-icon { background: var(--accent); }
.tile-orange .action-icon { background: var(--orange); }
.tile-gray .action-icon { background: var(--gray); }
.action-label { font-size: 15px; font-weight: 600; }
.card-list { margin-top: 0; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--safe-bottom) + 84px); z-index: 80; display: inline-flex; align-items: center; gap: 8px; max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 999px; background: rgba(44, 44, 48, 0.95); color: #fff; font-size: 15px; font-weight: 500; opacity: 0; transform: translate3d(-50%, 16px, 0) scale(0.92); pointer-events: none; transition: opacity 0.2s ease, transform 0.45s var(--ease-pop); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
#toast.show { opacity: 1; transform: translate3d(-50%, 0, 0) scale(1); }
#toast[data-kind="error"] { background: rgba(196, 42, 42, 0.96); }
#toast[data-kind="success"] { background: rgba(36, 138, 66, 0.96); }
.toast-text { line-height: 1.25; }
.toast-icon { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); }
.toast-icon .icon { width: 12px; height: 12px; stroke-width: 3; }

@media (max-width: 359px) {
  .summary { gap: 6px; padding: 12px; }
  .ring { width: 46px; height: 46px; }
  .ring-label { font-size: 12px; }
  .sum-num { font-size: 21px; }
  .sum-label { font-size: 10.5px; }
}

/* ---------- мышь и предпочтения ---------- */
@media (hover: hover) and (pointer: fine) {
  .row:hover { --row-bg: var(--press-bg); }
  .bar-btn:hover, .icon-btn:hover { background: var(--press-bg); }
  .chip-btn:hover:not(.on) { background: var(--press-bg); }
  .btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
  .btn-secondary:hover:not(:disabled), .btn-gray:hover:not(:disabled), .btn-danger:hover:not(:disabled) { filter: brightness(0.96); }
  .sum-stat:hover, .strip-item:hover .strip-face, .action-tile:hover { filter: brightness(0.97); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .skeleton-line::after, .skeleton-dot::after { animation: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .tabbar, .bar::before, .composer, .form-bar, #toast { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .tabbar, .bar::before, .composer, .form-bar { background: var(--bg2); }
}
@media (prefers-contrast: more) {
  :root { --sep: rgba(128, 128, 128, 0.6); }
  .card, .list, .input, .summary, .stat, .action-tile { outline: 1px solid var(--sep); }
}
