/* ==========================================================================
   Орб — дизайн-система «Графит и неон» (бриф: docs/DESIGN.md).

   Сдержанный премиум: графитовый фон, спокойные поверхности шагами светлоты, неон только на важном.
   Шрифт Geist. Мягкие карточки (20px), кнопки-капсулы. Свечение — только у орбов и главной кнопки.
   У каждого объединения свой неон: внутри элемента со --assoc акцент перекрашивается в его цвет.

   Движение (emil-design-eng, apple-design): только transform/opacity/цвет, конкретные свойства
   (никаких transition: all), 150–250 мс, свои кривые; наведение — только для мыши;
   при «уменьшить движение» переходы почти мгновенные.
   ========================================================================== */

/* Geist от Vercel (OFL, static/fonts/Geist-LICENSE.txt): в этой сборке есть кириллица, в Google Fonts — нет. */
@font-face {
  font-family: "Geist";
  src: url("../fonts/Geist-Variable.68be1efffc77.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Токены: тёмная тема по умолчанию ---------- */
:root {
  --bg: #0b0c0e;
  --surface: #131417;
  --surface-2: #1a1c20;
  --surface-3: #22252a;
  --border: #26292e;
  --border-strong: #34383e;
  --text: #edeef0;
  --muted: #a1a6ad;
  --faint: #868c94;

  /* Неон ИЭМИТ — бренд интерфейса. */
  --green: #44cb54;
  --cyan: #00eaff;
  --accent: var(--green);           /* главная кнопка и выбор */
  --accent-text: var(--green);      /* акцент в тексте */
  --on-accent: #0b0c0e;
  --link: #8fe7f2;

  --danger: #ff5c6c;
  --warning: #ffb547;
  --success: #44cb54;
  --tint-danger: rgba(255, 92, 108, .12);
  --tint-warning: rgba(255, 181, 71, .12);
  --tint-success: rgba(68, 203, 84, .12);
  --tint-info: rgba(0, 234, 255, .10);

  --orb-a: #44cb54;
  --orb-b: #00eaff;
  --orb-dim: #4d535c;
  --orb-warm: #ffb547;

  --radius-card: 20px;
  --radius-control: 12px;
  --radius-chip: 9999px;
  --shadow-float: 0 16px 40px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);
  --focus: rgba(0, 234, 255, .45);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-move: cubic-bezier(0.77, 0, 0.175, 1);
  --fast: 160ms;
  --normal: 220ms;

  --sidebar: 248px;
  --font: "Geist", "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

/* Светлая тема — вторая, неон приглушён до читаемых оттенков. */
:root[data-theme="light"] {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #f0f1f3;
  --surface-3: #e7e9ec;
  --border: #e3e5e8;
  --border-strong: #cfd3d8;
  --text: #0e1013;
  --muted: #5a6069;
  --faint: #646972;
  --accent: #2c8236;
  --accent-text: #2c8236;
  --on-accent: #ffffff;
  --link: #007385;
  --danger: #c4242a;
  --warning: #9a5600;
  --success: #20772b;
  --tint-danger: rgba(196, 36, 42, .08);
  --tint-warning: rgba(154, 86, 0, .08);
  --tint-success: rgba(32, 119, 43, .08);
  --tint-info: rgba(0, 115, 133, .07);
  --orb-a: #2c8236;
  --orb-b: #007385;
  --orb-dim: #c9cdd3;
  --orb-warm: #c96a00;
  --shadow-float: 0 16px 40px rgba(14, 16, 19, .12), 0 2px 8px rgba(14, 16, 19, .06);
  --focus: rgba(0, 115, 133, .35);
  color-scheme: light;
}

/* Внутри объединения акцент — его неон (в светлой теме — его читаемый оттенок). */
[style*="--assoc"] { --assoc-text: var(--assoc); }
:root[data-theme="light"] [style*="--assoc"] { --assoc-text: var(--assoc-ink, var(--assoc)); }
.assoc-scope { --accent: var(--assoc); --accent-text: var(--assoc-text); --orb-a: var(--assoc); }
:root[data-theme="light"] .assoc-scope { --accent: var(--assoc-ink, var(--assoc)); }

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  /* Невидимые подсказки у края экрана не должны расширять страницу — иначе окна на телефоне съезжают вбок. */
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  background: var(--bg);
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 600; text-wrap: balance; }
h1 { font-size: 24px; line-height: 32px; letter-spacing: -0.02em; }
h2 { font-size: 16px; line-height: 24px; letter-spacing: -0.01em; }
h3 { font-size: 14px; line-height: 20px; }
p { margin: 0 0 16px; }
p, li, dd, .small, .help { text-wrap: pretty; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; line-height: 16px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 12px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--cyan) 30%, transparent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -64px; z-index: 100; padding: 8px 16px; border-radius: var(--radius-chip); background: var(--accent); color: var(--on-accent) !important; font-weight: 600; transition: top var(--fast) var(--ease-out); }
.skip-link:focus { top: 16px; }
.ph { font-size: 18px; line-height: 1; flex: none; }

