/* ============================================================
   新概念英语 · 学习模式 — 卡通可爱风 Stylesheet
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --pink: #ff6f9f;
  --teal: #2bb8a8;
  --yellow: #ffb02e;
  --purple: #8b7cf6;
  --pink-soft: #ffe3ef;
  --teal-soft: #d5f5ef;
  --yellow-soft: #fff1cf;
  --purple-soft: #ece7ff;
  --ink: #2b2f4b;
  --ink-soft: #6b7094;
  --ink-faint: #9aa0bd;
  --card: #ffffff;
  --card-border: #ffe3ef;
  --bg: linear-gradient(160deg, #eaf6ff 0%, #f6ecff 45%, #e6fbf1 100%);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow-card: 0 20px 50px rgba(120, 90, 200, 0.18);
  --shadow-pop: 0 8px 20px rgba(255, 111, 159, 0.4);
  --shadow-soft: 0 6px 16px rgba(43, 47, 75, 0.10);
}

[data-theme="dark"] {
  --pink-soft: #4a2738;
  --teal-soft: #1f3a39;
  --yellow-soft: #3a3220;
  --purple-soft: #2e2b4a;
  --ink: #eef0ff;
  --ink-soft: #b8bcd6;
  --ink-faint: #8a8fb0;
  --card: #262a45;
  --card-border: #3a3f63;
  --bg: linear-gradient(160deg, #14162b 0%, #1d1a36 45%, #14262a 100%);
  --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 6px 16px rgba(0, 0, 0, 0.4);
}

html, body { height: 100%; }

body {
  font-family: 'Fredoka', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   背景装饰
   ============================================================ */
