/* ============================================================== токены */
:root {
  --bg: #0b0d14;
  --bg-elev: #12151f;
  --bg-soft: #161a26;
  --bg-input: #0e111a;
  --line: #232838;
  --line-soft: #1b1f2c;
  --text: #e8ebf5;
  --text-dim: #99a1b8;
  --text-faint: #6b7387;

  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --accent-line: rgba(124, 92, 255, 0.42);

  --ok: #34d399;
  --warn: #fbbf24;
  --err: #fb7185;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  --sidebar-w: 392px;
  --topbar-h: 58px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Безопасные зоны iPhone: вырез, Dynamic Island, полоска «Домой». На
     компьютере env() даёт 0, и отступы остаются прежними. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Видимая высота окна: в Safari 100vh выше экрана на высоту его панелей. */
  --vh: 100vh;
  /* Подложка под строкой состояния в режиме приложения: текст там всегда
     белый (black-translucent), поэтому фон обязан быть тёмным. */
  --status-bg: var(--bg-elev);
  --icon-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Zm0 2c-4.4 0-8 2.2-8 5v2h16v-2c0-2.8-3.6-5-8-5Z'/%3E%3C/svg%3E");
}

@supports (height: 100dvh) {
  :root {
    --vh: 100dvh;
  }
}

[data-theme='light'] {
  --bg: #f4f5fa;
  --bg-elev: #ffffff;
  --bg-soft: #f0f1f7;
  --bg-input: #ffffff;
  --line: #dfe2ee;
  --line-soft: #e9ebf4;
  --text: #171a24;
  --text-dim: #5b6479;
  --text-faint: #8b93a7;
  --accent-soft: rgba(124, 92, 255, 0.1);
  --shadow: 0 16px 38px rgba(29, 34, 58, 0.14);
  --status-bg: #171a24;
}

* {
  box-sizing: border-box;
}

/* Собственный display у компонентов перебивает атрибут hidden — возвращаем
   ему силу, иначе скрытые вкладки и кнопки остаются на экране. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: content-box;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ============================================================== каркас */
.app-shell {
  display: flex;
  flex-direction: column;
  height: var(--vh);
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

/* С экрана «Домой» панель открывается без Safari, строка состояния прозрачна.
   На телефоне страница прокручивается целиком, поэтому под часами держим
   сплошную полосу — иначе текст уезжал бы под них. В браузере её высота 0. */
body::before {
  content: '';
  position: fixed;
  inset: 0 0 auto;
  height: var(--safe-top);
  background: var(--status-bg);
  z-index: 400;
  pointer-events: none;
}

.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(12px);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), #b06cff 55%, var(--accent-2));
  box-shadow: 0 6px 16px rgba(124, 92, 255, 0.36);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text strong {
  font-size: 13.5px;
  letter-spacing: 0.2px;
}
.brand-text span {
  font-size: 11px;
  color: var(--text-faint);
}

.tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.tab:hover {
  color: var(--text);
}
.tab.is-active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}
.tab svg {
  opacity: 0.8;
}

.tab-badge {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.chip-btn:hover {
  color: var(--text);
  border-color: var(--accent-line);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.dot.is-ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16);
}
.dot.is-err {
  background: var(--err);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.16);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-dim);
  cursor: pointer;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent-line);
}

/* ============================================================ рабочая зона */
.workspace {
  flex: 1;
  min-height: 0;
  position: relative;
}

.panel-view {
  position: absolute;
  inset: 0;
  display: none;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}
.panel-view.is-active {
  display: grid;
}
.panel-view.is-wide {
  grid-template-columns: minmax(0, 1fr);
}

/* Колонка управления: прокручивается только средняя часть, панель запуска
   всегда остаётся на виду и не перекрывает параметры. */
.controls {
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.controls-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
}

/* ================================================================ блоки */
/* Без overflow:hidden — иначе блок обрезал бы выпадающий список моделей.
   Скругление нижних углов держит на себе последний элемент (.caps). */
.block {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line-soft);
}
.block-head .spacer {
  margin-left: auto;
}
.block-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > label,
.field-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-label .spacer {
  margin-left: auto;
}

.hint {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.45;
}

