/* ============================================================================
   admin.css — дизайн-система админки Кадрума (Jinja2 + HTMX, без сборки).

   Оглавление
    1. Токены (:root) и тёмная тема
    2. Reset / база / типографика
    3. Лейаут: .container, .topbar, #progress, .page-head
    4. Карточки: .card, .stat-card, .chip, .attention
    5. Кнопки: .btn*
    6. Поля форм: .input/.select/.textarea, .field, .char-count, .grid-*, .toggle, .checkbox
    7. Бейджи: .badge*, статусы
    8. Таблицы: .table-wrap, .table, строки, .thumb-strip, .row-actions
    9. Фильтры, .list-meta, .pagination, .bulk-bar
   10. Форма: .form-layout, .form-aside, .section, .save-bar
   11. Медиа: .slot*, .slot-grid, .preview-list, sortable, .app-card
   12. Комбобокс
   13. Рубрики, типы персон
   14. Тосты, спиннер, HTMX-индикаторы, empty-state
   15. Логин, страница ошибки
   16. Утилиты
   ========================================================================== */

/* 1. Токены ---------------------------------------------------------------- */
:root {
  color-scheme: light dark; /* нативные скроллбары/селекты следуют теме */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-s: 12px;
  --fs: 13px;
  --fs-l: 15px;
  --header-h: 52px;
  --radius-s: 4px;
  --radius: 6px;
  --radius-l: 10px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-2: 0 4px 16px rgba(15, 23, 42, .12), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-up: 0 -4px 16px rgba(15, 23, 42, .10);

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e6e9ee;
  --border: #dfe3e8;
  --border-strong: #c3c9d2;
  --text: #1c2430;
  --text-muted: #6b7684;
  --text-faint: #9aa3af;
  --on-primary: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #e6eefc;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fdecec;
  --success: #16a34a;
  --success-soft: #e5f7ea;
  --warning: #d97706;
  --warning-soft: #fdf3e0;
  --info: #0284c7;
  --info-soft: #e3f2fb;
  --hl: #fff3b0;
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, .25);

  /* Статусы промтов: 1 тест, 2 опубликован, 3 отключен, 4 генерация, 5 «хуета», 6 резерв, 7 архив */
  --st-p1: #b45309;
  --st-p2: #15803d;
  --st-p3: #6b7280;
  --st-p4: #1d4ed8;
  --st-p5: #b91c1c;
  --st-p6: #6d28d9;
  --st-p7: #475569;
  /* Статусы видео: 1 тест, 2 опубликован, 3 временно отключен, 4 «хуета» */
  --st-v1: #b45309;
  --st-v2: #15803d;
  --st-v3: #6b7280;
  --st-v4: #b91c1c;
  --st-special: #7c3aed;
  --st-ultra: #a16207;
  --st-dry: #0f766e;
  --st-muted: #6b7684;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --surface: #1c2129;
    --surface-2: #232a34;
    --surface-3: #2c3541;
    --border: #2f3843;
    --border-strong: #46515f;
    --text: #e6e9ee;
    --text-muted: #98a2b3;
    --text-faint: #6b7684;
    --primary: #4f8cff;
    --primary-hover: #6d9fff;
    --primary-soft: #1e2d4d;
    --danger: #f06565;
    --danger-hover: #ff7d7d;
    --danger-soft: #3a2124;
    --success: #3fbf6a;
    --success-soft: #1d3327;
    --warning: #f0a33a;
    --warning-soft: #3b2f18;
    --info: #3fb0e6;
    --info-soft: #17303d;
    --hl: #4a4116;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 6px 20px rgba(0, 0, 0, .5);
    --shadow-up: 0 -4px 16px rgba(0, 0, 0, .45);
    --focus-ring: 0 0 0 3px rgba(79, 140, 255, .35);
    --st-p1: #fbbf24; --st-p2: #4ade80; --st-p3: #9ca3af; --st-p4: #60a5fa;
    --st-p5: #f87171; --st-p6: #a78bfa; --st-p7: #94a3b8;
    --st-v1: #fbbf24; --st-v2: #4ade80; --st-v3: #9ca3af; --st-v4: #f87171;
    --st-special: #a78bfa; --st-ultra: #facc15; --st-dry: #2dd4bf; --st-muted: #98a2b3;
  }
}

/* 2. Reset / база ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 var(--fs)/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  min-width: 1024px;
}
h1, h2, h3, h4 { margin: 0 0 var(--sp-3); font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 var(--sp-3); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
small { font-size: var(--fs-s); }
ul, ol { margin: 0; padding: 0; }
table { border-collapse: collapse; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; display: inline-block; }
.icon-spin { transform-origin: 8px 8px; animation: spin .8s linear infinite; }
.inline-form { display: inline; margin: 0; }

/* 3. Лейаут ---------------------------------------------------------------- */
.container { max-width: 1600px; margin: 0 auto; padding: 16px 24px 96px; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 600; color: var(--text); white-space: nowrap; }
.topbar-brand:hover { text-decoration: none; }
.topbar-brand img { color: var(--primary); }
.topbar-nav { display: flex; gap: var(--sp-1); margin-left: var(--sp-3); }
.topbar-nav a { padding: 6px 10px; border-radius: var(--radius); color: var(--text-muted); font-weight: 500; }
.topbar-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topbar-nav a.active { color: var(--primary); background: var(--primary-soft); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); white-space: nowrap; }
.topbar-user-name { font-weight: 500; }
.topbar-user-roles { font-size: var(--fs-s); }

#progress { position: fixed; top: var(--header-h); left: 0; right: 0; height: 2px; z-index: 60; pointer-events: none; }
#progress::before {
  content: ""; display: block; height: 100%; width: 0; background: var(--primary);
  opacity: 0; transition: width .3s, opacity .4s;
}
#progress.is-active::before { opacity: 1; animation: progress 1.6s ease-out forwards; }
@keyframes progress { 0% { width: 0; } 60% { width: 70%; } 100% { width: 90%; } }

