:root {
  color-scheme: dark;
  --bg: #07090f;
  --ink: #f5f7fb;
  --muted: #9ba7bd;
  --soft: #657189;
  --panel: rgba(15, 22, 35, 0.78);
  --panel-strong: rgba(12, 18, 30, 0.94);
  --line: rgba(157, 174, 207, 0.18);
  --input: rgba(5, 9, 16, 0.68);
  --cyan: #6ee7ff;
  --violet: #b989ff;
  --rose: #ff7aa8;
  --mint: #73f2b5;
  --warn: #ffd166;
  --danger: #ff6b6b;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    radial-gradient(circle at 18% 8%, rgba(110, 231, 255, 0.2), transparent 28rem),
    radial-gradient(circle at 84% 18%, rgba(185, 137, 255, 0.18), transparent 30rem),
    radial-gradient(circle at 74% 88%, rgba(115, 242, 181, 0.12), transparent 22rem),
    var(--bg);
  background-size: 56px 56px, 56px 56px, auto, auto, auto, auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.ambient {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  filter: blur(18px);
  opacity: 0.6;
}

.ambient-one {
  top: 18%;
  left: -8rem;
  width: 22rem;
  height: 22rem;
  border: 1px solid rgba(110, 231, 255, 0.28);
  border-radius: 50%;
  animation: float 11s ease-in-out infinite;
}

.ambient-two {
  right: -10rem;
  bottom: 8%;
  width: 26rem;
  height: 26rem;
  border-radius: 42% 58% 44% 56%;
  background: linear-gradient(135deg, rgba(255, 122, 168, 0.22), rgba(185, 137, 255, 0.09));
  animation: morph 13s ease-in-out infinite;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1220px, calc(100% - 34px));
  margin: 0 auto;
  padding: 18px 0 56px;
}

.topbar {
  min-height: 56px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.logo-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #071018;
  font-weight: 950;
  background: conic-gradient(from 180deg, var(--cyan), var(--violet), var(--rose), var(--mint), var(--cyan));
  box-shadow: 0 12px 40px rgba(110, 231, 255, 0.18);
}

.logo strong,
.logo small {
  display: block;
}

.logo strong {
  font-size: 18px;
}

.logo small {
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.icon-btn,
.generate-btn,
.preset-row button,
.download-btn,
.copy-btn {
  border: 0;
  color: var(--ink);
  cursor: pointer;
}

.icon-btn {
  min-width: 78px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(12, 18, 30, 0.72);
}

.icon-btn.solid {
  background: linear-gradient(135deg, rgba(110, 231, 255, 0.24), rgba(185, 137, 255, 0.22));
}

.hero {
  max-width: 780px;
  padding: 54px 0 28px;
}

.kicker,
.section-label {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 650px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 0.96fr) minmax(360px, 1.04fr);
  gap: 18px;
  align-items: start;
}

.glass {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--panel), var(--panel-strong));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), transparent 26%, transparent 72%, rgba(110, 231, 255, 0.07));
}

.composer,
.preview {
  padding: 24px;
}

.section-head {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 20px;
}

h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(115, 242, 181, 0.24);
  border-radius: 999px;
  color: var(--mint);
  font-size: 12px;
  background: rgba(115, 242, 181, 0.08);
}

.live-dot i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 14px var(--mint);
}

.mode-switch {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 0 0 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(5, 9, 16, 0.58);
  isolation: isolate;
}

.mode-thumb {
  position: absolute;
  top: 5px;
  left: 5px;
  width: calc(50% - 5px);
  height: calc(100% - 10px);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 12px 34px rgba(110, 231, 255, 0.18);
  transition: transform 0.34s cubic-bezier(0.5, 0.05, 0.2, 1);
  z-index: 0;
  pointer-events: none;
}

.mode-switch label {
  position: relative;
  z-index: 1;
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-switch span {
  display: grid;
  place-items: center;
  height: 42px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
  transition: color 0.25s ease;
}

.mode-switch input:checked + span {
  color: #071018;
}

.grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  margin-bottom: 13px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
}

