/* ==========================================================================
   TOOL REDESIGN — Dark glassmorphism (2026)
   Главный инструмент генерации: выбор модели (каталог) + панель + результат.
   Подключается ПОСЛЕ styles.css, поэтому переопределяет точечно.
   ========================================================================== */

:root {
  --tr-accent: #8b5cf6;
  --tr-accent-2: #6366f1;
  --tr-accent-3: #06b6d4;
  --tr-glass: rgba(18, 25, 42, .55);
  --tr-glass-strong: rgba(15, 20, 34, .82);
  --tr-border: rgba(139, 92, 246, .22);
  --tr-border-hover: rgba(139, 92, 246, .55);
  --tr-glow: 0 0 0 1px rgba(139,92,246,.18), 0 18px 50px rgba(8,10,20,.55);
  --tr-glow-hover: 0 0 0 1px rgba(139,92,246,.45), 0 24px 70px rgba(139,92,246,.22);
}

/* --------------------------------------------------------------------------
   MODEL PICKER — премиум-карточка текущей модели
   (базовые правила; финальный полиш ниже в блоке POLISH v4)
   -------------------------------------------------------------------------- */
.model-picker {
  margin: 4px 0 22px;
}

.model-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 20px;
  cursor: pointer;
  text-align: left;
  color: #e5e7eb;
  background:
    linear-gradient(135deg, rgba(139,92,246,.10), rgba(99,102,241,.06)),
    var(--tr-glass-strong);
  border: 1px solid var(--tr-border);
  box-shadow: var(--tr-glow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color .25s ease, box-shadow .25s ease, transform .2s ease;
}

.model-trigger:hover {
  border-color: var(--tr-border-hover);
  box-shadow: var(--tr-glow-hover);
  transform: translateY(-1px);
}

.model-trigger__media {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 0 0 1px rgba(139,92,246,.3), 0 6px 18px rgba(0,0,0,.4);
}
.model-trigger__media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.model-trigger__info { flex: 1; min-width: 0; }
.model-trigger__overline {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #8b93a8;
  margin-bottom: 3px;
}
.model-trigger__name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  color: #f4f2ff;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.model-trigger__desc {
  display: block;
  font-size: 12.5px;
  color: #94a3b8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-trigger__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.model-trigger__badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  letter-spacing: .02em;
}
.model-trigger__badge[data-badge="free"] {
  color: #d1fae5;
  background: linear-gradient(135deg, rgba(34,197,94,.9), rgba(22,163,74,.9));
  box-shadow: 0 0 14px rgba(34,197,94,.35);
}
.model-trigger__badge[data-badge="pro"] {
  color: #e0e7ff;
  background: linear-gradient(135deg, rgba(99,102,241,.95), rgba(79,70,229,.95));
  box-shadow: 0 0 14px rgba(99,102,241,.4);
}
.model-trigger__badge[data-badge="premium"] {
  color: #fdf4ff;
  background: linear-gradient(135deg, rgba(168,85,247,.95), rgba(139,92,246,.95));
  box-shadow: 0 0 16px rgba(168,85,247,.45);
}

.model-trigger__chevron {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  color: #a78bfa;
  transition: transform .25s ease;
}
.model-trigger__chevron svg { width: 100%; height: 100%; }
.model-trigger[aria-expanded="true"] .model-trigger__chevron { transform: rotate(180deg); }

@media (max-width: 560px) {
  .model-trigger__desc { display: none; }
}

/* --------------------------------------------------------------------------
   MODEL CATALOG — полноэкранная модалка с каталогом нейросетей
   -------------------------------------------------------------------------- */
body.model-catalog-open { overflow: hidden; }

.model-catalog {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 40px);
}
.model-catalog[hidden] { display: none; }

.model-catalog__overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(139,92,246,.18), transparent 60%),
              rgba(6, 9, 18, .72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity .22s ease;
}
.model-catalog.is-open .model-catalog__overlay { opacity: 1; }

.model-catalog__panel {
  position: relative;
  width: min(1040px, 100%);
  max-height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  border-radius: 26px;
  background:
    radial-gradient(ellipse 700px 400px at 50% 0%, rgba(139,92,246,.16), transparent),
    linear-gradient(160deg, rgba(21,29,48,.96), rgba(13,18,30,.98));
  border: 1px solid var(--tr-border);
  box-shadow: 0 40px 120px rgba(0,0,0,.6), 0 0 0 1px rgba(139,92,246,.14) inset;
  overflow: hidden;
  transform: translateY(16px) scale(.98);
  opacity: 0;
  transition: transform .26s cubic-bezier(.2,.9,.3,1), opacity .22s ease;
}
.model-catalog.is-open .model-catalog__panel { transform: translateY(0) scale(1); opacity: 1; }