.page-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.page-title { margin: 0; display: flex; align-items: center; gap: var(--sp-2); }
.page-actions { margin-left: auto; display: flex; gap: var(--sp-2); }

/* 4. Карточки -------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: var(--sp-4); }
.card-title { font-size: 14px; margin-bottom: var(--sp-3); }
.stats-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.stat-card-label { font-size: var(--fs-s); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.stat-card-label a { color: inherit; }
.stat-card-value { font-size: 32px; font-weight: 700; line-height: 1.2; margin: var(--sp-1) 0 var(--sp-3); }
.stat-card-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: var(--fs-s); line-height: 1.3;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid transparent; white-space: nowrap;
}
.chip b { font-weight: 600; }
.chip:hover { text-decoration: none; border-color: var(--border-strong); }
.chip[data-status] { color: var(--st); background: color-mix(in srgb, var(--st) 13%, var(--surface)); }

.attention-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-2); }
.attention-list a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: 8px 12px; border-radius: var(--radius); background: var(--warning-soft); color: var(--text);
}
.attention-list a:hover { text-decoration: none; filter: brightness(.97); }
.attention-count { color: var(--warning); font-weight: 700; }

/* 5. Кнопки ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: var(--fs); line-height: 1; white-space: nowrap; cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
  user-select: none;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--surface); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-s); }
.btn-icon { width: 30px; height: 30px; padding: 0; border-color: transparent; background: transparent; color: var(--text-muted); border-radius: var(--radius); }
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon.btn-danger:hover { color: var(--danger); background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.htmx-request { opacity: .65; pointer-events: none; }
.btn .spinner { display: none; }
.btn.htmx-request .spinner { display: inline-block; }

/* 6. Поля форм ------------------------------------------------------------- */
.input, .select, .textarea {
  display: block; width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 68px; padding: 7px 10px; resize: vertical; line-height: 1.45; }
.textarea[data-autogrow] { overflow-y: hidden; resize: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: var(--focus-ring); outline: none; }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select-sm, .input-sm { height: 28px; font-size: var(--fs-s); padding: 0 8px; }
.select-sm { padding-right: 24px; background-position: calc(100% - 13px) 11px, calc(100% - 8px) 11px; }
.input-auto { width: auto; }

.field { display: block; margin-bottom: var(--sp-4); }
.field-label, .field > label { display: block; font-weight: 500; margin-bottom: 5px; }
.field-label .req, .field-label .muted { font-weight: 400; }
.field-hint { margin-top: 4px; font-size: var(--fs-s); color: var(--text-muted); }
.field-err { margin-top: 4px; font-size: var(--fs-s); color: var(--danger); }
.field--error .input, .field--error .select, .field--error .textarea { border-color: var(--danger); }
.field--error .input:focus, .field--error .textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.field-row { display: flex; align-items: center; gap: var(--sp-2); }
.field-row .input, .field-row .select { width: auto; flex: 1; }
.form-error { padding: 8px 12px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-size: var(--fs); }

.char-count { float: right; font-size: var(--fs-s); color: var(--text-faint); font-variant-numeric: tabular-nums; margin-top: -2px; }
.char-count.is-warn { color: var(--warning); }
.char-count.is-over { color: var(--danger); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 var(--sp-4); }

/* Тумблер: <label class="toggle"><input type="checkbox"><span class="toggle-track"></span><span>Текст</span></label> */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; vertical-align: middle; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: relative; flex: none; width: 32px; height: 18px; border-radius: 999px;
  background: var(--border-strong); transition: background .15s;
}
.toggle-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s;
}
.toggle input:checked + .toggle-track { background: var(--success); }
.toggle input:checked + .toggle-track::after { transform: translateX(14px); }
.toggle input:focus-visible + .toggle-track { box-shadow: var(--focus-ring); }
.toggle input:disabled + .toggle-track { opacity: .45; cursor: not-allowed; }
.toggle input:disabled ~ * { cursor: not-allowed; }
.toggle.htmx-request { opacity: .6; pointer-events: none; }
.toggle-label { font-size: var(--fs-s); color: var(--text-muted); }
.toggle-group { display: flex; flex-direction: column; gap: 6px; }

.checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.checkbox input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); cursor: pointer; }

/* 7. Бейджи ---------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: var(--radius-s); font-size: 11px; font-weight: 600; line-height: 1.35;
  white-space: nowrap; vertical-align: middle;
  color: var(--st, var(--text-muted)); background: color-mix(in srgb, var(--st, var(--text-muted)) 13%, var(--surface));
}
.badge--instance { text-transform: uppercase; letter-spacing: .06em; --st: var(--primary); }
.badge--p1, [data-status="p1"] { --st: var(--st-p1); }
.badge--p2, [data-status="p2"] { --st: var(--st-p2); }
.badge--p3, [data-status="p3"] { --st: var(--st-p3); }
.badge--p4, [data-status="p4"] { --st: var(--st-p4); }
.badge--p5, [data-status="p5"] { --st: var(--st-p5); }
.badge--p6, [data-status="p6"] { --st: var(--st-p6); }
.badge--p7, [data-status="p7"] { --st: var(--st-p7); }
.badge--v1, [data-status="v1"] { --st: var(--st-v1); }
.badge--v2, [data-status="v2"] { --st: var(--st-v2); }
.badge--v3, [data-status="v3"] { --st: var(--st-v3); }
.badge--v4, [data-status="v4"] { --st: var(--st-v4); }
.badge--special { --st: var(--st-special); }
.badge--ultra { --st: var(--st-ultra); }
.badge--dry { --st: var(--st-dry); }
.badge--muted { --st: var(--st-muted); }
.badge--danger { --st: var(--danger); }
.badge--success { --st: var(--success); }
.badge--info { --st: var(--info); }

/* 8. Таблицы --------------------------------------------------------------- */
/* Липкий thead работает, пока .table-wrap не является scroll-контейнером; ниже 1240px
   включаем горизонтальную прокрутку (и теряем липкость) — см. media ниже. */
