/* Telegram Mini App — main stylesheet.
 *
 * All selectors are prefixed with `ma-` to avoid collisions with the rest of
 * the Rails app.
 *
 * Визуальный язык — тот же, что у лендинга pixmaker.ru (app/views/pages/home):
 * тёмный тёплый фон, янтарный акцент, Fraunces для заголовков,
 * Hanken Grotesk для текста, скругление 18px, pill-кнопки.
 */

:root {
  color-scheme: dark;
  /* Палитра лендинга */
  --ma-bg:        #0c0b0d;
  --ma-bg-soft:   #141215;
  --ma-surface:   #1a171b;                    /* --panel лендинга */
  --ma-border:    rgba(255, 240, 210, 0.10);  /* --line лендинга  */
  --ma-action-border: rgba(255, 240, 210, 0.14);
  --ma-accent:    #ffc83d;                    /* --amber          */
  --ma-accent-deep: #f5a623;
  --ma-accent-soft: rgba(255, 200, 61, 0.12);
  --ma-on-accent: #2a1c00;                    /* тёмный текст на янтарном */
  --ma-white:     #f3ece0;                    /* --ink            */
  --ma-sub:       #b3a995;                    /* --ink-dim        */
  --ma-sub-2:     #8a8175;                    /* --ink-faint      */
  /* Шрифты лендинга */
  --ma-display:   "Fraunces", Georgia, serif;
  --ma-body:      "Hanken Grotesk", -apple-system, "Segoe UI", sans-serif;
  --ma-r:         18px;
}

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

html, body, .ma-main, .ma-cat-screen, .ma-detail {
  -webkit-user-select: text;
  user-select: text;
}

html, body {
  height: 100%;
  background: var(--ma-bg);
  color: var(--ma-white);
  font-family: var(--ma-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* Respect notches / dynamic islands when running as full-screen Mini App. */
  padding-top: var(--tg-content-safe-area-inset-top, env(safe-area-inset-top));
  padding-right: var(--tg-content-safe-area-inset-right, env(safe-area-inset-right));
  padding-bottom: var(--tg-content-safe-area-inset-bottom, env(safe-area-inset-bottom));
  padding-left: var(--tg-content-safe-area-inset-left, env(safe-area-inset-left));
}

/* Плёночное зерно лендинга — только на десктопе: на мобильных webview
   full-screen mix-blend слой заметно бьёт по скроллу. */
@media (min-width: 768px) {
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
  }
}

button,
a,
input,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

/* Hide scrollbars but keep scrolling */
.ma-noscroll { -ms-overflow-style: none; scrollbar-width: none; }
.ma-noscroll::-webkit-scrollbar { display: none; }

/* ── Main screen ───────────────────────────────────────────────── */
.ma-main {
  display: flex;
  flex-direction: column;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  height: var(--tg-viewport-stable-height, 100dvh);
  width: 100%;
  overflow-x: hidden;
  background: var(--ma-bg);
}

.ma-main__header {
  padding: 16px 16px 10px;
  flex-shrink: 0;
}

.ma-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 14px;
}
.ma-brand__logo {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  object-fit: cover;
  display: block;
  box-shadow: 0 6px 18px -6px rgba(255, 200, 61, 0.6);
}
.ma-brand__title {
  font-family: var(--ma-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--ma-white);
  line-height: 1.1;
}
.ma-brand__subtitle { font-size: 11px; color: var(--ma-sub); }

.ma-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ma-surface);
  border-radius: 100px;
  padding: 10px 16px;
  border: 1px solid var(--ma-border);
  transition: border-color .25s;
}
.ma-search:focus-within { border-color: rgba(255, 200, 61, 0.45); }
.ma-search__icon { font-size: 14px; opacity: 0.4; }
.ma-search__input {
  background: none;
  border: none;
  outline: none;
  color: var(--ma-white);
  font-size: 16px;
  flex: 1;
  font-family: inherit;
  min-width: 0;
}
.ma-search__input::placeholder { color: var(--ma-sub-2); }
.ma-search__clear {
  background: none;
  border: none;
  color: var(--ma-sub);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.ma-main__content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 4px 16px 20px;
}