.model-catalog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px 10px;
}
.model-catalog__heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}
.model-catalog__title {
  margin: 0;
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 800;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* Счётчик теперь inline рядом с заголовком (не отдельной строкой) — экономит вертикаль. */
.model-catalog__subtitle { margin: 0; font-size: 13px; color: #94a3b8; white-space: nowrap; }

.model-catalog__close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #cbd5e1;
  background: rgba(148,163,184,.08);
  border: 1px solid rgba(148,163,184,.18);
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.model-catalog__close svg { width: 20px; height: 20px; }
.model-catalog__close:hover { background: rgba(239,68,68,.18); color: #fecaca; }

.model-catalog__search {
  position: relative;
  margin: 2px 22px 10px;
}
.model-catalog__search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: #7c8699;
  pointer-events: none;
}
.model-catalog__search-input {
  width: 100%;
  height: 42px;
  padding: 0 16px 0 42px;
  border-radius: 12px;
  color: #e5e7eb;
  font-size: 15px;
  background: rgba(10,14,24,.7);
  border: 1px solid rgba(139,92,246,.22);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.model-catalog__search-input::placeholder { color: #64748b; }
.model-catalog__search-input:focus {
  border-color: rgba(139,92,246,.6);
  box-shadow: 0 0 0 4px rgba(139,92,246,.14);
}

/* ---- Строка фильтров: дропдауны + чипы в одну линию (компактная панель) ---- */
.model-catalog__filterbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px 12px;
  min-width: 0;
}
/* Чипы-категории: занимают остаток строки, при нехватке места — горизонтальный
   скролл одной лентой (а не перенос в несколько рядов → экономит вертикаль). */
.model-catalog__tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 7px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
          mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
}
.model-catalog__tabs::-webkit-scrollbar { display: none; }
.model-catalog__tab {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  color: #a9b2c4;
  background: rgba(148,163,184,.07);
  border: 1px solid rgba(148,163,184,.15);
  transition: all .2s ease;
}
.model-catalog__tab:hover { color: #e5e7eb; border-color: rgba(139,92,246,.4); }
.model-catalog__tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, rgba(139,92,246,.9), rgba(99,102,241,.9));
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(139,92,246,.4);
}
.model-catalog__tab-count {
  font-size: 11.5px;
  font-weight: 700;
  opacity: .72;
  margin-left: 7px;
}

/* ---- Catalog controls (провайдер + сортировка) ----
   Внутри .model-catalog__filterbar: два компактных дропдауна фикс-ширины слева,
   без верхних лейблов (значение селекта самодостаточно). ---- */
.model-catalog__controls {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}
.model-catalog__control {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
/* Лейблы ПРОВАЙДЕР/СОРТИРОВКА скрыты визуально (a11y — через aria-label у select) */
.model-catalog__control-label {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.model-catalog__select { position: relative; width: 168px; max-width: 42vw; }

/* --- Fallback: нативный <select> (до JS-улучшения или если JS не отработал) --- */
.model-catalog__select-native {
  width: 100%;
  height: 36px;
  padding: 0 34px 0 13px;
  border-radius: 11px;
  color: #e5e7eb;
  font-size: 13.5px;
  font-weight: 600;
  background: rgba(10,14,24,.7);
  border: 1px solid rgba(139,92,246,.22);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.model-catalog__select-native:hover { border-color: rgba(139,92,246,.4); }
.model-catalog__select-native:focus {
  border-color: rgba(139,92,246,.6);
  box-shadow: 0 0 0 4px rgba(139,92,246,.14);
}
.model-catalog__select-native option { background: #0d121e; color: #e5e7eb; }
/* Стрелка fallback-селекта (пока JS не улучшил контрол) */
.model-catalog__select:not(.model-catalog__select--enhanced)::after {
  content: "";
  position: absolute;
  right: 15px; top: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid #8b93a7;
  border-bottom: 2px solid #8b93a7;
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

/* --- Enhanced: кастомный дропдаун (JS) --- */
.model-catalog__select--enhanced .model-catalog__select-native {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}
.model-catalog__select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 11px 0 13px;
  font-size: 13.5px;
  font-weight: 600;
  color: #e5e7eb;
  background: rgba(10,14,24,.7);
  border: 1px solid rgba(139,92,246,.22);
  border-radius: 12px;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  transition: border-color .2s ease, box-shadow .2s ease, color .2s ease;
}
.model-catalog__select-trigger:hover { border-color: rgba(139,92,246,.4); }
.model-catalog__select-trigger:focus-visible {
  border-color: rgba(139,92,246,.6);
  box-shadow: 0 0 0 4px rgba(139,92,246,.14);
}
.model-catalog__select.is-open .model-catalog__select-trigger {
  border-color: rgba(139,92,246,.6);
  box-shadow: 0 0 0 4px rgba(139,92,246,.14);
}
.model-catalog__select-value { overflow: hidden; text-overflow: ellipsis; }
.model-catalog__select-chevron {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  color: #8b93a7;
  transition: transform .22s ease, color .2s ease;
}
.model-catalog__select.is-open .model-catalog__select-chevron { transform: rotate(180deg); color: #c4b5fd; }

/* Плавающая панель (position:fixed — координаты ставит JS) */
.model-catalog__select-panel {
  position: fixed;
  z-index: 10020;
  max-height: min(320px, 60vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  background: linear-gradient(160deg, rgba(21,29,48,.98), rgba(13,18,30,.99));
  border: 1px solid rgba(139,92,246,.3);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(5,7,15,.6), 0 0 0 1px rgba(139,92,246,.14) inset;
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  transform-origin: top;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,92,246,.5) transparent;
}
.model-catalog__select-panel::-webkit-scrollbar { width: 8px; }
.model-catalog__select-panel::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,.45);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.model-catalog__select-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.model-catalog__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: #cbd5e1;
  border-radius: 9px;
  cursor: pointer;
  outline: none;
  transition: background .15s ease, color .15s ease;
}
.model-catalog__option:hover,
.model-catalog__option:focus-visible { background: rgba(139,92,246,.16); color: #fff; }
.model-catalog__option-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-catalog__option-check {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  color: #c4b5fd;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .15s ease, transform .15s ease;
}
.model-catalog__option.is-selected {
  color: #fff;
  background: linear-gradient(135deg, rgba(139,92,246,.24), rgba(99,102,241,.22));
}
.model-catalog__option.is-selected .model-catalog__option-check { opacity: 1; transform: scale(1); }

.model-catalog__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  /* Карточки в одном ряду — одинаковой высоты (явно, не полагаясь на normal). */
  align-items: stretch;
  gap: 16px;
  padding: 2px 22px 24px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,92,246,.5) transparent;
}
.model-catalog__grid::-webkit-scrollbar { width: 8px; }
.model-catalog__grid::-webkit-scrollbar-thumb { background: rgba(139,92,246,.4); border-radius: 8px; }

.model-catalog__empty {
  padding: 40px 26px 46px;
  text-align: center;
  color: #94a3b8;
  font-size: 15px;
}
/* ---- Catalog card ----
   Карточка — <div role="button"> (не <button>): кнопка-контейнер в Chromium
   не растягивается как flex/grid-элемент и схлопывалась, из-за чего раньше
   стоял костыль display:block + height:max-content — он фиксировал высоту
   строго по контенту и ломал выравнивание высот в ряду (карточки с разным
   числом чипов / строк названия выходили разной высоты).
   Теперь flex-колонка + height:100%: грид-ячейки в ряду растягиваются
   одинаково (align-items:stretch по умолчанию), body тянется (flex:1), а
   метры .mc-card__stats прижаты к низу (margin-top:auto) — карточки ровные. */
.mc-card {
  display: flex;
  flex-direction: column;
  height: auto;
  width: 100%;
  /* min-width:0 обязателен: иначе flex/grid-элемент распирается min-content
     содержимого (длинные слова, чипы, метры) и колонки 1fr раздуваются сверх
     ширины грида → горизонтальный скролл. */
  min-width: 0;
  text-align: left;
  cursor: pointer;
  padding: 0;
  border-radius: 18px;
  /* overflow:clip (а не hidden): hidden вместе с aspect-ratio-превью внутри
     flex-колонки в grid-треке auto-высоты вызывал цикл измерения и трек
     схлопывался до ~14px. clip скругляет углы так же, но не ломает расчёт высоты. */
  overflow: clip;
  color: #e5e7eb;
  background: rgba(13,18,30,.75);
  border: 1px solid rgba(148,163,184,.14);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.mc-card:hover {
  transform: translateY(-4px);
  border-color: var(--tr-border-hover);
  box-shadow: 0 18px 40px rgba(0,0,0,.5), 0 0 24px rgba(139,92,246,.25);
}
.mc-card.is-active {
  border-color: rgba(139,92,246,.75);
  box-shadow: 0 0 0 1px rgba(139,92,246,.6), 0 18px 44px rgba(139,92,246,.3);
}

/* ---- Media (превью + оверлеи) ---- */
.mc-card__media {
  position: relative;
  display: block;
  flex: 0 0 auto;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #0f1726;
}
.mc-card__media img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform .4s ease;
}
.mc-card:hover .mc-card__media img { transform: scale(1.05); }
.mc-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(10,13,22,.85) 100%);
  pointer-events: none;
}

/* Бейдж доступа (с иконкой) */
.mc-card__badge {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .03em;
  padding: 5px 11px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.mc-card__badge svg { width: 13px; height: 13px; flex: 0 0 auto; }
.mc-card__badge[data-badge="free"]    { color: #052e16; background: rgba(74,222,128,.95); }
.mc-card__badge[data-badge="pro"]     { color: #e0e7ff; background: linear-gradient(135deg, rgba(99,102,241,.95), rgba(79,70,229,.95)); }
.mc-card__badge[data-badge="premium"] { color: #fdf4ff; background: linear-gradient(135deg, rgba(236,72,153,.95), rgba(168,85,247,.95)); }

/* Тип-пилюля (text→фото / референс / фото→видео / вектор) */
.mc-type-pill {
  position: absolute;
  left: 12px; bottom: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  background: rgba(10,13,22,.6);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  backdrop-filter: blur(6px);
}
.mc-type-pill__dot { width: 7px; height: 7px; border-radius: 50%; background: #a78bfa; }
.mc-type-pill[data-task="text-to-image"]  .mc-type-pill__dot { background: #38bdf8; }
.mc-type-pill[data-task="image-editing"]  .mc-type-pill__dot { background: #a78bfa; }
.mc-type-pill[data-task="image-to-video"] .mc-type-pill__dot { background: #f472b6; }
.mc-type-pill[data-task="vector"]         .mc-type-pill__dot { background: #34d399; }

.mc-card__tick {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 2;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  background: var(--tr-accent);
  box-shadow: 0 4px 14px rgba(139,92,246,.6);
}
.mc-card__tick svg { width: 16px; height: 16px; }

.mc-card__lock {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: #e9d5ff;
  background: rgba(10,8,20,.55);
  backdrop-filter: blur(2px);
}
.mc-card__lock svg { width: 30px; height: 30px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.6)); }
.mc-card.is-locked .mc-card__media img { filter: grayscale(.4) brightness(.7); }

/* ---- Body ---- */
.mc-card__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  gap: 10px;
  padding: 14px 15px 16px;
}
.mc-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.mc-card__headmain { min-width: 0; }
.mc-card__name {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.2;
  color: #f1f5f9;
  /* Длинные названия/слова переносятся, а не распирают колонку. */
  overflow-wrap: anywhere;
}
.mc-card__provider {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: #64748b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mc-card__price {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  color: #f1f5f9;
  background: rgba(139,92,246,.12);
  border: 1px solid rgba(139,92,246,.28);
  border-radius: 999px;
  white-space: nowrap;
}
.mc-card__price svg { width: 13px; height: 13px; color: #f472b6; flex: 0 0 auto; }
.mc-card__price--free {
  color: #86efac;
  background: rgba(74,222,128,.12);
  border-color: rgba(74,222,128,.28);
}
.mc-card__desc {
  display: block;
  font-size: 13px;
  line-height: 1.5;
  color: #94a3b8;
  /* Длинные слова переносятся, а не распирают колонку (главный источник
     раздувания min-content после перехода карточки на flex). */
  overflow-wrap: anywhere;
}

/* Возможности */
.mc-caps { display: flex; flex-wrap: wrap; gap: 6px; }
.mc-cap {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(139,92,246,.10);
  border: 1px solid rgba(139,92,246,.22);
  border-radius: 7px;
}
.mc-cap--more {
  color: #f472b6;
  background: rgba(236,72,153,.10);
  border-color: rgba(236,72,153,.28);
}

/* Сильные стороны */
.mc-card__best {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #94a3b8;
}
.mc-card__best svg {
  flex: 0 0 auto;
  width: 15px; height: 15px;
  margin-top: 1px;
  color: #f472b6;
}

/* Метры скорость / качество */
.mc-card__stats {
  display: flex;
  gap: 18px;
  padding-top: 10px;
  margin-top: auto;
  border-top: 1px solid rgba(148,163,184,.14);
}
.mc-card__stat {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
}
.mc-card__stat-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #64748b;
}
.mc-meter { display: inline-flex; gap: 4px; }
.mc-meter__dot {
  width: 14px; height: 5px;
  border-radius: 3px;
  background: rgba(148,163,184,.18);
}
.mc-meter__dot.is-on { background: #ec4899; box-shadow: 0 0 8px rgba(236,72,153,.45); }
.mc-card__stat--speed .mc-meter__dot.is-on { background: #22d3ee; box-shadow: 0 0 8px rgba(34,211,238,.45); }

/* (мобильные правила каталога сведены в единый блок ниже — bottom-sheet) */

/* --------------------------------------------------------------------------
   TOOL POLISH — лёгкое усиление панели инструмента в духе glassmorphism
   -------------------------------------------------------------------------- */
.generator-container {
  border-color: var(--tr-border) !important;
}
.generator-container::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 500px 300px at 85% 110%, rgba(6,182,212,.08), transparent);
  z-index: 0;
}
.generator-container > * { position: relative; z-index: 1; }

/* Акцентная подсветка полей при фокусе */
.textarea-enhanced:focus,
.input-enhanced:focus,
.select-enhanced:focus {
  border-color: rgba(139,92,246,.6) !important;
  box-shadow: 0 0 0 4px rgba(139,92,246,.14) !important;
}


/* ==========================================================================
   TOOL UI REDESIGN 2026 — mobile-first контролы инструмента генерации.
   Нативные select остаются в DOM (источник правды), визуально прячутся
   только когда JS готов (html.tool-ui-ready). Progressive enhancement.
   ========================================================================== */

/* Пока JS не готов — показываем нативные контролы, прячем кастомные холсты */
.ratio-tiles,
.segmented { display: none; }
.tool-ui-ready .ratio-tiles { display: grid; }
.tool-ui-ready .segmented { display: inline-flex; }
.tool-ui-ready .tool-native-control {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.tool-controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 4px;
}
.tool-controls__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}

/* --------------------------------------------------------------------------
   RATIO TILES — визуальные плитки соотношения сторон
   -------------------------------------------------------------------------- */
.ratio-tiles {
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 9px;
}
.ratio-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 72px;
  padding: 12px 8px;
  cursor: pointer;
  border-radius: 14px;
  color: #cbd5e1;
  background: rgba(13,18,30,.6);
  border: 1.5px solid rgba(148,163,184,.16);
  transition: border-color .2s ease, background .2s ease, transform .15s ease, color .2s ease;
}
.ratio-tile:hover {
  color: #e5e7eb;
  border-color: rgba(139,92,246,.45);
  transform: translateY(-2px);
}
.ratio-tile__glyph {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  color: #94a3b8;
  transition: color .2s ease;
}
.ratio-tile__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.ratio-tile.is-active {
  color: #fff;
  background:
    linear-gradient(135deg, rgba(139,92,246,.22), rgba(99,102,241,.14)),
    rgba(13,18,30,.6);
  border-color: rgba(139,92,246,.7);
  box-shadow: 0 0 0 1px rgba(139,92,246,.5), 0 10px 26px rgba(139,92,246,.22);
}
.ratio-tile.is-active .ratio-tile__glyph { color: #c4b5fd; }


/* --------------------------------------------------------------------------
   FORMAT SEGMENTED — сегментированный переключатель PNG/JPG/WEBP
   -------------------------------------------------------------------------- */
.segmented {
  width: 100%;
  padding: 3px;
  gap: 3px;
  border-radius: 11px;
  background: rgba(10,14,24,.7);
  border: 1.5px solid rgba(148,163,184,.16);
}
.segmented__item {
  flex: 1;
  min-height: 34px;
  padding: 0 10px;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #9aa6ba;
  background: transparent;
  transition: color .2s ease, background .2s ease, box-shadow .2s ease;
}
.segmented__item:hover { color: #e5e7eb; }
.segmented__item.is-active {
  color: #fff;
  background: linear-gradient(135deg, rgba(139,92,246,.95), rgba(99,102,241,.95));
  box-shadow: 0 6px 16px rgba(139,92,246,.35);
}

/* --------------------------------------------------------------------------
   DIMENSIONS — пара ширина/высота
   -------------------------------------------------------------------------- */
.tool-dimensions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tool-dimensions .input-enhanced:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.tool-dimensions.is-editable .input-enhanced {
  border-color: rgba(139,92,246,.5) !important;
}


/* --------------------------------------------------------------------------
   SLIDERS — градиентная заливка трека для #steps / #cfg (--range-fill от JS)
   -------------------------------------------------------------------------- */
#steps.range-enhanced,
#cfg.range-enhanced {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, #8b5cf6 0%, #6366f1 var(--range-fill, 0%), rgba(148,163,184,.18) var(--range-fill, 0%), rgba(148,163,184,.18) 100%) !important;
  border: none !important;
}
#steps.range-enhanced::-webkit-slider-thumb,
#cfg.range-enhanced::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #8b5cf6;
  box-shadow: 0 2px 10px rgba(139,92,246,.5);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
#steps.range-enhanced::-webkit-slider-thumb:hover,
#cfg.range-enhanced::-webkit-slider-thumb:hover { transform: scale(1.12); }
#steps.range-enhanced::-moz-range-thumb,
#cfg.range-enhanced::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #8b5cf6;
  box-shadow: 0 2px 10px rgba(139,92,246,.5);
  cursor: pointer;
}
#steps.range-enhanced::-moz-range-track,
#cfg.range-enhanced::-moz-range-track { background: transparent; }

/* Значение слайдера как «пилюля» справа в label */
.label-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #c4b5fd;
  background: rgba(139,92,246,.15);
  border: 1px solid rgba(139,92,246,.3);
}


/* --------------------------------------------------------------------------
   GENERATE ACTION — крупная кнопка + счётчик
   -------------------------------------------------------------------------- */
.generator-actions {
  gap: 14px;
}
#generateBtn.button--primary.button--enhanced {
  flex: 1;
  min-height: 56px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .01em;
  border-radius: 16px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 55%, #06b6d4 140%) !important;
  box-shadow: 0 10px 30px rgba(139,92,246,.38), inset 0 1px 0 rgba(255,255,255,.22) !important;
}
#generateBtn.button--primary.button--enhanced:hover {
  box-shadow: 0 14px 40px rgba(139,92,246,.5), inset 0 1px 0 rgba(255,255,255,.28) !important;
}
#generateBtn .button-icon { width: 20px; height: 20px; }

.counter-badge {
  border-radius: 14px;
  background: rgba(139,92,246,.1);
  border: 1px solid rgba(139,92,246,.28);
}

/* --------------------------------------------------------------------------
   RESULT — холст результата
   -------------------------------------------------------------------------- */
.generator-result .output {
  border-radius: 22px !important;
  background:
    radial-gradient(circle at 50% 38%, rgba(139,92,246,.1), transparent 62%),
    repeating-conic-gradient(rgba(148,163,184,.04) 0% 25%, transparent 0% 50%) 50% / 36px 36px,
    linear-gradient(135deg, rgba(15,23,42,.65), rgba(11,18,32,.78)) !important;
}
.generator-result .output__icon {
  animation: trFloat 4s ease-in-out infinite;
}
@keyframes trFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* --------------------------------------------------------------------------
   HISTORY — карточки истории (разметку JS не трогаем)
   -------------------------------------------------------------------------- */
.generation-history { border-radius: 22px; }
.history-card { border-radius: 16px; }


/* ==========================================================================
   MOBILE-FIRST ADAPTATION — упор на телефоны
   ========================================================================== */

/* Планшет и ниже: формат и размеры в одну колонку */
@media (max-width: 860px) {
  .tool-controls__row { grid-template-columns: 1fr; gap: 16px; }
}

/* Телефон */
@media (max-width: 560px) {
  .tool-controls { gap: 16px; }

  /* Плитки соотношений — горизонтальный скролл (swipe), без переноса */
  .ratio-tiles {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 9px;
    padding-bottom: 6px;
    margin: 0 -2px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .ratio-tiles::-webkit-scrollbar { display: none; }
  .ratio-tile {
    flex: 0 0 auto;
    width: 60px;
    min-height: 58px !important;
    scroll-snap-align: start;
  }

  .tool-dimensions { gap: 10px; }

  /* Поля ≥16px чтобы iOS Safari не зумил при фокусе (только реальные input/textarea/select;
     .segmented__item — кнопка, iOS её не зумит, поэтому оставляем компактной) */
  .textarea-enhanced,
  .input-enhanced,
  .select-enhanced { font-size: 16px; }

  #generateBtn.button--primary.button--enhanced { min-height: 54px; }
}

/* ==========================================================================
   MODEL CATALOG — bottom-sheet на телефоне (ты просил хорошую адаптацию)
   ========================================================================== */
@media (max-width: 560px) {
  /* Единый горизонтальный инсет: все зоны (шапка/поиск/контролы/чипы/грид)
     выравниваются по одной вертикали через ОДИН padding — никаких margin,
     чтобы не возникало двойных отступов и перекоса (баг на узких экранах). */
  .model-catalog { --mc-pad: 16px; padding: 0; align-items: stretch; }

  /* Полноэкранный лист: фикс-зона (шапка+поиск+фильтры+чипы) закреплена,
     скроллится ТОЛЬКО грид карточек (flex-column + grid:flex:1/overflow). */
  .model-catalog__panel {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(100%);
  }
  .model-catalog.is-open .model-catalog__panel { transform: translateY(0); }

  /* Шапка: заголовок + крестик по центру базовой линии. Уплотнена, чтобы
     освободить вертикаль под карточки моделей. */
  .model-catalog__header {
    padding: calc(10px + env(safe-area-inset-top, 0px)) var(--mc-pad) 6px;
    align-items: center;
    gap: 12px;
  }
  .model-catalog__title { font-size: 17px; min-width: 0; }
  .model-catalog__subtitle { display: none; }      /* дублирует чип «Все модели N» */
  .model-catalog__search { margin: 0 var(--mc-pad) 8px; }
  .model-catalog__search-input { height: 40px; font-size: 16px; } /* 16px — без авто-зума iOS */

  /* Строка фильтров на мобайле — в колонку: ряд из 2 дропдаунов, ниже лента чипов.
     Так на узком экране ничего не сдавливается, а вертикали тратится минимум. */
  .model-catalog__filterbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 0 var(--mc-pad) 8px;
  }
  /* Контролы: провайдер + сортировка — в два равных столбца на всю ширину */
  .model-catalog__controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .model-catalog__control { flex: initial; min-width: 0; }
  .model-catalog__control-label { display: none; }
  .model-catalog__select { width: auto; max-width: none; }
  .model-catalog__select-native { height: 38px; font-size: 13.5px; }
  .model-catalog__select-trigger { height: 38px; min-width: 0; font-size: 13.5px; }
  /* Значение селекта обязано обрезаться, иначе длинный текст ломает сетку */
  .model-catalog__select-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Чипы категорий — одна горизонтальная лента со скроллом (не переносим в ряды) */
  .model-catalog__tabs {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 0 0 2px;
  }
  .model-catalog__tab {
    padding: 6px 11px;
    font-size: 11.5px;
  }
  .model-catalog__tab-count { margin-left: 4px; font-size: 10px; }

  /* Сетка карточек — 2 колонки; скроллится сам грид (базовый flex:1/overflow).
     minmax(0,1fr), а НЕ 1fr: 1fr = minmax(auto,1fr), где auto-минимум = min-content
     карточки — колонка не может стать уже содержимого и раздувается за ширину
     грида → горизонтальный скролл. minmax(0,...) разрешает колонке ужиматься. */
  .model-catalog__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    padding: 2px var(--mc-pad) calc(22px + env(safe-area-inset-bottom, 0px));
  }

  /* Карточка: ровная высота, тактильный отклик, без залипающего hover */
  .mc-card {
    border-radius: 16px;
  }
  .mc-card:active { transform: scale(.97); }
  .mc-card.is-active { transform: none; }

  /* Компактнее превью — больше моделей на экран */
  .mc-card__media { aspect-ratio: 16 / 10; }

  .mc-card__body {
    padding: 11px 12px 13px;
    gap: 8px;
  }
  .mc-card__headmain { min-width: 0; }
  .mc-card__name {
    font-size: 14.5px;
    overflow-wrap: anywhere;
  }
  .mc-card__provider { font-size: 11px; }
  /* Описание в 2 строки — аккуратная обрезка «…» */
  .mc-card__desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12px;
  }
  /* Сильные стороны прячем на 2-колоночной сетке — карточка не раздувается */
  .mc-card__best { display: none; }
  /* Возможности: не больше одного ряда */
  .mc-caps { max-height: 24px; overflow: hidden; }
  .mc-cap { font-size: 11px; padding: 3px 8px; }
  .mc-card__stats { gap: 14px; padding-top: 9px; }
  .mc-card__stat-label { font-size: 10px; }
  .mc-meter__dot { width: 12px; height: 4px; }

  /* ===== Оверлеи на превью — мелкие и ненавязчивые (иерархия: превью/название/
     цена крупнее, служебные метки мельче), чтобы не перекрывали картинку. ===== */
  .mc-card__badge {
    top: 8px; left: 8px;
    gap: 3px;
    font-size: 9px;
    padding: 3px 6px;
  }
  .mc-card__badge svg { width: 10px; height: 10px; }

  .mc-type-pill {
    left: 8px; bottom: 8px;
    gap: 4px;
    font-size: 9px;
    padding: 3px 6px;
  }
  .mc-type-pill__dot { width: 5px; height: 5px; flex: 0 0 auto; }

  .mc-card__tick {
    top: 8px; right: 8px;
    width: 22px; height: 22px;
  }
  .mc-card__tick svg { width: 13px; height: 13px; }

  .model-catalog__close { width: 44px; height: 44px; }
}