.table-wrap { overflow: visible; }
@media (max-width: 1240px) { .table-wrap { overflow-x: auto; } }
.table { width: 100%; table-layout: fixed; min-width: 1180px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table th {
  position: sticky; top: var(--header-h); z-index: 5;
  background: var(--surface-2); font-weight: 600; font-size: var(--fs-s); color: var(--text-muted);
  white-space: nowrap; vertical-align: middle;
}
.table thead th:first-child { border-top-left-radius: var(--radius-l); }
.table thead th:last-child { border-top-right-radius: var(--radius-l); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.table th a.sort { color: inherit; display: inline-flex; align-items: center; gap: 3px; }
.table th a.sort:hover { color: var(--text); text-decoration: none; }
.table th a.sort::after { content: "↕"; opacity: .35; font-size: 10px; }
.table th a.sort.asc::after { content: "↑"; opacity: 1; color: var(--primary); }
.table th a.sort.desc::after { content: "↓"; opacity: 1; color: var(--primary); }
.table th.col-check, .table td.col-check { width: 32px; padding-right: 0; }
.table td.cell-id { white-space: nowrap; }
.table td.cell-id .muted { display: block; font-size: var(--fs-s); }
.table td.cell-status { width: 190px; }
.table td.cell-status .select { margin-bottom: 6px; }
.table td.cell-status[data-status] .select { border-left: 3px solid var(--st); }
.table td.cell-name b { font-weight: 600; }
.table .clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.table .name-en { font-style: italic; color: var(--text-muted); }
.table tr.row--muted td { opacity: .55; }
.table tr.row-hl > td { animation: row-hl 3s ease-out forwards; }
.table tr.row-saved > td { animation: row-saved 1s ease-out; }
@keyframes row-hl { 0%, 40% { background: var(--hl); } 100% { background: transparent; } }
@keyframes row-saved { 0% { background: var(--success-soft); } 100% { background: transparent; } }

.dots { display: inline-flex; gap: 3px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.dots i.on { background: var(--success); }

.thumb-strip { display: grid; grid-template-columns: repeat(4, 44px); gap: 3px; }
.thumb-slot { width: 44px; height: 51px; border-radius: 3px; overflow: hidden; background: var(--surface-2); position: relative; }
.thumb-slot img { width: 100%; height: 100%; object-fit: cover; }
.thumb-slot--empty { border: 1px dashed var(--border-strong); background: transparent; display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--text-faint); text-align: center; line-height: 1.1; padding: 2px; }
.thumb-slot--ref { border-color: var(--primary); }
.thumb { border-radius: var(--radius-s); overflow: hidden; background: var(--surface-2); }
.thumb img { object-fit: cover; width: 100%; height: 100%; }
.thumb-poster { width: 72px; height: 84px; }

.row-actions { display: flex; gap: 2px; opacity: .55; transition: opacity .12s; }
.table tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }

/* 9. Фильтры, пагинация, bulk-bar ------------------------------------------ */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.filters .input, .filters .select { width: auto; }
.filters .select { min-width: 140px; max-width: 220px; }
.filters-search { width: 260px !important; }
.filters-sep { width: 1px; height: 24px; background: var(--border); margin: 0 var(--sp-1); }
.filters-reset { color: var(--text-muted); }
.chip-toggle { display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; height: 28px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--fs-s); cursor: pointer; user-select: none; white-space: nowrap; }
.chip-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-toggle:hover { background: var(--surface-2); }
.chip-toggle:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip-toggle:has(input:focus-visible) { box-shadow: var(--focus-ring); }

.list-meta { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-muted); font-size: var(--fs-s); margin: var(--sp-2) 0; }
.pagination { display: flex; align-items: center; gap: var(--sp-1); margin-top: var(--sp-3); flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 30px; height: 30px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius); color: var(--text-muted); }
.pagination a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.pagination .is-current { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.pagination .is-disabled { opacity: .4; pointer-events: none; }
.pagination .per-page { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); font-size: var(--fs-s); }
.pagination .per-page .select { width: auto; }

.bulk-bar {
  position: fixed; left: 50%; bottom: 20px; z-index: 40;
  transform: translate(-50%, 140%); transition: transform .2s ease;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px 14px; border-radius: var(--radius-l);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2);
}
.bulk-bar.is-visible { transform: translate(-50%, 0); }
.bulk-bar .bulk-count { font-weight: 600; margin-right: var(--sp-2); white-space: nowrap; }
.bulk-bar .select { width: auto; }
.bulk-bar .filters-sep { margin: 0 var(--sp-2); }

/* 10. Форма ---------------------------------------------------------------- */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-5); align-items: start; }
@media (max-width: 1400px) { .form-layout { grid-template-columns: minmax(0, 1fr); } .form-aside { position: static; } }
.form-aside { position: sticky; top: calc(var(--header-h) + 16px); display: flex; flex-direction: column; gap: var(--sp-4); }
.toc { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.toc a { display: block; padding: 5px 10px; border-radius: var(--radius); color: var(--text-muted); }
.toc a:hover, .toc a.active { background: var(--surface-2); color: var(--text); text-decoration: none; }
.toc a.has-error { color: var(--danger); }

fieldset.section { border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); padding: var(--sp-3) var(--sp-4) var(--sp-2); margin: 0 0 var(--sp-4); min-width: 0; }
fieldset.section > legend { padding: 0 6px; font-weight: 600; font-size: var(--fs-l); }
fieldset.section:disabled { opacity: .6; }
.section-hint { color: var(--text-muted); font-size: var(--fs-s); margin: -4px 0 var(--sp-3); }

