/* Навигация и слои · хлебные крошки, страницы, шаги, боковое меню, оглавление,
   поповер, контекстное меню, шторки, стопка уведомлений, подтверждение опасного действия, командная палитра ⌘K.
   Требует: colors, motion, type, space, icons, components.css. Поведение — js/layers.js.
   Правила те же: наведение — ярче сам элемент (подложка только у строк списков), нажатие размер не меняет,
   фокус — контур без свечения, все появляется и уходит переходами. */

:where(.crumbs a, .crumb-more, .pager button, .side-item, .side-ws, .side-search, .side-label, .onpage a, .ctx-row, .cmdk-item, .toast-x) {
  --hd: var(--dur-hover-out);
  outline: var(--focus-outline) solid transparent; outline-offset: var(--focus-offset);
}
@media (hover: hover) and (pointer: fine) { :where(.crumbs a, .crumb-more, .pager button, .side-item, .side-ws, .side-search, .side-label, .onpage a, .ctx-row, .toast-x):hover { --hd: var(--dur-hover-in) } }
:where(.crumbs a, .crumb-more, .pager button, .side-item, .side-ws, .side-search, .side-label, .onpage a, .ctx-row, .toast-x):focus-visible { outline-color: var(--focus) }

/* ============ Хлебные крошки ============ */
/* Разделитель — шеврон 14 (маска, цвет из токена). Длинный путь: первый + «…» + два последних; «…» раскрывает середину плавно */
.crumbs ol { display: flex; align-items: center; gap: var(--sp-1); min-width: 0; margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); line-height: var(--lh-sm) }
.crumbs li { display: inline-flex; align-items: center; gap: var(--sp-1); flex: none; white-space: nowrap }
.crumbs li:last-child { flex: 0 1 auto; min-width: 0 }   /* сжимается только текущая страница — с многоточием */
.crumbs li + li::before { content: ""; flex: none; width: 14px; height: 14px; background: var(--text-faint);
  -webkit-mask: var(--chev-r) center / 14px no-repeat; mask: var(--chev-r) center / 14px no-repeat }
.crumbs { --chev-r: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E"); min-width: 0 }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-xs); color: var(--text-muted); text-decoration: none;
  transition: color var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out) }
@media (hover: hover) and (pointer: fine) { .crumbs a:hover { color: var(--text) } }
.crumbs a .lucide { width: var(--icon-sm); height: var(--icon-sm) }
.crumbs [aria-current=page] { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-weight: var(--w-medium) }
.crumbs li.folded { display: none }
.crumb-more { display: inline-grid; place-items: center; width: 24px; height: 20px; padding: 0; border: 0; border-radius: var(--r-xs); background: none; color: var(--text-muted); cursor: pointer;
  transition: color var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out) }
@media (hover: hover) and (pointer: fine) { .crumb-more:hover { color: var(--text) } }

/* ============ Страницы ============ */
/* Номера — без подложки (ярче при наведении), текущая — плашка, которая едет к новой странице.
   Набор номеров всегда одной длины (7 мест), поэтому ширина не прыгает. На узком экране — «Страница 3 из 24» */
.pager { position: relative; display: flex; align-items: center; gap: 2px; font-size: var(--fs-sm); line-height: var(--lh-sm); font-variant-numeric: tabular-nums }
.pager-nums { position: relative; display: flex; gap: 2px }
.pager button { position: relative; z-index: 1; display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 var(--sp-2); border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-muted); font: inherit; font-weight: var(--w-medium); cursor: pointer;
  transition: color var(--hd) var(--ease-hover), opacity var(--dur-enter) var(--ease-out), outline-color var(--dur-focus) var(--ease-out) }
@media (hover: hover) and (pointer: fine) { .pager button:hover { color: var(--text) } }
.pager button[aria-current=page] { color: var(--text); --hd: var(--dur-enter) }
.pager button:disabled { opacity: .35; cursor: default; pointer-events: none }
.pager .gap { display: inline-grid; place-items: center; min-width: 32px; height: 32px; color: var(--text-faint) }
.pager-plate { position: absolute; z-index: 0; top: 0; left: 0; height: 32px; width: var(--w, 32px); border-radius: var(--r-sm);
  background: var(--tile-strong); box-shadow: inset 0 0 0 1px var(--border); transform: translateX(var(--x, 0));
  transition: transform var(--dur-morph) var(--ease-out), width var(--dur-morph) var(--ease-out) }
.pager.no-anim .pager-plate { transition: none }
.pager-info { display: none; padding: 0 var(--sp-2); color: var(--text-muted); white-space: nowrap }
.pager-info b { color: var(--text); font-weight: var(--w-medium) }
.pager-range { margin-right: auto; color: var(--text-muted); white-space: nowrap }
@media (max-width: 520px) { .pager-nums { display: none } .pager-info { display: block } .pager-range { display: none } }

/* ============ Шаги ============ */
/* Без кружков: над каждым шагом — полоска, под ней номер «01» текстом и название.
   Пройденный и текущий — полоска акцентом (заполняется слева направо), будущий — серая.
   Пройденный: номер сменяется галочкой, которая прорисовывается; текущий — номер акцентом. На узком экране полоска — слева */