button, a, [role="button"], summary, .btn, .nav-link, .bottom-nav a, .tabs a, .chip-check, .choice { touch-action: manipulation; }
button, .btn, .nav-link, .bottom-nav a, .tabs a, .chip-check, .icon-btn, summary { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* ---------- Орбы ---------- */
.orb { --size: 40px; position: relative; width: var(--size); height: var(--size); flex: none; }
.orb canvas { position: absolute; inset: 0; display: block; }
.orb.md { --size: 72px; }
.orb.lg { --size: 120px; }
.orb.xl { --size: min(56vmin, 420px); }
.orb[data-interactive] { cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.orb.is-grabbing { cursor: grabbing; }
.orb.is-busy { opacity: .45; }

/* Большой орб — только на входе, в пустых состояниях и на 404; на рабочих экранах фон чистый. */
.orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.app .orbs { display: none; }
.orbs .orb, .orbs .glow, .lines { display: none; }

/* ---------- Каркас ---------- */
.layout { position: relative; z-index: 1; display: flex; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  width: var(--sidebar); flex: none;
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 12px;
  background: var(--bg);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; color: var(--text) !important; }
.brand .orb { --size: 36px; }
.brand-title { font-weight: 600; font-size: 14px; line-height: 20px; letter-spacing: -0.01em; }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 36px; padding: 8px 12px;
  border-radius: var(--radius-control);
  color: var(--muted) !important;
  font-weight: 500;
  transition: background-color var(--fast) var(--ease-out), color var(--fast) var(--ease-out);
}
.nav-link .ph { color: var(--faint); transition: color var(--fast) var(--ease-out); }
.nav-link.active { background: var(--surface-2); color: var(--text) !important; }
.nav-link.active .ph { color: var(--text); }
.nav-link .badge { margin-left: auto; }
.nav-section { margin: 16px 12px 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--faint); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot .grow { min-width: 0; }
.sidebar-foot .grow .small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--faint); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid transparent;
}
.topbar .spacer { flex: 1; }
.topbar > .icon-btn, .topbar > .menu, .topbar > form, .topbar-avatar { flex-shrink: 0; }
.topbar .brand { display: none; padding: 0; }
.topbar-avatar { display: none; }
.content { padding: 24px 32px 48px; max-width: 1240px; width: 100%; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head > div { min-width: 0; max-width: 100%; }
.page-head h1 { margin: 0; overflow-wrap: anywhere; }
/* Второстепенная кнопка в шапке страницы: без рамки она читается как подпись, а не как действие. */
.page-head .btn-ghost { border-color: var(--border-strong); }
.crumbs { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; margin-bottom: 4px; color: var(--faint); }
.crumbs a { color: var(--muted); }
.finding { margin: 4px 0 0; font-size: 14px; line-height: 20px; color: var(--muted); }
.finding-danger { color: var(--danger); }
.finding-warn { color: var(--warning); }

/* ---------- Карточки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid > .card { display: flex; flex-direction: column; }
.grid > .card > .empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { margin: 0; }
.subhead { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.count { font-weight: 400; color: var(--faint); }
.stack-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack-col > .card + .card { margin-top: 0; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border-radius: var(--radius-chip);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text) !important;
  font: inherit; font-size: 14px; line-height: 20px; font-weight: 500;
  white-space: nowrap; cursor: pointer;
  transition: transform var(--fast) var(--ease-out), background-color var(--fast) var(--ease-out),
    border-color var(--fast) var(--ease-out), box-shadow var(--normal) var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent) !important;
  font-weight: 600;
}
.btn-danger { color: var(--danger) !important; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--link) !important; font: inherit; font-weight: 500; cursor: pointer; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer;
  transition: background-color var(--fast) var(--ease-out), color var(--fast) var(--ease-out), transform var(--fast) var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }

/* ---------- Формы ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 13px; line-height: 16px; color: var(--muted); }
.field .help { margin-top: 8px; font-size: 12px; line-height: 16px; color: var(--faint); }
.field .errors { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12px; line-height: 16px; color: var(--danger); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="search"],
input[type="tel"], input[type="number"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 16px; line-height: 24px;  /* 16px — iOS не приближает страницу */
  transition: border-color var(--fast) var(--ease-out), box-shadow var(--fast) var(--ease-out), background-color var(--fast) var(--ease-out);
}
/* iOS Safari рисует поле даты своей шириной и выталкивает соседнее поле за край — сбрасываем. */
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; min-height: 24px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 112px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: color-mix(in srgb, var(--cyan) 60%, var(--border)); box-shadow: 0 0 0 3px var(--focus); background: var(--surface); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.form-errors { margin-bottom: 16px; }
.form-row { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.form-row > .field { min-width: 0; }
@supports (grid-template-rows: subgrid) {
  .form-row > .field { display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: 0; }
  .form-row > .field > label { align-self: end; }
}
.form-section { margin: 24px 0 12px; font-size: 13px; line-height: 16px; font-weight: 600; color: var(--muted); }
.form-section:first-of-type { margin-top: 4px; }
.form-card { max-width: 760px; }
.form-actions { margin-top: auto; padding-top: 8px; }
.select-filter { margin-bottom: 8px; }
.copy-box { display: flex; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; color: var(--muted); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.choice-list { border: 0; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.list.initiative-list { padding: 4px 20px; }
.initiative-item { align-items: center; gap: 12px; }
.support-form { margin: 0; }
.support-btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-width: 44px; min-height: 44px; padding: 4px 8px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 160ms ease, color 160ms ease;
}
.support-btn:active:not(:disabled) { transform: scale(0.96); }
.support-btn.is-on { background: var(--tint-info); color: var(--link); border-color: currentColor; }
.support-btn:disabled { cursor: default; opacity: .6; }
.initiative-status-new { color: var(--link); background: var(--tint-info); }
.initiative-status-accepted, .initiative-status-in_progress { color: var(--warning); background: var(--tint-warning); }
.initiative-status-done { color: var(--accent-text); }
.initiative-status-rejected { color: var(--muted); }
.rights-help { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.rights-help summary { cursor: pointer; color: var(--link); }
.rights-help p, .rights-help ul { margin: 8px 0 0; }
.rights-help ul { padding-left: 18px; }
.choice-list legend { font-weight: 500; font-size: 13px; margin-bottom: 8px; padding: 0; color: var(--muted); }
.choice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface-2); cursor: pointer;
  transition: border-color var(--fast) var(--ease-out), background-color var(--fast) var(--ease-out);
}
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.choice input { margin-top: 2px; accent-color: var(--accent); flex: none; width: 18px; height: 18px; }
/* Свой круглый переключатель: у системного обводка фокуса квадратная. */
input[type="radio"] {
  -webkit-appearance: none; appearance: none; flex: none;
  display: inline-grid; place-content: center; width: 18px; height: 18px; margin: 2px 0 0;
  border: 2px solid var(--border-strong); border-radius: 50%; background: var(--surface-2); cursor: pointer;
  transition: border-color var(--fast) var(--ease-out), box-shadow var(--fast) var(--ease-out);
}
input[type="radio"]::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  transform: scale(0); transition: transform var(--fast) var(--ease-out);
}
input[type="radio"]:checked { border-color: var(--accent); }
input[type="radio"]:checked::before { transform: scale(1); }
input[type="radio"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice.is-disabled { opacity: .5; cursor: not-allowed; }
.chip-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { display: inline-flex !important; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-chip); background: var(--surface-2); cursor: pointer; font-weight: 500 !important; margin: 0 !important; color: var(--text) !important; }
.chip-check:has(input:checked) { border-color: var(--accent); }
.chip-check input { accent-color: var(--accent); }
.filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(190px, 1fr) auto auto; align-items: center; gap: 8px; margin-bottom: 16px; padding: 12px; border-radius: var(--radius-card); }
.people-filters { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) auto; }
.filters-compact { grid-template-columns: minmax(0, 1fr) auto; max-width: 560px; }
@media (max-width: 700px) { .filters { grid-template-columns: 1fr 1fr; } .filters input { grid-column: 1 / -1; } .filters .btn { grid-column: 1 / -1; } }

