/* TaskTracker — дизайн «Воздух»: мягкие скругления, бирюзовый акцент, много воздуха.
   Мобильная раскладка — следующим этапом. */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/manrope-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f3f6f5;       /* поля, плитки внутри панелей */
  --column: #e3e9e7;          /* подложка колонок доски */
  --border: #dfe6e4;
  --border-strong: #c5d0cd;
  --text: #1f2a28;
  --text-2: #33423f;
  --muted: #5b6b68;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #ccfbf1;
  --primary-ink: #115e59;     /* текст на primary-soft */
  --on-primary: #ffffff;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --success: #15803d;
  --warning: #b45309;
  --unread: #ea580c;
  --unread-soft: #ffedd5;
  --unread-ink: #9a3412;
  --shadow: 0 1px 2px rgb(31 42 40 / 0.05), 0 4px 12px rgb(31 42 40 / 0.04);
  --shadow-panel: 0 1px 2px rgb(31 42 40 / 0.04), 0 6px 20px rgb(31 42 40 / 0.05);
  --shadow-lg: 0 10px 40px rgb(31 42 40 / 0.14);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --header-h: 72px;
  --column-w: 270px;
  --sidebar-w: var(--column-w); /* список проектов — одной ширины с колонками доски */
  --gap: 14px;
  --control-h: 38px; /* высота кнопок, полей ввода и выпадающих списков — одна на всё приложение */
  /* Палитра тонов для цветов типа, приоритета и статуса (выбираются в профиле, prefs.js): фон / текст */
  --gray-bg: #e7ecea;   --gray-fg: #3f4f4c;
  --blue-bg: #dbeafe;   --blue-fg: #1e40af;
  --teal-bg: #ccfbf1;   --teal-fg: #115e59;
  --green-bg: #dcfce7;  --green-fg: #166534;
  --yellow-bg: #fef9c3; --yellow-fg: #854d0e;
  --orange-bg: #ffedd5; --orange-fg: #9a3412;
  --red-bg: #fee2e2;    --red-fg: #991b1b;
  --pink-bg: #fce7f3;   --pink-fg: #9d174d;
  --purple-bg: #ede9fe; --purple-fg: #5b21b6;
  --amber-bg: #fef3c7;  --amber-fg: #92400e;
  --lime-bg: #ecfccb;   --lime-fg: #3f6212;
  --emerald-bg: #d1fae5; --emerald-fg: #065f46;
  --cyan-bg: #cffafe;   --cyan-fg: #155e75;
  --sky-bg: #e0f2fe;    --sky-fg: #075985;
  --indigo-bg: #e0e7ff; --indigo-fg: #3730a3;
  --fuchsia-bg: #fae8ff; --fuchsia-fg: #86198f;
  --mention: #0f766e;
  --mention-me-bg: #fef3c7;
  --scroll-thumb: rgb(31 42 40 / .16);       /* полоса прокрутки: тонкая «таблетка» без дорожки */
  --scroll-thumb-hover: rgb(31 42 40 / .32);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1413;
    --surface: #15201e;
    --surface-2: #1c2927;
    --column: #111a19;
    --border: #23312f;
    --border-strong: #33463f;
    --text: #e3ece9;
    --text-2: #c7d4d0;
    --muted: #95a8a3;
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-soft: #123c37;
    --primary-ink: #99f6e4;
    --on-primary: #06231f;
    --danger: #f87171;
    --danger-soft: #3b1414;
    --success: #4ade80;
    --warning: #fbbf24;
    --unread: #fb923c;
    --unread-soft: #3a2210;
    --unread-ink: #fdba74;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.35);
    --shadow-panel: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 40px rgb(0 0 0 / 0.5);
    --gray-bg: #22302d;   --gray-fg: #b6c5c1;
    --blue-bg: #172554;   --blue-fg: #bfdbfe;
    --teal-bg: #123c37;   --teal-fg: #99f6e4;
    --green-bg: #12301c;  --green-fg: #86efac;
    --yellow-bg: #352b07; --yellow-fg: #fde047;
    --orange-bg: #3a2210; --orange-fg: #fdba74;
    --red-bg: #3b1414;    --red-fg: #fca5a5;
    --pink-bg: #3a1027;   --pink-fg: #f9a8d4;
    --purple-bg: #2a1a4a; --purple-fg: #c4b5fd;
    --amber-bg: #3a2a06;  --amber-fg: #fcd34d;
    --lime-bg: #1f2e0a;   --lime-fg: #bef264;
    --emerald-bg: #0b3326; --emerald-fg: #6ee7b7;
    --cyan-bg: #0c3440;   --cyan-fg: #67e8f9;
    --sky-bg: #0c2d48;    --sky-fg: #7dd3fc;
    --indigo-bg: #1e1b4b; --indigo-fg: #a5b4fc;
    --fuchsia-bg: #3b0f40; --fuchsia-fg: #f0abfc;
    --mention: #5eead4;
    --mention-me-bg: #422f06;
    --scroll-thumb: rgb(227 236 233 / .16);
    --scroll-thumb-hover: rgb(227 236 233 / .32);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 Manrope, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
code, pre, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.9em; }

