:root {
  color-scheme: dark;
  --bg: #11100e;
  --panel: rgba(32, 29, 25, 0.86);
  --panel-strong: #25211c;
  --text: #f6efe4;
  --muted: #b5a99a;
  --faint: #756a5d;
  --line: rgba(246, 239, 228, 0.12);
  --accent: #ffb86b;
  --accent-strong: #ff8a3d;
  --danger: #ff6b6b;
  --ok: #7ee787;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 184, 107, 0.16), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(255, 138, 61, 0.14), transparent 30rem),
    linear-gradient(135deg, #11100e 0%, #1b1714 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

.shell {
  width: min(1440px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.05em;
}

h1 {
  max-width: 720px;
  font-size: clamp(44px, 8vw, 100px);
  line-height: 0.88;
}

h2 {
  font-size: 28px;
}

.hero-copy {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 13px;
}

.status-pill.ready {
  border-color: rgba(126, 231, 135, 0.36);
  color: var(--ok);
}

.status-pill.warn {
  border-color: rgba(255, 107, 107, 0.42);
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  gap: 22px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.generator,
.preview-panel,
.history-panel {
  padding: 24px;
}

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

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

.field + .field,
.form-grid {
  margin-top: 16px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  outline: none;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(255, 184, 107, 0.62);
  box-shadow: 0 0 0 4px rgba(255, 184, 107, 0.12);
  background: rgba(0, 0, 0, 0.26);
}

textarea {
  resize: vertical;
  padding: 15px 16px;
  line-height: 1.6;
}

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

.form-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.7fr;
  gap: 12px;
}

.primary-button,
.ghost-button,
.mini-button,
.icon-button {
  cursor: pointer;
  border: 0;
  color: var(--text);
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 58px;
  margin-top: 20px;
  border-radius: 20px;
  padding: 0 18px 0 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #24170d;
  font-weight: 900;
  box-shadow: 0 18px 36px rgba(255, 138, 61, 0.24);
}

.primary-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.7;
}

.button-hint {
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(36, 23, 13, 0.16);
  font-size: 12px;
}

.ghost-button,
.mini-button,
.icon-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
}

.ghost-button {
  border-radius: 999px;
  padding: 10px 13px;
  color: var(--muted);
  font-size: 13px;
}

.message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.message.error {
  color: var(--danger);
}


.reference-uploader {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.reference-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.upload-button {
  cursor: pointer;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.reference-hint,
.reference-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  min-height: 2.5rem;
}

.reference-item {
  position: relative;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.06);
}

.reference-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-remove {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.35rem;
  height: 1.35rem;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 16, 12, 0.78);
  cursor: pointer;
}

.preview {
  display: grid;
  min-height: 620px;
  overflow: hidden;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
    rgba(0, 0, 0, 0.18);
  background-size: 28px 28px;
  place-items: center;
}

.preview img {
  display: block;
  width: 100%;
  max-height: 760px;
  object-fit: contain;
}

.empty-state {
  display: grid;
  gap: 12px;
  color: var(--faint);
  place-items: center;
}

.empty-icon {
  display: grid;
  width: 74px;
  height: 74px;
  border: 1px solid var(--line);
  border-radius: 24px;
  color: var(--accent);
  font-size: 34px;
  place-items: center;
}

.history-panel {
  margin-top: 22px;
}

.history-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.search {
  width: min(360px, 48vw);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

.toggle input {
  width: auto;
  height: auto;
}

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

.card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.18);
}

.image-button {
  display: block;
  width: 100%;
  height: 260px;
  padding: 0;
  border: 0;
  background: #0e0d0c;
  cursor: zoom-in;
}

.image-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 14px;
}

.card-title-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
}

.title-input {
  height: 40px;
  border-radius: 14px;
}

.icon-button {
  border-radius: 14px;
  color: var(--accent);
  font-size: 20px;
}

.meta,
.prompt-text {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}

.note-input {
  min-height: 66px;
  margin-top: 10px;
  border-radius: 14px;
  font-size: 13px;
}

.prompt-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.mini-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 999px;
  padding: 0 11px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.mini-button.danger {
  color: var(--danger);
}

@media (max-width: 920px) {
  .hero,
  .workspace,
  .history-head {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .workspace {
    display: grid;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .preview {
    min-height: 360px;
  }

  .history-tools,
  .search {
    width: 100%;
  }
}

.admin-shell {
  max-width: 980px;
}

.admin-hero {
  align-items: center;
}

.ghost-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.admin-panel {
  padding: 24px;
}

.admin-login,
.settings-form {
  display: grid;
  gap: 18px;
}

.hidden {
  display: none !important;
}

/* Mode switch (饰品实拍 / 普通生图) */
.mode-switch {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.mode-button {
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #24170d;
  box-shadow: 0 8px 18px rgba(255, 138, 61, 0.22);
}

/* Stage-1 "用 Skill 写 Prompt" button */
.secondary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 50px;
  margin-bottom: 14px;
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 0 16px 0 18px;
  background: rgba(255, 184, 107, 0.1);
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

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

.secondary-button .button-hint {
  background: rgba(255, 184, 107, 0.16);
  color: var(--accent);
}

/* Stage-1 skill result summary */
.jewelry-result {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.jewelry-result-block,
.jewelry-result-scene,
.jewelry-result-tips {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.jewelry-result-block {
  color: var(--text);
}

.primary-button.compact {
  width: fit-content;
  min-width: 150px;
  min-height: 48px;
  justify-content: center;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.admin-section-title {
  margin: 22px 0 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
}

.admin-section-title:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 8px;
}

.admin-section-hint {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.api-key-field input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.task-panel {
  margin-top: 22px;
  padding: 24px;
}

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

.compact-empty {
  min-height: 160px;
}

.task-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.task-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.task-status {
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 184, 107, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.task-status.succeeded {
  background: rgba(126, 231, 135, 0.12);
  color: var(--ok);
}

.task-status.failed {
  background: rgba(255, 107, 107, 0.12);
  color: var(--danger);
}

.task-time,
.task-meta,
.task-prompt {
  color: var(--muted);
  font-size: 13px;
}

.task-prompt {
  display: -webkit-box;
  overflow: hidden;
  margin: 10px 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.5;
}

.progress-track {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 250ms ease;
}

.task-meta {
  margin: 9px 0 0;
}

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