/*
 * Clip Studio на ките DeadMoney UI.
 * dm/tokens.css и dm/base.css — копии из deadmoney/packages/ui/src/styles.
 * Ниже — CSS-модули кита, перенесённые в глобальные классы (имена как в модулях), и раскладки панели.
 * Правила кита: цвета только токенами; оранжевый — одно главное действие на экран; янтарный — только деньги
 * (здесь денег нет); выбранное — инверсия; наведение меняет только цвет, геометрия не меняется.
 */

/* ════════════════ кабинет: колонка разделов + основная часть (pages.module.css .dash) ════════════════ */
.dash {
  display: flex;
  min-height: 100vh;
  padding: 10px;
  gap: 14px;
}
.dash-rail {
  flex: 0 0 auto;
  height: calc(100vh - 20px);
  position: sticky;
  top: 10px;
}
.dash-main {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: var(--gap);
}
.dash-body {
  display: grid;
  gap: var(--gap);
  padding: 0 4px 24px;
  min-width: 0;
}
@media (max-width: 1023px) {
  .dash {
    padding: 0 0 96px;
  }
  .dash-rail {
    display: none;
  }
  .dash-body {
    padding: 0 var(--gutter) 24px;
  }
}

/* ── знак (Brand.module.css) ── */
.wordmark {
  font-family: var(--font-logo);
  font-weight: 900;
  font-size: var(--fs-16);
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  color: var(--ink);
}
.wordmark span {
  color: var(--brand);
}
.brand-suffix {
  margin-left: 8px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-12);
  color: var(--ink-muted);
}
.brand-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: var(--tap);
  max-width: var(--tap);
  padding: 0 11px;
  overflow: hidden;
  white-space: nowrap;
  color: var(--ink);
  border-radius: 14px;
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--line);
  transition:
    background-color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}
.brand-pill > svg {
  flex: 0 0 auto;
}
.brand-pill[data-expanded] {
  max-width: 260px;
}
.brand-pill:hover,
.brand-pill:focus-visible {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.brand-pill .wordmark {
  margin-left: 12px;
  opacity: 0;
}
.brand-pill[data-expanded] .wordmark {
  opacity: 1;
}

/* ── колонка разделов (Nav.module.css .rail) ── */
.rail {
  width: var(--rail-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.rail > .brand-pill {
  align-self: flex-start;
}
.rail-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 6px;
  border-radius: 20px;
  background: var(--surface-1);
  box-shadow:
    inset 0 0 0 1px var(--line),
    var(--elev-card);
}
.rail-foot {
  margin-top: auto;
}
.rail-foot form {
  display: contents;
}
.rail-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: 13px;
  font-size: var(--fs-14);
  font-weight: 500;
  text-align: left;
  color: var(--ink-muted);
  transition:
    color var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out);
}
.rail-btn:hover {
  color: var(--ink);
  background: var(--surface-3);
}
.rail-btn[aria-current="page"] {
  color: var(--selected-ink);
  background: var(--selected-bg);
}
.rail-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-count {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  font-size: var(--fs-12);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--on-accent);
  background: var(--accent);
}
.icon-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

/* ── нижняя панель на телефоне (Nav.module.css .tabbar) ── */
.tabbar {
  position: fixed;
  z-index: 60;
  left: 10px;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 22px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  box-shadow:
    inset 0 0 0 1px var(--line-strong),
    var(--shadow-float);
}
@media (min-width: 1024px) {
  .tabbar {
    display: none;
  }
}
.tab {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: var(--tap);
  padding: 7px 2px 6px;
  border-radius: 16px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-muted);
}
.tab[aria-current="page"] {
  color: var(--selected-ink);
  background: var(--selected-bg);
}
.tab-count {
  position: absolute;
  top: -9px;
  right: -11px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 0 0 2.5px var(--surface-1);
}

