:root {
  --bg: #f3f6f2;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-soft: #f8faf6;
  --text: #1f1810;
  --muted: #6f766c;
  --line: #d7dfd8;
  --accent: #c77d4a;
  --accent-strong: #a86116;
  --ok: #28634d;
  --warn: #75580d;
  --danger: #8b2d18;
  --shadow: 0 20px 48px rgba(64, 49, 28, 0.1);
  font-family: SimSun, "Songti SC", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(135deg, #f4f7f5 0%, #edf4ef 48%, #faf7f1 100%);
}

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

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

.cover-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.cover-appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 10px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid rgba(222, 208, 189, 0.72);
  background: rgba(255, 252, 245, 0.88);
  backdrop-filter: blur(14px);
}

.cover-brand,
.cover-appbar-actions,
.header-actions,
.prompt-actions,
.api-dialog-buttons,
.api-dialog footer,
.preview-footer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cover-brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #c3302d;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(178, 40, 34, 0.22);
}

.cover-brand div:last-child {
  display: grid;
  gap: 2px;
}

.cover-brand strong {
  font-size: 17px;
  font-weight: 900;
}

.cover-brand span,
.api-state,
.panel-head span,
.section-title span,
.preview-meta span,
.preview-stats span,
.api-dialog header span,
.api-dialog footer span,
.empty-card,
.reference-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
}

.api-state {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #e4d8c8;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.72);
  white-space: nowrap;
}

.api-state.is-ready {
  color: var(--ok);
  border-color: #c8ddce;
  background: #eef7f2;
}

.cover-workbench {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(0, 1.18fr);
  grid-template-areas:
    "preview settings"
    "archive archive";
  align-items: stretch;
  gap: 16px 20px;
  width: min(1240px, calc(100% - 48px));
  padding: 18px 0 26px;
  margin: 0 auto;
}

.cover-preview-panel,
.cover-settings-panel,
.cover-archive-panel,
.api-dialog {
  position: relative;
  border: 0;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cover-preview-panel,
.cover-settings-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 18px 16px;
}

.cover-preview-panel::before,
.cover-settings-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2da88f, #d8a54a, #ef6f88);
}

.cover-preview-panel {
  grid-area: preview;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
}

.cover-settings-panel {
  grid-area: settings;
  gap: 14px;
}

.cover-archive-panel {
  grid-area: archive;
  display: grid;
  gap: 12px;
  padding: 14px 18px;
  background: transparent;
  box-shadow: none;
}

.panel-kicker {
  color: #b57313;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
}

.prompt-launch {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: fit-content;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.prompt-launch.is-empty {
  opacity: 0.72;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
}

.panel-head > div:not(.header-actions) {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.panel-head > .header-actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-self: center;
}

.panel-head strong,
.section-title strong,
.preview-meta strong {
  color: #17120b;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
}

.reference-head strong,
.section-title strong {
  font-size: 14px;
}

.ghost-button,
.primary-button,
.outline-button,
.clear-button,
.gear-button,
.prompt-actions button,
.reference-actions button,
.api-dialog button,
.archive-card {
  border: 1px solid #d8c7b6;
  border-radius: 9px;
  background: #f6efe6;
  color: #5a4738;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
}

.primary-button {
  border-color: #c77d4a;
  background: linear-gradient(135deg, #dfa143, #c77d4a);
  color: #fff;
  box-shadow: 0 10px 22px rgba(198, 125, 74, 0.25);
}

.clear-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff8ef;
}

.gear-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 9px;
  background: #fff8ef;
  font-size: 18px;
  line-height: 1;
}

.gear-button span {
  display: block;
  transform: translateY(-1px);
}

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

button:disabled,
.outline-button.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  pointer-events: none;
}

.batch-counter,
.aspect-badge,
.panel-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #ead9c2;
  border-radius: 9px;
  background: #fff2d8;
  color: #9a611f;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

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

label,
.prompt-panel,
.reference-panel,
.chip-section,
.ratio-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

label > span,
.api-field > span:first-child {
  color: #6c6258;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea,
.soft-select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #d8d0c5;
  border-radius: 9px;
  padding: 0 10px;
  background: #fbf8f2;
  color: #1c1711;
  font-weight: 750;
}

textarea {
  min-height: 126px;
  padding: 10px 12px;
  line-height: 1.7;
  resize: vertical;
}

.soft-select {
  text-align: left;
  color: #786b5c;
  cursor: pointer;
}

.form-grid-top .soft-select,
.cover-status,
.prompt-actions button,
.reference-actions button,
.prompt-panel input,
.prompt-panel textarea,
.genre-chip {
  font-size: 13px;
}

.cover-status {
  border-radius: 9px;
  padding: 10px 12px;
  background: #eef7f2;
  color: var(--ok);
  font-weight: 800;
  line-height: 1.5;
}

.cover-status.is-error,
.api-dialog-status.is-error {
  background: #fff0ec;
  color: var(--danger);
}

.cover-status.is-loading,
.cover-status.is-running,
.api-dialog-status.is-loading {
  background: #fff8df;
  color: var(--warn);
}