.steps { display: flex; gap: var(--sp-3); margin: 0; padding: 0; list-style: none; counter-reset: step }
.steps li { position: relative; flex: 1; min-width: 0; display: grid; grid-template-columns: 20px minmax(0, 1fr); column-gap: var(--sp-2); row-gap: var(--sp-3); align-items: start; counter-increment: step }
.steps li::before { content: ""; grid-column: 1 / -1; height: 4px; border-radius: var(--r-full); background: var(--border-strong) }
.steps li::after { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 4px; border-radius: var(--r-full); background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform var(--dur-slide) var(--ease-in-out) }
.steps li:is(.done, [aria-current=step])::after { transform: none }
.step-dot { display: grid; place-items: center start; height: 20px; color: var(--text-faint); font: var(--w-medium) var(--fs-xs)/20px var(--font-mono); font-variant-numeric: tabular-nums;
  transition: color var(--dur-state) var(--ease-out) }
.step-dot::before { content: counter(step, decimal-leading-zero); grid-area: 1 / 1; transition: opacity var(--dur-enter) var(--ease-out) }
.step-dot svg { grid-area: 1 / 1; width: 16px; height: 16px; stroke-width: 2.5; color: var(--accent-text); opacity: 0; transition: opacity var(--dur-enter) var(--ease-out) }
.step-dot svg path { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 0s linear var(--dur-enter) }
.steps li[aria-current=step] .step-dot { color: var(--accent-text) }
.steps li.done .step-dot::before { opacity: 0 }
.steps li.done .step-dot svg { opacity: 1; transition-duration: 0s }
.steps li.done .step-dot svg path { stroke-dashoffset: 0; transition: stroke-dashoffset var(--dur-state) var(--ease-out) 120ms }
.step-tx { display: grid; min-width: 0 }
.step-tx b { font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: var(--w-medium); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--dur-state) var(--ease-out) }
.step-tx span { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.steps li:is([aria-current=step], .done) .step-tx b { color: var(--text) }
/* вертикально — по классу и на узком экране: полоска слева во всю высоту шага */
.steps-v { flex-direction: column; gap: var(--sp-2) }
.steps-v li { grid-template-columns: 4px 20px minmax(0, 1fr); column-gap: var(--sp-3); padding: 2px 0 }
.steps-v li::before { grid-column: 1; grid-row: 1; height: auto; align-self: stretch }
.steps-v li::after { width: 4px; height: 100%; transform: scaleY(0); transform-origin: top }
.steps-v .step-dot { margin-left: calc(var(--sp-1) * -1) }
@media (max-width: 720px) {
  .steps-auto { flex-direction: column; gap: var(--sp-2) }
  .steps-auto li { grid-template-columns: 4px 20px minmax(0, 1fr); column-gap: var(--sp-3); padding: 2px 0 }
  .steps-auto li::before { grid-column: 1; grid-row: 1; height: auto; align-self: stretch }
  .steps-auto li::after { width: 4px; height: 100%; transform: scaleY(0); transform-origin: top }
  .steps-auto .step-dot { margin-left: calc(var(--sp-1) * -1) }
}
.steps-v li:is(.done, [aria-current=step])::after { transform: none }
@media (max-width: 720px) { .steps-auto li:is(.done, [aria-current=step])::after { transform: none } }

/* ============ Боковое меню приложения ============ */
/* 240 ↔ 56. Иконки не двигаются при сворачивании (стоят на одной оси), подписи гаснут; ширина — плавно.
   Строки — список, поэтому у них есть плитка наведения; выбранная — плотнее */
.side { --side-w: 240px; display: flex; flex-direction: column; gap: var(--sp-1); width: var(--side-w); flex: none; min-height: 0; padding: var(--sp-2);
  background: var(--bg-raised); box-shadow: inset -1px 0 0 var(--border-subtle); overflow: hidden;
  transition: width var(--dur-state) var(--ease-in-out) }
.side.collapsed { --side-w: 56px }
.side-tx { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: opacity var(--dur-enter) var(--ease-out) }
.side.collapsed .side-tx, .side.collapsed .side-count, .side.collapsed .side-search .kbd, .side.collapsed .side-label .lucide { opacity: 0; pointer-events: none }
.side-head { display: flex; align-items: center; gap: var(--sp-1); height: 40px }
.side-ws { display: flex; align-items: center; gap: var(--sp-2); flex: 1; min-width: 0; height: 40px; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text);
  font: inherit; font-weight: var(--w-medium); cursor: pointer; transition: background-color var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out) }
@media (hover: hover) and (pointer: fine) { .side-ws:hover { background: var(--tile) } }
.side-ws .lucide { margin-left: auto; color: var(--text-faint); flex: none }
.ws-logo { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: var(--r-xs); background: var(--accent); color: var(--accent-fg); font-size: var(--fs-xs); font-weight: var(--w-semibold) }
.side-toggle { flex: none; transition: color var(--hd) var(--ease-hover), opacity var(--dur-enter) var(--ease-out) }
.side.collapsed .side-toggle { position: absolute; opacity: 0; pointer-events: none }
.side-search { display: flex; align-items: center; gap: var(--sp-2); height: 32px; padding: 0 12px; margin-bottom: var(--sp-2); border: 0; border-radius: var(--r-sm);
  background: var(--fill); box-shadow: inset 0 0 0 1px var(--border-subtle); color: var(--text-muted); font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer;
  transition: color var(--hd) var(--ease-hover), box-shadow var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out) }
@media (hover: hover) and (pointer: fine) { .side-search:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--border) } }
.side-search .side-tx { flex: 1 }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none }
.side-nav > *, .side-sub > div > * { flex: none }   /* строки не сжимаются — меню прокручивается */
.side-item { display: flex; align-items: center; gap: var(--sp-2); height: 32px; padding: 0 12px; border-radius: var(--r-sm); color: var(--text-muted); text-decoration: none;
  font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: var(--w-medium); cursor: pointer;
  transition: background-color var(--hd) var(--ease-hover), color var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out) }
