/* ==========================================================================
   宝贝专属绘本 · 设计系统 v2 —— 暖米白纸感 × 赤陶色 × 衬线标题
   ========================================================================== */

:root {
  /* 颜色 */
  --bg:        #F7F2EA;   /* 暖米白纸感底 */
  --bg-deep:   #EFE7D8;
  --surface:   #FFFFFF;
  --surface-warm: #FCF8F1;
  --ink:       #2A211B;   /* 深暖棕正文 */
  --ink-soft:  #7A6A58;   /* 灰棕次级 */
  --ink-faint: #9C8B74;   /* 弱化文字 */
  --brand:     #C2542F;   /* 赤陶橙红（主强调） */
  --brand-deep:#A6421F;
  --brand-soft:#F1DECF;   /* 品牌浅底 */
  --sage:      #4E6B5C;   /* 鼠尾草绿 */
  --gold:      #B08A57;   /* 金棕点缀 */
  --line:      #E8DECD;   /* 描边 */

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(66,48,30,.05), 0 4px 14px rgba(66,48,30,.06);
  --shadow-md: 0 10px 30px rgba(66,48,30,.10);
  --shadow-lg: 0 18px 48px rgba(66,48,30,.14);

  /* 圆角 */
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;

  /* 字体 */
  --font-display: "Playfair Display", "Georgia", "Songti SC", "STSong", "Noto Serif SC", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ============ Reset & Base ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: #EDE6DA;
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }

/* ============ App 容器 ============ */
#app {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(60,45,25,.08);
}
@media (min-width: 481px) {
  #app { border-radius: 32px; min-height: calc(100vh - 48px); margin-top: 24px; margin-bottom: 24px; }
}

/* ============ Page 通用 ============ */
.page {
  display: none;
  min-height: 100vh;
  padding: 22px 24px 34px;
  flex-direction: column;
}
.page.active { display: flex; animation: pageIn .35s ease both; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 26px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .5px;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 22px rgba(194,84,47,.26);
}
.btn-primary:hover { background: var(--brand-deep); }
.btn-ghost { background: var(--surface); color: var(--ink-soft); box-shadow: var(--shadow-sm); }
.btn-secondary {
  background: var(--surface-warm); color: var(--brand-deep);
  border: 1.5px solid var(--brand-soft); box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--brand); }
.btn-large { padding: 18px 32px; font-size: 16px; width: 100%; border-radius: var(--r-lg); }
.btn-small { padding: 11px 18px; font-size: 14px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 600; color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.ghost { background: transparent; box-shadow: none; }

/* ============ Topbar / Progress ============ */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.topbar .step { font-size: 13px; color: var(--ink-faint); font-weight: 600; letter-spacing: .5px; }
.progress-bar { height: 4px; background: var(--bg-deep); border-radius: 2px; overflow: hidden; margin-bottom: 26px; }
.progress-fill { height: 100%; background: var(--brand); border-radius: 2px; transition: width .4s ease; }

h2 { font-family: var(--font-display); font-size: 25px; font-weight: 700; color: var(--ink); margin-bottom: 8px; letter-spacing: .5px; }
.hint { font-size: 13px; color: var(--ink-soft); margin-bottom: 22px; }
.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--ink); margin: 20px 0 10px; letter-spacing: .3px; }

/* ============ P1 首页 ============ */
/* ============ P1 首页 · 绘本封面式 ============ */
.page-home { background: var(--bg); }
.home-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 0;
}
.home-brand-name {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 500;
  color: var(--brand-deep);
  letter-spacing: 2px;
}
.home-login {
  background: var(--brand-soft); color: var(--brand-deep);
  border: 1px solid transparent; border-radius: 18px;
  padding: 6px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; letter-spacing: .5px;
  transition: border-color .15s ease, transform .15s ease;
}
.home-login:active { transform: scale(.96); }
.home-login.logged { border-color: var(--brand); }