/* ---------- Сообщения, метки ---------- */
.alert { padding: 12px 16px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 12px; }
.alert-success { border-color: color-mix(in srgb, var(--success) 35%, transparent); background: var(--tint-success); }
.alert-error { border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--tint-danger); }
.alert-info { border-color: color-mix(in srgb, var(--cyan) 25%, transparent); background: var(--tint-info); }
.messages { margin-bottom: 16px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 2px 10px; border-radius: var(--radius-chip);
  font-size: 12px; line-height: 16px; font-weight: 500;
  background: var(--surface-3); color: var(--muted);
  white-space: nowrap;
}
.badge .ph { font-size: 13px; }
.badge-green { color: var(--success); background: var(--tint-success); }
.badge-blue { color: var(--link); background: var(--tint-info); }
.badge-red { color: var(--danger); background: var(--tint-danger); }
.badge-warn { color: var(--warning); background: var(--tint-warning); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); flex: none; }

/* ---------- Списки, таблицы ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item:has(> .grow > .row-title, > .grow > a > strong) { position: relative; }
.list-item .row-title::after { content: ""; position: absolute; inset: 0; }
.list-item a:not(.row-title), .list-item form, .list-item button, .list-item .badge, .list-item summary { position: relative; z-index: 1; }
.row-title { color: var(--text) !important; font-weight: 500; }
.task-rows .list-item { min-height: 56px; }
.due { flex: none; min-width: 48px; text-align: right; font-weight: 500; color: var(--muted); }
.due.is-overdue { color: var(--danger); }
.due.is-soon { color: var(--warning); }
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; line-height: 16px; color: var(--faint); font-weight: 500; padding: 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

/* Длинные данные в списках и карточках — до 1–3 строк; полный текст в title и на странице объекта. */
.clamp-1, .clamp-2, .clamp-3,
.project-card h3, .project-summary, .assoc-card h2, .assoc-card-head .small, .task-card-link h4,
.list-item .row-title, .list-item .grow > .small, .project-card-foot > .small {
  display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.clamp-1, .project-card-foot > .small { -webkit-line-clamp: 1; line-clamp: 1; }
.clamp-2, .project-summary, .assoc-card h2, .assoc-card-head .small, .list-item .row-title, .list-item .grow > .small { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3, .project-card h3, .task-card-link h4 { -webkit-line-clamp: 3; line-clamp: 3; }

/* ---------- Пустые состояния и загрузка ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 32px 16px; color: var(--muted); }
.empty .orb { margin: 0 auto; }
.empty-frame { padding: 16px; border: 1px dashed var(--border-strong); border-radius: 16px; color: var(--muted); }
.thinking-pill { display: inline-flex; align-items: center; gap: 12px; padding: 4px 16px 4px 6px; border-radius: var(--radius-chip); background: var(--surface-2); color: var(--muted); font-weight: 500; max-width: 100%; text-align: left; }
.thinking-pill .orb, .empty .thinking-pill .orb { --size: 32px; margin: 0; }
.skeleton { display: block; background: var(--surface-3); border-radius: 6px; }
.sk-line { height: 14px; margin: 6px 0; }
.sk-small { height: 10px; }
.sk-circle { width: 56px; height: 56px; border-radius: 50%; flex: none; }
.skeleton-card .row { flex-wrap: nowrap; }
.bell-skeleton { padding: 8px 12px; }
.is-fresh { animation: fresh-in var(--normal) var(--ease-out); }
@keyframes fresh-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Аватар: точечная сфера в цветах объединений человека ---------- */
.avatar {
  --av: 36px;
  position: relative; width: var(--av); height: var(--av); flex: none;
  display: inline-grid; place-items: center;
  border-radius: 50%; overflow: hidden;
  background: var(--surface-3);
  vertical-align: middle;
}
.avatar .orb { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .7; transition: opacity var(--normal) var(--ease-out); }
.avatar::after { content: ""; position: absolute; inset: 22%; border-radius: 50%; background: color-mix(in srgb, var(--surface-3) 82%, transparent); }
.avatar b { position: relative; z-index: 1; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text); }
.avatar-lg { --av: 64px; }
.avatar-lg b { font-size: 20px; line-height: 28px; }
.avatar-sm { --av: 28px; }
.avatar-sm b { font-size: 11px; }
.avatar-stack { display: flex; flex: none; }
.avatar-stack .avatar { margin-left: -4px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Вкладки: сегменты-капсулы ---------- */
.tabs-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius-chip); background: var(--surface); border: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 6px 14px; border-radius: var(--radius-chip); font-weight: 500; color: var(--muted) !important; white-space: nowrap; transition: background-color var(--fast) var(--ease-out), color var(--fast) var(--ease-out); }
.tabs a.active { background: var(--surface-3); color: var(--text) !important; }
.assoc-scope .tabs a.active { color: var(--assoc-text) !important; }
.date-picker { display: flex; align-items: center; gap: 8px; }
.date-picker input { min-height: 36px; padding: 4px 12px; width: auto; font-size: 14px; }