.bg-decor { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(46px); opacity: 0.55; }
.b1 { width: 340px; height: 340px; background: #ffd3e6; top: -90px; left: -70px; animation: float 13s ease-in-out infinite; }
.b2 { width: 300px; height: 300px; background: #d0eaff; bottom: -80px; right: -50px; animation: float 15s ease-in-out infinite reverse; }
.b3 { width: 240px; height: 240px; background: #d8f6e9; top: 40%; left: -90px; animation: float 17s ease-in-out infinite; }
.b4 { width: 220px; height: 220px; background: #efe6ff; bottom: 10%; right: 8%; animation: float 14s ease-in-out infinite; }
[data-theme="dark"] .b1 { background: #4a2738; }
[data-theme="dark"] .b2 { background: #23314a; }
[data-theme="dark"] .b3 { background: #1f3a39; }
[data-theme="dark"] .b4 { background: #2e2b4a; }
.spark { position: absolute; font-size: 22px; opacity: 0.7; }
.s1 { top: 18%; left: 12%; animation: twinkle 4s ease-in-out infinite; }
.s2 { top: 30%; right: 14%; animation: twinkle 5s ease-in-out infinite 1s; }
.s3 { bottom: 22%; left: 22%; animation: twinkle 4.5s ease-in-out infinite 0.5s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(26px, -34px); }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 0.85; transform: scale(1.1); }
}

/* ============================================================
   布局
   ============================================================ */
#app {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  height: 100vh; max-width: 1080px; margin: 0 auto; padding: 0 20px;
}

/* --- 顶栏 --- */
.topbar {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 4px 12px; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mascot { font-size: 34px; line-height: 1; cursor: pointer; display: inline-block; transition: transform 0.3s; }
.mascot:hover { transform: rotate(-10deg) scale(1.2); }
.brand-txt h1 { font-size: 21px; font-weight: 700; letter-spacing: 0.5px; }
.brand-txt .sub { font-size: 12.5px; color: var(--ink-faint); }
.top-tools { display: flex; align-items: center; gap: 10px; }
.home-link, .theme-toggle {
  width: 40px; height: 40px; border-radius: 14px; border: 2px solid var(--card-border);
  background: var(--card); cursor: pointer; font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; transition: all 0.2s; box-shadow: var(--shadow-soft);
}
.home-link:hover, .theme-toggle:hover { transform: translateY(-2px); }
.continue-btn, .shelf-back-btn {
  border: none; font-weight: 600; padding: 9px 16px; border-radius: 999px;
  cursor: pointer; font-size: 13.5px; transition: all 0.2s; font-family: inherit;
}
.continue-btn { background: linear-gradient(135deg, var(--pink), var(--purple)); color: #fff; box-shadow: 0 6px 16px rgba(255, 111, 159, 0.35); }
.shelf-back-btn { background: var(--purple); color: #fff; box-shadow: 0 6px 14px rgba(139, 124, 246, 0.4); }
.continue-btn:hover, .shelf-back-btn:hover { transform: translateY(-2px) scale(1.03); }

/* ============================================================
   书架首页
   ============================================================ */
.shelf-view {
  flex: 1; width: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 20px; overflow-y: auto;
}
.shelf-title { text-align: center; margin-bottom: 56px; }
.shelf-title h2 { font-size: 28px; font-weight: 700; }
.shelf-title p { color: var(--ink-faint); font-size: 15px; margin-top: 6px; }

.shelf { position: relative; display: flex; align-items: flex-end; gap: 34px; padding: 20px 30px 24px; }
.book { border: none; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; transition: transform 0.25s; font-family: inherit; padding: 0; }
.book:not(.disabled):hover { transform: translateY(-14px); }
.book.disabled { opacity: 0.5; filter: grayscale(0.55); cursor: not-allowed; }
.book-cover {
  position: relative; width: 158px; height: 218px; border-radius: 8px 16px 16px 8px;
  background: var(--book-color); box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  display: flex; align-items: center; justify-content: center; padding: 18px; overflow: hidden;
}
.book-cover::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(0, 0, 0, 0.16));
  pointer-events: none;
}
.book-cover::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 15px;
  background: rgba(0, 0, 0, 0.18);
}
.book-body { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; color: #fff; }
.book-emoji { font-size: 36px; }
.book-name { font-size: 16px; font-weight: 700; line-height: 1.3; }
.book-meta { font-size: 12px; opacity: 0.9; }
.shelf-board {
  position: absolute; left: -20px; right: -20px; bottom: 0; height: 18px; border-radius: 9px;
  background: linear-gradient(#c89a63, #a97b49);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
}

/* ============================================================
   学习视图
   ============================================================ */
.learn-view { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; }

.book-name { font-size: 19px; font-weight: 700; padding: 6px 0 2px; flex-shrink: 0; }
.book-name .bk-emoji { margin-right: 6px; }

.selector { width: 100%; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; padding: 4px 0 8px; }
.book-tabs { display: flex; gap: 8px; justify-content: center; }
.book-tab {
  padding: 8px 22px; border-radius: 999px; border: 2px solid transparent; cursor: pointer;
  font-size: 15px; font-weight: 600; background: var(--card); color: var(--ink-soft);
  box-shadow: var(--shadow-soft); transition: all 0.2s; font-family: inherit;
}
.book-tab:hover { transform: translateY(-2px); }
.book-tab.active { background: var(--pink); color: #fff; border-color: #fff; }
.lesson-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: thin; width: 100%; }
.lesson-chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 999px; border: 2px solid var(--card-border);
  background: var(--card); cursor: pointer; color: var(--ink-soft); font-size: 13.5px;
  transition: all 0.15s; font-family: inherit; white-space: nowrap;
}
.lesson-chip:hover { border-color: var(--pink); }
.lesson-chip.active { background: var(--teal); color: #fff; border-color: #fff; }
.lesson-chip:not(.has-content) { opacity: 0.4; }
.lesson-chip .ln { font-weight: 700; font-variant-numeric: tabular-nums; }
.lesson-strip::-webkit-scrollbar { height: 6px; }
.lesson-strip::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 6px; }
.lesson-empty { text-align: center; color: var(--ink-faint); font-size: 13px; padding: 6px; width: 100%; }

.stepper { display: flex; gap: 8px; justify-content: center; padding: 6px 0; flex-shrink: 0; }
.step {
  display: flex; align-items: center; gap: 6px; padding: 8px 20px;
  border-radius: 999px; border: 2px solid var(--card-border); background: var(--card);
  cursor: pointer; color: var(--ink-soft); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-soft); transition: all 0.2s; font-family: inherit;
}
.step:hover { transform: translateY(-2px); }
.step.active { background: var(--purple); color: #fff; border-color: #fff; }
.step.done { color: var(--teal); border-color: var(--teal); }
.step-icon { font-size: 15px; }

/* ============================================================
   卡片区
   ============================================================ */
.stage {
  flex: 1; min-height: 0; width: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 10px 34px 26px; overflow-y: auto;
}

.card-wrap { position: relative; width: min(680px, 94vw); max-height: 100%; }
.card-wrap.wide { width: min(800px, 96vw); }
.card {
  width: 100%;
  background: var(--card); border: 3px solid var(--card-border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-card);
  padding: 30px 34px 26px; animation: pop 0.4s ease;
}
.card.card-wide { max-height: 100%; overflow-y: auto; }
@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.card-title { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-count { font-size: 14px; color: var(--ink-faint); font-weight: 500; margin-left: 4px; }
.card-hint { font-size: 13px; color: var(--ink-faint); }

.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 54px; height: 54px; border-radius: 50%; border: 3px solid #fff;
  cursor: pointer; font-size: 28px; line-height: 1; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: var(--pink); color: #fff; box-shadow: var(--shadow-pop);
  transition: all 0.2s;
}
.nav-arrow:hover { transform: translateY(-50%) scale(1.12); }
.nav-arrow:disabled { opacity: 0.3; cursor: not-allowed; }
.nav-prev { left: -24px; }
.nav-next { right: -24px; }

.card-body { display: flex; flex-direction: column; gap: 14px; }

/* --- 单词翻面卡 --- */
.flashcard { width: 100%; height: 320px; perspective: 1100px; cursor: pointer; }
.flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform 0.5s; transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0; border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  backface-visibility: hidden; padding: 24px;
}
.flashcard-front { background: linear-gradient(140deg, var(--pink-soft), var(--card)); border: 2px solid var(--card-border); }
.flashcard-back { background: linear-gradient(140deg, var(--teal-soft), var(--card)); border: 2px solid var(--card-border); transform: rotateY(180deg); }
.word { font-size: 48px; font-weight: 700; letter-spacing: 0.5px; }
.ipa { font-size: 20px; color: var(--ink-soft); }
.pos {
  display: inline-block; padding: 1px 10px; border-radius: 999px;
  background: var(--purple-soft); color: var(--purple);
  font-size: 13px; font-weight: 600; line-height: 1.6;
}
.meaning { font-size: 32px; font-weight: 600; color: var(--teal); text-align: center; }
.word-sm { font-size: 15px; color: var(--ink-faint); }

/* --- 句子卡 --- */
.sentence-card {
  border-radius: var(--radius-lg); border: 2px solid var(--card-border);
  background: linear-gradient(140deg, var(--purple-soft), var(--card));
  padding: 22px 24px; cursor: pointer; display: flex; flex-direction: column; gap: 12px;
}
.sentence-en { font-size: 23px; line-height: 1.6; font-weight: 500; }
.sentence-zh { display: none; font-size: 17px; color: var(--ink-soft); border-top: 1px dashed var(--card-border); padding-top: 12px; }
.sentence-card.revealed .sentence-zh,
.sentence-card.zh-only .sentence-zh { display: block; }
.write-hint { font-size: 14px; color: var(--pink); font-weight: 600; }

/* --- 表达卡 --- */
.expr-card {
  border-radius: var(--radius-lg); border: 2px solid var(--card-border);
  background: linear-gradient(140deg, var(--yellow-soft), var(--card));
  padding: 24px; cursor: pointer; display: flex; flex-direction: column; gap: 16px;
}
.expr-en { font-size: 28px; font-weight: 700; color: var(--pink); }
.expr-zh { display: none; font-size: 18px; }
.expr-example { display: none; font-size: 16px; color: var(--ink-soft); font-style: italic; }
.expr-card.revealed .expr-zh, .expr-card.revealed .expr-example { display: block; }
.eg-label { display: inline-block; background: var(--yellow); color: #5a3d00; border-radius: 6px; font-size: 12px; padding: 1px 7px; margin-right: 8px; font-style: normal; }

/* --- 模式切换 --- */
.mode-toggle { display: inline-flex; gap: 4px; background: var(--purple-soft); border-radius: 999px; padding: 4px; }
.mode-btn { padding: 6px 16px; border: none; background: none; border-radius: 999px; cursor: pointer; font-size: 13px; color: var(--ink-soft); font-family: inherit; font-weight: 500; }
.mode-btn.active { background: var(--card); color: var(--purple); font-weight: 600; box-shadow: var(--shadow-soft); }

/* --- 列表模式 --- */
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.word-chip { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--pink-soft); }
.chip-en { font-weight: 700; font-size: 16px; }
.chip-ipa { font-size: 13px; color: var(--ink-faint); }
.chip-zh { font-size: 14px; color: var(--ink-soft); }
.expr-list { display: flex; flex-direction: column; gap: 12px; }
.expr-row { padding: 15px 18px; border-radius: var(--radius-md); background: var(--yellow-soft); display: flex; flex-direction: column; gap: 6px; }
.expr-row-en { font-weight: 700; color: var(--pink); font-size: 16px; }
.expr-row-zh { font-size: 15px; }
.expr-row-ex { font-size: 14px; color: var(--ink-faint); font-style: italic; }

/* --- 抄写 / 默写 --- */
.dictation { border-top: 2px dashed var(--card-border); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.dict-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dict-input {
  width: 100%; padding: 13px 15px; border-radius: var(--radius-md);
  border: 2px solid var(--card-border); background: var(--card); color: var(--ink);
  font-size: 17px; font-family: inherit; resize: vertical; min-height: 68px;
}
.dict-input:focus { outline: none; border-color: var(--pink); }
.dict-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.dict-check {
  padding: 10px 22px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--teal); color: #fff; font-size: 15px; font-weight: 600; transition: all 0.2s; font-family: inherit;
}
.dict-check:hover { transform: translateY(-2px); }
.dict-result { font-size: 16px; line-height: 2; padding: 12px 16px; border-radius: var(--radius-md); background: var(--purple-soft); }
.dict-result .ok { color: var(--teal); font-weight: 600; }
.dict-result .bad { color: #e5484d; font-weight: 700; text-decoration: underline; }
.dict-score { font-size: 14px; color: var(--ink-soft); }

/* --- 全文 + 卡拉 OK --- */
.full-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.audio-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex: 1; min-width: 220px; }
.audio-box audio { flex: 1; min-width: 220px; }
.audio-label { font-size: 14px; color: var(--ink-soft); font-weight: 600; }
.audio-controls { display: flex; align-items: center; gap: 8px; }
.speed-select {
  padding: 6px 10px; border-radius: 8px; border: 2px solid var(--card-border);
  background: var(--card); color: var(--ink); font-size: 13px; font-family: inherit; cursor: pointer;
}
.full-text { display: flex; flex-direction: column; gap: 6px; }
.full-text.hide-zh .sentence-line .z { display: none; }
.sentence-line { padding: 10px 14px; border-radius: 10px; font-size: 17px; line-height: 1.7; transition: all 0.15s; }
.sentence-line .e { display: block; }
.sentence-line .z { display: block; font-size: 15px; color: var(--ink-soft); margin-top: 2px; }
.sentence-line.active { background: var(--pink-soft); box-shadow: inset 0 0 0 2px var(--pink); }

/* --- 完成视图 --- */
.done-view { text-align: center; display: flex; flex-direction: column; gap: 18px; align-items: center; padding: 28px 10px; }
.done-emoji { font-size: 60px; animation: bounce 1.2s ease-in-out infinite; }
.done-view h2 { font-size: 24px; }
.done-view p { color: var(--ink-soft); font-size: 15px; }
.done-actions { display: flex; gap: 12px; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* --- 通用按钮 --- */
.btn { padding: 11px 24px; border-radius: 999px; border: 2px solid var(--card-border); cursor: pointer; font-size: 15px; font-weight: 600; background: var(--card); color: var(--ink); transition: all 0.2s; font-family: inherit; }
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--pink); color: #fff; border-color: var(--pink); }
.btn-ghost { color: var(--ink-soft); }
.btn-sm { padding: 6px 14px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.btn.active { background: var(--purple); color: #fff; border-color: var(--purple); }

/* --- Toast --- */
.toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--card); padding: 12px 24px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow-card); z-index: 999;
}

/* --- 响应式 --- */
@media (max-width: 640px) {
  .brand-txt h1 { font-size: 17px; }
  .mascot { font-size: 26px; }
  .nav-prev { left: -8px; }
  .nav-next { right: -8px; }
  .nav-arrow { width: 44px; height: 44px; font-size: 24px; }
  .word { font-size: 34px; }
  .sentence-en { font-size: 18px; }
  .book-cover { width: 120px; height: 170px; }
  .shelf { gap: 18px; }
}