input[type='text'],
input[type='password'],
input[type='email'],
input[type='number'],
input[type='search'],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
/* Автозаполнение Chrome иначе перекрашивает поле в белый. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset;
  caret-color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.55;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' stroke='%2399a1b8' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* iOS увеличивает страницу при фокусе на поле со шрифтом мельче 16px и сам
   масштаб не возвращает. -webkit-touch-callout есть только в Safari на
   iPhone и iPad, так что на компьютере поля остаются прежними. */
@supports (-webkit-touch-callout: none) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* --------------------------------------------------------------- чипы */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.13s;
  font-variant-numeric: tabular-nums;
}
.chip:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent-line);
}
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--text);
  font-weight: 500;
}
.chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--line);
}
.seg button {
  padding: 7px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg button.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}
.seg button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* -------------------------------------------------------------- кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  border-color: var(--accent-line);
  background: var(--bg-soft);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.is-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-dim);
}
.btn.is-ghost:hover:not(:disabled) {
  background: var(--bg-input);
  color: var(--text);
}
.btn.is-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #9b6bff 60%, #6ea8ff);
  color: #fff;
  box-shadow: 0 8px 22px rgba(124, 92, 255, 0.3);
}
.btn.is-primary:hover:not(:disabled) {
  filter: brightness(1.07);
}
.btn.is-danger:hover:not(:disabled) {
  border-color: var(--err);
  color: var(--err);
}
.btn.is-sm {
  padding: 6px 10px;
  font-size: 12px;
}
.btn.is-on {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.4);
}
.btn.is-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------ свитчер */
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.switch input {
  display: none;
}
.switch .track {
  position: relative;
  width: 38px;
  height: 21px;
  border-radius: 11px;
  background: var(--line);
  transition: background 0.16s;
  flex: 0 0 auto;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.switch input:checked + .track {
  background: var(--accent);
}
.switch input:checked + .track::after {
  transform: translateX(17px);
}
.switch input:disabled + .track {
  opacity: 0.4;
}
.switch .switch-text {
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ======================================================= выбор модели */
.model-picker {
  position: relative;
}

.model-current {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-input);
  cursor: pointer;
  text-align: left;
}
.model-current:hover {
  border-color: var(--accent-line);
}
.model-current .avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
}
.model-current .meta {
  min-width: 0;
  flex: 1;
}
.model-current .meta strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.model-current .meta span {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Пока список открыт, вся карточка модели поднимается над соседними блоками. */
.model-picker.is-open {
  position: relative;
  z-index: 60;
}

.model-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 460px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* Если снизу места мало — раскрываем вверх. */
.model-menu.is-up {
  top: auto;
  bottom: calc(100% + 6px);
}
.model-menu[hidden] {
  display: none;
}
.model-menu .search {
  padding: 9px;
  border-bottom: 1px solid var(--line-soft);
}
.model-menu .list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}

.model-option {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.model-option:hover {
  background: var(--bg-soft);
}
.model-option.is-active {
  background: var(--accent-soft);
}
.model-option .avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
}
.model-option .meta {
  min-width: 0;
  flex: 1;
}
.model-option .meta strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
}
.model-option .meta .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tag {
  padding: 1.5px 6px;
  border-radius: 5px;
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.2px;
}
.tag.is-accent {
  color: var(--accent-2);
  border-color: rgba(34, 211, 238, 0.3);
}
.tag.is-audio {
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.3);
}

.caps {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-input);
  border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px);
}

/* ====================================================== слоты картинок */
.slots {
  display: grid;
  gap: 9px;
}
.slots.is-two {
  grid-template-columns: 1fr 1fr;
}

.slot {
  position: relative;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  min-height: 108px;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.14s, background 0.14s;
}
.slot:hover,
.slot.is-hot {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.slot.is-filled {
  border-style: solid;
  cursor: default;
}
/* Пока разворачивается HEIC — слот занят и на клики не реагирует. */
.slot.is-busy {
  pointer-events: none;
  opacity: 0.55;
  border-color: var(--accent-line);
  animation: slot-busy 1.1s ease-in-out infinite;
}
@keyframes slot-busy {
  50% {
    opacity: 0.85;
  }
}
.slot img {
  width: 100%;
  height: 100%;
  max-height: 190px;
  object-fit: contain;
  display: block;
  background: repeating-conic-gradient(var(--bg-soft) 0% 25%, transparent 0% 50%) 50% / 16px 16px;
}
.slot video {
  width: 100%;
  max-height: 190px;
  display: block;
  background: #05070c;
}
.slot .placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--text-faint);
  font-size: 11.5px;
  padding: 14px 8px;
  text-align: center;
}
.slot .slot-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(6, 8, 14, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  backdrop-filter: blur(4px);
}
.slot .slot-actions {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.14s;
}
.slot:hover .slot-actions {
  opacity: 1;
}
/* На телефоне наведения нет — кнопки слота видны всегда. */
@media (hover: none) {
  .slot .slot-actions {
    opacity: 1;
  }
}
.slot .slot-actions button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 0;
  background: rgba(6, 8, 14, 0.78);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.slot .slot-actions button:hover {
  background: var(--accent);
}