.save-bar {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--sp-2);
  margin: var(--sp-4) -4px 0; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l);
  box-shadow: var(--shadow-up);
}
.save-bar .save-status, .save-bar .dirty-note { font-size: var(--fs-s); color: var(--text-muted); margin-left: var(--sp-2); display: none; align-items: center; gap: 6px; }
.save-bar.htmx-request .save-status { display: inline-flex; }
.save-bar.htmx-request .dirty-note { display: none; }
.save-bar.is-dirty .dirty-note { display: inline-flex; color: var(--warning); }
.save-bar .save-right { margin-left: auto; display: flex; gap: var(--sp-2); }

#model-hint { font-size: var(--fs-s); color: var(--text-muted); margin-top: 4px; }
#model-hint.is-over { color: var(--danger); font-weight: 600; }

/* 11. Медиа ---------------------------------------------------------------- */
.slot {
  position: relative; width: 100%; aspect-ratio: 6 / 7; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border); overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.slot img, .slot video { width: 100%; height: 100%; object-fit: cover; }
.slot-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 2px dashed var(--border-strong); border-radius: inherit; color: var(--text-faint); font-size: var(--fs-s); text-align: center; padding: 8px; cursor: pointer;
}
.slot-empty .icon { width: 22px; height: 22px; opacity: .6; }
.slot--over { border-color: var(--primary); box-shadow: var(--focus-ring); }
.slot--over .slot-empty { border-color: var(--primary); color: var(--primary); }
.slot--error { border-color: var(--danger); }
.slot--filled .slot-empty { display: none; }
.slot input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.slot--filled input[type="file"] { pointer-events: none; }
.slot-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0, 0, 0, .15); display: none; }
.slot.htmx-request .slot-progress, .slot:has(.htmx-request) .slot-progress { display: block; }
.slot-progress i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .15s; }
.slot-actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s;
}
.slot-actions .btn { height: 26px; padding: 0 8px; font-size: var(--fs-s); background: rgba(255, 255, 255, .92); color: #1c2430; border-color: transparent; box-shadow: var(--shadow-1); }
.slot-actions .btn:hover { background: #fff; }
.slot:hover .slot-actions, .slot:focus-within .slot-actions { opacity: 1; }
.slot-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: var(--fs-s); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent); pointer-events: none;
}
.slot:not(.slot--filled) .slot-label { color: var(--text-muted); text-shadow: none; background: none; text-align: center; }
.slot-err { font-size: var(--fs-s); color: var(--danger); margin-top: 4px; }
.slot-wrap { display: flex; flex-direction: column; gap: 4px; }
.slot-wrap .slot-caption { font-size: var(--fs-s); color: var(--text-muted); text-align: center; }
.slot-grid { display: grid; grid-template-columns: repeat(4, 150px); gap: var(--sp-3); }
.slot-grid .slot { width: 150px; }
.slot--video { aspect-ratio: 9 / 16; }
.slot--square { aspect-ratio: 1; }