.side-item .lucide { flex: none; transition: color var(--hd) var(--ease-hover) }
.side-item .side-tx { flex: 1 }
@media (hover: hover) and (pointer: fine) { .side-item:hover { background: var(--tile); color: var(--text) } }
.side-item[aria-current=page] { background: var(--tile-strong); color: var(--text); --hd: var(--dur-enter) }
.side-count { flex: none; min-width: 20px; height: 18px; padding: 0 6px; border-radius: var(--r-full); display: inline-grid; place-items: center;
  font-size: var(--fs-2xs); line-height: 1; font-weight: var(--w-semibold); font-variant-numeric: tabular-nums; color: var(--text-secondary); background: var(--tile-strong);
  transition: opacity var(--dur-enter) var(--ease-out) }
.side-label { display: flex; align-items: center; gap: var(--sp-1); height: 28px; margin-top: var(--sp-3); padding: 0 12px; border: 0; border-radius: var(--r-xs); background: none;
  font: var(--w-medium) var(--fs-2xs)/var(--lh-2xs) var(--font-mono); letter-spacing: var(--label-tracking); text-transform: uppercase; color: var(--text-faint); cursor: pointer; text-align: left;
  transition: color var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out) }
@media (hover: hover) and (pointer: fine) { .side-label:hover { color: var(--text-muted) } }
.side-label .lucide { width: 12px; height: 12px; transition: transform var(--dur-state) var(--ease-out), opacity var(--dur-enter) var(--ease-out) }
.side-label[aria-expanded=false] .lucide { transform: rotate(-90deg) }
/* сворачивание группы — высота через сетку 1fr ↔ 0fr: плавно и без замеров */
.side-sub { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--dur-expand) var(--ease-out) }
.side-sub > div { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden }
.side-label[aria-expanded=false] + .side-sub { grid-template-rows: 0fr; transition-duration: var(--dur-collapse) }
.side.collapsed .side-label { height: 0; margin-top: var(--sp-2); overflow: hidden }
.side-dot { flex: none; width: 8px; height: 8px; margin: 0 4px; border-radius: 3px }
.side-foot { display: flex; align-items: center; gap: var(--sp-2); height: 40px; padding: 0 8px; margin-top: var(--sp-1); border-radius: var(--r-sm); color: var(--text-secondary); font-size: var(--fs-sm) }
.side-foot .avatar { flex: none }
.side-foot .side-tx { flex: 1 }

/* ===== Каркас экрана приложения: боковое меню + рабочая область (references/app.md) =====
   z-index у липкого меню обязателен: без него строки таблиц под ним становятся отдельными слоями
   (замер: 21 слой вместо 4, кадр прокрутки до 55 мс при CPU ×4). */
.app-shell { display: flex; min-height: 100dvh }
.app-shell > .side { position: sticky; top: 0; z-index: 1; height: 100dvh; box-shadow: inset -1px 0 0 var(--border-subtle) }
.app-main { flex: 1; min-width: 0; padding: var(--sp-8) var(--sp-6) var(--sp-6) }
.app-inner { max-width: 1200px; margin: 0 auto }
.app-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap }
.app-title { display: flex; align-items: center; gap: var(--sp-3); min-width: 0 }
.app-title h1 { margin: 0; font-size: var(--fs-2xl); line-height: var(--lh-2xl); letter-spacing: var(--ls-2xl); font-weight: var(--w-medium) }
.app-sub { margin: var(--sp-1) 0 0; color: var(--text-muted); font-size: var(--fs-sm); line-height: var(--lh-sm) }
@media (max-width: 640px) { .app-main { padding: var(--sp-4) var(--sp-4) var(--sp-6) } }
@media (pointer: coarse) { .side-item { height: 40px } }

/* ============ Оглавление страницы ============ */
/* Метка текущего раздела — одна полоска на линии слева, едет к активному пункту (transform + высота) */
.onpage { position: relative; display: grid; gap: var(--sp-2); align-content: start; font-size: var(--fs-sm); line-height: var(--lh-sm) }
.onpage ul { position: relative; display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; box-shadow: inset 1px 0 0 var(--border) }
.onpage a { display: block; padding: 4px var(--sp-3); border-radius: 0 var(--r-xs) var(--r-xs) 0; color: var(--text-muted); text-decoration: none;
  transition: color var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out); outline-offset: -2px }
.onpage .sub a { padding-left: var(--sp-6) }
@media (hover: hover) and (pointer: fine) { .onpage a:hover { color: var(--text) } }
.onpage a[aria-current=true] { color: var(--text); --hd: var(--dur-enter) }
.onpage-mark { position: absolute; left: 0; top: 0; width: 2px; height: var(--h, 0); border-radius: 2px; background: var(--text); transform: translateY(var(--y, 0));
  transition: transform var(--dur-morph) var(--ease-out), height var(--dur-morph) var(--ease-out), opacity var(--dur-enter) var(--ease-out) }
.onpage.no-anim .onpage-mark { transition: none }

/* ============ Плавающие панели: поповер и контекстное меню ============ */
/* Позиция — от точки (курсор) или от кнопки; растут из угла, ближайшего к источнику (--origin считает js) */
.pop { position: fixed; z-index: 55; width: min(var(--pop-w, 300px), calc(100vw - 16px)); padding: var(--sp-4); border-radius: var(--r-lg);
  background: var(--bg-raised); box-shadow: inset 0 0 0 1px var(--border), var(--shadow-md); transform-origin: var(--origin, top left);
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(calc(var(--shift-sm) * var(--dir, -1))) scale(var(--scale-in));
  transition: opacity var(--dur-exit) var(--ease-out), transform var(--dur-exit) var(--ease-out), visibility 0s linear var(--dur-exit) }
