:root {
  --ink: #493c58;
  --muted: #806f89;
  --soft: #b0a2ba;
  --pink: #ffd2e2;
  --deep-pink: #d85d8a;
  --cream: #fff5df;
  --paper: #fffdf8;
  --purple: #bca2f6;
  --yellow: #ffd874;
  --line: #ddd0e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(255,255,255,.9), transparent 28%),
    radial-gradient(circle at 90% 15%, rgba(188,162,246,.15), transparent 24%),
    #f8eef3;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.spec-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border: 4px solid var(--ink);
  border-radius: 22px;
  background: rgba(255,253,248,.92);
  box-shadow: 0 7px 0 rgba(73,60,88,.10);
}
.spec-heading strong { display: block; font-size: 14px; font-weight: 900; }
.spec-heading small { color: var(--muted); font-size: 11px; }
.spec-options { display: flex; gap: 8px; flex: none; }
.spec-options button {
  min-width: 126px;
  padding: 8px 18px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  text-align: left;
}
.spec-options button b { display: block; font-size: 14px; }
.spec-options button span { font-size: 10px; }
.spec-options button.on {
  border-color: var(--ink);
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(73,60,88,.12);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px;
  border: 4px solid var(--ink);
  border-radius: 30px;
  background: linear-gradient(120deg, rgba(255,253,248,.96), rgba(255,234,243,.92));
  box-shadow: 0 10px 0 rgba(73,60,88,.10);
}

.brand { display: flex; align-items: center; gap: 20px; min-width: 0; }
.brand-mark {
  width: 92px; height: 92px; flex: none; object-fit: cover;
  border: 4px solid var(--ink); border-radius: 26px;
  transform: rotate(-4deg); background: #fff;
  box-shadow: 6px 8px 0 rgba(73,60,88,.12);
}
.eyebrow, .kicker {
  margin: 0;
  color: var(--deep-pink);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 34px; letter-spacing: -.03em; }
h2 { margin-bottom: 0; font-size: 24px; }
.brand-sub { margin: 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 12px; flex: none; }

.btn {
  min-height: 46px;
  padding: 0 22px;
  border: 3px solid var(--ink);
  border-radius: 15px;
  font-weight: 900;
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(73,60,88,.12);
}
.btn:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(73,60,88,.12); }
.btn.primary { background: var(--yellow); }
.btn.pink { background: var(--pink); }
.btn.ghost { background: rgba(255,255,255,.75); }
.btn.wide { flex: 1; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(610px, .96fr);
  gap: 22px;
  align-items: start;
  margin-top: 22px;
}

.form-panel, .preview-panel {
  border: 4px solid var(--ink);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 9px 0 rgba(73,60,88,.10);
}
.form-panel { padding: 26px; }
.preview-panel { position: sticky; top: 18px; padding: 24px; }

.template-picker {
  margin-bottom: 18px;
  padding: 14px;
  border: 3px dashed #e5c9d5;
  border-radius: 18px;
  background: #fff8fb;
}
.template-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}
.template-title span { font-size: 13px; font-weight: 900; }
.template-title small { color: var(--muted); font-size: 10px; }
.template-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}
.template-card {
  min-width: 0;
  padding: 8px 4px 7px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}