.preview-list { list-style: none; display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.preview-list li { width: 120px; position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.preview-list video { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; background: #000; }
.preview-list .drag { position: absolute; top: 4px; left: 4px; }
.preview-actions { display: flex; justify-content: space-between; align-items: center; padding: 4px; gap: 4px; background: var(--surface); }
.preview-actions .btn { height: 24px; padding: 0 6px; font-size: 11px; }
.preview-index { position: absolute; top: 4px; right: 6px; font-size: 11px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .7); }
.drag { cursor: grab; color: var(--text-faint); display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: var(--radius-s); flex: none; touch-action: none; }
.drag:hover { color: var(--text); background: var(--surface-3); }
.drag:active { cursor: grabbing; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: var(--shadow-2); }
.sortable-drag { opacity: .9; }

.app-card {
  position: relative; width: 300px; height: 350px; border-radius: 14px; overflow: hidden;
  background: var(--surface-3); box-shadow: var(--shadow-1); flex: none;
}
.app-card-blur, .app-card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.app-card-blur { filter: blur(6px); transform: scale(1.06); }
.app-card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 55%; background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, 0)); pointer-events: none; }
.app-card-title { position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 2; color: #fff; font-size: 18px; font-weight: 700; line-height: 1.2; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.app-card-badges { position: absolute; top: 10px; left: 10px; z-index: 2; display: flex; gap: 4px; }
.app-card-badges .badge { background: rgba(255, 255, 255, .92); }
.app-card-badges .badge--ultra { color: #fff; background: linear-gradient(135deg, #f59e0b, #d946ef); }
.app-card-badges .badge--new { color: #fff; background: var(--primary); }
.app-card-toolbar { display: flex; gap: var(--sp-1); margin-top: var(--sp-2); flex-wrap: wrap; }
.app-card-toolbar .chip-toggle { height: 24px; }

/* 12. Комбобокс ------------------------------------------------------------ */
.combobox { position: relative; }
.combobox .input { padding-right: 30px; }
.combobox-clear { position: absolute; right: 4px; top: 4px; width: 26px; height: 26px; border: 0; background: transparent; color: var(--text-faint); border-radius: var(--radius-s); display: none; align-items: center; justify-content: center; }
.combobox.has-value .combobox-clear { display: inline-flex; }
.combobox-clear:hover { color: var(--text); background: var(--surface-3); }
.combobox-list {
  position: absolute; z-index: 45; left: 0; right: 0; top: calc(100% + 4px);
  display: none; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-2);
}
.combobox.is-open .combobox-list:not(:empty) { display: block; }
.combobox-option { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; }
.combobox-option:hover, .combobox-option.is-active { background: var(--primary-soft); }
.combobox-option img { width: 24px; height: 28px; object-fit: cover; border-radius: 3px; flex: none; background: var(--surface-2); }
.combobox-option .opt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combobox-option .opt-meta { font-size: var(--fs-s); color: var(--text-muted); white-space: nowrap; }
.combobox-empty { padding: 8px 10px; color: var(--text-muted); font-size: var(--fs-s); }
.combobox-link { margin-left: 6px; font-size: var(--fs-s); }

/* 13. Рубрики, типы персон ------------------------------------------------- */
.rubric-list { list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); }
.rubric-list li.rubric { display: flex; align-items: center; gap: var(--sp-3); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.rubric-list li.rubric:last-child { border-bottom: 0; }
.rubric-list li.rubric.row-saved { animation: row-saved 1s ease-out; }
.rubric--off { opacity: .55; }
.rubric--off .rubric-name { text-decoration: line-through; text-decoration-color: var(--text-faint); }
.rubric-name { flex: 1; min-width: 0; font-weight: 500; }
.rubric-name small { display: block; color: var(--text-muted); font-weight: 400; font-style: italic; }
.rubric-count { font-family: var(--mono); font-size: var(--fs-s); color: var(--text-muted); white-space: nowrap; min-width: 80px; text-align: right; }
.rubric-count a { color: inherit; }
.rubric-ratio { font-size: var(--fs-s); color: var(--text-muted); min-width: 40px; }
.rubric-edit { display: grid; grid-template-columns: 1fr 1fr 110px 150px auto auto; gap: var(--sp-2); align-items: center; flex: 1; }
.rubric-edit .input, .rubric-edit .select { height: 30px; }

/* Экран /rubrics (pages/rubrics/*): шапка колонок, ширины ячеек, инлайн-форма. Ширины ячеек общие для .rubric-head и li.rubric. */
.page-count { font-size: 15px; font-weight: 400; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.page-hint { margin: 0; font-size: var(--fs-s); color: var(--text-muted); }
.rubric-head {
  position: sticky; top: var(--header-h); z-index: 5;
  display: flex; align-items: center; gap: var(--sp-3); padding: 6px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-l) var(--radius-l) 0 0;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); white-space: nowrap;
}
.rubric-head + .rubric-list { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.rubric-head .rubric-name, .rubric-head .rubric-ratio, .rubric-head .rubric-counts { font: inherit; color: inherit; }
.rubric-head-drag { width: 22px; flex: none; }
.rubric-special { width: 112px; flex: none; }
.rubric-ratio { width: 48px; flex: none; font-variant-numeric: tabular-nums; }
.rubric-counts { width: 96px; flex: none; display: inline-flex; justify-content: flex-end; gap: 4px; font-family: var(--mono); font-size: var(--fs-s); white-space: nowrap; }
.rubric-counts .rubric-count { min-width: 0; }
.rubric-counts .rubric-count:first-child { color: var(--text); font-weight: 600; }
.rubric-counts a:hover { color: var(--primary); text-decoration: none; }
.rubric-video { width: 72px; flex: none; }
.rubric-video a.badge:hover { text-decoration: none; filter: brightness(.95); }
.rubric-list .toggle { width: 32px; flex: none; }
.rubric-toggle { width: 32px; flex: none; text-align: center; }
.rubric-actions { width: 62px; flex: none; display: flex; gap: 2px; opacity: .55; transition: opacity .12s; }
.rubric-list li.rubric:hover .rubric-actions, .rubric-actions:focus-within { opacity: 1; }
.rubric-list .btn:disabled { pointer-events: auto; } /* иначе title «Нет прав» не всплывает */
.rubric-list li.rubric--off { opacity: 1; } /* гасим только данные: тумблер и кнопки остаются контрастными */
.rubric--off .rubric-name, .rubric--off .rubric-special, .rubric--off .rubric-ratio, .rubric--off .rubric-counts, .rubric--off .rubric-video { opacity: .55; }
.rubric-list .rubric-empty { display: block; }
.rubric-list .rubric-empty .empty-state { border: 0; background: transparent; }
.rubric-list li.rubric ~ li.rubric-empty { display: none; }
/* инлайн-форма (_item_edit.html) */
.rubric-list li.rubric--edit { background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); align-items: flex-start; }
.rubric-list li.rubric--edit .drag { margin-top: 21px; }
form.rubric-edit { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 96px 150px auto auto; gap: var(--sp-2) var(--sp-3); align-items: start; margin: 0; }
.rubric-field { display: block; margin: 0; min-width: 0; }
.rubric-field-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; white-space: nowrap; }
.rubric-field-label .req { color: var(--danger); }
.rubric-field .field-err { margin-top: 3px; }
.rubric-edit .rubric-field-toggle { height: 30px; margin-top: 18px; width: auto; }
.rubric-edit .rubric-edit-actions { display: flex; gap: var(--sp-1); margin-top: 18px; }
.rubric-edit .rubric-edit-actions .btn { height: 30px; }

.person-grid { display: grid; grid-template-columns: repeat(auto-fill, 220px); gap: var(--sp-4); }
.person-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); overflow: hidden; }
.person-card .person-photo { width: 220px; height: 220px; background: var(--surface-2); }
.person-card .person-photo img { width: 100%; height: 100%; object-fit: cover; }
.person-card .person-body { padding: var(--sp-3); }
.person-card .person-name { font-weight: 600; }
.person-card .person-many { color: var(--text-muted); }
.person-card .person-id { font-size: var(--fs-s); color: var(--text-faint); font-family: var(--mono); }
.person-card .person-actions { display: flex; gap: var(--sp-1); margin-top: var(--sp-2); }
.person-card.row-saved { animation: row-saved 1s ease-out; }

