:root {
  color-scheme: dark;
  --bg: #080b12;
  --bg-soft: #0e1422;
  --text: #f8fafc;
  --muted: #9aa4b2;
  --line: rgba(255, 255, 255, 0.13);
  --glass: rgba(18, 24, 38, 0.66);
  --glass-strong: rgba(25, 33, 52, 0.82);
  --orange: #ff6a35;
  --orange-2: #ff9f43;
  --cyan: #5eead4;
  --blue: #60a5fa;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(96, 165, 250, 0.22), transparent 28rem),
    radial-gradient(circle at 86% 18%, rgba(255, 106, 53, 0.16), transparent 26rem),
    linear-gradient(135deg, #080b12 0%, #111827 46%, #0b1020 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  padding-top: 14px;
}

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

button {
  cursor: pointer;
}

.ambient {
  position: fixed;
  z-index: -1;
  filter: blur(70px);
  opacity: 0.55;
  pointer-events: none;
}

.ambient-a {
  width: 28rem;
  height: 28rem;
  left: -8rem;
  top: 12rem;
  background: rgba(94, 234, 212, 0.24);
}

.ambient-b {
  width: 32rem;
  height: 32rem;
  right: -10rem;
  top: 3rem;
  background: rgba(255, 106, 53, 0.24);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 12, 22, 0.62);
  backdrop-filter: blur(20px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
}

.brand,
.nav a {
  color: var(--text);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--orange), var(--cyan));
  color: #08111d;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  gap: 6px;
}

.nav a {
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

main {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  min-height: calc(100vh - 82px);
  padding: 24px 0 42px;
}

.hero-copy {
  /* max-width: 780px; */
  margin-bottom: 28px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--orange-2);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  /* max-width: 840px; */
  margin-bottom: 14px;
  font-size: clamp(42px, 6vw, 84px);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(22px, 2.5vw, 34px);
}

.lead {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.glass,
.panel,
.template-card,
.modal-card {
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
}

.generator-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 18px;
  padding: 18px;
  border-radius: var(--radius);
}

.panel {
  min-width: 0;
  border-radius: 20px;
  padding: 22px;
  background: rgba(11, 17, 30, 0.58);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.field,
.search-field,
.select-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 12px;
  margin-top: 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input,
select {
  height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 186px;
  resize: vertical;
  padding: 14px;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(255, 159, 67, 0.72);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 4px rgba(255, 106, 53, 0.12);
}

.upload-block {
  margin: 16px 0;
}

.label-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.label-row b {
  color: var(--text);
}

.upload-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
}

.upload-zone {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  width: 92px;
  min-height: 92px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.upload-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.plus {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

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

.upload-thumb {
  position: relative;
  width: 92px;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

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

.upload-thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
}

.prompt-field small {
  justify-self: end;
  color: var(--muted);
}

.choice-group {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.segmented.aspect {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.choice,
.ghost-button,
.primary-button,
.pagination button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  color: var(--text);
}

.choice {
  min-height: 52px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
}

.choice.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  color: #fff;
  box-shadow: 0 12px 28px rgba(255, 106, 53, 0.28);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  margin-top: 22px;
  border: 0;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 18px 42px rgba(255, 106, 53, 0.28);
}

.primary-button:disabled {
  cursor: wait;
  filter: grayscale(0.5);
  opacity: 0.76;
}

.ghost-button {
  min-height: 42px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.result-stage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  min-height: 650px;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 100%;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.loading-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 100%;
  border: 1px solid rgba(255, 159, 67, 0.22);
  border-radius: 18px;
  background:
    radial-gradient(circle at center, rgba(255, 106, 53, 0.14), transparent 18rem),
    rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: center;
}

.loading-state p {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.loading-state small {
  color: var(--muted);
}

.loader-ring {
  width: 62px;
  height: 62px;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--orange-2);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--orange-2);
  font-size: 28px;
}

.result-item {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
}

.result-item img {
  display: block;
  width: 100%;
  height: 100%;
  /* min-height: 280px; */
  max-height:68vh;
  object-fit: contain;
  cursor: zoom-in;
}

.result-item a {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.result-item::after {
  content: "点击图片查看大图";
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.48);
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.result-item:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.templates {
  padding: 64px 0 96px;
}

.section-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.library-tools {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(150px, 220px);
  gap: 12px;
}

.meta-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}

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

.template-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  content-visibility: auto;
  contain-intrinsic-size: 320px 400px;
}

.card-main {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
}

.card-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.card-main img.is-loaded {
  opacity: 1;
}

.template-card:hover img {
  transform: scale(1.04);
}

.card-gradient {
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
}

.card-title {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: -webkit-box;
  overflow: hidden;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.35;
  text-align: left;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.use-card-prompt {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.template-card:hover .use-card-prompt,
.template-card:focus-within .use-card-prompt {
  opacity: 1;
  transform: translateY(0);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
}

.pagination button {
  min-width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.06);
}

.pagination button.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  font-weight: 900;
}

.pagination button:disabled {
  cursor: default;
  opacity: 0.45;
}

.prompt-modal {
  width: min(1160px, calc(100% - 28px));
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.prompt-modal::backdrop {
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(10px);
}

.image-viewer {
  width: min(96vw, 1800px);
  height: min(94vh, 1200px);
  padding: 0;
  border: 0;
  background: transparent;
}

.image-viewer::backdrop {
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(12px);
}

.image-viewer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(10, 14, 24, 0.92);
}

.image-viewer-close {
  position: fixed;
}

.modal-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(360px, 1.08fr);
  max-height: min(820px, calc(100vh - 28px));
  overflow: hidden;
  border-radius: 24px;
  background: rgba(13, 18, 30, 0.92);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  font-size: 28px;
  text-align: center;
  line-height: 36px;
}

.modal-media {
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: inherit;
  overflow: auto;
  padding: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.modal-media img {
  width: 100%;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.modal-info {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 38px 28px 24px;
}

.modal-info h3 {
  margin-bottom: 10px;
  font-size: clamp(26px, 3vw, 44px);
  line-height: 1.1;
}

.modal-desc {
  color: var(--muted);
  line-height: 1.7;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tag {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.modal-prompt {
  min-height: 0;
  flex: 1;
}

.modal-prompt textarea {
  min-height: 260px;
  height: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.modal-actions .primary-button {
  margin-top: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 100;
  transform: translateX(-50%);
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 17, 30, 0.9);
  color: var(--text);
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .generator-shell,
  .modal-card {
    grid-template-columns: 1fr;
  }

  .result-stage {
    min-height: 420px;
  }

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

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
    overflow-x: auto;
  }

  main,
  .topbar {
    width: min(100% - 20px, 1480px);
  }

  .hero {
    padding-top: 24px;
  }

  .generator-shell,
  .panel {
    padding: 12px;
  }

  .field-grid,
  .library-tools,
  .section-title-row,
  .meta-line {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

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

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

  .modal-actions {
    grid-template-columns: 1fr;
  }
}

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