:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #676b73;
  --line: #d9ded8;
  --panel: #ffffff;
  --paper: #f6f5f0;
  --mint: #2b8a6e;
  --mint-dark: #17614d;
  --coral: #cc4b3f;
  --amber: #c98921;
  --shadow: 0 18px 60px rgba(25, 29, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(135deg, rgba(43, 138, 110, 0.13), transparent 30%),
    linear-gradient(315deg, rgba(204, 75, 63, 0.12), transparent 34%),
    var(--paper);
}

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

button {
  cursor: pointer;
}

.shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 56px);
}

.composer,
.result-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

.brand-row,
.toolbar,
.image-actions,
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--mint-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 850;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.04;
}

h2 {
  font-size: 25px;
}

.status-pill {
  flex: 0 1 auto;
  max-width: 170px;
  overflow: hidden;
  border: 1px solid rgba(43, 138, 110, 0.35);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--mint-dark);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.switch,
.counter {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

textarea,
select,
input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

textarea:focus,
select:focus,
input:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(43, 138, 110, 0.14);
}

textarea {
  min-height: 230px;
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
}

select,
input {
  padding: 0 12px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.switch-row {
  min-height: 34px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.switch span {
  position: relative;
  width: 48px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #e9ebe7;
  transition: background 0.16s ease;
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
  content: "";
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: var(--mint);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.password-row[hidden] {
  display: none;
}

.generate-button,
.ghost-button,
.image-actions button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 820;
}

.generate-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: auto;
  padding: 0 16px;
  color: #fff;
  background: var(--ink);
}

.generate-button:hover {
  background: #000;
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.button-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mint);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--coral);
  font-size: 13px;
  line-height: 1.5;
}

.result-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 22px;
}

.toolbar {
  min-height: 54px;
  margin-bottom: 18px;
}

.ghost-button,
.image-actions button {
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.ghost-button:hover,
.image-actions button:hover {
  border-color: var(--mint);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  align-content: start;
}

.image-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.image-wrap,
.empty-frame {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(45deg, rgba(43, 138, 110, 0.16), transparent),
    linear-gradient(135deg, rgba(201, 137, 33, 0.2), transparent),
    #eceee8;
  aspect-ratio: 1 / 1;
}

.image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f2f3ef;
}

.image-card.loading .image-wrap::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  content: "";
  animation: shimmer 1.1s linear infinite;
}

.image-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.image-actions button {
  min-width: 0;
  min-height: 38px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-prompt {
  display: -webkit-box;
  min-height: 42px;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 14px;
  height: 100%;
  min-height: 420px;
  color: var(--muted);
  text-align: center;
}

.empty-frame {
  width: min(330px, 72vw);
  border: 1px solid var(--line);
}

.empty-frame::before,
.empty-frame::after {
  position: absolute;
  content: "";
}

.empty-frame::before {
  inset: 16%;
  border: 1px solid rgba(23, 23, 23, 0.14);
  border-radius: 6px;
}

.empty-frame::after {
  right: 18%;
  bottom: 18%;
  width: 44%;
  height: 34%;
  border-radius: 60% 40% 0 0;
  background: rgba(43, 138, 110, 0.36);
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

@media (max-width: 940px) {
  .shell {
    padding: 16px;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .composer {
    min-height: auto;
  }

  textarea {
    min-height: 180px;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 0;
  }

  .workspace {
    gap: 0;
  }

  .composer,
  .result-area {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .brand-row,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    max-width: 100%;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .gallery {
    grid-template-columns: 1fr;
  }
}
