* { box-sizing: border-box; }
body {
  margin: 0 auto;
  max-width: 1380px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f7f3cf;
  color: #3f3f56;
  padding: 18px;
}
.dot { position: fixed; border-radius: 50%; opacity: .25; z-index: 0; pointer-events: none; }
.dot1 { width: 90px; height: 90px; background: #ffb8c6; left: 22px; top: 52px; }
.dot2 { width: 100px; height: 100px; background: #cdb4ff; left: 220px; bottom: 80px; }
.dot3 { width: 90px; height: 90px; background: #a0d8ff; right: 160px; top: 280px; }

.topbar, .grid-main, .card { position: relative; z-index: 1; }

.btn { border: none; border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.btn.icon {
  background: #e8ddff; color: #7959df;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
}
.btn.icon svg { width: 18px; height: 18px; fill: currentColor; }
.btn.green { background: #c9f0da; color: #2c8b5a; }
.btn.gray { background: #ececf0; color: #666; }
.btn.orange { background: linear-gradient(90deg, #ff8b2c, #ff5db1); color: #fff; }
.btn.purple { background: linear-gradient(90deg, #d044c0, #7a53f2); color: #fff; }
.btn.cyan { background: #14b8b0; color: #fff; }

.grid-main {
  display: grid;
  grid-template-columns: 520px 1fr;
  gap: 16px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}
.card {
  background: linear-gradient(135deg, #f7e9f2, #edf6ef);
  border: 1px solid #efdce9;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .05);
}
.title-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.title-row h2 { margin: 0; color: #6a55ff; }

.switch {
  background: #fff;
  border: 1px solid #eed4e9;
  border-radius: 16px;
  padding: 4px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.switch button {
  border: none;
  border-radius: 12px;
  padding: 8px 12px;
  background: transparent;
  cursor: pointer;
}
.switch .active { background: #5d7cff; color: #fff; }

label { display: block; margin: 14px 0 8px; font-weight: 600; color: #666b82; }
textarea {
  width: 100%;
  height: 88px;
  border: 2px solid #f1c7e2;
  border-radius: 14px;
  padding: 12px;
  font-size: 15px;
}
.counter { text-align: right; color: #9196ad; margin-top: 4px; }
.row { display: flex; gap: 10px; margin-top: 12px; }

.image-panel { margin-top: 14px; }
.ref-row { display: flex; justify-content: space-between; align-items: center; }
.upload-box {
  margin-top: 8px;
  border: 2px dashed #f0b9dc;
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  background: rgba(255, 255, 255, .4);
}
.upload-box.dragover { border-color: #7c5cff; background: rgba(124, 92, 255, .08); }

.thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.thumb-item { position: relative; }
.thumbs img { width: 100%; height: 70px; object-fit: cover; border-radius: 8px; cursor: pointer; }
.thumb-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; cursor: pointer;
}

.expand-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.expand-grid input {
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #d8d8de;
}

.hidden { display: none !important; }

.toolbar {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(180px,1fr) minmax(120px,.8fr) auto;
  gap: 12px;
  align-items: end;
}
.toolbar p { margin: 0 0 6px; font-weight: 600; }
select {
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #d8d8de;
  background: #f4f4f6;
}

.action-wrap { display: flex; align-items: center; gap: 10px; }
.btn-generate, .btn-history { min-width: 108px; height: 36px; padding: 0 14px; white-space: nowrap; }

.result-head { display: flex; justify-content: space-between; align-items: center; }
.result h2 { margin: 0; color: #c950ea; }
#status { color: #666c87; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  min-height: 240px;
}
.result-grid img { width: 100%; border-radius: 12px; cursor: zoom-in; }

.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .4);
  display: grid; place-items: center; z-index: 310;
}
.panel {
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 16px;
  padding: 16px;
}
.panel input {
  width: 100%; padding: 10px; border: 1px solid #ddd;
  border-radius: 10px; margin-bottom: 10px;
}
.preview { width: min(1000px, 94vw); position: relative; }
.preview img { width: 100%; max-height: 90vh; object-fit: contain; border-radius: 12px; }
#btn-close-preview {
  position: absolute; top: 8px; right: 8px;
  border: none; border-radius: 50%; width: 30px; height: 30px; cursor: pointer;
}

.history-wrap {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  padding: 10px 12px;
}
.history-wrap #history-list { margin: 0; padding-left: 18px; max-height: 220px; overflow: auto; }

.topbar {
  min-height: 72px;
  background: linear-gradient(135deg, #ffebf5, #ece6fb);
  border: 1px solid #d9dae6;
  border-bottom: 1px solid rgba(236, 72, 153, 0.2);
  border-radius: 0 0 14px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; margin: -18px 0 16px; z-index: 300;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; color: #d65adf; line-height: 1.05; }
.brand p { margin: 0; font-size: 12px; color: #5c6077; line-height: 1.2; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

@media (max-width: 980px) { .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .action-wrap { grid-column: 1 / -1; }
}
/* 历史记录项移动端优化：文本与复制按钮分行更整齐 */
#history-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.5;
}

#history-list li > span {
  flex: 1 1 260px;
  min-width: 0;
  word-break: break-all;
}

#history-list li > button {
  flex: 0 0 auto;
}

/* 小屏下按钮独占一行，避免挤压文本 */
@media (max-width: 640px) {
  #history-list li > button {
    margin-left: 0 !important;
    width: 100%;
    height: 34px !important;
  }
}

/* ===== 示例区（恢复 image.html 的 samples 样式） ===== */
.samples {
  margin-top: 16px;
  width: 100%;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.samples-grid.one-line {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 175px;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding-bottom: 4px;
  font-size: 0.875rem;
  text-align: center;
  align-items: start;
}

.sample-item {
  width: 175px;
  color: #3f3f56;
  cursor: pointer;
  user-select: none;
}

.sample-item img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  margin: 0 auto 6px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sample-item:hover img {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

/* 横向滚动条更柔和 */
.samples-grid.one-line::-webkit-scrollbar {
  height: 8px;
}
.samples-grid.one-line::-webkit-scrollbar-thumb {
  background: rgba(120, 90, 170, 0.35);
  border-radius: 999px;
}
.samples-grid.one-line::-webkit-scrollbar-track {
  background: transparent;
}