/* 14. Тосты, спиннер, HTMX ------------------------------------------------- */
.toasts { position: fixed; top: calc(var(--header-h) + 12px); right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: 360px; max-width: calc(100vw - 32px); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--info); box-shadow: var(--shadow-2);
  font-size: var(--fs); line-height: 1.4; pointer-events: auto; word-break: break-word;
  animation: toast-in .2s ease-out;
}
.toast[data-kind="success"] { border-left-color: var(--success); }
.toast[data-kind="error"] { border-left-color: var(--danger); }
.toast[data-kind="info"] { border-left-color: var(--info); }
.toast.is-hiding { animation: toast-out .25s ease-in forwards; }
.toast-text { flex: 1; }
.toast-close { border: 0; background: transparent; color: var(--text-faint); padding: 0 2px; font-size: 16px; line-height: 1; margin: -2px -4px 0 0; }
.toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
#table { position: relative; transition: opacity .15s; }
#table.htmx-request { opacity: .55; pointer-events: none; }
.is-busy { opacity: .6; pointer-events: none; }

.empty-state { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--text-muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-l); }

/* 15. Логин, ошибки -------------------------------------------------------- */
.auth-body { min-width: 0; }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-5); }
.login-card { width: 360px; max-width: 100%; padding: 28px; box-shadow: var(--shadow-1); }
.login-brand { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.login-brand img { color: var(--primary); }
.login-title { margin: 0; font-size: 17px; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack .field { margin-bottom: 0; }

.error-page { max-width: 560px; margin: 80px auto; text-align: center; }
.error-code { font-size: 72px; font-weight: 800; line-height: 1; color: var(--text-faint); letter-spacing: -.02em; margin-bottom: var(--sp-3); }
.error-title { font-size: 22px; }
.error-message { color: var(--text-muted); }
.error-perm { color: var(--text-muted); }
.error-actions { margin-top: var(--sp-5); }
.error-request-id { font-size: var(--fs-s); margin-top: var(--sp-5); }

/* 16. Утилиты -------------------------------------------------------------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.danger { color: var(--danger); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.small { font-size: var(--fs-s); }
.flex { display: flex; align-items: center; gap: var(--sp-2); }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ml-auto { margin-left: auto; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 17. Экран /prompts (pages/prompts/*) ------------------------------------- */
/* Ширины колонок задаёт thead (table-layout: fixed); «Название» — остаток. */
.table--prompts .col-id { width: 84px; }
.table--prompts .col-photos { width: 210px; }
.table--prompts .col-status { width: 190px; }
.table--prompts .col-prompts { width: 132px; }
.table--prompts .col-counter { width: 88px; }
.table--prompts .col-actions { width: 154px; }
.table--prompts th .th-sub { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; margin-top: 1px; }
.table--prompts th .th-sub a.sort { color: var(--text-faint); }
.table--prompts td.cell-id .mono { font-weight: 600; color: var(--text); }
.table--prompts td.cell-id .mono:hover { color: var(--primary); text-decoration: none; }
.table--prompts td.cell-name { min-width: 0; }
.table--prompts .name-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.table--prompts .name-line a { color: var(--text); }
.table--prompts .name-line a:hover { color: var(--primary); text-decoration: none; }
.table--prompts .name-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; margin: 2px 0 4px; font-size: var(--fs-s); }
.table--prompts .rubric-link { color: var(--text-muted); }
.table--prompts .rubric-link:hover { color: var(--primary); text-decoration: none; }
.table--prompts .name-sub a.badge:hover { text-decoration: none; filter: brightness(.92); }
.table--prompts .prompt-text { color: var(--text-muted); font-size: var(--fs-s); line-height: 1.35; }
.table--prompts td.cell-status .select { margin-bottom: 8px; }
.cell-toggles { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.toggle--cell { gap: 5px; }
.toggle--cell .toggle-track { width: 28px; height: 16px; }
.toggle--cell .toggle-track::after { width: 12px; height: 12px; }
.toggle--cell input:checked + .toggle-track::after { transform: translateX(12px); }
.toggle--cell .toggle-label { font-size: 11px; }
.toggle--cell:has(input:checked) .toggle-label { color: var(--text); font-weight: 500; }
/* Подписи тумб: заполненный слот — подпись в углу; референс — 8-й слот с рамкой. */
.thumb-slot .thumb-cap { position: absolute; left: 0; bottom: 0; padding: 1px 4px; font-size: 9px; line-height: 1.3; font-style: normal; font-weight: 600; color: #fff; background: rgba(0, 0, 0, .55); border-top-right-radius: 3px; pointer-events: none; }
.thumb-slot--ref { box-shadow: inset 0 0 0 2px var(--primary); }
.thumb-slot--ref img { opacity: .95; }
/* Заполненность промтов по типу персоны: точка + короткая подпись, 3 в ряд. */
.pdots { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 3px 9px; font-size: 11px; color: var(--text-faint); }
.pdot { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; line-height: 1.3; }
.pdot i { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; }
.pdot.is-on { color: var(--text-muted); }
.pdot.is-on i { background: var(--success); }
.table--prompts td.cell-counter { font-variant-numeric: tabular-nums; }
.table--prompts td.cell-counter b { display: block; font-weight: 600; }
.table--prompts td.cell-counter .muted { display: block; font-size: var(--fs-s); }
.table--prompts .row-actions { flex-wrap: wrap; }
.btn-icon.btn-ultra { color: var(--st-ultra); }
.btn-icon.btn-ultra:hover { background: color-mix(in srgb, var(--st-ultra) 14%, var(--surface)); }
.table--prompts tr.row-empty td { padding: var(--sp-3); }
.table--prompts tr.row-empty:hover td { background: transparent; }
.table--prompts tr.row-empty .empty-state { border: 0; }
/* Фильтры: чипы флагов группой, «Сбросить» справа. */
.filters--prompts .filters-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.filters--prompts .filters-reset:hover { color: var(--danger); text-decoration: none; }
.pagination .pagination-gap { min-width: 20px; color: var(--text-faint); }
/* Bulk-bar: зависимые от действия блоки value (admin.js переключает hidden). */
.bulk-bar [data-bulk-value][hidden] { display: none; }
.bulk-bar .select-sm { height: 30px; }
.bulk-bar .btn-sm { height: 30px; }

/* 18. Форма промта (pages/prompts/form.html, macros/forms.html, macros/media.html) ------------------------------ */
/* Aside рядом с формой уже от 1100px: минимум формы = сетка слотов 4×150 + отступы (~670px) + aside 300 + gap. Перекрывает правило
   «<1400px aside под форму» из раздела 10 — на 1280 оглавление и карточка иначе уезжали вниз. */
@media (min-width: 1100px) { .form-layout { grid-template-columns: minmax(0, 1fr) 300px; } .form-aside { position: sticky; } }
.form-main { min-width: 0; }
.page-head--form .page-title { flex-wrap: wrap; font-size: 20px; }
.page-head--form .page-title-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.page-head--form .badge { font-size: 11px; }
fieldset.section { scroll-margin-top: calc(var(--header-h) + 12px); }
fieldset.section > legend .icon { vertical-align: -3px; }
.section-hint .icon { width: 13px; height: 13px; vertical-align: -2px; color: var(--text-muted); }
.card--tight { padding: var(--sp-3); }
.form-aside .card-title { margin-bottom: var(--sp-2); }

/* Подпись поля в строку: слева текст, справа инструменты (метка, копирование) и счётчик из admin.js. */
.field-label--row { display: flex; align-items: center; gap: 6px; }
.field-label--row .field-label-text { flex: 1; min-width: 0; }
.field-label--row .char-count { float: none; margin: 0; }
.field-label .req { color: var(--danger); }
.field-mark { font-size: 11px; font-weight: 500; color: var(--text-faint); padding: 1px 7px; border-radius: 999px; background: var(--surface-2); line-height: 1.4; }
.field-mark.is-on { color: var(--success); background: var(--success-soft); }
.btn-copy { width: 26px; height: 26px; margin: -4px 0; }
.field-label--row .btn-copy { flex: none; }

/* Тумблеры формы: обычный размер текста, подсказка под названием. */
.toggle-group--form { gap: 12px; }
.toggle--field { align-items: flex-start; }
.toggle--field .toggle-track { margin-top: 2px; }
.toggle--field .toggle-text { display: flex; flex-direction: column; gap: 1px; }
.toggle--field .toggle-label { font-size: var(--fs); color: var(--text); font-weight: 500; }
.toggle--field .toggle-hint { font-size: var(--fs-s); color: var(--text-muted); }
.flags-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); gap: var(--sp-5); margin-bottom: var(--sp-3); }
@media (max-width: 800px) { .flags-layout { grid-template-columns: minmax(0, 1fr); } }
.ultra-box { padding: var(--sp-3); border-radius: var(--radius); border: 1px dashed color-mix(in srgb, var(--st-ultra) 50%, var(--border)); background: color-mix(in srgb, var(--st-ultra) 6%, var(--surface)); align-self: start; }
.ultra-box-title { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: var(--sp-2); color: var(--st-ultra); }
.ultra-box .btn { margin-bottom: 4px; }
.ultra-box .field-hint { margin-top: 6px; }

/* Оживление: текстовые поля слева, видео-слот 9:16 справа. */
.animate-layout { display: flex; gap: var(--sp-5); align-items: flex-start; }
.slot-grid--single { grid-template-columns: 150px; flex: none; }
.slot-grid--photos { margin-bottom: var(--sp-3); }
@media (max-width: 720px) { .slot-grid { grid-template-columns: repeat(auto-fill, 150px); } }

/* Слот: подпись-мета, ошибка поверх, референс с альфой (contain на «шахматке»), видео на чёрном. */
.slot-file:focus-visible ~ .slot-actions, .slot:has(.slot-file:focus-visible) { box-shadow: var(--focus-ring); }
.slot-meta { position: absolute; right: 8px; bottom: 6px; font-size: 10px; color: #fff; opacity: .85; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); pointer-events: none; font-variant-numeric: tabular-nums; }
.slot:not(.slot--filled) .slot-meta { color: var(--text-faint); text-shadow: none; }
.slot .slot-err { position: absolute; left: 6px; right: 6px; bottom: 30px; z-index: 2; margin: 0; padding: 4px 7px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--danger) 90%, #000); color: #fff; font-size: 11px; line-height: 1.3; }
.slot--error .slot-label { color: var(--danger); }
.slot--reference img { object-fit: contain; background: conic-gradient(var(--surface-3) 25%, var(--surface) 0 50%, var(--surface-3) 0 75%, var(--surface) 0) 0 0 / 16px 16px; }
.slot--video video { background: #000; }
.slot.htmx-request, .slot:has(.htmx-request) { opacity: .85; }
.slot--filled .slot-actions .btn { color: #1c2430; }

/* Карточка «как в приложении» + переключатели языка и типа персоны. */
.preview-card { display: flex; flex-direction: column; gap: var(--sp-2); }
.preview-card.htmx-request .app-card { opacity: .6; transition: opacity .15s; }
.preview-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; flex: none; }
.seg-btn { height: 24px; padding: 0 9px; border: 0; background: var(--surface); color: var(--text-muted); font-size: var(--fs-s); font-weight: 600; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border-strong); }
.seg-btn:hover { background: var(--surface-2); color: var(--text); }
.seg-btn.is-active { background: var(--primary); color: var(--on-primary); }
.preview-variants { display: flex; gap: 4px; flex-wrap: wrap; }
.preview-variants .chip-toggle { height: 24px; padding: 0 8px; }
.chip-toggle.is-active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip-toggle.is-off { opacity: .45; }
.chip-toggle.is-off.is-active { opacity: .8; }
.app-card--empty { background: var(--surface-3); }
.app-card-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-faint); font-size: var(--fs-s); }
.app-card-placeholder .icon { width: 28px; height: 28px; opacity: .5; }
.app-card--empty::after { opacity: .5; }
.app-card-sub { display: block; font-size: 11px; font-weight: 500; opacity: .85; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }
.form-aside .app-card { width: 100%; max-width: 300px; height: auto; aspect-ratio: 6 / 7; }