.template-card.on {
  border-color: var(--ink);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(73,60,88,.12);
}
.template-swatch {
  display: block;
  width: 100%;
  height: 18px;
  margin-bottom: 5px;
  border: 1px solid rgba(73,60,88,.25);
  border-radius: 7px;
  background-size: cover;
  background-position: center center;
}
.template-swatch.elegant { background: linear-gradient(90deg,#fffdfb 0 54%,#403536 54% 78%,#c9a5a8 78%); }
.template-swatch.cream { background: linear-gradient(90deg,#fffdf5 0 56%,#d5c78d 56% 79%,#bfd1ae 79%); }
.template-swatch.cloud { background: linear-gradient(90deg,#f5fbff 0 56%,#8ba8cb 56% 79%,#d7e4f3 79%); }
.template-swatch.rose { background: linear-gradient(90deg,#fff8f8 0 56%,#8f4e5b 56% 79%,#ddb9c0 79%); }
.template-swatch.minimal { background: linear-gradient(90deg,#fff 0 56%,#222 56% 79%,#d8d8d8 79%); }

.panel-head, .preview-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; padding-bottom: 18px;
}
.preview-badges { display: flex; align-items: center; gap: 8px; }
.spec-badge {
  padding: 7px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff7d8;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
}
.status-pill, .live-dot {
  padding: 7px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #f5edff;
  color: #755a9f;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}
.live-dot::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #42b88b;
  box-shadow: 0 0 0 4px rgba(66,184,139,.14);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid label { min-width: 0; }
.form-grid label > span {
  display: block;
  margin: 0 2px 7px;
  color: #75677e;
  font-size: 12px;
  font-weight: 900;
}
.form-grid label.full { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%;
  border: 3px solid var(--line);
  border-radius: 14px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
input, select { height: 48px; padding: 0 14px; }
textarea { min-height: 78px; padding: 12px 14px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(188,162,246,.15);
}
#points { background: #fff7e8; }

.segmented {
  display: flex;
  height: 48px;
  gap: 6px;
  padding: 4px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.segment {
  flex: 1;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
.segment.on {
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(73,60,88,.12);
}

.multi-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border: 3px dashed #e8b8ca;
  border-radius: 16px;
  background: #fff7fb;
}
.multi-title { display: block; font-size: 13px; font-weight: 900; }
.multi-panel small { color: var(--muted); font-size: 11px; }
.multi-buttons { display: flex; gap: 8px; flex: none; }
.extra-btn {
  min-width: 82px;
  height: 40px;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
.extra-btn.on {
  border-color: var(--ink);
  background: var(--pink);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(73,60,88,.12);
}

.discount-panel {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border: 3px dashed #e8c9d5;
  border-radius: 16px;
  background: #fff9fb;
}
.discount-copy { flex: 1; min-width: 0; }
.discount-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.discount-controls { display: flex; align-items: center; gap: 10px; }
.discount-switch { flex: 1; width: auto; }
.discount-value {
  display: flex;
  align-items: center;
  width: 118px;
  flex: none;
  height: 48px;
  padding-right: 12px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.discount-value input {
  height: 42px;
  border: 0;
  box-shadow: none;
  text-align: right;
  padding-right: 3px;
}
.discount-value input:focus { box-shadow: none; }
.discount-value span { color: var(--muted); font-size: 13px; font-weight: 900; }

.inline-input { display: flex; gap: 8px; }
.inline-input input { min-width: 0; flex: 1; }
.mini-btn {
  width: 64px;
  flex: none;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff1f7;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.total-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 20px; padding: 18px 20px;
  border: 3px solid var(--ink); border-radius: 20px;
  background: linear-gradient(135deg, #fff8e8, #ffe9f1);
}
.total-row span { display: block; font-size: 14px; font-weight: 900; }
.total-row small { color: var(--muted); font-size: 11px; }
.total-row strong { color: var(--deep-pink); font-size: 32px; }

.form-actions { display: flex; gap: 12px; margin-top: 18px; }
.form-status { margin: 14px 2px 0; color: var(--muted); font-size: 12px; }

.receipt-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 188px;
  gap: 14px;
  align-items: start;
}
.receipt-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 540px;
  max-height: calc(100vh - 215px);
  overflow: auto;
  padding: 22px;
  border: 3px dashed #e6b8c9;
  border-radius: 22px;
  background:
    radial-gradient(circle at 16px 16px, rgba(238,108,156,.10) 2px, transparent 2.5px) 0 0 / 30px 30px,
    #fff7eb;
}
.background-panel {
  padding: 14px;
  border: 3px dashed #d9c3e9;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.96), rgba(250,243,255,.94));
}
.background-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.background-panel-head strong { display: block; font-size: 14px; font-weight: 900; }
.background-panel-head small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}
.background-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: var(--yellow);
  font-size: 10px;
  font-weight: 900;
  box-shadow: 2px 3px 0 rgba(73,60,88,.12);
}
.background-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(45deg, #f1eaf6 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(45deg, transparent 75%, #f1eaf6 75%) 0 0 / 16px 16px,
    linear-gradient(45deg, transparent 75%, #f1eaf6 75%) -8px 8px / 16px 16px,
    linear-gradient(45deg, #f1eaf6 25%, #fff 25%) -8px 8px / 16px 16px;
  cursor: pointer;
  outline: 0;
}
.background-preview:hover, .background-preview:focus-visible {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(188,162,246,.18);
}
.background-preview.drag-over {
  border-color: var(--deep-pink);
  box-shadow: 0 0 0 4px rgba(216,93,138,.16);
}
#backgroundPreviewImage {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.background-empty-copy {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}
.background-empty-copy b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--deep-pink);
  font-size: 21px;
  line-height: 1;
}
.background-preview:not(.empty) #backgroundPreviewImage { display: block; }
.background-preview:not(.empty) .background-empty-copy { display: none; }
.background-preview.empty #backgroundPreviewImage { display: none; }
.background-upload-btn {
  width: 100%;
  min-height: 36px;
  margin-top: 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(73,60,88,.10);
}
.background-upload-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(73,60,88,.10); }
.background-file {
  min-height: 28px;
  margin: 7px 0 12px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.background-slider {
  display: block;
  padding: 12px 0;
  border-top: 2px dashed #e5d8ea;
  border-bottom: 2px dashed #e5d8ea;
  font-size: 11px;
  font-weight: 900;
}
.background-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}
.background-slider input {
  min-width: 0;
  flex: 1;
  accent-color: var(--deep-pink);
  cursor: pointer;
}
.background-slider output {
  min-width: 37px;
  color: var(--deep-pink);
  font-size: 11px;
  font-weight: 900;
  text-align: right;
}
.background-slider small {
  display: block;
  margin-top: 6px;
  color: var(--soft);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.45;
}
.background-remove {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  border: 2px solid #e0c4cf;
  border-radius: 10px;
  background: #fff7fa;
  color: var(--deep-pink);
  font-size: 10px;
  font-weight: 900;
}
.background-remove:disabled {
  cursor: default;
  opacity: .38;
}
.receipt-canvas-wrap {
  position: relative;
  width: min(100%, 480px);
  margin: 0 auto;
  transition: width .18s ease;
}
.receipt-canvas-wrap.spec-90 { width: min(100%, 340px); }
#receiptImage {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 12px 18px rgba(73,60,88,.16));
}
.receipt-edit-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.receipt-inline-input {
  position: absolute;
  z-index: 2;
  min-width: 0;
  padding: 0 5px;
  border: 1px dashed transparent;
  border-radius: 6px;
  outline: 0;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-weight: 800;
  pointer-events: auto;
  transition: background .12s ease, border-color .12s ease;
}
.receipt-inline-input:hover {
  border-color: rgba(188,162,246,.55);
  background: rgba(255,255,255,.42);
}
.receipt-inline-input:focus {
  z-index: 4;
  border-color: #bca2f6;
  background: rgba(255,255,255,.97);
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  box-shadow: 0 5px 14px rgba(73,60,88,.14);
}
.receipt-inline-input::selection {
  background: #ffd874;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
}
.receipt-inline-input.title {
  font-weight: 900;
  letter-spacing: .5px;
}
.preview-tip {
  margin: 13px 2px 0;
  text-align: center;
  color: var(--soft);
  font-size: 11px;
}

.vip-status-btn {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vip-status-btn.is-vip {
  border-color: #967325;
  background: #fff3b8;
  color: #5b4313;
}
.receipt-canvas-wrap.receipt-locked #receiptImage {
  filter: blur(1.7px) saturate(.84) drop-shadow(0 12px 18px rgba(73,60,88,.12));
  transform: scale(1.004);
}
.receipt-canvas-wrap.receipt-locked { user-select: none; }
.receipt-canvas-wrap.receipt-locked .receipt-inline-input {
  display: none;
}
.receipt-canvas-wrap.receipt-locked::after {
  content: "VIP 解锁高清导出";
  position: absolute;
  z-index: 5;
  right: 10px;
  bottom: 10px;
  width: max-content;
  max-width: 70%;
  padding: 5px 9px;
  border: 1.5px solid rgba(73,60,88,.72);
  border-radius: 999px;
  background: rgba(255,253,248,.88);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(73,60,88,.12);
  font-size: 8px;
  font-weight: 900;
  text-align: center;
  pointer-events: none;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  filter: grayscale(.45);
  opacity: .5;
  transform: none;
}

.vip-modal[hidden] { display: none; }
.vip-modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(42,30,52,.48);
  backdrop-filter: blur(8px);
}
body.vip-modal-open { overflow: hidden; }
.vip-dialog {
  position: relative;
  width: min(100%, 460px);
  padding: 30px;
  border: 4px solid var(--ink);
  border-radius: 26px;
  background:
    radial-gradient(circle at 90% 0, rgba(255,216,116,.35), transparent 32%),
    linear-gradient(145deg, #fffdf8, #fff3f8);
  box-shadow: 0 14px 0 rgba(38,26,47,.18);
}
.vip-dialog h2 { margin: 7px 0 10px; font-size: 28px; }
.vip-lead {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.vip-modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 23px;
  line-height: 1;
}
.vip-login-form label { display: block; }
.vip-login-form label span {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 900;
}
.vip-login-form input {
  width: 100%;
  min-height: 50px;
  padding: 0 15px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .06em;
  outline: 0;
}
.vip-login-form input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(188,162,246,.16); }
.vip-login-form .btn { width: 100%; margin-top: 12px; }
.vip-message {
  min-height: 34px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}
.vip-message.error { color: #b23c62; font-weight: 900; }
.vip-account-card {
  padding: 18px;
  border: 3px solid #d7c17a;
  border-radius: 18px;
  background: #fff8d9;
}
.vip-account-label {
  display: block;
  margin-bottom: 7px;
  color: #8b6d25;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}
.vip-account-card strong {
  display: block;
  font-size: 19px;
  letter-spacing: .06em;
}
.vip-account-card p { margin: 8px 0 16px; color: #79642f; font-size: 12px; }
.vip-logout-btn {
  width: 100%;
  min-height: 38px;
  border: 2px solid #b99e51;
  border-radius: 11px;
  background: #fff;
  color: #765b18;
  font-size: 11px;
  font-weight: 900;
}

@media (max-width: 1120px) {
  .app-shell { padding: 16px 14px 32px; }
  .topbar { align-items: flex-start; padding: 20px; }
  .brand-mark { width: 72px; height: 72px; }
  h1 { font-size: 27px; }
  .topbar { background: linear-gradient(120deg, rgba(255,253,248,.96), rgba(255,234,243,.92)); }
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .receipt-stage { max-height: none; }
}

@media (max-width: 640px) {
  .spec-bar { align-items: stretch; flex-direction: column; }
  .spec-options { width: 100%; }
  .spec-options button { flex: 1; min-width: 0; }
  .topbar { display: block; }
  .top-actions { margin-top: 18px; }
  .top-actions .btn { flex: 1; }
  .top-actions { display: flex; }
  .top-actions { flex-wrap: wrap; }
  .vip-status-btn { max-width: none; }
  .form-panel, .preview-panel { padding: 18px; border-radius: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.full { grid-column: auto; }
  .form-actions { flex-direction: column; }
  .multi-panel { align-items: stretch; flex-direction: column; }
  .multi-buttons { width: 100%; }
  .extra-btn { flex: 1; }
  .discount-controls { flex-direction: column; }
  .discount-switch, .discount-value { width: 100%; }
  .template-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .receipt-stage { padding: 10px; min-height: 360px; }
  .receipt-layout { grid-template-columns: 1fr; }
  .background-panel { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 0 14px; }
  .background-panel-head { grid-column: 1 / -1; }
  .background-panel > .background-preview { grid-row: span 4; }
  .background-panel > .background-upload-btn { align-self: end; }
  .background-panel > .background-slider, .background-panel > .background-remove { grid-column: 2; }
  .vip-dialog { padding: 24px 20px; }
}
