/* Hora Academy · Primary Mathematics Portal
 * Aesthetic: Sunny Montessori × Illustrated Picture-Book × Playful Discovery (Ages 5–11)
 */
:root {
  --bg-top: #eef7ff;
  --bg-mid: #fffdf7;
  --bg-bot: #f5f9f2;
  --card: rgba(255, 255, 255, 0.94);
  --ink: #1e2d42;
  --ink-2: #415570;
  --muted: #697d96;
  --line: #e2eaf3;
  --line-strong: #cbd8e6;
  --sunny: #ffb703;
  --sunny-soft: #fff4cc;
  --coral: #ff6b6b;
  --mint: #12b886;
  --sky: #339af0;
  --violet: #7950f2;
  --stage-color: #339af0;
  --stage-soft: #e7f5ff;
  --shadow-sm: 0 6px 18px rgba(30, 58, 95, 0.06);
  --shadow-md: 0 14px 36px rgba(30, 58, 95, 0.10);
  --shadow-lg: 0 22px 50px rgba(30, 58, 95, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-round: ui-rounded, "Nunito", "Avenir Next", "Quicksand", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Consolas", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-round);
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(255, 212, 102, 0.24) 0, transparent 34%),
    radial-gradient(circle at 92% 10%, rgba(116, 192, 252, 0.24) 0, transparent 36%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bot) 100%);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--stage-color); outline-offset: 3px; border-radius: 10px; }

/* ==================== TOP BAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(255, 253, 248, 0.85);
  border-bottom: 1px solid rgba(203, 216, 230, 0.65);
}
.topbar-in {
  max-width: 1240px;
  margin: 0 auto;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: linear-gradient(135deg, #ffd43b, #ff922b);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(255, 146, 43, 0.30);
  transition: transform .4s cubic-bezier(.3, 1.6, .5, 1);
}
.brand:hover .brand-mark { transform: rotate(-10deg) scale(1.08); }
.brand-text strong {
  display: block;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.brand-text small {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.nav-tag {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #2b6cb0;
  padding: 6px 13px;
  border-radius: 999px;
  background: #e7f5ff;
  border: 1px solid #c5e4ff;
}
.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.btn-pill:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--sky);
  color: #1971c2;
}
.btn-pill.primary {
  background: linear-gradient(135deg, #339af0, #5c7cfa);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(51, 154, 240, 0.28);
}
.btn-pill.primary:hover { color: #fff; box-shadow: 0 12px 26px rgba(51, 154, 240, 0.36); }

/* ==================== CONTAINER ==================== */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 24px 72px;
}