/* Отключаем залипающий hover карточек на тач-устройствах */
@media (hover: none) {
  .mc-card:hover { transform: none; box-shadow: none; }
  .mc-card:hover .mc-card__media img { transform: none; }
  .mc-card.is-active {
    box-shadow: 0 0 0 1px rgba(139,92,246,.6), 0 18px 44px rgba(139,92,246,.3);
  }
}

/* ======= Совсем узкие экраны (≤360px): одна широкая колонка =======
   На 320px две колонки слишком тесные — переходим на 1 колонку с крупным
   превью и бОльшим объёмом текста. Инсет уменьшаем через ту же переменную. */
@media (max-width: 360px) {
  .ratio-tile { width: 56px; }
  .model-catalog { --mc-pad: 14px; }

  /* Одна колонка — карточки во всю ширину (minmax(0,1fr) на случай длинного
     неразрывного контента — колонка не распирается за ширину грида). */
  .model-catalog__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  /* Раз места больше — крупнее превью и текст, возвращаем «сильные стороны» */
  .mc-card__media { aspect-ratio: 16 / 9; }
  .mc-card__name { font-size: 16px; }
  .mc-card__provider { font-size: 12px; }
  .mc-card__desc { -webkit-line-clamp: 3; font-size: 13px; }
  .mc-card__best { display: flex; font-size: 12px; }
  .mc-caps { max-height: none; }

  /* Превью широкое (1 колонка) — оверлеи можно вернуть к читаемому размеру,
     они всё равно займут малую долю картинки и сохранят иерархию. */
  .mc-card__badge { top: 10px; left: 10px; font-size: 10.5px; padding: 4px 9px; }
  .mc-card__badge svg { width: 12px; height: 12px; }
  .mc-type-pill { left: 10px; bottom: 10px; font-size: 10.5px; padding: 4px 8px; }
  .mc-type-pill__dot { width: 7px; height: 7px; }
  .mc-card__tick { top: 10px; right: 10px; width: 26px; height: 26px; }
  .mc-card__tick svg { width: 15px; height: 15px; }

  /* Контролы на 320 остаются в 2 столбца, но текст гарантированно обрезается */
  .model-catalog__tab { padding: 6px 10px; font-size: 11.5px; }
}

