:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  /* Рамки были #2a2a2a — 1.34 к фону при норме 3.0 для границ интерфейса
     (WCAG 1.4.11). Из-за этого блоки выглядели «почти без рамок»: на
     скриншотах границы зон не читались вовсе. #5f5f5f даёт ровно 3.0. */
  --border: #5f5f5f;
  /* Внутренние разделители (таблицы, штриховые слоты): #4a4a4a там слишком
     шумно, а прежний #2a2a2a терялся. */
  --border-soft: #333333;
  --text: #e0e0e0;
  /* 5.41 к фону. Ниже опускать нельзя: этим цветом набраны подписи,
     примеры промптов и второстепенные действия. */
  --text-muted: #9a9a9a;
  --text-dim: #5c5c5c;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --error: #ef4444;
  --success: #22c55e;
  /* Высота рабочей зоны: ~56% окна, в пределах 400-560px. Одна на оба
     состояния, чтобы при появлении результата разметка не прыгала. */
  --zone-height: clamp(400px, 56vh, 560px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── App Layout ── */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 0;
}

/* ── Header ── */

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-size: 1.1rem;
  font-weight: 300;
  color: #e2e8f0;
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-id {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
}

.user-id:hover {
  color: var(--text);
}

.balance {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.balance.negative {
  color: var(--error);
}

.topup-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}

.topup-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}

.logout-btn:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ── Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 360px;
  width: 100%;
  margin: 20px;
  position: relative;
}

.modal-card h2 {
  font-size: 1.15rem;
  font-weight: 500;
  margin-bottom: 20px;
  color: var(--text);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 0 12px;
  transition: border-color 0.2s;
}

.modal-input-wrap:focus-within {
  border-color: var(--accent);
}

.modal-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 0;
  font-size: 1.1rem;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.modal-currency {
  color: var(--text-muted);
  font-size: 1rem;
}

.modal-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, #0d9488, #0f766e);
  color: #fff;
  transition: opacity 0.2s;
  margin-top: 4px;
}

.modal-btn:hover {
  opacity: 0.9;
}

.modal-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.modal-error {
  color: var(--error);
  font-size: 0.8rem;
  text-align: center;
}

/* ── Editor Main ── */

#editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.editor-content {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ── Image Zones ── */

.editor-images {
  display: flex;
  gap: 24px;
  width: 100%;
  justify-content: center;
  align-items: flex-start;
}

.image-zone {
  flex: 1;
  max-width: 520px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  /* Было 320px: зона занимала 27% экрана и вытягивалась в полосу ~1074x320,
     то есть 10:3. Для инструмента, у которого результат — изображение,
     это неверная пропорция: в такой ленте не представить ни 1:1, ни 16:9.
     Высота одна на оба состояния: если задать разную, при появлении
     результата холст прыгает вниз на ~70px и экран дёргается. */
  height: var(--zone-height);
  transition: max-width 0.6s ease, opacity 0.4s ease, border-color 0.2s, background 0.2s, height 0.3s ease;
}

/* В режиме создания зона одна на всю ширину: держим её почти квадратной,
   иначе на широком экране снова получается лента. */
.editor-content:not(.has-result) .image-zone {
  max-width: min(100%, 820px);
  /* Высота намеренно не переопределяется: она общая с состоянием
     результата, иначе при появлении картинки холст прыгает по высоте.
     При ширине 820px общая высота даёт ~1.7 — близко к пропорции самой
     генерации (1408x768 = 1.83), поэтому пустая зона читается как место
     под картинку, а не как провал. */
}

/* ── Source Zone ── */

.source-zone {
  cursor: pointer;
  overflow: hidden;
}

.source-zone:hover {
  border-color: var(--accent);
  background: rgba(13,148,136,0.03);
}

/* ── Source Gallery Grid ── */

.source-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  width: 100%;
  height: 100%;
}

.source-gallery.n1 { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
.source-gallery.n2 { grid-template-rows: 1fr auto; }
.source-gallery.n3 { grid-template-rows: 1fr 1fr auto; }
.source-gallery.n4 { grid-template-rows: 1fr 1fr; }

/* ── Source Slot ── */

.source-slot {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface);
  border: 2px dashed var(--border-soft);
}

.source-slot-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: pointer;
}

.source-slot-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  z-index: 2;
  transition: background 0.15s;
}

.source-slot-remove:hover {
  background: rgba(239,68,68,0.8);
}

/* ── Source Slot Add (empty +) ── */

.source-slot-add {
  grid-column: 1 / -1;
  border: 2px dashed var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color 0.2s, color 0.2s;
  background: rgba(255,255,255,0.01);
  /* В раскладках n1/n2 нижний ряд задан как «auto» и сжимался до высоты
     текста: полоса «+ Загрузить ещё» выходила в 25 px и читалась как
     обрезанный блок. Нижняя граница возвращает ей вид кнопки. */
  min-height: 52px;
  border-radius: 6px;
}

