:root {
  --bg: #0b0c0e;
  --bg-glow: rgba(120, 140, 170, 0.07);
  --surface: rgba(255, 255, 255, 0.028);
  --surface-2: rgba(255, 255, 255, 0.05);
  --float-bg: rgba(18, 19, 22, 0.62);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #ecedee;
  --text-2: #a4a7ad;
  --text-3: #74787f;
  --accent: #7fd1b9;
  --accent-line: rgba(127, 209, 185, 0.55);
  --st-pending: #5d6168;
  --st-running: #e7c35a;
  --st-waiting: #f09a5b;
  --st-done: #5fc48e;
  --st-cached: #74a9e0;
  --st-failed: #ec6a74;
  --st-skipped: #4a4d53;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius-surface: 16px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f4f1;
    --bg-glow: rgba(90, 120, 150, 0.08);
    --surface: rgba(0, 0, 0, 0.022);
    --surface-2: rgba(0, 0, 0, 0.045);
    --float-bg: rgba(255, 255, 255, 0.88);
    --line: rgba(0, 0, 0, 0.09);
    --line-2: rgba(0, 0, 0, 0.18);
    --text: #16171a;
    --text-2: #50535a;
    --text-3: #6f737a;
    --accent: #147a62;
    --accent-line: rgba(20, 122, 98, 0.5);
    --st-pending: #9a9da3;
    --st-running: #a77d06;
    --st-waiting: #c0621c;
    --st-done: #1f8a55;
    --st-cached: #2c6db0;
    --st-failed: #c43341;
    --st-skipped: #b5b8bd;
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f4f4f1;
  --bg-glow: rgba(90, 120, 150, 0.08);
  --surface: rgba(0, 0, 0, 0.022);
  --surface-2: rgba(0, 0, 0, 0.045);
  --float-bg: rgba(255, 255, 255, 0.88);
  --line: rgba(0, 0, 0, 0.09);
  --line-2: rgba(0, 0, 0, 0.18);
  --text: #16171a;
  --text-2: #50535a;
  --text-3: #6f737a;
  --accent: #147a62;
  --accent-line: rgba(20, 122, 98, 0.5);
  --st-pending: #9a9da3;
  --st-running: #a77d06;
  --st-waiting: #c0621c;
  --st-done: #1f8a55;
  --st-cached: #2c6db0;
  --st-failed: #c43341;
  --st-skipped: #b5b8bd;
  color-scheme: light;
}

* { box-sizing: border-box; }
/* атрибут hidden сильнее любого display из классов (.layout — grid) */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, var(--bg-glow), transparent 70%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.45 var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- верх */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--float-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; }
.brand-mark { width: 22px; height: 22px; fill: var(--accent); stroke: var(--accent); stroke-width: 1.4; }
.top-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- пилюли: все кнопки и выделения круглые, без плотной заливки */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 34px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line-2);
  background: transparent; color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: border-color .15s, color .15s, background-color .15s;
}
.pill:hover { background: var(--surface-2); }
a.pill { text-decoration: none; }
.pill:focus-visible { outline: none; border-color: var(--accent); }
.pill:disabled { opacity: .45; cursor: default; background: transparent; }
.pill-accent { border-color: var(--accent-line); color: var(--accent); }
.pill-accent:hover { border-color: var(--accent); }
.pill-quiet { border-color: var(--line); color: var(--text-2); }
.pill-sm { min-height: 28px; padding: 0 12px; font-size: 13px; }
.pill-icon { width: 34px; padding: 0; }
.pill-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }

/* ---------- раскладка */
.layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 420px;
  gap: 16px;
  padding: 16px 20px 32px;
  align-items: start;
}
.section-label { font-size: 12px; color: var(--text-3); margin: 4px 4px 10px; letter-spacing: .02em; }