/* Ландшафт на телефоне: лист повыше, превью ещё компактнее */
@media (max-width: 920px) and (max-height: 520px) and (orientation: landscape) {
  .model-catalog__panel { max-height: 96dvh; }
  .model-catalog__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mc-card__media { aspect-ratio: 16 / 8; }
}


/* ==========================================================================
   POLISH v2 — премиальная доводка (иконка, плитки, слайдеры, хелперы)
   ========================================================================== */

/* --------------------------------------------------------------------------
   HEADER ICON — премиальная иконка заголовка инструмента
   -------------------------------------------------------------------------- */
.generator-icon {
  width: 58px !important;
  height: 58px !important;
  border-radius: 18px !important;
  background:
    radial-gradient(120% 120% at 28% 20%, rgba(255,255,255,.28), transparent 55%),
    linear-gradient(135deg, #8b5cf6 0%, #6366f1 52%, #06b6d4 128%) !important;
  box-shadow:
    0 10px 28px rgba(99,102,241,.45),
    0 0 0 1px rgba(139,92,246,.45) inset,
    inset 0 1px 0 rgba(255,255,255,.35) !important;
  overflow: visible !important;
}
/* Мягкое внешнее свечение */
.generator-icon::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(139,92,246,.5), rgba(6,182,212,.4));
  filter: blur(14px);
  opacity: .55;
  z-index: -1;
  transition: opacity .3s ease;
}
.generator-icon::before {
  background: linear-gradient(135deg, rgba(255,255,255,.35), transparent 60%) !important;
}
.generator-icon:hover::after { opacity: .9; }
.generator-icon svg {
  width: 30px !important;
  height: 30px !important;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)) !important;
}