/* Оглавление: счётчик ошибок, активный раздел (admin.js initTocSpy). */
.toc .toc-err { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; margin-left: 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; }
.toc a.active { font-weight: 600; }

/* Факты о промте в aside. */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: var(--fs-s); margin: 0; }
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; }

/* Save-bar: подсказка хоткея справа, иконка у «несохранённых». */
.save-bar kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); }
.save-bar .dirty-note .icon { width: 14px; height: 14px; }

/* 19. Экран /videos (pages/videos/*) --------------------------------------- */
/* Наследует .table--prompts (ID/название/статус/действия); свои ширины: ☐32 · ID 84 · Постер 100 · Название — остаток · Модель 150 · Статус 190 · Счётчик 84 · Действия 80. */
.table--videos .col-poster { width: 100px; }
.table--videos .col-model { width: 150px; }
.table--videos .col-counter { width: 84px; }
.table--videos .col-actions { width: 80px; }
.thumb-poster { display: block; }
.thumb-poster img { display: block; }
.thumb-poster--empty { display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border-strong); background: transparent; font-size: 10px; color: var(--text-faint); text-align: center; line-height: 1.15; padding: 4px; }
.poster-meta { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; font-size: var(--fs-s); line-height: 1.2; white-space: nowrap; }
/* Индикатор 360p: точка серая/зелёная + подпись. */
.mark360 { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; color: var(--text-faint); }
.mark360::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.mark360.is-on { color: var(--success); }
.mark360.is-on::before { background: var(--success); }
.table--videos .session-link { color: var(--text-muted); }
.table--videos .session-link:hover { color: var(--primary); text-decoration: none; }
.table--videos .name-sub .session-link::before { content: "·"; color: var(--text-faint); margin-right: 6px; }
.table--videos td.cell-model .model-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table--videos .model-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: var(--fs-s); margin-top: 2px; font-variant-numeric: tabular-nums; }
.filters--videos .filters-search { width: 240px !important; }