/* ── верхняя панель (Nav.module.css .top) ── */
.top {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--header-h);
  padding: 0 4px;
}
.top-mark {
  flex: 0 0 auto;
}
@media (min-width: 1024px) {
  .top-mark {
    display: none;
  }
}
@media (max-width: 1023px) {
  .top {
    padding: 0 var(--gutter);
  }
}
.top-title {
  min-width: 0;
  font-size: var(--fs-20);
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-center {
  flex: 1 1 auto;
  min-width: 0;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* переключатель темы: солнце и луна меняются местами поворотом */
.theme-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: 13px;
  color: var(--ink-2);
  background: var(--surface-1);
  box-shadow:
    inset 0 0 0 1px var(--line),
    var(--elev-card);
  overflow: hidden;
  transition:
    color var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out);
}
.theme-toggle:hover {
  color: var(--ink);
  background: var(--surface-2);
}
.theme-toggle .sun,
.theme-toggle .moon {
  position: absolute;
  display: grid;
  transition:
    transform 0.45s var(--ease-out),
    opacity 0.3s var(--ease-out);
}
/* в тёмной теме показываем солнце (куда переключит), в светлой — луну */
:root:not([data-theme="light"]) .theme-toggle .moon,
[data-theme="light"] .theme-toggle .sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

/* ── шапка страницы (Nav.module.css .pageHead) ── */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 16px;
}
.page-title {
  font-size: var(--fs-28);
  line-height: 1.15;
}
.page-sub {
  margin-top: 2px;
  font-size: var(--fs-14);
  color: var(--ink-muted);
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ════════════════ примитивы ════════════════ */

/* ── Button ── */
.btn {
  --h: 44px;
  --px: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--h);
  padding: 0 var(--px);
  border-radius: var(--r-sm);
  font-size: var(--fs-14);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
  user-select: none;
  transition:
    background-color var(--dur) var(--ease-out),
    color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    transform 0.12s var(--ease-out);
}
.btn:active:not(:disabled) {
  transform: scale(0.98);
}
.btn[data-size="sm"] {
  --h: 36px;
  --px: 14px;
}
.btn[data-size="lg"] {
  --h: 52px;
  --px: 24px;
  font-size: var(--fs-16);
  border-radius: var(--r-md);
}
.btn[data-block] {
  width: 100%;
}
.btn[data-variant="primary"] {
  color: var(--on-accent);
  background: var(--accent);
}
.btn[data-variant="primary"]:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn[data-variant="secondary"] {
  color: var(--ink);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn[data-variant="secondary"]:hover:not(:disabled) {
  background: var(--surface-4);
}
.btn[data-variant="ghost"] {
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn[data-variant="ghost"]:hover:not(:disabled) {
  background: var(--surface-2);
}
.btn[data-variant="danger"] {
  color: var(--danger);
  background: var(--danger-soft);
}
.btn[data-variant="danger"]:hover:not(:disabled) {
  color: #fff;
  background: var(--danger-fill);
}
.btn[data-variant="link"] {
  min-height: 0;
  padding: 0;
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline 1px;
  text-decoration-color: var(--ink-faint);
  text-underline-offset: 4px;
}
.btn[data-variant="link"]:hover:not(:disabled) {
  text-decoration-color: var(--ink);
}
.btn[data-variant="link"]:active:not(:disabled) {
  transform: none;
}
.btn:disabled {
  color: var(--ink-faint);
  background: var(--surface-3);
  box-shadow: none;
}
@media (max-width: 520px), (pointer: coarse) {
  .btn[data-size="sm"] {
    --h: var(--tap);
  }
}

/* ── IconButton ── */
.icon-btn {
  --s: 40px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--s);
  height: var(--s);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  transition:
    background-color var(--dur) var(--ease-out),
    color var(--dur) var(--ease-out);
}
.icon-btn[data-size="sm"] {
  --s: 32px;
  border-radius: 10px;
}
.icon-btn[data-variant="secondary"] {
  background: var(--surface-3);
}
.icon-btn[data-variant="secondary"]:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-4);
}
.icon-btn[data-variant="ghost"]:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-3);
}
@media (max-width: 520px), (pointer: coarse) {
  .icon-btn {
    --s: var(--tap);
  }
}

/* ── Card ── */
.card {
  position: relative;
  display: block;
  min-width: 0;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow:
    inset 0 0 0 1px var(--line),
    var(--elev-card);
  color: var(--ink);
  transition:
    background-color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}
