@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600&family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #f7f4ef;
  --card: #fffefb;
  --ink: #2c2824;
  --muted: #7a7268;
  --accent: #8b5a3c;
  --accent-soft: #e8ddd3;
  --border: #e5ddd2;
  --danger: #b54a4a;
  --shadow: 0 8px 32px rgba(44, 40, 36, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', 'Noto Serif SC', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a88a, #8b5a3c);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Noto Serif SC', serif;
  font-weight: 600;
}
.brand-title { margin: 0; font-size: 1.15rem; font-family: 'Noto Serif SC', serif; }
.brand-sub { margin: 0; font-size: 0.8rem; color: var(--muted); }

.nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.nav a {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}
.nav a.active, .nav a:hover {
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.layout-main {
  display: grid;
  grid-template-columns: 280px 1fr 220px;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .layout-main { grid-template-columns: 1fr; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-family: 'Noto Serif SC', serif;
}

.field { margin-bottom: 0.85rem; }
.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.field select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.9rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-zone p { margin: 0.35rem 0; font-size: 0.85rem; color: var(--muted); }
.upload-zone strong { color: var(--accent); }

.ref-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.ref-item {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.ref-item img { width: 100%; height: 100%; object-fit: cover; }
.ref-item .badge {
  position: absolute;
  top: 4px; left: 4px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
}
.ref-item button {
  position: absolute;
  top: 4px; right: 4px;
  border: none;
  background: var(--danger);
  color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
}

.preview-area {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.preview-placeholder {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}
.preview-img {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  width: 100%;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 70vh;
  overflow-y: auto;
}
.history-item {
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.history-item img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  margin-top: 0.5rem;
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  width: 100%;
  margin-top: 0.4rem;
}
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; width: auto; }

.copy-section {
  max-width: 1400px;
  margin: 0 auto 2rem;
  padding: 0 1.5rem;
}
.copy-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.copy-block h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.copy-text {
  font-size: 0.85rem;
  color: var(--ink);
  white-space: pre-wrap;
  margin: 0 0 0.5rem;
}
.copy-list { margin: 0; padding-left: 1.1rem; font-size: 0.85rem; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 100;
}
.toast.show { opacity: 1; }

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-hero {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  text-align: center;
}
.page-hero h1 { font-family: 'Noto Serif SC', serif; }
.steps { text-align: left; max-width: 560px; margin: 1.5rem auto; }
.steps li { margin-bottom: 0.5rem; }

.hidden { display: none !important; }

.admin-wrap { max-width: 960px; margin: 2rem auto; padding: 0 1rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th, .admin-table td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: left;
}
.admin-table textarea { width: 100%; min-height: 60px; }

/* —— 用户端体验增强 —— */
.status-strip {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.status-strip--ok { color: #4a6b4a; background: #f0f6f0; }
.status-strip--busy { color: #8b5a3c; background: var(--accent-soft); }

.user-steps {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  max-width: 1400px;
  margin: 0 auto;
}
.user-step {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
}
.user-step span {
  display: inline-flex;
  width: 1.25rem; height: 1.25rem;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--border);
  font-size: 0.7rem;
  margin-right: 0.25rem;
}
.user-step.done { border-color: #4a6b4a; color: #4a6b4a; }
.user-step.done span { background: #4a6b4a; color: #fff; }
.user-step.active { border-color: var(--accent); color: var(--accent); font-weight: 500; }
.user-step.active span { background: var(--accent); color: #fff; }

.label-req { font-weight: 400; color: var(--danger); font-size: 0.75rem; }
.label-hint { font-weight: 400; color: var(--muted); font-size: 0.72rem; }
.hint-small { font-size: 0.8rem; color: var(--muted); }
.generate-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}
.empty-hint { font-size: 0.8rem; color: var(--muted); margin: 0; }

.upload-zone--full { opacity: 0.65; cursor: not-allowed; }
.upload-zone--disabled { pointer-events: none; opacity: 0.7; }
.hint-small { display: block; margin-top: 0.35rem; }

.ref-item .ref-rm { position: absolute; top: 4px; right: 4px; border: none; background: var(--danger); color: #fff; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; }

.loading-title { font-size: 1rem; color: var(--ink); margin: 0; }
.loading-sub, .loading-tip { font-size: 0.8rem; margin: 0; text-align: center; max-width: 280px; }
.progress-bar {
  width: 100%; max-width: 240px; height: 6px;
  background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--accent);
  transition: width 0.3s ease;
}

.preview-img--main { max-width: 400px; cursor: zoom-in; }
.preview-img.is-active { outline: 3px solid var(--accent); outline-offset: 2px; }
.preview-actions {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  justify-content: center; margin-top: 1rem;
}
.preview-actions .btn { width: auto; margin-top: 0; }
.result-count { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.75rem; text-align: center; width: 100%; }
.preview-card { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.preview-card-dl { width: 100% !important; margin-top: 0 !important; }

.copy-type-hint { font-size: 0.85rem; color: var(--muted); margin: 0 0 1rem; }
.copy-list li {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 0.5rem; margin-bottom: 0.5rem; list-style: disc;
}
.copy-row { display: flex; gap: 0.5rem; align-items: flex-start; margin-bottom: 0.75rem; }
.copy-row .copy-text { flex: 1; margin: 0; }
.btn-copy-one {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--accent);
}

.lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 1rem;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 100%; max-height: 90vh;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute; top: 1rem; right: 1rem;
  border: none; background: rgba(255,255,255,0.2);
  color: #fff; width: 40px; height: 40px;
  border-radius: 50%; font-size: 1.5rem; cursor: pointer;
}

.mobile-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 0.65rem 1rem;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  z-index: 50;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.mobile-bar .btn { width: auto; margin: 0; min-width: 88px; }
.mobile-bar span { font-size: 0.85rem; color: var(--muted); flex: 1; }

@media (max-width: 1024px) {
  body { padding-bottom: 72px; }
  .mobile-bar { display: flex; }
  .ref-grid { grid-template-columns: repeat(3, 1fr); }
  .panel-left .btn-primary { margin-bottom: 0; }
}
@media (max-width: 480px) {
  .ref-grid { grid-template-columns: repeat(2, 1fr); }
  .user-steps { font-size: 0.75rem; }
  .site-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}
