* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Comic Sans MS", cursive, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  background: #f0e0f0;
}
.bg-deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.floating { position: absolute; animation: floatAnim 6s ease-in-out infinite; font-size: 36px; opacity: 0.3; }
.floating:nth-child(1) { top: 8%; left: 5%; animation-delay: 0s; }
.floating:nth-child(2) { top: 20%; right: 8%; animation-delay: 1.2s; }
.floating:nth-child(3) { top: 60%; left: 3%; animation-delay: 2.5s; }
.floating:nth-child(4) { top: 80%; right: 5%; animation-delay: 0.5s; }
.floating:nth-child(5) { top: 12%; left: 50%; animation-delay: 3.5s; }
.floating:nth-child(6) { top: 55%; left: 85%; animation-delay: 1.8s; }
.floating:nth-child(7) { top: 90%; left: 30%; animation-delay: 2.8s; }
.floating:nth-child(8) { top: 35%; left: 15%; animation-delay: 4s; }
@keyframes floatAnim {
  0%,100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-12px) rotate(3deg); }
  50% { transform: translateY(-6px) rotate(-2deg); }
  75% { transform: translateY(-16px) rotate(4deg); }
}
#app {
  width: 100vw; height: 100vh;
  display: flex; flex-direction: column;
  position: relative; z-index: 1;
  background: linear-gradient(170deg, #fff5f9 0%, #f0f4ff 40%, #fef9f0 100%);
}
.page { display: none; flex: 1; flex-direction: column; overflow: hidden; position: relative; }
.page.active { display: flex; }
.setup-header { text-align: center; padding: 36px 0 0; }
.setup-header-emoji { font-size: 64px; display: block; margin-bottom: 8px; animation: bounce 2s ease-in-out infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.setup-header-text { font-size: 38px; font-weight: 900; background: linear-gradient(135deg,#f093fb,#667eea,#43e97b); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: 6px; }
.setup-subtitle { text-align: center; font-size: 17px; color: #c09abf; margin: 8px 0 20px; font-weight: 600; }
.setup-card { flex: 1; overflow-y: auto; padding: 0 24px 40px; max-width: 600px; margin: 0 auto; width: 100%; }
.setup-card::-webkit-scrollbar { display: none; }
.setup-section { margin-bottom: 18px; }
.setup-label { font-size: 16px; font-weight: 800; color: #7c6f9e; margin-bottom: 10px; }
.setup-options { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.setup-opt { padding: 18px 10px; border-radius: 20px; border: 3px solid #f0e6f6; background: #fff; text-align: center; font-size: 17px; font-weight: 700; cursor: pointer; transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1); box-shadow: 0 3px 12px rgba(102,126,234,0.08); }
.setup-opt:active { transform: scale(0.92); }
.setup-opt.selected { border-color: #667eea; background: linear-gradient(135deg,#eef2ff,#fce4ec); color: #5a4fcf; box-shadow: 0 6px 24px rgba(102,126,234,0.2); transform: scale(1.02); }
.setup-opt .opt-emoji { font-size: 36px; display: block; margin-bottom: 6px; }
.setup-confirm { display: block; width: 100%; padding: 20px; border: none; border-radius: 24px; background: linear-gradient(135deg,#f093fb,#f5576c,#667eea); background-size: 200% 200%; animation: gradShift 3s ease infinite; color: #fff; font-size: 24px; font-weight: 800; cursor: pointer; margin-top: 24px; box-shadow: 0 8px 32px rgba(240,147,251,0.3); letter-spacing: 2px; }
@keyframes gradShift { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
.setup-confirm:active { transform: scale(0.95); }
.setup-confirm:disabled { opacity: 0.35; cursor: default; box-shadow: none; animation: none; transform: none; }
.top-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; background: rgba(255,255,255,0.7); backdrop-filter: blur(16px); border-bottom: 2px solid rgba(255,200,220,0.3); flex-shrink: 0; z-index: 10; }
.top-title { font-size: 20px; font-weight: 800; color: #5a4fcf; letter-spacing: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 8px; }
.top-btn { background: linear-gradient(135deg,#fce4ec,#f3e5f5); border: none; font-size: 22px; cursor: pointer; padding: 8px 14px; border-radius: 14px; transition: all 0.2s; line-height: 1; box-shadow: 0 2px 8px rgba(0,0,0,0.04); flex-shrink: 0; }
.top-btn:active { transform: scale(0.9); }
.main-landscape { flex: 1; display: flex; overflow: hidden; padding: 16px; gap: 16px; }
.main-left { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.main-right { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.main-right::-webkit-scrollbar { display: none; }
@media (max-width: 680px) {
  .main-landscape { flex-direction: column; align-items: center; }
  .main-left { width: 100%; max-width: 300px; }
}
.cover-img { width: 100%; height: auto; border-radius: 16px; box-shadow: 8px 8px 32px rgba(0,0,0,0.15); display: block; }
.cover-btn { padding: 16px; border: none; border-radius: 18px; font-size: 18px; font-weight: 800; cursor: pointer; transition: all 0.15s cubic-bezier(0.34,1.56,0.64,1); text-align: center; letter-spacing: 1px; }
.cover-btn:active { transform: scale(0.94); }
.catalog-btn { background: #fff; color: #5a4fcf; box-shadow: 0 4px 16px rgba(0,0,0,0.06); border: 2px solid #e8e0f0; }
.reader-btn { background: linear-gradient(135deg,#667eea,#845ec2); color: #fff; box-shadow: 0 6px 24px rgba(102,126,234,0.25); }
.plan-card { background: linear-gradient(135deg, #ff6f91, #ff9671); border-radius: 24px; padding: 24px; color: #fff; box-shadow: 0 8px 40px rgba(255,111,145,0.2); position: relative; overflow: hidden; }
.plan-card::before { content: ''; position: absolute; top: -30px; right: -30px; width: 100px; height: 100px; background: radial-gradient(circle,rgba(255,255,255,0.15) 0%,transparent 70%); border-radius: 50%; }
.plan-card::after { content: '🌟'; position: absolute; top: 10px; right: 14px; font-size: 24px; opacity: 0.4; animation: sparkle 3s ease-in-out infinite; }
@keyframes sparkle { 0%,100% { transform:scale(1) rotate(0deg); opacity:0.4; } 50% { transform:scale(1.2) rotate(15deg); opacity:0.7; } }
.plan-header { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.plan-progress { height: 12px; background: rgba(255,255,255,0.25); border-radius: 6px; overflow: hidden; margin-bottom: 12px; }
.plan-progress-bar { height: 100%; background: linear-gradient(90deg,#f9f871,#ffc75f); border-radius: 6px; transition: width 0.6s cubic-bezier(0.34,1.56,0.64,1); width: 0%; position: relative; }
.plan-progress-bar::after { content: '🚀'; position: absolute; right: -18px; top: -8px; font-size: 18px; }
.plan-info { font-size: 15px; opacity: 0.95; margin-bottom: 16px; line-height: 1.7; }
.plan-actions { display: flex; gap: 10px; }
.plan-action-btn { flex: 1; padding: 14px 8px; border: none; border-radius: 16px; font-size: 16px; font-weight: 800; cursor: pointer; transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1); letter-spacing: 1px; }
.plan-action-btn:active { transform: scale(0.92); }
.plan-action-btn.primary { background: #fff; color: #d65db1; box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.plan-action-btn.secondary { background: rgba(255,255,255,0.2); color: #fff; border: 2px solid rgba(255,255,255,0.3); }
.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat-box { background: #fff; border-radius: 20px; padding: 16px 8px; text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,0.04); position: relative; overflow: hidden; }
.stat-box::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.stat-box.pink::before { background: linear-gradient(90deg,#ff6f91,#d65db1); }
.stat-box.orange::before { background: linear-gradient(90deg,#ff9671,#ffc75f); }
.stat-box.green::before { background: linear-gradient(90deg,#00c9a7,#43e97b); }
.stat-num { font-size: 32px; font-weight: 900; display: block; line-height: 1.2; }
.stat-label { font-size: 13px; color: #999; margin-top: 2px; font-weight: 600; }
.stat-box.pink .stat-num { color: #d65db1; }
.stat-box.orange .stat-num { color: #ff9671; }
.stat-box.green .stat-num { color: #00c9a7; }
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.overlay.open { display: flex; }
.overlay-content { background: #fff; border-radius: 28px; width: 90%; max-width: 500px; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 20px 80px rgba(0,0,0,0.2); overflow: hidden; animation: slideUp 0.3s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.overlay-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; background: linear-gradient(135deg,#f8f4ff,#fce4ec); font-size: 18px; font-weight: 800; color: #5a4fcf; }
.overlay-close { background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 10px; color: #999; }
.overlay-close:active { background: rgba(0,0,0,0.05); }
.overlay-body { flex: 1; overflow-y: auto; padding: 16px 20px 20px; }
.overlay-body::-webkit-scrollbar { display: none; }
.cat-chapter { margin-bottom: 12px; background: #faf8ff; border-radius: 14px; padding: 12px 14px; }
.cat-ch-title { font-size: 15px; font-weight: 700; color: #5a4fcf; margin-bottom: 6px; }
.cat-section { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 8px 14px; border-top: 1px solid #f0eaf5; font-size: 14px; color: #666; cursor: pointer; border-radius: 8px; }
.cat-section:first-of-type { border-top: none; }
.cat-section:active { background: #f0eaff; }
.cat-section .cat-sec-title { flex: 1; }
.cat-status { font-size: 14px; flex-shrink: 0; }
.cat-status.done { opacity: 1; color: #00c9a7; }
.cat-status.pend { opacity: 0.4; }
.cat-status.cur { color: #667eea; font-weight: 700; }

/* ============ Chapter Page ============ */
.ch-tabs { display: flex; flex-shrink: 0; background: #fff; border-bottom: 2px solid #f0eaf5; padding: 0 12px; }
.ch-tab { flex: 1; padding: 12px 4px; border: none; background: none; font-size: 14px; font-weight: 700; color: #b8a8d0; cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.2s; }
.ch-tab.active { color: #5a4fcf; border-bottom-color: #667eea; }
.ch-tab:active { opacity: 0.7; }
.ch-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.ch-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.ch-panel.active { display: flex; }

/* Reader tab */
.pdf-wrapper { flex: 1; overflow: hidden; background: #f5f0f8; display: flex; }
.pdf-wrapper.full { background: #fff; }
.pdf-frame { width: 100%; height: 100%; border: none; }
.pdf-frame.reader-frame { height: 100vh; }
.pdf-fallback { flex-shrink: 0; text-align: center; padding: 12px; font-size: 14px; color: #999; background: #faf8ff; }
.pdf-fallback a { color: #667eea; font-weight: 700; }

/* Knowledge Points tab */
.kp-list { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.kp-list::-webkit-scrollbar { display: none; }
.kp-item { background: #fff; border-radius: 16px; padding: 16px 18px; box-shadow: 0 3px 12px rgba(0,0,0,0.04); border-left: 5px solid #667eea; display: flex; align-items: flex-start; gap: 12px; }
.kp-num { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg,#667eea,#845ec2); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; flex-shrink: 0; }
.kp-text { font-size: 15px; color: #444; line-height: 1.6; }
.kp-tip { background: linear-gradient(135deg,#fff5f5,#fff8e1); border-radius: 14px; padding: 16px 20px; margin: 0 20px 12px; font-size: 14px; color: #c06b5a; border: 1px solid #ffe0cc; }
.kp-tip::before { content: '💡 给家长的提示：'; font-weight: 700; display: block; margin-bottom: 4px; }
.done-btn { display: block; width: calc(100% - 40px); margin: 0 20px 16px; padding: 16px; border: none; border-radius: 18px; background: linear-gradient(135deg,#00c9a7,#43e97b); color: #fff; font-size: 18px; font-weight: 800; cursor: pointer; box-shadow: 0 6px 24px rgba(0,201,167,0.25); flex-shrink: 0; }
.done-btn:active { transform: scale(0.95); }

/* Practice tab */
.p-scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; align-items: flex-start; justify-content: center; }
.p-scroll::-webkit-scrollbar { display: none; }
.quiz-visual { text-align: center; font-size: 28px; margin-bottom: 16px; padding: 16px; background: linear-gradient(135deg,#fff5f9,#f0f4ff); border-radius: 14px; line-height: 1.8; letter-spacing: 4px; }

/* ============ Reader (full) ============ */
.reader-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: linear-gradient(135deg,#2d1b4e,#1a1a2e); color: #fff; font-size: 13px; flex-shrink: 0; }

/* ============ Quiz ============ */
.quiz-scroll { flex: 1; overflow-y: auto; padding: 24px; display: flex; align-items: flex-start; justify-content: center; }
.quiz-card { background: #fff; border-radius: 28px; padding: 36px 32px; box-shadow: 0 8px 40px rgba(0,0,0,0.06); max-width: 540px; width: 100%; border: 2px solid #f0e6f6; }
.quiz-progress { font-size: 14px; color: #b8a8d0; margin-bottom: 20px; font-weight: 700; }
.quiz-progress::before { content: '🎯 '; }
.quiz-question { font-size: 24px; font-weight: 800; color: #5a4fcf; margin-bottom: 16px; line-height: 1.5; padding: 20px; background: linear-gradient(135deg,#f8f4ff,#fce4ec); border-radius: 16px; text-align: center; }
.quiz-options { display: flex; flex-direction: column; gap: 12px; }
.quiz-opt { padding: 18px 24px; border: 3px solid #f0e6f6; border-radius: 18px; font-size: 20px; font-weight: 700; background: #fff; cursor: pointer; text-align: left; transition: all 0.15s cubic-bezier(0.34,1.56,0.64,1); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.quiz-opt:active { transform: scale(0.96); }
.quiz-opt.correct { border-color: #00c9a7; background: #e6fff5; color: #00c9a7; box-shadow: 0 4px 20px rgba(0,201,167,0.2); }
.quiz-opt.wrong { border-color: #ff6f91; background: #fff0f5; color: #ff6f91; box-shadow: 0 4px 20px rgba(255,111,145,0.2); }
.quiz-opt.reveal { border-color: #00c9a7; background: #e6fff5; color: #00c9a7; }
.quiz-feedback { text-align: center; font-size: 22px; font-weight: 800; margin-top: 16px; padding: 16px; border-radius: 18px; animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes popIn { 0% { transform:scale(0.8); opacity:0; } 100% { transform:scale(1); opacity:1; } }
.quiz-feedback.correct { background: #e6fff5; color: #00c9a7; }
.quiz-feedback.wrong { background: #fff0f5; color: #ff6f91; }
.wrong-item { background: #fff; border-radius: 18px; padding: 18px 20px; margin-bottom: 12px; box-shadow: 0 3px 12px rgba(0,0,0,0.04); border-left: 5px solid #ff6f91; }
.wrong-q { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: #5a4fcf; }
.wrong-a { font-size: 14px; color: #00c9a7; font-weight: 600; }
.wrong-date { font-size: 12px; color: #ccc; margin-top: 6px; }
.empty-state { text-align: center; padding: 80px 20px; color: #c09abf; font-size: 18px; font-weight: 600; }
.empty-state .empty-icon { font-size: 64px; display: block; margin-bottom: 16px; }
.bottom-nav { display: flex; background: rgba(255,255,255,0.9); backdrop-filter: blur(16px); border-top: 2px solid rgba(255,200,220,0.3); padding: 4px 0; padding-bottom: max(4px,env(safe-area-inset-bottom)); flex-shrink: 0; z-index: 10; }
.nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; border: none; background: none; cursor: pointer; padding: 6px 0; opacity: 0.4; transition: all 0.2s; position: relative; border-radius: 12px; margin: 0 2px; }
.nav-btn.active { opacity: 1; background: linear-gradient(135deg,rgba(240,147,251,0.08),rgba(102,126,234,0.08)); }
.nav-icon { font-size: 24px; line-height: 1; }
.nav-label { font-size: 11px; color: #7c6f9e; margin-top: 2px; font-weight: 700; }
@keyframes fadeUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.plan-card, .stat-box, .cover-img, .cover-btn { animation: fadeUp 0.5s cubic-bezier(0.34,1.56,0.64,1); }
.catalog-btn { animation-delay: 0.08s; }
.reader-btn { animation-delay: 0.15s; }
@media (min-width: 1100px) {
  body { display: flex; justify-content: center; align-items: center; background: #e8d8e8; }
  #app { max-width: 1200px; height: 95vh; border-radius: 32px; box-shadow: 0 16px 80px rgba(132,94,194,0.15); }
}