.home-cover {
  position: relative;
  margin: 12px 0 4px;
  border-radius: 22px;
  overflow: hidden;
  background: #FDF0DC;
  box-shadow: 0 8px 28px rgba(166,66,31,.10), 0 2px 6px rgba(166,66,31,.06);
  aspect-ratio: 3/2;
}
.home-cover img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
/* 右下角品牌落款：覆盖 AI 生图水印 + 品牌签名 */
.home-cover-mark {
  position: absolute; right: 10px; bottom: 10px;
  display: flex; flex-direction: column; align-items: flex-end;
  background: rgba(255,252,248,.94);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 12px; padding: 7px 12px;
  box-shadow: 0 2px 10px rgba(66,48,30,.10);
}
.home-cover-mark .mark-title {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 500; color: var(--brand-deep);
  letter-spacing: 1px;
}
.home-cover-mark .mark-sub {
  font-size: 10px; color: var(--ink-faint);
  letter-spacing: .5px; margin-top: 1px;
}

.home-slogan {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 500; line-height: 1.55;
  color: var(--ink);
  text-align: center; letter-spacing: 1px;
  margin: 16px 0 6px;
}
.home-sub {
  font-size: 12px; color: var(--ink-soft);
  text-align: center; letter-spacing: 1px;
  margin: 0 0 18px;
}

.home-trust {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 0 0 18px;
}
.trust-item {
  font-size: 13px; color: var(--brand-deep);
  font-weight: 500; letter-spacing: 1px;
}
.trust-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: #F1DECF;
}

#btn-start { margin-top: 4px; }

.home-foot {
  margin-top: 16px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.home-library-link {
  font-size: 13px; font-weight: 500; color: var(--brand-deep);
  cursor: pointer; text-decoration: none; letter-spacing: 1px;
}
.home-library-link:active { opacity: .6; }

/* ============ 二屏作品秀 ============ */
.home-showcase { margin-top: 22px; }
.showcase-title {
  font-family: var(--font-display);
  font-size: 13px; color: var(--ink-soft);
  text-align: center; letter-spacing: 2px;
  margin-bottom: 12px;
}
.showcase-scroll {
  display: flex; gap: 12px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding-bottom: 4px;
}
.showcase-scroll::-webkit-scrollbar { display: none; }
.showcase-card {
  flex-shrink: 0; width: 118px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.showcase-card:active { transform: scale(.96); border-color: var(--brand); }
.showcase-cover {
  aspect-ratio: 3/4;
  border-radius: 10px; overflow: hidden;
  background: var(--surface-warm);
}
.showcase-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.showcase-meta {
  display: flex; flex-direction: column;
  padding: 7px 2px 2px;
}
.showcase-style {
  font-size: 10px; color: var(--brand);
  background: var(--brand-soft);
  align-self: flex-start;
  padding: 2px 8px; border-radius: 10px;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.showcase-title {
  font-size: 12px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============ P2 宝贝信息表单 ============ */
.page-form { background: var(--bg); }
.avatar-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-warm); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px;
  margin-bottom: 20px;
}
.avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand-soft); display: flex; align-items: center; justify-content: center;
  font-size: 28px; box-shadow: var(--shadow-sm); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-info { flex: 1; }
.avatar-info .t1 { font-size: 14px; font-weight: 700; color: var(--ink); }
.avatar-info .t2 { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.upload-btn {
  padding: 8px 14px; background: var(--brand); color: #fff;
  border-radius: 12px; font-size: 12px; font-weight: 700; cursor: pointer;
  transition: background .2s ease;
}
.upload-btn:active { background: var(--brand-deep); }

/* 照片隐私说明与监护人同意 */
.privacy-note {
  margin: -6px 0 20px; padding: 10px 12px;
  background: var(--surface-warm); border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  font-size: 12px; line-height: 1.7; color: var(--ink-soft);
}
.privacy-check {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 8px; font-size: 12px; color: var(--ink);
  cursor: pointer; user-select: none;
}
.privacy-check input { margin-top: 2px; accent-color: var(--brand); width: 15px; height: 15px; flex-shrink: 0; }

.form { display: flex; flex-direction: column; gap: 16px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 8px; display: block; letter-spacing: .3px; }
.field input {
  width: 100%; padding: 15px 16px;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 500;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(194,84,47,.1); }

.gender-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gender-btn {
  padding: 14px 0; text-align: center; border: 1.5px solid var(--line);
  border-radius: var(--r-md); background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
  transition: all .2s ease;
}
.gender-btn.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 700; }

.tag-group { display: flex; flex-wrap: wrap; gap: 9px; }
.tag-btn {
  padding: 9px 15px; border-radius: 20px;
  background: var(--surface); border: 1.5px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  transition: all .2s ease;
}
.tag-btn.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 700; }

