:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #2b2a26;
  --muted: #8a877e;
  --accent: #e8703a;
  --accent-dark: #d45f2b;
  --line: #e7e4dc;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 30px rgba(40, 35, 25, .08);
  text-align: center;
}
.login-card h1 { font-size: 26px; margin-bottom: 8px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color .15s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s;
}
.login-card button:hover { background: var(--accent-dark); }

/* ---------- 布局 ---------- */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 16px 60px;
}
.header { margin-bottom: 20px; }
.header h1 { font-size: 26px; }
.subtitle { color: var(--muted); font-size: 14px; margin-top: 4px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(40, 35, 25, .05);
}
.card h2 { font-size: 17px; margin-bottom: 14px; }

/* ---------- 上传 ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: #fdf6f2;
}
.dropzone-icon { font-size: 34px; margin-bottom: 8px; }
.dropzone p { color: var(--ink); font-size: 14px; }
.dropzone-hint { color: var(--muted); font-size: 12px !important; margin-top: 6px; }

#preview-box { display: flex; align-items: center; gap: 16px; text-align: left; }
#preview-img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.preview-meta { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  padding: 0;
  align-self: flex-start;
}

/* ---------- 风格 ---------- */
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.style-card {
  border: 2px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, transform .12s;
  text-align: left;
  padding: 0;
}
.style-card:hover { transform: translateY(-2px); }
.style-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 112, 58, .15); }
.style-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: var(--bg);
}
.style-card .style-info { padding: 10px 12px 12px; }
.style-card .style-name { font-size: 14px; font-weight: 600; }
.style-card .style-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.style-loading { color: var(--muted); font-size: 14px; grid-column: 1 / -1; }
.style-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 1px 6px;
  margin-top: 6px;
}

/* ---------- 生成 ---------- */
.tier-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tier-label { font-size: 14px; color: var(--muted); }
.tier-hint { font-size: 12px; color: var(--muted); width: 100%; }
.segmented { display: inline-flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented button {
  border: none;
  background: #fff;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink);
}
.segmented button.active { background: var(--accent); color: #fff; }

.generate-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.generate-btn:hover:not(:disabled) { background: var(--accent-dark); }
.generate-btn:disabled { background: #d8d5cc; cursor: not-allowed; }

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--ink);
}
.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-text { color: #c0392b; font-size: 14px; margin-top: 10px; }

/* ---------- 结果 ---------- */
.result-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.result-compare figure { margin: 0; }
.result-compare img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
  background: var(--bg);
}
.result-compare figcaption {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 11px 22px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
  border: none;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 22px;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink);
}
.btn-secondary:hover { border-color: var(--muted); }

/* ---------- 历史 ---------- */
.history-head { display: flex; align-items: baseline; gap: 10px; }
.history-hint { font-size: 12px; color: var(--muted); }
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.history-grid img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  display: block;
  transition: transform .12s;
}
.history-grid img:hover { transform: scale(1.03); }
.history-empty { color: var(--muted); font-size: 14px; grid-column: 1 / -1; }

/* ---------- 风格封面放大预览 ---------- */
.style-lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(35, 31, 25, .28);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, backdrop-filter .3s ease, -webkit-backdrop-filter .3s ease;
}
.style-lightbox.open {
  opacity: 1;
  pointer-events: auto;
  background: rgba(35, 31, 25, .38);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.lightbox-figure { margin: 0; display: flex; flex-direction: column; align-items: center; max-width: 100%; }
.style-lightbox img {
  width: min(86vw, calc(70vh * 0.75), 520px);
  aspect-ratio: 3 / 4;
  height: auto;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(30, 25, 15, .35);
  background: #fff;
  will-change: transform;
}
.lightbox-caption {
  text-align: center;
  margin-top: 16px;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .25);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s ease .12s, transform .3s ease .12s;
}
.style-lightbox.open .lightbox-caption { opacity: 1; transform: none; }
.lightbox-name { font-size: 17px; font-weight: 600; }
.lightbox-desc { font-size: 13px; opacity: .88; margin-top: 4px; }
.style-lightbox .style-badge {
  display: inline-block;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  font-size: 11px;
  border-radius: 6px;
  padding: 1px 8px;
  margin-top: 8px;
}
.style-lightbox .selected-note { font-size: 12px; opacity: .75; margin-top: 8px; }
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: rgba(255, 255, 255, .14);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 16px;
  color: #fff;
  cursor: pointer;
  transition: background .15s;
  z-index: 1;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .28); }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 22, .45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-body {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 760px;
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  z-index: 1;
}
.modal-meta { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #33312c;
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 99;
  max-width: 80vw;
}

@media (max-width: 560px) {
  .result-compare { grid-template-columns: 1fr; }
  .card { padding: 16px; }
}