/* ---------- список прогонов */
.runs { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
#runs { display: flex; flex-direction: column; gap: 4px; }
.run-item {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 9px 14px; border-radius: 999px; border: 1px solid transparent;
  background: transparent; cursor: pointer;
}
.run-item:hover { background: var(--surface-2); }
.run-item[aria-current="true"] { border-color: var(--line-2); background: var(--surface); }
.run-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-item .sub { display: block; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-item .when { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.empty { color: var(--text-3); padding: 8px 14px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-pending); flex: none; }
.dot[data-st="running"], .dot[data-st="queued"] { background: var(--st-running); animation: pulse 1.2s ease-in-out infinite; }
.dot[data-st="waiting"] { background: var(--st-waiting); animation: pulse 1.6s ease-in-out infinite; }
.dot[data-st="done"] { background: var(--st-done); }
.dot[data-st="cached"] { background: var(--st-cached); }
.dot[data-st="failed"] { background: var(--st-failed); }
.dot[data-st="skipped"], .dot[data-st="canceled"] { background: var(--st-skipped); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- сцена */
.stage { min-width: 0; }
.run-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 2px 0 12px; }
.run-title h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-2);
}
.chip-parent { font-size: 12.5px; color: var(--text-3); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile {
  padding: 12px 14px; border-radius: var(--radius-surface);
  border: 1px solid var(--line); background: var(--surface);
}
.tile .k { font-size: 12px; color: var(--text-3); }
.tile .v { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.tile a.dl { color: var(--accent); text-decoration: none; }
.tile a.dl:hover { text-decoration: underline; }

.graph-wrap {
  border: 1px solid var(--line); border-radius: var(--radius-surface);
  background: var(--surface);
  padding: 18px 10px;
  overflow-x: auto;
}
#graph { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.edge { fill: none; stroke: var(--line-2); stroke-width: 1.4; }
.edge[data-long="1"] { stroke: var(--line); }
.edge[data-live="1"] { stroke: var(--st-running); stroke-dasharray: 4 5; animation: flow 1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -18; } }
.gnode { cursor: pointer; }
.gnode rect.body { fill: var(--bg); stroke: var(--line-2); stroke-width: 1; transition: stroke .15s; }
.gnode:hover rect.body { stroke: var(--text-3); }
.gnode[data-sel="1"] rect.body { stroke: var(--accent); stroke-width: 1.6; }
.gnode rect.tint { fill: var(--surface); stroke: none; }
.gnode .title { fill: var(--text); font: 500 13px var(--sans); }
.gnode .meta { fill: var(--text-3); font: 11.5px var(--mono); }
.gnode[data-st="skipped"] .title, .gnode[data-st="canceled"] .title { fill: var(--text-3); }
.gnode circle.st { fill: var(--st-pending); }
.gnode[data-st="running"] circle.st, .gnode[data-st="queued"] circle.st { fill: var(--st-running); animation: pulse 1.2s ease-in-out infinite; }
.gnode[data-st="waiting"] circle.st { fill: var(--st-waiting); animation: pulse 1.6s ease-in-out infinite; }
.gnode[data-st="done"] circle.st { fill: var(--st-done); }
.gnode[data-st="cached"] circle.st { fill: var(--st-cached); }
.gnode[data-st="failed"] circle.st { fill: var(--st-failed); }
.gnode[data-st="skipped"] circle.st, .gnode[data-st="canceled"] circle.st { fill: var(--st-skipped); }
.gnode:focus { outline: none; }
.gnode:focus-visible rect.body { stroke: var(--accent); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; padding: 0 4px; font-size: 12px; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- инспектор */
.inspector { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius-surface);
  background: var(--surface); padding: 14px 16px;
}
.card h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.card h3 { font-size: 12px; font-weight: 500; color: var(--text-3); margin: 0 0 8px; letter-spacing: .02em; }
.node-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.node-id { color: var(--text-3); font-family: var(--mono); font-size: 12px; margin-top: 2px; }
.mini-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.mini-tiles .tile { padding: 9px 11px; }
.mini-tiles .tile .v { font-size: 16px; }
.error { color: var(--st-failed); font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; margin-top: 10px; }

video.preview { width: 100%; max-height: 460px; border-radius: 12px; background: #000; display: block; }
.shot { width: 100%; border-radius: 10px; display: block; margin-top: 8px; border: 1px solid var(--line); }
a.shot-link { display: block; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.ok { color: var(--st-done); }
.bad { color: var(--st-failed); }
.problems { margin: 8px 0 0; padding-left: 18px; color: var(--st-failed); font-size: 13px; }

.ranges { display: flex; flex-direction: column; gap: 8px; }
.range { border-left: 2px solid var(--line-2); padding: 2px 0 2px 10px; }
.range .tc { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.range .beat { font-size: 11px; color: var(--accent); margin-left: 8px; letter-spacing: .04em; }
.range .q { margin-top: 2px; }
.strategy { color: var(--text-2); margin: 0 0 10px; }

pre.text {
  margin: 0; max-height: 280px; overflow: auto;
  font: 12px/1.5 var(--mono); color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- поля */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--text-2); }
.input {
  height: 36px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent; outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
textarea.area {
  min-height: 84px; padding: 10px 14px; border-radius: 14px; resize: vertical;
  border: 1px solid var(--line-2); background: transparent; outline: none; line-height: 1.45;
}
textarea.area:focus { border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .input { flex: 1; min-width: 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  min-height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px;
}
.seg button[aria-pressed="true"] { border-color: var(--accent-line); color: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- панель у кнопки (не модалка) */
.pop-anchor { position: relative; }
.pop {
  --float-bg: rgba(18, 19, 22, 0.95);
  position: absolute; right: 0; top: calc(100% + 8px);
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line-2); border-radius: var(--radius-surface);
  background: var(--float-bg);
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}
:root[data-theme="light"] .pop { --float-bg: rgba(255, 255, 255, 0.96); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .pop { --float-bg: rgba(255, 255, 255, 0.96); } }
.pop-inner { padding: 16px; max-height: calc(100vh - 120px); overflow: auto; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--float-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 13px; z-index: 50; max-width: calc(100vw - 32px);
}

details.log summary { cursor: pointer; list-style: none; display: inline-flex; }
details.log summary::-webkit-details-marker { display: none; }
details.log[open] pre { margin-top: 10px; }

/* ---------- узкие экраны */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .inspector { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 760px) {
  .top { padding: 10px 16px; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 28px; gap: 12px; }
  .runs { position: static; max-height: none; overflow: visible; }
  #runs { flex-direction: row; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  #runs::-webkit-scrollbar { display: none; }
  .run-item { width: auto; max-width: 240px; flex: none; border-color: var(--line); }
  .run-item .when { display: none; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-tiles .tile { padding: 8px 10px; }
  .graph-wrap { padding: 10px; }
  .pop { right: -44px; }
}

/* узкий экран: вместо графа — список узлов по порядку */
.node-list { display: none; flex-direction: column; gap: 6px; }
.node-list button {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-height: 42px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg); text-align: left; cursor: pointer;
}
.node-list button[aria-current="true"] { border-color: var(--accent); }
.node-list .meta { font: 11.5px var(--mono); color: var(--text-3); }
@media (max-width: 760px) {
  #graph { display: none; }
  .node-list { display: flex; }
}

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

/* ---------- разделы и склад */
.views { margin-right: auto; margin-left: 18px; }
.lib { padding: 16px 20px 32px; }
.lib-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.lib-q { flex: 1; min-width: 0; height: 40px; }
.lib-kinds { margin-bottom: 8px; }
.lib-kinds .n { color: var(--text-3); margin-left: 6px; font-variant-numeric: tabular-nums; }
.lib-note { font-size: 12.5px; color: var(--text-3); margin: 0 4px 12px; min-height: 18px; }
.lib-body { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.lib-body:has(.lib-detail[hidden]) { grid-template-columns: minmax(0, 1fr); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.lib-tile {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer;
  transition: border-color .15s;
}
.lib-tile:hover { border-color: var(--line-2); }
.lib-tile[aria-current="true"] { border-color: var(--accent); }
.lib-tile:focus-visible { outline: none; border-color: var(--accent); }
.lib-media { position: relative; aspect-ratio: 4 / 5; background: var(--surface-2); overflow: hidden; }
.lib-media img, .lib-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-media[data-fit="contain"] img { object-fit: contain; padding: 10px; }
.lib-media video.hover-motion { position: absolute; inset: 0; opacity: 0; transition: opacity .15s; }
.lib-media[data-play="1"] video.hover-motion { opacity: 1; }
.lib-media .score {
  position: absolute; right: 8px; top: 8px; padding: 2px 8px; border-radius: 999px;
  font: 11px var(--mono); background: var(--float-bg); color: var(--text-2);
}
.lib-tile .cap { padding: 8px 12px 10px; }
.lib-tile .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-tile .s { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-tile .nolic { color: var(--st-waiting); margin-right: 6px; }
.lib-pub[aria-pressed="true"] { border-color: var(--accent-line); color: var(--accent); }
/* превью шрифтов нарисованы чёрным по прозрачному: в тёмной теме переворачиваем */
:root:not([data-theme="light"]) img.ink { filter: invert(1); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) img.ink { filter: none; } }
.lib-detail { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; }
.lib-detail .big { width: 100%; border-radius: 12px; display: block; background: var(--surface-2); max-height: 520px; object-fit: contain; }
.lib-detail .big.ink { background: transparent; }
.lib-detail audio { width: 100%; margin-top: 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags span { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.lib-detail a { color: var(--accent); }
.key { font-family: var(--mono); font-size: 12px; color: var(--text-2); word-break: break-all; }
.look-pick .shot { margin-top: 10px; }

@media (max-width: 980px) {
  .lib-body { grid-template-columns: minmax(0, 1fr); }
  .lib-detail { position: static; order: -1; }
}
@media (max-width: 760px) {
  .top { flex-wrap: wrap; row-gap: 8px; }
  .views { order: 3; margin: 0; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .views::-webkit-scrollbar { display: none; }
  .views button { flex: 1 0 auto; }
  .lib { padding: 12px 16px 28px; }
  .lib-bar { flex-wrap: wrap; }
  .lib-bar .pill { flex: 1; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
}

/* карусель */
.slides-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slides-grid .shot { margin-top: 0; }
.art-prompts { margin-top: 12px; font-size: 12.5px; color: var(--text-2); }
.art-prompts summary { cursor: pointer; color: var(--text); }
.art-prompts p { margin: 6px 0; white-space: normal; word-break: break-word; }
.shots-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.shots-grid figure { margin: 0; min-width: 0; }
.shots-grid figcaption { font-size: 12px; color: var(--text-3); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shots-grid figure.bad figcaption { color: var(--st-failed); white-space: normal; }
.plan-items, .copy-slides { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 8px; font-size: 13.5px; }
.plan-items .mono { color: var(--text-3); font-size: 12px; }
.card em { font-style: normal; color: var(--accent); }
pre.caption { white-space: pre-wrap; margin-top: 10px; font-family: inherit; font-size: 13.5px; }
.plan-items a { color: var(--accent); }
.copy-slides + .strategy { margin-top: 12px; }
@media (max-width: 560px) {
  .slides-grid { grid-template-columns: repeat(2, 1fr); }
  .shots-grid { grid-template-columns: 1fr; }
}

/* разбор ниши */
ul.plain { margin: 0; padding-left: 16px; }
.market-posts .mono { color: var(--text-3); font-size: 12px; }

/* персонажи и шаблоны */
.studio { padding: 16px 20px 32px; }
.studio-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.studio-bar .section-label { margin: 0 4px; }
.studio-body { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.studio-detail { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 92px); overflow: auto; }
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.cast-tile { text-align: left; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: inherit; font: inherit; cursor: pointer; overflow: hidden; }
.cast-tile:hover { border-color: var(--line-2); }
.cast-tile[aria-current="true"] { border-color: var(--accent); }
.cast-tile:focus-visible { outline: none; border-color: var(--accent); }
.cast-tile .cap { padding: 8px 12px 10px; }
.cast-tile .t { font-weight: 500; }
.cast-tile .s { font-size: 12px; color: var(--text-3); }
.cast-stage {
  position: relative; width: 100%; overflow: hidden; border-radius: 12px;
  background-color: var(--surface-2);
  background-image: linear-gradient(45deg, var(--surface) 25%, transparent 25%, transparent 75%, var(--surface) 75%),
    linear-gradient(45deg, var(--surface) 25%, transparent 25%, transparent 75%, var(--surface) 75%);
  background-size: 22px 22px; background-position: 0 0, 11px 11px;
}
.cast-stage .in { position: absolute; inset: 0; transform-origin: 50% 100%; }
.cast-stage img { position: absolute; max-width: none; height: auto; user-select: none; pointer-events: none; }
.cast-stage img[hidden] { display: none; }
.cast-stage.thumb { border-radius: 0; }
.cast-stage.big { max-height: 58vh; margin: 0 auto; }
.cast-stage.big .in { animation: breathe 3.4s ease-in-out infinite; }
.cast-stage.mini { width: 56px; flex: none; border-radius: 10px; }
.cast-stage.none { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text-3); aspect-ratio: 1 / 1; text-align: center; }
@keyframes breathe { 50% { transform: scaleY(1.012); } }
@media (prefers-reduced-motion: reduce) { .cast-stage.big .in { animation: none; } }
.cast-controls { margin-top: 12px; }
.cast-controls .field { margin-bottom: 10px; }
.voice-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.voice-row:first-of-type { border-top: 0; }
.voice-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-row .m { color: var(--text-3); font-size: 12px; margin-left: 8px; }
.voice-row.on .t { color: var(--accent); }
.play[data-on] { border-color: var(--accent); color: var(--accent); }
.tagc { font-size: 11.5px; color: var(--accent); border: 1px solid var(--accent-line); border-radius: 999px; padding: 1px 8px; margin-left: 8px; white-space: nowrap; }
.hint { font-size: 12.5px; color: var(--text-3); margin: 0 0 10px; }
.voice-list { display: flex; flex-direction: column; margin-top: 8px; max-height: 320px; overflow: auto; }
.voice-list > .pill { align-self: flex-start; margin-top: 8px; }
.range { flex: 1; accent-color: var(--accent); }
.tpl-body { grid-template-columns: 300px minmax(0, 1fr); }
.tpl-body .studio-detail { position: static; max-height: none; overflow: visible; max-width: 760px; }
.tpl-list { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 76px; }
.tpl-item { display: flex; gap: 10px; align-items: center; text-align: left; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.tpl-item:hover { border-color: var(--line-2); }
.tpl-item[aria-current="true"] { border-color: var(--accent); }
.tpl-item .body { min-width: 0; }
.tpl-item .t { font-weight: 500; }
.tpl-item .s { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw { display: flex; gap: 4px; margin-top: 6px; }
.sw i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line-2); display: block; }
.cast-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.cast-pick .pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; width: 82px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; }
.cast-pick .pick.none { justify-content: center; min-height: 92px; }
.cast-pick .pick[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.cast-pick .pick span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-preview { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 4px; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.preset { display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
.preset[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }
.preset .sample { position: relative; display: flex; align-items: center; height: 44px; border-radius: 8px; padding: 0 10px; background: var(--pc); color: var(--pi); }
.preset .sample b { font-size: 20px; font-weight: 800; }
.preset .sample i { position: absolute; right: 10px; width: 14px; height: 14px; border-radius: 50%; background: var(--pa); }
.shot.checker { background-color: #d6d6d6; background-image: linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%), linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%); background-size: 22px 22px; background-position: 0 0, 11px 11px; }
@media (max-width: 980px) {
  .studio-body, .tpl-body { grid-template-columns: minmax(0, 1fr); }
  .studio-detail, .tpl-list { position: static; max-height: none; overflow: visible; }
  #cast .studio-detail { order: -1; }
}
@media (max-width: 760px) {
  .studio { padding: 12px 16px 28px; }
  .cast-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  .tpl-preview { grid-template-columns: minmax(0, 1fr); }
  .tpl-preview .cast-stage { max-width: 240px; }
}
.pair { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; }
.bd-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.bd-tile { display: flex; flex-direction: column; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; }
.bd-tile[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }
.bdp { display: block; height: 84px; border-radius: 8px; background-color: var(--pc); overflow: hidden; position: relative; }
.bdp-auto::after { content: "?"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 800; color: var(--pa); }
.bdp-mesh { background-image: radial-gradient(circle at 25% 30%, color-mix(in srgb, var(--pa) 35%, transparent), transparent 55%), radial-gradient(circle at 75% 65%, color-mix(in srgb, var(--pa) 22%, #fff 20%), transparent 60%), radial-gradient(circle at 40% 90%, color-mix(in srgb, var(--pa) 18%, transparent), transparent 50%); background-size: 180% 180%; animation: bdp-drift 7s ease-in-out infinite alternate; }
.bdp-aurora { background-image: radial-gradient(circle at 20% 25%, color-mix(in srgb, var(--pa) 55%, transparent), transparent 45%), radial-gradient(circle at 80% 75%, color-mix(in srgb, var(--pa) 35%, transparent), transparent 45%); background-size: 160% 160%; animation: bdp-drift 5s ease-in-out infinite alternate; }
.bdp-grid::before { content: ""; position: absolute; left: -60%; right: -60%; top: 38%; bottom: -30%; background-image: linear-gradient(color-mix(in srgb, var(--pa) 55%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--pa) 55%, transparent) 1px, transparent 1px); background-size: 14px 14px; transform: perspective(50px) rotateX(40deg); transform-origin: 50% 0; animation: bdp-fall 1.6s linear infinite; }
.bdp-dots { background-image: radial-gradient(circle, color-mix(in srgb, var(--pa) 60%, transparent) 2px, transparent 2.5px); background-size: 12px 12px; animation: bdp-rise 3s linear infinite; }
.bdp-rays { background-image: repeating-conic-gradient(from 0deg at 50% 60%, color-mix(in srgb, var(--pa) 40%, transparent) 0deg 7deg, transparent 7deg 18deg); }
.bdp-rays::before { content: ""; position: absolute; inset: -40%; background: inherit; animation: bdp-spin 12s linear infinite; }
.bdp-bokeh { background-image: radial-gradient(circle at 25% 70%, color-mix(in srgb, var(--pa) 45%, transparent) 0 8px, transparent 11px), radial-gradient(circle at 70% 40%, color-mix(in srgb, var(--pa) 35%, transparent) 0 12px, transparent 15px), radial-gradient(circle at 45% 20%, color-mix(in srgb, var(--pa) 30%, transparent) 0 6px, transparent 9px); background-size: 100% 140%; animation: bdp-rise 4s linear infinite; }
.bdp-stripes { background-image: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--pa) 30%, transparent) 0 6px, transparent 6px 15px); background-size: 200% 100%; animation: bdp-slide 3s linear infinite; }
@keyframes bdp-drift { to { background-position: 100% 100%; } }
@keyframes bdp-fall { to { background-position: 0 14px; } }
@keyframes bdp-rise { to { background-position: 0 -60px; } }
@keyframes bdp-spin { to { transform: rotate(360deg); } }
@keyframes bdp-slide { to { background-position: 21.2px 0; } }
@media (prefers-reduced-motion: reduce) { .bdp, .bdp::before { animation: none !important; } }
.bd-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; max-height: 360px; overflow: auto; }
.bd-pick { display: flex; flex-direction: column; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--text-2); font: inherit; font-size: 11px; cursor: pointer; }
.bd-pick[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }
.bd-pick img, .bd-cur img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; display: block; background: #000; }
.bd-cur { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bd-cur img { width: 42px; }
.cast-stage.emoji .lot { position: absolute; inset: 6%; }
.cast-stage.emoji .lot svg { display: block; }
.cast-stage.emoji.talking .in { animation: emo-talk .19s ease-in-out infinite alternate; transform-origin: 50% 70%; }
@keyframes emo-talk { to { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .cast-stage.emoji.talking .in { animation: none; } }
.emoji-new { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.emoji-new h3 { margin: 0 0 4px; }

/* ---------- вход и приглашение (многопользовательская панель) */
body.auth { display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(400px, 100%); padding: 28px 28px 24px;
  border: 1px solid var(--line); border-radius: var(--radius-surface); background: var(--surface);
}
.auth-card h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 22px 0 16px; }
.auth-card .input { width: 100%; }
.auth-lead { color: var(--text-2); margin: -6px 0 18px; }
.auth-go { width: 100%; margin-top: 6px; }
.auth-err { color: var(--st-failed); font-size: 13px; margin: 2px 4px 10px; }
.auth-note { color: var(--text-3); font-size: 12.5px; margin: 18px 4px 0; }
.auth .actions .pill { flex: 1; }

/* ---------- учётная запись, команда, платформа */
.acc-btn { padding: 0 14px 0 4px; gap: 8px; max-width: 260px; }
.acc-ava {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 999px;
  border: 1px solid var(--accent-line); color: var(--accent); font-size: 11px; font-weight: 600; flex: none;
}
.acc-ws { overflow: hidden; text-overflow: ellipsis; }
.acc-pop { width: min(340px, calc(100vw - 32px)); z-index: 40; }
/* меню живёт внутри шапки с размытием: своё размытие там не видит страницу, поэтому фон почти плотный */
.acc-menu-pop { --float-bg: rgba(18, 19, 22, 0.985); backdrop-filter: none; -webkit-backdrop-filter: none; }
:root[data-theme="light"] .acc-menu-pop { --float-bg: rgba(255, 255, 255, 0.985); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .acc-menu-pop { --float-bg: rgba(255, 255, 255, 0.985); } }
.acc-menu { display: flex; flex-direction: column; gap: 10px; }
.acc-who { padding: 0 4px 4px; }
.acc-name { font-weight: 600; }
.acc-sub, .acc-dim { color: var(--text-3); font-size: 12.5px; }
.acc-wss, .acc-links { display: flex; flex-direction: column; gap: 4px; }
.acc-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid transparent;
  background: transparent; cursor: pointer; text-align: left;
}
.acc-item:hover { background: var(--surface-2); }
.acc-item[aria-current="true"] { border-color: var(--accent-line); color: var(--accent); }
.acc-pw .input { width: 100%; }
.acc { max-width: 1080px; margin: 0 auto; }
.acc-sec { border: 1px solid var(--line); border-radius: var(--radius-surface); background: var(--surface); padding: 16px 18px; margin-bottom: 14px; }
.acc-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.acc-sec-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.acc-meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.acc-meter-top { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.acc-meter-val { margin-top: 7px; color: var(--text-3); font-size: 12px; }
.acc-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.acc-bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.acc-meter.over .acc-bar i { background: var(--st-failed); }
.acc-meter.over .acc-meter-val { color: var(--st-failed); }
.acc-list { display: flex; flex-direction: column; }
.acc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.acc-list .acc-row:first-child, .acc-sec-head + .acc-row { border-top: 0; }
.acc-main { flex: 1 1 220px; min-width: 0; }
.acc-main > div { overflow: hidden; text-overflow: ellipsis; }
.acc-pending .acc-main > div:first-child { color: var(--text-2); }
.acc-tag { font-size: 12.5px; color: var(--text-2); padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; }
.acc-out { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.acc-out:empty { display: none; }
.acc-pad { padding: 4px 4px 8px; }
.acc-plan {
  display: grid; grid-template-columns: 110px minmax(140px, 1.6fr) repeat(4, minmax(86px, 1fr)) auto;
  gap: 10px; align-items: end; padding: 12px 0; border-top: 1px solid var(--line);
}
.acc-sec-head + .acc-plan { border-top: 0; }
.acc-lab { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 12px; color: var(--text-3); }
.acc-lab .input { width: 100%; }
.acc-plan-id { height: 36px; display: flex; align-items: center; font-size: 13px; color: var(--text-2); }
.acc-num { padding: 0 12px; }
.acc-plan .pill { height: 36px; }
@media (max-width: 760px) {
  .acc-ws { display: none; }
  .acc-pop { right: 0; }
  .acc-menu-pop { position: fixed; top: 56px; left: 16px; right: 16px; width: auto; }
  .acc-btn { padding: 0 4px; width: 34px; justify-content: center; }
  .acc-sec { padding: 14px; }
  .acc-plan { grid-template-columns: 1fr 1fr; }
  .acc-plan > :nth-child(2) { grid-column: 1 / -1; }
}

/* ---------- автопилот */
.ap-bar-act { gap: 8px; }
.ap-detail { max-width: 860px; }
.ap-gap { margin-top: 10px; }
.ap-h { margin: 0 !important; }
.ap-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin: 0 4px; background: var(--st-pending); }
.ap-dot[data-st="ok"] { background: var(--st-done); }
.ap-dot[data-st="needs_login"], .ap-dot[data-st="route_down"], .ap-dot[data-st="error"] { background: var(--st-failed); }
.ap-st { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.ap-st[data-st="ok"], .ap-st[data-st="published"] { color: var(--st-done); }
.ap-st[data-st="running"] { color: var(--st-running); }
.ap-st[data-st="waiting"] { color: var(--st-waiting); }
.ap-st[data-st="needs_login"], .ap-st[data-st="route_down"], .ap-st[data-st="error"], .ap-st[data-st="failed"] { color: var(--st-failed); }
.ap-st[data-st="skipped"] { color: var(--text-3); }
.ap-title { flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 999px; padding: 4px 12px; margin-left: -12px; outline: none; }
.ap-title:hover { border-color: var(--line); }
.ap-title:focus { border-color: var(--accent); }
.ap-facts { margin-top: 12px; }
.ap-facts dd { min-width: 0; overflow-wrap: anywhere; }
.ap-pop { left: 0; right: auto; width: min(380px, calc(100vw - 32px)); z-index: 30; }
.ap-bar-act .ap-pop { left: auto; right: 0; }
.ap-danger { border-color: var(--st-failed); color: var(--st-failed); }
.ap-two { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 16px; }
.ap-strat { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; color: var(--text-2); }
.ap-strat b { color: var(--text); font-weight: 600; }
.ap-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-tags .tagc { margin-left: 0; }
.ap-lessons { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.ap-items { display: flex; flex-direction: column; margin-top: 8px; }
.ap-item, .ap-post { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.ap-items > :first-child { border-top: 0; }
.ap-item[data-st="published"] .ap-what, .ap-item[data-st="skipped"] .ap-what { color: var(--text-2); }
.ap-when { color: var(--text-3); font-size: 12px; padding-top: 2px; }
.ap-what { min-width: 0; overflow-wrap: anywhere; }
.ap-what .s { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.ap-what a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--line-2); }
.ap-what a:hover { border-color: var(--accent); }
.ap-fmt { font-size: 11.5px; color: var(--accent); border: 1px solid var(--accent-line); border-radius: 999px; padding: 1px 8px; margin-right: 8px; white-space: nowrap; }
.ap-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ap-act { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
a.pill { text-decoration: none; }
.ap-nums, .ap-nnums { display: flex; gap: 14px; align-items: flex-start; font-size: 13px; }
.ap-nums > span, .ap-nnums > span { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.ap-nums small, .ap-nnums small { font-family: var(--sans); font-size: 11px; color: var(--text-3); }
.ap-nums .s { align-self: center; font-family: var(--sans); font-size: 12px; color: var(--text-3); }
.ap-journal { display: flex; flex-direction: column; max-height: 420px; overflow: auto; }
.ap-j { display: grid; grid-template-columns: 92px 76px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.ap-journal > :first-child { border-top: 0; }
.ap-jk { color: var(--text-3); }
.ap-j[data-kind="fail"] .ap-jk, .ap-j[data-kind="error"] .ap-jk { color: var(--st-failed); }
.ap-j[data-kind="publish"] .ap-jk { color: var(--st-done); }
.ap-j[data-kind="owner"] .ap-jk { color: var(--accent); }
.ap-jt { min-width: 0; overflow-wrap: anywhere; color: var(--text-2); }
.ap-niches { display: flex; flex-direction: column; gap: 12px; max-width: 1100px; }
#autopilot-view .hint a, .ap-jt a { color: var(--accent); }
.ap-summary { margin: 0; line-height: 1.5; }
.ap-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.ap-pick { display: flex; flex-direction: column; gap: 8px; }
.ap-pick p { margin: 0; line-height: 1.45; }
.ap-pick .actions { margin-top: auto; align-items: center; justify-content: space-between; }
.ap-score { font-size: 13px; color: var(--accent); border: 1px solid var(--accent-line); border-radius: 999px; padding: 2px 10px; }
.ap-pick-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-niche-list { display: flex; flex-direction: column; }
.ap-nrow { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.ap-niche-list > :first-child { border-top: 0; }
.ap-nrow.dim { opacity: .55; }
.ap-bar { position: relative; height: 22px; border-radius: 999px; border: 1px solid var(--line); overflow: hidden; }
.ap-bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--accent); opacity: .22; }
.ap-bar span { position: relative; display: block; padding-left: 10px; line-height: 20px; font-size: 12px; }
@media (max-width: 760px) {
  .ap-item, .ap-post { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .ap-side { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
  .ap-act { justify-content: flex-start; }
  .ap-j { grid-template-columns: 84px minmax(0, 1fr); }
  .ap-j .ap-jt { grid-column: 1 / -1; }
  .ap-nrow { grid-template-columns: 64px minmax(0, 1fr); }
  .ap-nnums { grid-column: 1 / -1; gap: 12px; flex-wrap: wrap; }
  .ap-nums { flex-wrap: wrap; }
  .ap-picks { grid-template-columns: minmax(0, 1fr); }
  .ap-pop, .ap-bar-act .ap-pop { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; width: auto; }
  .ap-two { grid-template-columns: minmax(0, 1fr); }
}