/* ================================================== оценка + генерация */
.launch {
  flex: 0 0 auto;
  padding: 11px 14px 13px;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: 0 -8px 18px -14px rgba(0, 0, 0, 0.7);
}

.estimate {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.estimate .price {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.estimate .price.is-approx::before {
  content: '≈ ';
  color: var(--text-faint);
  font-weight: 400;
}
.estimate .spacer {
  margin-left: auto;
}

/* ================================================================ сцена */
.stage-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.stage-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.stage-head .spacer {
  margin-left: auto;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 320px;
  padding: 40px 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-faint);
  text-align: center;
}
.empty h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text-dim);
  font-weight: 600;
}
.empty p {
  margin: 0;
  max-width: 460px;
  font-size: 12.5px;
  line-height: 1.6;
}
.empty kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.media-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.14s, transform 0.14s;
}
.media-card:hover {
  border-color: var(--accent-line);
}

.media-frame {
  position: relative;
  background: #05070c;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.media-frame img,
.media-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.media-frame .badge {
  position: absolute;
  top: 7px;
  left: 7px;
  padding: 2.5px 7px;
  border-radius: 6px;
  background: rgba(6, 8, 14, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  backdrop-filter: blur(4px);
}
.media-frame .fav {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: rgba(6, 8, 14, 0.7);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s;
  backdrop-filter: blur(4px);
}
.media-card:hover .fav,
.media-frame .fav.is-on {
  opacity: 1;
}
.media-frame .fav.is-on {
  color: var(--warn);
}

.media-body {
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}
.media-body .prompt {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.media-body .meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.media-body .meta-row .spacer {
  margin-left: auto;
}
.media-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding-top: 2px;
}
.media-actions .btn {
  padding: 5px 8px;
  font-size: 11.5px;
  gap: 5px;
}

/* ============================================================== очередь */
.job-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.job {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.job.is-running {
  border-color: var(--accent-line);
}
.job.is-failed {
  border-color: rgba(251, 113, 133, 0.4);
}

.job-thumb {
  width: 96px;
  height: 62px;
  border-radius: var(--radius-sm);
  background: #05070c;
  overflow: hidden;
  display: grid;
  place-items: center;
  position: relative;
}
.job-thumb img,
.job-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.job-thumb .spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.job-main {
  min-width: 0;
}
.job-main .title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 3px;
}
.job-main .prompt {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.job-main .sub {
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--text-faint);
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.job-main .err {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--err);
  line-height: 1.45;
}
.job-main .note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--warn);
  line-height: 1.45;
}
.job-main .tip {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-dim);
}
.job-main .tip svg {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--accent-2);
}

/* ================================================================ журнал */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 56vh;
  overflow-y: auto;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--bg-input);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
}
.log-row {
  display: grid;
  grid-template-columns: 62px 52px 78px minmax(0, 1fr);
  gap: 8px;
  padding: 3px 4px;
  border-radius: 5px;
}
.log-row:hover {
  background: var(--bg-soft);
}
.log-row .lvl {
  font-weight: 600;
  letter-spacing: 0.3px;
}
.log-row.info .lvl {
  color: var(--text-faint);
}
.log-row.warn .lvl {
  color: var(--warn);
}
.log-row.error .lvl {
  color: var(--err);
}
.log-row .tag {
  color: var(--accent-2);
}
.log-row .time,
.log-row .msg {
  color: var(--text-dim);
}
.log-row .msg {
  word-break: break-word;
  white-space: pre-wrap;
}
.log-row.error .msg {
  color: var(--text);
}