.pop.open { opacity: 1; visibility: visible; pointer-events: auto; transform: none;
  transition: opacity var(--dur-enter) var(--ease-out), transform var(--dur-enter) var(--ease-out), visibility 0s }
.pop h4 { margin: 0 0 var(--sp-1); font-size: var(--fs-base); line-height: var(--lh-base); font-weight: var(--w-semibold) }
.pop p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); line-height: var(--lh-sm) }
.pop-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4) }
.pop .field + .field { margin-top: var(--sp-3) }
/* карточка человека (по наведению) */
.pop-person { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-3); align-items: center }
.pop-person + .pop-meta { margin-top: var(--sp-3); padding-top: var(--sp-3); box-shadow: inset 0 1px 0 var(--border-subtle); display: grid; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-muted) }
.pop-meta span { display: flex; align-items: center; gap: var(--sp-2) }
.pop-meta .lucide { width: var(--icon-sm); height: var(--icon-sm) }
.menu.fixed { position: fixed }

/* строки, у которых есть контекстное меню */
.ctx-list { display: grid; padding: var(--sp-1); border-radius: var(--r-lg); background: var(--bg); box-shadow: inset 0 0 0 1px var(--border-subtle); user-select: none; -webkit-touch-callout: none }
.ctx-row { position: relative; display: grid; grid-template-columns: 16px 1fr auto; gap: var(--sp-3); align-items: center; height: 40px; padding: 0 var(--sp-3); border-radius: var(--r-sm);
  color: var(--text-secondary); font-size: var(--fs-sm); cursor: default; outline-offset: -2px;
  transition: background-color var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out) }
.ctx-row .lucide { color: var(--text-muted) }
.ctx-row .meta { color: var(--text-muted); font-variant-numeric: tabular-nums }
.ctx-row.ctx-on { background: var(--tile) }
@media (hover: hover) and (pointer: fine) { .ctx-row:hover { background: var(--tile) } }
.ctx-row.ctx-on { --hd: 0ms }
.ctx-row + .ctx-row::before { content: ""; position: absolute; top: 0; left: var(--sp-3); right: var(--sp-3); height: 1px; background: var(--border-subtle); transition: opacity var(--hd) var(--ease-hover) }
.ctx-row:is(.ctx-on)::before, .ctx-row:is(.ctx-on) + .ctx-row::before { opacity: 0 }
@media (hover: hover) and (pointer: fine) { .ctx-row:hover::before, .ctx-row:hover + .ctx-row::before { opacity: 0 } }

/* ============ Шторка (сбоку и снизу) ============ */
/* Это <dialog>: фокус внутри, Esc закрывает, страница под ней не прокручивается (scroll-lock.js).
   Выезжает по кривой шторок 320 мс, уезжает быстрее тем же путем. Нижнюю можно смахнуть вниз */
.sheet { position: fixed; margin: 0; padding: 0; border: 0; max-width: none; max-height: none; color: var(--text); background: var(--bg-raised);
  display: flex; flex-direction: column; box-shadow: inset 0 0 0 1px var(--border), var(--shadow-lg);
  transition: transform var(--dur-sheet-out) var(--ease-out), overlay var(--dur-sheet-out) allow-discrete, display var(--dur-sheet-out) allow-discrete }
