:root {
  color-scheme: light;
  --red: #8e2f2f;
  --deep: #4e4038;
  --gold: #cfae75;
  --paper: #fffaf2;
  --line: #e0cfb4;
}

* {
  box-sizing: border-box;
}

html {
  background: #eee5d9;
}

body {
  margin: 0;
  color: var(--deep);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #eee5d9;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 40px rgba(80, 47, 31, 0.12);
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 68px;
  padding: 10px 20px;
  color: #fff8e9;
  background: #7f0d12;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 239, 196, 0.55);
  border-radius: 50%;
  color: #f3cf8e;
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
}

.brand-copy {
  flex: 1;
}

.brand-copy p,
.brand-copy span {
  margin: 0;
}

.brand-copy p {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand-copy span {
  color: #d7b881;
  font-size: 10px;
  letter-spacing: 0.3em;
}

.hero {
  padding: 44px 28px 34px;
  text-align: center;
  background: linear-gradient(rgba(255, 250, 240, 0.92), rgba(255, 250, 240, 0.98));
}

.eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 14px;
  color: #c79a51;
  font-size: 12px;
  letter-spacing: 0.45em;
}

.eyebrow span {
  width: 28px;
  height: 1px;
  background: #c79a51;
}

.hero h1 {
  margin: 0;
  color: #351916;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(38px, 11vw, 58px);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: 0.04em;
}

.hero h1 em {
  color: #a8171c;
  font-style: normal;
}

.hero-note {
  margin: 20px 0 0;
  color: #80685c;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.preview-section {
  padding: 24px 28px 20px;
  text-align: center;
  background: linear-gradient(180deg, #f5eadc, #fffaf2);
}

#posterCanvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #d8c09b;
  background: #fff url("./assets/backgrounds/modern-bg.png") center / 100% 100% no-repeat;
  box-shadow: 0 14px 28px rgba(73, 43, 27, 0.14);
  transform: none !important;
  rotate: 0deg;
}

.preview-section > p {
  margin: 14px 0 0;
  color: #8b7566;
  font-size: 11px;
}

.form-card {
  padding: 10px 24px 34px;
}

.form-card h2 {
  margin: 28px 0 14px;
  color: #592a29;
  font-family: "Songti SC", "STSong", serif;
  font-size: 19px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.template-card {
  display: flex;
  min-width: 0;
  padding: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(80, 45, 25, 0.08);
  flex-direction: column;
}

.template-card.is-selected {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(142, 47, 47, 0.1);
}

.template-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.template-card img {
  width: 100%;
  aspect-ratio: 9 / 14;
  object-fit: cover;
  border: 1px solid #eadfce;
  background: #f7f1e8;
}

.template-card strong {
  margin-top: 7px;
  color: #642c2c;
  font-size: 13px;
}

.template-card small {
  margin-top: 3px;
  color: #8d786b;
  font-size: 10px;
  line-height: 1.45;
}

.upload-box {
  position: relative;
  display: grid;
  min-height: 118px;
  place-items: center;
  padding: 22px;
  cursor: pointer;
  border: 1px dashed #c99f77;
  border-radius: 12px;
  background: #fffdf9;
  text-align: center;
  overflow: hidden;
}

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

.upload-box strong {
  color: var(--red);
}

.upload-preview {
  display: none;
  width: 132px;
  height: 92px;
  object-fit: cover;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: 0 0 0 1px #d9b890;
}

.upload-box.has-photo {
  gap: 8px;
  padding: 14px 22px;
}

.upload-box.has-photo .upload-preview {
  display: block;
}

.upload-box small {
  color: #8d786b;
  font-size: 11px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-grid label {
  display: flex;
  gap: 7px;
  flex-direction: column;
}

.field-grid span {
  color: #6b5147;
  font-size: 12px;
}

.field-grid input,
.field-grid select,
.field-grid textarea {
  width: 100%;
  padding: 0 13px;
  border: 1px solid #dbc9b3;
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
}

.field-grid input,
.field-grid select {
  min-height: 48px;
}

.field-grid textarea {
  min-height: 136px;
  padding: 12px 13px;
  line-height: 1.65;
  resize: vertical;
}

.date-field,
.copy-select-field,
.copy-field {
  grid-column: 1 / -1;
}

.field-grid textarea[readonly] {
  color: #6f5a4f;
  background: #fffaf4;
}

.primary-button,
.download-button,
.secondary-button {
  display: block;
  width: 100%;
  min-height: 50px;
  cursor: pointer;
  border: 0;
  border-radius: 9px;
  text-align: center;
  text-decoration: none;
}

.primary-button,
.download-button {
  margin-top: 22px;
  color: #fff;
  background: var(--red);
  line-height: 50px;
}

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

.status-text {
  min-height: 18px;
  margin: 10px 0 0;
  color: #a33b3a;
  text-align: center;
  font-size: 12px;
}

footer {
  padding: 28px 20px 30px;
  color: #e8c9b7;
  border-top: 0;
  background: #7f0d12;
  text-align: center;
  font-size: 12px;
}

footer p {
  margin: 12px 0 14px;
  letter-spacing: 0.08em;
}

footer strong {
  display: block;
  color: #e8c27b;
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.28em;
}

.disclaimer-link {
  padding: 3px 6px;
  cursor: pointer;
  color: #f0d9c9;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  font-size: 11px;
}

.result-modal {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.disclaimer-modal {
  position: fixed;
  z-index: 11;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.disclaimer-modal.is-open {
  display: flex;
}

.result-modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 20, 16, 0.72);
}

.result-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: 92vh;
  padding: 22px 24px calc(26px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  background: #fffaf2;
  text-align: center;
}

.disclaimer-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 500px);
  max-height: 80vh;
  padding: 28px 26px 20px;
  overflow-y: auto;
  border-radius: 14px;
  background: #fffaf2;
  box-shadow: 0 18px 48px rgba(42, 23, 16, 0.24);
}