/* ==================== FULL-BLEED STORYBOOK BANNER ==================== */
.portal-banner {
  position: relative;
  border-radius: 30px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 2px solid #dcebfa;
  aspect-ratio: 16 / 9;
  background: #d8eeff;
  margin-bottom: 26px;
  isolation: isolate;
}
.portal-banner-in {
  position: absolute;
  inset: 0;
}
.portal-banner-in > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#bannerSparkles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.book-hot {
  position: absolute;
  z-index: 4;
  display: block;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .32s cubic-bezier(.3, 1.5, .5, 1), box-shadow .28s ease, background .28s ease;
}
.book-hot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(110deg, transparent 34%, rgba(255,255,255,0.42) 50%, transparent 66%) -180% 0 / 260% 100% no-repeat;
  animation: bookSweep 7.5s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.85s);
}
@keyframes bookSweep {
  0%, 72% { background-position: -180% 0; }
  100% { background-position: 180% 0; }
}
.book-hot:hover, .book-hot:focus-visible, .book-hot.on {
  transform: translateY(-10px) scale(1.03);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.96), 0 0 26px 6px var(--c, #339af0), 0 20px 28px rgba(15, 27, 45, 0.25);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}
.book-hot .tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translate(-50%, 8px);
  opacity: 0;
  white-space: nowrap;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
  font-size: clamp(11px, 1.25vw, 14px);
  padding: 6px 13px;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(15, 27, 45, 0.22);
  border: 1.5px solid color-mix(in srgb, var(--c, #339af0) 35%, white);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}
.book-hot .tip i {
  font-style: normal;
  color: var(--c, #339af0);
  margin-right: 6px;
}
.book-hot:hover .tip, .book-hot:focus-visible .tip, .book-hot.on .tip {
  opacity: 1;
  transform: translate(-50%, 0);
}
.book-card.on {
  transform: translateY(-7px);
  box-shadow: var(--shadow-lg);
  border-color: var(--stage-color);
}

/* ==================== SUNNY PRIMARY HERO ==================== */
.hero {
  position: relative;
  border-radius: 32px;
  background: linear-gradient(130deg, #ffffff 0%, #f1f8ff 52%, #fff8e6 100%);
  border: 2px solid #dcebfa;
  padding: 36px 38px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 30px;
  align-items: center;
}
.hero::before, .hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: floatBubble 12s ease-in-out infinite alternate;
}
.hero::before {
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(255, 212, 59, 0.25), transparent 70%);
  top: -90px; left: -60px;
}
.hero::after {
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(116, 192, 252, 0.25), transparent 70%);
  right: -80px; bottom: -110px;
  animation-delay: -5s;
}
@keyframes floatBubble {
  to { transform: translate(18px, -16px) scale(1.08); }
}

/* Playful floating math shapes */
.float-shape {
  position: absolute;
  pointer-events: none;
  font-size: 26px;
  opacity: 0.22;
  animation: bobShape 6s ease-in-out infinite alternate;
}
.float-shape.s1 { top: 20px; left: 46%; color: #ff6b6b; }
.float-shape.s2 { bottom: 24px; left: 42%; color: #12b886; animation-delay: -2s; }
.float-shape.s3 { top: 24px; right: 26px; color: #7950f2; animation-delay: -4s; }
@keyframes bobShape {
  to { transform: translateY(-10px) rotate(12deg); }
}

.hero-left { position: relative; z-index: 2; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  color: #b45309;
  padding: 6px 14px;
  border-radius: 999px;
  background: #fff3bf;
  border: 1.5px solid #ffe066;
  margin-bottom: 16px;
}
.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 3.8vw, 46px);
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.hero h1 .rainbow {
  background: linear-gradient(90deg, #339af0, #7950f2, #f76707);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  margin: 0 0 22px;
  font-size: 15.5px;
  color: var(--ink-2);
  max-width: 530px;
}
.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}
.metric {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.04);
}
.metric .m-ico { font-size: 20px; }
.metric strong {
  display: block;
  font-size: 17px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.1;
}
.metric span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.cta-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff922b, #ff6b6b);
  color: #fff;
  font-weight: 800;
  font-size: 14.5px;
  box-shadow: 0 10px 22px rgba(255, 107, 107, 0.30);
  transition: transform .2s ease, box-shadow .2s ease;
}
.cta-main:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 14px 28px rgba(255, 107, 107, 0.38); }
.cta-soft {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-size: 14.5px;
  border: 1.5px solid var(--line-strong);
  transition: all .2s ease;
}
.cta-soft:hover { border-color: var(--sky); color: #1971c2; transform: translateY(-2px); }

/* ==================== PLAYFUL MATH TOY BOX (HERO RIGHT) ==================== */
.hero-lab {
  position: relative;
  z-index: 2;
  background: #ffffff;
  border: 2px solid #e1edf9;
  border-radius: 26px;
  padding: 18px 20px;
  box-shadow: 0 16px 36px rgba(51, 154, 240, 0.12);
}
.lab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.lab-title {
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lab-tabs {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 999px;
}
.lab-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  transition: all .18s ease;
}
.lab-tab.active {
  background: #fff;
  color: #1971c2;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.12);
}
.lab-stage {
  position: relative;
  height: 230px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 18% 18%, #fff9db 0, transparent 42%),
    linear-gradient(180deg, #f4faff 0%, #ffffff 100%);
  border: 1.5px dashed #bfdcf7;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.lab-stage canvas { width: 100%; height: 100%; display: block; }
.lab-controls {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lab-sliders {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.slider-pill {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-2);
}
.slider-pill input[type="range"] { flex: 1; accent-color: #339af0; }
.lab-readout {
  text-align: center;
  padding: 8px 14px;
  border-radius: 12px;
  background: #fff4cc;
  color: #7c4a00;
  font-size: 13.5px;
  font-weight: 900;
}

/* ==================== SECTION HEADS ==================== */
.sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 42px 0 20px;
  flex-wrap: wrap;
}
.sec-head .kicker {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f76707;
  margin-bottom: 4px;
}
.sec-head h2 {
  margin: 0;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.sec-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ==================== SIX-STAGE PICTURE-BOOK SHELF ==================== */
.books-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}
.book-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 26px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .26s cubic-bezier(.3, 1.5, .5, 1), box-shadow .26s ease, border-color .26s ease;
  overflow: hidden;
}
.book-card:hover {
  transform: translateY(-7px);
  box-shadow: var(--shadow-lg);
  border-color: var(--stage-color);
}
.book-cover {
  position: relative;
  height: 186px;
  border-radius: 19px;
  padding: 18px 20px;
  background: linear-gradient(140deg, var(--stage-pastel), #ffffff 100%);
  border: 1.5px solid color-mix(in srgb, var(--stage-color) 24%, white);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.book-cover svg.geo-art {
  position: absolute;
  right: -8px;
  bottom: -10px;
  width: 158px;
  height: 158px;
  transition: transform .42s cubic-bezier(.3, 1.5, .5, 1);
  pointer-events: none;
}
.book-card:hover .book-cover svg.geo-art {
  transform: scale(1.08) rotate(-5deg);
}
.cover-top {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stage-badge {
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--stage-color);
  color: #fff;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--stage-color) 32%, transparent);
}
.lo-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink-2);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.cover-title {
  position: relative;
  z-index: 2;
  max-width: 72%;
}
.cover-emoji {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 6px;
  display: inline-block;
}
.cover-title h3 {
  margin: 0 0 2px;
  font-size: 21px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.2;
}
.cover-title .zh {
  font-size: 13px;
  font-weight: 700;
  color: var(--stage-color);
}
.book-body {
  padding: 15px 8px 6px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.book-desc {
  margin: 0 0 13px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.strand-bar {
  display: flex;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #edf2f7;
  margin-bottom: 8px;
  gap: 3px;
}
.strand-bar span { height: 100%; border-radius: 999px; }
.strand-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 14px;
}
.strand-legend i {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.book-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1.5px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--stage-color);
}
.book-foot .meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.book-foot .go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.book-foot .arrow {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--stage-pastel);
  color: var(--stage-color);
  display: grid;
  place-items: center;
  font-size: 15px;
  transition: transform .25s ease;
}
.book-card:hover .book-foot .arrow { transform: translateX(4px); }

/* ==================== GLOBAL EXPLORER ==================== */
.explorer-panel {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 24px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.search-input {
  flex: 1;
  min-width: 230px;
  padding: 11px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line-strong);
  background: #f8fbff;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.search-input:focus { border-color: var(--sky); background: #fff; }
.chip-group { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 800;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--stage-color); color: var(--stage-color); }
.chip.active {
  background: var(--stage-color);
  color: #fff;
  border-color: var(--stage-color);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--stage-color) 28%, transparent);
}
.search-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-height: 430px;
  overflow-y: auto;
  padding-right: 4px;
}
.res-card {
  display: block;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: #fbfdff;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.res-card:hover {
  transform: translateY(-2px);
  background: #fff;
  border-color: var(--sky);
}
.res-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 4px;
}
.res-title { font-weight: 800; font-size: 14.5px; color: var(--ink); margin-bottom: 3px; }
.res-sub { font-size: 12.5px; color: var(--ink-2); }