/* ---------- Меню на <details>: раскрывается от своей кнопки ---------- */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 220px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 16px;
  box-shadow: var(--shadow-float);
  transform-origin: top right;
  transition: opacity var(--fast) var(--ease-out), transform var(--fast) var(--ease-out);
  overscroll-behavior: contain;
}
@starting-style { .menu[open] .menu-list { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.menu-list a, .menu-list button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 10px;
  color: var(--text) !important; background: none; border: 0; font: inherit; cursor: pointer;
}
.menu-list a:active, .menu-list button:active { background: var(--surface-3); }

/* Колокольчик */
.bell summary { position: relative; }
.bell-badge {
  position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--radius-chip); background: var(--cyan); color: #0b0c0e;
  font-size: 10px; line-height: 16px; font-weight: 700; text-align: center;
}
.bell-badge[hidden] { display: none; }
.bell-list { width: min(360px, calc(100vw - 32px)); }
.bell-item { display: flex !important; flex-direction: column; gap: 2px; }
.bell-all { text-align: center !important; font-weight: 500; margin-top: 4px; background: var(--surface-3) !important; }
.bell-push { display: flex !important; align-items: center; gap: 8px; margin-top: 4px; color: var(--link) !important; font-weight: 500; }
.bell-push[hidden] { display: none !important; }
.bell-empty { padding: 8px 12px; }

/* Всплывающие уведомления: приходят в реальном времени, справа снизу (на телефоне — над нижней навигацией). */
.toasts {
  position: fixed; right: 24px; bottom: 24px; z-index: 40;
  display: flex; flex-direction: column; gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  position: relative; display: flex; align-items: flex-start; gap: 4px;
  padding: 12px 8px 12px 16px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 16px;
  box-shadow: var(--shadow-float);
  pointer-events: auto;
  transform-origin: bottom right;
  transition: opacity var(--normal) var(--ease-out), transform var(--normal) var(--ease-out);
}
@starting-style { .toast { opacity: 0; transform: translateY(8px) scale(0.98); } }
.toast.is-leaving { opacity: 0; transform: translateY(4px) scale(0.98); }
.toast::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--cyan); }
.toast-link { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; color: var(--text) !important; }
.toast-title { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--muted); }
.toast-text { overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.toast-close { width: 28px; height: 28px; flex: none; }
.notification.is-unread .notification-link div:first-child { font-weight: 600; }
.notification-link { color: var(--text) !important; }

/* ---------- Вход ---------- */
.auth { position: relative; z-index: 1; min-height: 100svh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
.auth-hero { display: grid; place-items: center; min-height: 100svh; padding: 32px; }
.auth-panel { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card.wide { max-width: 560px; }
.auth-head { margin-bottom: 32px; }
.auth-head h1 { font-size: 30px; line-height: 36px; letter-spacing: -0.03em; margin-bottom: 8px; }
.auth-head p { margin: 0; color: var(--muted); }
.auth-foot { margin-top: 24px; font-size: 13px; line-height: 20px; color: var(--muted); }
.theme-toggle { position: fixed; top: calc(16px + env(safe-area-inset-top, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); z-index: 2; }
.auth-hint { margin-top: 16px; text-align: center; color: var(--faint); font-size: 12px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { min-height: auto; padding: 48px 16px 0; }
  .auth-hero .orb.xl { --size: 200px; }
  .auth-hero .auth-hint { display: none; }
}

/* ---------- Страницы ошибок: большая живая сфера и короткое объяснение ---------- */
.error-page {
  min-height: 100svh;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 32px;
  max-width: 1080px; margin: 0 auto; padding: 48px 32px;
}
.error-orb { display: grid; place-items: center; }
.error-orb .orb { --size: min(46vmin, 420px); }
.error-text { max-width: 440px; }
.error-code {
  display: inline-flex; margin: 0 0 16px; padding: 4px 12px; border-radius: var(--radius-chip);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 13px; line-height: 20px; font-weight: 500;
}
.error-page h1 { font-size: 36px; line-height: 40px; letter-spacing: -0.03em; margin-bottom: 12px; }
.error-lead { margin: 0 0 32px; color: var(--muted); font-size: 16px; line-height: 24px; }
.error-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) {
  .error-page { grid-template-columns: 1fr; gap: 8px; padding: 64px 16px 32px; text-align: center; align-content: center; }
  .error-orb .orb { --size: min(64vw, 260px); }
  .error-text { margin: 0 auto; }
  .error-page h1 { font-size: 28px; line-height: 32px; }
  .error-actions { justify-content: center; }
  .error-actions .btn { flex: 1 1 160px; }
}

/* ---------- Моя работа ---------- */
.home-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1200px) { .home-grid { grid-template-columns: 1fr; } }

/* ---------- Объединения ---------- */
.assoc-mark { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--assoc); }
.assoc-mark.sm { width: 8px; height: 8px; margin: 0; }
.assoc-mark.lg { width: 14px; height: 14px; }
.assoc-badge { color: var(--text) !important; background: color-mix(in srgb, var(--assoc) 14%, var(--surface-2)); }
.assoc-card { position: relative; display: flex; flex-direction: column; gap: 16px; color: var(--text) !important; overflow: hidden;
  transition: border-color var(--normal) var(--ease-out), transform var(--normal) var(--ease-out); }
.assoc-card:active { transform: scale(0.99); }
.assoc-card.is-archived { opacity: .55; }
.assoc-card-head { display: flex; gap: 16px; align-items: center; }
.assoc-card-head .orb { --size: 72px; }
.assoc-card-head h2 { margin: 0; font-size: 18px; line-height: 24px; }
.assoc-desc { margin: 0; color: var(--muted); }
.assoc-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.assoc-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); }
.assoc-stats strong { color: var(--text); font-weight: 600; }
.assoc-stats .text-danger { color: var(--danger); }
.assoc-header .page-head .orb { --size: 56px; }
.assoc-about { max-width: 820px; margin: -8px 0 16px; color: var(--muted); }
.assoc-about-more summary { list-style: none; cursor: pointer; }
.assoc-about-more summary::-webkit-details-marker { display: none; }
.assoc-about-more:not([open]) .assoc-about-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.assoc-about-more summary .more { color: var(--link); font-weight: 500; }
.assoc-about-more[open] summary .more { display: none; }