.sheet:not([open]) { display: none }
.sheet[open] { transition-duration: var(--dur-sheet); transition-timing-function: var(--ease-drawer) }
.sheet::backdrop { background: #00000000; transition: background-color var(--dur-sheet-out) var(--ease-out), overlay var(--dur-sheet-out) allow-discrete, display var(--dur-sheet-out) allow-discrete }
.sheet[open]::backdrop { background: #0000008c; transition-duration: var(--dur-sheet) }
[data-theme="light"] .sheet[open]::backdrop { background: #0f101166 }
@starting-style { .sheet[open]::backdrop { background: #00000000 } }
.sheet-side { inset: 0 0 0 auto; width: min(420px, 100vw); height: 100dvh; border-radius: var(--r-xl) 0 0 var(--r-xl); transform: translateX(100%) }
.sheet-side[open] { transform: none }
@starting-style { .sheet-side[open] { transform: translateX(100%) } }
.sheet-bottom { inset: auto 0 0 0; width: min(560px, 100vw); margin-inline: auto; max-height: 85dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; transform: translateY(100%); touch-action: none }
.sheet-bottom[open] { transform: none }
@starting-style { .sheet-bottom[open] { transform: translateY(100%) } }
.sheet.dragging { transition: none }
.sheet-grab { flex: none; display: grid; place-items: center; height: 20px; cursor: grab }
.sheet-grab::before { content: ""; width: 36px; height: 4px; border-radius: var(--r-full); background: var(--border-strong) }
.sheet-head { flex: none; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) var(--sp-4) }
.sheet-bottom .sheet-head { padding-top: var(--sp-1) }
.sheet-head h2 { flex: 1; margin: 0; font-size: var(--fs-lg); line-height: var(--lh-lg); letter-spacing: var(--ls-lg); font-weight: var(--w-semibold) }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--sp-6); display: grid; gap: var(--sp-4); align-content: start; overscroll-behavior: contain }
.sheet-body > p { margin: 0; color: var(--text-muted) }
.sheet-foot { flex: none; display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-5) var(--sp-6) calc(var(--sp-5) + env(safe-area-inset-bottom)) }
@media (max-width: 520px) { .sheet-side { border-radius: 0 } }

/* ============ Стопка уведомлений ============ */
/* Внизу по центру, одной колодой: новое — спереди, два прежних выглядывают из-за него полосками по 12px
   (уменьшены и той же высоты, что переднее, текст в них погашен). Наведение или фокус — колода раскрывается в список,
   таймеры стоят. Новое въезжает снизу, уходит вниз; смахнуть вниз — закрыть. Все — переходы, их можно прервать */
.toasts { position: fixed; z-index: 70; left: 50%; bottom: calc(var(--sp-6) + env(safe-area-inset-bottom)); width: 380px; height: var(--stack-h, 0px);
  transform: translateX(-50%); transition: height var(--dur-sheet) var(--ease-drawer) }
.toasts:empty { pointer-events: none }
/* мостик под раскрытым списком: курсор, уходящий между карточками, не схлопывает колоду */
.toasts::before { content: ""; position: absolute; inset: -12px -12px -24px }
.tst { position: absolute; left: 0; right: 0; bottom: 0; z-index: var(--z, 1); box-sizing: border-box; height: var(--h, auto); overflow: hidden;
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: var(--sp-3); align-items: start; padding: 14px var(--sp-3) 14px var(--sp-4);
  border-radius: var(--r-lg); background: var(--bg-raised); box-shadow: inset 0 0 0 1px var(--border), var(--shadow-lg);
  font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-secondary); touch-action: none; user-select: none;
  transform: translate(var(--dx, 0px), calc(var(--y, 0px) + var(--dy, 0px))) scale(var(--s, 1)); transform-origin: 50% 0;
  transition: transform var(--dur-sheet) var(--ease-drawer), height var(--dur-sheet) var(--ease-drawer), opacity var(--dur-enter) var(--ease-out) }
.tst.enter { transform: translateY(calc(100% + var(--sp-6))); opacity: 0 }
.tst.leave { transform: translateY(calc(var(--y, 0px) + var(--dy, 0px) + 100% + var(--sp-6))) scale(var(--s, 1)); opacity: 0; pointer-events: none;
  transition-duration: var(--dur-sheet-out), var(--dur-sheet-out), var(--dur-exit) }
/* смахнули вбок — уходит дальше в ту же сторону, а не вниз */
.tst.leave.leave-x { transform: translate(calc(var(--dx, 0px) + var(--dir, 1) * 110%), var(--y, 0px)) scale(var(--s, 1)) }
.tst.behind-out { opacity: 0; pointer-events: none }
.tst.dragging { transition: none }
/* содержимое задних карточек гаснет — видна только полоска */
.tst > * { transition: opacity var(--dur-enter) var(--ease-out) }
.tst.behind > * { opacity: 0 }
/* иконка 24 без круга: сам знак (галочка, крестик, «i», колокольчик), линия 2.25 — заметна рядом с текстом 14/20.
   Центр иконки — на середине строки заголовка */
.tst-ic { display: grid; width: 24px; height: 24px; margin-top: -2px; place-items: center }
.tst-ic > * { grid-area: 1 / 1; transition: opacity var(--dur-enter) var(--ease-out), transform var(--dur-state) var(--ease-out) }
.tst-ic > svg { width: 24px; height: 24px; stroke-width: 2.25 }
.tst-ic > .i-info { width: 22px; height: 22px; stroke-width: 2 }   /* «i» в круге: круг занимает всю клетку — на 2px меньше, чтобы по весу совпадала с галочкой и крестиком */
.tst-ic > .i-default { width: 18px; height: 18px; stroke-width: 2 }   /* колокол — массивный знак: на 24px перевешивает текст, 18 — как спиннер */
.tst-ic .off { opacity: 0; transform: scale(.6) }
.tst[data-type=success] .tst-ic { color: var(--success-text) }
.tst[data-type=error] .tst-ic { color: var(--danger-text) }
.tst[data-type=info] .tst-ic { color: var(--info-text) }
.tst[data-type=loading] .tst-ic, .tst[data-type=default] .tst-ic { color: var(--text-muted) }
.tst-ic .spinner { width: 18px; height: 18px }
.tst-body { min-width: 0; overflow-wrap: anywhere }
.tst-body b { display: block; font-weight: var(--w-medium); color: var(--text) }
.tst-body span { display: block; margin-top: 2px; color: var(--text-muted) }
/* есть пояснение — кнопка действия встает под текст, а не сжимает его в узкую колонку */
.tst-foot { display: flex; gap: var(--sp-2); margin-top: var(--sp-3) }
.tst-foot:empty { display: none }
/* справа — своя колонка: кнопка действия и крестик рядом, ничего не перекрывает друг друга */
.tst-act { display: flex; align-items: center; gap: var(--sp-1); margin: -4px 0 }
.toast-x { display: grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-faint); cursor: pointer;
  transition: color var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out) }
.toast-x .lucide { width: 16px; height: 16px }
@media (hover: hover) and (pointer: fine) { .toast-x:hover { color: var(--text) } }
@media (max-width: 520px) { .toasts { left: var(--sp-4); right: var(--sp-4); width: auto; transform: none; bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)) } }
@media (prefers-reduced-motion: reduce) {
  .tst, .toasts { transition-property: opacity; transition-duration: var(--dur-enter) }
  .tst.enter, .tst.leave, .tst.leave.leave-x { transform: translate(var(--dx, 0px), var(--y, 0px)) scale(var(--s, 1)) }
}