/* ==================== STAGE PAGE SUNNY HERO (RICH COLORFUL EDITION) ==================== */
.stage-hero {
  position: relative;
  border-radius: 30px;
  background: linear-gradient(125deg, color-mix(in srgb, var(--stage-color) 86%, #0f172a) 0%, var(--stage-color) 52%, color-mix(in srgb, var(--stage-color) 68%, #ffd43b) 100%);
  border: 3px solid rgba(255, 255, 255, 0.7);
  padding: 32px 36px;
  overflow: hidden;
  box-shadow: 0 22px 48px color-mix(in srgb, var(--stage-color) 28%, transparent);
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 26px;
  align-items: center;
  color: #ffffff;
}
.stage-hero::before {
  content: "+   ×   ÷   ∠   △   π   =";
  position: absolute;
  right: 24px;
  top: 10px;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 14px;
  color: rgba(255, 255, 255, 0.16);
  pointer-events: none;
}
.stage-hero::after {
  content: "";
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 232, 102, 0.34), transparent 70%);
  left: -60px; bottom: -120px;
  pointer-events: none;
}
.stage-hero-left { position: relative; z-index: 2; }
.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.16);
  padding: 5px 13px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.breadcrumb a:hover { text-decoration: underline; }
.stage-hero h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 3.6vw, 42px);
  font-weight: 900;
  line-height: 1.12;
  color: #ffffff;
  text-shadow: 0 4px 14px rgba(15, 27, 45, 0.18);
}
.stage-hero .zh-sub {
  font-size: 15.5px;
  font-weight: 800;
  color: #fff3bf;
  margin-bottom: 10px;
}
.stage-hero p {
  margin: 0;
  max-width: 600px;
  font-size: 14.5px;
  color: rgba(255, 255, 255, 0.92);
}
.stage-hero-banner-img {
  position: relative;
  z-index: 2;
  border-radius: 20px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 14px 30px rgba(15, 27, 45, 0.24);
  margin-bottom: 14px;
  aspect-ratio: 16 / 9;
}
.stage-hero-banner-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage-progress-box {
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  padding: 16px 18px;
  box-shadow: 0 14px 30px rgba(15, 27, 45, 0.16);
  color: var(--ink);
}
.prog-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-weight: 800;
  color: var(--ink);
}
.prog-row strong { font-size: 24px; color: var(--stage-color); }
.prog-bar {
  height: 10px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
  margin-bottom: 14px;
}
.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd43b, var(--stage-color));
  border-radius: 999px;
  width: 0%;
  transition: width .35s ease;
}
.stage-stats-mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}
.stage-stats-mini div {
  background: var(--stage-pastel);
  border-radius: 13px;
  padding: 9px 6px;
}
.stage-stats-mini b { display: block; font-size: 17px; font-weight: 900; color: var(--stage-color); }
.stage-stats-mini span { font-size: 11px; font-weight: 700; color: var(--ink-2); }