/* Полосы прокрутки в стиле дизайна: без дорожки и стрелок, тонкая скруглённая «таблетка»,
   ярче при наведении на прокручиваемую область. Chrome/Edge/Safari — ::-webkit-scrollbar (если задать
   scrollbar-color, Chrome игнорирует эти правила, поэтому стандартные свойства — только для Firefox). */
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); background-clip: padding-box; border: 3px solid transparent; border-radius: 999px; min-height: 40px; }
:hover::-webkit-scrollbar-thumb { background-color: var(--scroll-thumb-hover); }
::-webkit-scrollbar-thumb:hover, ::-webkit-scrollbar-thumb:active { background-color: var(--muted); border-width: 2px; }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb-hover) transparent; }
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 18px; font-weight: 700; }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--control-h); padding: 8px 16px; border: 0; border-radius: 10px;
  background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; font-weight: 700;
  transition: background .15s, box-shadow .15s;
}
.btn:hover { background: var(--column); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.danger { color: var(--danger); background: var(--danger-soft); }
.btn.primary.danger { background: var(--danger); color: #fff; }
.btn.small { min-height: 32px; padding: 5px 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--muted); border-color: var(--muted) transparent var(--muted) transparent;
  animation: spin .8s linear infinite;
}
.btn.primary.is-busy::after { border-color: var(--on-primary) transparent var(--on-primary) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px;
  border: 0; border-radius: 12px; background: var(--surface-2); cursor: pointer; font-size: 16px; position: relative; color: var(--muted);
}
.icon-btn:hover { background: var(--column); color: var(--text); }
.icon-btn.small { min-width: 26px; height: 26px; font-size: 12px; border-radius: 8px; }
.icon-btn.danger-hover:hover { background: var(--danger-soft); color: var(--danger); }
.svg-icon { display: block; flex: none; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); cursor: pointer; font-size: 13px; font-weight: 700; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

.input, .select {
  /* Высота как у кнопок: 19px строка + 2×8px отступы + 2×1.5px рамка = 38px (--control-h). */
  width: 100%; min-height: var(--control-h); padding: 8px 12px; border: 1.5px solid transparent; border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: inherit; line-height: 19px;
  transition: border-color .15s, background .15s;
}
.input:hover, .select:hover { border-color: var(--border); }
.input:focus, .select:focus, .btn:focus-visible, .icon-btn:focus-visible, .card-tile:focus-visible, .key-btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent;
}
.input:focus, .select:focus { background-color: var(--surface); }
.input[readonly] { color: var(--muted); }
textarea.input { resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 34px; cursor: pointer; white-space: nowrap;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.select.small {
  /* 32px = 13px строка + 2×8px отступы + 2×1.5px рамка: текст ровно по центру и в системном, и в настраиваемом списке. */
  width: auto; height: 32px; min-height: 32px; padding: 8px 30px 8px 12px; line-height: 13px; font-size: 13px; font-weight: 700;
  background-color: var(--surface); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; border-radius: 9px;
}

/* Выпадающий список в стиле «Воздух» — настраиваемый select (Chrome/Edge 135+).
   Где не поддерживается (Firefox, Safari), остаётся системный список — функционально то же самое. */
@supports (appearance: base-select) {
  .select, .select::picker(select) { appearance: base-select; }
  .select::picker-icon { display: none; } /* стрелка — наша, фоном */
  .select::picker(select) {
    margin-top: 6px; padding: 6px; min-width: anchor-size(width); max-height: min(320px, 60vh); overflow-y: auto;
    border: 0; border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
    font-size: 14px; font-weight: 600;
    opacity: 1; transform: none; transition: opacity .12s, transform .12s, overlay .12s allow-discrete, display .12s allow-discrete;
  }
  .select:not(:open)::picker(select) { opacity: 0; transform: translateY(-4px); }
  @starting-style { .select:open::picker(select) { opacity: 0; transform: translateY(-4px); } }
  .select option { padding: 9px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; outline: none; }
  .select option::checkmark { display: none; }
  .select option:hover, .select option:focus-visible { background: var(--surface-2); }
  .select option:checked { background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }
  .select option:checked:hover, .select option:checked:focus-visible { background: var(--primary-soft); filter: brightness(.97); }
}

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-weight: 700; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.field-hint.warning { color: var(--warning); }
.field-error, .form-error { color: var(--danger); font-size: 13px; font-weight: 600; }
.field-error:empty, .form-error:empty { display: none; }
.field.has-error .input { border-color: var(--danger); }
.form-error { margin: 4px 0 12px; }
.form-success { color: var(--success); font-weight: 600; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; align-items: center; }
.form-actions.left { justify-content: flex-start; margin-top: 10px; }
.form-actions.spread { justify-content: space-between; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form .field { flex: 1; min-width: 0; margin-bottom: 0; }
.inline-form > .btn { flex: none; }
.section-title { font-size: 15px; font-weight: 800; color: var(--text); margin: 22px 0 10px; }
.danger-title { color: var(--danger); }

.tag { display: inline-block; padding: 2px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag-owner, .tag-pending { background: var(--primary-soft); color: var(--primary-ink); }
.tag-expired { background: var(--danger-soft); color: var(--danger); }
.tag-bot { background: var(--surface-2); color: var(--text-2); }

.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 99px; background: var(--unread-soft); color: var(--unread-ink); font-size: 11px; font-weight: 800;
}
/* Колокольчик: без непрочитанного — серый (цвет кнопки), с непрочитанным — оранжевый. */
.bell.has-unread { color: var(--unread); }
.bell .badge { position: absolute; top: -4px; right: -4px; background: var(--unread); color: #fff; box-shadow: 0 0 0 2px var(--surface); }

/* ---------- Аватары: скруглённые квадраты ---------- */
.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 30%; color: #fff;
  font-weight: 700; user-select: none; letter-spacing: .02em;
}
.avatar-xs { width: 22px; height: 22px; font-size: 9px; border-radius: 7px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; border-radius: 9px; }
.avatar-md { width: 36px; height: 36px; font-size: 13px; border-radius: 12px; }
.avatar-system { background: var(--surface-2); color: var(--muted); }
.avatar-empty { width: 26px; height: 26px; border-radius: 9px; border: 1.5px dashed var(--border-strong); flex: none; }

/* ---------- Вход ---------- */
.auth-page { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 24px; padding: 36px; box-shadow: var(--shadow-lg); }
.auth-logo { font-weight: 800; font-size: 19px; margin-bottom: 22px; letter-spacing: -.01em; }
.auth-logo span { color: var(--primary); }
.auth-card h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 22px; }
.auth-links { margin-top: 16px; text-align: center; font-weight: 600; }
.auth-note { margin-top: 22px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-invite { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; padding: 12px 14px; border-radius: var(--radius); margin: 0 0 18px; }

/* ---------- Каркас ---------- */
.app { height: 100%; display: flex; flex-direction: column; padding: var(--gap); gap: var(--gap); }
.header {
  flex: none; display: flex; align-items: center; gap: 18px; padding: 10px 14px 10px 22px;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel); z-index: 20;
}
.logo { font-weight: 800; font-size: 21px; color: var(--text); text-decoration: none; letter-spacing: -.01em; width: calc(var(--sidebar-w) - 22px); }
.logo span { color: var(--primary); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
/* Все элементы шапки — одной высоты (36px, как поиск) и с одним скруглением (10px): колокольчик, меню пользователя.
   Подложка — одинаковая серая; при наведении темнее. */
.header-right .icon-btn { width: 36px; min-width: 36px; height: 36px; padding: 0; border-radius: 10px; }
.user-btn {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 4px; border: 0; border-radius: 10px;
  background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; font-weight: 700;
}
.user-btn:hover { background: var(--column); }
.user-btn .avatar { border-radius: 8px; }
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-banner { background: var(--unread-soft); color: var(--unread-ink); text-align: center; padding: 6px; font-size: 13px; font-weight: 700; border-radius: var(--radius); }
.app-body { flex: 1; display: flex; gap: var(--gap); min-height: 0; }

.dropdown-wrap { position: relative; }
.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 240px; background: var(--surface);
  border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden;
}
.menu { display: flex; flex-direction: column; padding: 8px; }
.menu-caption { padding: 6px 12px 8px; font-size: 12px; color: var(--muted); }
.menu-item { text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-decoration: none; color: var(--text); font-weight: 600; }
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-empty { padding: 22px; text-align: center; color: var(--muted); }

/* Поиск */
/* Поиск — шириной в две колонки доски, высотой 36px. */
.search { position: relative; flex: 0 1 calc(var(--column-w) * 2 + var(--gap)); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; pointer-events: none; }
.search-input { width: 100%; height: 36px; padding: 0 14px 0 38px; border: 1.5px solid transparent; border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; }
.search-input:focus { outline: 2px solid var(--primary); background: var(--surface); }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; max-height: 60vh; overflow: auto; padding: 6px;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 50;
}
.search-item { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; cursor: pointer; border-radius: 10px; }
.search-item:hover, .search-item.active { background: var(--surface-2); }
.search-item-head { display: flex; gap: 10px; align-items: baseline; }
.search-title { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.search-snippet { font-size: 12px; color: var(--muted); margin-top: 2px; }
.search-snippet-author { color: var(--text); font-weight: 600; }
.search-snippet mark { background: var(--unread-soft); color: var(--unread-ink); border-radius: 3px; padding: 0 2px; }
.search-empty { padding: 16px; color: var(--muted); text-align: center; }

/* Уведомления */
.notifications { width: 400px; max-height: 70vh; overflow: auto; display: flex; flex-direction: column; padding: 6px; }
.notifications-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 12px; font-size: 15px; }
.notification { display: flex; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; cursor: pointer; border-radius: 12px; flex: none; }
.notification:hover { background: var(--surface-2); }
.notification.unread { background: var(--primary-soft); }
.notification.unread .notification-title { color: var(--primary-ink); }
.notification-text { min-width: 0; flex: 1; }
.notification-title { font-weight: 700; }
.notification-body { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notification-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Боковая панель */
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel);
  display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; padding: 14px 14px 18px;
  /* Сворачивание: ширина уходит в 0, промежуток до доски — отрицательным отступом; visibility — после анимации. */
  transition: width .25s ease, padding .25s ease, margin .25s ease, opacity .2s ease, visibility 0s linear 0s;
}
/* Содержимое не перестраивается при изменении ширины — просто обрезается. */
.sidebar > * { min-width: calc(var(--sidebar-w) - 28px); }
.sidebar-section { margin-bottom: 20px; }
.sidebar-section.grow { flex: 1; display: flex; flex-direction: column; margin-bottom: 0; }
.sidebar-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 6px 10px; }
/* Шапка списка проектов зеркальна панели над доской: строка 32px на 14px от верха, кнопка сворачивания — справа;
   «Проекты» и название проекта — на одной линии и одного размера.
   Отступ 18px: 14 + 32 + 18 = 64px — верх колонок доски (10 + 4 + 32 + 4 + промежуток 14), первый проект на их уровне. */
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 32px; margin-bottom: 18px; }
.sidebar-head .sidebar-title { margin: 0 0 0 10px; /* по левому краю ключей проектов в списке */ font-size: 22px; line-height: 32px; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.sidebar-toggle.icon-btn, .sidebar-head-actions .icon-btn { flex: none; width: 32px; min-width: 32px; height: 32px; padding: 0; border-radius: 9px; background: var(--surface-2); }
/* Свёрнутая панель скрыта целиком; развернуть — кнопкой «»» слева от названия проекта. */
.sidebar.collapsed {
  width: 0; padding-left: 0; padding-right: 0; margin-right: calc(-1 * var(--gap)); opacity: 0; overflow: hidden; visibility: hidden;
  transition: width .25s ease, padding .25s ease, margin .25s ease, opacity .15s ease, visibility 0s linear .25s;
}
.project-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
/* Строка проекта: название как заголовок колонки «Бэклог» (15px). Выбранный проект — как карточка на доске:
   белый фон, чёрный текст, мягкая тень и тонкая рамка (на белой панели одной тени мало). */
.project-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius);
  text-decoration: none; color: var(--text); font-size: 15px; font-weight: 700; transition: background .15s, box-shadow .15s;
}
.project-item:hover { background: var(--surface-2); color: var(--text); }
.project-item.active { background: var(--surface); color: var(--text); font-weight: 800; box-shadow: 0 0 0 1px var(--border), 0 4px 14px rgb(31 42 40 / 0.08); }
.project-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* ключ — к правому краю */
.project-key {
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; min-width: 34px; height: 26px; padding: 0 6px;
  border-radius: 8px; background: var(--surface-2); color: var(--text-2);
}
.project-item.active .project-key { background: var(--primary-soft); color: var(--primary-ink); } /* светлый, как в заголовке над доской */
.project-key.large { font-size: 13px; height: 28px; background: var(--primary-soft); color: var(--primary-ink); }
/* «Новый проект» — только при наведении на список (и при фокусе с клавиатуры); без проектов — всегда. */
.new-project { margin-top: auto; color: var(--primary); opacity: 0; transition: opacity .15s ease; }
.sidebar:hover .new-project, .new-project:focus-visible, .new-project.always { opacity: 1; }
.invitation { padding: 14px; border-radius: 14px; background: var(--primary-soft); margin-bottom: 8px; }
.invitation-project { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.invitation .project-key { background: var(--surface); }
.invitation-from { font-size: 13px; color: var(--primary-ink); margin: 4px 0 12px; }
.invitation-actions { display: flex; gap: 8px; }
.invitation-actions .btn { flex: 1; }
.invitation-actions .btn:not(.primary) { background: var(--surface); color: var(--primary-ink); }

/* ---------- Доска ---------- */
.main { flex: 1; min-width: 0; overflow: auto; }
.board-page { height: 100%; display: flex; flex-direction: column; gap: var(--gap); padding-top: 10px; } /* 10 + 4 = 14px — как у шапки списка проектов */
.board-loading { padding: 24px; }
/* Группа названия — ровно над колонкой «Бэклог» (от её левого края), промежуток как между колонками:
   фильтры начинаются с левого края колонки «В работе». Длинное название — с многоточием. */
.board-toolbar {
  display: grid; grid-template-columns: var(--column-w) auto minmax(max-content, 1fr); align-items: center;
  column-gap: var(--gap); padding: 4px 6px 4px 0;
}
/* Узкая доска: элементы не переносятся, а скрываются по очереди (board.js, fitToolbar) —
   фильтры, участники, «Отметить всё прочитанным»; в последнюю очередь сжимается название. */
.board-filters { grid-column: 2; display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; justify-content: flex-start; }
.board-filters .select { flex: none; } /* не сжимаются: не помещаются — fitToolbar скрывает фильтры целиком */
.board-filters .select.is-active { border-color: var(--primary); background-color: var(--primary-soft); color: var(--primary-ink); } /* выбран фильтр */
.filters-reset.icon-btn { flex: none; width: 32px; min-width: 32px; height: 32px; padding: 0; border-radius: 9px; }
.filters-reset.icon-btn, .filters-reset.icon-btn:hover { color: var(--danger); }
.filters-reset.icon-btn:hover { background: var(--danger-soft); }
.board-tools { grid-column: 3; }
.board-toolbar.hide-filters .board-filters,
.board-toolbar.hide-members .members-stack,
.board-toolbar.hide-read-all .read-all-btn { display: none; }
.board-toolbar.shrink-title { grid-template-columns: minmax(0, var(--column-w)) auto minmax(max-content, 1fr); }
.board-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.board-title h1 { font-size: 22px; line-height: 32px; font-weight: 800; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-expand { position: relative; flex: none; }
.unread-dot { position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--unread); box-shadow: 0 0 0 2px var(--bg); }
.board-tools { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; justify-content: flex-end; }
/* Все элементы панели над доской — одной высоты (32px) и по центру строки. */
.board-toolbar .icon-btn { min-width: 32px; width: 32px; height: 32px; padding: 0; border-radius: 9px; font-size: 14px; background: var(--surface); }
.board-toolbar .icon-btn:hover { background: var(--column); }
.board-toolbar .btn.small { min-height: 32px; height: 32px; padding: 0 12px; border-radius: 9px; background: var(--surface); }
/* Ключ текущего проекта — один размер в списке проектов и в заголовке над доской (при сворачивании он «перелетает»);
   flex: none — в заголовке ширина группы названия фиксирована, и без этого ключ сжимался. */
.project-item .project-key, .board-title .project-key { flex: none; height: 24px; min-width: 40px; padding: 0 7px; font-size: 12px; border-radius: 7px; }
/* Кнопка разворота списка проектов: место под неё плавно раскрывается/схлопывается (0,25 с — как сворачивание списка),
   поэтому название проекта отъезжает плавно. Сама кнопка в это время «прилетает» копией (shell.js, animateToggle). */
.board-toolbar .sidebar-expand { overflow: hidden; transition: width .25s ease, min-width .25s ease, margin .25s ease, opacity .25s ease; }
.board-toolbar .sidebar-expand.is-hidden { width: 0; min-width: 0; margin-right: -10px; opacity: 0; pointer-events: none; }
.board-toolbar .sidebar-expand .unread-dot { top: 2px; right: 2px; }
/* На время замера итоговой раскладки (shell.js) переходы выключены. */
body.measure-layout .sidebar, body.measure-layout .board-toolbar .sidebar-expand { transition: none !important; }
/* Ключ проекта у названия нужен, только когда список проектов не виден (свёрнут или на его месте открыта карточка). */
.board-title .project-key { transition: opacity .25s ease; }
.app-body:not(.has-card):has(> .sidebar:not(.collapsed)) .board-title .project-key { visibility: hidden; opacity: 0; } /* место остаётся */
.members-stack { display: flex; padding: 0 4px; }
.members-stack .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--bg); }
.members-stack .avatar:first-child { margin-left: 0; }
.more-count { font-size: 12px; color: var(--muted); align-self: center; margin-left: 4px; font-weight: 700; }