/* Секционная подпись в духе .eyebrow лендинга — янтарный uppercase с чёрточкой. */
.ma-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ma-accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ma-section-label::before {
  content: "";
  width: 16px;
  height: 1px;
  background: var(--ma-accent);
  display: inline-block;
  flex-shrink: 0;
}

.ma-cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Search results ────────────────────────────────────────────── */
/* Same single-column layout as inside a category — reuse .ma-prompt-card. */
.ma-search-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.ma-search-results__item {
  flex-shrink: 0;
  min-width: 0;
  width: 100%;
}

/* ── Category card ─────────────────────────────────────────────── */
.ma-cat-card {
  background: var(--ma-surface);
  border-radius: var(--ma-r);
  overflow: hidden;
  border: 1px solid var(--ma-border);
  cursor: pointer;
  display: block;
  color: inherit;
  text-decoration: none;
  height: 131px;
  transition: transform .3s, border-color .3s;
}
@media (hover: hover) {
  .ma-cat-card:hover { transform: translateY(-3px); border-color: rgba(255, 200, 61, 0.35); }
}
.ma-cat-card__stripe { height: 3px; }
.ma-cat-card__image {
  height: 96px;
  overflow: hidden;
}
.ma-cat-card__image > span { display: block; height: 100%; }
.ma-cat-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ma-cat-card__img-fallback {
  display: block;
  width: 100%;
  height: 96px;
}
.ma-cat-card__body {
  min-height: 32px;
  padding: 0 12px;
  display: flex;
  align-items: center;
}
.ma-cat-card__label {
  font-family: var(--ma-display);
  font-weight: 500;
  font-size: 14px;
  color: var(--ma-white);
  line-height: 1.2;
}

/* ── Empty state ───────────────────────────────────────────────── */
.ma-empty {
  text-align: center;
  padding: 50px 0;
  color: var(--ma-sub);
}
.ma-empty__icon { font-size: 30px; margin-bottom: 8px; }
.ma-empty__text { font-size: 14px; }

/* ── In-page back arrow ────────────────────────────────────────── */
/* Hidden inside real Telegram clients (.is-telegram is added by an inline
   script in the layout before paint) — Telegram's native BackButton is
   used there instead. Outside Telegram (browser dev preview) this is the
   only "back" affordance, so it stays visible. */
.is-telegram .ma-back-fallback { display: none; }

/* ── Generic ───────────────────────────────────────────────────── */
.ma-icon-button {
  background: var(--ma-accent-soft);
  border: 1px solid rgba(255, 200, 61, 0.25);
  color: var(--ma-accent);
  width: 34px;
  height: 34px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  flex-shrink: 0;
}

/* ── Image placeholder banner ──────────────────────────────────── */
.ma-img-banner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Tags ──────────────────────────────────────────────────────── */
.ma-tag-list {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.ma-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--ma-accent);
  background: var(--ma-accent-soft);
  border: 1px solid rgba(255, 200, 61, 0.18);
  padding: 2px 8px;
  border-radius: 100px;
}

/* ── Category screen ───────────────────────────────────────────── */
.ma-cat-screen {
  display: flex;
  flex-direction: column;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  height: var(--tg-viewport-stable-height, 100dvh);
  width: 100%;
  overflow-x: hidden;
  background: var(--ma-bg);
}
.ma-cat-screen__header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--ma-border);
  background: rgba(12, 11, 13, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.ma-cat-screen__stripe { height: 3px; }
.ma-cat-screen__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}
.ma-cat-screen__title {
  font-family: var(--ma-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ma-white);
  line-height: 1.1;
}
.ma-cat-screen__desc {
  font-size: 11px;
  color: var(--ma-sub);
}
.ma-cat-screen__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 14px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Prompt card ───────────────────────────────────────────────── */
.ma-prompt-card {
  background: var(--ma-surface);
  border-radius: var(--ma-r);
  overflow: hidden;
  border: 1px solid var(--ma-border);
  flex-shrink: 0;
  min-width: 0;
  width: 100%;
  transition: transform .3s, border-color .3s;
}
@media (hover: hover) {
  .ma-prompt-card:hover { transform: translateY(-3px); border-color: rgba(255, 200, 61, 0.35); }
}
.ma-prompt-card__body {
  padding: 12px 14px 8px;
}
.ma-prompt-card__title {
  font-family: var(--ma-display);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--ma-white);
  margin-bottom: 5px;
  line-height: 1.25;
}
.ma-prompt-card__desc {
  font-size: 12px;
  color: var(--ma-sub);
  line-height: 1.55;
  margin-bottom: 10px;
}