.prompt-toolbar,
.submit-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.prompt-actions,
.reference-actions {
  flex-wrap: wrap;
}

.section-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 10px;
  align-items: end;
  margin-bottom: 8px;
}

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

.genre-chip {
  --chip-bg: #f1e7db;
  min-height: 34px;
  border: 1px solid rgba(116, 91, 64, 0.13);
  border-radius: 8px;
  background: var(--chip-bg);
  color: #4e4032;
  font-weight: 850;
  cursor: pointer;
  white-space: nowrap;
}

.genre-chip.is-active {
  border-color: rgba(122, 78, 32, 0.45);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42), 0 8px 18px rgba(88, 61, 30, 0.09);
}

.genre-custom {
  grid-column: span 2;
}

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

.aspect-card {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  min-height: 78px;
  padding: 8px 6px 7px;
  border: 1px solid #ead9c2;
  border-radius: 9px;
  background: #fff4e6;
  color: #594736;
  cursor: pointer;
  font-weight: 850;
}

.aspect-card.is-active {
  border-color: #c77d4a;
  background: #f4e1cf;
}

.aspect-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 34px;
  margin-top: 0;
}

.aspect-icon::before {
  content: "";
  display: block;
  width: var(--aspect-icon-width, 24px);
  height: var(--aspect-icon-height, 32px);
  border: 2px solid #8b7866;
  border-radius: 3px;
  background: rgba(255, 251, 244, 0.62);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  aspect-ratio: var(--ratio, 3 / 4);
}

.aspect-card small {
  color: #897968;
  font-size: 10px;
}

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

.reference-group {
  display: grid;
  gap: 10px;
}

.reference-list {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-height: 84px;
  width: 100%;
  padding: 8px;
  border: 1px dashed #ead7bd;
  border-radius: 9px;
  background: #fffaf4;
  overflow-x: auto;
}

.reference-list.is-dragover {
  border-color: #c77d4a;
  background: #fff2df;
}

.reference-empty {
  display: grid;
  place-items: center;
  width: 100%;
  text-align: center;
}

.reference-empty strong {
  color: #ef7e6d;
  font-size: 16px;
}

.reference-thumb {
  position: relative;
  flex: 0 0 74px;
  display: grid;
  gap: 4px;
}

.reference-thumb img {
  width: 74px;
  height: 58px;
  border-radius: 7px;
  object-fit: cover;
}

.reference-thumb button {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  border-radius: 999px;
  background: #211a12;
  color: #fff;
}

.reference-thumb small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #7b6d5f;
  font-size: 10px;
}

.submit-bar {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 74px 112px;
  align-items: end;
  gap: 8px;
}

.submit-bar label > span {
  color: #7c7268;
  font-size: 12px;
}

.submit-bar select,
.submit-bar .primary-button {
  min-height: 34px;
  font-size: 13px;
}

.submit-bar select {
  font-weight: 700;
}

.submit-bar .primary-button {
  font-weight: 800;
  padding-inline: 14px;
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 610px;
  border-radius: 9px;
  background: linear-gradient(145deg, #dce9dc, #f0efd9);
  padding: 28px;
}

.preview-frame {
  display: grid;
  place-items: center;
  width: min(78%, 320px);
  max-height: 520px;
  border: 7px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  background: #f6f2eb;
  box-shadow: 0 24px 58px rgba(42, 52, 37, 0.16);
  aspect-ratio: var(--preview-aspect, 3 / 4);
  padding: 0;
  overflow: hidden;
}

.preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-empty {
  display: grid;
  place-items: center;
  gap: 28px;
  color: #4e453b;
  text-align: center;
  padding: 20px;
}

.preview-empty em {
  color: #b57313;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.preview-empty strong {
  font-size: 20px;
  font-weight: 900;
}

.preview-empty small {
  color: #a79b8c;
  line-height: 1.5;
}

.preview-footer {
  justify-content: space-between;
  align-items: center;
}

.preview-meta {
  display: grid;
  gap: 4px;
}

.preview-meta strong {
  color: #5f5750;
  font-size: 15px;
  font-weight: 700;
}

.preview-meta span {
  color: #7b736a;
  font-size: 11px;
}

.preview-footer .outline-button {
  min-height: 32px;
  padding: 0 11px;
  border-color: #d9c7b2;
  color: #6b6157;
  font-size: 13px;
  font-weight: 700;
}

.preview-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid #eadfd3;
}

.preview-stats div {
  display: grid;
  gap: 4px;
  padding: 12px 10px 2px;
}

.preview-stats div + div {
  border-left: 1px solid #eadfd3;
}

.preview-stats strong {
  font-size: 14px;
  font-weight: 900;
}

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

.archive-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  min-height: 74px;
  padding: 8px;
  text-align: left;
  background: rgba(255, 255, 255, 0.84);
}

.archive-card img {
  width: 56px;
  height: 56px;
  border-radius: 7px;
  object-fit: cover;
}

.archive-card strong,
.archive-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-card span {
  color: var(--muted);
  font-size: 11px;
}

