/* ---------- шрифты ---------- */
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(fonts/manrope-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(fonts/manrope-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(fonts/playfair-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(fonts/playfair-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/cormorant-italic-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/cormorant-italic-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ---------- токены ---------- */
:root {
  --bg: #08080b;
  --bg-raise: #111116;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-2: rgba(255, 255, 255, 0.06);
  --panel-3: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.15);
  --text: #f4f2f5;
  --muted: #a19dab;
  --faint: #6f6b78;
  --tiffany: #81d8d0;
  --pink: #ff8dc1;
  --lilac: #bcb2ec;
  --grad: linear-gradient(115deg, #81d8d0 0%, #bcb2ec 52%, #ff8dc1 100%);
  --on-grad: #0b0b10;
  --danger: #ff7a8e;
  --radius: 20px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --composer-w: 392px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.lock { overflow: hidden; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--tiffany); outline-offset: 2px; }
::selection { background: rgba(129, 216, 208, 0.35); }

/* ---------- фон: медленное северное сияние ---------- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i {
  position: absolute;
  width: 60vmax; height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  animation: drift 28s var(--ease) infinite alternate;
}
.aurora i:nth-child(1) { background: var(--tiffany); top: -30vmax; left: -18vmax; }
.aurora i:nth-child(2) { background: var(--pink); bottom: -34vmax; right: -20vmax; animation-delay: -9s; }
.aurora i:nth-child(3) { background: var(--lilac); top: 30%; left: 40%; width: 36vmax; height: 36vmax; opacity: 0.08; animation-delay: -17s; }
@keyframes drift {
  to { transform: translate3d(8vmax, 6vmax, 0) scale(1.12); }
}

/* ---------- логотип ---------- */
.logo { display: inline-flex; align-items: baseline; gap: 1px; font-size: 22px; line-height: 1; letter-spacing: -0.01em; user-select: none; }
.logo span { font-weight: 600; color: var(--text); }
.logo em {
  font-family: 'Cormorant Garamond', 'Playfair Display', serif;
  font-style: italic; font-weight: 500;
  font-size: 1.3em;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  padding-right: 0.08em;
}
.logo-xl { font-size: 44px; }

/* ---------- кнопки ---------- */
.btn-primary {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px;
  border-radius: 16px;
  background: var(--grad);
  background-size: 160% 100%;
  color: var(--on-grad);
  font-weight: 650; font-size: 16px; letter-spacing: 0.01em;
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.35s var(--ease), background-position 0.6s var(--ease), opacity 0.2s;
  box-shadow: 0 10px 30px -12px rgba(255, 141, 193, 0.55), 0 6px 20px -14px rgba(129, 216, 208, 0.7);
}
.btn-primary::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.9s var(--ease);
}
.btn-primary:hover { background-position: 100% 0; box-shadow: 0 14px 38px -12px rgba(255, 141, 193, 0.7), 0 8px 24px -14px rgba(129, 216, 208, 0.9); }
.btn-primary:hover::after { transform: translateX(120%); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled, .btn-primary.busy { opacity: 0.6; pointer-events: none; }
.btn-primary kbd {
  font: 600 11px/1 'Manrope', sans-serif;
  padding: 4px 6px; border-radius: 6px;
  background: rgba(11, 11, 16, 0.12);
  color: rgba(11, 11, 16, 0.65);
}

.btn-soft {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-weight: 550; font-size: 14px;
  transition: background 0.2s, border-color 0.2s, transform 0.2s var(--ease), color 0.2s;
}
.btn-soft:hover { background: var(--panel-3); border-color: var(--line-2); }
.btn-soft:active { transform: scale(0.97); }
.btn-soft.danger { color: var(--danger); }
.btn-soft.danger.confirm { background: rgba(255, 122, 142, 0.16); border-color: rgba(255, 122, 142, 0.5); }
.btn-soft.on { color: var(--pink); border-color: rgba(255, 141, 193, 0.4); }
.btn-soft.on svg { fill: currentColor; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 13px;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.tool-btn svg { width: 17px; height: 17px; }
.tool-btn:hover { background: var(--panel-3); border-color: var(--line-2); }
.tool-btn.ghost { background: none; border-color: transparent; color: var(--muted); padding: 0 8px; }
.tool-btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.tool-btn.busy { pointer-events: none; color: var(--tiffany); }
.tool-btn.busy svg { animation: spin 1.2s linear infinite; }
#improve svg { color: var(--tiffany); }
#idea svg { color: var(--pink); }

/* ---------- вход ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 44px 28px 30px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.8);
  animation: rise 0.8s var(--ease) both;
}
.login-sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; text-align: center; }
.login-field { width: 100%; }
.login-field input, .search input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.25s, background 0.2s;
}
.login-field input { height: 52px; padding: 0 18px; font-size: 16px; text-align: center; letter-spacing: 0.04em; }
.login-field input:focus, .search input:focus {
  border-color: rgba(129, 216, 208, 0.55);
  box-shadow: 0 0 0 4px rgba(129, 216, 208, 0.12);
}
.login-card .btn-primary { width: 100%; }
.login-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; text-align: center; }
.shake { animation: shake 0.42s var(--ease); }
@keyframes shake {
  20% { transform: translateX(-8px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.98); } }

/* ---------- каркас ---------- */
.app { animation: fade 0.5s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 64px;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(8, 8, 11, 0.92), rgba(8, 8, 11, 0.7));
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar .icon-btn { margin-left: auto; }

/* разделы: на компьютере — в шапке по центру, на телефоне — нижняя панель */
.nav {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: inline-flex; gap: 4px; padding: 4px;
  border-radius: 15px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.nav-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: 11px;
  font-size: 14px; font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.25s var(--ease), color 0.2s;
}
.nav-tab svg { width: 18px; height: 18px; }
.nav-tab:hover { color: var(--text); }
.nav-tab[aria-selected='true'] { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.nav-tab[aria-selected='true'] svg { color: var(--tiffany); }
.view { animation: fade 0.35s var(--ease) both; }
.badge {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 99px;
  color: var(--pink); border: 1px solid rgba(255, 141, 193, 0.35);
}

.layout {
  display: grid;
  grid-template-columns: var(--composer-w) minmax(0, 1fr);
  gap: 28px;
  padding: 24px max(24px, env(safe-area-inset-right)) 48px max(24px, env(safe-area-inset-left));
  max-width: 1880px;
  margin: 0 auto;
}

/* ---------- панель ввода ---------- */
.composer {
  position: sticky; top: 88px;
  align-self: start;
  max-height: calc(100dvh - 108px);
  overflow-y: auto;
  scrollbar-width: thin;
  display: flex; flex-direction: column; gap: 22px;
  padding: 20px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
  border: 1px solid var(--line);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.prompt-box {
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid var(--line);
  transition: border-color 0.25s, box-shadow 0.3s;
}
.prompt-box:focus-within { border-color: rgba(129, 216, 208, 0.5); box-shadow: 0 0 0 4px rgba(129, 216, 208, 0.1); }
.prompt-box.flash { animation: flash 1.2s var(--ease); }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(255, 141, 193, 0.5); } 100% { box-shadow: 0 0 0 14px rgba(255, 141, 193, 0); } }
#prompt, #idea-text {
  display: block;
  width: 100%; min-height: 118px; max-height: 320px;
  padding: 16px 16px 8px;
  border: 0; outline: none; resize: none;
  background: none;
  font-size: 16px; line-height: 1.55;
}
#idea-text { min-height: 170px; max-height: 420px; }
#prompt::placeholder, #idea-text::placeholder { color: var(--faint); }
.prompt-tools { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; }
.counter { margin-left: auto; white-space: nowrap; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.counter.warn { color: var(--pink); }

.group { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.group h3 {
  margin: 0;
  font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.group-row { flex-direction: row; align-items: center; justify-content: space-between; }

.chips { position: relative; display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  height: 36px; padding: 0 14px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 550;
  color: #d9d6de;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip:active { transform: scale(0.96); }
.chip[aria-checked='true'] {
  color: var(--on-grad);
  background: var(--grad);
  border-color: transparent;
}

.aspects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.aspect {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px;
  height: 84px; padding: 10px 6px 9px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: background 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.aspect:hover { border-color: var(--line-2); }
.aspect:active { transform: scale(0.97); }
.aspect .shape {
  display: block;
  border: 1.6px solid var(--muted);
  border-radius: 4px;
  transition: border-color 0.2s, background 0.2s;
}
.aspect b { font-size: 12.5px; font-weight: 650; line-height: 1; }
.aspect small { font-size: 11px; color: var(--faint); line-height: 1; }
.aspect[aria-checked='true'] { border-color: rgba(129, 216, 208, 0.6); background: rgba(129, 216, 208, 0.08); }
.aspect[aria-checked='true'] .shape { border-color: var(--tiffany); background: rgba(129, 216, 208, 0.18); }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
}
.segmented button {
  width: 42px; height: 34px;
  border-radius: 10px;
  font-weight: 650; font-size: 14px;
  color: var(--muted);
  transition: background 0.25s var(--ease), color 0.2s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked='true'] { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }


.btn-generate { width: 100%; min-height: 58px; font-size: 17px; margin-top: 2px; }
.btn-generate svg { width: 21px; height: 21px; }
.btn-generate kbd { margin-left: 4px; }

/* ---------- галерея ---------- */
.gallery-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.tab {
  height: 34px; padding: 0 14px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  color: var(--muted);
  transition: background 0.25s var(--ease), color 0.2s;
}
.tab span { color: var(--faint); font-weight: 500; margin-left: 2px; font-variant-numeric: tabular-nums; }
.tab.active { background: var(--panel-3); color: var(--text); }
.search { position: relative; margin-left: auto; width: min(280px, 100%); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); pointer-events: none; }
.search input { height: 42px; padding: 0 14px 0 38px; font-size: 14px; }
.search input::-webkit-search-cancel-button { filter: invert(0.6); }

.gallery { display: flex; gap: 14px; align-items: flex-start; }
.col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.card {
  position: relative;
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: zoom-in;
  isolation: isolate;
  transform: translateZ(0);
  transition: border-color 0.3s, transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.card.enter { animation: pop 0.6s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 22px 40px -24px rgba(0, 0, 0, 0.9); }
.card-media { position: relative; width: 100%; }
.card-media img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s var(--ease), transform 0.8s var(--ease);
}
.card-media img.loaded { opacity: 1; }
.card:hover .card-media img { transform: scale(1.025); }
.card-over {
  position: absolute; inset: auto 0 0 0;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 40px 12px 12px;
  background: linear-gradient(180deg, transparent, rgba(5, 5, 8, 0.85));
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s var(--ease), transform 0.35s var(--ease);
}
.card:hover .card-over, .card:focus-within .card-over { opacity: 1; transform: none; }
.card-over p {
  flex: 1; min-width: 0; margin: 0;
  font-size: 12.5px; line-height: 1.4; color: #e9e6ec;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-btn {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #fff;
  transition: background 0.2s, transform 0.2s var(--ease);
}
.card-btn svg { width: 17px; height: 17px; }
.card-btn:hover { background: rgba(255, 255, 255, 0.26); }
.card-btn:active { transform: scale(0.92); }
.card-btn.on { color: var(--pink); }
.card-btn.on svg { fill: currentColor; }
.card-heart {
  position: absolute; top: 10px; right: 10px;
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 10px;
  background: rgba(8, 8, 11, 0.45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--pink);
  transition: opacity 0.25s;
}
.card-heart svg { width: 16px; height: 16px; fill: currentColor; }
.card:hover .card-heart { opacity: 0; }

/* карточка, которая рисуется */
.card.pending { cursor: default; min-height: 156px; }
.card.pending:hover { transform: none; }
.pending-glow {
  position: absolute; inset: -40%;
  background: conic-gradient(from 0deg, rgba(129, 216, 208, 0.0), rgba(129, 216, 208, 0.28), rgba(188, 178, 236, 0.18), rgba(255, 141, 193, 0.3), rgba(129, 216, 208, 0.0));
  filter: blur(30px);
  animation: spin 6s linear infinite;
}
.pending-body {
  position: absolute; inset: 1px;
  border-radius: 17px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 16px;
  background: rgba(10, 10, 14, 0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  text-align: center;
}
.pending-body .ring {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--tiffany);
  border-right-color: var(--pink);
  animation: spin 1s linear infinite;
}
.pending-body b { font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.pending-body p {
  margin: 0; max-width: 92%;
  font-size: 12px; line-height: 1.4; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card.failed { cursor: default; border-color: rgba(255, 122, 142, 0.3); aspect-ratio: auto !important; }
.card.failed .pending-body { position: relative; inset: auto; min-height: 156px; padding: 22px 16px; }
.card.failed:hover { transform: none; }
.card.failed .pending-body { background: rgba(40, 12, 20, 0.6); }
.card.failed b { color: var(--danger); font-weight: 600; line-height: 1.4; }
.failed-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.failed-actions .tool-btn { height: 32px; }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 70px 20px;
  text-align: center;
  color: var(--muted);
  animation: fade 0.6s var(--ease) both;
}
.empty-art {
  display: grid; place-items: center;
  width: 76px; height: 76px; border-radius: 24px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--tiffany);
}
.empty-art svg { width: 34px; height: 34px; stroke-width: 1.4; }
.empty h2 { margin: 6px 0 0; font: 400 28px/1.2 'Playfair Display', serif; color: var(--text); }
.empty p { margin: 0; max-width: 420px; }
.empty .chips { justify-content: center; max-width: 560px; margin-top: 8px; }
.empty .chip { white-space: normal; height: auto; min-height: 36px; padding: 8px 14px; text-align: left; line-height: 1.35; }

/* ---------- просмотр ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 50;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  background: rgba(5, 5, 8, 0.9);
  backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.viewer.open { opacity: 1; }
.viewer-stage {
  position: relative;
  min-height: 0; min-width: 0;
  overflow: hidden;
  touch-action: pan-y;
}
/* картинка вписывается в сцену: абсолютная + margin:auto центрирует и сохраняет пропорции */
.viewer-stage img {
  position: absolute; inset: 28px;
  margin: auto;
  max-width: calc(100% - 56px); max-height: calc(100% - 56px);
  border-radius: 16px;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.9);
  transform: scale(0.97); opacity: 0;
  transition: transform 0.45s var(--ease), opacity 0.35s var(--ease);
  user-select: none; -webkit-user-drag: none;
}
.viewer.open .viewer-stage img.loaded { transform: none; opacity: 1; }
.viewer-nav {
  position: absolute; top: 50%;
  display: grid; place-items: center;
  width: 48px; height: 48px; margin-top: -24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: var(--text);
  transition: background 0.2s, opacity 0.2s;
}
.viewer-nav:hover { background: rgba(255, 255, 255, 0.16); }
.viewer-nav:disabled { opacity: 0; pointer-events: none; }
.viewer-nav.prev { left: 18px; }
.viewer-nav.next { right: 18px; }
.viewer-info {
  position: relative;
  display: flex; flex-direction: column; gap: 18px;
  padding: 64px 24px 24px;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  overflow-y: auto;
}
.viewer-close { position: absolute; top: 12px; right: 12px; }
.viewer-prompt { margin: 0; font-size: 16px; line-height: 1.6; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.viewer-meta { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13.5px; }
.viewer-meta dt { color: var(--faint); }
.viewer-meta dd { margin: 0; color: #dcd9e0; font-variant-numeric: tabular-nums; }
.viewer-meta dd button { color: var(--tiffany); text-decoration: underline dotted; text-underline-offset: 3px; }
.viewer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; }
.viewer-actions .btn-primary { grid-column: 1 / -1; min-height: 50px; font-size: 15px; }
.viewer-actions svg { width: 18px; height: 18px; }

/* ---------- уведомления ---------- */
.toasts {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 80;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px 12px 18px;
  border-radius: 16px;
  background: rgba(28, 27, 34, 0.92);
  border: 1px solid var(--line-2);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.8);
  font-size: 14px;
  pointer-events: auto;
  animation: toast-in 0.4s var(--ease) both;
}
.toast.error { border-color: rgba(255, 122, 142, 0.45); }
.toast.error::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; }
.toast button { margin-left: auto; padding: 6px 10px; border-radius: 9px; font-weight: 650; font-size: 13px; color: var(--tiffany); }
.toast button:hover { background: var(--panel-2); }
.toast.out { animation: toast-out 0.3s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  :root { --composer-w: 340px; }
  .layout { gap: 20px; }
  .btn-generate kbd { display: none; }
}
.btn-generate span { white-space: nowrap; }

@media (max-width: 899px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 40px; gap: 26px; }
  .topbar { height: 58px; padding: 0 12px 0 16px; }
  .composer { position: static; max-height: none; overflow: visible; padding: 16px; border-radius: 22px; gap: 20px; }
  .chips:not(.empty .chips) {
    flex-wrap: nowrap; overflow-x: auto;
    margin: 0 -16px; padding: 0 16px 2px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent);
  }
  .chips::-webkit-scrollbar { display: none; }
  .btn-generate kbd { display: none; }
  .search { width: 100%; margin-left: 0; }
  .gallery-head { gap: 10px; }
  .tabs { width: 100%; }
  .tab { flex: 1; }
  .gallery, .col { gap: 10px; }
  .card { border-radius: 14px; }
  .pending-body { border-radius: 13px; }
  .card-over { display: none; }

  .viewer { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .viewer-stage img { inset: 60px 12px 12px; max-width: calc(100% - 24px); max-height: calc(100% - 72px); border-radius: 12px; }
  .viewer-nav { display: none; }
  .viewer-info { border-left: 0; border-top: 1px solid var(--line); padding: 16px 16px max(16px, env(safe-area-inset-bottom)); gap: 12px; max-height: 50dvh; position: static; }
  .viewer-close { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 10px; background: rgba(255, 255, 255, 0.1); color: var(--text); }
  .viewer-prompt { font-size: 14.5px; max-height: 6.2em; overflow-y: auto; }
  .viewer-meta { font-size: 12.5px; gap: 4px 14px; }
  .viewer-actions .btn-soft { min-height: 42px; font-size: 13.5px; padding: 0 10px; }
}

@media (max-width: 380px) {
  .aspect { height: 76px; }
  .aspect small { display: none; }
}

/* ---------- референсы ---------- */
.group h3 small { margin-left: 6px; font-size: 11.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--faint); }
.refs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ref-thumb, .ref-add { flex: none; width: 68px; height: 68px; border-radius: 14px; }
.ref-thumb { position: relative; overflow: hidden; border: 1px solid var(--line-2); background: var(--panel-2); animation: pop 0.45s var(--ease) both; }
.ref-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ref-thumb button {
  position: absolute; top: 4px; right: 4px;
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 7px;
  background: rgba(8, 8, 11, 0.72); color: #fff;
}
.ref-thumb button svg { width: 13px; height: 13px; stroke-width: 2.2; }
.ref-thumb.loading {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.ref-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px dashed var(--line-2);
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.ref-add svg { width: 22px; height: 22px; }
.ref-add:hover { border-color: var(--tiffany); color: var(--text); background: rgba(129, 216, 208, 0.06); }
.ref-note { flex: 1 1 160px; margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--faint); }
.composer.dragover { border-color: var(--tiffany); box-shadow: 0 0 0 4px rgba(129, 216, 208, 0.14); }
.meta-refs { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-refs img { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; border: 1px solid var(--line-2); }
.idea-head-refs { display: flex; gap: 6px; flex: none; }
.idea-head-refs img { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line-2); }

/* ---------- идея → промпт ---------- */
.idea-intro h2 { margin: 0; font: 400 26px/1.2 'Playfair Display', serif; }
.idea-intro p { margin: 8px 0 0; font-size: 14px; line-height: 1.55; color: var(--muted); }
.segmented.seg-text button { width: auto; padding: 0 14px; }

.ideas-wrap { min-width: 0; display: flex; flex-direction: column; gap: 34px; }
#ideas-result { scroll-margin-top: 84px; }
.idea-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.idea-head-text { flex: 1; min-width: 0; }
.idea-head-text small { display: block; font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.idea-head-text p {
  margin: 4px 0 0; font-size: 15px; line-height: 1.5; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.variant {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  transition: border-color 0.3s;
}
.variant:hover { border-color: var(--line-2); }
.variant.enter { animation: pop 0.6s var(--ease) both; }
.variant-head { display: flex; align-items: center; gap: 10px; }
.variant-num {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 9px;
  background: var(--grad); color: var(--on-grad);
  font-weight: 700; font-size: 13px;
}
.variant h3 { flex: 1; min-width: 0; margin: 0; font: 400 20px/1.25 'Playfair Display', serif; }
.variant-aspect {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 5px 9px; border-radius: 9px;
  border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.variant-aspect .shape { display: block; border: 1.4px solid currentColor; border-radius: 2px; }
.variant-prompt { flex: 1; margin: 0; font-size: 14.5px; line-height: 1.62; color: #e4e1e8; overflow-wrap: anywhere; }
.variant-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.variant-actions .btn-primary { flex: 1 1 auto; }
.btn-sm { min-height: 42px; padding: 0 14px; font-size: 14px; border-radius: 13px; }
.btn-sm svg { width: 18px; height: 18px; }
.btn-icon { width: 42px; padding: 0; }

.variant.skeleton { min-height: 300px; gap: 12px; }
.sk {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.04));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.sk.title { height: 22px; width: 55%; margin-bottom: 8px; }
.sk.short { width: 70%; }
.sk.btn { height: 42px; margin-top: auto; border-radius: 13px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.recent h3 { margin: 0 0 12px; font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recent-item {
  display: flex; align-items: center; gap: 4px;
  padding-right: 6px;
  border-radius: 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: border-color 0.2s, background 0.2s;
}
.recent-item:hover { border-color: var(--line-2); background: var(--panel-2); }
.recent-item.current { border-color: rgba(129, 216, 208, 0.45); }
.recent-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; text-align: left; }
.recent-open b { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-open small { font-size: 12px; color: var(--faint); }
.recent-item .icon-btn { width: 36px; height: 36px; }
.recent-item .icon-btn svg { width: 17px; height: 17px; }

@media (max-width: 899px) {
  /* backdrop-filter у шапки сделал бы её «окном» для position: fixed — панель разделов прилипла бы к шапке */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(8, 8, 11, 0.95); }
  .nav {
    position: fixed; left: 12px; right: 12px; transform: none;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 30;
    display: flex;
    background: rgba(22, 21, 28, 0.88);
    border-color: var(--line-2);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.85);
  }
  .nav-tab { flex: 1; height: 46px; font-size: 14.5px; }
  .layout { padding-bottom: 100px; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .idea-intro h2 { font-size: 23px; }
  .variants { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .variant { padding: 16px; border-radius: 20px; }
  .variant-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .variant-actions .btn-primary { grid-column: 1 / -1; }
}

@media (hover: none) {
  .card:hover { transform: none; box-shadow: none; }
  .card:hover .card-media img { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .pending-body .ring { animation: spin 1.6s linear infinite !important; }
}