.structure-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.structure { display: flex; flex-direction: column; gap: 12px; }
.unit { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px 24px; }
.unit.is-archived { opacity: .6; }
.unit-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.unit-head h3 { margin: 0; font-size: 15px; }
.unit-children { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; padding-left: 16px; border-left: 1px solid var(--border-strong); }
.unit-children .unit { background: var(--surface-2); border-radius: 16px; }
.role-list { list-style: none; margin: 0; padding: 0; }
.role-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto; gap: 8px 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.role-row:first-child { border-top: 0; }
.role-row.is-archived { opacity: .55; }
.role-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.role-title a { color: var(--text) !important; }
.role-resp { margin-top: 2px; color: var(--faint); }
.role-holders { display: flex; flex-direction: column; gap: 6px; }
.holder { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.holder-name { font-weight: 500; }
.holder form { margin: 0; display: inline-flex; }
.vacant { color: var(--faint); }
.role-actions { display: flex; gap: 4px; justify-content: flex-end; }
.role-chips { justify-content: flex-end; gap: 4px; }
/* Участники: на узком экране роли уходят на отдельную строку под имя, а не наезжают на него. */
.member-item { flex-wrap: wrap; }
.member-item > .grow { flex: 1 1 200px; min-width: 0; }
.member-item > .grow .small { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .member-item .role-chips { flex-basis: 100%; justify-content: flex-start; padding-left: 52px; }
  .member-item > form { margin-left: 52px; }
}
@media (max-width: 860px) { .role-row { grid-template-columns: 1fr; } .role-actions { justify-content: flex-start; } .unit-children { padding-left: 8px; } }
.danger-zone { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- Проекты ---------- */
.status-idea { color: var(--muted); }
.status-preparation { color: var(--link); background: var(--tint-info); }
.status-in_progress, .status-completed { color: var(--success); background: var(--tint-success); }
.status-cancelled { color: var(--danger); background: var(--tint-danger); }
.status-archived { color: var(--faint); }
.project-card { display: flex; flex-direction: column; gap: 12px; color: var(--text) !important;
  transition: border-color var(--normal) var(--ease-out), transform var(--normal) var(--ease-out); }
.project-card:active { transform: scale(0.99); }
.project-card-top { display: flex; align-items: center; gap: 6px; }
.project-card-top .orb { --size: 44px; margin-left: auto; }
.project-card h3 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.project-summary { margin: 0; color: var(--muted); }
.project-card-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.project-card-foot > .small { flex: 1; min-width: 0; color: var(--faint); }
.project-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1200px) { .project-grid { grid-template-columns: 1fr; } }
.project-health { display: flex; align-items: center; gap: 16px; }
.project-health .orb { --size: 88px; }
.project-health > div:last-child { min-width: 0; }  /* иначе длинное название выталкивает колонку за край */
.assoc-header .page-head .row > div { min-width: 0; }
.assoc-badge { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) { .project-health { gap: 12px; align-items: flex-start; } .project-health .orb, .assoc-header .page-head .orb { --size: 48px; } }
.lifecycle { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.lifecycle .step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--faint); }
.lifecycle .step::before { content: ""; position: absolute; top: 6px; left: -50%; right: 50%; height: 2px; background: var(--border-strong); }
.lifecycle .step:first-child::before { display: none; }
.lifecycle .step-dot { position: relative; z-index: 1; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--border-strong); }
.lifecycle .step.done, .lifecycle .step.current { color: var(--text); }
.lifecycle .step.done .step-dot { background: var(--accent); border-color: var(--accent); }
.lifecycle .step.done::before, .lifecycle .step.current::before { background: var(--accent); }
.lifecycle .step.current .step-dot { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.result-card { border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin: 16px 0 0; padding-top: 16px; border-top: 1px solid var(--border); }
.facts dt, .task-facts dt { font-size: 12px; line-height: 16px; color: var(--faint); font-weight: 500; }
.facts dd, .task-facts dd { margin: 4px 0 0; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 1px solid var(--border-strong); }
.timeline li { position: relative; padding: 0 0 16px 12px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--bg); border: 2px solid var(--muted); }
.add-member { margin-top: 12px; }
.add-member summary { list-style: none; }
.add-member summary::-webkit-details-marker { display: none; }
.add-member[open] summary { margin-bottom: 12px; }

