:root {
  color-scheme: light;
  --paper: #f4efe6;
  --paper-deep: #e8dfd2;
  --ink: #101817;
  --navy: #092332;
  --muted: #646964;
  --leaf: #16845b;
  --leaf-deep: #0f6244;
  --gold: #f4cb70;
  --line: rgba(16, 24, 23, 0.16);
  --danger: #9b2f25;
  --serif: "Songti SC", "STSong", "SimSun", "Times New Roman", Times, serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 0, rgba(255,255,255,.88), transparent 28rem),
    linear-gradient(160deg, var(--paper), #f8f5ee 55%, var(--paper-deep));
  font-family: var(--sans);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
html[lang="zh-CN"] .brand-name,
html[lang="zh-CN"] h1,
html[lang="zh-CN"] h2 { font-family: var(--serif); }
button, input, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 40;
  padding: 10px 14px;
  color: #fff;
  background: #111;
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 64px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 239, 230, 0.92);
  backdrop-filter: blur(16px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand img { width: 40px; height: 40px; border-radius: 12px; }
.brand strong { display: block; font-size: 17px; line-height: 1.1; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.lang-toggle {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.6);
}
.lang-toggle button {
  min-width: 44px;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.lang-toggle button.is-active {
  color: #fff;
  background: var(--ink);
}

.wrap {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 120px;
}
.kicker {
  margin: 0 0 10px;
  color: var(--leaf-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
}
h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(32px, 9vw, 48px);
  line-height: 1.15;
  letter-spacing: -.03em;
}
.lede {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.card {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,253,248,.94);
  box-shadow: 0 18px 48px rgba(38, 31, 20, .08);
}
.fields { display: grid; gap: 14px; }
label.field { display: grid; gap: 7px; font-size: 14px; font-weight: 700; }
label.field input, label.field select {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid rgba(16,24,23,.18);
  border-radius: 14px;
  background: #fff;
  font-weight: 500;
}
.hint { color: var(--muted); font-size: 12px; font-weight: 500; }

.upload-start {
  margin: 18px 0 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(22, 132, 91, .1);
  color: var(--leaf-deep);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.4;
}
.upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.upload-start + .upload-row { margin-top: 8px; }
.upload-btn {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border: 1.5px dashed rgba(15,98,68,.4);
  border-radius: 16px;
  background: rgba(22,132,91,.06);
  color: var(--leaf-deep);
  font-weight: 800;
  text-align: center;
}
.upload-btn input { display: none; }

.notice, .adult-note {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f0e2c8;
  color: #3d3426;
  font-size: 13px;
  line-height: 1.5;
}
.choice-row {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.choice-row legend { font-weight: 800; padding: 0; }
.choice-row .check {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 16px;
  font-weight: 800;
}
.choice-row .check input { width: 22px; height: 22px; margin: 0; flex: none; }
.choice-row .hint { font-weight: 500; }
.yu-progress {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 18px 14px 16px;
  border: 1px solid rgba(180, 148, 90, 0.28);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 36%, rgba(244, 203, 112, 0.2), transparent 16rem),
    #fffdf8;
  text-align: center;
}
.yu-progress-dial {
  position: relative;
  width: min(232px, 74vw);
  aspect-ratio: 1;
}
.yu-progress-dial::before {
  position: absolute;
  z-index: 0;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #fffdf8 0%, #f3e6cf 78%);
  box-shadow: inset 0 0 0 1px rgba(180, 148, 90, 0.2);
  content: "";
}
.yu-progress-glow {
  position: absolute;
  z-index: 1;
  inset: 12%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(244, 203, 112, 0) 0deg, rgba(244, 203, 112, 0.2) 36deg, rgba(255, 248, 220, 0.96) 78deg, rgba(244, 203, 112, 0.28) 118deg, rgba(244, 203, 112, 0) 168deg);
  animation: yu-progress-glow 4.8s linear infinite;
  pointer-events: none;
}
.yu-progress-svg {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}
.yu-progress-track,
.yu-progress-value,
.yu-progress-sheen { fill: none; stroke-width: 8; }
.yu-progress-track { stroke: #e4d2ae; }
.yu-progress-value { stroke: var(--leaf-deep); }
.yu-progress-sheen {
  stroke: #f4cb70;
  stroke-linecap: round;
  stroke-dasharray: 22px 304.7256359733385px;
  filter: drop-shadow(0 0 2px rgba(255, 248, 220, 0.95));
  animation: yu-progress-sheen 3.6s linear infinite;
}
/* --extract-progress on [data-extract-progress] is 0–100 for a circular progress treatment. */
.yu-progress img {
  position: absolute;
  z-index: 3;
  top: 44%;
  left: 50%;
  width: 58%;
  height: 58%;
  object-fit: contain;
  transform: translate(-50%, -56%);
  filter: drop-shadow(0 8px 10px rgba(15, 98, 68, 0.16));
  pointer-events: none;
}
.yu-progress strong {
  position: absolute;
  z-index: 4;
  bottom: 13%;
  left: 50%;
  min-width: 4.6ch;
  padding: 4px 10px 5px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 6px 16px rgba(61, 52, 38, 0.1);
  color: var(--leaf-deep);
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  transform: translateX(-50%);
}
.yu-progress p {
  max-width: 28rem;
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}
@keyframes yu-progress-glow {
  to { transform: rotate(360deg); }
}
@keyframes yu-progress-sheen {
  to { stroke-dashoffset: -326.7256359733385px; }
}
@media (prefers-reduced-motion: reduce) {
  .yu-progress-sheen { animation: none; opacity: 0; }
  .yu-progress-glow {
    animation: none;
    transform: none;
    background: radial-gradient(circle, rgba(244, 203, 112, 0.42), transparent 68%);
  }
}
.status {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--leaf-deep);
  font-size: 14px;
}
.status.is-error { color: var(--danger); }
.official-path, .follow-up {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.official-path h3, .follow-up h3 { margin: 0 0 8px; font-size: 18px; }
.official-path p, .follow-up p, .follow-up li { font-size: 14px; line-height: 1.5; }
.pay-steps { margin: 10px 0 0; padding-left: 1.2em; }
.pay-steps li { margin: 4px 0; font-size: 14px; }
.follow-up ul { margin: 8px 0 0; padding-left: 1.2em; }
.follow-up .actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  text-decoration: none;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.thumb {
  position: relative;
  overflow: visible;
  border-radius: 14px;
  background: transparent;
}
.thumb-frame { position: relative; }
.thumb img, .thumb-frame img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  display: block;
  border-radius: 14px;
  background: #f6f0e4;
}
.thumb-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.thumb-tools button {
  min-height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: #e7e0d4;
  font-size: 12px;
  font-weight: 800;
}
.thumb-tools button.is-on { background: var(--leaf-deep); color: #fff; }
.thumb-text {
  width: 100%;
  min-height: 72px;
  margin-top: 6px;
  padding: 8px;
  border: 1px solid rgba(28, 36, 32, 0.16);
  border-radius: 10px;
  background: #fffdf8;
  color: #1c2420;
  font: 500 13px/1.4 inherit;
  resize: vertical;
}
.thumb-note { margin: 4px 0 0; color: #6d5b3c; font-size: 12px; line-height: 1.35; }
.avatar-panel, .consent-box { display: grid; gap: 8px; margin-top: 12px; }
.signature-pad {
  width: 100%;
  max-width: 420px;
  height: 140px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: none;
}
.thumb-actions {
  position: absolute;
  inset: auto 4px 4px 4px;
  display: flex;
  gap: 4px;
}
.thumb-actions button,
.thumb-remove {
  min-width: 36px;
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(16,24,23,.78);
  color: #fff;
  font-weight: 800;
}
.thumb-remove { position: absolute; top: 4px; right: 4px; }

.preview-stage { margin-top: 8px; }
.book-edit {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.book-edit h3 { margin: 0 0 6px; font-size: 18px; }
.book-edit .fields { margin-top: 12px; }
.book-assistant {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.book-assistant h3 { margin: 0 0 6px; font-size: 18px; }
.book-assistant .suggest-actions { margin-top: 12px; }
.assist-sample {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f0e4;
  white-space: pre-wrap;
}
.assist-preview {
  width: min(100%, 280px);
  margin-top: 8px;
  border-radius: 12px;
  background: #f6f0e4;
}
.piece-edit { display: grid; gap: 8px; }
.piece-edit .secondary { width: 100%; }
.book-frame {
  position: relative;
  width: min(100%, 420px);
  margin: 0 auto;
  aspect-ratio: 154 / 216;
  overflow: hidden;
  border-radius: 8px 18px 18px 8px;
  background: #fff;
  box-shadow:
    8px 14px 36px rgba(38, 31, 20, .18),
    inset -18px 0 0 rgba(16,24,23,.04);
}
.book-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #f6f0e4;
}
.book-frame.is-editing > [data-page-image] { visibility: hidden; }
.page-editor {
  position: absolute;
  inset: 0;
  background: #f6f0e4;
}
.page-editor[hidden] { display: none; }
.page-art {
  position: absolute;
  touch-action: none;
  cursor: grab;
  border: 1.5px dashed rgba(16, 24, 23, .38);
  box-sizing: border-box;
}
.page-art img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  display: block;
  background: transparent;
}
.page-art-handle {
  position: absolute;
  right: -10px;
  bottom: -10px;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #1c2420;
  background: #fff;
  cursor: nwse-resize;
}
.page-text {
  position: absolute;
  overflow: auto;
  box-sizing: border-box;
  padding: 2px 4px;
  color: #1c2420;
  background: #f6f0e4;
  outline: none;
  white-space: pre-wrap;
}
.page-text:focus { box-shadow: inset 0 0 0 1.5px rgba(15, 98, 68, .5); }
.page-watermark {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: auto;
  height: auto;
  pointer-events: none;
  background-image: url("assets/storieslens-logo.png");
  background-repeat: repeat;
  background-size: 16% auto;
  opacity: .32;
}
.page-editor-note { text-align: center; }
.proof-banner {
  width: min(100%, 420px);
  margin: 12px auto 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f3faf6;
}
.proof-banner.is-alert {
  border-color: #9a3412;
  background: #fff7ed;
  box-shadow: 0 0 0 3px rgba(154, 52, 18, 0.16);
}
.proof-banner p { margin: 0; }
.proof-banner .suggest-actions { margin-top: 10px; }
.proof-banner .assist-sample { margin-top: 8px; }
.proof-banner.is-alert [data-proof-banner-text] { font-weight: 800; }
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}
.pager button,
.primary,
.secondary {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  font-weight: 800;
}
.pager button,
.secondary {
  border: 1px solid var(--line);
  background: #fff;
}
.pager .page-label { color: var(--muted); font-size: 14px; font-weight: 700; }
.actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.primary {
  border: 0;
  color: #fff;
  background: var(--leaf-deep);
  box-shadow: 0 12px 28px rgba(15,98,68,.22);
}
.primary:disabled, .secondary:disabled, .pager button:disabled { opacity: .5; cursor: not-allowed; }
.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.film-box, .file-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: 18px;
  background: #111817;
  color: #f6f1e6;
}
.film-box video, .file-box iframe, .file-box embed {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: #000;
}
.film-box video { max-height: 70vh; }
[data-ai-movie-first] video, [data-ai-movie-result] video {
  display: block;
  width: min(100%, 280px);
  max-height: 60vh;
  margin-top: 14px;
  border-radius: 12px;
  background: #111817;
}
.file-box iframe { height: 62vh; background: #fff; }
.wechat-help, .share-note {
  margin: 10px 0 0;
  color: #d8d2c6;
  font-size: 13px;
  line-height: 1.5;
}
.print-shop-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.trust {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.print-root { display: none; }

@media print {
  @page { size: 154mm 216mm; margin: 0; }
  body { background: #fff; padding: 0; }
  .topbar, .skip-link, .wrap, .status { display: none !important; }
  .print-root {
    display: block;
    width: 100%;
  }
  .print-root img {
    display: block;
    width: 154mm;
    height: 216mm;
    object-fit: contain;
    background: #f6f0e4;
    page-break-after: always;
    break-after: page;
  }
}

@media (max-width: 520px) {
  .wrap { width: min(100% - 24px, 720px); padding-top: 20px; }
  .upload-row, .actions-row { grid-template-columns: 1fr; }
  .thumbs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; }
  .pager button, .primary, .secondary, .upload-btn { min-height: 54px; }
}