.source-slot-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.source-slot-plus {
  font-size: 1.3rem;
  font-weight: 300;
  line-height: 1;
  color: inherit;
}

.source-slot-add-label {
  font-size: 0.85rem;
  font-weight: 400;
  color: inherit;
}

/* ── Placeholder (0 images) ── */

.zone-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.zone-placeholder svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: inline-block;
}

.zone-placeholder p {
  color: var(--text-muted);
}

.zone-placeholder .hint {
  font-size: 0.8rem;
  margin-top: 4px;
}

/* Примеры промптов в пустой зоне. Текст «опишите, что создать» убеждает
   слабо: большая дропзона всё равно читается как «загрузите файл».
   Готовые примеры показывают действием, что фото не нужно — по нажатию
   описание подставляется в поле ввода.
   pointer-events у родителя выключен, поэтому включаем их здесь. */
.prompt-examples {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
  pointer-events: auto;
}

.prompt-example {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-family: inherit;
  /* #a0a0a0 вместо --text-muted (#888): на фоне #1d1d1d это 6.45:1 вместо
     4.76:1. Плашки — главный смысловой элемент пустого экрана, и читаться
     они должны без напряжения. */
  color: #a0a0a0;
  background: rgba(255,255,255,0.03);
  border: 1px solid #333;
  border-radius: 20px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
}

.prompt-example:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(13,148,136,0.08);
}

/* Ссылка внутри подсказки: выглядит как текст, а не как кнопка, но
   остаётся кликабельной. pointer-events у зоны выключены, включаем здесь. */
.link-like {
  padding: 0;
  font: inherit;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  pointer-events: auto;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-like:hover {
  color: #14b8a6;
}


.result-zone {
  cursor: default;
  max-width: 0;
  flex: 0;
  overflow: hidden;
  opacity: 0;
}

.editor-content.has-result .result-zone {
  max-width: 620px;
  opacity: 1;
  flex: 1;
}

/* Создание с нуля: исходников нет по определению, поэтому левая зона — не
   «пустой слот», а просто пустое место. Убираем её из потока, чтобы результат
   получил всю ширину, а не половину. */
.editor-content.created-from-scratch .source-zone {
  display: none;
}

.editor-content.created-from-scratch .result-zone {
  max-width: min(100%, 820px);
}



/* ── Zone Image ── */

.zone-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Result Panel ── */

.result-image-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.result-image-wrapper .zone-image {
  cursor: pointer;
}

.result-image-wrapper .shimmer {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shimmer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(13,148,136,0.12) 0%, transparent 60%);
  animation: shimmerGlow 2s ease-in-out infinite;
}

@keyframes shimmerGlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.shimmer-text {
  color: var(--text-muted);
  font-size: 0.95rem;
  z-index: 1;
}

.shimmer-dot {
  color: var(--text-muted);
  font-size: 0.95rem;
  animation: dotFade 1.2s ease-in-out infinite;
  z-index: 1;
}

.shimmer-dot:nth-of-type(1) { animation-delay: 0s; }
.shimmer-dot:nth-of-type(2) { animation-delay: 0.4s; }
.shimmer-dot:nth-of-type(3) { animation-delay: 0.8s; }

@keyframes dotFade {
  0%, 40%, 100% { opacity: 0.2; }
  20% { opacity: 1; }
}

.result-zone:not(.hidden) .zone-image {
  animation: fadeSlideIn 0.4s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Use Result Button ── */

.use-result-btn {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  /* Было rgba(0,0,0,0.5) и текст 30% белого: на светлой картинке кнопка
     почти не читалась, хотя это единственный способ продолжить работу с
     результатом. Плотнее подложка и почти белый текст. */
  background: rgba(0,0,0,0.72);
  color: rgba(255,255,255,0.92);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  letter-spacing: 0.3px;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, background 0.2s;
}

.use-result-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.use-result-btn.visible:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Cost Toast ── */

.cost-toast {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(249,115,22,0.65);
  backdrop-filter: blur(6px);
  border: none;
  border-radius: 0;
  font-size: 0.85rem;
  color: #fff;
  animation: fadeSlideIn 0.3s ease;
}

.cost-toast .cost-toast-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
  transition: color 0.2s;
  line-height: 1;
}

.cost-toast .cost-toast-close:hover {
  color: #fff;
}

/* ── Controls Section ── */

.editor-controls-section {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

/* ── Model Selector ── */

.model-selector {
  display: flex;
  align-items: center;
  gap: 20px;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.model-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  transition: all 0.2s;
  flex-shrink: 0;
}

.model-item input:checked ~ .model-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
}

.model-item input:checked ~ .model-label {
  color: var(--accent);
  font-weight: 600;
}

