:root {
  --bg: #07150d;
  --bg-soft: #0c2416;
  --panel: rgba(14, 46, 28, 0.72);
  --panel-2: rgba(8, 28, 17, 0.88);
  --line: rgba(134, 239, 172, 0.18);
  --text: #ecfdf3;
  --muted: #9cb8a6;
  --green: #4ade80;
  --green-2: #22c55e;
  --green-deep: #166534;
  --danger: #fb7185;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  --radius: 22px;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
}

body {
  padding: calc(18px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(74, 222, 128, 0.18), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(21, 128, 61, 0.28), transparent 50%),
    linear-gradient(180deg, #0a1f13 0%, #07150d 42%, #051109 100%);
  z-index: -1;
}

.topbar,
.studio,
.gallery-wrap,
.progress,
.card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto 16px;
  padding: 14px 16px;
  border-radius: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand > div {
  min-width: 0;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #86efac, #166534);
}

.logo svg {
  width: 26px;
  height: 26px;
  fill: #052e16;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  letter-spacing: 0.12em;
}

.brand p,
.hint,
.count,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--green);
  white-space: nowrap;
}

.status-pill.bad {
  color: var(--danger);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lang-switch {
  display: flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 28, 17, 0.7);
}

.lang-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-width: 36px;
  height: 28px;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.lang-switch button.active {
  background: #4ade80;
  color: #052e16;
  font-weight: 700;
}

html[lang="en"] h1 {
  letter-spacing: 0.04em;
}

.layout {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.studio,
.gallery-wrap {
  border-radius: var(--radius);
  padding: 18px;
}

.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 16px;
  background: rgba(5, 20, 12, 0.55);
}

.mode {
  border: 0;
  min-height: 40px;
  padding: 8px 6px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  line-height: 1.2;
  cursor: pointer;
}

html[lang="en"] .mode {
  font-size: 13px;
}

.mode.active {
  background: linear-gradient(180deg, #4ade80, #16a34a);
  color: #052e16;
  font-weight: 700;
}

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

.label-row {
  display: flex;
  justify-content: space-between;
}

textarea,
select,
input,
input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.55;
}

textarea:focus,
select:focus,
input:focus {
  border-color: rgba(74, 222, 128, 0.55);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.size-btn,
.stepper button,
.text-btn,
.card-btn,
.ghost,
.lightbox-bar button {
  border: 1px solid var(--line);
  background: rgba(22, 101, 52, 0.28);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

.chip:hover,
.size-btn:hover,
.stepper button:hover,
.card-btn:hover,
.ghost:hover {
  border-color: var(--green);
}

.chip {
  font-size: 12px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 99px;
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
}

.stepper button {
  height: 44px;
  border-radius: 14px;
  font-size: 20px;
}

.stepper strong {
  text-align: center;
  font-size: 18px;
}

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

.size-btn {
  border-radius: 16px;
  min-height: 44px;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.3;
  font-size: 12px;
}

.size-btn.active,
.chip.active,
.text-btn.active {
  background: linear-gradient(180deg, #4ade80, #16a34a);
  color: #052e16;
  border-color: transparent;
  font-weight: 700;
}

.dropzone {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  background: rgba(8, 28, 17, 0.55);
}

.dropzone.drag {
  border-color: var(--green);
  background: rgba(22, 101, 52, 0.25);
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}

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

.thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 99px;
  background: rgba(5, 20, 12, 0.8);
  color: var(--text);
  cursor: pointer;
  z-index: 2;
}

.thumb .bbox-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  z-index: 1;
}

.thumb .bbox-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  z-index: 2;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.92);
  color: #052e16;
}

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

.scene-row textarea {
  width: 100%;
  min-height: 52px;
}

.custom-palette {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.custom-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-edit {
  display: flex;
  align-items: center;
  gap: 4px;
}

.color-edit input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.shortcut {
  margin-top: 6px;
}

.prompt-more {
  margin-top: 8px;
}

.prompt-more summary {
  cursor: pointer;
  color: var(--green);
  font-size: 12px;
}

.filter-btn.active,
.head-actions .text-btn.active {
  color: #052e16;
  background: #86efac;
  border-color: transparent;
}

.seed-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.advanced {
  margin: 4px 0 16px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.advanced summary {
  cursor: pointer;
  color: var(--green);
  margin-bottom: 12px;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.action-row {
  display: flex;
  gap: 8px;
}

.generate,
.ghost {
  height: 52px;
}

.generate {
  flex: 1;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(90deg, #86efac, #22c55e 55%, #15803d);
  color: #052e16;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ghost {
  min-width: 84px;
  border-radius: 18px;
}

.generate:disabled {
  opacity: 0.65;
  cursor: wait;
}

.hint {
  margin-top: 10px;
  min-height: 18px;
}

.hint.error {
  color: var(--danger);
}

.gallery-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.head-actions input {
  width: 140px;
  padding: 8px 12px;
  border-radius: 999px;
}

.text-btn {
  background: transparent;
}

.progress {
  padding: 12px;
  border-radius: 16px;
  margin-bottom: 14px;
}

.progress-bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-bar i {
  display: block;
  height: 100%;
  width: 18%;
  border-radius: inherit;
  background: linear-gradient(90deg, #86efac, #22c55e);
  animation: load 1.6s ease infinite;
}

@keyframes load {
  0% {
    width: 12%;
    transform: translateX(0);
  }
  50% {
    width: 58%;
    transform: translateX(20%);
  }
  100% {
    width: 12%;
    transform: translateX(700%);
  }
}

.gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.card {
  border-radius: 20px;
  overflow: hidden;
  background: var(--panel-2);
}

.card-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.card-images.single {
  grid-template-columns: 1fr;
}

.card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #0b1f14;
  cursor: zoom-in;
}

.card-body {
  padding: 12px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}

.card-body p {
  font-size: 13px;
  line-height: 1.5;
  color: #d1fae5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.star {
  margin-left: auto;
}

.star.active {
  color: #052e16;
  background: #86efac;
  border-color: transparent;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 12px;
  border: 1px dashed var(--line);
  border-radius: 20px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2, 10, 6, 0.9);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 56px 16px 72px;
}

.lightbox img {
  max-width: min(92vw, 920px);
  max-height: 78vh;
  border-radius: 16px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 99px;
  background: #4ade80;
  color: #052e16;
  font-size: 28px;
  cursor: pointer;
}

.lightbox-nav.prev {
  left: 12px;
}

.lightbox-nav.next {
  right: 12px;
}

.lightbox-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(16px + var(--safe-bottom));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  align-items: center;
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #14532d;
  color: #ecfdf3;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  z-index: 30;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

@media (min-width: 840px) {
  body {
    padding: calc(28px + var(--safe-top)) 28px 40px;
  }

  .layout {
    grid-template-columns: minmax(320px, 420px) 1fr;
    align-items: start;
  }

  .studio {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow: auto;
  }

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

  .sizes {
    grid-template-columns: repeat(4, 1fr);
  }

  .head-actions input {
    width: 180px;
  }
}

@media (min-width: 1280px) {
  .gallery {
    grid-template-columns: repeat(3, 1fr);
  }
}