.job-side {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.status.pending,
.status.in_progress {
  background: rgba(124, 92, 255, 0.16);
  color: #b3a0ff;
}
.status.completed {
  background: rgba(52, 211, 153, 0.14);
  color: var(--ok);
}
.status.failed,
.status.error,
.status.cancelled,
.status.expired {
  background: rgba(251, 113, 133, 0.14);
  color: var(--err);
}

.progress-line {
  height: 2px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  margin-top: 7px;
}
.progress-line::after {
  content: '';
  display: block;
  height: 100%;
  width: 34%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: slide 1.5s ease-in-out infinite;
}
@keyframes slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(330%);
  }
}

/* =============================================================== фильтры */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-bar input[type='search'] {
  width: 240px;
}
.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ================================================================ модалка */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right))
    calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
  background: rgba(4, 6, 11, 0.72);
  backdrop-filter: blur(6px);
}
.modal-host[hidden] {
  display: none;
}

.modal {
  width: min(1080px, 100%);
  max-height: calc(var(--vh) - 48px - var(--safe-top) - var(--safe-bottom));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal.is-narrow {
  width: min(540px, 100%);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}
.modal-head .spacer {
  margin-left: auto;
}
.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-foot {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-soft);
}
.modal-foot .spacer {
  margin-left: auto;
}

/* ================================================================ редактор */
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: 14px;
}
.editor-canvas-wrap {
  position: relative;
  background: #05070c;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  min-height: 380px;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
}
.editor-canvas-wrap canvas {
  max-width: 100%;
  max-height: 62vh;
  display: block;
  cursor: grab;
}
.editor-canvas-wrap canvas.is-dragging {
  cursor: grabbing;
}
.editor-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: 62vh;
  padding-right: 3px;
}

.range-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.range-row .range-head {
  display: flex;
  font-size: 11.5px;
  color: var(--text-dim);
}
.range-row .range-head .spacer {
  margin-left: auto;
}
.range-row .range-head b {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text);
}
input[type='range'] {
  width: 100%;
  height: 4px;
  appearance: none;
  border-radius: 3px;
  background: var(--line);
  outline: none;
}
input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2.5px solid var(--bg-elev);
  box-shadow: 0 0 0 1px var(--accent);
}

/* ================================================================ лайтбокс */
.lightbox {
  position: relative;
  width: min(1200px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0;
  max-height: calc(var(--vh) - 48px - var(--safe-top) - var(--safe-bottom));
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  overflow: hidden;
}
.lightbox-media {
  background: #05070c;
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 10px;
}
.lightbox-media img,
.lightbox-media video {
  max-width: 100%;
  max-height: calc(var(--vh) - 88px - var(--safe-top) - var(--safe-bottom));
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(6, 8, 14, 0.72);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.lightbox-close:hover {
  background: var(--accent);
}
.lightbox-side {
  border-left: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lightbox-side .body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kv {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 11.5px;
}
.kv dt {
  color: var(--text-faint);
}
.kv dd {
  margin: 0;
  color: var(--text-dim);
  word-break: break-word;
}
.kv dd.mono {
  font-family: var(--mono);
  font-size: 11px;
}

.prompt-box {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--bg-soft);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
  max-height: 160px;
  overflow-y: auto;
}

/* ================================================================ тосты */
.toast-host {
  position: fixed;
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 260px;
  max-width: 380px;
  display: flex;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  line-height: 1.5;
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.toast.is-out {
  animation: toast-out 0.18s ease-in forwards;
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(16px);
  }
}
.toast .bar {
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  flex: 0 0 auto;
}
.toast.is-ok .bar {
  background: var(--ok);
}
.toast.is-err .bar {
  background: var(--err);
}
.toast .text {
  flex: 1;
  min-width: 0;
}
.toast .text strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12.5px;
}
.toast .text span {
  color: var(--text-dim);
  word-break: break-word;
}

/* ================================================================== вход */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right))
    calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
  background: var(--bg);
}

.auth-card {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 4px;
}
.auth-brand strong {
  display: block;
  font-size: 14px;
}
.auth-brand span {
  font-size: 11.5px;
  color: var(--text-faint);
}
.auth-error:empty {
  display: none;
}
.auth-error {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.1);
  color: var(--err);
  font-size: 12px;
  line-height: 1.45;
}

/* ============================================ предупреждение при входе */
.notice-overlay {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right))
    calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
  background: rgba(4, 6, 11, 0.78);
  backdrop-filter: blur(8px);
  animation: notice-in 0.22s ease-out;
}
.notice-overlay.is-out {
  animation: notice-out 0.16s ease-in forwards;
}
@keyframes notice-in {
  from {
    opacity: 0;
  }
}
@keyframes notice-out {
  to {
    opacity: 0;
  }
}

