:root {
  --ink: #18212e;
  --muted: #748094;
  --line: #dfe4eb;
  --line-strong: #cbd3de;
  --panel: #ffffff;
  --bg: #f4f6f8;
  --soft: #f7f8fa;
  --accent: #ed6842;
  --accent-dark: #d85632;
  --blue: #3975d5;
  --success: #288f60;
  --shadow: 0 10px 28px rgba(22, 31, 44, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  height: 64px;
  padding: 0 clamp(20px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #121a27;
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  font-size: 19px;
  font-weight: 800;
}
.brand strong { display: block; font-size: 14px; }
.brand small { display: block; margin-top: 1px; color: #aeb8c6; font-size: 10px; }
.top-actions { display: flex; align-items: center; }
.ghost-btn {
  border: 0;
  background: transparent;
  color: #bdc6d3;
  text-decoration: none;
  cursor: pointer;
}
.ghost-btn:hover { color: #fff; }

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px clamp(18px, 3.5vw, 52px) 56px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 410px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.controls { padding: 22px; }

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 22px;
  padding: 4px;
  border-radius: 6px;
  background: #eef1f5;
}

.mode {
  min-height: 42px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #808b9c;
  font-weight: 700;
  cursor: pointer;
}
.mode:hover { color: var(--ink); }
.mode.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(25, 35, 49, 0.08);
}

.field { margin-bottom: 18px; }
.field label:not(.upload) {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #293343;
  font-size: 12px;
  font-weight: 700;
}
.field em { color: var(--accent); font-style: normal; }

.upload {
  position: relative;
  height: 242px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--soft);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}
.upload:hover { border-color: var(--accent); background: #fffaf8; }
.upload input { display: none; }
.upload b { display: block; color: #556276; font-size: 13px; }
.upload small { display: block; margin-top: 6px; color: #929cad; font-size: 10px; }
.upload img { display: none; width: 100%; height: 100%; object-fit: contain; }
.upload.has-image { background: #fff; border-style: solid; }
.upload.has-image span { display: none; }
.upload.has-image img { display: block; }

select, input, textarea {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
select:focus, input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(237, 104, 66, 0.1);
}
select { width: 100%; height: 44px; padding: 0 11px; }

.field-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(190px, 1.4fr);
  gap: 12px;
}
.field-row.single { grid-template-columns: 1fr; }
.field-row .field { margin-bottom: 16px; }
.count-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.count-inputs input { width: 100%; height: 44px; text-align: center; }
.counts small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; text-align: center; }

.primary-btn {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}
.primary-btn:hover { background: var(--accent-dark); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.55; cursor: wait; }
.arrow { font-size: 18px; line-height: 1; }

.results {
  min-height: 568px;
  padding: 24px 26px;
  overflow: hidden;
}
.results-head, .section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.8px;
}
.results h2, .section-head h2 { margin: 0; font-size: 19px; letter-spacing: 0; }
.result-count { color: var(--muted); font-size: 11px; }

.empty, .loading {
  min-height: 450px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}
.empty-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border: 1px solid #efb8a8;
  border-radius: 50%;
  color: var(--accent);
  font-size: 20px;
}
.empty h3 { margin: 0; color: #3d4858; font-size: 14px; }
.hidden { display: none !important; }

.loading { flex-direction: row; flex-wrap: wrap; align-content: center; gap: 6px; }
.loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite;
}
.loading span:nth-child(2) { animation-delay: 0.15s; }
.loading span:nth-child(3) { animation-delay: 0.3s; }
.loading b { width: 100%; margin-top: 7px; font-size: 12px; font-weight: 500; }
@keyframes pulse { 50% { opacity: 0.3; transform: translateY(-3px); } }

.result-list { display: grid; gap: 0; margin-top: 20px; }
.group-title {
  margin: 18px 0 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
}
.group-title:first-child { margin-top: 0; }
.prompt-card {
  padding: 15px 0;
  border-top: 1px solid var(--line);
  background: #fff;
}
.card-top { display: flex; justify-content: space-between; color: var(--accent); font-size: 10px; font-weight: 800; }
.card-index { color: #a3acb9; }
.prompt { margin: 9px 0 13px; color: #394556; font-size: 13px; line-height: 1.75; white-space: pre-wrap; }
.card-actions { display: flex; gap: 8px; }
.card-actions button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
}
.card-actions .copy { border-color: #cad8ef; color: var(--blue); }
.card-actions .make-image { border-color: #f0cabf; color: var(--accent); }
.generated { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.generated img { display: block; max-width: min(320px, 100%); border-radius: 5px; }

.history-section { margin-top: 34px; }
.history-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.history-item {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.history-item:hover { border-color: var(--line-strong); }
.history-item b { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.history-item small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.muted { color: var(--muted); font-size: 12px; }

.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; margin-bottom: 34px; }
.intro h1 { margin: 0 0 10px; font-size: clamp(27px, 3.1vw, 44px); line-height: 1.15; letter-spacing: 0; }
.subhead { margin: 0; color: var(--muted); font-size: 15px; }
.admin-shell { max-width: 1080px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .controls { padding: 20px; }
  .upload { height: min(54vw, 300px); }
  .results { min-height: 360px; }
  .empty, .loading { min-height: 260px; }
  .history-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .topbar { height: 60px; padding: 0 16px; }
  .brand small { display: none; }
  .shell { padding: 16px 12px 40px; }
  .controls, .results { padding: 16px; }
  .mode { min-height: 40px; }
  .upload { height: 64vw; min-height: 210px; }
  .field-row { grid-template-columns: 1fr; }
  .results { min-height: 320px; }
  .empty, .loading { min-height: 220px; }
  .history-grid { grid-template-columns: 1fr; }
  .card-actions button { flex: 1; }
}