/* 20. Форма видео (pages/videos/{form,_form_body,_previews,_gallery_job}.html, partials/combobox_results.html) ---------- */
/* Комбобокс фотосессии: поле + ссылка «открыть промт ↗» в строку; опции — кнопки на всю ширину. */
.combobox-row { display: flex; align-items: center; gap: var(--sp-2); }
.combobox-row .combobox { flex: 1; min-width: 0; }
.combobox-row .combobox-link { margin-left: 0; }
.combobox-option { width: 100%; border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; }
.combobox-option .name-en { font-style: italic; color: var(--text-muted); }
.combobox-option .badge { flex: none; }
.combobox-thumb-empty { width: 24px; height: 28px; border-radius: 3px; border: 1px dashed var(--border-strong); flex: none; }
/* Генерация: модель шире, три числовых поля рядом. */
.gen-layout { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 0 var(--sp-4); }
@media (max-width: 800px) { .gen-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Медиа: слоты 150px слева (постер, референс), справа превью и 360p. */
.media-layout { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-3); align-items: start; }
.media-layout .slot-wrap { width: 150px; }
.media-layout .slot-caption { text-align: left; }
.media-title { font-weight: 600; margin-bottom: var(--sp-2); }
.media-locked { display: flex; align-items: center; gap: 8px; padding: var(--sp-4); border: 1px dashed var(--border-strong); border-radius: var(--radius-l); color: var(--text-faint); font-size: var(--fs-s); }
.media-locked .icon { width: 20px; height: 20px; opacity: .6; flex: none; }
/* Превью: шапка с кнопкой-лейблом загрузки, список 150px, действия в две строки. */
.previews-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.previews-head .media-title { margin: 0; }
.previews-upload { cursor: pointer; margin-left: auto; }
.previews-upload:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.previews.htmx-request { opacity: .6; pointer-events: none; }
.previews.htmx-request .previews-upload .spinner { display: inline-block; }
.previews > .slot-err { margin: 0 0 var(--sp-2); }
.previews .empty-state { padding: var(--sp-4); }
.preview-list li { width: 150px; }
.preview-list .drag { background: rgba(0, 0, 0, .45); color: #fff; z-index: 2; }
.preview-list .drag:hover { background: rgba(0, 0, 0, .65); color: #fff; }
.preview-actions { flex-wrap: wrap; }
.preview-actions .btn:first-child { flex: 1 1 100%; }
.preview-actions .btn-icon { width: 24px; height: 24px; margin-left: auto; }
/* 360p: строка со спиннером при генерации, плеер 150px и путь, кнопка. */
.gallery-job { display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-start; }
.gallery-job--running { flex-direction: row; align-items: center; gap: 8px; color: var(--text-muted); font-size: var(--fs-s); padding: var(--sp-2) 0; }
.gallery-job .slot-err { margin: 0; }
.gallery-video { width: 150px; aspect-ratio: 9 / 16; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--border); }
.gallery-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-path { max-width: 320px; font-size: 11px; margin: 0; }
.success-text { color: var(--success); }