/* Колонки фиксированной ширины, прижаты влево и не сжимаются: если места не хватает (например, открыта карточка),
   внизу доски появляется горизонтальная прокрутка. */
.board {
  flex: 1; display: grid; grid-template-columns: repeat(4, var(--column-w)); justify-content: start; gap: var(--gap);
  min-height: 0; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px;
}
.column { background: var(--column); border-radius: var(--radius-lg); display: flex; flex-direction: column; min-height: 0; padding: 12px 6px 6px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 2px 8px 12px; }
.column-head h2 { font-size: 15px; font-weight: 800; }
.column-count { font-size: 13px; font-weight: 700; color: var(--muted); }
/* padding/-margin 4px — запас под кольцо выделения карточки (непрочитанное — 3px за краем), иначе overflow его обрезает. */
.column-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 80px; padding: 4px; margin: -4px; }
/* «Недавно закрытые»: приглушённые карточки, подсказка для перетаскивания, ссылка на историю. */
.column-closed .card-tile.is-closed { opacity: .75; }
.column-closed .card-tile.is-closed:hover { opacity: 1; }
.column-closed .card-tile.is-closed .card-title { text-decoration: line-through; text-decoration-color: var(--border-strong); }
.column-closed .column-list:empty::before {
  content: attr(data-empty); display: grid; place-items: center; min-height: 76px; padding: 8px; text-align: center;
  font-size: 13px; color: var(--muted); border: 2px dashed var(--border-strong); border-radius: 14px;
}
.column-footer { align-self: flex-start; margin: 10px 8px 4px; }
.card-closed-at { margin: -8px 0 10px; font-size: 12px; color: var(--muted); }
.history-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow-y: auto; }
.history-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); text-align: left; cursor: pointer; font: inherit;
}
.history-row:hover { background: var(--primary-soft); }
.history-key { font-size: 12px; font-weight: 800; color: var(--muted); flex: none; min-width: 52px; }
.history-title { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-assignee { flex: none; display: flex; }
.history-when { flex: none; font-size: 12px; color: var(--muted); }
.quick-add { padding: 0 0 10px; }
.quick-add-input { background: var(--surface); }

.card-tile {
  background: var(--surface); border-radius: 14px; padding: 11px 12px 10px;
  box-shadow: var(--shadow); cursor: pointer; user-select: none; position: relative; transition: box-shadow .15s, transform .15s;
}
.card-tile:hover { box-shadow: 0 1px 2px rgb(31 42 40 / 0.06), 0 8px 20px rgb(31 42 40 / 0.08); }
.card-tile.is-open { box-shadow: 0 0 0 2px var(--primary), 0 8px 20px rgb(15 118 110 / 0.18); }
/* Копия карточки, плавно перелетающая в другую колонку при смене статуса (board.js, flip). */
.card-flyer { position: fixed; margin: 0; z-index: 60; pointer-events: none; box-shadow: var(--shadow-lg); }
/* Подсказка карточки на доске (cardTooltip.js): белая панель «Воздух» — номер и заголовок, описание, автор и дата.
   Интерактивная (TT-34): мышь можно перевести на неё, описание прокручивается, клик по номеру/заголовку открывает карточку. */
.card-tooltip {
  position: fixed; z-index: 70; width: max-content; max-width: 360px; max-height: calc(100vh - 16px); padding: 12px 14px;
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border-radius: 14px; box-shadow: var(--shadow-lg);
  font-size: 13px; line-height: 1.45;
  opacity: 0; transform: translateY(4px); visibility: hidden;
  transition: opacity .15s ease, transform .15s ease, visibility 0s linear .15s;
}
.card-tooltip.is-visible { opacity: 1; transform: none; visibility: visible; transition: opacity .15s ease, transform .15s ease; }
.card-tooltip-head { display: flex; flex-direction: column; gap: 2px; flex: none; cursor: pointer; }
.card-tooltip-head:hover .card-tooltip-title { color: var(--primary); }
.card-tooltip-key { font-size: 12px; font-weight: 700; color: var(--muted); }
.card-tooltip-title { font-size: 14px; font-weight: 800; overflow-wrap: anywhere; }
/* Описание — до ~14 строк, длиннее — прокручивается внутри подсказки (прокрутка не уходит на доску). */
.card-tooltip-desc {
  margin-top: 8px; color: var(--text-2); max-height: calc(1.45em * 14); min-height: 0; flex: 0 1 auto;
  overflow-y: auto; overscroll-behavior: contain; overflow-wrap: anywhere; scrollbar-width: thin;
}
.card-tooltip-desc.is-empty { color: var(--muted); font-style: italic; }
.card-tooltip-rels { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-2); }
.card-tooltip-rel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-tooltip-rel-label { color: var(--muted); }
.card-tooltip-rels { flex: none; }
.card-tooltip-meta { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); flex: none; }
.card-tooltip-meta strong { color: var(--text); font-weight: 700; }
.card-tile.has-unread { box-shadow: 0 0 0 2px var(--unread-soft), 0 0 0 3px var(--unread); }
.card-tile.has-unread.is-open { box-shadow: 0 0 0 2px var(--primary), 0 8px 20px rgb(15 118 110 / 0.18); }
/* Первая строка: заголовок на всю ширину в одну строку (не помещается — многоточие). Номер — в нижней строке. */
.card-head { display: flex; align-items: center; margin-bottom: 8px; }
/* Ширина по тексту (не на всю строку) — подсказка с описанием появляется только при наведении на сам заголовок. */
.card-title { flex: 0 1 auto; min-width: 0; font-size: 15px; font-weight: 700; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-key { flex: none; font-size: 12px; font-weight: 700; color: var(--muted); }
/* Номер — кнопка (TT-24): клик копирует ссылку на карточку; выглядит как текст, при наведении — подложка. */
.card-key-btn { height: 20px; margin-left: -5px; padding: 0 5px; border: 0; border-radius: 6px; background: none; font-family: inherit; cursor: copy; }
.card-key-btn:hover { background: var(--surface-2); color: var(--text); }
.card-key-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* Значки связей (TT-20): «↑ TT-2» — родитель (кнопка), «☰ 2/5» — подзадачи (все готовы — зелёным), ⛔ — заблокирована. */
.card-rels { display: inline-flex; align-items: center; gap: 4px; min-width: 0; margin-left: 6px; overflow: hidden; }
.card-rel {
  flex: none; display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 6px; border: 0; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font: inherit; font-size: 11px; font-weight: 700; white-space: nowrap;
}
button.card-rel { cursor: pointer; }
button.card-rel:hover { background: var(--column); color: var(--text); }
button.card-rel:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.card-rel-children.is-done { background: var(--green-bg); color: var(--green-fg); }
.card-rel-blocked { background: var(--danger-soft); color: var(--danger); padding: 0 4px; }
/* Наведение на карточку — её родитель и подзадачи подсвечиваются рамкой. */
.card-tile.is-family { box-shadow: 0 0 0 2px var(--primary-soft), 0 0 0 3px var(--primary); }
/* Вторая строка: плашки приоритета и типа; при наведении справа — кнопки ←/→. */
.card-top { position: relative; display: flex; align-items: center; gap: 8px; min-height: 22px; margin-bottom: 12px; overflow: hidden; }
.card-top > .plate, .card-top > .priority { white-space: nowrap; }
.card-type { font-weight: 600; } /* тип — плашкой (.plate), цвет из профиля */
.card-bottom { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.card-assignee { display: inline-flex; align-items: center; }
.card-assignee .avatar-empty { width: 22px; height: 22px; border-radius: 7px; } /* как аватар xs исполнителя */
/* Слева внизу — номер (клик — скопировать ссылку); справа — бейдж новых сообщений (если есть) и аватар исполнителя. */
.card-counters { margin-left: auto; display: flex; gap: 8px; align-items: center; flex: none; }
.counter.unread { background: var(--unread-soft); color: var(--unread-ink); border-radius: 99px; padding: 2px 8px; font-weight: 800; }
.priority, .plate { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 8px; padding: 2px 8px; }
/* Тоны (prefs.js): класс .tone-* задаёт --tone-bg / --tone-fg; плашки, чипы и точки статуса их используют. */
.tone-gray { --tone-bg: var(--gray-bg); --tone-fg: var(--gray-fg); }
.tone-blue { --tone-bg: var(--blue-bg); --tone-fg: var(--blue-fg); }
.tone-teal { --tone-bg: var(--teal-bg); --tone-fg: var(--teal-fg); }
.tone-green { --tone-bg: var(--green-bg); --tone-fg: var(--green-fg); }
.tone-yellow { --tone-bg: var(--yellow-bg); --tone-fg: var(--yellow-fg); }
.tone-orange { --tone-bg: var(--orange-bg); --tone-fg: var(--orange-fg); }
.tone-red { --tone-bg: var(--red-bg); --tone-fg: var(--red-fg); }
.tone-pink { --tone-bg: var(--pink-bg); --tone-fg: var(--pink-fg); }
.tone-purple { --tone-bg: var(--purple-bg); --tone-fg: var(--purple-fg); }
.tone-amber { --tone-bg: var(--amber-bg); --tone-fg: var(--amber-fg); }
.tone-lime { --tone-bg: var(--lime-bg); --tone-fg: var(--lime-fg); }
.tone-emerald { --tone-bg: var(--emerald-bg); --tone-fg: var(--emerald-fg); }
.tone-cyan { --tone-bg: var(--cyan-bg); --tone-fg: var(--cyan-fg); }
.tone-sky { --tone-bg: var(--sky-bg); --tone-fg: var(--sky-fg); }
.tone-indigo { --tone-bg: var(--indigo-bg); --tone-fg: var(--indigo-fg); }
.tone-fuchsia { --tone-bg: var(--fuchsia-bg); --tone-fg: var(--fuchsia-fg); }
.priority, .plate { background: var(--tone-bg, var(--gray-bg)); color: var(--tone-fg, var(--gray-fg)); }
.status-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tone-fg, var(--gray-fg)); }
.card-ghost { opacity: .4; }
.card-chosen { box-shadow: var(--shadow-lg); }
.card-drag { opacity: .95; transform: rotate(1.5deg); }
body.is-dragging .column { outline: 2px dashed var(--border-strong); outline-offset: -2px; }
.empty-state { display: grid; place-items: center; height: 100%; color: var(--muted); padding: 40px; text-align: center; font-weight: 600;
  background: var(--surface); border-radius: var(--radius-lg); }

/* ---------- Панель карточки ---------- */
/* Открытая карточка встаёт слева вместо списка проектов (по умолчанию — половина рабочей области),
   доска сдвигается вправо. Ширину задаёт пользователь, перетаскивая правый край. */
.app-body.has-card > .sidebar { display: none; }
.card-panel {
  position: relative; flex: none; width: 50%; min-width: calc(var(--column-w) * 2 + var(--gap)); /* не уже двух колонок доски */ max-width: calc(100% - 320px);
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel);
}
.card-panel-inner { height: 100%; display: flex; flex-direction: column; overflow: hidden; border-radius: inherit; animation: card-content-in .45s cubic-bezier(.22, 1, .36, 1) .06s backwards; }
@keyframes card-content-in { from { opacity: 0; transform: translateX(-16px); } }
/* Анимация открытия (card.js, animateOpen): ширина растёт от ширины списка проектов, доска отъезжает вправо. */
/* Открытие «со списка проектов» — три шага внахлёст: текст списка гаснет (копия, card.js fadeOutSidebar, 0–0,16 с),
   проявляется содержимое карточки в ширине списка (с 0,14 с), сразу за ним панель плавно расширяется
   (с 0,18 с, 0,8 с, easeOutQuint). Закрытие — 0,35 с, симметричное замедление. */