/* ============ Подтверждение опасного действия ============ */
.dialog-danger .dialog-body { display: grid; grid-template-columns: 24px 1fr; gap: var(--sp-3) }
.danger-ic { display: grid; place-items: center; width: 24px; height: 28px; color: var(--danger-text) }   /* знак без круга — стоит на строке заголовка */
.danger-ic .lucide { width: 24px; height: 24px; stroke-width: 2 }
.dialog-danger .field { margin-top: var(--sp-4) }
.dialog-danger code { padding: 1px 6px; border-radius: var(--r-xs); background: var(--fill); box-shadow: inset 0 0 0 1px var(--border-subtle); font: var(--fs-sm)/var(--lh-sm) var(--font-mono); color: var(--text) }
@media (max-width: 520px) { .dialog-danger .dialog-body { grid-template-columns: 1fr } .dialog-foot .btn { flex: 1 } }

/* ============ Диалоги: размеры и виды ============
   Ширина: обычный 440 (подтверждения), .dialog-md 520 (формы), .dialog-lg 640 (текст, списки).
   Строение: .dialog-head (заголовок + подзаголовок + крестик) → .dialog-main (содержимое) → .dialog-foot (действия справа).
   Крестик — только там, где закрыть = «ничего не делать» (формы, справка). У подтверждений его нет: выбор — кнопками. */
.dialog { overflow: visible }   /* списки выбора внутри формы не обрезаются краем окна */
/* Раскладка окна — на .dialog, а не на :modal/[open]: при close() они снимаются сразу, а окно еще ~170мс гаснет.
   Было: в эти кадры окно теряло flex-column (шапка, текст и низ вставали в ряд — колонки по 20px) и overflow (вылезала полоса) */
.dialog-scroll, .dialog.wz-anim { overflow: hidden }
.dialog-md { width: min(520px, calc(100vw - 32px)) }
.dialog-lg { width: min(640px, calc(100vw - 32px)) }
.dialog-head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-6) var(--sp-6) 0 }
.dialog-head > div { flex: 1; min-width: 0 }
.dialog-head h2:last-child { margin-bottom: 0 }
.dialog-head .icon-btn { margin: 0 calc(var(--sp-2) * -1) 0 0 }   /* знак крестика — по краю текста, а не кнопка */
.dialog-main { display: grid; gap: var(--sp-4); align-content: start; padding: var(--sp-5) var(--sp-6) 0 }
.dialog-foot .grow { margin-right: auto }

/* Длинное содержимое: шапка и кнопки стоят, прокручивается середина. Линии под шапкой и над кнопками
   проявляются, только когда за ними есть скрытый текст (не до краев — с отступом 24px) */
.dialog-scroll { flex-direction: column; max-height: min(680px, calc(100dvh - 32px)) }
.dialog-scroll[open] { display: flex }   /* при закрытии display держится переходом, а направление и высота — с базы */
.dialog-scroll .dialog-head, .dialog-scroll .dialog-foot { position: relative; flex: none }
.dialog-scroll .dialog-head { padding-bottom: var(--sp-4) }
.dialog-scroll .dialog-main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-top: 0; padding-bottom: var(--sp-1) }
.dialog-scroll .dialog-foot { padding-top: var(--sp-4) }
.dialog-scroll .dialog-head::after, .dialog-scroll .dialog-foot::before { content: ""; position: absolute; left: var(--sp-6); right: var(--sp-6); height: 1px;
  background: var(--border-subtle); opacity: 0; transition: opacity var(--dur-enter) var(--ease-out) }
.dialog-scroll .dialog-head::after { bottom: 0 }
.dialog-scroll .dialog-foot::before { top: 0 }
.dialog-scroll.sh-top .dialog-head::after, .dialog-scroll.sh-bottom .dialog-foot::before { opacity: 1 }
.dialog-main h3 { margin: var(--sp-2) 0 0; font-size: var(--fs-base); line-height: var(--lh-base); font-weight: var(--w-semibold) }
.dialog-main h3 + p { margin-top: calc(var(--sp-3) * -1) }

/* Итог (успех): по центру, знак без круга прорисовывается, одна кнопка во всю ширину */
.dialog-center .dialog-body { display: grid; justify-items: center; text-align: center; padding-top: var(--sp-8) }
.dialog-center .done-ic { width: 32px; height: 32px; margin-bottom: var(--sp-4); color: var(--accent-text); stroke-width: 2 }
.dialog-center .done-ic path { stroke-dasharray: 1; stroke-dashoffset: 1 }
.dialog-center[open] .done-ic path { stroke-dashoffset: 0; transition: stroke-dashoffset var(--dur-state) var(--ease-out) 160ms }
@starting-style { .dialog-center[open] .done-ic path { stroke-dashoffset: 1 } }
.dialog-center .dialog-foot .btn { flex: 1 }

