:root {
  --midnight-indigo: #100b22;
  --surface: #1d1638;
  --surface-2: #2a214e;
  --gold: #e8c66a;
  --rose: #ff7eb3;
  --text: #f2ecff;
  --muted: #b9add6;
  --line: rgba(232, 198, 106, 0.34);
  --danger: #ff9abf;
  --safe-midnight: #15122a;
  --safe-surface: #241f3f;
  --safe-gold: #d7b75f;
  --safe-rose: #e874a5;
  --safe-text: #efe8f7;
}

* { box-sizing: border-box; }

html { background: var(--midnight-indigo); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", SimSun, serif;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 126, 179, 0.18), transparent 32rem),
    radial-gradient(circle at 82% 12%, rgba(232, 198, 106, 0.14), transparent 30rem),
    linear-gradient(180deg, #100b22 0%, #15102a 58%, #0d091c 100%);
}

button, select, input, a.button-link {
  font: inherit;
}

button, a.button-link {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(232, 198, 106, 0.08);
  border-radius: 8px;
  padding: 10px 13px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

button:hover, a.button-link:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
  background: rgba(232, 198, 106, 0.14);
}

button.primary {
  color: #160d25;
  background: linear-gradient(135deg, var(--gold), var(--rose));
  border-color: transparent;
  font-weight: 700;
}

.app-header {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 34px clamp(18px, 4vw, 52px) 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-family: "Cormorant Garamond", serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .18em;
}

h1, h2, h3 {
  font-family: "Cormorant Garamond", "Source Han Serif SC", serif;
  font-weight: 700;
  letter-spacing: .02em;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 7vw, 78px);
  line-height: .9;
  color: var(--text);
}

h2 { margin: 0; font-size: 30px; }
h3 { margin: 0 0 12px; font-size: 22px; color: var(--gold); }

.lead {
  max-width: 780px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(29, 22, 56, .72);
}

.switch input { accent-color: var(--gold); }

main {
  padding: 0 clamp(14px, 4vw, 52px) 54px;
}

.panel {
  border: 1px solid var(--line);
  background: rgba(29, 22, 56, 0.76);
  box-shadow: 0 20px 80px rgba(0, 0, 0, .24);
  border-radius: 8px;
  padding: 18px;
  margin-top: 18px;
}

.controls-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.spec-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
  flex: 1;
}

.spec-grid div {
  border: 1px solid rgba(232, 198, 106, .18);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(16, 11, 34, .42);
}

.spec-grid b {
  display: block;
  color: var(--gold);
  font-family: "Cormorant Garamond", serif;
  font-size: 18px;
}

.spec-grid span {
  color: var(--muted);
  font-size: 13px;
}

.export-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(240px, 310px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.side-panel {
  position: sticky;
  top: 18px;
}

select {
  width: 100%;
  margin: 8px 0 14px;
  padding: 11px 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selected-preview {
  display: grid;
  place-items: center;
  min-height: 410px;
  overflow: auto;
}

.note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 16px;
}

.section-head p:last-child {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
  line-height: 1.6;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(166px, 1fr));
  gap: 18px;
  align-items: start;
}

.card-tile {
  border: 1px solid rgba(232, 198, 106, .16);
  border-radius: 8px;
  padding: 10px;
  background: rgba(16, 11, 34, .34);
  cursor: pointer;
}

.card-tile.active {
  border-color: var(--rose);
  box-shadow: 0 0 0 1px rgba(255, 126, 179, .28), 0 18px 42px rgba(0, 0, 0, .22);
}

.card-caption {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.card-caption b {
  color: var(--text);
  font-family: "Cormorant Garamond", serif;
  font-size: 15px;
}

.print-card-svg {
  width: 100%;
  max-width: 210px;
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .28));
}

.selected-preview .print-card-svg {
  max-width: 245px;
}

.asset-grid {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 24px;
}

.asset-preview, .dieline-preview {
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: auto;
  background: rgba(16, 11, 34, .4);
  border: 1px solid rgba(232, 198, 106, .16);
  border-radius: 8px;
  padding: 18px;
}

.dieline-preview svg {
  width: min(100%, 980px);
  height: auto;
}

.hide-guides .safe-guide,
.hide-guides .guide-label { display: none; }

.hide-bleed .bleed-tint,
.hide-bleed .bleed-label { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px;
  color: var(--text);
  background: rgba(29, 22, 56, .96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 50px rgba(0, 0, 0, .34);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 20;
}

.toast.show { opacity: 1; }

.booklet-body {
  background: #f7f1e8;
  color: #221a34;
}

.booklet-header {
  padding: 28px 28px 10px;
  color: #221a34;
}

.booklet-header h1 {
  color: #221a34;
  font-size: 46px;
}

.booklet-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.booklet-actions button,
.booklet-actions a {
  color: #221a34;
  border-color: rgba(34, 26, 52, .28);
  background: rgba(232, 198, 106, .28);
}

.booklet-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148mm, 1fr));
  gap: 18px;
  padding: 18px 28px 40px;
}

.booklet-page {
  width: 148mm;
  min-height: 210mm;
  padding: 12mm;
  background: #fffaf2;
  border: 1px solid rgba(34, 26, 52, .18);
  box-shadow: 0 16px 36px rgba(34, 26, 52, .18);
}

.booklet-page.cover {
  display: grid;
  align-content: center;
  text-align: center;
  border: 2px solid #d7b75f;
}

.booklet-page.cover h2 {
  font-size: 44px;
  color: #221a34;
}

.booklet-card {
  break-inside: avoid;
  padding: 6mm 0;
  border-bottom: 1px solid rgba(34, 26, 52, .14);
}

.booklet-card h3 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 3mm;
  color: #221a34;
  font-size: 22px;
}

.booklet-card .keyword {
  color: #9b2f62;
  font-weight: 700;
}

.booklet-card p {
  margin: 2mm 0;
  line-height: 1.65;
}

@media (max-width: 900px) {
  .app-header, .section-head { align-items: flex-start; flex-direction: column; }
  .layout, .asset-grid { grid-template-columns: 1fr; }
  .side-panel { position: static; }
  .spec-grid { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  @page { size: A6; margin: 0; }
  body { background: #fff; }
  .booklet-header, .booklet-actions { display: none; }
  .booklet-pages {
    display: block;
    padding: 0;
  }
  .booklet-page {
    width: 105mm;
    min-height: 148mm;
    padding: 9mm;
    border: 0;
    box-shadow: none;
    page-break-after: always;
  }
}

/* ── 版本号系统 ── */
.version-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-family: "Cormorant Garamond", serif;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--gold);
  background: rgba(232, 198, 106, .08);
  border: 1px solid var(--line);
  border-radius: 20px;
  white-space: nowrap;
}

.update-banner {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(100vw - 24px);
  padding: 12px 16px 12px 20px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(232, 198, 106, .2), rgba(37, 23, 69, .98));
  border: 1px solid var(--gold);
  border-radius: 40px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  animation: bannerDrop .35s ease;
}
.update-banner[hidden] { display: none; }
.update-banner b { color: var(--gold); }
.update-banner button {
  flex-shrink: 0;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: #271a05;
  background: linear-gradient(135deg, #f5d98b, var(--gold));
  border: none;
  border-radius: 24px;
  cursor: pointer;
}
.update-banner button:active { transform: scale(.97); }
@keyframes bannerDrop { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translateX(-50%); } }