.notice-card {
  width: min(480px, 100%);
  max-height: calc(var(--vh) - 48px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  animation: notice-rise 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes notice-rise {
  from {
    transform: translateY(12px) scale(0.985);
    opacity: 0;
  }
}

.notice-head {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}
.notice-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), #b06cff 55%, var(--accent-2));
  box-shadow: 0 8px 20px rgba(124, 92, 255, 0.34);
}
.notice-head strong {
  display: block;
  font-size: 16px;
  letter-spacing: 0.1px;
}
.notice-head span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}

.notice-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.notice-list li {
  display: flex;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.14s;
}
.notice-list li:hover {
  background: var(--bg-soft);
}
.notice-list .ico {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-2);
}
.notice-list b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}
.notice-list p {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-dim);
}

#user-chip .chip-btn .who {
  color: var(--text);
  font-weight: 500;
}
#user-chip .chip-btn .sep {
  opacity: 0.4;
}
#user-chip .chip-btn.is-empty {
  border-color: rgba(251, 113, 133, 0.5);
  color: var(--err);
}

/* ======================================================== учётные записи */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.user-row.is-off {
  opacity: 0.55;
}
.user-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.user-main strong {
  font-size: 13px;
}
.user-spend {
  font-size: 12px;
  white-space: nowrap;
}
.perm-group {
  display: inline-flex;
  gap: 4px;
  margin-left: 2px;
}
.perm-group .chip {
  padding: 2px 8px;
  font-size: 11px;
}
/* Запрещённая возможность гасится, чтобы разница читалась с одного взгляда. */
.perm-group .chip:not(.is-active) {
  opacity: 0.45;
  text-decoration: line-through;
}
.user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 720px) {
  .user-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* =========================================================== drag overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  background: rgba(6, 8, 14, 0.78);
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.drop-overlay[hidden] {
  display: none;
}
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 38px 52px;
  border: 2px dashed var(--accent-line);
  border-radius: 20px;
  color: var(--text);
  background: var(--accent-soft);
}
.drop-overlay-inner p {
  margin: 0;
  font-size: 14px;
}