.cover-archive-panel .clear-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.empty-card {
  padding: 18px;
  border: 1px dashed #e6d8c6;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.64);
}

.api-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 22, 20, 0.34);
}

.api-dialog-backdrop[hidden],
.cover-status[hidden],
.api-dialog-status[hidden] {
  display: none !important;
}

.api-dialog {
  display: grid;
  gap: 22px;
  width: min(960px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 26px 30px 30px;
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.98);
}

.api-dialog header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.api-dialog header div,
.api-field {
  display: grid;
  gap: 10px;
}

.api-dialog header strong {
  font-size: 22px;
}

.api-dialog header button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
}

.api-field input,
.api-field select {
  min-height: 48px;
  border-radius: 10px;
  font-size: 18px;
}

.prompt-output-field textarea {
  min-height: 360px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #fbf8f2;
  color: #1c1711;
  font-size: 15px;
  line-height: 1.75;
  resize: vertical;
}

.prompt-output-field textarea[readonly] {
  cursor: text;
}

.api-key-box {
  position: relative;
  display: block;
}

.api-key-box input {
  padding-right: 46px;
}

.api-key-box button {
  position: absolute;
  right: 7px;
  top: 50%;
  width: 34px;
  min-height: 34px;
  padding: 0;
  transform: translateY(-50%);
  background: transparent;
  border-color: transparent;
}

.api-dialog-buttons {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.api-dialog-status {
  border-radius: 9px;
  padding: 10px 12px;
  background: #eef7f2;
  color: var(--ok);
  font-weight: 800;
}

.api-dialog footer {
  justify-content: flex-start;
  padding-top: 20px;
  border-top: 1px solid #eadfd3;
}

.api-settings-dialog {
  gap: 14px;
  width: min(840px, calc(100vw - 36px));
  padding: 20px 22px 22px;
  border-radius: 12px;
}

.api-settings-dialog header {
  gap: 12px;
}

.api-settings-dialog header div,
.api-settings-dialog .api-field {
  gap: 8px;
}

.api-settings-dialog header strong {
  font-size: 17px;
}

.api-settings-dialog header button {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 8px;
  font-size: 17px;
}

.api-settings-dialog .api-field input,
.api-settings-dialog .api-field select {
  min-height: 40px;
  border-radius: 9px;
  font-size: 13px;
}

.api-settings-dialog .api-key-box button {
  right: 6px;
  width: 30px;
  min-height: 30px;
}

.api-settings-dialog .api-dialog-buttons,
.api-settings-dialog footer {
  gap: 8px;
}

.api-settings-dialog .api-dialog-status {
  padding: 8px 10px;
  font-size: 12px;
}

.api-settings-dialog footer {
  padding-top: 14px;
}

.api-recommend-card {
  display: grid;
  width: min(100%, 620px);
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid #d8e4de;
  border-radius: 18px;
  background: linear-gradient(180deg, #f7fbf8 0%, #eef6f1 100%);
  color: #263a34;
  justify-self: start;
}

.api-recommend-copy {
  min-width: 0;
}

.api-recommend-copy > strong {
  display: block;
  margin-bottom: 4px;
  color: #557166;
  font-size: 11px;
  font-weight: 800;
}

.api-recommend-copy h3 {
  margin: 0 0 5px;
  color: #285b4c;
  font-size: 18px;
}

.api-recommend-copy p {
  max-width: 520px;
  margin: 0;
  color: #60736b;
  font-size: 12px;
  line-height: 1.38;
}

.api-recommend-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.api-recommend-tags span {
  padding: 4px 8px;
  border: 1px solid #d6e5de;
  border-radius: 999px;
  background: #ffffff;
  color: #527165;
  font-size: 10px;
}

.api-recommend-actions {
  display: grid;
  grid-template-columns: minmax(0, 170px);
  gap: 10px;
}

.api-recommend-quick {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #dbe6e0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
}

.api-recommend-quick > strong {
  color: #536f64;
  font-size: 12px;
  font-weight: 800;
}

.api-recommend-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid #adc6ba;
  border-radius: 12px;
  background: #ffffff;
  color: #285b4c;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.api-recommend-link:hover {
  border-color: #5d977f;
  background: #e8f3ed;
}

@media (max-width: 980px) {
  .cover-workbench {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "preview"
      "settings"
      "archive";
  }

  .preview-stage {
    min-height: 460px;
  }
}

@media (max-width: 720px) {
  .cover-appbar,
  .cover-appbar-actions,
  .panel-head,
  .preview-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .cover-workbench {
    width: min(100% - 24px, 1240px);
  }

  .form-grid,
  .prompt-toolbar,
  .submit-bar,
  .reference-groups,
  .section-title {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .genre-custom {
    grid-column: auto;
  }

  .preview-stage {
    min-height: 360px;
    padding: 18px;
  }

  .api-dialog {
    padding: 20px 16px;
  }

  .api-settings-dialog {
    width: min(100vw - 24px, 840px);
    padding: 16px 14px 18px;
  }

  .api-recommend-card {
    gap: 14px;
  }

  .api-recommend-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .api-recommend-link {
    width: 100%;
  }
}