/* --------------------------------------------------------------------------
   RATIO TILES v2 — ровные плитки, единая высота, аккуратный глиф
   -------------------------------------------------------------------------- */
.ratio-tile {
  gap: 7px !important;
  min-height: 62px !important;
  padding: 9px 6px !important;
  border-radius: 13px !important;
  border-width: 1.5px !important;
  background: rgba(15,21,34,.55) !important;
}
.ratio-tile__glyph {
  width: 24px !important;
  height: 22px !important;
  color: #aab4c6;
}
.ratio-tile__glyph svg { width: 22px; height: 22px; display: block; }
.ratio-tile__label {
  font-size: 11px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  color: inherit;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ratio-tile:hover {
  background: rgba(22,30,48,.7) !important;
  transform: translateY(-2px);
}
.ratio-tile.is-active {
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(139,92,246,.3), transparent 70%),
    linear-gradient(135deg, rgba(139,92,246,.2), rgba(99,102,241,.12)) !important;
  border-color: rgba(139,92,246,.75) !important;
  box-shadow:
    0 0 0 1px rgba(139,92,246,.55),
    0 8px 22px rgba(139,92,246,.28) !important;
}
.ratio-tile.is-active .ratio-tile__glyph { color: #ddd6fe !important; }


/* --------------------------------------------------------------------------
   SLIDERS v2 — трек «заполняется», край заливки точно под центром ползунка
   (JS считает --range-fill с поправкой на ширину ползунка THUMB=22)
   -------------------------------------------------------------------------- */
#steps.range-enhanced,
#cfg.range-enhanced {
  height: 10px !important;
  margin: 10px 0 6px !important;
  background:
    linear-gradient(90deg,
      #8b5cf6 0%, #6366f1 var(--range-fill, 0%),
      rgba(148,163,184,.16) var(--range-fill, 0%), rgba(148,163,184,.16) 100%) !important;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.35) !important;
}
#steps.range-enhanced::-webkit-slider-thumb,
#cfg.range-enhanced::-webkit-slider-thumb {
  width: 22px !important;
  height: 22px !important;
  background:
    radial-gradient(circle at 35% 30%, #fff, #ede9fe 70%) !important;
  border: 3px solid #8b5cf6 !important;
  box-shadow:
    0 2px 10px rgba(139,92,246,.55),
    0 0 0 4px rgba(139,92,246,.12) !important;
}
#steps.range-enhanced::-moz-range-thumb,
#cfg.range-enhanced::-moz-range-thumb {
  width: 22px !important;
  height: 22px !important;
  background: radial-gradient(circle at 35% 30%, #fff, #ede9fe 70%) !important;
  border: 3px solid #8b5cf6 !important;
  box-shadow:
    0 2px 10px rgba(139,92,246,.55),
    0 0 0 4px rgba(139,92,246,.12) !important;
}

/* --------------------------------------------------------------------------
   HELPERS v3 — «чистая подпись»: без тяжёлой плашки, тонкая акцент-линия слева,
   ровная info-иконка в приглушённом сине-сером тоне. Строго и премиально.
   -------------------------------------------------------------------------- */