/* Stage switcher pills */
.stage-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0 18px;
}
.sw-link {
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: #fff;
  border: 1.5px solid var(--line-strong);
  color: var(--ink-2);
  transition: all .18s ease;
}
.sw-link:hover { border-color: var(--stage-color); color: var(--stage-color); transform: translateY(-1px); }
.sw-link.active {
  background: var(--stage-color);
  color: #fff;
  border-color: var(--stage-color);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--stage-color) 28%, transparent);
}

/* ==================== CHAPTER EXPEDITION CARDS (COLORFUL STRAND RIBBONS) ==================== */
.chapters-list { display: flex; flex-direction: column; gap: 16px; }
.chapter-card {
  position: relative;
  background: var(--card);
  border: 2px solid color-mix(in srgb, var(--ch-accent, var(--stage-color)) 26%, white);
  border-left: 7px solid var(--ch-accent, var(--stage-color));
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--ch-accent, var(--stage-color)) 10%, transparent);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.chapter-card:hover { transform: translateY(-2px); }
.chapter-card.open {
  border-color: var(--ch-accent, var(--stage-color));
  box-shadow: 0 14px 34px color-mix(in srgb, var(--ch-accent, var(--stage-color)) 18%, transparent);
}
.chapter-head {
  width: 100%;
  border: none;
  background: linear-gradient(90deg, color-mix(in srgb, var(--ch-accent, var(--stage-color)) 9%, white), #ffffff 65%);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
}
.chapter-head:hover { background: linear-gradient(90deg, color-mix(in srgb, var(--ch-accent, var(--stage-color)) 16%, white), #ffffff 72%); }
.ch-left { display: flex; align-items: center; gap: 15px; min-width: 0; }
.ch-num {
  flex-shrink: 0;
  width: 52px; height: 52px;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--ch-accent, var(--stage-color)), color-mix(in srgb, var(--ch-accent, var(--stage-color)) 72%, #ffd43b));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 18px;
  box-shadow: 0 8px 16px color-mix(in srgb, var(--ch-accent, var(--stage-color)) 30%, transparent);
  transition: transform .25s ease;
}
.chapter-card.open .ch-num {
  transform: rotate(-5deg) scale(1.06);
}
.ch-titles h3 { margin: 0 0 2px; font-size: 17.5px; font-weight: 900; color: var(--ink); }
.ch-titles .ch-zh { font-size: 13px; font-weight: 700; color: var(--muted); }
.ch-right { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.strand-pill {
  font-size: 11.5px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
}
.strand-number { background: #e7f5ff; color: #1971c2; }
.strand-geometry { background: #e6fcf5; color: #099268; }
.strand-stats { background: #fff3bf; color: #b45309; }
.ch-meta-pill {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  background: #f8fafc;
  padding: 5px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.chev {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f1f5f9;
  color: var(--ink-2);
  font-size: 14px;
  transition: transform .22s ease;
}
.chapter-card.open .chev { transform: rotate(180deg); background: var(--stage-pastel); color: var(--stage-color); }

.chapter-body {
  display: none;
  padding: 4px 22px 22px;
  border-top: 1.5px dashed var(--line);
  background: #fcfdff;
}
.chapter-card.open .chapter-body { display: block; }
.sections-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-top: 16px;
}
.sec-card {
  position: relative;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.sec-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
  border-color: var(--stage-color);
}
.sec-card.done {
  border-color: #38d9a9;
  background: linear-gradient(180deg, #ffffff, #f2fff9);
}
.sec-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec-code {
  font-size: 12px;
  font-weight: 900;
  color: var(--stage-color);
  background: var(--stage-pastel);
  padding: 3px 10px;
  border-radius: 999px;
}
.sec-page { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.sec-title { font-weight: 900; font-size: 15px; color: var(--ink); line-height: 1.35; }
.sec-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.lo-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  background: #edf2ff;
  color: #364fc7;
}
.twm-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 8px;
  background: #f3f0ff;
  color: #6741d9;
}
.sec-idea {
  font-size: 12.5px;
  font-weight: 600;
  color: #1f4f3d;
  background: #ebfbee;
  border-left: 3.5px solid #20c997;
  padding: 8px 10px;
  border-radius: 0 10px 10px 0;
}
.sec-actions {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.btn-mini {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  transition: all .15s ease;
}
.btn-mini:hover { background: var(--stage-color); color: #fff; border-color: var(--stage-color); }
.btn-done {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1.5px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
}
.btn-done.checked {
  background: #fff3bf;
  color: #9c5700;
  border-color: #ffd43b;
}

/* ==================== DETAIL DRAWER ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 42, 71, 0.42);
  backdrop-filter: blur(4px);
  z-index: 80;
  display: none;
  justify-content: flex-end;
}
.drawer-backdrop.open { display: flex; }
.drawer {
  width: min(580px, 100vw);
  height: 100%;
  background: #fffefa;
  overflow-y: auto;
  padding: 26px 26px 40px;
  box-shadow: -16px 0 44px rgba(20, 42, 71, 0.18);
  animation: slideIn .24s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes slideIn {
  from { transform: translateX(36px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1.5px dashed var(--line);
  margin-bottom: 18px;
}
.drawer-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  font-size: 20px;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.drawer-block {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f8fbff;
  border: 1.5px solid var(--line);
}
.drawer-block h4 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.drawer-block p, .drawer-block li { margin: 0; font-size: 13.5px; color: var(--ink); }
.drawer-block ul { margin: 0; padding-left: 18px; }
.drawer-block.idea-box { background: #ebfbee; border-color: #b2f2bb; }
.drawer-block.misc-box { background: #fff5f5; border-color: #ffc9c9; }

footer {
  text-align: center;
  padding: 26px 20px 42px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--muted);
}

@media (max-width: 1024px) {
  .hero, .stage-hero { grid-template-columns: 1fr; padding: 26px 22px; }
  .books-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .books-grid, .sections-grid, .search-results { grid-template-columns: 1fr; }
  .chapter-head { flex-direction: column; align-items: flex-start; }
  .ch-right { justify-content: flex-start; }
}
