:root {
  color-scheme: dark;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --bg: #0b0f17;
  --card: #151a24;
  --text: #e5e7eb;
  --muted: #9aa3b2;
  --accent: #6fb89a;
  --accent-light: rgba(111, 184, 154, 0.18);
  --border: #2a3140;
  --shadow: 0 18px 45px rgba(9, 12, 18, 0.65);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #151a24 0%, var(--bg) 55%);
  color: var(--text);
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 48px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

#loginView {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px 28px;
  border-radius: 24px;
  background: linear-gradient(120deg, rgba(10, 14, 24, 0.96) 0%, rgba(24, 28, 40, 0.98) 100%);
  box-shadow: var(--shadow);
  border: 1px solid rgba(128, 148, 255, 0.12);
}

.hero-login {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(112, 174, 255, 0.2);
  background: radial-gradient(circle at top left, rgba(73, 112, 255, 0.3), transparent 55%),
    radial-gradient(circle at 80% 20%, rgba(111, 255, 214, 0.18), transparent 45%),
    linear-gradient(135deg, rgba(10, 14, 24, 0.98) 0%, rgba(18, 24, 36, 0.98) 100%);
}

.hero-login::after {
  content: "";
  position: absolute;
  inset: -40% 60% 30% -20%;
  background: radial-gradient(circle, rgba(111, 184, 154, 0.28), transparent 65%);
  opacity: 0.6;
  pointer-events: none;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hero-logo {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  object-fit: contain;
  background: transparent;
  padding: 0;
}

.hero h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  margin: 0;
  line-height: 1;
  display: flex;
  align-items: center;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.account {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-weight: 600;
}

.account-name {
  font-size: 1.1rem;
}

.account-points {
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

#loginCard {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(20, 26, 38, 0.98) 0%, rgba(10, 12, 20, 0.98) 100%);
  border: 1px solid rgba(116, 167, 255, 0.18);
}

#loginCard::before {
  content: "";
  position: absolute;
  inset: -30% 55% 50% -25%;
  background: radial-gradient(circle, rgba(79, 121, 255, 0.35), transparent 60%);
  opacity: 0.7;
  pointer-events: none;
}

#loginCard::after {
  content: "";
  position: absolute;
  inset: 60% -10% -40% 50%;
  background: radial-gradient(circle, rgba(79, 255, 223, 0.22), transparent 60%);
  opacity: 0.6;
  pointer-events: none;
}

.card h2 {
  margin-top: 0;
}

#loginView .form {
  gap: 18px;
}

#loginView .field input {
  background: rgba(18, 24, 36, 0.9);
  border-color: rgba(79, 121, 255, 0.25);
  box-shadow: inset 0 0 0 1px rgba(12, 16, 24, 0.3);
}

#loginView .field input:focus {
  outline: none;
  border-color: rgba(111, 184, 154, 0.8);
  box-shadow: 0 0 0 2px rgba(111, 184, 154, 0.18);
}

#loginView #loginBtn {
  background: linear-gradient(135deg, rgba(111, 184, 154, 0.95), rgba(68, 214, 168, 0.95));
  color: #0b0f17;
  box-shadow: 0 16px 30px rgba(72, 214, 168, 0.2);
}

#loginView #loginBtn:hover {
  box-shadow: 0 18px 34px rgba(72, 214, 168, 0.3);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
}

.field textarea,
.field select,
.field input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 1rem;
  font-family: inherit;
  background: #141822;
  color: var(--text);
}

.field textarea {
  min-height: 130px;
  resize: vertical;
}

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

.captcha-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.captcha-btn {
  border: 1px solid rgba(111, 184, 154, 0.35);
  border-radius: 14px;
  padding: 8px 10px;
  background: #fffaf6;
  min-width: 130px;
  min-height: 48px;
  box-shadow: 0 10px 20px rgba(111, 184, 154, 0.18);
}

.captcha-btn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

button {
  border: none;
  border-radius: 14px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: #0b0f17;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(111, 184, 154, 0.28);
}