.field span {
  color: #dbe6f6;
  font-size: 12px;
  font-weight: 780;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(157, 174, 207, 0.2);
  outline: none;
  border-radius: 14px;
  color: var(--ink);
  background: var(--input);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

input,
select {
  height: 44px;
  padding: 0 13px;
}

textarea {
  min-height: 156px;
  resize: vertical;
  padding: 14px;
  line-height: 1.65;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(110, 231, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(110, 231, 255, 0.1);
  transform: translateY(-1px);
}

.upload-zone {
  position: relative;
  z-index: 1;
  min-height: 128px;
  margin: 0 0 13px;
  padding: 18px;
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  border: 1px dashed rgba(110, 231, 255, 0.42);
  border-radius: 18px;
  background: rgba(110, 231, 255, 0.06);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.upload-zone.hidden {
  display: none;
}

.upload-zone.dragging {
  border-color: var(--cyan);
  background: rgba(110, 231, 255, 0.16);
  transform: scale(1.01);
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-prompt,
.upload-preview {
  position: relative;
  z-index: 1;
  width: 100%;
}

.upload-prompt {
  display: grid;
  place-items: center;
  gap: 6px;
}

.upload-prompt.hidden,
.upload-preview.hidden {
  display: none;
}

.upload-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 4px;
}

.upload-preview img {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.upload-meta {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}

.upload-meta strong {
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-meta small {
  color: var(--muted);
  font-size: 12px;
}

.upload-clear {
  position: relative;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.upload-clear:hover {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.1);
}

.upload-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #071018;
  font-size: 24px;
  font-weight: 700;
  background: var(--cyan);
}

.upload-prompt small {
  color: var(--muted);
}

.preset-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 13px 0 18px;
}

.preset-row button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: #dbe6f6;
  font-size: 12px;
}

.preset-row button:hover {
  border-color: rgba(110, 231, 255, 0.55);
}

.form-footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.form-footer p {
  margin: 0;
  color: var(--soft);
  font-size: 12px;
}

.generate-btn {
  position: relative;
  min-width: 142px;
  height: 46px;
  overflow: hidden;
  border-radius: 999px;
  color: #071018;
  font-weight: 900;
  background: linear-gradient(135deg, var(--mint), var(--cyan), var(--violet));
  box-shadow: 0 18px 42px rgba(110, 231, 255, 0.2);
}

.generate-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.generate-btn span {
  position: absolute;
  inset: -80% auto auto -30%;
  width: 70px;
  height: 190px;
  background: rgba(255, 255, 255, 0.32);
  transform: rotate(28deg);
  animation: sweep 3s ease-in-out infinite;
}

.status-stack {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.status-badge {
  min-width: 48px;
  padding: 7px 11px;
  border-radius: 999px;
  text-align: center;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  background: rgba(110, 231, 255, 0.09);
  border: 1px solid rgba(110, 231, 255, 0.16);
}

.status-badge.working {
  color: #071018;
  background: var(--warn);
}

.status-badge.done {
  color: #06140d;
  background: var(--mint);
}

.status-badge.error {
  color: #210909;
  background: var(--danger);
}

#elapsed {
  color: var(--muted);
  font-size: 12px;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 520px;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(110, 231, 255, 0.08), transparent 42%),
    radial-gradient(circle at 78% 22%, rgba(255, 122, 168, 0.11), transparent 22rem),
    rgba(4, 7, 13, 0.5);
}

.stage.empty,
.stage.loading {
  display: grid;
  place-items: center;
  padding: 28px;
}

.empty-state,
.loader,
.error-box {
  max-width: 560px;
  text-align: left;
  color: var(--muted);
}

.empty-state strong,
.loader strong,
.error-box strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 20px;
}

.empty-state p,
.loader p,
.error-box p {
  margin: 0;
  line-height: 1.7;
  white-space: pre-wrap;
}

.preview-orb {
  width: 96px;
  height: 96px;
  margin: 0 auto 18px;
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(110, 231, 255, 0.2), rgba(185, 137, 255, 0.24)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.22) 0 8px, transparent 8px 16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  animation: breathe 2.8s ease-in-out infinite;
}

.loader-orbit {
  width: 86px;
  height: 86px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--cyan);
  border-right-color: var(--violet);
  animation: spin 0.95s linear infinite;
}

.loader-lines {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.loader-lines i {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.loader-lines i::before {
  content: "";
  display: block;
  width: 46%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--violet));
  animation: drift 1.25s ease-in-out infinite;
}

.loader-lines i:nth-child(2)::before {
  animation-delay: 0.18s;
}

.loader-lines i:nth-child(3)::before {
  animation-delay: 0.36s;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 16px;
}

.image-card {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  animation: rise 0.35s ease both;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.3s ease, box-shadow 0.3s ease;
}

.image-card:hover {
  transform: translateY(-4px);
  border-color: rgba(110, 231, 255, 0.4);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
}