/* Оценка стоимости рядом с моделью. Приглушена: это ориентир, а не прайс,
   и списание идёт по факту. */
.model-price {
  font-size: 0.75rem;
  /* #8a8a8a даёт 5.5 к фону: прежний #5c5c5c (2.87) не проходил AA,
     а цена в этом интерфейсе — не декор, а причина выбрать модель. */
  color: #8a8a8a;
  margin-left: 2px;
  transition: color 0.2s;
  white-space: nowrap;
}

.model-item input:checked ~ .model-price {
  color: var(--accent);
  opacity: 0.85;
}

/* ── Input Row ── */

.input-row {
  width: 100%;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
}

#prompt-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 12px;
  font-size: 0.9rem;
  color: var(--text);
  font-family: inherit;
  outline: none;
  line-height: 1.4;
}

#generate-btn {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  background: linear-gradient(135deg, #0d9488, #0f766e);
  box-shadow: 0 0 0 0 rgba(13,148,136,0);
  transition: transform 0.15s, box-shadow 0.3s ease, opacity 0.2s;
}

#generate-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  box-shadow: 0 0 20px rgba(13,148,136,0.25);
}

#generate-btn:active:not(:disabled) {
  transform: scale(0.97);
}

/* ── Button Utilities ── */

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}


/* ── Lightbox ── */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-overlay img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: default;
  z-index: 1;
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 2001;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
}

.lightbox-close:hover {
  background: rgba(255,255,255,0.2);
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 80px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 2001;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.lightbox-nav:hover {
  background: rgba(255,255,255,0.15);
}

.lightbox-prev {
  left: 0;
  border-radius: 0 8px 8px 0;
}

.lightbox-next {
  right: 0;
  border-radius: 8px 0 0 8px;
}

/* ── Clipboard Toast ── */

.clipboard-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  white-space: nowrap;
}

.clipboard-toast.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Error ── */

.error-msg {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 8px;
  text-align: center;
}

/* ── Utilities ── */

.hidden {
  display: none !important;
}

/* ── Recovery ── */

.recovery-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.recovery-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 420px;
  width: 100%;
}

.recovery-card h2 {
  margin-bottom: 12px;
  font-size: 1.25rem;
}

.recovery-hint {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.form-label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-label input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: monospace;
  outline: none;
  transition: border-color 0.2s;
}

.form-label input:focus {
  border-color: var(--accent);
}

/* ── Вход и регистрация ── */

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}

.auth-tab.active {
  border-color: var(--accent);
  color: var(--text);
}

.auth-back {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.auth-back:hover {
  color: var(--text);
}

#auth-email {
  font-family: inherit;
}

/* ── Лендинг ── */

.landing {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
}

.landing-actions {
  display: flex;
  gap: 12px;
}

.landing-actions .btn {
  width: auto;
  padding: 10px 18px;
}

.landing-main {
  padding-top: 40px;
}

.landing-hero {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 72px;
}

.landing-hero h1 {
  font-size: 2.6rem;
  line-height: 1.15;
  margin-bottom: 20px;
}

.landing-sub {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 32px;
}

.landing-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.landing-cta .btn {
  width: auto;
  padding: 14px 26px;
}

.landing-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 20px;
}

.landing-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.landing-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.landing-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  margin-bottom: 14px;
}

.landing-step h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.landing-step p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .landing-hero h1 {
    font-size: 1.9rem;
  }

  .landing-steps {
    grid-template-columns: 1fr;
  }

  .landing-actions .btn,
  .landing-cta .btn {
    width: auto;
  }
}

/* ── Responsive ── */

@media (max-width: 768px) {
  /* Шапка не помещалась в 360px: логотип, почта, баланс и три кнопки
     вместе давали 615px и выталкивали страницу в горизонтальную прокрутку.
     Прячем адрес почты (он всё равно есть в подсказке) и разрешаем перенос. */
  #header {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .header-right {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .user-id {
    display: none;
  }

  .history-btn,
  .topup-btn,
  .logout-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  #editor {
    padding: 12px;
  }

  .editor-images {
    flex-direction: column;
    gap: 16px;
  }

  .image-zone {
    max-width: 100%;
    /* Было 240px: на телефоне картинка выходила мельче, чем позволяет
       экран, хотя это единственное, за чем человек пришёл. */
    height: auto;
    aspect-ratio: 4 / 3;
    min-height: 260px;
  }



  /* Общее правило растягивало и кнопку генерации: она занимала всю
     строку и оставляла полю ввода 161px. Остальным кнопкам ширина нужна. */
  .btn:not(#generate-btn) {
    width: 100%;
  }

  .recovery-card {
    padding: 24px;
    margin: 0 12px;
  }
}

/* ── Правовые документы: подвал и уведомление о принятии условий ── */