.card[data-tone="raised"] {
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: none;
}
.card[data-pad="sm"] {
  padding: 12px;
}
.card[data-pad="md"] {
  padding: var(--pad-card);
}
.card[data-pad="lg"] {
  padding: clamp(18px, 2.4vw, 28px);
}
.card[data-interactive]:hover {
  background: var(--surface-2);
  box-shadow:
    inset 0 0 0 1px var(--line-strong),
    var(--elev-card);
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-titles {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.card-eyebrow {
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-muted);
}
.card-title {
  font-size: var(--fs-16);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

/* ── Badge ── */
.badge {
  --tone: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-12);
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 14%, transparent);
}
.badge[data-tone="neutral"] {
  --tone: var(--ink-2);
  background: var(--surface-3);
}
.badge[data-tone="accent"] { --tone: var(--accent-text); }
.badge[data-tone="success"] { --tone: var(--success); }
.badge[data-tone="danger"] { --tone: var(--danger); }
.badge[data-tone="info"] { --tone: var(--info); }
.badge[data-tone="magenta"] { --tone: var(--magenta); }
.badge[data-tone="cyan"] { --tone: var(--cyan); }
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge-dot[data-pulse] {
  animation: pulse 1.4s var(--ease-in-out) infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

/* ── Chip (вкладки очереди — ссылки; выбранная — инверсия) ── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  font-size: var(--fs-14);
  font-weight: 500;
  white-space: nowrap;
  color: var(--ink-2);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  transition:
    color var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out);
}
.chip:hover:not([aria-current="page"]) {
  color: var(--ink);
  background: var(--surface-3);
}
.chip[aria-current="page"] {
  color: var(--selected-ink);
  background: var(--selected-bg);
  box-shadow: none;
}
.chip-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  font-size: var(--fs-12);
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: var(--surface-4);
}
.chip[aria-current="page"] .chip-count {
  background: color-mix(in srgb, var(--selected-ink) 14%, transparent);
}
@media (max-width: 520px), (pointer: coarse) {
  .chip {
    min-height: var(--tap);
  }
}

/* ── Segmented (радиокнопки внутри подписей) ── */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg[data-block] {
  display: flex;
}
.seg[data-block] > * {
  flex: 1 1 0;
}
.seg > label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 16px;
  border-radius: var(--r-pill);
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--ink-muted);
  white-space: nowrap;
  cursor: pointer;
  transition:
    color var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out);
}
.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.seg > label:hover:not(:has(input:checked)) {
  color: var(--ink);
}
.seg[data-size="sm"] > label {
  min-height: 30px;
  padding: 4px 12px;
  font-size: var(--fs-12);
}
.seg > label:has(input:checked) {
  color: var(--selected-ink);
  background: var(--selected-bg);
}
.seg > label:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
@media (max-width: 520px), (pointer: coarse) {
  .seg > label {
    min-height: var(--tap);
  }
}

/* ── Field ── */
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.field-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.field-label {
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-muted);
  line-height: 1.3;
}
.field-hint {
  font-size: var(--fs-12);
  line-height: 1.45;
  color: var(--ink-muted);
}
.control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition:
    box-shadow var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out);
}
.control:hover {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 28%, transparent);
}
.control:focus-within {
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 55%, transparent);
}
.control[data-multiline] {
  align-items: stretch;
  padding: 10px 14px;
}
.control[data-size="sm"] {
  min-height: 36px;
  padding: 0 12px;
}
.control[data-size="sm"] .input {
  padding: 6px 0;
  font-size: var(--fs-14);
}
.input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  padding: 11px 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}
textarea.input {
  padding: 0;
  resize: vertical;
  min-height: 72px;
}
.input::placeholder {
  color: var(--ink-faint);
}
.affix {
  flex: 0 0 auto;
  color: var(--ink-muted);
  font-size: var(--fs-14);
}

