:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(10, 22, 38, 0.82);
  --panel-border: rgba(143, 201, 255, 0.16);
  --text: #eff7ff;
  --muted: #93acc4;
  --primary: #5ac8fa;
  --primary-strong: #00a3ff;
  --accent: #7ef7c8;
  --danger: #ff8f9b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(0, 163, 255, 0.22), transparent 32%),
    radial-gradient(circle at bottom right, rgba(126, 247, 200, 0.18), transparent 28%),
    linear-gradient(180deg, #07111f 0%, #0d1d33 100%);
}

.page-shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(32px, 5vw, 48px); }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
.hero-text { margin: 12px 0 0; color: var(--muted); max-width: 620px; line-height: 1.7; }
.hero-badges { display: grid; gap: 12px; }
.hero-badge {
  min-width: 180px;
  padding: 14px 18px;
  text-align: center;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(90, 200, 250, 0.18), rgba(0, 163, 255, 0.08));
  border: 1px solid rgba(90, 200, 250, 0.3);
  color: #d8f3ff;
  font-weight: 700;
}
.hero-badge-sub {
  background: linear-gradient(135deg, rgba(126, 247, 200, 0.12), rgba(22, 56, 83, 0.12));
  border-color: rgba(126, 247, 200, 0.24);
  color: #dffff5;
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 22px;
}

.panel { padding: 22px; }
.field-label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 10px;
}
textarea,
select {
  width: 100%;
  border: 1px solid rgba(145, 174, 207, 0.18);
  background: rgba(4, 11, 20, 0.62);
  color: var(--text);
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 16px;
  outline: none;
}
textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.7;
}
textarea:focus,
select:focus {
  border-color: rgba(90, 200, 250, 0.72);
  box-shadow: 0 0 0 4px rgba(90, 200, 250, 0.12);
}

.mode-banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(90, 200, 250, 0.12);
  border: 1px solid rgba(90, 200, 250, 0.16);
  color: #d9f6ff;
  font-weight: 700;
}

.toolbar {
  display: grid;
  gap: 16px;
  align-items: end;
  margin-top: 18px;
}
.toolbar-2col { grid-template-columns: 1fr 1fr; }
.toolbar-3col { grid-template-columns: repeat(3, 1fr); }
.toolbar-action { grid-template-columns: 1fr; }

.primary-btn,
.ghost-btn,
.chip,
.upload-btn,
.history-card {
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}
.primary-btn:hover,
.ghost-btn:hover,
.chip:hover,
.upload-btn:hover,
.history-card:hover { transform: translateY(-1px); }
.primary-btn:disabled,
.ghost-btn.disabled { cursor: not-allowed; opacity: 0.55; transform: none; }

.primary-btn {
  width: 100%;
  padding: 16px 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #03121f;
  font-size: 16px;
  font-weight: 800;
}

.ghost-btn,
.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(143, 201, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  border: 1px solid rgba(143, 201, 255, 0.12);
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(126, 247, 200, 0.08);
  color: #d8ffef;
  border: 1px solid rgba(126, 247, 200, 0.16);
}

.reference-card,
.history-section {
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(4, 11, 20, 0.52);
  border: 1px solid rgba(145, 174, 207, 0.12);
}
.reference-head,
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.reference-title { font-size: 16px; font-weight: 700; }
.reference-desc { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.reference-empty,
.history-empty {
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(10, 22, 38, 0.6);
  color: var(--muted);
  text-align: center;
}
.reference-preview-wrap { margin-top: 14px; display: grid; gap: 12px; }
#referencePreview {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(10, 22, 38, 0.9);
  border: 1px solid rgba(145, 174, 207, 0.12);
}

.status-box {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(4, 11, 20, 0.62);
  color: var(--muted);
  line-height: 1.6;
  min-height: 56px;
}

.history-list {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  max-height: 420px;
  overflow: auto;
}
.history-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(10, 22, 38, 0.9);
  border: 1px solid rgba(145, 174, 207, 0.08);
  text-align: left;
}
.history-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  background: rgba(4, 11, 20, 0.9);
}
.history-title {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.preview-frame {
  position: relative;
  min-height: 680px;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(90, 200, 250, 0.08), rgba(126, 247, 200, 0.08)),
    rgba(4, 11, 20, 0.72);
  border: 1px solid rgba(145, 174, 207, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

#resultImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.empty-state {
  text-align: center;
  color: var(--muted);
}
.empty-icon { font-size: 56px; margin-bottom: 14px; }

.loading-layer {
  position: absolute;
  inset: 0;
  background: rgba(4, 11, 20, 0.74);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  text-align: center;
  gap: 16px;
}
.spinner {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.meta-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}
.meta-item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(4, 11, 20, 0.5);
  color: var(--muted);
}
.meta-item strong { color: var(--text); }

@media (max-width: 1100px) {
  .page-shell { width: min(100vw - 20px, 1000px); padding-top: 18px; }
  .grid { grid-template-columns: 1fr; }
  .preview-frame { min-height: 420px; }
}

@media (max-width: 720px) {
  .hero-card,
  .reference-head,
  .history-head,
  .preview-header,
  .toolbar-2col { grid-template-columns: 1fr; display: grid; }
  .hero-badges { width: 100%; }
  .history-card { grid-template-columns: 60px 1fr; }
  .history-thumb { width: 60px; height: 60px; }
}