.ghost {
  background: rgba(13, 17, 26, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.result {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-header span {
  font-size: 0.9rem;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 13, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.modal[hidden] {
  display: none;
}

.modal.picker-active {
  cursor: crosshair;
}

.modal.picker-active .modal-content {
  cursor: crosshair;
}

.modal.picker-active img {
  cursor: crosshair;
}

.modal-content {
  background: #141a24;
  border-radius: 20px;
  padding: 20px;
  max-width: min(92vw, 1100px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
}

.zoom-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 3;
}

.zoom-modal[hidden] {
  display: none;
}

.zoom-modal img {
  max-width: none;
  max-height: none;
  display: block;
  transform-origin: center;
  cursor: zoom-in;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.modal-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.preview-title {
  font-weight: 600;
}

.icon-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.95rem;
  line-height: 1;
}

.preview-panel img,
.preview-surface {
  width: 100%;
  min-height: 260px;
  border-radius: 16px;
  object-fit: contain;
  background: #0f141d;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-surface {
  position: relative;
  padding: 12px;
}

.preview-surface canvas {
  max-width: 100%;
  max-height: 60vh;
}

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

.tolerance {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.tolerance input[type="number"] {
  width: 72px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.modal-close {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-download {
  align-self: flex-end;
}

.result-body {
  border-radius: 16px;
  border: 1px dashed var(--border);
  min-height: 220px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(12, 16, 24, 0.6);
}

.result-body img {
  width: 300px;
  height: 300px;
  object-fit: cover;
  border-radius: 16px;
  display: block;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(159, 92, 46, 0.22);
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 24px;
  align-items: stretch;
  border-top: 1px dashed var(--border);
  padding-top: 16px;
}

.reference-panel {
  padding-right: 12px;
  border-right: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reference-title {
  font-weight: 600;
  color: var(--muted);
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.reference-slot {
  border: 2px dashed var(--border);
  border-radius: 14px;
  height: 92px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(12, 16, 24, 0.6);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.reference-slot.filled {
  border-style: solid;
}

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

.reference-plus {
  font-size: 1.8rem;
  line-height: 1;
}

.reference-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 999px;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 0.75rem;
}

.icon-none {
  font-size: 1.6rem;
  color: #c2410c;
}

.placeholder {
  color: var(--muted);
  font-size: 0.95rem;
}

.placeholder--loading {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.placeholder--loading .spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(111, 184, 154, 0.3);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.notice {
  background: var(--accent-light);
  color: var(--accent);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.error {
  color: #b42318;
}

.hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.generate-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(12, 16, 24, 0.7);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

.generate-status .spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(111, 184, 154, 0.3);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

.style-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.style-title {
  font-weight: 700;
}

.style-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.style-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 0;
}

.style-row-title {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.style-grid {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0 6px;
  min-height: 220px;
  scroll-snap-type: x mandatory;
}

.style-grid::-webkit-scrollbar {
  height: 6px;
}

.style-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.style-grid::-webkit-scrollbar-track {
  background: transparent;
}

.style-row--compact .style-grid {
  gap: 8px;
  padding: 4px 0;
  min-height: 80px;
}

.style-card {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.style-card--color {
  flex: 0 0 auto;
}

.style-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  background: rgba(15, 20, 30, 0.85);
  cursor: pointer;
  width: 230px;
  height: 230px;
  transition: border 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  align-items: center;
  justify-content: center;
}

.style-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  background: rgba(11, 15, 23, 0.5);
  display: block;
}

.style-card--none {
  display: flex;
  align-items: center;
  justify-content: center;
}

.style-card--color {
  width: 60px;
  height: 60px;
  padding: 4px;
}

.style-card--color .color-swatch {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #111827;
}

.style-card.active {
  border-color: var(--accent);
  box-shadow: 0 12px 24px rgba(111, 184, 154, 0.25);
  transform: translateY(-2px);
}

.ratio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}

.ratio-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: rgba(15, 20, 30, 0.85);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: border 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.ratio-card .ratio-box {
  width: 72px;
  height: 72px;
  border: 1px solid var(--border);
  border-radius: 6px;
  position: relative;
  display: grid;
  place-items: center;
  background: #0f131c;
  padding: 8px;
  overflow: hidden;
}

.ratio-card .ratio-rect {
  width: var(--rect-w);
  height: var(--rect-h);
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: rgba(111, 184, 154, 0.12);
  box-sizing: border-box;
}

.ratio-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.ratio-card.active {
  border-color: var(--accent);
  box-shadow: 0 10px 20px rgba(111, 184, 154, 0.28);
  transform: translateY(-1px);
}

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

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  gap: 10px;
}

.history-item {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(12, 16, 24, 0.6);
  cursor: pointer;
  aspect-ratio: 1 / 1;
}

.history-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: rgba(12, 16, 24, 0.6);
}

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

  .account {
    align-items: flex-start;
  }
}