.image-frame {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: rgba(3, 6, 11, 0.8);
  cursor: zoom-in;
  overflow: hidden;
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.image-frame img.img-ready {
  opacity: 1;
  transform: scale(1);
}

.image-frame:hover img.img-ready {
  transform: scale(1.04);
}

.image-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
}

.image-link {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px 0;
}

.image-link.hidden {
  display: none;
}

.image-url {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--cyan);
  font-size: 11px;
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid rgba(110, 231, 255, 0.25);
  border-radius: 999px;
  background: rgba(110, 231, 255, 0.06);
  transition: border-color 0.18s ease, background 0.18s ease;
}

.image-url:hover {
  border-color: rgba(110, 231, 255, 0.55);
  background: rgba(110, 231, 255, 0.14);
}

.copy-url-btn {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.copy-url-btn:hover {
  color: var(--cyan);
  border-color: rgba(110, 231, 255, 0.45);
  background: rgba(110, 231, 255, 0.12);
}

.image-frame.frame-error::after {
  content: "图片加载失败，请使用下方链接";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  color: var(--warn);
  font-size: 12px;
  background: rgba(7, 16, 24, 0.85);
}

.image-frame {
  position: relative;
}

.download-btn,
.copy-btn,
.zoom-btn {
  flex: 1 1 0;
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 860;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.download-btn:hover,
.copy-btn:hover,
.zoom-btn:hover {
  background: rgba(110, 231, 255, 0.14);
  border-color: rgba(110, 231, 255, 0.45);
  color: var(--cyan);
}

.history {
  position: relative;
  z-index: 1;
  margin-top: 18px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.history-list {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.history-item {
  position: relative;
  flex: 0 0 68px;
}

.history-item:hover .history-remove {
  opacity: 1;
  transform: scale(1);
}

.history-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(15, 22, 35, 0.95);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.18s ease, transform 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  z-index: 2;
}

.history-remove:hover {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.5);
}

.history-thumb {
  width: 68px;
  height: 68px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.history-thumb:hover {
  border-color: rgba(110, 231, 255, 0.5);
  transform: translateY(-2px);
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(34px);
  }
}

@keyframes morph {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
    border-radius: 42% 58% 44% 56%;
  }
  50% {
    transform: rotate(10deg) scale(1.07);
    border-radius: 58% 42% 56% 44%;
  }
}

@keyframes sweep {
  0% {
    transform: translateX(0) rotate(28deg);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  100% {
    transform: translateX(260px) rotate(28deg);
    opacity: 0;
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(110, 231, 255, 0.18);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 22px rgba(110, 231, 255, 0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes drift {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(260%);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-row .hint {
  color: var(--soft);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ghost-btn {
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.ghost-btn:hover {
  color: var(--cyan);
  border-color: rgba(110, 231, 255, 0.45);
  background: rgba(110, 231, 255, 0.08);
}

.remember-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 9, 16, 0.45);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.remember-row:hover {
  border-color: rgba(110, 231, 255, 0.35);
}

.remember-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--cyan);
}

.error-actions {
  margin-top: 14px;
}

.usage-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 9, 16, 0.45);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.usage-row.hidden {
  display: none;
}

.usage-row span {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(110, 231, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(110, 231, 255, 0.18);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(2, 4, 8, 0.86);
  backdrop-filter: blur(14px);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.lightbox.hidden {
  display: none;
}

.lightbox.lightbox-in {
  opacity: 1;
}

.lightbox img {
  max-width: min(92vw, 1400px);
  max-height: 88vh;
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  transform: scale(0.97);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lightbox.lightbox-in img {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(15, 22, 35, 0.85);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.lightbox-close:hover {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.5);
  transform: rotate(90deg);
}

.toast-stack {
  position: fixed;
  z-index: 60;
  top: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 180px;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--panel), var(--panel-strong));
  backdrop-filter: blur(18px);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast-in {
  opacity: 1;
  transform: translateX(0);
}

.toast-out {
  opacity: 0;
  transform: translateX(20px);
}

.toast-success {
  border-color: rgba(115, 242, 181, 0.45);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(115, 242, 181, 0.12) inset;
}

.toast-error {
  border-color: rgba(255, 107, 107, 0.45);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 107, 107, 0.12) inset;
}

.toast-info {
  border-color: rgba(110, 231, 255, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 34px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 22px, 1220px);
  }

  .topbar,
  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .composer,
  .preview {
    padding: 16px;
    border-radius: 18px;
  }

  .hero h1 {
    font-size: 40px;
  }

  .generate-btn {
    width: 100%;
  }
}