.disclaimer-panel h2 {
  margin: 0 0 18px;
  color: var(--red);
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
  text-align: center;
}

.disclaimer-panel p {
  margin: 0 0 14px;
  color: #5f4a40;
  font-size: 13px;
  line-height: 1.8;
  text-align: left;
}

.result-panel h2 {
  margin: 0 0 16px;
  color: var(--red);
  font-family: "Songti SC", "STSong", serif;
}

.result-panel img {
  display: block;
  width: min(100%, 390px);
  height: auto;
  margin: 0 auto;
  box-shadow: 0 10px 24px rgba(69, 40, 25, 0.16);
}

.result-panel p {
  color: #7c6658;
  font-size: 12px;
}

.share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.share-button, .result-page-button { border: 1px solid #8d251e; border-radius: 4px; padding: 11px; background: #fff; color: #8d251e; font: inherit; text-align: center; text-decoration: none; }
.share-hint { font-size: 13px; color: #7b6259; }

.secondary-button {
  margin-top: 10px;
  color: #6d4f45;
  border: 1px solid #d8c3a8;
  background: #fff;
}

.close-button {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  color: #795d51;
  border: 0;
  background: transparent;
  font-size: 26px;
}

.usage-notice-modal {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.usage-notice-modal.is-open {
  display: flex;
}

.usage-notice-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 20, 16, 0.74);
}

.usage-notice-panel {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 520px);
  max-height: min(86vh, 760px);
  border-radius: 16px;
  background: #fffaf2;
  box-shadow: 0 20px 60px rgba(24, 12, 8, 0.32);
  flex-direction: column;
  overflow: hidden;
}

.usage-notice-panel h2 {
  margin: 0;
  padding: 22px 22px 14px;
  color: var(--red);
  font-family: "Songti SC", "STSong", serif;
  font-size: 24px;
  text-align: center;
}

.usage-notice-content {
  min-height: 0;
  padding: 0 22px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.usage-notice-content p {
  margin: 0 0 14px;
  color: #5f4a40;
  font-size: 14px;
  line-height: 1.82;
  text-align: left;
}

.usage-notice-actions {
  padding: 14px 20px 20px;
  border-top: 1px solid #eadac4;
  background: #fffaf2;
}

.usage-notice-check {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-bottom: 12px;
  color: #5f4a40;
  font-size: 13px;
  line-height: 1.45;
}

.usage-notice-check input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--red);
  flex: 0 0 auto;
}

.usage-notice-actions .primary-button,
.usage-notice-actions .secondary-button {
  margin-top: 10px;
}

.usage-notice-actions .primary-button:disabled {
  cursor: not-allowed;
  background: #c8b9a9;
  opacity: 1;
}

.usage-notice-actions .secondary-button {
  line-height: 50px;
}

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

  .template-card {
    display: grid;
    grid-template-columns: 76px 1fr;
    column-gap: 10px;
  }

  .template-card img {
    grid-row: 1 / 3;
  }

  .template-card strong,
  .template-card small {
    align-self: end;
  }
}

@media (min-width: 700px) {
  body {
    padding: 26px 0;
  }

  .page-shell {
    border-radius: 8px;
  }
}