.card-panel.is-opening, .card-panel.is-closing { min-width: 0; overflow: hidden; will-change: width; }
.card-panel.is-opening { transition: width .8s cubic-bezier(.22, 1, .36, 1) .18s, margin-right .8s cubic-bezier(.22, 1, .36, 1) .18s; }
/* Список проектов свёрнут — гасить нечего: расширяемся сразу, без паузы. */
.card-panel.is-opening.from-zero { transition-delay: 0s; }
.card-panel.is-opening.from-zero .card-panel-inner { animation-delay: .05s; }
.card-panel.is-opening .card-panel-inner { animation-duration: .32s; animation-delay: .14s; }
.card-panel.is-closing { transition: width .35s cubic-bezier(.4, 0, .2, 1), margin-right .35s cubic-bezier(.4, 0, .2, 1); }
/* Закрытие: панель сужается до ширины списка проектов, содержимое гаснет. */
.card-panel.is-closing { pointer-events: none; }
.card-panel.is-closing .card-panel-inner { opacity: 0; transform: translateX(-12px); transition: opacity .2s ease, transform .35s cubic-bezier(.4, 0, .2, 1); }
.card-panel.is-opening .card-resizer, .card-panel.is-closing .card-resizer { display: none; }
/* Ручка на правом краю — в промежутке между панелью и доской. */
.card-resizer {
  position: absolute; top: 0; bottom: 0; right: calc(var(--gap) / -2 - 5px); width: 10px; cursor: col-resize; z-index: 2; touch-action: none;
}
.card-resizer::after {
  content: ''; position: absolute; top: 50%; left: 3px; width: 4px; height: 48px; transform: translateY(-50%);
  border-radius: 4px; background: var(--border-strong); opacity: .6; transition: opacity .15s, background .15s, height .15s;
}
.card-resizer:hover::after, .card-resizer:focus-visible::after, body.is-resizing .card-resizer::after { opacity: 1; background: var(--primary); height: 96px; }
.card-resizer:focus-visible { outline: none; }
body.is-resizing { cursor: col-resize; user-select: none; }
body.is-resizing .main { pointer-events: none; }
/* Шапка карточки: [ключ][заголовок …][Закрыть задачу][🗑][✕]. Все элементы — строка 32px; длинный заголовок
   переносится, кнопки остаются вверху справа. */
.card-panel-header { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px 4px 20px; }
.card-panel-key { flex: none; display: flex; align-items: center; height: 32px; }
.card-panel-title { flex: 1; min-width: 0; }
.card-panel-actions { flex: none; display: flex; align-items: center; gap: 8px; }
.card-panel-actions .btn.small { height: 32px; min-height: 32px; padding: 0 12px; border-radius: 9px; gap: 6px; }
.card-panel-actions .icon-btn { width: 32px; min-width: 32px; height: 32px; padding: 0; border-radius: 9px; }
.key-btn { display: inline-flex; align-items: center; height: 26px; border: 0; background: var(--primary-soft); color: var(--primary-ink); padding: 0 10px; border-radius: 8px; cursor: pointer; font-weight: 800; font-size: 13px; }
.key-btn:hover { filter: brightness(.97); }
.card-panel-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 20px 18px; } /* без горизонтальной прокрутки: выпадающие панели прижимаются к краю (fitPopover) */
/* Удалённая задача: крупная плашка «Задача удалена» с «Восстановить»; карточка только для чтения. */
.deleted-banner { display: flex; align-items: center; gap: 14px; background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 14px; }
.deleted-banner[hidden] { display: none; }
.deleted-banner-icon { flex: none; display: flex; }
.deleted-banner-text { flex: 1; min-width: 0; }
.deleted-banner-title { font-size: 20px; font-weight: 800; letter-spacing: -.01em; line-height: 1.3; }
.deleted-banner-note { font-size: 13px; opacity: .85; margin-top: 2px; }
.deleted-banner .btn { flex: none; }
.is-deleted .title-view { cursor: default; text-decoration: line-through; opacity: .7; }
.is-deleted .title-view:hover, .is-deleted .description-view:hover { background: none; }
.is-deleted .description-view { cursor: default; }
.is-deleted .message-actions { display: none; }
@media (max-width: 899px) { .deleted-banner { flex-wrap: wrap; } }
.conflict-banner { background: var(--danger-soft); color: var(--danger); font-weight: 600; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; }
.title-view { font-size: 20px; font-weight: 800; letter-spacing: -.01em; line-height: 1.3; padding: 3px 8px; margin: 0 -8px; min-height: 32px; border-radius: 9px; cursor: text;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* длинный — многоточие, целиком — в подсказке и при редактировании */
.title-view:hover { background: var(--surface-2); }
textarea.title-input { font-size: 20px; font-weight: 800; line-height: 1.3; padding: 2px 8px; margin: 0 -8px; width: calc(100% + 16px); min-height: 32px; resize: none; }
/* Поля карточки — строка «чипов» по 32px: тип, приоритет (цветом, как на доске), статус, исполнитель (с аватаром).
   Чип — <label> с прозрачным <select> внутри; подпись поля — в подсказке (title). */
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 8px; }
.meta-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding-left: 10px; border-radius: 9px;
  background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer; transition: filter .15s;
}
.meta-chip.is-static { padding-right: 12px; cursor: default; color: var(--muted); }
/* 📎 — файлы карточки: квадратный чип, с файлами — с числом. */
.files-chip { border: 0; padding: 0 10px; min-width: 32px; justify-content: center; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; }
.files-chip:hover { color: var(--text); }
/* 🔗 — связи с другими задачами (TT-2): чип как у файлов, панель добавления — как список исполнителей. */
.links-chip { border: 0; padding: 0 10px; min-width: 32px; justify-content: center; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; }
.links-chip:hover { color: var(--text); }
.links-chip[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--primary); }
.link-picker { width: min(380px, calc(100vw - 32px)); gap: 8px; padding: 12px; }
.link-picker-title { font-weight: 800; font-size: 14px; }
.link-field { display: flex; flex-direction: column; gap: 4px; }
.link-results { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.link-result { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.link-result:hover:not(:disabled), .link-result.active { background: var(--surface-2); }
.link-result:disabled { opacity: .45; cursor: default; }
.link-result-title, .link-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-hint { line-height: 1.35; }
/* Список связей под описанием: группы по виду связи, строка — номер, заголовок, колонка, ✕ при наведении. */
.card-links { display: flex; flex-direction: column; gap: 10px; }
.link-group-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.link-row { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 8px; margin: 0 -8px; border-radius: 9px; font-size: 14px; }
.link-row:hover { background: var(--surface-2); }
.link-title { color: var(--text); text-decoration: none; font-weight: 600; }
.link-title:hover { text-decoration: underline; }
.link-key { flex: none; text-decoration: none; }
.link-status { flex: none; }
.link-row.is-closed .link-title { text-decoration: line-through; color: var(--muted); }
.link-remove, .link-copy { flex: none; opacity: 0; }
.link-row:hover .link-copy, .link-copy:focus-visible { opacity: 1; }
@media (hover: none) { .link-copy { opacity: 1; } }
/* Быстрое создание подзадачи (TT-22): строка «+ Добавить подзадачу» → поле ввода. */
.subtask-open { align-self: flex-start; margin-top: 2px; font-size: 13px; }
.card-links > .subtask-open:only-child { margin-top: 12px; } /* без связей — одна строка под файлами */
.subtask-add { margin-top: 4px; }
.subtask-input { height: 32px; font-size: 14px; }
.link-row:hover .link-remove, .link-remove:focus-visible { opacity: 1; }
@media (hover: none) { .link-remove { opacity: 1; } }
/* Перетаскивание файлов на карточку (fileDropOverlay): две половины — «к карточке» и «к сообщению в чате». */
.card-panel-inner { position: relative; }
.drop-overlay {
  position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: color-mix(in srgb, var(--surface) 80%, transparent); backdrop-filter: blur(2px); border-radius: inherit;
}
.drop-overlay[hidden] { display: none; }
.drop-zone {
  flex: 1; display: grid; place-items: center; pointer-events: none; /* события ловит сам слой */
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--muted);
  transition: background .12s, border-color .12s, color .12s;
}
.drop-zone.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); }
.drop-zone-label { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 800; }
.meta-chip .avatar, .meta-chip .avatar-empty { flex: none; }
.meta-chip .avatar-empty { width: 22px; height: 22px; border-radius: 7px; } /* как аватар xs */
/* Выпадающая панель привязана к самому <select>, а он стоит в чипе после отступа (и аватара) —
   сдвигаем панель влево, чтобы она начиналась от левого края чипа. 10px — отступ; 10 + 22 + 6 — с аватаром. */
.meta-chip { --picker-shift: -10px; }
.meta-chip:has(> .avatar, > .avatar-empty) { --picker-shift: -38px; }
.meta-chip .select::picker(select) { margin-left: var(--picker-shift); }
/* 32px = 14px строка + 2×9px отступы; стрелка — фоном справа. */
.meta-chip .select {
  width: auto; height: 32px; min-height: 0; padding: 9px 24px 9px 0; line-height: 14px; border: 0; border-radius: 0;
  background-color: transparent; color: inherit; font-size: 13px; font-weight: 700;
  background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%;
}
/* Фокус — рамкой всей плитки (её скругление), а не обводкой самого списка. */
.meta-chip .select:focus { outline: none; background-color: transparent; }
/* Рамка — внутренняя (inset): по краю чипа, вровень с краем выпадающего списка. */
.meta-chip:has(.select:focus-visible) { box-shadow: inset 0 0 0 2px var(--primary); }
.meta-chip:has(.select:open) { box-shadow: inset 0 0 0 2px var(--primary); } /* отдельно: где нет :open, правило выше не теряется */
.meta-chip:not(.is-static):hover { filter: brightness(.96); }
/* Тип, приоритет, статус — цветом из профиля (тон), как плашки на доске. */
.meta-chip[class*="tone-"] { background: var(--tone-bg); color: var(--tone-fg); }
.card-section .section-title { margin-top: 20px; }
.card-files-section { margin-top: 8px; } /* файлы карточки — без заголовка, сразу под описанием */
.description-view { padding: 6px 8px; margin: 0 -8px; border-radius: 10px; cursor: text; min-height: 34px; color: var(--text-2); }
.description-view:hover { background: var(--surface-2); }
/* Режимы открытой карточки (TT-33): чтение — номер, заголовок, описание, чат; редактирование (✎) — поля, файлы, связи, действия.
   Блоки редактирования плавно раскрываются по высоте (grid 0fr → 1fr); на время анимации и в режиме чтения содержимое обрезается. */
.edit-only { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows .3s ease, opacity .25s ease; }
.edit-only-inner { min-height: 0; }
.card-panel.is-reading .edit-only {
  grid-template-rows: 0fr; opacity: 0; visibility: hidden;
  transition: grid-template-rows .3s ease, opacity .2s ease, visibility 0s linear .3s;
}
.card-panel.is-reading .edit-only-inner, .card-panel.is-mode-changing .edit-only-inner { overflow: hidden; }
/* Режим чтения компактнее: меньше отступ под шапкой, над «Описанием» и над «Обсуждением». */
.card-panel-scroll, .card-description-section .section-title, .card-panel .chat-section-head { transition: padding .3s ease, margin .3s ease; }
.card-panel.is-reading .card-panel-scroll { padding-top: 4px; }
.card-panel.is-reading .card-description-section .section-title { margin: 4px 0 4px; }
.card-panel.is-reading .chat-section-head { margin: 10px 0 6px; }
/* Закрепление (TT-35, только в режиме чтения): 📌 у «Описания» и у сообщений. Закреплённое описание стоит наверху панели
   (длинное — прокручивается внутри, до 40% высоты окна), под ним прилипают «Обсуждение» с фильтром и закреплённое сообщение. */