/* ================================================================ утилиты */
.spacer {
  margin-left: auto;
}
.mono {
  font-family: var(--mono);
}
.muted {
  color: var(--text-faint);
}
.nowrap {
  white-space: nowrap;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.row.is-tight {
  gap: 6px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

details.adv > summary {
  cursor: pointer;
  list-style: none;
  font-size: 11.5px;
  color: var(--text-dim);
  padding: 4px 0;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
details.adv > summary::-webkit-details-marker {
  display: none;
}
details.adv > summary::before {
  content: '▸';
  font-size: 10px;
  transition: transform 0.14s;
}
details.adv[open] > summary::before {
  transform: rotate(90deg);
}
details.adv > .adv-body {
  padding-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================================= адаптив */
@media (max-width: 1180px) {
  :root {
    --sidebar-w: 340px;
  }
  .lightbox {
    grid-template-columns: minmax(0, 1fr);
  }
  .lightbox-side {
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    max-height: 40vh;
  }
}

/* ===================================================== телефон и планшет */
/* Одна колонка, страница прокручивается целиком: шапка прилипает сверху,
   вкладки — панель снизу, как в приложениях iPhone. Панель запуска держится
   над вкладками, пока на экране форма. На компьютере ничего не меняется. */
@media (max-width: 900px) {
  :root {
    --tabbar-h: 56px;
  }
  body {
    overflow: auto;
  }
  .app-shell {
    height: auto;
    min-height: var(--vh);
    padding: 0 var(--safe-right) calc(var(--tabbar-h) + var(--safe-bottom)) var(--safe-left);
  }

  /* ------------------------------------------------------------ шапка */
  .topbar {
    position: sticky;
    top: 0;
    height: auto;
    gap: 10px;
    padding: calc(var(--safe-top) + 8px) 12px 8px;
    background: var(--bg-elev);
    /* С backdrop-filter шапка стала бы контейнером для position: fixed,
       и панель вкладок прилипла бы к ней, а не к низу экрана. */
    backdrop-filter: none;
  }
  .brand {
    min-width: 0;
  }
  .brand-text {
    display: none;
  }
  .topbar-right {
    gap: 6px;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
  }
  .chip-btn {
    height: 36px;
    padding: 0 11px;
  }
  /* Учётка — значком: имя и лимит открываются по нажатию. */
  #user-chip .chip-btn {
    width: 36px;
    padding: 0;
    justify-content: center;
    gap: 0;
    font-size: 0;
  }
  #user-chip .chip-btn::before {
    content: '';
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: var(--icon-user) center / contain no-repeat;
    mask: var(--icon-user) center / contain no-repeat;
  }

  /* --------------------------------------------------- вкладки снизу */
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    gap: 0;
    padding: 0 max(4px, var(--safe-right)) var(--safe-bottom) max(4px, var(--safe-left));
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    /* Сплошной фон: с полупрозрачным сквозь панель просвечивает форма, а
       размытие под ней WebKit рисует не везде. */
    background: var(--bg-elev);
  }
  .tab {
    position: relative;
    flex: 1;
    height: var(--tabbar-h);
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    border-radius: 0;
    font-size: 10.5px;
  }
  .tab svg {
    width: 23px;
    height: 23px;
    opacity: 1;
  }
  .tab.is-active {
    background: transparent;
    box-shadow: none;
    color: var(--accent);
  }
  .tab-badge {
    position: absolute;
    top: 5px;
    left: calc(50% + 7px);
    line-height: 17px;
  }

  /* ------------------------------ рабочая зона без внутренних прокруток */
  .workspace {
    flex: none;
    position: static;
  }
  .panel-view,
  .panel-view.is-wide {
    position: static;
    display: none;
  }
  .panel-view.is-active {
    display: block;
  }
  .controls {
    border-right: 0;
    background: transparent;
    overflow: visible;
  }
  .controls-scroll {
    overflow: visible;
    padding: 12px 12px 6px;
    gap: 10px;
  }
  .stage {
    overflow: visible;
    padding: 16px 12px 18px;
    /* При прокрутке к результатам их заголовок не должен уйти под шапку. */
    scroll-margin-top: calc(var(--safe-top) + 52px);
  }
  .empty {
    min-height: 200px;
    padding: 28px 18px;
  }

  /* Запуск прилипает над вкладками, пока на экране форма: цена слева, кнопка справа. */
  .launch {
    position: sticky;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom));
    z-index: 20;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-elev);
    box-shadow: none;
  }
  .launch .estimate {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    gap: 0 6px;
    font-size: 11px;
  }
  .launch .estimate > span:first-child {
    flex-basis: 100%;
    color: var(--text-faint);
  }
  .launch .estimate .spacer,
  .launch .estimate .muted.mono {
    display: none;
  }
  .launch .estimate .price {
    font-size: 16px;
  }
  .launch .btn.is-block {
    width: auto;
    flex: 0 0 auto;
    padding: 12px 18px;
    font-size: 14px;
  }

  /* --------------------------------------------- пальцу нужно место */
  .seg button {
    padding: 9px 4px;
    font-size: 13px;
  }
  .chip {
    padding: 8px 12px;
    font-size: 13px;
  }
  .btn.is-sm {
    padding: 8px 12px;
    font-size: 12.5px;
  }
  .slot {
    min-height: 120px;
  }
  textarea {
    min-height: 120px;
  }
  /* Как в приложении: без серой вспышки при касании, двойное касание не
     увеличивает страницу, а кнопки отвечают на нажатие. */
  html {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .btn:active:not(:disabled),
  .chip:active:not(:disabled),
  .seg button:active:not(:disabled),
  .icon-btn:active,
  .chip-btn:active {
    transform: scale(0.96);
  }
  .tab:active {
    opacity: 0.6;
  }
  .tabs,
  .btn,
  .chip,
  .seg {
    -webkit-user-select: none;
    user-select: none;
  }
  /* Описание модели из каталога бывает на полэкрана — хватит трёх строк. */
  .caps > .hint {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* ---------------------------------- выбор модели — шторка снизу */
  .model-menu,
  .model-menu.is-up {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: min(78vh, calc(var(--vh) - var(--safe-top) - 40px));
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    padding-bottom: var(--safe-bottom);
    box-shadow: 0 0 0 100vmax rgba(4, 6, 11, 0.62);
  }
  .model-menu .search {
    padding: 12px;
  }
  .model-option {
    padding: 11px 9px;
  }

  /* ------------------ результаты и галерея: две колонки, действия — в лайтбоксе */
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .media-frame {
    aspect-ratio: 1;
  }
  .media-frame img,
  .media-frame video {
    object-fit: cover;
  }
  .media-frame .badge {
    top: 6px;
    left: 6px;
    font-size: 9px;
    padding: 2px 6px;
  }
  .media-frame .fav:not(.is-on) {
    display: none;
  }
  .media-body {
    padding: 8px 9px 9px;
    gap: 4px;
  }
  .media-body .prompt {
    font-size: 11.5px;
    line-height: 1.4;
  }
  /* Модель — первой строкой, цена и время — второй: в узкой карточке
     в одну строку они не помещаются. */
  .media-body .meta-row {
    flex-wrap: wrap;
    gap: 1px 8px;
  }
  .media-body .meta-row > .nowrap {
    flex: 1 1 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .media-body .meta-row > .spacer {
    display: none;
  }
  .media-actions {
    display: none;
  }

  /* Поиск — на всю ширину, чипы фильтров листаются вбок одной строкой. */
  .filter-bar {
    gap: 10px;
  }
  .filter-bar input[type='search'] {
    order: -1;
    width: 100%;
  }
  .filter-bar > .spacer {
    display: none;
  }
  .filter-chips {
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -12px;
    padding: 0 12px;
    scrollbar-width: none;
  }
  .filter-chips::-webkit-scrollbar {
    display: none;
  }
  .filter-chips .chip {
    flex: 0 0 auto;
  }

  /* ---------------------------------------------------------- очередь */
  .job {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    align-items: start;
  }
  .job-thumb {
    width: 60px;
    height: 60px;
  }
  .job-main .prompt {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .job-side {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }

  /* ------------------------------------------------- окна — шторки снизу */
  .modal-host {
    place-items: end stretch;
    padding: calc(var(--safe-top) + 12px) 0 0;
  }
  .modal,
  .modal.is-narrow {
    width: 100%;
    max-height: calc(var(--vh) - var(--safe-top) - 12px);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
  }
  .modal-body {
    padding: 14px;
  }
  .modal-body:last-child {
    padding-bottom: calc(16px + var(--safe-bottom));
  }
  .modal-foot {
    flex-wrap: wrap;
    padding: 10px 14px calc(10px + var(--safe-bottom));
  }
  .modal-foot > .hint {
    flex: 1 1 100%;
  }
  .modal-foot > .spacer {
    display: none;
  }
  .modal-foot > .btn {
    flex: 1 1 auto;
  }

  /* ----------------------------------------------- лайтбокс — на весь экран */
  .modal-host:has(> .lightbox) {
    place-items: stretch;
    padding: 0;
    background: #05070c;
  }
  .lightbox {
    width: 100%;
    height: var(--vh);
    max-height: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    border: 0;
    border-radius: 0;
  }
  .lightbox-media {
    min-height: 0;
    padding: calc(var(--safe-top) + 52px) 0 10px;
  }
  .lightbox-media img,
  .lightbox-media video {
    width: 100%;
    max-height: 50vh;
  }
  .lightbox-side {
    max-height: none;
  }
  .lightbox-side .body {
    padding: 14px 14px calc(18px + var(--safe-bottom));
  }
  /* Действия — сразу под роликом, подробности — ниже. */
  .lightbox-side .btn-row {
    order: -1;
  }
  .lightbox-close {
    top: calc(var(--safe-top) + 8px);
    right: calc(12px + var(--safe-right));
  }

  /* ------------------------------------------- уведомления — сверху */
  .toast-host {
    top: calc(var(--safe-top) + 8px);
    bottom: auto;
    left: calc(10px + var(--safe-left));
    right: calc(10px + var(--safe-right));
  }
  .toast {
    min-width: 0;
    max-width: none;
  }

  /* ------------------------------ журнал: время, уровень, источник — строкой, текст — под ними */
  .log-row {
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 2px 8px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--line-soft);
  }
  .log-row .msg {
    grid-column: 1 / -1;
  }
  .log-row .tag {
    justify-self: start;
  }

  /* ---------------------------------------------------- редактор кадра */
  .editor-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .editor-canvas-wrap {
    min-height: 240px;
  }
  .editor-canvas-wrap canvas {
    max-height: 46vh;
  }
  .editor-side {
    max-height: none;
    overflow: visible;
  }
}
