:root {
  color-scheme: light;
  --bg: #fdf7ee;
  --bg-2: #fff3e0;
  --surface: #ffffff;
  --ink: #2c2440;
  --muted: #7c7596;
  --line: #f0e6d8;
  --primary: #ff8a5b;
  --primary-ink: #e0623a;
  --accent: #5b9df0;
  --accent-ink: #2f6fd0;
  --mint: #41c7a0;
  --grape: #9354e0;
  --sun: #ffc94d;
  --radius: 22px;
  --shadow: 0 16px 40px rgba(120, 86, 60, 0.14);
  --shadow-soft: 0 10px 26px rgba(120, 86, 60, 0.08);
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 12% -8%, var(--bg-2), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, #eaf3ff, transparent 55%),
    var(--bg);
  font-weight: 600;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand-text strong,
.hero h1,
.player-title h2 {
  font-family: "Baloo 2", "Nunito", system-ui, sans-serif;
}

[hidden] {
  display: none !important;
}

/* ---------- 顶栏 ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  font-size: 28px;
  background: linear-gradient(145deg, var(--sun), var(--primary));
  box-shadow: var(--shadow-soft);
}

.brand-text strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
}

.brand-text span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 0 auto;
  padding: 6px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 16px;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease;
}

.tab.active {
  color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--primary-ink));
  box-shadow: 0 8px 18px rgba(224, 98, 58, 0.34);
}

.tab:not(.active):hover {
  transform: translateY(-1px);
  color: var(--ink);
}

.stats {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.stats b {
  color: var(--primary-ink);
  font-size: 18px;
  font-family: "Baloo 2", sans-serif;
}

/* ---------- 主体 ---------- */
.page {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px) 60px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 26px;
}

.greeting {
  color: var(--primary-ink);
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
}

.hero h1 {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  line-height: 1.1;
}

.hero-note {
  margin-top: 8px;
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(147, 84, 224, 0.14);
  color: var(--grape);
  font-size: 13px;
  font-weight: 700;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(380px, 100%);
  padding: 0 18px;
  height: 56px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--line);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(91, 157, 240, 0.18);
}

.search-icon {
  font-size: 18px;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-weight: 700;
}

/* ---------- 筛选条 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.chip {
  padding: 9px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
  transition: transform 0.12s ease, border-color 0.2s ease, color 0.2s ease;
}

.chip:hover {
  transform: translateY(-1px);
}

.chip.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(145deg, var(--accent), var(--accent-ink));
  box-shadow: 0 8px 16px rgba(47, 111, 208, 0.28);
}

/* 绘本系列切换 chip（橙色，区别于蓝色的级别 chip）*/
.chip.series.active {
  background: linear-gradient(145deg, var(--primary), var(--primary-ink));
  box-shadow: 0 8px 16px rgba(224, 98, 58, 0.3);
}

.chip-sep {
  width: 2px;
  align-self: stretch;
  margin: 2px 4px;
  background: var(--line);
  border-radius: 2px;
}

.group-select {
  max-width: min(100%, 460px);
  padding: 11px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.result-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

/* ---------- 画廊 ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: clamp(14px, 2vw, 22px);
}

.card {
  border: 0;
  padding: 0;
  text-align: left;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.card:hover {
  transform: translateY(-5px) rotate(-0.4deg);
  box-shadow: var(--shadow);
}

.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  color: #fff;
  text-align: center;
  padding: 14px;
}

.cover.video {
  aspect-ratio: 16 / 11;
}

.cover-emoji {
  font-size: clamp(44px, 8vw, 60px);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.18));
}

.cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover.video .cover-img {
  object-fit: cover;
}

.cover-level {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  font-family: "Baloo 2", sans-serif;
}

.cover-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 44px;
  color: rgba(255, 255, 255, 0.95);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.fav-star {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  color: #fff;
  font-size: 19px;
  line-height: 1;
  transition: transform 0.12s ease, background 0.2s ease;
}

.fav-star:hover {
  transform: scale(1.15);
  background: rgba(0, 0, 0, 0.5);
}

.fav-star.on {
  color: var(--sun);
  background: rgba(0, 0, 0, 0.42);
}

/* ⭐ 我的 */
.gallery.mine-mode {
  display: block;
}

.mine-section + .mine-section {
  margin-top: 34px;
}

.mine-title {
  margin-bottom: 16px;
  font-size: 20px;
  font-weight: 800;
  font-family: "Baloo 2", "Nunito", sans-serif;
}

.fav-btn {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 10px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease;
}

.fav-btn:hover {
  transform: translateY(-1px);
}

.fav-btn.on {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(145deg, var(--sun), var(--primary));
}

.card-body {
  padding: 12px 14px 16px;
}

.card-series {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title {
  margin: 3px 0 8px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(65, 199, 160, 0.16);
  color: #1f8e6e;
  font-size: 12px;
  font-weight: 800;
}

.card-tag.play {
  background: rgba(91, 157, 240, 0.16);
  color: var(--accent-ink);
}

.card-tag.read {
  background: rgba(147, 84, 224, 0.14);
  color: var(--grape);
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 34px;
}

.load-more {
  padding: 14px 34px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--primary-ink);
  font-weight: 800;
  font-size: 16px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease;
}

.load-more:hover {
  transform: translateY(-2px);
}

.empty {
  grid-column: 1 / -1;
  padding: 50px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

/* ---------- 播放页 ---------- */
#player {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.player-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--line);
}

.back-btn {
  flex: 0 0 auto;
  padding: 10px 18px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--primary-ink);
  font-weight: 800;
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease;
}