/* ── Select: нативный список в оболочке кнопки Select кита ── */
.select {
  position: relative;
  display: inline-block;
}
.select select {
  appearance: none;
  min-width: 200px;
  height: 40px;
  padding: 0 40px 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease-out);
}
.select select:hover {
  background: var(--surface-2);
}
.select::after {
  content: "";
  position: absolute;
  right: 17px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -6px;
  border-right: 2px solid var(--ink-muted);
  border-bottom: 2px solid var(--ink-muted);
  border-radius: 1px;
  transform: rotate(45deg);
  pointer-events: none;
}
/* во всю ширину поля — как Select кита с block */
.select[data-block] {
  display: block;
}
.select[data-block] select {
  width: 100%;
  min-width: 0;
  height: 46px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.select[data-block] select:hover {
  background: var(--surface-3);
}
.select option {
  color: var(--ink);
  background: var(--surface-2);
}
@media (max-width: 520px), (pointer: coarse) {
  .select select {
    height: var(--tap);
    min-width: 0;
  }
}

/* ── Checkbox ── */
.check {
  position: relative;
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.check-input {
  position: absolute;
  opacity: 0;
  width: 22px;
  height: 22px;
  margin: 0;
  cursor: inherit;
}
.check-box {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 7px;
  color: transparent;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  transition:
    background-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.check:hover .check-box {
  box-shadow: inset 0 0 0 1.5px var(--ink-faint);
}
.check-input:checked + .check-box {
  color: var(--selected-ink);
  background: var(--selected-bg);
  box-shadow: none;
}
.check-input:focus-visible + .check-box {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
.check-input:disabled + .check-box,
.check-input:disabled ~ .check-text {
  opacity: 0.5;
}
.check:has(.check-input:disabled) {
  cursor: not-allowed;
}
.check-text {
  display: grid;
  gap: 2px;
}
.check-label {
  font-size: var(--fs-14);
  font-weight: 500;
  line-height: 1.45;
}
.check-hint {
  font-size: var(--fs-12);
  color: var(--ink-muted);
  line-height: 1.4;
}

/* ── Switch (на чекбоксе) ── */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.switch-input {
  position: absolute;
  opacity: 0;
  width: 36px;
  height: 20px;
  margin: 0;
  cursor: inherit;
}
.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  border-radius: var(--r-pill);
  background: var(--surface-4);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color var(--dur) var(--ease-out);
}
.switch-track::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink-muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition:
    transform var(--dur-slow) var(--ease-out),
    background-color var(--dur) var(--ease-out);
}
.switch-input:checked + .switch-track {
  background: var(--selected-bg);
  box-shadow: none;
}
.switch-input:checked + .switch-track::before {
  transform: translateX(16px);
  background: var(--selected-ink);
}
.switch-input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
.switch-label {
  font-size: var(--fs-14);
  font-weight: 500;
}

/* ── Spinner / EmptyState (Feedback) ── */
.spinner {
  --s: 18px;
  display: inline-block;
  flex: 0 0 auto;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  border: calc(var(--s) / 6) solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: clamp(32px, 5vw, 64px) 16px;
  color: var(--ink-muted);
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  background: var(--surface-3);
}
.empty-title {
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--ink);
}
.empty-text {
  max-width: 46ch;
  font-size: var(--fs-14);
  line-height: 1.5;
}
.empty > :last-child:not(.empty-text):not(.empty-title) {
  margin-top: 6px;
}

/* ── Toast (флеш-сообщения) ── */
.toast-stack {
  position: fixed;
  z-index: 90;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
@media (max-width: 1023px) {
  .toast-stack {
    bottom: calc(96px + env(safe-area-inset-bottom));
  }
}
.toast {
  --tone: var(--info);
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow:
    inset 0 0 0 1px var(--line-strong),
    var(--shadow-float);
  padding: 12px 12px 12px 14px;
  animation: toast-in 0.3s var(--ease-out) both;
  transition: opacity var(--dur-slow) var(--ease-out);
}
.toast[data-tone="success"] {
  --tone: var(--success);
}
.toast[data-tone="error"] {
  --tone: var(--danger);
}
.toast[data-hiding] {
  opacity: 0;
}
.toast-tag {
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--tone);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--tone) 16%, transparent);
}
.toast-text {
  font-size: var(--fs-14);
  line-height: 1.4;
  color: var(--ink);
}
.toast-close {
  display: grid;
  color: var(--ink-muted);
  padding: 3px;
  border-radius: 6px;
}
.toast-close:hover {
  color: var(--ink);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ── Avatar и знак площадки ── */
.avatar {
  --s: 40px;
  position: relative;
  flex: 0 0 auto;
  display: inline-block;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  vertical-align: middle;
}
.avatar img,
.avatar-initial {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.avatar img {
  object-fit: cover;
  background: var(--surface-3);
}
.avatar-initial {
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: calc(var(--s) * 0.42);
  line-height: 1;
  color: var(--selected-ink);
  background: var(--selected-bg);
}
.platform {
  --s: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--s);
  height: var(--s);
  border-radius: calc(var(--s) * 0.3);
  color: #fff;
  background: var(--brand-bg, #555);
}
.platform[data-platform="twitch"] {
  --brand-bg: var(--platform-twitch);
}

/* ── мелочи ── */
[hidden] {
  display: none !important;
}
.muted {
  color: var(--ink-muted);
}
.small {
  font-size: var(--fs-12);
}
.text-link {
  text-decoration: underline 1px;
  text-decoration-color: var(--ink-faint);
  text-underline-offset: 4px;
  transition: text-decoration-color var(--dur) var(--ease-out);
}
.text-link:hover {
  text-decoration-color: var(--ink);
}
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 6px;
  font: 600 var(--fs-12) / 1.5 var(--font-body);
  text-align: center;
  color: var(--ink-2);
  background: var(--surface-3);
  box-shadow: inset 0 -1px 0 var(--line-strong);
}
code {
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.9em;
  background: var(--surface-3);
}
code[data-block] {
  display: block;
  padding: 10px 12px;
  margin: 8px 0;
  word-break: break-all;
  border-radius: var(--r-xs);
}
details > summary {
  cursor: pointer;
  list-style: none;
}
details > summary::-webkit-details-marker {
  display: none;
}

/* ════════════════ экраны панели ════════════════ */

/* ── очередь ── */
.queue-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.hint-line {
  font-size: var(--fs-14);
  color: var(--ink-muted);
}
.hint-line kbd {
  margin: 0 2px;
}
.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
}
.clip-card {
  display: flex;
  flex-direction: column;
  padding: 8px;
  transition:
    background-color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    opacity var(--dur-slow) var(--ease-out);
}
.clip-card[data-gone] {
  opacity: 0;
}
/* ссылка на всю карточку; кнопки поверх неё */
.clip-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.clip-card .icon-btn,
.clip-card .over {
  position: relative;
  z-index: 2;
}
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--surface-3);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-tag {
  position: absolute;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-12);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: rgba(0, 0, 0, 0.66);
}
.thumb-tag[data-at="left"] {
  left: 8px;
}
.thumb-tag[data-at="right"] {
  right: 8px;
}
/* момент из чата: вместо превью — что писал чат */
.thumb-chat {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 36px 14px 34px;
  background:
    radial-gradient(90% 70% at 50% 110%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    var(--surface-3);
}
.thumb-chat span {
  justify-self: start;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-samples {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chat-samples li {
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-14);
  background: var(--surface-2);
}
.thumb-tag[data-at="top"] {
  top: 8px;
  left: 8px;
  bottom: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.clip-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 4px 8px;
  align-items: start;
  padding: 10px 6px 4px;
}
.clip-title {
  font-size: var(--fs-14);
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clip-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: var(--fs-12);
  color: var(--ink-muted);
}
.clip-meta b {
  font-weight: 600;
  color: var(--ink-2);
}
.clip-error {
  grid-column: 1 / -1;
  font-size: var(--fs-12);
  color: var(--danger);
}

/* ── страница клипа ── */
.clip-page {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
  align-items: start;
  gap: var(--gap);
}
.clip-side {
  display: grid;
  gap: var(--gap);
  min-width: 0;
}
.clip-head {
  display: grid;
  gap: 10px;
}
.clip-head .page-title {
  text-wrap: balance;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: var(--fs-14);
  color: var(--ink-muted);
}
.streamer-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink);
}
.embed {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--r-md);
  background: #000;
}
.embed video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}
.embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.vertical-player {
  display: flex;
  justify-content: center;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.vertical-player video {
  height: min(76vh, 820px);
  aspect-ratio: 9 / 16;
  border-radius: var(--r-sm);
  background: #000;
}
.player-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 4px 0;
  font-size: var(--fs-14);
}
.original[open] .embed {
  margin-top: 10px;
}
.status-line {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.status-line p {
  margin-top: 4px;
  font-size: var(--fs-14);
  color: var(--ink-muted);
}
.status-title {
  font-weight: 600;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.stack {
  display: grid;
  gap: 16px;
}
.error-text {
  margin: 0;
  padding: 10px 12px;
  max-height: 220px;
  overflow: auto;
  border-radius: var(--r-xs);
  font: 12px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--danger);
  background: var(--danger-soft);
}
.edit-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--fs-16);
  font-weight: 600;
}
.edit-summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin: -4px 4px 0 0;
  border-right: 2px solid var(--ink-muted);
  border-bottom: 2px solid var(--ink-muted);
  border-radius: 1px;
  transform: rotate(45deg);
  transition: transform var(--dur) var(--ease-out);
}
details[open] > .edit-summary {
  margin-bottom: 16px;
}
details[open] > .edit-summary::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}
.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.checks {
  display: grid;
  gap: 12px;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}