.legal-footer {
  /* Подвал в обычном потоке: раньше он был position: fixed и висел поверх
     содержимого, перекрывая нижнюю часть страницы. Ссылки на документы
     обязаны быть доступны, но не заслонять работу с редактором. */
  margin-top: auto;
  padding: 18px 16px 14px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  font-size: 0.72rem;
  /* Было #6b6b6b (3.60) — ниже AA для мелкого текста. Правовые ссылки
     обязаны читаться: это не декор, а требование к информации об операторе. */
  color: #9a9a9a;
}

/* Реквизиты оператора: ст. 9 ЗоЗПП и правила платёжных систем требуют
   ФИО (или наименование), ИНН и место нахождения. Полный адрес и телефон
   в подвал не выносятся — они есть в оферте и на странице контактов. */
.legal-details {
  /* До подстановки скриптом здесь плейсхолдеры того же размера, иначе
     подгрузка реквизитов сдвигала бы текст под ними. */
  margin-bottom: 5px;
  color: #8f8f8f;
  line-height: 1.45;
}

.legal-details .req {
  /* Плейсхолдер: тот же кегль, приглушённый цвет. */
  opacity: 0.5;
}

.legal-contacts {
  margin-bottom: 7px;
  color: #9a9a9a;
}

.legal-footer a {
  /* Было #7a7a7a (4.47) — на грани. */
  color: #a8a8a8;
  text-decoration: none;
}

.legal-footer a:hover {
  color: var(--accent, #0d9488);
  text-decoration: underline;
}

.legal-sep {
  margin: 0 6px;
  opacity: 0.5;
}

.accept-bar {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(620px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #b4b4b4;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  z-index: 20;
}

.accept-bar a {
  color: var(--accent, #0d9488);
}

.accept-btn {
  flex-shrink: 0;
  padding: 7px 14px;
  border: none;
  border-radius: 8px;
  background: #2a2a2a;
  color: #e0e0e0;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}

.accept-btn:hover {
  background: #343434;
}

@media (max-width: 560px) {
  .accept-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
}

/* ── История обработок ── */

.history-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: #b4b4b4;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.history-btn:hover {
  background: #1f1f1f;
  color: #fff;
}

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
}

.panel-overlay.active { display: flex; }

.panel-card {
  background: #141414;
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(980px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid #222;
}

.panel-head h2 { font-size: 1.05rem; font-weight: 600; }

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  padding: 18px 22px;
  overflow-y: auto;
}

.history-item {
  background: #1a1a1a;
  border: 1px solid #262626;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.history-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #101010;
  cursor: zoom-in;
  display: block;
}

.history-gone,
.history-broken .history-thumb {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5f5f5f;
  font-size: 0.75rem;
  text-align: center;
  padding: 10px;
  background: #101010;
}

.history-caption {
  padding: 9px 11px 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.history-prompt {
  font-size: 0.78rem;
  color: #c4c4c4;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-date { font-size: 0.7rem; color: var(--text-muted); }

.history-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px 18px;
  border-top: 1px solid #222;
}

.history-more {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: #d0d0d0;
  font-size: 0.82rem;
  cursor: pointer;
}

.history-more:hover { background: #1f1f1f; }
.history-status { font-size: 0.76rem; color: var(--text-muted); margin-left: auto; }

@media (max-width: 560px) {
  .history-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 14px; }
  .panel-card { max-height: 92vh; }
}

/* ── Памятка с данными для восстановления доступа ── */

.recovery-hint {
  position: fixed;
  right: 20px;
  bottom: 46px;
  width: min(340px, calc(100vw - 40px));
  padding: 18px 18px 16px;
  background: #16211f;
  border: 1px solid #1f3d38;
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  z-index: 30;
}

.hint-close {
  position: absolute;
  top: 8px;
  right: 10px;
}

.hint-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
  padding-right: 18px;
}

.hint-text {
  font-size: 0.78rem;
  line-height: 1.5;
  color: #9fb5b0;
  margin-bottom: 14px;
}

.hint-values {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.hint-values > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.hint-label {
  font-size: 0.72rem;
  color: #7a8f8b;
  min-width: 46px;
}

.hint-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: #2dd4bf;
  user-select: all;
}

.hint-copy {
  width: 100%;
  padding: 9px;
  border: none;
  border-radius: 9px;
  background: #0d9488;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.hint-copy:hover { background: #0f766e; }

@media (max-width: 560px) {
  .recovery-hint { right: 12px; left: 12px; width: auto; bottom: 40px; }
}

/* Кнопки формы восстановления: рядом с «Восстановить» нужен выход,
   потому что форма замещает собой всё приложение. */
.recovery-actions {
  display: flex;
  gap: 10px;
}

.recovery-actions .btn { flex: 1; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: #b4b4b4;
}

.btn-ghost:hover {
  background: #1f1f1f;
  color: #fff;
}