.desc-head { display: flex; align-items: center; gap: 4px; } /* 📌 — сразу за словом «Описание» (TT-37) */
.desc-pin { color: var(--muted); }
.pin-action.is-active { color: var(--primary); }
.card-panel.card-view:not(.is-reading) .pin-action, .card-panel.is-deleted .pin-action { display: none; } /* общий чат проекта — всегда */
.card-panel.is-reading.desc-pinned .card-description-section {
  position: sticky; top: 0; z-index: 3; background: var(--surface);
  max-height: 40vh; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  /* .description-view выступает на 8px (margin: 0 -8px) — без запаса по бокам появлялась горизонтальная прокрутка;
     отступ сверху — внутри блока, а не у .card-panel-scroll: иначе над прилипшим описанием щель, в которой видна лента
     (а с отрицательным top — скачок на 4px в начале прокрутки) */
  margin-inline: -8px; padding: 4px 8px 6px; border-bottom: 1px solid var(--border);
}
.card-panel.is-reading.desc-pinned .card-panel-scroll { padding-top: 0; }
.chat-sticky { position: sticky; top: -14px; z-index: 2; display: flow-root; background: var(--surface); } /* минус padding-top .card-panel-scroll */
.card-panel.is-reading .chat-sticky { top: -4px; }
.card-panel.is-reading.desc-pinned .chat-sticky { top: var(--desc-sticky-h, 0px); }
/* Прокрутка к сообщению (своё отправленное, исходное у ответа, найденное) — ниже прилипших блоков, а не под ними. */
.card-panel.card-view .chat .message { scroll-margin-top: calc(var(--chat-sticky-h, 0px) + 8px); }
.card-panel.is-reading.desc-pinned .chat .message { scroll-margin-top: calc(var(--desc-sticky-h, 0px) + var(--chat-sticky-h, 0px) + 8px); }
.chat-pinned { display: flex; align-items: center; gap: 4px; margin: 0 0 8px; padding: 0 4px 0 10px; border-left: 3px solid var(--primary); border-radius: 10px; background: var(--surface-2); }
.card-panel-header + .chat-pinned { margin: 6px 20px 0; } /* общий чат проекта: под шапкой панели */
.chat-pinned-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 6px 0; border: 0; background: none;
  font: inherit; font-size: 13px; text-align: left; cursor: pointer; color: var(--text-2);
}
.chat-pinned-main svg { flex: none; color: var(--primary); }
.chat-pinned-author { flex: none; font-weight: 800; color: var(--primary-ink); }
.chat-pinned-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.card-panel.is-reading .title-view, .card-panel.is-reading .description-view { cursor: default; }
.card-panel.is-reading .title-view:hover, .card-panel.is-reading .description-view:hover { background: none; }
.edit-toggle.is-active { background: var(--primary-soft); color: var(--primary); }
.card-panel.is-mode-changing .edit-action { animation: edit-action-in .25s ease; }
@keyframes edit-action-in { from { opacity: 0; transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) {
  .edit-only, .card-panel.is-reading .edit-only { transition: none; }
  .card-panel-scroll, .card-description-section .section-title, .card-panel .chat-section-head { transition: none; }
  .card-panel.is-mode-changing .edit-action { animation: none; }
}
/* Наведение на плашку файла под описанием — его картинка/ссылка в описании обводится рамкой. */
.description-view .desc-highlight { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; transition: outline-color .15s; }
.placeholder { margin: 0; }
.description-input { min-height: 260px; resize: vertical; }

/* Текст с разметкой */
.rich { word-wrap: break-word; overflow-wrap: anywhere; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p { margin: 0 0 6px; }
.rich ul, .rich ol { margin: 0 0 6px; padding-left: 22px; }
.rich blockquote { margin: 0 0 6px; padding-left: 12px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.rich code { background: var(--column); padding: 1px 5px; border-radius: 6px; }
.rich pre { background: var(--column); padding: 12px; border-radius: 10px; overflow: auto; }
.rich pre code { background: none; padding: 0; }
/* Заголовки, разделители, таблицы, список задач (TT-31). В чате и в подсказке карточки заголовки компактные. */
.rich :is(h1, h2, h3, h4, h5, h6) { margin: 12px 0 6px; font-weight: 800; line-height: 1.3; color: var(--text); letter-spacing: -.01em; }
.rich h1 { font-size: 1.45em; }
.rich h2 { font-size: 1.28em; }
.rich h3 { font-size: 1.14em; }
.rich :is(h4, h5, h6) { font-size: 1em; }
.message-body .rich :is(h1, h2, h3, h4, h5, h6), .card-tooltip .rich :is(h1, h2, h3, h4, h5, h6) { font-size: 1em; margin: 6px 0 2px; }
.rich hr { border: 0; border-top: 1px solid var(--border-strong); margin: 12px 0; }
.rich-table { max-width: 100%; overflow-x: auto; margin: 0 0 8px; }
.rich table { border-collapse: collapse; font-size: .95em; }
.rich :is(th, td) { border: 1px solid var(--border-strong); padding: 4px 10px; text-align: left; vertical-align: top; }
.rich th { background: var(--surface-2); font-weight: 800; }
.rich :is(th, td).align-center { text-align: center; }
.rich :is(th, td).align-right { text-align: right; }
.rich ul.task-list { list-style: none; padding-left: 4px; }
.rich ul.task-list ul.task-list { padding-left: 22px; }
.rich .task-check { margin: 0 6px 0 0; vertical-align: -2px; accent-color: var(--primary); pointer-events: none; }
/* Картинки-вложения в описании (`![имя](/api/v1/attachments/…)`) — превью medium, клик — оригинал. */
.rich-image { display: inline-block; max-width: 100%; margin: 4px 0; }
.rich-image img { display: block; max-width: 100%; max-height: 360px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.card-tooltip .rich-image img { max-height: 120px; }
.mention { color: var(--mention); font-weight: 700; }
.mention-me { background: var(--mention-me-bg); border-radius: 5px; padding: 0 3px; }
.card-link { font-weight: 700; }

/* Вложения */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.card-files .attachments { margin-top: 0; }
.attachment-image { position: relative; margin: 0; }
.attachment-image img { display: block; max-width: 220px; max-height: 180px; width: auto; height: auto; border-radius: var(--radius); cursor: zoom-in; background: var(--column); object-fit: cover; }
/* Картинка в чате: максимальная ширина, которая влезает в пузырь (90% чата − отступы 20px) рядом со временем
   (--meta-w: время + промежуток; с «изменено» — шире), но не больше исходной и не выше 360px
   (ширина = 360px × ширина/высота). Пузырь растягивается под картинку. */
.chat-list { container-type: inline-size; }
.message { --meta-w: 46px; }
.message.edited { --meta-w: 112px; }
.attachment-image.in-chat img {
  width: min(var(--img-w), calc(90cqw - 20px - var(--meta-w)), calc(360px * var(--img-r)));
  max-width: none; max-height: none; height: auto; object-fit: contain;
}
.attachment-image .icon-btn { position: absolute; top: 6px; right: 6px; background: var(--surface); box-shadow: var(--shadow); }
.attachment-file { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius); background: var(--surface-2); max-width: 100%; }
.attachment-file > .svg-icon { flex: none; color: var(--muted); }
.attachment-file a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; font-weight: 600; }
.attachment-file .icon-btn { background: var(--surface); }
.image-viewer { position: fixed; inset: 0; z-index: 100; background: rgb(10 15 14 / .88); display: grid; place-items: center; padding: 56px 24px 24px; cursor: zoom-out; }
.image-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius); cursor: default; }
.image-viewer-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 16px; align-items: center; padding: 10px 16px; color: #fff; cursor: default; }
.image-viewer-bar a { color: #99f6e4; }
.image-viewer-bar .icon-btn { margin-left: auto; color: #fff; background: rgb(255 255 255 / .12); }

/* Чат — «пузыри» */
/* Компактные пузыри: свои справа, чужие слева, ширина по тексту.
   Подряд идущие сообщения одного автора (в пределах дня) — один пузырь (.message-group), у каждого сообщения своё время в конце. */
.chat-list { display: flex; flex-direction: column; gap: 8px; }
.chat-empty { text-align: center; padding: 12px; }
.load-more { align-self: center; margin: 4px 0; }
.message-group { display: flex; }
.message-group.mine { justify-content: flex-end; }
.message-bubble {
  min-width: 0; max-width: 90%; background: var(--surface-2); padding: 4px 10px 3px;
  border-radius: 4px 14px 14px 14px; display: flex; flex-direction: column; gap: 2px;
}
.message-group.mine .message-bubble { background: var(--primary-soft); border-radius: 14px 4px 14px 14px; }
.message-group:has(.message.editing) .message-bubble { flex: 1; max-width: 100%; }
.message-author { font-size: 13px; font-weight: 800; color: var(--primary-ink); }
/* Сообщение: время прижато к правому нижнему углу поверх невидимой вставки .meta-spacer в конце последней строки
   (addMetaSpacer в card.js) — встаёт на последнюю строку, если там есть место, иначе вставка переносится вниз. */
.message { position: relative; }
.message-body { min-width: 0; color: var(--text); overflow-wrap: anywhere; }
.message-body .attachments { margin: 3px 0; } /* в пузыре — плотнее, чем в файлах карточки */
.message-meta { position: absolute; right: 0; bottom: 0; display: flex; gap: 6px; font-size: 11px; line-height: 21px; color: var(--muted); white-space: nowrap; }
.meta-spacer { display: inline-block; width: var(--meta-w); height: 1px; }
.attachments > .meta-spacer { align-self: flex-end; width: calc(var(--meta-w) - 10px); height: 18px; } /* gap ряда 8px + запас */
/* Чужие сообщения (слева): время перед текстом — в левом верхнем углу, вставка — в начале первой строки. */
.message-group:not(.mine) .message-meta { left: 0; right: auto; top: 0; bottom: auto; flex-direction: row-reverse; }
.message-group:not(.mine) .attachments > .meta-spacer { align-self: flex-start; }
/* Рядом с файлом (плашка 37px = 21px строка + 2×8px, ряд с отступом 3px) время — по центру плашки, на уровне имени файла. */
.message-group.mine :is(.message, .message-main):has(> .message-body > .attachments:last-child > .attachment-file:nth-last-child(2)) > .message-meta { bottom: 11px; }
.message-group:not(.mine) :is(.message, .message-main):has(> .message-body > .attachments:first-child > .meta-spacer:first-child + .attachment-file) > .message-meta { top: 11px; }
.message.editing .message-meta { display: none; }
/* Сообщение, найденное поиском: вспыхивает оранжевой подложкой и плавно гаснет (chat.js, revealMessage). */
/* Найдено поиском (сообщение чата или описание карточки): оранжевая рамка на 5 с, найденные слова — mark.search-hit
   (dom.js, revealFound). Без анимации (prefers-reduced-motion) — рамка просто видна 5 с. */
.message.is-found, .description-view.is-found { outline: 2px solid var(--unread); outline-offset: 4px; border-radius: 8px; animation: found-frame 5s ease-out; }
@keyframes found-frame {
  0% { outline-color: transparent; }
  6%, 80% { outline-color: var(--unread); }
  100% { outline-color: transparent; }
}
mark.search-hit { background: var(--unread-soft); color: var(--unread-ink); border-radius: 3px; padding: 0 1px; }
/* Действия — снаружи пузыря напротив сообщения (у своих слева, у чужих справа), появляются при наведении. */
.message-actions {
  position: absolute; top: 50%; transform: translateY(-50%); left: 100%; padding-left: 14px; /* отступ — «мостик»: при переходе мышью кнопки не пропадают */
  display: flex; gap: 2px; line-height: 1; white-space: nowrap; visibility: hidden; opacity: 0; transition: opacity .12s;
}
.message-group.mine .message-actions { left: auto; right: 100%; padding: 0 14px 0 0; }
/* Кнопки — столбиком (TT-32: ↩ ✎ 🗑 друг над другом — по ширине как одна кнопка). Прозрачные поля вокруг столбика и
   полоса от сообщения до кнопок (::after) — часть зоны наведения: пока мышь идёт к кнопке, они не пропадают. */
.message-actions { flex-direction: column; gap: 2px; z-index: 2; padding: 8px 8px 8px 14px; }
.message-group.mine .message-actions { padding: 8px 14px 8px 8px; }
.message:has(> .message-actions)::after { content: ''; position: absolute; top: 0; bottom: 0; left: 100%; width: 24px; }
.message-group.mine .message:has(> .message-actions)::after { left: auto; right: 100%; }
.message.editing::after { display: none; }
.message-action { width: 28px; min-width: 28px; height: 28px; padding: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.message:hover .message-actions, .message:focus-within .message-actions { visibility: visible; opacity: 1; }
.message.editing .message-actions { display: none; }
/* Ответ на сообщение (TT-32): цитата исходного сверху (клик — перейти к нему); время — относительно текста под цитатой. */
.message-main { position: relative; }
.message-reply {
  display: block; width: 100%; min-width: 0; margin: 3px 0 4px; padding: 2px 8px; text-align: left; cursor: pointer;
  border: 0; border-left: 3px solid var(--primary); border-radius: 6px;
  background: color-mix(in srgb, currentColor 6%, transparent); color: var(--text-2); font: inherit; font-size: 12px; line-height: 1.4;
}
.message-reply:hover { background: color-mix(in srgb, currentColor 11%, transparent); }
.message-reply-author { display: block; font-weight: 800; color: var(--primary-ink); }
.message-reply-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.composer-reply { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 4px 6px 4px 10px; border-left: 3px solid var(--primary); border-radius: 8px; background: var(--surface-2); color: var(--primary); }
.composer-reply-info { flex: 1; min-width: 0; font-size: 12px; line-height: 1.4; }
.composer-reply-author { font-weight: 800; color: var(--primary-ink); }
.composer-reply-text { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-deleted { color: var(--muted); font-style: italic; }
.message-edit { margin-top: 4px; background: var(--surface); }
.chat-divider { align-self: center; font-size: 12px; font-weight: 800; color: var(--unread-ink); background: var(--unread-soft); border-radius: 99px; padding: 2px 12px; }
.chat-day { align-self: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0 0; }
.typing { min-height: 18px; font-size: 12px; color: var(--muted); font-style: italic; padding: 6px 0 0 4px; }

.composer { padding: 8px 16px 10px; background: var(--surface); position: relative; }
/* Кнопки и поле одной высоты (--composer-h: 34px, на тач-экранах 44px); при многострочном вводе поле растёт вверх, кнопки остаются внизу. */
.composer-row { --composer-h: 34px; display: flex; gap: 6px; align-items: flex-end; }
.composer-row > .icon-btn { width: var(--composer-h); min-width: var(--composer-h); height: var(--composer-h); padding: 0; }
.composer-field { flex: 1; min-width: 0; position: relative; display: flex; }
/* textarea.* — сильнее общего «textarea.input { resize: vertical }»: поле чата растёт само, без уголка растягивания.
   Вертикальный отступ: (высота − 19px строка − 3px рамка) / 2. */
textarea.composer-input {
  display: block; height: var(--composer-h); min-height: var(--composer-h); max-height: 200px; resize: none; overflow-y: hidden;
  padding-top: calc((var(--composer-h) - 22px) / 2); padding-bottom: calc((var(--composer-h) - 22px) / 2);
}
.composer-input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send-btn { width: var(--composer-h); min-width: var(--composer-h); height: var(--composer-h); min-height: var(--composer-h); padding: 0; border-radius: 10px; font-size: 16px; }
@media (pointer: coarse) { .composer-row { --composer-h: 44px; } }
.composer-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.composer-file { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 6px; border-radius: var(--radius); background: var(--surface-2); max-width: 240px; }
.composer-file.error { box-shadow: 0 0 0 2px var(--danger); }
.composer-file img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.composer-file-info { min-width: 0; }
.composer-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; font-size: 13px; font-weight: 600; }
.file-icon { width: 40px; text-align: center; font-size: 20px; }

.mention-list {
  position: absolute; bottom: calc(100% + 6px); left: 0; min-width: 240px; max-height: 260px; overflow: auto;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 40; padding: 6px;
}
.message-body .mention-list { position: relative; bottom: auto; margin-top: 4px; }
.mention-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; font-weight: 600; }
.mention-item:hover, .mention-item.active { background: var(--primary-soft); color: var(--primary-ink); }

/* ---------- Модальные окна ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 60; background: rgb(31 42 40 / .35); display: grid; place-items: start center; padding: 8vh 16px 16px; overflow: auto; }
.modal { width: 100%; max-width: 540px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); }
.modal-wide { max-width: 860px; }
.modal-profile { max-width: 640px; }
.modal-profile .profile-btn { width: 160px; } /* «Сохранить» и «Сменить пароль» — одной ширины, правые края полей совпадают */
/* «Цвета» в профиле: вкладки Тип / Приоритет / Статус → строки «плашка-образец + ряд тонов». */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head .section-title { margin-bottom: 4px; }
.colors-tabs { display: inline-flex; gap: 2px; padding: 3px; margin-top: 10px; border-radius: 10px; background: var(--gray-bg); }
.colors-tab {
  height: 28px; padding: 0 14px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700;
}
.colors-tab:hover { color: var(--text); }
.colors-tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.colors-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.colors { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.colors-row { display: flex; align-items: center; gap: 12px; min-height: 30px; }
.colors-row > .plate { flex: none; width: 120px; text-align: center; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch {
  width: 21px; height: 21px; padding: 0; border: 0; border-radius: 7px; cursor: pointer;
  background: var(--tone-bg); box-shadow: inset 0 0 0 1.5px var(--tone-fg); transition: transform .1s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.selected { outline: 2px solid var(--text); outline-offset: 2px; }
.swatch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 4px 24px; }
.modal-header h2 { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.modal-body { padding: 14px 24px 24px; }
.modal-body > :first-child { margin-top: 0; }

.key-row { display: flex; gap: 8px; align-items: center; }
.key-input { width: 96px; text-transform: uppercase; font-weight: 800; font-size: 17px; letter-spacing: .12em; text-align: center; }
.key-status { font-size: 13px; font-weight: 700; }
.key-status.good { color: var(--success); }
.key-status.bad { color: var(--danger); }

.invite-list, .member-list, .session-list { display: flex; flex-direction: column; gap: 4px; }
.invite-row, .member-row, .session-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.invite-email, .member-info, .session-info { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.invite-actions, .member-actions { display: flex; gap: 12px; }
.member-name { font-weight: 700; }

.key-form-grid { display: grid; grid-template-columns: 2fr 1fr 1.5fr 1fr; gap: 10px; }
.key-form-grid .field { margin-bottom: 0; }
/* Боты в профиле: чекбоксы проектов, доступ и срок ключа, кнопка удаления. */
.bot-projects { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 14px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); cursor: pointer; font-size: 14px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.check-row.muted { cursor: default; }
.bot-key-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.bot-key-grid .field { margin-bottom: 0; }
.bot-key-grid > .btn { height: 40px; }
.bot-danger { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.created-key { margin: 18px 0; padding: 14px; border-radius: 14px; background: var(--unread-soft); }
.created-key .warning { color: var(--unread-ink); margin: 0 0 10px; font-weight: 700; }
.created-key .input { background: var(--surface); }
.code { background: var(--surface); padding: 10px 12px; border-radius: 10px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 4px 0 0; }
.table { width: 100%; border-collapse: separate; border-spacing: 0 4px; margin-top: 16px; font-size: 13px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 10px; }
.table td { padding: 10px; background: var(--surface-2); vertical-align: top; }
.table td:first-child { border-radius: 10px 0 0 10px; }
.table td:last-child { border-radius: 0 10px 10px 0; }

/* ---------- Всплывающие сообщения ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2a28; color: #fff; font-weight: 600; padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow-lg); max-width: min(560px, 90vw); transition: opacity .3s, transform .3s; }
.toast-error { background: #b91c1c; }
.toast-success { background: #0f766e; }
.toast-hide { opacity: 0; transform: translateY(8px); }

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

/* Автор и даты карточки — одной строкой под плитками */
/* «Закрыть задачу» / «Открыть заново» — справа в строке полей (не рядом с ✕ панели). */
.meta-close-btn { margin-left: auto; height: 32px; min-height: 32px; padding: 0 12px; border-radius: 9px; gap: 6px; }
.meta-close-btn:hover { background: var(--primary-soft); color: var(--primary); }
.card-meta-line { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); padding: 2px 2px 0; }
.card-meta-line strong { color: var(--text); font-weight: 700; }

/* ---------- Общий чат проекта ---------- */
/* Кнопка «💬 Чат» над доской: открыт — бирюзовая, есть непрочитанное — с оранжевым бейджем. */
.board-toolbar .chat-btn { gap: 6px; }
.board-toolbar .chat-btn.active { background: var(--primary-soft); color: var(--primary-ink); }
.board-toolbar .chat-btn.has-unread:not(.active) { color: var(--unread-ink); }
.chat-btn .badge { min-width: 18px; height: 18px; padding: 0 5px; background: var(--unread); color: #fff; }
/* Узкая доска: у кнопки остаются только иконка и бейдж (вместе с участниками — см. fitToolbar). */
.board-toolbar.hide-members .chat-btn-label { display: none; }
/* Число новых сообщений чата в списке проектов. */
.chat-badge { display: inline-flex; gap: 3px; align-items: center; }
/* Шапка панели чата: иконка, «Чат проекта» мелко и название проекта. */
.chat-panel-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--primary-soft); color: var(--primary-ink); }
.chat-panel-heading { display: flex; flex-direction: column; min-width: 0; }
.chat-panel-caption { font-size: 12px; font-weight: 700; color: var(--muted); line-height: 1.2; }
.chat-panel-heading .chat-panel-title { cursor: default; font-size: 17px; line-height: 1.3; min-height: 0; padding: 0; margin: 0; }
.chat-panel-heading .chat-panel-title:hover { background: none; }
/* Лента прижата к низу панели: короткая переписка — у поля ввода, как в мессенджерах. */
.chat-panel-scroll { display: flex; flex-direction: column; }
.chat-panel-scroll > .chat { margin-top: auto; }
/* «← Чат проекта» в шапке карточки, открытой из чата. */
.card-panel-key { gap: 6px; }
.back-btn { width: 32px; min-width: 32px; height: 32px; padding: 0; border-radius: 9px; }

/* Меню непрочитанного у проекта в списке (unreadMenu.js): при наведении на бейдж — переходы к чату проекта и карточкам. */
.unread-menu {
  position: fixed; z-index: 70; min-width: 220px; max-width: 340px; padding: 6px;
  background: var(--surface); color: var(--text); border-radius: 14px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 2px;
  opacity: 0; transform: translateX(-4px); visibility: hidden; pointer-events: none;
  transition: opacity .15s ease, transform .15s ease, visibility 0s linear .15s;
}
.unread-menu.is-visible { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition: opacity .15s ease, transform .15s ease; }
.unread-menu-head { padding: 4px 8px 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.unread-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: var(--radius-sm);
  background: none; text-align: left; cursor: pointer; font-size: 13px;
}
.unread-menu-item:hover, .unread-menu-item:focus-visible { background: var(--surface-2); outline: none; }
.unread-menu-item > svg { flex: none; color: var(--unread); }
.unread-menu-key { flex: none; font-size: 12px; font-weight: 700; color: var(--muted); }
.unread-menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.unread-menu-item .badge { flex: none; background: var(--unread-soft); color: var(--unread-ink); }
.unread-menu-more { padding: 4px 8px; font-size: 12px; color: var(--muted); }

/* Системные сообщения (TT-4) — пузырь автора «Система» слева на сером фоне (темнее, чем у сообщений людей),
   текст приглушён, кто сделал действие — мелко после текста. */
.message-group.system .message-bubble { background: var(--border); }
.message-group.system .message-author { color: var(--muted); }
.message-group.system .message-body { color: var(--text-2); }
.message-actor { color: var(--muted); font-size: 12px; white-space: nowrap; }
/* Фильтр ленты в шапке общего чата: все / сообщения людей / системные. */
.chat-kind-filter { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--surface-2); margin-right: 6px; }
/* Чат карточки: заголовок «Обсуждение» и сразу за ним — фильтр ленты. */
.chat-section-head { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.chat-section-head .section-title { margin: 0; }
.chat-section-head .chat-kind-filter { margin-right: 0; }
.chat-kind-btn.icon-btn { width: 28px; min-width: 28px; height: 28px; padding: 0; border-radius: 8px; color: var(--muted); }
.chat-kind-btn.icon-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* «Мои дела» (TT-5): пункт внизу левой панели и экран со списком вместо доски. */
.todos-item { margin-bottom: 4px; } /* первым, над проектами */
.todos-count { flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 7px; display: inline-grid; place-items: center;
  background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 800; }
.todos-page { height: 100%; overflow-y: auto; padding: 0 4px 24px; }
.todos-head { display: flex; align-items: baseline; gap: 12px; height: 32px; margin-bottom: 18px; }
.todos-head h1 { font-size: 22px; line-height: 32px; font-weight: 800; letter-spacing: -.02em; }
.todos-panel { max-width: 720px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel); padding: 16px; }
.todo-new-input { margin-bottom: 10px; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.todo-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 8px; border-radius: 10px; cursor: grab; }
.todo-item:hover { background: var(--surface-2); }
.todo-item.done { cursor: default; }
.todo-check {
  flex: none; width: 22px; height: 22px; padding: 0; border: 2px solid var(--border-strong); border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); color: var(--on-primary); cursor: pointer;
}
.todo-check:hover { border-color: var(--primary); }
.todo-item.done .todo-check { background: var(--primary); border-color: var(--primary); }
.todo-text { flex: 1; min-width: 0; overflow-wrap: anywhere; cursor: text; }
.todo-item.done .todo-text { color: var(--muted); text-decoration: line-through; cursor: default; }
.todo-edit-input { flex: 1; min-height: 32px; padding: 4px 10px; }
.todo-meta { flex: none; font-size: 12px; color: var(--muted); }
.todo-delete { opacity: 0; }
.todo-item:hover .todo-delete, .todo-delete:focus-visible { opacity: 1; }
.todo-ghost { opacity: .4; }
.todo-empty { padding: 10px 8px; }
.todo-done { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.todo-done summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: 4px 8px; }
.todo-more { margin: 6px 8px 0; }

/* Календарь звонков (TT-6): кнопка в шапке и неделя по дням. */
.header-right .calendar-btn { display: inline-grid; place-items: center; color: var(--muted); }
.header-right .calendar-btn:hover { color: var(--text); }
.calendar-page { height: 100%; display: flex; flex-direction: column; min-height: 0; padding: 0 4px 8px; }
.calendar-toolbar { display: flex; align-items: center; gap: 12px; height: 32px; margin-bottom: 18px; flex-wrap: nowrap; }
.calendar-toolbar h1 { font-size: 22px; line-height: 32px; font-weight: 800; letter-spacing: -.02em; }
.calendar-nav { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.calendar-nav .icon-btn { width: 32px; min-width: 32px; height: 32px; padding: 0; border-radius: 9px; }
.calendar-range { margin-left: 8px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar-week { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 10px; overflow: auto; }
.calendar-day { background: var(--column); border-radius: var(--radius-lg); padding: 10px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
.calendar-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.calendar-day.past { opacity: .75; }
.calendar-day-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; font-weight: 800; font-size: 13px; }
.calendar-day-head > span::first-letter { text-transform: uppercase; }
.calendar-day.today .calendar-day-head { color: var(--primary); }
.calendar-add { opacity: 0; }
.calendar-day:hover .calendar-add, .calendar-add:focus-visible { opacity: 1; }
.calendar-empty { padding: 4px; }
.calendar-event {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; padding: 8px 10px; border: 0; border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow); text-align: left; cursor: pointer; border-left: 3px solid var(--primary);
}
.calendar-event:hover { box-shadow: var(--shadow), 0 0 0 1px var(--border-strong); }
.calendar-event.private { background: var(--surface-2); border-left-color: var(--border-strong); }
.calendar-event.past { opacity: .7; }
.calendar-event-time { font-size: 12px; font-weight: 700; color: var(--muted); }
.calendar-event-title { font-weight: 700; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.calendar-event.private .calendar-event-title { color: var(--muted); }
.calendar-project { height: 20px; min-width: 0; padding: 0 6px; font-size: 11px; border-radius: 6px; }
.calendar-people { display: flex; gap: 2px; flex-wrap: wrap; }
.calendar-details { display: flex; flex-direction: column; gap: 12px; }
.calendar-details-when { font-weight: 800; font-size: 15px; }
.calendar-details-when::first-letter { text-transform: uppercase; }
.calendar-details-row { display: flex; flex-direction: column; gap: 4px; }
.calendar-cards { display: flex; flex-direction: column; gap: 2px; }
.calendar-participants { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.calendar-participant { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.calendar-when { display: flex; gap: 8px; align-items: center; }
.calendar-when .input, .calendar-when .select { width: auto; flex: 1; min-width: 0; }
.calendar-pick-filter { margin-bottom: 6px; }
.calendar-pick-list { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 10px; background: var(--surface-2); }
.calendar-pick-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.calendar-pick-item:hover { background: var(--surface); }
@media (max-width: 899px) {
  .calendar-week { grid-template-columns: 1fr; overflow: visible; }
  .calendar-page { height: auto; }
  .calendar-toolbar { flex-wrap: wrap; height: auto; }
}
.project-ghost { opacity: .4; }

/* Несколько исполнителей: аватары внахлёст на доске, в истории и в чипе карточки; список с галочками. */
.assignee-stack { display: inline-flex; align-items: center; }
.assignee-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.assignee-stack .avatar + .avatar { margin-left: -6px; }
.assignee-stack .more-count { margin-left: 3px; font-size: 11px; }
.meta-chip .assignee-stack .avatar { box-shadow: 0 0 0 2px var(--surface-2); }
.history-assignee .avatar + .avatar { margin-left: -6px; }
.assignees-wrap { position: relative; display: inline-flex; }
.assignees-chip { border: 0; padding-right: 10px; font: inherit; font-size: 13px; font-weight: 700; max-width: 260px; }
.assignees-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-caret { flex: none; width: 5px; height: 5px; margin: -3px 2px 0 4px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); }
.assignees-chip[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--primary); }
.assignee-picker {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 240px; max-height: min(320px, 60vh); overflow-y: auto;
  padding: 6px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 2px;
}
.assignee-option { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; }
.assignee-option:hover { background: var(--surface-2); }
.assignee-option input { accent-color: var(--primary); }
.assignee-clear { align-self: flex-start; margin: 4px 8px 2px; font-size: 13px; }

/* Профиль → «Проектов: N»: две полоски — задачи и место под файлы суммарно по моим проектам относительно лимитов. */
.usage { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); }
@media (max-width: 899px) { .usage { grid-template-columns: 1fr; gap: 10px; } }
.usage-meter { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 13px; cursor: help; }
.usage-meter-head { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.usage-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.usage-bar-fill { height: 100%; border-radius: 3px; background: var(--primary); }
.usage-bar.is-full .usage-bar-fill { background: var(--danger); }

/* Меню подзадач у значка «☰ 2/5» на карточке доски (TT-27): при наведении — список, клик открывает подзадачу. */
.subtasks-menu {
  position: fixed; z-index: 60; width: min(360px, calc(100vw - 16px)); max-height: min(360px, 60vh); overflow-y: auto;
  padding: 6px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 2px;
}
.subtasks-menu[hidden] { display: none; }
.subtasks-menu-title { padding: 4px 8px 2px; font-size: 12px; font-weight: 700; color: var(--muted); }
.subtasks-menu-empty { padding: 6px 8px; font-size: 13px; color: var(--muted); }
.subtasks-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 4px 8px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;
}
.subtasks-menu-item:hover, .subtasks-menu-item:focus-visible { background: var(--surface-2); outline: none; }
.subtasks-menu-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtasks-menu-item.is-closed .subtasks-menu-name { text-decoration: line-through; color: var(--muted); }
.subtasks-menu-item .tag { flex: none; }

/* Шпаргалка по Markdown (TT-29): подпись «Поддерживается Markdown» у редактора описания, при наведении — примеры. */
.md-hint { font-size: 12px; color: var(--muted); border-bottom: 1px dashed currentColor; cursor: help; }
.md-hint:hover, .md-hint:focus-visible { color: var(--primary); outline: none; }
.md-cheatsheet {
  position: fixed; z-index: 1000; width: min(460px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow: hidden;
  padding: 12px 14px; border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  pointer-events: none; font-size: 13px;
}
.md-cheatsheet[hidden] { display: none; }
.md-cheatsheet-title { font-weight: 800; margin-bottom: 8px; }
.md-cheatsheet-rows { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.md-cheatsheet-row { display: contents; }
.md-cheatsheet-src, .md-cheatsheet-out { padding: 5px 0; border-top: 1px solid var(--border); }
.md-cheatsheet-src {
  margin: 0; padding-right: 12px; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--text-2);
}
.md-cheatsheet-out { font-size: 13px; }
.md-cheatsheet-out .rich > :first-child { margin-top: 0; }
.md-cheatsheet-out .rich > :last-child { margin-bottom: 0; }
.md-cheatsheet-out .rich h1 { font-size: 17px; }
.md-cheatsheet-out .rich h2 { font-size: 15px; }
.md-cheatsheet-out .rich h1, .md-cheatsheet-out .rich h2 { margin: 0 0 2px; }
.md-cheatsheet-note { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* Личные и групповые чаты (TT-18): в левой панели два раздела — активный наверху со списком (проекты или чаты),
   второй — крупным заголовком внизу («Сообщения» / «Проекты»); открытый чат — в основной области вместо доски. */
.sidebar-switch {
  position: sticky; bottom: -18px; z-index: 1; display: flex; align-items: center; gap: 10px; min-height: 48px; margin: 12px -14px -18px;
  padding: 8px 24px 12px; border-top: 1px solid var(--border); background: var(--surface); color: inherit; text-decoration: none;
}
.sidebar-switch .sidebar-title { flex: 1; margin: 0; font-size: 22px; line-height: 32px; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.sidebar-switch:hover .sidebar-title { color: var(--primary); }
.sidebar-head-actions { display: flex; gap: 4px; }
.chats-section { min-height: 0; }
.chats-side { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chats-list .chat-row { padding: 7px 8px; gap: 10px; }
.chats-page { height: 100%; display: flex; }
.chat-main { flex: 1; min-width: 0; max-width: 960px; height: 100%; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel); }
.chats-empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); text-align: center; padding: 24px; }
.chats-empty-state .btn { display: inline-flex; align-items: center; gap: 6px; }
.chats-search { margin-bottom: 8px; }
.chats-list { display: flex; flex-direction: column; gap: 2px; }
.chats-empty { padding: 12px 8px; }
.chat-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px;
  color: inherit; text-decoration: none;
}
.chat-row:hover { background: var(--surface-2); }
.chat-row.active { background: var(--primary-soft); }
.chat-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-row-top, .chat-row-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.chat-row.has-unread .chat-row-title { font-weight: 800; }
.chat-row-muted, .chat-row-closed { flex: none; color: var(--muted); display: inline-flex; font-size: 12px; }
.chat-row-time { flex: none; font-size: 12px; color: var(--muted); }
.chat-row-last { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.chat-row.has-unread .chat-row-last { color: var(--text-2); }
.badge.badge-muted { background: var(--surface-2); color: var(--muted); }
.avatar-group { background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; flex: none; }
.chat-readonly { margin: 0 20px 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 13px; text-align: center; }
.chat-readonly[hidden] { display: none; }
.card-panel-actions .icon-btn.is-active { color: var(--primary); }
/* Выбор людей: «Написать» и участники группы — список с поиском. */
.people-picker { display: flex; flex-direction: column; gap: 8px; }
.people-list { display: flex; flex-direction: column; gap: 2px; max-height: min(50vh, 360px); overflow-y: auto; }
.people-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 8px; border: 0; border-radius: 10px;
  background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.people-row:hover { background: var(--surface-2); }
.people-row input { flex: none; width: 18px; height: 18px; accent-color: var(--primary); }
.people-empty { padding: 8px; }

/* PWA (TT-39): «Доступна новая версия», подсказка установки на iPhone, экран «Нет подключения». */
.update-banner, .ios-hint {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 1200; width: max-content; max-width: calc(100vw - 24px);
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600;
}
.update-banner { top: calc(12px + env(safe-area-inset-top)); }
.ios-hint { bottom: calc(12px + env(safe-area-inset-bottom)); align-items: flex-start; }
.ios-hint-text { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.ios-hint-text strong { font-weight: 800; }
.offline-screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.offline-screen h1 { font-size: 22px; font-weight: 800; }
.push-status { font-size: 13px; font-weight: 600; margin-left: 6px; }

/* ---------- Мобильная раскладка (TT-39): ширина < 900px, тот же клиент, что на компьютере ----------
   Шапка: ☰ (выезжающее меню — проекты / сообщения), название раздела, лупа (поиск на весь экран), колокольчик.
   Доска — одна колонка, вкладки сверху и свайп (board.js), «+» — плавающая кнопка. Карточка и чаты — на весь экран.
   Высота — видимая область без экранной клавиатуры (--vvh / --vvt из pwa.js), отступы — под чёлку и полоску «Домой». */
.menu-btn, .search-toggle, .header-title, .board-tabs, .fab, .drawer-backdrop { display: none; }
.board-tab .tab-drop { position: absolute; inset: 0; border-radius: inherit; }
.tab-drop > * { display: none !important; } /* карточка, отпущенная на вкладке, переезжает в колонку при перерисовке */

@media (max-width: 899px) {
  html, body { overscroll-behavior: none; }
  .app {
    position: fixed; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100dvh); gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right))
      calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  }
  /* Поля ввода не меньше 16px — иначе iPhone увеличивает страницу при фокусе. */
  .input, .select, textarea, .search-input, .composer textarea { font-size: 16px; }
  /* Поле «Новая задача…» в «Бэклоге» — только по плавающей «+». */
  .quick-add:not(.open) { display: none; }

  /* Шапка */
  .header { gap: 4px; padding: 6px; border-radius: 16px; }
  .logo, .search, .user-name { display: none; }
  .menu-btn, .search-toggle { display: inline-grid; }
  .header .icon-btn, .header-right .icon-btn { width: 40px; min-width: 40px; height: 40px; padding: 0; border-radius: 11px; }
  .menu-btn { position: relative; }
  .menu-btn .unread-dot { position: absolute; top: 7px; right: 7px; }
  .header-title { display: block; flex: 1; min-width: 0; padding: 0 6px; font-size: 17px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-right { gap: 4px; margin-left: 0; }
  .user-btn { height: 40px; padding: 0 6px; }
  /* Лента уведомлений и меню пользователя — на всю ширину экрана. */
  .header .dropdown {
    position: fixed; left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right));
    top: calc(var(--vvt, 0px) + 62px + env(safe-area-inset-top)); min-width: 0;
    max-height: calc(var(--vvh, 100dvh) - 74px - env(safe-area-inset-top)); overflow-y: auto;
  }
  /* Поиск — на весь экран. */
  body.search-open .search {
    display: block; position: fixed; z-index: 1100; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100dvh);
    padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 12px calc(12px + env(safe-area-inset-left));
    background: var(--bg);
  }
  body.search-open .search-icon { display: none; }
  body.search-open .search-input { height: 46px; padding: 0 14px; background: var(--surface); }
  body.search-open .search-results { position: static; max-height: calc(100% - 56px); margin-top: 8px; box-shadow: var(--shadow-panel); }
  .search-item { padding: 12px; }
  .search-item-head { flex-wrap: wrap; }

  /* Выезжающее меню: список проектов / сообщений. */
  .app-body { gap: 0; }
  .sidebar, .sidebar.collapsed {
    position: fixed; z-index: 1000; top: 0; bottom: 0; left: 0; width: min(290px, 80vw) !important;
    margin: 0 !important; opacity: 1 !important; visibility: visible !important; border-radius: 0 18px 18px 0;
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
    transform: translateX(-105%); transition: transform .25s cubic-bezier(.22, 1, .36, 1); box-shadow: var(--shadow-lg);
  }
  body.drawer-open .sidebar { transform: none; }
  .sidebar > * { min-width: 0; }
  .drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 999; background: rgb(0 0 0 / .35);
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
  }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar-toggle, .board-toolbar .sidebar-expand { display: none !important; }
  /* Компактное меню (TT-48): заголовки 18px, плотные строки, «Сообщения» / «Проекты» внизу — узкой полосой. */
  .sidebar-switch {
    bottom: calc(-12px - env(safe-area-inset-bottom)); min-height: 0; margin: 8px -10px calc(-12px - env(safe-area-inset-bottom));
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  }
  .sidebar-head { height: 32px; margin-bottom: 6px; }
  .sidebar-head .sidebar-title, .sidebar-switch .sidebar-title { margin-left: 6px; font-size: 18px; line-height: 28px; }
  .sidebar-section { margin-bottom: 10px; }
  .project-list { gap: 2px; margin-bottom: 6px; }
  .project-item { padding: 6px 10px; font-size: 15px; }
  .todos-item { margin-bottom: 2px; }
  .invitation { padding: 10px; }
  .invitation-from { margin: 2px 0 8px; }
  .new-project { margin-top: 4px; min-height: 40px; }
  .chats-search { margin-bottom: 6px; }
  .chats-list .chat-row { padding: 6px 8px; }
  .new-project { opacity: 1; }
  .project-item, .chat-row { min-height: 40px; }

  /* Доска: панель над доской переносится, фильтры — второй строкой с прокруткой; одна колонка и вкладки. */
  .board-page { padding-top: 0; gap: 8px; position: relative; }
  .board-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .board-title { display: none; }
  .board-tools { margin-left: auto; }
  .board-filters { order: 2; flex: 1 0 100%; overflow-x: auto; scrollbar-width: none; }
  .board-toolbar .members-stack { display: none; }
  .board-toolbar .icon-btn { width: 40px; min-width: 40px; height: 40px; }
  .board-toolbar .btn.small { height: 40px; min-height: 40px; }
  .board-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--column); overflow-x: auto; scrollbar-width: none; flex: none; }
  .board-tab {
    position: relative; flex: 1 0 auto; display: flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: none;
    font: inherit; font-size: 14px; font-weight: 700; color: var(--muted); white-space: nowrap;
  }
  .board-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
  .board-tab-count { min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); font-size: 12px; }
  body.is-dragging .board-tab:not(.active) { box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary); }
  .board { display: flex; overflow: hidden; }
  .board > .column { display: none; }
  .board > .column.is-current { display: flex; flex: 1; min-width: 0; }
  .board > .column .column-head { display: none; }
  .column-list { gap: 8px; }
  .fab {
    display: grid; place-items: center; position: absolute; z-index: 5; right: 8px; bottom: 8px;
    width: 56px; height: 56px; border: 0; border-radius: 18px; background: var(--primary); color: var(--on-primary);
    box-shadow: var(--shadow-lg); cursor: pointer;
  }

  /* Карточка и чат проекта — на весь экран; «✕» и системный «назад» возвращают на доску. */
  .card-panel, .card-panel.is-opening, .card-panel.is-closing {
    position: fixed !important; z-index: 30; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100dvh);
    width: 100% !important; min-width: 0 !important; max-width: none !important; border-radius: 0; box-shadow: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .card-panel.is-closing { display: none; }
  .card-resizer { display: none !important; }
  .card-panel-header { padding: 10px 10px 4px 14px; }
  .card-panel-scroll { padding: 10px 14px 14px; }
  .card-panel-actions .icon-btn { width: 40px; min-width: 40px; height: 40px; }
  .composer { padding: 8px 10px 10px; }

  /* Личные и групповые чаты: открытый чат — на всю основную область. */
  .chat-main { max-width: none; border-radius: 16px; }

  /* Окна — почти на весь экран. */
  .modal-overlay { padding: calc(12px + env(safe-area-inset-top)) 8px calc(12px + env(safe-area-inset-bottom)); }
  .modal { border-radius: 18px; }
  /* Профиль на телефоне (TT-39): только имя, лимиты, уведомления, пароль и удаление аккаунта; имя и «Сохранить» — двумя строками. */
  .profile-desktop-only { display: none; }
  .modal-profile .inline-form { flex-direction: column; align-items: stretch; gap: 8px; }
  .modal-profile .inline-form .field { margin-bottom: 0; }
  .modal-profile .profile-btn { width: auto; align-self: flex-start; }
  .modal-profile .form-actions.spread { flex-wrap: wrap; gap: 8px; }
}

/* Устройства без наведения: действия у сообщения — по тапу (chat.js, .is-touched), кнопки крупнее. */
@media (hover: none) {
  .message.is-touched .message-actions { visibility: visible; opacity: 1; }
  .message-actions .icon-btn { min-width: 36px; height: 36px; }
}