/* ---------- Задачи ---------- */
.board-filters { grid-template-columns: minmax(0, 1.4fr) repeat(4, minmax(0, 1fr)) auto; }
@media (max-width: 1100px) { .board-filters { grid-template-columns: 1fr 1fr; } .board-filters input { grid-column: 1 / -1; } }
@media (max-width: 520px) { .filters, .board-filters { grid-template-columns: 1fr; } .filters .check { padding: 4px 2px; } }
.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: stretch; min-height: 60vh; overscroll-behavior-x: contain; }
@media (max-width: 860px) { .board { grid-template-columns: repeat(4, 46vw); scroll-snap-type: x mandatory; } .board-col { scroll-snap-align: start; } }
@media (max-width: 600px) { .board { grid-template-columns: repeat(4, 82vw); } }
.board-col { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 8px; }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 12px; }
.board-col-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.col-new .board-col-head h3 { color: var(--muted); }
.col-in_progress .board-col-head h3 { color: var(--link); }
.col-review .board-col-head h3 { color: var(--warning); }
.col-done .board-col-head h3 { color: var(--success); }
.board-list { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
/* Колонка 20px с отступом 8 — значит карточка 12px. */
.task-card {
  position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; cursor: grab;
  transition: border-color var(--fast) var(--ease-out), box-shadow var(--fast) var(--ease-out);
}
.task-card.is-locked { cursor: default; }
.task-card:focus-within { border-color: var(--cyan); }
.task-card.is-ghost { opacity: .35; }
.task-card.is-chosen { box-shadow: var(--shadow-float); border-color: var(--border-strong); }  /* в руке — «парит» */
.col-done .task-card h4 { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); }
.task-card-link { color: var(--text) !important; display: block; }
.task-card-link h4 { margin: 4px 0 10px; font-size: 14px; line-height: 20px; font-weight: 500; }
.task-card-place { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--faint); }
.task-card-meta { display: flex; align-items: center; gap: 6px; }
.prio-badge-urgent { color: var(--danger); background: var(--tint-danger); }
.prio-badge-high { color: var(--warning); background: var(--tint-warning); }
.prio-badge-low { opacity: .75; }
.prio-dot-low { background: var(--border-strong); }
.prio-dot-normal { background: var(--link); }
.prio-dot-high { background: var(--warning); }
.prio-dot-urgent { background: var(--danger); }
.task-status-new { color: var(--muted); }
.task-status-in_progress { color: var(--link); background: var(--tint-info); }
.task-status-review { color: var(--warning); background: var(--tint-warning); }
.task-status-done { color: var(--success); background: var(--tint-success); }
.text-danger { color: var(--danger); font-weight: 600; }
.text-success { color: var(--accent-text); }
.review-box { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--tint-info); }
.review-box .row { align-items: flex-start; }
.review-box form { margin: 0; }
.review-return[open] { flex-basis: 100%; }
.review-return[open] summary { margin-bottom: 8px; }
.board-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; padding: 10px 18px; border-radius: var(--radius-chip); background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow-float); font-weight: 500; }
.task-title { overflow-wrap: anywhere; }
.task-text { word-wrap: break-word; }
.task-facts { display: flex; flex-direction: column; gap: 16px; margin: 0 0 16px; }
.status-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-top: 16px; border-top: 1px solid var(--border); }
.status-switch .btn.is-current { background: var(--accent); color: var(--on-accent) !important; border-color: transparent; opacity: 1; }
.task-counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.counter { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 14px; background: var(--surface-2); font-size: 12px; line-height: 16px; text-align: center; color: var(--muted); }
.counter strong { font-size: 18px; line-height: 24px; font-weight: 600; color: var(--text); }

/* Обсуждение */
.comments { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.comment { display: flex; gap: 10px; }
.comment-body { flex: 1; min-width: 0; background: var(--surface-2); border-radius: 6px 18px 18px 18px; padding: 10px 14px; }
.comment.is-own .comment-body { background: color-mix(in srgb, var(--accent) 9%, var(--surface-2)); }
.comment.is-deleted .comment-body { background: transparent; border: 1px dashed var(--border-strong); }
.comment-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.comment-text { margin: 4px 0 6px; word-wrap: break-word; }
.comment-quote { display: flex; flex-direction: column; margin: 6px 0 4px; padding: 6px 10px; border-radius: 10px; background: var(--surface-3); color: var(--muted) !important; }
.comment-actions { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.comment-actions a, .comment-edit summary { color: var(--faint) !important; cursor: pointer; }
.comment-edit summary { list-style: none; }
.comment-edit summary::-webkit-details-marker { display: none; }
.comment-edit[open] { flex-basis: 100%; }
.comment-edit form { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.danger-link { color: var(--danger) !important; }
.comment:target .comment-body { box-shadow: 0 0 0 2px var(--cyan); }
.composer { display: flex; flex-direction: column; gap: 8px; }
.composer-quote { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.composer-quote[hidden] { display: none; }
[data-live] { color: var(--success); }

/* ---------- Карта связей ---------- */
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; padding: 12px; }
.map-toolbar input[type="search"] { flex: 1 1 260px; }
.map-toolbar select { flex: 0 1 220px; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .map-layout { grid-template-columns: 1fr; } }
.map-canvas { position: relative; height: calc(100dvh - 260px); min-height: 460px; padding: 0; overflow: hidden; }
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; }
.map-loading[hidden] { display: none; }
.map-legend { position: absolute; left: 16px; bottom: 12px; z-index: 2; display: flex; gap: 12px; flex-wrap: wrap; color: var(--faint); pointer-events: none; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--text); }
.lg-assoc { width: 14px !important; height: 14px !important; border: 2.5px solid var(--green) !important; }
.lg-project { width: 10px !important; height: 10px !important; }
.lg-person { width: 8px !important; height: 8px !important; border-color: var(--muted) !important; }
.lg-head { width: 9px !important; height: 9px !important; border-color: var(--cyan) !important; }
.lg-hint { opacity: .8; }
.map-counts { position: absolute; right: 16px; top: 12px; z-index: 2; pointer-events: none; }
.map-panel { position: sticky; top: 80px; max-height: calc(100dvh - 100px); overflow: auto; overscroll-behavior: contain; }
.node-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.node-head h2 { margin: 0 0 4px; }
.node-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; flex-wrap: wrap; }
.node-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.map-list { margin-top: 16px; }
.map-list summary { cursor: pointer; font-weight: 500; }
.map-list-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 12px; }
.map-list-groups h3 { font-size: 13px; color: var(--faint); margin: 0 0 4px; }
.map-list-groups button { display: block; width: 100%; text-align: left; padding: 8px 10px; min-height: 40px; border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; cursor: pointer; }
.map-list-groups button:focus-visible, .map-list-groups button:active { background: var(--surface-2); }

/* ---------- Журнал ---------- */
.audit-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-bottom: 16px; padding: 12px; align-items: center; }
.date-field { display: flex; align-items: center; gap: 6px; }
.audit-list { list-style: none; margin: 0; padding: 0; }
.audit-entry { display: grid; grid-template-columns: 72px 32px minmax(0, 1fr); gap: 8px; padding: 12px 0; border-top: 1px solid var(--border); }
.audit-entry:first-child { border-top: 0; }
.audit-what > div:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.audit-create { color: var(--success); background: var(--tint-success); }
.audit-update { color: var(--link); background: var(--tint-info); }
.audit-delete { color: var(--danger); background: var(--tint-danger); }
.audit-changes { margin-top: 6px; }
.audit-changes summary { cursor: pointer; color: var(--faint); }
.audit-changes .table td { padding: 4px 8px; }
@media (max-width: 600px) { .audit-entry { grid-template-columns: 32px minmax(0, 1fr); } .audit-when { grid-column: 1 / -1; } }

/* ---------- Профиль и люди ---------- */