.page-form .btn-large { margin-top: 28px; }

/* ============ P3 主题选择 ============ */
.theme-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 26px;
}
.theme-card {
  position: relative; overflow: hidden;
  border-radius: var(--r-lg); padding: 6px 6px 10px;
  border: 2px solid var(--line); text-align: left;
  background: var(--surface);
  transition: all .2s ease;
  box-shadow: var(--shadow-sm);
}
.theme-cover {
  aspect-ratio: 16/9;
  border-radius: 12px; overflow: hidden;
  background: #F7F2EA;
}
.theme-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.theme-meta { padding: 9px 4px 2px; }
.theme-name { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--ink); }
.theme-desc { font-size: 11px; color: var(--ink-soft); margin-top: 3px; letter-spacing: .3px; }
.theme-card.selected {
  border-color: var(--brand);
  box-shadow: 0 14px 32px rgba(194,84,47,.22);
  transform: translateY(-2px);
}
.theme-card.selected::after {
  content: "✓";
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(194,84,47,.40);
  z-index: 2;
}

/* ============ P4 画风 ============ */
.lang-group { display: flex; gap: 9px; }
.lang-btn {
  flex: 1; padding: 13px 0; text-align: center;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-soft);
  transition: all .2s ease;
}
.lang-btn.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 700; }

.style-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-bottom: 22px;
}
.style-card {
  position: relative; overflow: hidden;
  border-radius: var(--r-lg); padding: 5px 5px 0;
  border: 2px solid var(--line);
  background: var(--surface);
  transition: all .2s ease;
}
.style-preview {
  aspect-ratio: 3/3.4;
  border-radius: 12px; overflow: hidden;
  background: #F6F0E6;
  position: relative;
}
.style-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 画风名覆盖 AI 生图右下角水印（兼作品牌小标签） */
.style-name {
  position: absolute; right: 8px; bottom: 8px;
  font-size: 13px; font-weight: 700; color: #fff;
  background: rgba(166,66,31,.88);
  padding: 5px 13px; border-radius: 12px;
  letter-spacing: .5px;
  box-shadow: 0 2px 8px rgba(66,48,30,.25);
}
.style-card.selected {
  border-color: var(--brand);
  box-shadow: 0 10px 24px rgba(194,84,47,.22);
  transform: translateY(-2px);
}
.style-card.selected::after {
  content: "✓";
  position: absolute; top: 8px; left: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(194,84,47,.40);
  z-index: 2;
}

.length-group { display: flex; gap: 9px; }
.length-btn {
  flex: 1; padding: 13px 0; text-align: center;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-soft);
  transition: all .2s ease;
}
.length-btn.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 700; }

.page-form .btn-large { margin-top: 28px; }

/* ============ P5 进度 ============ */
.page-progress {
  background:
    radial-gradient(120% 50% at 50% -6%, #F0DEC9 0%, rgba(240,222,201,0) 60%),
    var(--bg);
  align-items: center; justify-content: center; text-align: center;
}
.ring-wrap {
  position: relative; width: 220px; height: 220px;
  margin: 34px 0 26px;
  display: flex; align-items: center; justify-content: center;
}
.ring-svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-deep); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--brand); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 565.5; stroke-dashoffset: 565.5; transition: stroke-dashoffset .4s ease; }
.ring-text { text-align: center; }
.ring-pct { font-family: var(--font-display); font-size: 54px; font-weight: 700; color: var(--brand); line-height: 1; }
.ring-stage { font-size: 13px; color: var(--ink-soft); margin-top: 8px; font-weight: 600; }

