:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --accent: #111827;
  --accent-soft: #f2f4f7;
  --brand: #2563eb;
  --danger: #b42318;
  --ok: #027a48;
  --warn: #b54708;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), transparent 34rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 52rem);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

button,
a,
select,
label {
  -webkit-tap-highlight-color: transparent;
}

p,
h1,
h2 {
  margin: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 0 clamp(18px, 5vw, 72px);
  border-bottom: 1px solid rgba(228, 231, 236, 0.72);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
}

.brand,
.main-nav,
.header-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}

.main-nav {
  justify-content: center;
  gap: clamp(18px, 3vw, 36px);
}

.main-nav a,
.ghost-link {
  color: #344054;
  font-weight: 650;
  text-decoration: none;
}

.main-nav a:hover,
.ghost-link:hover {
  color: var(--text);
}

.header-actions {
  justify-content: flex-end;
  gap: 12px;
}

.login-link,
.ghost-button,
.redeem-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 15px;
  background: var(--accent);
  color: #fff;
  font-weight: 760;
  text-decoration: none;
}

.ghost-button,
.redeem-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #344054;
  cursor: pointer;
}

.redeem-button {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.header-actions form {
  margin: 0;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  background: #fff;
  color: #344054;
  font-size: 12px;
  font-weight: 760;
}

main {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 44px 24px 42px;
}

.hero {
  display: grid;
  gap: 24px;
  justify-items: center;
  padding: 28px 0 18px;
}

.hero-copy {
  width: min(100%, 820px);
  text-align: center;
}

.eyebrow {
  margin-bottom: 12px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  color: #0f172a;
  font-size: clamp(36px, 7vw, 72px);
  font-weight: 850;
  line-height: 1.04;
}

.hero-subtitle {
  margin: 18px auto 0;
  width: min(100%, 680px);
  color: var(--muted);
  font-size: 17px;
}

.creator-shell {
  width: min(100%, 980px);
  border: 1px solid rgba(208, 213, 221, 0.9);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.creator-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.prompt-toolbar,
.creator-controls,
.action-row,
.workspace-head,
.task-head,
.task-meta {
  display: flex;
  align-items: center;
}

.prompt-toolbar {
  justify-content: space-between;
  gap: 12px;
}

.mode-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.mode-tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 13px;
  background: transparent;
  color: #475467;
  cursor: pointer;
  font-weight: 740;
}

.mode-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.mode-tab:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.model-status {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.prompt-field {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

textarea {
  width: 100%;
  min-height: 172px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfe;
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
  outline: 0;
}

textarea:focus,
select:focus,
input:focus {
  border-color: #98a2b3;
  box-shadow: 0 0 0 4px rgba(16, 24, 40, 0.07);
}

textarea::placeholder {
  color: #98a2b3;
}

.creator-controls {
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 2px;
}

.control-field {
  display: grid;
  gap: 6px;
  min-width: 132px;
  flex: 1;
}

.model-field {
  min-width: 280px;
  flex: 2.2;
}

.control-field span {
  color: #475467;
  font-size: 12px;
  font-weight: 760;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
  outline: 0;
}

.action-row {
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.upload-button,
.generate-button,
.workspace-head button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 780;
}

.upload-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #344054;
}

.upload-button input {
  display: none;
}

.generate-button {
  min-width: 154px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.reference-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.reference-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
}

.reference-item img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
}

.reference-item span {
  min-width: 0;
  overflow: hidden;
  color: #475467;
  font-size: 12px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-item button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
}

.workspace {
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 18px;
}

.workspace-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.workspace h2 {
  color: var(--text);
  font-size: 18px;
  line-height: 1.3;
}

.workspace p {
  margin-top: 4px;
  color: var(--muted);
}

.workspace-head button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #344054;
}

.task-list {
  display: grid;
  gap: 12px;
}

.empty-state,
.task-message {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 28px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.task-card--running,
.task-card--submitting {
  border-color: #fedf89;
  background: #fffdf6;
}

.task-card--completed {
  border-color: #abefc6;
}

.task-card--failed {
  border-color: #fecdca;
  background: #fffbfa;
}

.task-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.task-head strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.task-head p {
  margin-top: 6px;
  color: #475467;
  overflow-wrap: anywhere;
}

.task-head span {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--accent-soft);
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.task-meta {
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 11px 0;
  color: var(--muted);
  font-size: 12px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.result-card {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344054;
  text-decoration: none;
}

.result-card img,
.result-card video {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #eef2f7;
  object-fit: cover;
}

.result-card img.is-preview-failed {
  min-height: 150px;
  object-fit: contain;
}

.result-card:has(img.is-preview-failed)::before {
  content: "预览加载失败\A请打开原图查看";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  padding: 18px;
  color: #667085;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  white-space: pre-line;
  pointer-events: none;
}

.result-card video {
  aspect-ratio: 16 / 9;
  background: #111827;
}

.result-card span {
  display: block;
  padding: 9px 10px;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.redeem-dialog {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.redeem-head h2 {
  color: var(--text);
  font-size: 18px;
}

.redeem-head button {
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #475467;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.redeem-field {
  display: grid;
  gap: 7px;
}

.redeem-field span {
  color: #475467;
  font-size: 12px;
  font-weight: 760;
}

.redeem-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
  outline: 0;
  text-transform: uppercase;
}

.redeem-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.redeem-status {
  min-height: 21px;
  margin-top: 10px;
  color: var(--ok);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.error-text {
  color: var(--danger) !important;
}

@media (max-width: 820px) {
  .site-header {
    grid-template-columns: 1fr auto;
    gap: 12px;
    min-height: auto;
    padding: 14px 16px;
  }

  .main-nav {
    display: none;
  }

  .ghost-link {
    display: none;
  }

  main {
    padding: 22px 14px 28px;
  }

  .hero {
    padding-top: 14px;
  }

  h1 {
    font-size: 38px;
  }

  .hero-subtitle {
    font-size: 15px;
  }

  .creator-form,
  .workspace {
    padding: 14px;
  }

  .prompt-toolbar,
  .action-row,
  .workspace-head,
  .task-head {
    align-items: stretch;
    flex-direction: column;
  }

  .model-field,
  .control-field,
  .upload-button,
  .generate-button,
  .redeem-button,
  .workspace-head button {
    width: 100%;
    min-width: 0;
  }
}