/* Приглашение: строка ввода + список участников */
.invite-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px auto; gap: var(--sp-2); align-items: start }
.invite-row .error { grid-column: 1 / -1 }
.members { display: grid; margin: calc(var(--sp-2) * -1) calc(var(--sp-3) * -1) 0; padding: 0; list-style: none }
.members .mem { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: var(--sp-3); align-items: center; padding: var(--sp-2) var(--sp-3) }
.members .avatar { width: 32px; height: 32px; font-size: var(--fs-xs) }
.mem-tx { display: grid; min-width: 0 }
.mem-tx b { font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: var(--w-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.mem-tx span { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.mem-role { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); white-space: nowrap }
/* Роль — тихая кнопка меню: роли + «Убрать из проекта». Отдельной колонки под крестик нет: у владельца его быть не может,
   и зарезервированное место стало бы дырой. Без подложки — светлеет текст; край шеврона = край колонки, как текст «Владелец» */
.role-btn { display: inline-flex; align-items: center; gap: var(--sp-1); height: 28px; padding: 0 0 0 var(--sp-2); border: 0; border-radius: var(--r-xs); background: none;
  color: var(--text-muted); font: inherit; font-size: var(--fs-sm); line-height: var(--lh-sm); white-space: nowrap; cursor: pointer;
  transition: color var(--hd) var(--ease-hover), outline-color var(--dur-focus) var(--ease-out); --hd: var(--dur-hover-out); outline: 2px solid transparent; outline-offset: 2px }
.role-btn[aria-expanded=true] { color: var(--text); --hd: var(--dur-icon-in) }
@media (hover: hover) and (pointer: fine) { .role-btn:hover { color: var(--text); --hd: var(--dur-icon-in) } }
.role-btn:focus-visible { outline-color: var(--focus) }
.role-btn .lucide { flex: none; transition: transform var(--dur-enter) var(--ease-out) }
.role-btn[aria-expanded=true] .lucide { transform: rotate(180deg) }
.members ~ .menu, .dialog > .menu { min-width: 208px }
.menu-item[aria-checked=true] { background: var(--fill); color: var(--text) }
.members-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: var(--sp-2) }
.members-head .t-label { margin: 0 }
@media (max-width: 520px) {
  .invite-row { grid-template-columns: 1fr auto }
  .invite-row .input { grid-column: 1 / -1 }
  /* на телефоне роль — третьей строкой под почтой, имя получает всю ширину */
  /* на телефоне роль — строкой под почтой, имя получает всю ширину */
  .members .mem { grid-template-columns: 32px minmax(0, 1fr); row-gap: 0 }
  .members .mem > .avatar { grid-row: 1 / span 2 }
  .members .mem > :is(.mem-role, .role-btn) { grid-column: 2; grid-row: 2; justify-self: start; font-size: var(--fs-xs); line-height: var(--lh-xs) }
  .members .role-btn { height: 20px; padding: 0 }
  .dialog-wizard .step-tx { transition: opacity var(--dur-state) var(--ease-out) }
  .dialog-wizard .steps li:not([aria-current=step]) .step-tx { opacity: 0 }   /* подписи не влезают — видна только текущая, смена плавная */
  .dialog-wizard .steps li { transition: flex-grow var(--dur-morph) var(--ease-out) }
  .dialog-wizard .steps li[aria-current=step] { flex-grow: 2.4 }   /* текущий шаг шире: его подпись помещается целиком, а не обрезается многоточием */
}

/* Пошаговый: шаги сверху, высота окна плавно меняется под шаг, шаг въезжает по направлению движения */
.dialog-wizard .steps { margin-top: var(--sp-5) }
.dialog-wizard .step-tx span { display: none }
.wz-pane { display: grid; gap: var(--sp-4); align-content: start }
.wz-pane[hidden] { display: none }
.dns { display: grid; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--border-subtle); font-size: var(--fs-sm); line-height: var(--lh-sm) }
.dns > div { display: grid; grid-template-columns: 56px 64px minmax(0, 1fr) 28px; gap: var(--sp-3); align-items: center; min-height: 44px; padding: 0 var(--sp-2) 0 var(--sp-4) }
.dns > div + div { box-shadow: inset 0 1px 0 var(--border-subtle) }
.dns .dns-h { min-height: 36px; color: var(--text-faint); font: var(--w-medium) var(--fs-2xs)/var(--lh-2xs) var(--font-mono); letter-spacing: var(--label-tracking); text-transform: uppercase }
.dns code { font: var(--fs-sm)/var(--lh-sm) var(--font-mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.wz-check { display: grid; justify-items: center; gap: var(--sp-3); padding: var(--sp-6) 0 var(--sp-2); text-align: center; color: var(--text-muted) }
.wz-check .ic { display: grid; place-items: center; width: 32px; height: 32px }
.wz-check .ic > * { grid-area: 1 / 1; transition: opacity var(--dur-enter) var(--ease-out) }
.wz-check .ic .lucide { width: 32px; height: 32px; stroke-width: 2; color: var(--accent-text); opacity: 0 }
.wz-check .spinner { width: 24px; height: 24px }
.wz-check.ok .spinner { opacity: 0 }
.wz-check.ok .ic .lucide { opacity: 1 }
.wz-check .tx { display: grid }
.wz-check .tx > * { grid-area: 1 / 1; transition: opacity var(--dur-enter) var(--ease-out) }
.wz-check .tx b { display: block; color: var(--text); font-weight: var(--w-medium) }
.wz-check .tx .ok-tx, .wz-check.ok .tx .wait-tx { opacity: 0 }
.wz-check.ok .tx .ok-tx { opacity: 1 }
@media (max-width: 520px) { .dns > div { grid-template-columns: 48px minmax(0, 1fr) 28px } .dns > div > :nth-child(2) { display: none } }

/* Горячие клавиши: группы в две колонки, клавиши прижаты вправо */
.keys-groups { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6) var(--sp-8); padding-bottom: var(--sp-2) }
.keys-group { display: grid; align-content: start }
.keys-groups .t-label { margin: 0 0 var(--sp-1) }
.key-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: 36px; font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-secondary) }
.key-row + .key-row { box-shadow: inset 0 1px 0 var(--border-subtle) }
.key-row .keys { display: flex; gap: var(--sp-1); flex: none }
@media (max-width: 600px) { .keys-groups { grid-template-columns: 1fr } }
@media (prefers-reduced-motion: reduce) { .dialog-center[open] .done-ic path { transition: none } }

