:root {
  color-scheme: light;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fd;
  --border: #dfe6f0;
  --border-strong: #cfd9e8;
  --text: #1f2a37;
  --muted: #6b7789;
  --accent: #4f86eb;
  --accent-soft: #eaf2ff;
  --accent-strong: #2563eb;
  --shadow: 0 8px 24px rgba(18, 30, 50, 0.06);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.82), transparent 42%),
    linear-gradient(180deg, #f3f7fc 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  padding: 24px;
}

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

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

.shell {
  width: min(1340px, 100%);
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 60px rgba(18, 30, 50, 0.12);
}

.login-badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #bfd3ff;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

.login-card h1 {
  font-size: 26px;
}

.login-subtitle {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.remember-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.remember-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.login-button {
  width: 100%;
}

.login-error {
  min-height: 18px;
  color: #c2410c;
  font-size: 13px;
}

.hero {
  padding: 6px 4px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: min(620px, 100%);
  margin: 0 auto 18px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.tab,
.segment,
.chip,
.preset,
.icon-btn,
.text-btn,
.primary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.tab {
  height: 34px;
  border-radius: 12px;
  font-weight: 600;
  color: var(--muted);
}

.tab.is-active {
  background: var(--accent-soft);
  border-color: #bfd3ff;
  color: var(--accent-strong);
}

.workspace {
  display: grid;
  gap: 16px;
}

.view {
  display: none;
  gap: 16px;
}

.view.is-active {
  display: grid;
}

.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.compose-card,
.canvas-card,
.tasks-card,
.simple-panel {
  padding: 16px;
}

.compose-card {
  display: grid;
  gap: 16px;
}

.compose-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr minmax(300px, 1.6fr);
  gap: 12px;
  align-items: start;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.segment {
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
}

.segment.is-active {
  background: var(--accent-soft);
  border-color: #bfd3ff;
  color: var(--accent-strong);
}

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

.field.slim span,
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

select,
textarea,
input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

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

select:focus,
textarea:focus,
input:focus,
.tab:focus,
.segment:focus,
.chip:focus,
.preset:focus,
.primary:focus,
.icon-btn:focus,
.text-btn:focus {
  border-color: #9ec0ff;
  box-shadow: 0 0 0 3px rgba(79, 134, 235, 0.12);
}

.ratio-wrap {
  display: grid;
  gap: 6px;
}

.ratio-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chip,
.primary,
.ghost,
.icon-btn,
.text-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 12px;
}

.chip {
  color: var(--muted);
}

.chip.is-active {
  background: var(--accent-soft);
  border-color: #bfd3ff;
  color: var(--accent-strong);
}

.ghost {
  color: var(--muted);
  background: var(--surface-soft);
}

.primary {
  background: #7aa5f3;
  border-color: #7aa5f3;
  color: #fff;
  font-weight: 600;
}

.prompt-field {
  gap: 8px;
}

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

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

.preset {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 10px 8px 9px;
  border-radius: 14px;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.preset.is-active {
  border-color: #bcd0f6;
  background: #f7faff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.08);
}

.swatch {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

.swatch-cinematic { background: linear-gradient(135deg, #2b1d16, #181d28); }
.swatch-commerce { background: linear-gradient(135deg, #e8edf5, #ffffff); }
.swatch-sticker { background: linear-gradient(135deg, #ff88bb, #ffc36b); }
.swatch-toy { background: linear-gradient(135deg, #a45bf7, #ffbc86); }
.swatch-icon { background: linear-gradient(135deg, #4f73f2, #31b8ff); }
.swatch-poster { background: linear-gradient(135deg, #f08c00, #ffdb7a); }
.swatch-anime { background: linear-gradient(135deg, #cc5cff, #8ed8ff); }
.swatch-wallpaper { background: linear-gradient(135deg, #151c35, #253a6b); }

.preset span:last-child {
  font-size: 12px;
  font-weight: 600;
}

.advanced {
  border-top: 1px solid var(--border);
  padding-top: 2px;
}

.advanced summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  color: var(--text);
  font-weight: 600;
  padding: 8px 2px;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.muted {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

.advanced-body {
  padding-top: 6px;
}

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

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

.card-head h2 {
  font-size: 18px;
}

.card-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.icon-btn,
.text-btn {
  color: var(--muted);
  background: var(--surface);
}

.icon-btn {
  min-width: 72px;
}

.text-btn {
  border-color: transparent;
  background: transparent;
}

.logout-btn {
  margin-top: 2px;
}

.canvas-card {
  min-height: 430px;
}

.canvas-stage {
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 247, 252, 0.92)),
    linear-gradient(135deg, #f7faff, #edf3fc);
  display: grid;
  place-items: center;
  padding: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  text-align: center;
  max-width: 320px;
  color: var(--muted);
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 20px;
}

.empty-state h3 {
  color: var(--text);
  font-size: 18px;
  margin-bottom: 6px;
}

.generation-panel {
  width: 100%;
  display: grid;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid #cfe0ff;
  border-radius: 16px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
}

.generation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.generation-head h3 {
  font-size: 18px;
  margin-bottom: 6px;
}

.generation-head p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.generation-time {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #bfd3ff;
  background: #fff;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.generation-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  overflow: hidden;
}

.generation-bar span {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4f86eb, #8bb1ff);
  animation: generation-slide 1.1s ease-in-out infinite;
}

@keyframes generation-slide {
  0% { transform: translateX(-90%); }
  50% { transform: translateX(95%); }
  100% { transform: translateX(220%); }
}

.error-banner {
  width: 100%;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.5;
}

.result-stack {
  width: 100%;
  display: grid;
  gap: 14px;
}

.result-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  overflow: hidden;
}

.result-image {
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, hsl(var(--hue) 72% 86%), hsl(var(--hue) 72% 95%));
  display: grid;
  place-items: center;
  color: rgba(20, 30, 45, 0.82);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}

.result-image.has-image {
  background: #f8fafc;
}

.result-image img,
.gallery-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
}

.task-list,
.history-list,
.gallery-grid,
.template-grid {
  display: grid;
  gap: 10px;
}

.task-empty,
.history-empty,
.gallery-empty {
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.task-item,
.history-item,
.template-card,
.gallery-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 12px;
}

.task-item,
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.task-title,
.history-title,
.template-card h3 {
  font-size: 14px;
  margin-bottom: 4px;
}

.task-sub,
.history-sub,
.template-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.gallery-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.gallery-thumb {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, hsl(var(--hue) 60% 82%), hsl(var(--hue) 60% 95%));
  border: 1px solid rgba(255, 255, 255, 0.75);
  overflow: hidden;
}

.gallery-thumb.has-image {
  background: #f8fafc;
}

.gallery-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.show {
  display: block;
}

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

  .ratio-wrap {
    grid-column: 1 / -1;
  }

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

@media (max-width: 820px) {
  body {
    padding: 16px;
  }

  .tabs {
    width: 100%;
  }

  .compose-row,
  .advanced-grid,
  .template-grid {
    grid-template-columns: 1fr;
  }

  .card-actions {
    flex-wrap: wrap;
  }

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