/* Закреплённый предмет рядом с именем: маленькая живая сфера; описание — при наведении и при фокусе (касании). */
.name-with-mark { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ach-mark.orb { --size: 1.25em; min-width: 22px; min-height: 22px; border-radius: 50%; vertical-align: middle; cursor: default; }
.ach-mark::after {
  content: attr(data-tip);
  /* Подсказка растёт вправо от сферы: имена стоят слева, так она не уходит за край экрана. */
  position: absolute; left: -10px; bottom: calc(100% + 8px); z-index: 30;
  width: max-content; max-width: min(280px, 70vw);
  padding: 6px 12px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow-float);
  color: var(--text); font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0; text-align: left;
  white-space: normal; overflow-wrap: anywhere;
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity var(--fast) var(--ease-out), transform var(--fast) var(--ease-out);
}
.ach-mark:focus-visible::after, .ach-mark:focus::after { opacity: 1; transform: none; }
.ach-mark:focus { outline: none; }
.ach-mark:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.person-about { margin-bottom: 16px; }
.person-about-text { margin: 0 0 12px; max-width: 72ch; }
.person-about-text:last-child { margin-bottom: 0; }
.skill-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.skill-chips .badge { color: var(--text) !important; min-height: 28px; padding: 4px 12px; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; margin: 0 0 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 16px 20px; border-radius: var(--radius-card); background: var(--surface); border: 1px solid var(--border); }
.stat dt { font-size: 12px; line-height: 16px; color: var(--faint); font-weight: 500; }
.stat dd { margin: 2px 0 0; font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.02em; }
.person-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .person-grid { grid-template-columns: 1fr; } }