.ma-prompt-card__actions {
  border-top: 1px solid var(--ma-action-border);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 2px;
}
.ma-prompt-card__btn {
  background: none;
  border: none;
  color: var(--ma-accent);
  font-size: 12px;
  font-weight: 600;
  padding: 12px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 42px;
  line-height: 1;
  box-sizing: border-box;
  text-decoration: none;
  font-family: inherit;
  transition: background-color .18s, color .18s;
  min-width: 0;
  overflow: hidden;
}
.ma-prompt-card__btn--copy {
  border-right: 1px solid var(--ma-action-border);
}
.ma-prompt-card__btn--copy:disabled {
  cursor: default;
  opacity: 1;
}
.ma-prompt-card__btn--more {
  color: var(--ma-sub);
  font-weight: 500;
}
@media (hover: hover) {
  .ma-prompt-card__btn:hover { background-color: var(--ma-accent-soft); }
  .ma-prompt-card__btn--more:hover { color: var(--ma-accent); }
}
.ma-prompt-card__btn-icon {
  font-size: 14px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  flex-shrink: 0;
}
.ma-prompt-card__btn-label {
  display: inline-block;
  min-width: 0;
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ma-prompt-card__btn-arrow {
  opacity: 0.7;
}
.ma-prompt-card__banner-link {
  display: block;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.ma-prompt-card__banner-link > span { display: block; }
.ma-prompt-card__banner-img {
  width: 100%;
  height: 155px;
  object-fit: cover;
  display: block;
}

/* ── Detail screen ─────────────────────────────────────────────── */
.ma-detail {
  display: flex;
  flex-direction: column;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  height: var(--tg-viewport-stable-height, 100dvh);
  width: 100%;
  overflow-x: hidden;
  background: var(--ma-bg);
}
.ma-detail__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ma-border);
  flex-shrink: 0;
  background: rgba(12, 11, 13, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.ma-detail__title {
  font-family: var(--ma-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ma-white);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ma-detail__content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.ma-detail__card {
  background: var(--ma-surface);
  border-radius: var(--ma-r);
  margin-bottom: 14px;
  border: 1px solid var(--ma-border);
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(100% - 170px);
  display: flex;
  flex-direction: column;
}
.ma-detail__card-body {
  padding: 14px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.ma-detail__label {
  font-size: 10px;
  font-weight: 600;
  color: var(--ma-accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: 8px;
}
.ma-detail__prompt {
  font-size: 13px;
  color: var(--ma-white);
  line-height: 1.65;
  background: rgba(12, 11, 13, 0.7);
  border: 1px solid var(--ma-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-word;
  flex: 1 1 auto;
  min-height: 118px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-user-select: text;
  user-select: text;
}

/* Copy button: same look as the bottom-row "Скопировать" in a list prompt
   card. Full-width, edge to edge, separated from the body by a 1px border.   */
.ma-detail__copy {
  background: none;
  border: none;
  border-top: 1px solid var(--ma-action-border);
  color: var(--ma-accent);
  font-size: 12px;
  font-weight: 600;
  padding: 12px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 42px;
  line-height: 1;
  box-sizing: border-box;
  font-family: inherit;
  transition: background-color .18s, color .18s;
  flex-shrink: 0;
}
@media (hover: hover) {
  .ma-detail__copy:hover { background-color: var(--ma-accent-soft); }
}
.ma-detail__copy:disabled {
  cursor: default;
  opacity: 1;
}
.ma-detail__copy-icon {
  font-size: 14px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  flex-shrink: 0;
}
.ma-detail__copy-label {
  display: inline-block;
  line-height: 1.1;
}

.ma-detail__examples-wrap {
  flex: 0 0 auto;
}

.ma-detail__examples {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ma-detail__examples > * {
  border-radius: 12px;
  overflow: hidden;
}
.ma-detail__examples > span { display: block; }
.ma-detail__example-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

/* ── Copy button "copied" state ────────────────────────────────── */
/* Toggled by app/javascript/controllers/copy_controller.js for ~2s after
   a successful clipboard write. */
.ma-prompt-card__btn--copy.ma-copy--copied,
.ma-detail__copy.ma-copy--copied {
  background-color: rgba(39, 174, 96, 0.15);
  color: #4cd137;
}

/* ── Image lightbox ────────────────────────────────────────────── */
.ma-lightbox-open,
.ma-lightbox-open body {
  overflow: hidden;
}
.ma-detail__example-button {
  background: none;
  border: 0;
  padding: 0;
  width: 100%;
  height: 120px;
  display: block;
  cursor: pointer;
  font: inherit;
}
.ma-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ma-lightbox[hidden] {
  display: none;
}
.ma-lightbox__image {
  width: 100vw;
  height: 100dvh;
  object-fit: contain;
  display: block;
  cursor: pointer;
}
.ma-lightbox__close,
.ma-lightbox__share {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--ma-border);
  background: rgba(12, 11, 13, 0.72);
  color: var(--ma-white);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
}
.ma-lightbox__close {
  left: max(12px, env(safe-area-inset-left));
}
.ma-lightbox__share {
  right: max(12px, env(safe-area-inset-right));
}
.ma-lightbox__icon {
  display: block;
  object-fit: contain;
  filter: invert(1);
}
.ma-lightbox__close-icon {
  width: 18px;
  height: 18px;
}
.ma-lightbox__share-icon {
  width: 27px;
  height: 27px;
}

/* ── Generate screen ────────────────────────────────────────────── */
/* Токены генерации — те же янтарные, что и на лендинге. */

:root {
  --ma-accent-new:      #ffc83d;   /* amber — action + selection  */
  --ma-accent-glow:     #f5a623;
  --ma-success:         #4cd137;
  --ma-warn:            #fbbf24;
  --ma-warn-soft:       rgba(251, 191, 36, 0.13);
  --ma-border-strong:   rgba(255, 240, 210, 0.16);
  --ma-text-disabled:   rgba(243, 236, 224, 0.28);
  --ma-scrim:           rgba(0, 0, 0, 0.82);
}

.ma-generate {
  display: flex;
  flex-direction: column;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  height: var(--tg-viewport-stable-height, 100dvh);
  width: 100%;
  overflow-x: hidden;
  background: var(--ma-bg);
}

/* Header */
.ma-generate__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ma-border);
  flex-shrink: 0;
  background: rgba(12, 11, 13, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.ma-generate__title {
  font-family: var(--ma-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ma-white);
  flex: 1;
  line-height: 1.15;
}

/* Scrollable content */
.ma-generate__content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.ma-generate__section {
  display: flex;
  flex-direction: column;
}
.ma-generate__tags {
  margin-top: 10px;
}

/* Preview */
.ma-generate__preview-wrap {
  border-radius: var(--ma-r);
  overflow: hidden;
  background: var(--ma-surface);
  border: 1px solid var(--ma-border);
  height: 230px;
  position: relative;
  flex-shrink: 0;
}
.ma-generate__preview-wrap > span { display: block; height: 100%; }
.ma-generate__preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ma-generate__preview-pill {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ma-sub);
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 9px;
  border-radius: 9999px;
}

/* Result */
.ma-generate__result-wrap {
  border-radius: var(--ma-r);
  overflow: hidden;
  background: var(--ma-surface);
  position: relative;
  flex-shrink: 0;
}
.ma-generate__result-img {
  width: 100%;
  display: block;
  border-radius: var(--ma-r);
}
.ma-generate__download-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 13px 16px;
  background: var(--ma-accent);
  color: var(--ma-on-accent);
  border-radius: 100px;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 30px -8px rgba(255, 200, 61, 0.5);
}

/* Status message (error / info) */
.ma-generate__status-msg {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--ma-warn-soft);
  color: var(--ma-warn);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

/* Model row */
.ma-generate__model-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ma-surface);
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-r);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--ma-white);
  font-family: inherit;
  transition: border-color .25s;
}
@media (hover: hover) {
  .ma-generate__model-row:hover { border-color: rgba(255, 200, 61, 0.35); }
}
.ma-generate__model-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.ma-generate__model-text-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ma-generate__model-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ma-white);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ma-generate__model-desc {
  font-size: 12px;
  color: var(--ma-sub);
  display: block;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ma-generate__model-chev {
  color: var(--ma-sub-2);
  font-size: 20px;
  flex-shrink: 0;
}

/* Upload slot */
.ma-generate__uploads {
  display: flex;
  gap: 10px;
}
/* Positioned wrapper so the remove button (a sibling of the slot, not nested
   inside it) is still placed at the top-right of the slot visually. */
.ma-generate__slot-wrap {
  position: relative;
  display: inline-flex;
}
.ma-generate__slot {
  width: 84px;
  height: 84px;
  min-height: 44px;
  border-radius: 12px;
  background: rgba(255, 240, 210, 0.05);
  border: 1.5px dashed var(--ma-border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--ma-sub-2);
  position: relative;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: border-color .25s, color .25s;
}
@media (hover: hover) {
  .ma-generate__slot:hover { border-color: rgba(255, 200, 61, 0.45); color: var(--ma-accent); }
}
.ma-generate__slot--filled {
  border-style: solid;
  border-color: var(--ma-border);
}
.ma-generate__slot-plus {
  font-size: 28px;
  line-height: 1;
  pointer-events: none;
}
.ma-generate__slot-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  pointer-events: none;
}
.ma-generate__slot-check {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 20px;
  height: 20px;
  border-radius: 9999px;
  background: var(--ma-success);
  color: #0b1f08;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.ma-generate__slot-remove {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: var(--ma-white);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  min-width: 22px;
  padding: 0;
}
.ma-generate__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Aspect-ratio chips */
.ma-generate__chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.ma-generate__chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 9px 14px;
  border-radius: 100px;
  background: var(--ma-surface);
  border: 1px solid var(--ma-border);
  color: var(--ma-sub);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  min-height: 44px;
  font-family: inherit;
  line-height: 1;
  transition: border-color .2s, color .2s, background .2s;
}
.ma-generate__chip--selected {
  background: var(--ma-accent-soft);
  border: 1.5px solid var(--ma-accent);
  color: var(--ma-white);
}