/* ============ Командная палитра ⌘K ============ */
/* Открывают десятки раз в день — поэтому без сдвига и масштаба, только короткая прозрачность 120 мс.
   Высота списка при фильтрации меняется плавно (js). Строки — плитка выбранной, мышь и стрелки двигают одно выделение */
.cmdk { position: fixed; top: 14vh; margin: 0 auto; padding: 0; border: 0; width: min(600px, calc(100vw - 32px)); max-width: none; max-height: none; color: var(--text);
  border-radius: var(--r-lg); background: var(--bg-raised); box-shadow: inset 0 0 0 1px var(--border), var(--shadow-lg); overflow: hidden;
  opacity: 0; transition: opacity var(--dur-palette) var(--ease-out), overlay var(--dur-palette) allow-discrete, display var(--dur-palette) allow-discrete }
.cmdk[open] { opacity: 1 }
@starting-style { .cmdk[open] { opacity: 0 } }
.cmdk::backdrop { background: #00000000; transition: background-color var(--dur-palette) var(--ease-out), overlay var(--dur-palette) allow-discrete, display var(--dur-palette) allow-discrete }
.cmdk[open]::backdrop { background: #00000066 }
[data-theme="light"] .cmdk[open]::backdrop { background: #0f101133 }
@starting-style { .cmdk[open]::backdrop { background: #00000000 } }
.cmdk-in { display: flex; align-items: center; gap: var(--sp-3); height: 52px; padding: 0 var(--sp-4); box-shadow: inset 0 -1px 0 var(--border-subtle) }
.cmdk-in .lucide { color: var(--text-muted); flex: none }
.cmdk-in input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; color: var(--text); font: inherit; font-size: var(--fs-md) }
.cmdk-in input::placeholder { color: var(--text-faint) }
.cmdk-list { max-height: min(360px, 50vh); overflow-y: auto; padding: var(--sp-2); overscroll-behavior: contain; scroll-padding: var(--sp-2) }
.cmdk-group + .cmdk-group { margin-top: var(--sp-2) }
.cmdk-label { padding: var(--sp-2) var(--sp-2) var(--sp-1); font: var(--w-medium) var(--fs-2xs)/var(--lh-2xs) var(--font-mono); letter-spacing: var(--label-tracking); text-transform: uppercase; color: var(--text-faint) }
.cmdk-item { display: flex; align-items: center; gap: var(--sp-3); height: 40px; padding: 0 var(--sp-3); border-radius: var(--r-sm); color: var(--text-secondary); font-size: var(--fs-sm); cursor: pointer;
  --hd: var(--dur-item-out); transition: background-color var(--hd) var(--ease-hover), color var(--hd) var(--ease-hover) }
.cmdk-item > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.cmdk-item .lucide { flex: none; color: var(--text-muted); transition: color var(--hd) var(--ease-hover) }
.cmdk-item mark { background: none; color: var(--text); font-weight: var(--w-semibold) }
.cmdk-item .hint-r { color: var(--text-faint); font-size: var(--fs-xs) }
.cmdk-item .kbd { background: none }
.cmdk-item.active { --hd: 0ms; background: var(--tile); color: var(--text) }
.cmdk-item.active .lucide { color: var(--text) }
.cmdk-empty { display: grid; justify-items: center; gap: var(--sp-1); padding: var(--sp-8) var(--sp-4); color: var(--text-muted); font-size: var(--fs-sm); text-align: center }
.cmdk-empty b { color: var(--text); font-weight: var(--w-medium) }
.cmdk-foot { display: flex; align-items: center; gap: var(--sp-4); height: 40px; padding: 0 var(--sp-4); box-shadow: inset 0 1px 0 var(--border-subtle); color: var(--text-faint); font-size: var(--fs-xs) }
.cmdk-foot span { display: inline-flex; align-items: center; gap: var(--sp-1) }
.cmdk-foot .kbd { height: 18px; min-width: 18px }
@media (max-width: 520px) { .cmdk { top: var(--sp-4) } .cmdk-foot { display: none } }
@media (pointer: coarse) { .cmdk-item { height: 44px } }

/* служебное: первый показ без анимации (js ставит на один кадр); скрытые атрибутом hidden */
.no-anim, .no-anim *, .no-anim *::before, .no-anim *::after { transition: none !important }
:is(.cmdk-item, .cmdk-group, .cmdk-empty, .tst-body span, .tst-foot)[hidden] { display: none }
.pager button.gap { opacity: 1; color: var(--text-faint); cursor: default }
.side.collapsed .side-ws > .lucide { opacity: 0 }
.side-ws > .lucide { transition: opacity var(--dur-enter) var(--ease-out) }

@media (prefers-reduced-motion: reduce) {
  .steps li::after, .step-dot svg path, .pager-plate, .onpage-mark, .side, .side-sub { transition-duration: 0s }
  /* шторки: без выезда — только проявление */
  .sheet-side, .sheet-bottom, .sheet-side[open], .sheet-bottom[open] { transform: none }
  .sheet { opacity: 0; transition-property: opacity, overlay, display }
  .sheet[open] { opacity: 1 }
  @starting-style { .sheet[open] { opacity: 0 } }
}