.helper-enhanced {
  align-items: center !important;
  gap: 10px !important;
  min-height: 0 !important;
  margin-top: 10px !important;
  padding: 2px 0 2px 14px !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
  letter-spacing: .005em;
  border: 0 !important;
  border-left: 2px solid rgba(139,92,246,.4) !important;
  border-radius: 0 !important;
  background: none !important;
  color: #aab4c6 !important;
}
.helper-icon {
  width: 16px !important;
  height: 16px !important;
  margin-top: 0 !important;
  color: #7f8cab !important;       /* приглушённый сине-серый вместо кричащего неона */
  stroke-width: 1.6 !important;
}

/* Негативный промпт и соседние поля в advanced-сетке — выравнивание верхом */
.advanced-grid { align-items: start; }

/* --------------------------------------------------------------------------
   GENERAL POLISH — единый ритм радиусов/бордеров
   -------------------------------------------------------------------------- */
.textarea-enhanced {
  border-radius: 16px !important;
  border-color: rgba(139,92,246,.22) !important;
  background: rgba(10,14,24,.72) !important;
}
.input-enhanced,
.select-enhanced {
  border-radius: 13px !important;
  border-color: rgba(139,92,246,.22) !important;
  background: rgba(10,14,24,.72) !important;
}
.label-badge {
  border-radius: 999px !important;
}
.advanced-controls {
  border-radius: 18px !important;
  border-width: 1.5px !important;
}


/* ==========================================================================
   POLISH v3 — неоновая шапка (без плашки/иконки), степперы, короткий лейбл
   ========================================================================== */

/* --------------------------------------------------------------------------
   HEADER — удалён из DOM (дублировал hero H1). Прячем остатки на всякий случай.
   Выбор модели теперь оформлен как самостоятельная премиум-карточка
   (см. блок MODEL PICKER выше и POLISH v4 ниже).
   -------------------------------------------------------------------------- */
.generator-header,
.generator-icon { display: none !important; }


/* --------------------------------------------------------------------------
   NUMBER STEPPERS — премиальные −/+ для #widthPx / #heightPx
   -------------------------------------------------------------------------- */
/* Прячем нативные стрелки спинбоксов */
#widthPx::-webkit-outer-spin-button,
#widthPx::-webkit-inner-spin-button,
#heightPx::-webkit-outer-spin-button,
#heightPx::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#widthPx, #heightPx { -moz-appearance: textfield; }

.num-stepper {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
/* Поле ввода внутри степпера — по центру, число всегда видно целиком */
.num-stepper .input-enhanced {
  flex: 1 1 auto;
  min-width: 0;         /* не даём кнопкам распирать контейнер */
  width: 100%;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: .01em;
}
.num-stepper__btn {
  flex: 0 0 auto;
  width: 44px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #c4b5fd;
  border-radius: 13px;
  background:
    linear-gradient(135deg, rgba(139,92,246,.14), rgba(99,102,241,.08)),
    rgba(10,14,24,.72);
  border: 1.5px solid rgba(139,92,246,.28);
  -webkit-tap-highlight-color: transparent;
  transition: color .15s ease, border-color .15s ease, background .15s ease, transform .1s ease, box-shadow .15s ease;
}
/* Hover — только на устройствах с настоящим ховером (не залипает на тач) */
@media (hover: hover) {
  .num-stepper__btn:hover {
    color: #fff;
    border-color: rgba(139,92,246,.6);
    background:
      linear-gradient(135deg, rgba(139,92,246,.3), rgba(99,102,241,.18)),
      rgba(10,14,24,.72);
    box-shadow: 0 6px 16px rgba(139,92,246,.3);
    transform: translateY(-1px);
  }
}
/* Чёткий отклик на нажатие (виден и на тач): подсветка + вдавливание */
.num-stepper__btn:active {
  color: #fff;
  border-color: rgba(139,92,246,.9);
  background:
    linear-gradient(135deg, rgba(139,92,246,.55), rgba(99,102,241,.4)),
    rgba(10,14,24,.72);
  box-shadow: 0 0 0 4px rgba(139,92,246,.2), inset 0 2px 6px rgba(0,0,0,.3);
  transform: scale(.92);
}
.num-stepper__btn svg { width: 18px; height: 18px; display: block; }

/* Заблокированное состояние (не-custom соотношение) */
.num-stepper.is-disabled .num-stepper__btn {
  opacity: .4;
  pointer-events: none;
}
.num-stepper.is-disabled .input-enhanced { opacity: .55; }


/* ==========================================================================
   POLISH v4 — мобильные степперы (значение видно целиком) + адаптив каталога
   ========================================================================== */

/* -- Степперы на телефоне: поле получает приоритет, число всегда целиком -- */
@media (max-width: 560px) {
  /* Формат + размеры уже идут в один столбец (tool-controls__row).
     Внутри .tool-dimensions оставляем 2 колонки (Ширина | Высота),
     но делаем кнопки компактнее и гарантируем ширину поля. */
  .tool-dimensions { gap: 12px; }
  .num-stepper { gap: 6px; }
  .num-stepper__btn { width: 40px; border-radius: 12px; }
  .num-stepper .input-enhanced {
    padding-left: 2px;
    padding-right: 2px;
    font-size: 16px;      /* iOS без зума + крупно */
  }
}

/* Узкие экраны: Ширина и Высота друг под другом — каждому полная ширина,
   значение «1024» гарантированно помещается, кнопки крупные и удобные. */
@media (max-width: 400px) {
  .tool-dimensions { grid-template-columns: 1fr; gap: 12px; }
  .num-stepper { gap: 8px; }
  .num-stepper__btn { width: 48px; }
}


/* --------------------------------------------------------------------------
   REFERENCE UPLOADER — загрузка референс-изображений (features.referenceImage)
   -------------------------------------------------------------------------- */
.reference-field .label-hint {
  margin-left: 8px;
  font-size: 12px;
  color: #8b93a7;
  font-weight: 500;
}
.reference-uploader {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.reference-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px dashed rgba(139, 92, 246, 0.5);
  background: rgba(139, 92, 246, 0.08);
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.reference-add-btn:hover {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.8);
  transform: translateY(-1px);
}
.reference-add-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.reference-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.reference-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(139, 92, 246, 0.35);
  background: #0f1726;
}
.reference-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.reference-thumb__remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.reference-thumb__remove:hover {
  background: rgba(239, 68, 68, 0.9);
}


/* --------------------------------------------------------------------------
   RESOLUTION TILES — выбор разрешения (0.5K / 1K / 2K) для perPixel-моделей
   -------------------------------------------------------------------------- */
.resolution-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.resolution-tile {
  min-width: 68px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.5);
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s;
  text-align: center;
}
.resolution-tile:hover {
  border-color: rgba(139, 92, 246, 0.5);
  transform: translateY(-1px);
}
.resolution-tile.is-active {
  color: #fff;
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(139, 92, 246, 0.3), transparent 70%),
    rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.7);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.5), 0 8px 22px rgba(139, 92, 246, 0.22);
}
.resolution-tile__dims {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: #8b93a7;
  margin-top: 2px;
}


/* ==========================================================================
   POLISH v4 — «дороже и понятнее»: шапка, триггер модели, видео-загрузчик,
   сегменты длительности/качества, ровный крестик удаления.
   ========================================================================== */

/* --- Контейнер: убираем «дыру» сверху (бывший заголовок удалён) --- */
.generator-container { padding-top: 26px !important; }

/* --- Model picker: самостоятельная премиум-карточка текущей модели --- */
.model-picker { margin: 0 0 26px !important; }