/* Fixed footer */
.ma-generate__footer {
  flex-shrink: 0;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ma-border);
  background: var(--ma-bg);
}
.ma-generate__hint {
  font-size: 12px;
  color: var(--ma-sub);
  text-align: center;
  margin-bottom: 8px;
}
.ma-generate__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 100px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  background: var(--ma-accent);
  color: var(--ma-on-accent);
  box-shadow: 0 10px 30px -8px rgba(255, 200, 61, 0.5);
  transition: opacity 0.15s, transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
}
@media (hover: hover) {
  .ma-generate__cta:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px -8px rgba(255, 200, 61, 0.65);
  }
}
.ma-generate__cta:disabled {
  background: rgba(255, 240, 210, 0.06);
  color: var(--ma-text-disabled);
  cursor: default;
  box-shadow: none;
}

/* Spinner inside CTA */
.ma-generate__spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(42, 28, 0, 0.3);
  border-top-color: var(--ma-on-accent);
  border-radius: 50%;
  animation: ma-spin 0.75s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .ma-generate__spinner { animation: none; }
  /* Scope to the busy/generating state only (aria-busy set by JS),
     so the initial disabled (no-photo) CTA does not show "В обработке". */
  .ma-generate__cta[aria-busy="true"]::after { content: "В обработке"; }
}
@keyframes ma-spin {
  to { transform: rotate(360deg); }
}

/* Model selection bottom-sheet */
.ma-generate__scrim {
  position: fixed;
  inset: 0;
  background: var(--ma-scrim);
  z-index: 100;
}
.ma-generate__sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--ma-surface);
  border: 1px solid var(--ma-border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  z-index: 101;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ma-generate__sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(243, 236, 224, 0.2);
  border-radius: 9999px;
  margin: 0 auto 14px;
}
.ma-generate__sheet-title {
  font-family: var(--ma-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  color: var(--ma-white);
}
.ma-generate__sheet-model-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: none;
  border: 1px solid var(--ma-border);
  border-radius: var(--ma-r);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--ma-white);
  margin-bottom: 8px;
  font-family: inherit;
  min-height: 44px;
  transition: border-color .2s;
}
@media (hover: hover) {
  .ma-generate__sheet-model-row:hover { border-color: rgba(255, 200, 61, 0.35); }
}
.ma-generate__sheet-model-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ma-generate__sheet-check {
  color: var(--ma-accent);
  font-size: 16px;
  flex-shrink: 0;
}