.step-title { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.step-desc { font-size: 13px; color: var(--ink-soft); margin-bottom: 26px; }

.timeline {
  width: 100%; background: rgba(255,255,255,.8);
  border-radius: var(--r-lg); padding: 16px 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,.6);
}
.tl-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; font-size: 13px; color: var(--ink-faint);
}
.tl-item.done { color: var(--ink); font-weight: 600; }
.tl-item.cur { color: var(--brand); font-weight: 700; }
.tl-dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.tl-item.pending .tl-dot { background: var(--bg-deep); color: var(--ink-faint); }
.tl-item.cur .tl-dot { background: var(--brand); color: #fff; animation: pulse 1.2s infinite; }
.tl-item.done .tl-dot { background: var(--sage); color: #fff; }
@keyframes pulse { 50% { transform: scale(1.15); } }

/* ============ P6 阅读器 · 沉浸式 ============ */
.page-reader {
  background:
    radial-gradient(120% 40% at 50% 0%, #F0DEC9 0%, rgba(240,222,201,0) 55%),
    var(--bg);
  padding: 12px 12px 16px;
}
.reader-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px; margin-bottom: 10px;
}
.reader-title-wrap { flex: 1; min-width: 0; text-align: center; }
.reader-title {
  font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-info { font-size: 10px; color: var(--ink-faint); margin-top: 2px; letter-spacing: .5px; }
.reader-top-right { display: flex; gap: 8px; }
.pdf-btn { font-size: 15px; }

/* 舞台：全屏图 + 文字浮层 + 控制条 */
.reader-stage {
  position: relative;
  flex: 1; min-height: 0;
  border-radius: 20px; overflow: hidden;
  background: #FDF0DC;
  box-shadow: 0 10px 30px rgba(66,48,30,.12), 0 2px 6px rgba(66,48,30,.06);
}
.reader-illust {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.reader-illust img {
  width: 100%; height: 100%;
  object-fit: contain; object-position: center top;
  display: block;
}
.illust-tag {
  position: absolute; top: 12px; left: 12px;
  background: rgba(255,255,255,.92);
  padding: 6px 13px; border-radius: 20px;
  font-size: 11px; font-weight: 700; color: var(--brand);
  letter-spacing: .5px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(66,48,30,.08);
  z-index: 3;
}

/* 文字浮层（点图显隐） */
.reader-panel {
  position: absolute; left: 12px; right: 12px;
  bottom: 70px;
  background: rgba(255,252,248,.93);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 4px 18px rgba(66,48,30,.10);
  transition: transform .25s ease, opacity .25s ease;
  z-index: 2;
}
.reader-panel.hidden-panel { transform: translateY(10px); opacity: 0; pointer-events: none; }
.text-cn {
  font-family: var(--font-display);
  font-size: 16px; line-height: 1.8; color: var(--ink);
  font-weight: 600;
}
.text-en {
  font-size: 12px; line-height: 1.55; color: var(--ink-faint);
  font-style: italic; margin-top: 6px;
}

/* 底部控制条（播放 + 信息 + 语言 + 点阵） */
.reader-controls {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,252,248,.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 8px 12px;
  box-shadow: 0 4px 18px rgba(66,48,30,.12);
  z-index: 3;
}
.play-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(194,84,47,.30);
  flex-shrink: 0;
  transition: transform .15s ease;
}
.play-btn:active { transform: scale(.92); }
.audio-info { flex: 1; min-width: 0; }
.audio-info .t1 { font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-info .t2 { font-size: 10px; color: var(--ink-faint); margin-top: 2px; }
.wave { display: flex; gap: 2px; align-items: center; height: 22px; flex-shrink: 0; }
.wave div { width: 3px; background: var(--brand); border-radius: 2px; }
.wave div:nth-child(1) { height: 8px; animation: w1 1s infinite; }
.wave div:nth-child(2) { height: 13px; animation: w2 1s infinite; }
.wave div:nth-child(3) { height: 18px; animation: w3 1s infinite; }
.wave div:nth-child(4) { height: 10px; animation: w1 1s infinite; }
.wave div:nth-child(5) { height: 15px; animation: w2 1s infinite; }
.wave.paused div { animation: none; height: 4px !important; }
@keyframes w1 { 50% { height: 13px; } }
@keyframes w2 { 50% { height: 6px; } }
@keyframes w3 { 50% { height: 8px; } }
.lang-switch {
  font-size: 11px; color: var(--ink); font-weight: 600;
  padding: 5px 10px; background: var(--surface); border-radius: 12px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.dots { display: flex; gap: 5px; flex-shrink: 0; }
.dots .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--bg-deep); }
.dots .dot.act { background: var(--brand); width: 14px; border-radius: 4px; }

/* 翻页按钮：所有设备显示（手机紧凑版，平板/桌面大按钮），手势滑动是手机加分项 */
.reader-nav {
  display: flex;
  justify-content: space-between; align-items: center;
  margin-top: 12px; padding: 0 4px;
}
.nav-btn {
  padding: 9px 14px; border-radius: 14px;
  font-size: 12px; font-weight: 700;
  background: var(--surface); color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}
.nav-btn:active { transform: scale(.96); }
.nav-btn.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(194,84,47,.26); }
.nav-btn:disabled { opacity: .4; pointer-events: none; }

/* ============ 分享面板 ============ */
.share-sheet {
  position: fixed; inset: 0;
  background: rgba(42,33,27,.42);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.share-sheet[hidden] { display: none; }
.share-card {
  width: 100%; max-width: 480px;
  background: var(--surface); border-radius: 28px 28px 0 0;
  padding: 30px 24px 34px;
  text-align: center;
  animation: sheetUp .3s ease both;
}
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.share-card h3 { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.share-card p { font-size: 13px; color: var(--ink-soft); margin-bottom: 20px; }
.share-row { display: flex; gap: 9px; margin-bottom: 12px; }
.share-row input {
  flex: 1; padding: 15px 16px;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  font-size: 15px; outline: none;
}
.share-row input:focus { border-color: var(--brand); }
.share-divider {
  font-size: 12px; color: var(--ink-faint); text-align: center;
  margin: 16px 0 12px; display: flex; align-items: center; gap: 10px;
}
.share-divider::before, .share-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.share-tip { font-size: 12px; min-height: 16px; margin: 8px 0 14px; }
.share-tip.success { color: var(--sage); }
.share-tip.error { color: #C0392B; }

/* ============ Toast ============ */
.toast {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.8);
  background: rgba(42,33,27,.92); color: #fff;
  padding: 13px 22px; border-radius: 16px;
  font-size: 14px; font-weight: 600;
  pointer-events: none; opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 300; max-width: 80%;
  backdrop-filter: blur(6px);
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ============ 自定义兴趣 ============ */
.custom-tag { display: flex; gap: 8px; margin-top: 13px; align-items: center; }
.custom-tag input {
  flex: 1;
  padding: 11px 15px;
  border: 1.5px dashed var(--line);
  border-radius: 20px;
  background: var(--surface-warm);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
}
.custom-tag input:focus { border-style: solid; border-color: var(--brand); background: #fff; }
.custom-tag .custom-add {
  flex-shrink: 0;
  background: var(--brand);
  color: #fff;
  border: none;
  font-weight: 600;
}
.tag-btn.custom { background: var(--brand-soft); border-color: var(--brand); border-style: solid; color: var(--brand); }

/* ============ 剩余次数 / 付费墙 ============ */
.quota-info {
  font-size: 12px; color: var(--gold); font-weight: 600;
  margin-top: 14px; letter-spacing: .5px; text-align: center;
}

/* ============ 用户条 / 登录 ============ */
.user-bar {
  margin-top: 16px; text-align: center;
}
.user-login {
  background: none; border: 1px solid var(--line); border-radius: 20px;
  padding: 7px 16px; font-size: 12px; color: var(--ink-soft);
  cursor: pointer; transition: border-color .15s ease, color .15s ease;
}
.user-login:hover { border-color: var(--brand); color: var(--brand-deep); }
.user-login.logged { color: var(--brand-deep); border-color: var(--brand-soft); }

.login-sheet {
  position: fixed; inset: 0;
  background: rgba(42,33,27,.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 220;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.login-sheet[hidden] { display: none; }
.login-card {
  width: 100%; max-width: 480px;
  background: var(--surface); border-radius: 28px 28px 0 0;
  padding: 30px 24px 34px;
  text-align: center;
  animation: sheetUp .3s ease both;
}
.login-card h3 { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 20px; }
.login-row { display: flex; gap: 9px; margin-bottom: 12px; }
.login-row input {
  flex: 1; min-width: 0; padding: 13px 14px;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  font-size: 15px; background: var(--surface-warm); color: var(--ink);
  outline: none; transition: border-color .15s ease;
}
.login-row input:focus { border-color: var(--brand); }
.login-row .btn-small { flex-shrink: 0; white-space: nowrap; }
.login-tip { min-height: 20px; font-size: 12px; color: var(--brand); margin-bottom: 10px; }
.login-note { font-size: 11px; color: var(--ink-faint); margin: 14px 0 16px; line-height: 1.6; }

.paywall-sheet {
  position: fixed; inset: 0;
  background: rgba(42,33,27,.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 210;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.paywall-sheet[hidden] { display: none; }
.paywall-card {
  width: 100%; max-width: 480px;
  background: var(--surface); border-radius: 28px 28px 0 0;
  padding: 30px 24px 34px;
  text-align: center;
  animation: sheetUp .3s ease both;
}
.paywall-card h3 { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.pw-used { font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.plan-card {
  border: 1.5px solid var(--line); border-radius: var(--r-lg);
  padding: 20px 14px; text-align: center;
  background: var(--surface-warm);
}
.plan-name { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.plan-price { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--brand); margin: 8px 0 2px; }
.plan-price span { font-size: 13px; color: var(--ink-faint); font-weight: 400; }
.plan-desc { font-size: 12px; color: var(--ink-faint); margin-bottom: 12px; }
.plan-buy { width: 100%; }
.activate-row { display: flex; gap: 8px; margin-bottom: 12px; }
.activate-row input {
  flex: 1; padding: 12px 15px;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  font-size: 14px; outline: none;
}
.activate-row input:focus { border-color: var(--brand); }

/* ============ 平板横屏适配（≥900px 且横屏，如 iPad 横屏） ============ */
@media (min-width: 900px) and (orientation: landscape) {
  #app { max-width: 960px; }

  /* 首页 */
  .page-home { padding-top: 44px; }
  .feature-grid { grid-template-columns: repeat(4, 1fr); }

  /* 表单页：字段两列（昵称/年龄一排；性别/兴趣整行） */
  .page-form { padding: 24px 34px 40px; }
  .form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 22px;
    align-items: start;
  }
  .form .field:nth-child(3),
  .form .field:nth-child(4) { grid-column: 1 / 3; }

  /* 主题 2 列 → 3 列 */
  .theme-grid { grid-template-columns: repeat(3, 1fr); }

  /* 画风 3 列 → 6 列（6 个画风一行排完） */
  .style-grid { grid-template-columns: repeat(3, 1fr); }

  /* 语言/长度选择限宽，避免拉满 */
  .lang-group, .length-group { max-width: 460px; }

  /* 进度页 */
  .page-progress { padding-top: 50px; }

  /* 阅读器：左图右文双栏（沉浸舞台 + 右栏文字/控制） */
  .page-reader { padding: 20px 30px 26px; }
  .reader-title-wrap { text-align: left; }
  .reader-title { max-width: 480px; font-size: 18px; }
  .reader-stage {
    position: relative;
    display: grid;
    grid-template-columns: 56% 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 14px 26px;
    padding: 16px;
    height: min(640px, calc(100vh - 215px));
    min-height: 0;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
  }
  .reader-illust {
    position: static;
    grid-column: 1; grid-row: 1 / 3;
    border-radius: 16px; overflow: hidden;
    background: #FDF0DC;
  }
  .reader-illust img { width: 100%; height: 100%; object-fit: contain; }
  .reader-panel {
    position: static;
    grid-column: 2; grid-row: 1;
    background: none; backdrop-filter: none;
    box-shadow: none; border-radius: 0;
    padding: 0 4px;
    display: flex; flex-direction: column; justify-content: flex-end;
    transform: none !important; opacity: 1 !important;
    pointer-events: auto !important;
  }
  .reader-panel .text-cn { font-size: 19px; line-height: 1.9; }
  .reader-panel .text-en { font-size: 13px; }
  .reader-controls {
    position: static;
    grid-column: 2; grid-row: 2;
    margin-top: 6px; padding: 14px 16px;
    box-shadow: var(--shadow-sm);
  }

  /* 底部翻页导航（平板显示按钮） */
  .reader-nav { display: flex; margin-top: 16px; padding: 0 8px; }
  .nav-btn { padding: 12px 26px; font-size: 14px; }
  .dots .dot { width: 8px; height: 8px; }
  .dots .dot.act { width: 22px; }
}

/* 平板/大屏竖屏（≥600px 竖屏，如 iPad 竖屏 768×1024）：内容放宽到 700px，单列大图 */
@media (min-width: 600px) and (orientation: portrait) {
  #app { max-width: 700px; }
  .page-home { padding-top: 40px; }
  .feature-grid { grid-template-columns: repeat(3, 1fr); }
  .page-form { padding: 22px 28px 36px; }
  .theme-grid { grid-template-columns: repeat(3, 1fr); }
  .style-grid { grid-template-columns: repeat(3, 1fr); }
  .lang-group, .length-group { max-width: 480px; }
  .page-reader { padding: 18px 24px 26px; }
  .reader-title { max-width: 420px; font-size: 18px; }
  .reader-illust img { max-height: 56vh; }
  .reader-panel .text-cn { font-size: 18px; line-height: 1.9; }
}

/* ============ 我的绘本库 ============ */
.page-library { background: var(--bg); min-height: 100vh; }
.library-intro {
  font-size: 13px; color: var(--ink-soft); text-align: center;
  margin: 6px 0 18px;
}
.library-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface-warm);
  border: 1px dashed var(--brand-soft);
  border-radius: var(--r-md);
  padding: 11px 14px;
  margin-bottom: 14px;
}
.library-banner[hidden] { display: none; }
.banner-text {
  font-size: 12px; color: var(--ink-soft); line-height: 1.5;
  flex: 1;
}
.banner-btn {
  flex-shrink: 0;
  background: var(--brand); color: #fff;
  border-radius: 14px; padding: 7px 14px;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease;
}
.banner-btn:active { transform: scale(.96); }
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.library-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); overflow: hidden; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, border-color .15s ease;
}
.library-card:active { transform: scale(.97); border-color: var(--brand); }
.lib-cover {
  aspect-ratio: 3/4; background: var(--surface-warm); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.lib-cover img { width: 100%; height: 100%; object-fit: cover; }
.lib-cover-ph { font-size: 34px; opacity: .5; }
.lib-title {
  font-size: 13px; font-weight: 700; color: var(--ink);
  padding: 10px 12px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-meta {
  font-size: 11px; color: var(--ink-faint);
  padding: 0 12px 12px;
}
.library-loading {
  grid-column: 1 / -1; text-align: center; color: var(--ink-faint);
  padding: 40px 0; font-size: 13px;
}
.library-empty {
  text-align: center; padding: 48px 0 30px;
}
.empty-icon { font-size: 46px; opacity: .6; }
.empty-text { font-size: 14px; color: var(--ink-soft); margin: 14px 0 20px; }

/* ============ 生成流程：步骤胶囊条 + 吸底按钮 ============ */
/* 注意：display 由 .page/.page.active 控制（.page 默认 none、active 时 flex），
   这里只能补 flex-direction，绝不能重设 display 否则所有表单页会同时显示 */
.page-form.active { flex-direction: column; }
.form-scroll { flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.steps-bar {
  position: relative;
  display: flex; align-items: flex-start; gap: 8px;
  padding: 16px 4px 18px;
}
.steps-bar .back-btn { flex-shrink: 0; width: 36px; height: 36px; margin-right: 2px; }
.step {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  min-width: 38px;
}
.step-num {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--bg-deep); color: var(--ink-faint);
  transition: all .2s ease;
}
.step-label { font-size: 10px; color: var(--ink-faint); letter-spacing: .5px; white-space: nowrap; }
.step.cur .step-num {
  background: var(--brand); color: #fff;
  box-shadow: 0 4px 12px rgba(194,84,47,.35);
  transform: scale(1.08);
}
.step.cur .step-label { color: var(--brand); font-weight: 700; }
.step.done .step-num { background: var(--sage); color: #fff; }
.step.done .step-label { color: var(--ink-soft); }
.step-line { flex: 1; height: 2.5px; border-radius: 2px; background: var(--bg-deep); margin: 12px 2px 0; min-width: 12px; }
.step-line.done { background: var(--sage); }

.steps-actions {
  margin-top: auto;
  position: sticky; bottom: 0; z-index: 5;
  margin-left: -24px; margin-right: -24px;
  padding: 12px 24px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(247,242,234,0) 0%, var(--bg) 30%);
}

@media (min-width: 600px) and (orientation: portrait) {
  .steps-actions { margin-left: -28px; margin-right: -28px; padding-left: 28px; padding-right: 28px; }
}
@media (min-width: 900px) and (orientation: landscape) {
  .steps-actions { margin-left: -34px; margin-right: -34px; padding-left: 34px; padding-right: 34px; }
}

/* ============ 阅读器末页结束动作 ============ */
.reader-end {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: rgba(247,242,234,.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-radius: 20px;
  animation: endIn .3s ease both;
}
.reader-end[hidden] { display: none; }
@keyframes endIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.end-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 26px 24px 22px;
  text-align: center;
  width: calc(100% - 56px);
  max-width: 300px;
}
.end-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--brand-deep); }
.end-sub { font-size: 13px; color: var(--ink-soft); margin: 8px 0 18px; }
.end-actions { display: flex; flex-direction: column; gap: 10px; }
.end-btn {
  padding: 13px 0; border-radius: 14px;
  font-size: 14px; font-weight: 700;
  background: var(--surface-warm); color: var(--ink);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .15s ease;
}
.end-btn:active { transform: scale(.97); }
.end-btn.primary { background: var(--brand); color: #fff; border: none; box-shadow: 0 6px 16px rgba(194,84,47,.26); }

/* ============ Toast 三色（成功/失败/普通） ============ */
.toast.success { background: rgba(62,90,74,.95); }
.toast.error { background: rgba(185,70,70,.95); }

/* ============ 无障碍：键盘焦点 + 减少动效 ============ */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ 绘本库骨架屏 ============ */
.skeleton-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.skeleton-card {
  aspect-ratio: 3/4.1;
  border-radius: 14px;
  background: var(--bg-deep);
  position: relative; overflow: hidden;
}
.skeleton-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
