:root {
  --ink: #28231f;
  --muted: #7b716a;
  --paper: #fff9f1;
  --surface: #fffdf8;
  --line: #e9ded1;
  --accent: #b55d4d;
  --accent-dark: #873f35;
  --mint: #dbe8df;
  --blue: #b7cadb;
  --shadow: 0 18px 50px rgba(72, 49, 34, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  background: #efe9df;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(223, 193, 177, 0.75), transparent 28rem),
    radial-gradient(circle at 92% 22%, rgba(183, 202, 219, 0.8), transparent 26rem),
    linear-gradient(150deg, #fffaf3 0%, #eee7dc 52%, #d9e2dc 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 24px 16px 118px;
}

.app-view {
  display: none;
}

.app-view.is-active {
  display: block;
}

.top-login-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f7d8c8 0%, #f3c4a8 100%);
  color: #6b3120;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(181, 93, 77, 0.16);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.top-login-banner:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(181, 93, 77, 0.22);
}

.top-login-banner.is-hidden {
  display: none;
}

.top-login-banner.is-flash {
  animation: bannerFlash 0.6s ease;
}

@keyframes bannerFlash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); box-shadow: 0 6px 18px rgba(181, 93, 77, 0.35); }
}

.banner-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.banner-text strong {
  font-size: 15px;
  font-weight: 600;
}

.banner-text small {
  font-size: 12px;
  opacity: 0.78;
}

.banner-cta {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
}

.email-bound-inline {
  margin-top: 10px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--muted);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.7);
  border: 1px solid rgba(181, 93, 77, 0.12);
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
}

.email-bound-inline strong {
  color: var(--ink);
  word-break: break-all;
}

.email-bound-inline.is-hidden {
  display: none;
}

.email-dialog {
  width: min(420px, 92vw);
  border: none;
  border-radius: 12px;
  padding: 24px;
  background: var(--paper, #fffaf3);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(135, 63, 53, 0.25);
}

.email-dialog::backdrop {
  background: rgba(38, 24, 18, 0.45);
}

.email-dialog h2 {
  margin: 0 0 6px 0;
  font-size: 20px;
}

.email-dialog-tip {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.top-panel {
  display: grid;
  gap: 18px;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 660px;
  font-family: Georgia, "Times New Roman", "Microsoft YaHei", serif;
  font-size: clamp(34px, 7vw, 72px);
  line-height: 0.98;
}

h2 {
  font-size: 20px;
}

.upload-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.upload-zone,
.preview-wrap {
  min-height: 216px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  box-shadow: var(--shadow);
}

.upload-zone {
  display: grid;
  place-items: center;
  align-content: center;
  padding: 18px;
  text-align: center;
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 34px;
  line-height: 1;
}

.upload-title {
  display: block;
  font-size: 18px;
  font-weight: 800;
}

.upload-note {
  display: block;
  max-width: 13rem;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.preview-wrap {
  position: relative;
  overflow: hidden;
}

.preview-wrap img {
  width: 100%;
  height: 100%;
  min-height: 216px;
  object-fit: cover;
}

.preview-wrap.is-empty {
  display: none;
}

.ghost-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  color: #fff;
  background: rgba(0, 0, 0, 0.58);
}

.controls-band,
.compose-band,
.result-band,
.account-grid {
  margin-top: 26px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-heading span,
.section-heading button {
  color: var(--muted);
  font-size: 13px;
}

.section-heading button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 253, 248, 0.8);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.template-card {
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(74, 55, 43, 0.12);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  box-shadow: 0 10px 30px rgba(75, 54, 38, 0.08);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.template-card.active {
  border-color: var(--accent);
  box-shadow: 0 15px 38px rgba(135, 63, 53, 0.22);
  transform: translateY(-2px);
}

.template-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.template-copy {
  display: grid;
  gap: 6px;
  padding: 11px;
}

.template-copy strong {
  font-size: 15px;
}

.template-copy small {
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.compose-band {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.74);
}

.field-label,
.size-header span {
  font-weight: 800;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fffaf3;
  outline: none;
}

textarea:focus,
.custom-size input:focus {
  border-color: var(--accent);
}

.size-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.size-header small,
.custom-size p {
  color: var(--muted);
  font-size: 12px;
}

.ratio-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.ratio-row button {
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 8px;
  color: var(--ink);
  background: #fffdf8;
}

.ratio-row button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.custom-size {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px dashed rgba(135, 63, 53, 0.3);
  border-radius: 8px;
  background: rgba(255, 249, 241, 0.72);
}

.custom-size.is-hidden {
  display: none;
}

.custom-size label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.custom-size input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: #fffdf8;
}

.custom-size p {
  grid-column: 1 / -1;
  margin: 0;
}

.consent-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.consent-line input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--accent-dark);
}