/* Коллекция: плитки-сферы, как подарки в Telegram. Собранные — в цвете, закрытые — тусклые с прогрессом. */
.coll-season { margin: 24px 0 12px; font-size: 14px; color: var(--muted); }
.coll-rules { margin: -8px 0 16px; max-width: 70ch; }
.coll-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.coll-item {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 8px 10px; border-radius: 16px; border: 1px solid var(--border);
  background: radial-gradient(120% 90% at 50% 18%, color-mix(in srgb, var(--tone) 16%, var(--surface-2)), var(--surface-2) 72%);
  color: var(--text); font: inherit; cursor: pointer;
  transition: transform var(--fast) var(--ease-out), border-color var(--fast) var(--ease-out);
}
.coll-item:active { transform: scale(0.97); }
.coll-item.is-locked { background: var(--surface-2); }
.coll-item.rarity-rare { border-color: color-mix(in srgb, #22D3E0 30%, var(--border)); }
.coll-item.rarity-epic { border-color: color-mix(in srgb, #FF3D6E 35%, var(--border)); }
.coll-item.rarity-legendary, .coll-item.rarity-unique { border-color: color-mix(in srgb, var(--tone) 55%, var(--border)); }
.coll-item.rarity-secret:not(.is-locked) { border-color: color-mix(in srgb, #8B5CF6 55%, var(--border)); }
.coll-item.is-locked { border-color: var(--border); }
.coll-orb { --size: 64px; margin-bottom: 4px; }
.coll-name {
  font-size: 13px; line-height: 16px; font-weight: 600; text-align: center; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.coll-item.is-locked .coll-name { color: var(--muted); font-weight: 500; }
.coll-item.is-secret .coll-name { letter-spacing: 0.2em; }
.coll-sub { font-size: 11px; line-height: 14px; color: var(--faint); }
.coll-lock { position: absolute; top: 8px; right: 8px; font-size: 14px; color: var(--faint); }
.coll-bar { display: block; width: 72%; height: 4px; margin-top: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.coll-bar i { display: block; height: 100%; border-radius: inherit; background: var(--tone, var(--accent)); }

.coll-dialog {
  width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 28px 24px 24px;
  border: 1px solid var(--border-strong); border-radius: 24px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-float);
  overscroll-behavior: contain;
  transition: opacity var(--normal) var(--ease-out), transform var(--normal) var(--ease-out);
}
@starting-style { .coll-dialog[open] { opacity: 0; transform: scale(0.96); } }
.coll-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.coll-close { position: absolute; top: 12px; right: 12px; }
.app-dialog { width: min(480px, calc(100vw - 32px)); }
.application { align-items: flex-start; }
.application-text { margin: 8px 0; white-space: normal; overflow-wrap: anywhere; }
.application-contacts { gap: 6px; margin-bottom: 10px; }
.application-form input { flex: 1; min-width: 0; }
.application-reject { margin-top: 6px; }
.application-reject[open] summary { margin-bottom: 8px; }
.application-history { margin-top: 12px; }
.application-history summary { cursor: pointer; }
.coll-detail { text-align: center; }
.coll-orb-big { --size: min(60vw, 230px); display: block; margin: 0 auto 12px; }
.coll-detail-series { margin: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--faint); }
.coll-rarity { font-weight: 600; }
.rarity-rare .coll-rarity { color: #22D3E0; }
.rarity-epic .coll-rarity { color: #FF3D6E; }
.rarity-legendary .coll-rarity { color: #F5C451; }
.rarity-secret .coll-rarity { color: #A78BFA; }
.rarity-unique .coll-rarity { color: var(--accent-text); }
.coll-detail-title { margin: 4px 0 8px; font-size: 22px; line-height: 28px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.coll-detail-how { margin: 0 0 16px; color: var(--muted); overflow-wrap: anywhere; }
.coll-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 0 0 16px; text-align: left; }
.coll-facts div { padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.coll-facts dt { font-size: 11px; line-height: 14px; color: var(--faint); }
.coll-facts dd { margin: 2px 0 0; font-size: 13px; font-weight: 500; }
.coll-levels { list-style: none; margin: 0 0 16px; padding: 4px; display: grid; gap: 2px; border-radius: 12px; background: var(--surface-2); text-align: left; }
.coll-levels li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 13px; line-height: 18px; color: var(--faint); }
.coll-levels li.is-open { color: var(--text); }
.coll-levels li.is-open i { color: var(--tone, var(--accent)); }
.coll-level-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.coll-level-target { font-variant-numeric: tabular-nums; }
.coll-copy-pin { margin: -4px -4px -4px 0; }
.coll-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.coll-actions form { margin: 0; }
.coll-progress { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 16px; }
.coll-progress .coll-bar { width: 100%; height: 6px; }
.stat-of { font-size: 14px; font-weight: 400; color: var(--faint); }

.award-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Рейтинг */
.rating-filters { grid-template-columns: auto minmax(0, 260px); max-width: none; justify-content: start; }
.rating-filters .tabs { border: 0; background: var(--surface-2); }
.rating td { vertical-align: middle; }
.rating-place { width: 40px; color: var(--faint); font-variant-numeric: tabular-nums; }
.rating tr:nth-child(-n+3) .rating-place { color: var(--warning); font-weight: 700; }
@media (max-width: 600px) { .rating-filters { grid-template-columns: 1fr; } }

.profile-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: stretch; }
.profile-grid > .card { display: flex; flex-direction: column; }
.profile-grid > .card > form { flex: 1; display: flex; flex-direction: column; }
@media (max-width: 1200px) { .profile-grid { grid-template-columns: 1fr; } }
.contact-links { display: flex; gap: 4px; }
.people-list .list-item { align-items: flex-start; }
@media (max-width: 600px) { .people-list .contact-links { display: none; } }

/* ---------- Телефон ---------- */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; border-bottom-color: var(--border); }
  .topbar .brand { display: flex; }
  .topbar .brand .orb { --size: 30px; }
  .topbar .brand { min-width: 0; }
  /* Колокольчик не у правого края — выпадающий список уезжал за левый край экрана. На телефоне — во всю ширину. */
  .bell .menu-list {
    position: fixed; left: 16px; right: 16px; width: auto;
    top: calc(60px + env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 160px); overflow-y: auto;
    transform-origin: top center;
  }
  .topbar-avatar { display: inline-flex; }
  .content { padding: 16px 16px 96px; }
  h1 { font-size: 20px; line-height: 28px; }
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--border);
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 48px; padding: 4px 2px; font-size: 11px; line-height: 14px; font-weight: 500;
    color: var(--faint) !important; border-radius: var(--radius-control);
  }
  .bottom-nav a.active { color: var(--text) !important; }
  .bottom-nav a.active .ph { color: var(--accent-text); }
  .bottom-nav .ph { font-size: 22px; }
  @media (max-width: 420px) { .topbar .brand-title { display: none; } }
  .board-toast { bottom: 88px; }
  .toasts { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}

.theme-switching, .theme-switching * { transition: none !important; }

/* ---------- Наведение: только мышь (на телефоне :hover «залипает») ---------- */
@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration: underline; text-underline-offset: 3px; }
  .nav-link:hover, .btn:hover, .tabs a:hover, .bottom-nav a:hover, .brand:hover,
  .assoc-card:hover, .project-card:hover, .task-card-link:hover, .notification-link:hover,
  .comment-quote:hover, .menu-list a:hover, .list-item .row-title:hover { text-decoration: none; }
  .nav-link:hover { background: var(--surface-2); color: var(--text) !important; }
  .nav-link:hover .ph { color: var(--text); }
  .btn:hover { background: var(--surface-3); }
  .btn-ghost:hover { background: var(--surface-2); }
  /* Главная кнопка — единственная, кроме орбов, со свечением (DESIGN.md). */
  .btn-primary:hover { background: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent), 0 0 24px color-mix(in srgb, var(--accent) 45%, transparent); }
  .icon-btn:hover { background: var(--surface-2); color: var(--text); }
  .tabs a:hover { color: var(--text) !important; }
  .assoc-card:hover { border-color: color-mix(in srgb, var(--assoc) 45%, var(--border)); }
  .assoc-card:hover .orb, .project-card:hover .orb { filter: brightness(1.15); }
  .project-card:hover { border-color: var(--border-strong); }
  .task-card:hover { border-color: var(--border-strong); }
  .menu-list a:hover, .menu-list button:hover { background: var(--surface-3); }
  .list-item .row-title:hover { color: var(--link) !important; }
  .role-title a:hover { color: var(--link) !important; }
  li:hover .avatar .orb, a:hover .avatar .orb { opacity: 1; }
  .ach-mark:hover::after { opacity: 1; transform: none; }
    .coll-item:hover { border-color: var(--border-strong); }
  .choice:hover { border-color: var(--border-strong); }
}

/* ---------- Пальцем: цели не меньше 44px ---------- */
@media (pointer: coarse) {
  .toast-close { width: 44px; height: 44px; }
  .btn-sm { min-height: 44px; padding: 8px 14px; }
  .icon-btn { width: 44px; height: 44px; }
  .comment-actions a, .comment-edit summary, .comment-actions .btn-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
  .contact-links .badge { min-height: 44px; padding: 0 12px; }
  .menu-list a, .menu-list button { min-height: 44px; }
  .card-head > a, .card-head > .small, .audit-changes summary, .holder-name { display: inline-flex; align-items: center; min-height: 44px; }
  .check input, .chip-check input { width: 20px; height: 20px; }
  .date-picker input { font-size: 16px; min-height: 44px; }  /* меньше 16px — iOS приближает страницу */
  .tabs a { min-height: 40px; }
  .topbar-avatar { width: 44px; height: 44px; justify-content: center; align-items: center; }
}

/* ---------- Уменьшить движение ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* ---------- Внутри мини-приложения Telegram ----------
   Telegram может открыть его во весь экран: сверху строка состояния и шапка Telegram («Закрыть», меню),
   снизу — системная полоса. Их высоту он сообщает переменными --tg-safe-area-inset-* и
   --tg-content-safe-area-inset-* (telegram-web-app.js) — отступаем, чтобы кнопки не прятались под ними. */
.miniapp-telegram .topbar {
  padding-top: calc(8px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
}
.miniapp-telegram .bottom-nav {
  padding-bottom: calc(4px + max(env(safe-area-inset-bottom, 0px),
    var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
}
.miniapp-telegram .theme-toggle { top: calc(16px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); }
.miniapp-telegram .auth-hero { padding-top: calc(48px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); }
.miniapp-telegram .sidebar { padding-top: calc(16px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); }