.model-trigger {
  position: relative;
  gap: 20px;
  padding: 20px 22px;
  border-radius: 22px;
  border-width: 1.5px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(139,92,246,.15), rgba(99,102,241,.07) 55%, rgba(6,182,212,.05)),
    var(--tr-glass-strong);
}
/* Мягкое верхнее свечение — ощущение «дорогого» стеклянного блока */
.model-trigger::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 0% -20%, rgba(167,139,250,.18), transparent 60%);
  opacity: .9;
}
/* Неоновая акцент-черта слева — проявляется при наведении/фокусе */
.model-trigger::before {
  content: '';
  position: absolute;
  left: 0; top: 16px; bottom: 16px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #a78bfa, #6366f1 55%, #06b6d4);
  box-shadow: 0 0 12px rgba(139,92,246,.7);
  opacity: 0;
  transition: opacity .25s ease;
  z-index: 1;
}
.model-trigger:hover::before,
.model-trigger:focus-visible::before { opacity: .95; }
/* Содержимое — поверх декоративных слоёв */
.model-trigger__media,
.model-trigger__info,
.model-trigger__actions { position: relative; z-index: 1; }

.model-trigger__media {
  width: 70px;
  height: 70px;
  border-radius: 18px;
}
.model-trigger__name { font-size: clamp(15px, 1.2vw + 12px, 18.5px); }
.model-trigger__overline { font-size: 11px; letter-spacing: .16em; white-space: nowrap; }

/* CTA-блок «Сменить ⌄» — явный сигнал кликабельности */
.model-trigger__cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  padding: 7px 12px 7px 14px;
  border-radius: 999px;
  background: rgba(139,92,246,.12);
  border: 1px solid rgba(139,92,246,.28);
  color: #c4b5fd;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.model-trigger__cta-text {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
}
.model-trigger:hover .model-trigger__cta,
.model-trigger:focus-visible .model-trigger__cta {
  background: rgba(139,92,246,.22);
  border-color: rgba(139,92,246,.6);
  color: #e9e3ff;
}
/* Шеврон теперь внутри CTA — переопределяем размеры */
.model-trigger__cta .model-trigger__chevron {
  width: 16px;
  height: 16px;
  color: inherit;
}
.model-trigger[aria-expanded="true"] .model-trigger__cta .model-trigger__chevron {
  transform: rotate(180deg);
}

@media (max-width: 560px) {
  .model-trigger__cta-text { display: none; }         /* на узких — только шеврон */
  .model-trigger__cta { padding: 7px; gap: 0; }
}

/* --- Видео-режим: крупный drag-&-drop загрузчик вместо мелкой кнопки --- */
.reference-field--video .reference-uploader {
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}
/* Кнопка «Загрузить фото» превращается в большую зону на всю ширину */
.reference-field--video .reference-add-btn {
  width: 100%;
  min-height: 132px;
  flex-direction: column;
  gap: 10px;
  padding: 24px 20px;
  border-radius: 18px;
  border: 1.5px dashed rgba(139,92,246,.45);
  background:
    radial-gradient(130% 120% at 50% 0%, rgba(139,92,246,.12), transparent 65%),
    rgba(139,92,246,.05);
  font-size: 15px;
  font-weight: 700;
  color: #d7ccff;
}
.reference-field--video .reference-add-btn:hover {
  border-color: rgba(139,92,246,.75);
  background:
    radial-gradient(130% 120% at 50% 0%, rgba(139,92,246,.2), transparent 65%),
    rgba(139,92,246,.09);
  transform: translateY(-1px);
}
/* Крупная иконка загрузки внутри большой зоны */
.reference-field--video .reference-add-btn svg {
  width: 30px;
  height: 30px;
  opacity: .9;
}
/* Когда фото уже загружено — зона прячется (лимит 1), остаётся превью */
.reference-field--video .reference-add-btn[disabled] {
  display: none;
}
/* Превью первого кадра в видео-режиме — крупнее, на всю ширину */
.reference-field--video .reference-previews { width: 100%; }
.reference-field--video .reference-thumb {
  width: 100%;
  max-width: 260px;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
}

/* --- Видео-сегменты (длительность/качество) в стиле сайта --- */
.video-segmented { flex-wrap: wrap; }
.video-segmented .segmented__item { min-width: 72px; }

/* --- Ровный крестик удаления референса/фото --- */
.reference-thumb__remove {
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: rgba(10,14,24,.78);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background .18s ease, border-color .18s ease, transform .15s ease;
}
.reference-thumb__remove svg { display: block; }
.reference-thumb__remove:hover {
  background: rgba(239,68,68,.92);
  border-color: rgba(239,68,68,.9);
  transform: scale(1.08);
}


/* ==========================================================================
   POLISH v5 — ADAPTIVE: сквозная адаптивность инструмента (320px → desktop)
   Приоритеты: промт просторнее, карточка модели читается, плитки компактнее,
   на телефоне — почти во всю ширину экрана с сохранением окантовки.
   ========================================================================== */

/* --- Промт: главное поле, делаем его просторнее на всех экранах --- */
.textarea-enhanced#prompt,
#prompt.textarea-enhanced { min-height: 168px !important; }

/* ==========================================================================
   ПЛАНШЕТ И НИЖЕ (≤767px)
   ========================================================================== */
@media (max-width: 767px) {
  /* Full-width: гасим горизонтальные отступы Tailwind-обёртки (.px-4/sm:px-6),
     чтобы секция инструмента растянулась почти во всю ширину вьюпорта.
     Боковой зазор ~9px задаём самому контейнеру — окантовка остаётся видна. */
  .workbench.container {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }

  .generator-container {
    margin-left: 9px !important;
    margin-right: 9px !important;
    width: auto !important;
    max-width: none !important;
  }

  /* Промт на планшете/телефоне — не ниже 156px (было 110-120) */
  .textarea-enhanced#prompt,
  #prompt.textarea-enhanced { min-height: 156px !important; }
}

/* Выносим компенсацию padding на внешнюю Tailwind-обёртку (надёжнее :has) */
@media (max-width: 767px) {
  #workbench { margin-left: -16px; margin-right: -16px; }
}
@media (min-width: 640px) and (max-width: 767px) {
  #workbench { margin-left: -24px; margin-right: -24px; }
}

/* ==========================================================================
   ТЕЛЕФОН (≤560px) — перестройка карточки модели и ритма
   ========================================================================== */
@media (max-width: 560px) {
  .generator-container {
    padding: 18px 14px 18px !important;
    border-radius: 18px !important;
    margin-left: 8px !important;
    margin-right: 8px !important;
  }
  #workbench { margin-left: -16px; margin-right: -16px; }

  /* Карточка модели: обложка меньше, контент плотнее, имя читается целиком */
  .model-trigger {
    gap: 13px !important;
    padding: 14px !important;
    border-radius: 18px !important;
  }
  .model-trigger__media {
    width: 54px !important;
    height: 54px !important;
    border-radius: 14px !important;
  }
  .model-trigger__overline { font-size: 10px !important; letter-spacing: .12em !important; }
  .model-trigger__name { font-size: 15.5px !important; -webkit-line-clamp: 2; }
  .model-trigger__actions { gap: 8px !important; }
  .model-trigger__badge { font-size: 10px !important; padding: 4px 9px !important; }

  /* Промт на телефоне — просторный (≥16px шрифт против iOS-зума задаётся выше) */
  .textarea-enhanced#prompt,
  #prompt.textarea-enhanced { min-height: 150px !important; }

  /* Сегменты (формат/видео) — компактнее, перенос при нехватке места */
  .segmented { flex-wrap: wrap; }
  .segmented__item { min-height: 38px; font-size: 13px; }

  /* Разрешение — компактнее, равномерный ряд */
  .resolution-tile {
    min-width: 60px !important;
    padding: 9px 12px !important;
    font-size: 13px !important;
  }
}