.back-btn:hover {
  transform: translateX(-3px);
}

.player-title {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.player-badge {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  font-family: "Baloo 2", sans-serif;
  background: var(--accent);
}

.player-series {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-title h2 {
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 800;
  overflow-wrap: anywhere;
}

/* 绘本播放 */
.book-player {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(1000px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px) clamp(14px, 4vw, 28px) 40px;
}

.reader {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 18px);
}

.page-arrow {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--primary-ink);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease;
}

.page-arrow:not(:disabled):hover {
  transform: scale(1.08);
  background: var(--primary);
  color: #fff;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  min-height: 360px;
  padding: 12px;
  border-radius: 20px;
  background: #1a1626;
  box-shadow: var(--shadow);
}

#pdfCanvas {
  max-width: 100%;
  max-height: min(66vh, 680px);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.reader-loading {
  position: absolute;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
}

.book-dock {
  border-radius: 20px;
  padding: 16px 20px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.video-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 2px dashed var(--line);
}

.video-links-label {
  color: var(--mint);
  font-size: 13px;
  font-weight: 800;
}

.video-links-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.video-link {
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(65, 199, 160, 0.16);
  color: #1f8e6e;
  font-weight: 800;
  font-size: 13px;
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease;
}

.video-link:hover {
  transform: translateY(-1px);
  background: var(--mint);
  color: #fff;
}

.page-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.page-counter {
  color: var(--muted);
  font-weight: 700;
}

.turn-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--bg-2);
}

.turn {
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.turn.active {
  color: #fff;
  background: var(--accent);
}

.calib-btn {
  padding: 6px 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}
.calib-btn.done {
  border-color: transparent;
  color: #fff;
  background: var(--mint);
}

.calib-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(91, 157, 240, 0.12);
}
.calib-hint {
  flex: 1;
  min-width: 180px;
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 14px;
}
.calib-mark {
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--primary), var(--primary-ink));
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 8px 18px rgba(224, 98, 58, 0.3);
}
.calib-secondary {
  padding: 10px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.page-counter b {
  color: var(--primary-ink);
  font-family: "Baloo 2", sans-serif;
}

.audio-dock {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.big-play {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary), var(--primary-ink));
  color: #fff;
  font-size: 22px;
  box-shadow: 0 8px 18px rgba(224, 98, 58, 0.34);
  transition: transform 0.12s ease;
}

.big-play:hover {
  transform: scale(1.06);
}

.audio-mid {
  flex: 1;
  min-width: 180px;
}

.track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-2);
  cursor: pointer;
  overflow: hidden;
}

.track-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sun), var(--primary));
  transition: width 0.1s linear;
}

.audio-sub {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.accent-toggle {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: var(--bg-2);
}

.accent {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}

.accent.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 6px 14px rgba(224, 98, 58, 0.3);
}

.accent:disabled {
  opacity: 0.35;
}

/* 视频播放 */
.video-player {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: clamp(12px, 3vw, 30px);
  overflow-y: auto;
}

.video-player video {
  width: min(1000px, 100%);
  max-height: 78vh;
  border-radius: 20px;
  background: #1a1626;
  box-shadow: var(--shadow);
}

.video-player iframe#biliFrame {
  width: min(1000px, 100%);
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 20px;
  background: #1a1626;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

/* 分集列表 */
.ep-list {
  width: min(1000px, 100%);
}
.ep-head {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 2px 4px 10px;
}
.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.ep {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 9px 11px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--card, #fff);
  box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, 0.06));
  cursor: pointer;
  font: inherit;
  color: var(--ink, #333);
  transition: border-color 0.15s, transform 0.1s;
}
.ep:hover {
  transform: translateY(-1px);
}
.ep.active {
  border-color: var(--brand, #f0913a);
  background: #fff6ec;
}
.ep-num {
  flex-shrink: 0;
  min-width: 1.6em;
  height: 1.6em;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand, #f0913a);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}
.ep.active .ep-num {
  background: #e0623a;
}
.ep-title {
  font-size: 0.86rem;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .appbar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .tabs {
    order: 3;
    width: 100%;
    margin: 0;
    justify-content: center;
  }

  .stats {
    margin-left: auto;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .result-count {
    width: 100%;
  }

  .page-arrow {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .canvas-wrap {
    min-height: 280px;
  }

  .audio-dock {
    justify-content: center;
  }

  .accent-toggle {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}