.account-hero {
  display: grid;
  gap: 16px;
}

.account-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid rgba(181, 93, 77, 0.18);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow);
}

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

.account-card strong {
  font-size: 32px;
}

.account-card .primary-button {
  grid-row: 1 / 3;
  grid-column: 2;
}

.email-card {
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid rgba(181, 93, 77, 0.18);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.email-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.email-card-header span {
  font-size: 14px;
  font-weight: 600;
}

.email-card-header small {
  color: var(--muted);
  font-size: 12px;
}

.email-bound {
  display: grid;
  gap: 4px;
}

.email-bound strong {
  font-size: 15px;
  word-break: break-all;
}

.email-bound small {
  color: var(--muted);
  font-size: 12px;
}

.email-form {
  display: grid;
  gap: 8px;
}

.email-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.email-row input {
  height: 40px;
  min-width: 0;
  width: 100%;
  padding: 0 12px;
  border: 1px solid rgba(181, 93, 77, 0.28);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

.email-row input:focus {
  outline: none;
  border-color: var(--accent, #b55d4d);
}

.email-row button {
  height: 40px;
  padding: 0 14px;
  font-size: 13px;
  white-space: nowrap;
  box-sizing: border-box;
}

.email-row button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.email-dev-hint {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  font-size: 18px;
}

.action-dock {
  position: fixed;
  z-index: 5;
  right: max(16px, calc((100vw - 1120px) / 2 + 16px));
  bottom: 16px;
  left: max(16px, calc((100vw - 1120px) / 2 + 16px));
  display: grid;
  grid-template-columns: 64px 1fr auto 64px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(40, 35, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 20px 50px rgba(42, 32, 25, 0.22);
  backdrop-filter: blur(18px);
}

.tab-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab-button.is-active {
  color: var(--accent-dark);
  background: rgba(181, 93, 77, 0.1);
}

.current-choice {
  min-width: 0;
}

.selected-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.current-choice strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fffaf3;
  background: linear-gradient(135deg, var(--ink), var(--accent-dark));
  font-weight: 800;
  box-shadow: 0 14px 24px rgba(74, 35, 30, 0.24);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.wide {
  width: 100%;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.result-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.result-image-button {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
}

.result-card img,
.result-placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--mint);
}

.result-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.result-placeholder.is-working {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(255,255,255,0.1), rgba(255,255,255,0.55), rgba(255,255,255,0.1)),
    var(--mint);
  background-size: 220% 100%;
  animation: loadingSweep 1.6s ease-in-out infinite;
}

.result-placeholder span {
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.82);
  font-weight: 800;
}

.result-card div {
  display: grid;
  gap: 5px;
  padding: 10px;
}

.result-card span,
.empty-state,
.job-help {
  color: var(--muted);
  font-size: 13px;
}

.job-help {
  line-height: 1.35;
}

.result-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.result-card-actions button,
.result-card-actions a,
.primary-link,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.result-card-actions button,
.ghost-link {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fffdf8;
}

.result-card-actions a,
.primary-link {
  border: 0;
  color: #fffaf3;
  background: var(--ink);
}

.pay-dialog {
  width: min(92vw, 430px);
  border: 0;
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pay-dialog::backdrop {
  background: rgba(31, 27, 24, 0.45);
}

.close-button {
  float: right;
  border: 0;
  background: transparent;
  font-size: 30px;
}

.pay-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.pay-fields label {
  display: grid;
  gap: 7px;
  font-size: 13px;
}

.pay-fields input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.pay-link {
  display: none;
  margin-top: 14px;
  color: var(--accent-dark);
  font-weight: 800;
}

.pay-link.show {
  display: inline-block;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 8px;
}

.product-card {
  position: relative;
  display: grid;
  gap: 7px;
  min-height: 156px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #fffdf8;
  text-align: left;
}

.product-card.featured {
  border-color: var(--accent-dark);
  box-shadow: 0 16px 32px rgba(135, 63, 53, 0.16);
}

.product-card.active {
  border-color: var(--ink);
  border-width: 2px;
  background: #fff5e8;
}

.pay-flow {
  display: grid;
  gap: 18px;
}

.pay-flow.is-hidden,
.pay-need-email.is-hidden {
  display: none;
}

.pay-need-email {
  padding: 16px;
  border: 1px solid rgba(181, 93, 77, 0.28);
  border-radius: 8px;
  background: rgba(255, 244, 232, 0.85);
  text-align: center;
  display: grid;
  gap: 12px;
}

.pay-need-email p {
  font-size: 14px;
  color: #6b3120;
  margin: 0;
}

.pay-step {
  display: grid;
  gap: 8px;
}

.pay-step-head {
  font-size: 14px;
  font-weight: 600;
}

.pay-step-head strong {
  display: inline-block;
  margin-right: 6px;
  color: var(--accent-dark);
}

.pay-amount-tag {
  font-weight: 600;
  color: var(--accent-dark);
  margin-left: 4px;
}

.qr-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.qr-tab {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf3;
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
}

.qr-tab.active {
  background: var(--ink);
  color: #fffaf3;
  border-color: var(--ink);
}

.payment-qr {
  width: 220px;
  height: 220px;
  display: block;
  margin: 4px auto;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  object-fit: contain;
}

.pay-tip {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.pay-tip-small {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
}

.product-card strong {
  font-size: 30px;
  line-height: 1;
}

.product-card span {
  color: var(--ink);
  font-weight: 800;
}

.product-card small {
  color: var(--muted);
  line-height: 1.35;
}

.payment-methods {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.payment-methods button {
  border: 1px solid rgba(51, 44, 38, 0.14);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fffaf3;
  font-weight: 800;
}

.payment-methods button.active {
  color: #fffaf3;
  background: var(--ink);
}

.product-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #fffaf3 !important;
  background: var(--accent-dark);
  font-size: 11px;
}

.product-name {
  padding-right: 42px;
}

.image-dialog {
  width: min(96vw, 920px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.image-dialog::backdrop {
  background: rgba(31, 27, 24, 0.62);
}

.image-dialog-inner {
  margin: 0;
  padding: 14px;
}

.image-dialog .close-button {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, 0.48);
}

.image-dialog img {
  display: block;
  width: 100%;
  max-height: 72vh;
  border-radius: 8px;
  object-fit: contain;
  background: #1f1d1a;
}

.image-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding-top: 12px;
}

.image-toolbar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.image-toolbar strong {
  display: block;
  margin-top: 3px;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 16px;
  bottom: 96px;
  max-width: min(90vw, 360px);
  transform: translateY(18px);
  opacity: 0;
  border-radius: 8px;
  padding: 12px 14px;
  color: #fffaf3;
  background: rgba(40, 35, 31, 0.92);
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@keyframes loadingSweep {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

.mock-pay-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 16px;
}

.mock-pay-card {
  width: min(100%, 430px);
  border-radius: 8px;
  padding: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mock-pay-card h1 {
  font-size: 36px;
}

.mock-pay-card dl {
  padding: 14px;
  border-radius: 8px;
  background: #f4eee5;
}

.mock-pay-card dt {
  color: var(--muted);
  font-size: 13px;
}

.mock-pay-card dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.mock-result {
  color: var(--accent-dark);
  font-weight: 800;
}

@media (max-width: 820px) {
  .app-shell {
    padding-top: 18px;
  }

  h1 {
    font-size: 43px;
  }

  .upload-card {
    grid-template-columns: 1fr;
  }

  .template-grid,
  .account-grid,
  .result-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .brand-row {
    display: grid;
  }

  h1 {
    font-size: 38px;
  }

  .template-grid {
    gap: 10px;
  }

  .template-copy small {
    min-height: 50px;
  }

  .ratio-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .action-dock {
    grid-template-columns: 54px 1fr 118px 54px;
    gap: 6px;
  }

  .tab-button,
  .primary-button {
    min-height: 46px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .account-card,
  .pay-fields,
  .product-grid,
  .account-grid,
  .result-grid,
  .image-toolbar {
    grid-template-columns: 1fr;
  }

  .account-card .primary-button {
    grid-row: auto;
    grid-column: auto;
  }
}