/* ==========================================================================
   УЗКИЕ ТЕЛЕФОНЫ (≤400px)
   ========================================================================== */
@media (max-width: 400px) {
  .generator-container {
    padding: 15px 11px 15px !important;
    border-radius: 16px !important;
    margin-left: 7px !important;
    margin-right: 7px !important;
  }
  .model-trigger { gap: 11px !important; padding: 12px !important; }
  .model-trigger__media { width: 48px !important; height: 48px !important; border-radius: 12px !important; }
  .model-trigger__name { font-size: 14.5px !important; }
  .model-trigger__cta { padding: 7px !important; }     /* только шеврон (текст скрыт ≤560) */

  .ratio-tile { width: 54px !important; min-height: 54px !important; }
  .resolution-tile { min-width: 56px !important; padding: 8px 10px !important; }
}

/* ==========================================================================
   МИКРО-ЭКРАНЫ (≤320px)
   ========================================================================== */
@media (max-width: 320px) {
  .generator-container {
    padding: 13px 9px 13px !important;
    margin-left: 6px !important;
    margin-right: 6px !important;
  }
  .model-trigger { gap: 10px !important; padding: 11px !important; }
  .model-trigger__media { width: 44px !important; height: 44px !important; }
  .model-trigger__overline { font-size: 9px !important; }
  .model-trigger__name { font-size: 13.5px !important; }
  .model-trigger__badge { font-size: 9px !important; padding: 3px 7px !important; }

  .textarea-enhanced#prompt,
  #prompt.textarea-enhanced { min-height: 140px !important; }

  .ratio-tile { width: 50px !important; }
  .ratio-tile__label { font-size: 10px !important; }
}


/* ==========================================================================
   POLISH v6 — компактные пропорциональные контролы (формат/размеры/advanced)
   Цель: убрать «выпирающие» крупные элементы, выровнять единый ритм.
   ========================================================================== */

/* --- Лейблы полей: плотнее --- */
.label-enhanced {
  font-size: 13px !important;
  margin-bottom: 6px !important;
}

/* --- Ширина/Высота: инпут и select чуть ниже --- */
.input-enhanced,
.select-enhanced {
  height: 44px !important;
  font-size: 14px !important;
}

/* --- Степперы −/+ : компактнее --- */
.num-stepper { gap: 7px; }
.num-stepper__btn { width: 40px; border-radius: 12px; }
.num-stepper__btn svg { width: 16px; height: 16px; }

/* --- Advanced controls: собраннее --- */
.advanced-controls { margin-top: 18px !important; }
.advanced-controls-summary { padding: 12px 16px !important; }
.advanced-controls-title { font-size: 13.5px !important; }
.advanced-controls-icon { width: 18px !important; height: 18px !important; }
.advanced-controls-content { padding: 16px !important; }
.advanced-grid { gap: 16px !important; }

/* Негативный промпт — поле на 2 строки, не высоченное (база 140px → компактно) */
#negativePrompt.textarea-enhanced { min-height: 84px !important; }

/* --- Слайдеры Steps/CFG: тоньше трек, аккуратнее ползунок --- */
#steps.range-enhanced,
#cfg.range-enhanced {
  height: 8px !important;
  margin: 8px 0 4px !important;
}
#steps.range-enhanced::-webkit-slider-thumb,
#cfg.range-enhanced::-webkit-slider-thumb {
  width: 20px !important;
  height: 20px !important;
}
#steps.range-enhanced::-moz-range-thumb,
#cfg.range-enhanced::-moz-range-thumb {
  width: 20px !important;
  height: 20px !important;
}

/* --- Значение слайдера (пилюля справа в label) --- */
.label-value {
  min-width: 32px !important;
  padding: 2px 9px !important;
  font-size: 11px !important;
}

/* ==========================================================================
   POLISH v6 — адаптив контролов (единый ритм по брейкпоинтам)
   ========================================================================== */
@media (max-width: 560px) {
  /* height сжимаем, но font-size держим 16px — иначе iOS Safari зумит при фокусе */
  .input-enhanced,
  .select-enhanced { height: 42px !important; font-size: 16px !important; }
  .num-stepper__btn { width: 38px !important; }
  .advanced-controls-summary { padding: 11px 14px !important; }
  .advanced-controls-content { padding: 14px !important; }
  .advanced-grid { gap: 14px !important; }
}

@media (max-width: 400px) {
  .segmented__item { min-height: 36px; font-size: 12.5px; }
  .input-enhanced,
  .select-enhanced { height: 40px !important; }
  .num-stepper { gap: 6px; }
  .num-stepper__btn { width: 36px !important; }
  .advanced-controls-title { font-size: 13px !important; }
  .advanced-controls-content { padding: 12px !important; }
}

@media (max-width: 320px) {
  .segmented__item { min-height: 34px; font-size: 12px; }
  .input-enhanced,
  .select-enhanced { height: 38px !important; }   /* font-size оставляем 16px (анти-зум iOS) */
  .num-stepper__btn { width: 34px !important; }
  .num-stepper__btn svg { width: 14px; height: 14px; }
}


/* ==========================================================================
   POLISH v7 — кликабельный результат + обёртка видео + кнопка «развернуть»
   ========================================================================== */
/* Картинка-результат: курсор-лупа, лёгкий отклик на наведение */
.output__image.is-clickable { cursor: zoom-in; transition: filter .2s ease; }
.output__image.is-clickable:hover { filter: brightness(1.04); }

/* Видео: блок результата подстраивается под пропорции ролика, без растяжения.
   Точный px-размер блока и обёртки проставляет JS (renderVideo → sizeVideoWrap) из
   натуральных размеров видео — с клампом по ширине колонки и 72% экрана (без апскейла
   и без горизонтального переполнения на узких экранах).
   Селектор :has() (specificity 0,3,0) перебивает min-height во всех медиа-запросах —
   !important и правка каждого брейкпоинта не нужны. Картинки/плейсхолдер не трогаем. */
.generator-result .output:has(.output__video-wrap) {
  min-height: 0;
  height: auto;
  max-width: 100%;        /* ширину в px задаёт JS; это — страховка от overflow */
  margin-inline: auto;
  padding: 0;
}

/* Обёртка видео: ширину/высоту в px выставляет JS; тут — только клип и фон.
   Фолбэк max-* на случай, если JS не успел проставить размеры. */
.output__video-wrap {
  position: relative;
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 72vh;
  overflow: hidden;       /* клипуем по скруглённому блоку результата */
  border-radius: 20px;
  background: #0b1220;
}
/* Фолбэк-размер, пока JS не проставил ширину/высоту в px (защита от «пустого
   блока»): держим обёртку видимой с разумными пропорциями. Как только JS задаёт
   inline width/height — эти правила им уступают (inline специфичнее). */
.output__video-wrap:not([style*="width"]) {
  width: min(100%, 720px);
  aspect-ratio: 16 / 9;
  min-height: 220px;
}
.output__video-wrap .output__media {
  display: block;
  width: 100%;            /* заполняет обёртку, размер которой = размеру видео */
  height: 100%;
  object-fit: contain;    /* сохраняем пропорции, без растяжения */
  border-radius: 0;       /* радиус задаёт обёртка */
  background: #000;
}
/* Кнопка «на весь экран» поверх видео (правый верхний угол) */
.output__expand-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  cursor: pointer;
  color: #fff;
  background: rgba(10, 14, 24, .62);
  border: 1px solid rgba(255, 255, 255, .18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background .18s ease, border-color .18s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.output__expand-btn:hover {
  background: rgba(139, 92, 246, .5);
  border-color: rgba(139, 92, 246, .7);
}
.output__expand-btn:active { transform: scale(.92); }
.output__expand-btn svg { width: 20px; height: 20px; display: block; }