/* главное действие — во всю ширину, второстепенные — парой под ним */
.form-actions > * {
  flex: 1 1 0;
}
.form-actions > :first-child {
  flex-basis: 100%;
}

/* ── выделение вебки ── */
.rect-editor {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}
.rect-editor img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}
.rect-editor .rect {
  position: absolute;
  border-radius: 6px;
  box-shadow:
    0 0 0 2px var(--selected-bg),
    0 0 0 9999px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* ── стримеры ── */
.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 12px;
}
.streamer-list {
  display: grid;
  gap: var(--gap);
}
.streamer-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) auto auto auto;
  align-items: center;
  gap: 12px 20px;
}
.streamer-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.streamer-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.streamer-stats {
  margin-top: 2px;
  font-size: var(--fs-12);
  color: var(--ink-muted);
}
.streamer-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}
.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-14);
  color: var(--ink-muted);
}
.inline-field .control {
  width: 96px;
}
.facecam-details > summary {
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--ink-2);
}
.facecam-details > summary:hover {
  color: var(--ink);
}
.facecam-details[open] {
  grid-column: 1 / -1;
  order: 5;
}
.facecam-details .rect-editor {
  max-width: 520px;
  margin: 10px 0;
}
.streamer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* ── форма монтажа: лого и превью ── */
.logo-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}
.logo-picker .seg {
  justify-self: start;
}
.logo-phone {
  position: relative;
  width: 108px;
  aspect-ratio: 9 / 16;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.logo-spot {
  position: absolute;
  display: grid;
  place-items: center;
  width: 30px;
  height: 22px;
  transform: translate(-50%, -50%);
  cursor: pointer;
}
.logo-spot input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.logo-spot span {
  width: 22px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  transition: background 0.15s;
}
.logo-spot:hover span {
  background: var(--ink-muted);
}
.logo-spot:has(input:checked) span {
  width: 26px;
  height: 10px;
  background: var(--selected-bg);
  box-shadow: 0 0 0 2px var(--selected-ink);
}
.logo-spot:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
.logo-spot[data-at="top-left"] { left: 24%; top: 12%; }
.logo-spot[data-at="top"] { left: 50%; top: 12%; }
.logo-spot[data-at="top-right"] { left: 76%; top: 12%; }
.logo-spot[data-at="center"] { left: 50%; top: 50%; }
.logo-spot[data-at="bottom-left"] { left: 24%; top: 76%; }
.logo-spot[data-at="bottom"] { left: 50%; top: 76%; }
.preview-frame {
  display: block;
  width: min(260px, 100%);
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: var(--r-md);
  background: #000;
}

/* ── YouTube ── */
.section-title {
  margin: 8px 0 -2px;
  font-size: var(--fs-20);
  font-weight: 600;
}
.meter {
  height: 8px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--surface-3);
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
}
.plain-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-14);
}
.plain-list li {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.plain-list li > a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plain-list .muted,
.plain-list .danger-text {
  font-size: var(--fs-12);
}
.danger-text {
  color: var(--danger);
}
.chapters {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 14px;
  margin: 0;
  font-size: var(--fs-14);
}
.chapters dt {
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}
.chapters dd {
  margin: 0;
  min-width: 0;
}
.thumb-preview {
  display: block;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--r-sm);
}

/* ── настройки ── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: var(--gap);
  align-items: start;
}
.kv {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0 0 16px;
  font-size: var(--fs-14);
}
.kv dt {
  color: var(--ink-muted);
}
.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ── вход ── */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}
.login-card {
  display: grid;
  gap: 18px;
  width: min(380px, 100%);
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink);
}
.login-brand .wordmark {
  font-size: var(--fs-20);
}
.login-sub {
  margin-top: -8px;
  text-align: center;
  font-size: var(--fs-14);
  color: var(--ink-muted);
}
.login-error {
  font-size: var(--fs-14);
  color: var(--danger);
  text-align: center;
}

/* ── адаптив ── */
@media (max-width: 1180px) {
  .clip-page {
    grid-template-columns: minmax(0, 1fr);
  }
  .vertical-player video {
    height: 70vh;
  }
}
@media (max-width: 900px) {
  .streamer-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .streamer-actions {
    justify-content: flex-start;
  }
}
@media (max-width: 640px) {
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
  .kv dd {
    margin-bottom: 10px;
  }
  .add-row,
  .two {
    grid-template-columns: minmax(0, 1fr);
  }
  .select,
  .select select {
    width: 100%;
  }
}
