:root {
  --bg: #FFF9F2;
  --bg-2: #FFF3E6;
  --card: #FFFFFF;
  --primary: #E85D3D;
  --primary-2: #C9472B;
  --primary-soft: #FFE8E0;
  --text: #2B2118;
  --text-2: #6B5F55;
  --muted: #9A8F86;
  --line: #F0E6DC;
  --green: #2E7D5B;
  --green-soft: #E6F4EE;
  --gold: #B8860B;
  --gold-soft: #FFF4D6;
  --shadow: 0 2px 12px rgba(120, 80, 50, .08);
  --shadow-lg: 0 8px 28px rgba(120, 80, 50, .14);
  --r: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100vh; min-height: 100dvh; }
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
h1, h2, h3, p { margin: 0; }

/* ============ 启动页 ============ */
.splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(165deg, #FFF6EC 0%, #FFE3D2 55%, #FFD3BC 100%);
  z-index: 100;
  transition: opacity .45s ease, transform .45s ease;
}
.splash.hide { opacity: 0; transform: scale(1.04); pointer-events: none; }

.splash-inner { text-align: center; padding: 0 28px; }

.splash-badge {
  display: inline-block;
  font-size: 12px; letter-spacing: 3px;
  color: var(--primary-2);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(232,93,61,.18);
  padding: 6px 14px; border-radius: 999px;
  margin-bottom: 22px;
}

.splash-title {
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 800;
  letter-spacing: 1px;
  color: #3A2418;
  line-height: 1.28;
}

.splash-sub {
  margin-top: 10px;
  font-size: clamp(15px, 4.2vw, 18px);
  color: #8A5A3C;
  letter-spacing: 2px;
}

.splash-tip {
  margin-top: 26px;
  font-size: 13px;
  color: #A98A75;
  letter-spacing: 1px;
}

.enter-btn {
  position: absolute;
  bottom: max(46px, env(safe-area-inset-bottom, 46px));
  left: 50%; transform: translateX(-50%);
  width: 68px; height: 68px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 10px 30px rgba(200, 90, 50, .28), 0 2px 6px rgba(200,90,50,.12);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
}
.enter-btn:active { transform: translateX(-50%) scale(.92); }
.enter-btn svg { width: 28px; height: 28px; stroke: var(--primary); stroke-width: 2.4; fill: none; }

/* 呼吸光圈 */
.enter-btn::after {
  content: ""; position: absolute; inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(232,93,61,.28);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(.92); opacity: .9; }
  70% { transform: scale(1.22); opacity: 0; }
  100% { opacity: 0; }
}

/* ============ 主框架 ============ */
.app { max-width: 760px; margin: 0 auto; padding-bottom: 84px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 12px;
  background: rgba(255,249,242,.88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.level-pill {
  font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
  background: var(--gold-soft); color: var(--gold);
}
.level-pill.lv2 { background: #E4F0FF; color: #2563A8; }
.level-pill.lv3 { background: var(--green-soft); color: var(--green); }

main { padding: 16px 18px 24px; }

/* ============ 首页 ============ */
.hero {
  background: linear-gradient(135deg, #FFF1E6, #FFE0CF);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.hero h2 { font-size: 19px; font-weight: 800; color: #3A2418; }
.hero p { margin-top: 6px; font-size: 13px; color: #8A6A55; line-height: 1.6; }

.progress-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.progress-bar {
  flex: 1; height: 8px; border-radius: 99px;
  background: rgba(255,255,255,.75); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #F08A5D, var(--primary));
  transition: width .5s cubic-bezier(.22,.8,.35,1);
}
.progress-num { font-size: 12px; font-weight: 700; color: var(--primary-2); min-width: 46px; text-align: right; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 2px 12px;
  font-size: 15px; font-weight: 700; color: var(--text);
}
.section-title span { font-size: 12px; font-weight: 400; color: var(--muted); }

.cat-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 620px) { .cat-grid { grid-template-columns: 1fr 1fr; } }

.cat-card {
  position: relative;
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--card);
  border-radius: var(--r);
  padding: 16px 16px 15px;
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .16s ease, box-shadow .16s ease;
  width: 100%;
}
.cat-card:active { transform: scale(.985); }
.cat-card:hover { box-shadow: var(--shadow-lg); }

.cat-emoji {
  width: 46px; height: 46px; flex: 0 0 46px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; border-radius: 14px;
  background: var(--bg-2);
}
.cat-body { flex: 1; min-width: 0; }
.cat-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cat-desc { margin-top: 4px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.cat-meta { margin-top: 8px; font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; }

.cat-card.locked { opacity: .62; }
.cat-card.locked .cat-emoji { filter: grayscale(1); }
.lock-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  background: #EFE8E1; color: #8A7F76;
  padding: 3px 8px; border-radius: 999px;
}

.dot-done { color: var(--green); }

/* ============ 列表页 ============ */
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.back-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 16px; color: var(--text);
}
.page-title { font-size: 18px; font-weight: 800; }
.page-sub { margin: 8px 2px 14px; font-size: 12.5px; color: var(--muted); }

.item {
  background: var(--card);
  border-radius: 15px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.item-main {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 15px;
  width: 100%; text-align: left;
}
.item-text { flex: 1; min-width: 0; }
.item-yue { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.item-jp { margin-top: 3px; font-size: 12px; color: var(--primary-2); font-family: ui-monospace, Menlo, monospace; }
.item-cn { margin-top: 3px; font-size: 13px; color: var(--text-2); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--muted);
  background: transparent; flex: 0 0 34px;
}
.icon-btn.on { color: var(--primary); }
.icon-btn.done { color: var(--green); }

.item-detail {
  display: none;
  padding: 0 15px 15px;
  border-top: 1px dashed var(--line);
  margin-top: 2px;
  padding-top: 12px;
}
.item.open .item-detail { display: block; }

.note {
  font-size: 13px; color: var(--text-2); line-height: 1.65;
  background: var(--bg-2); border-radius: 10px;
  padding: 10px 12px;
}
.ex { margin-top: 10px; font-size: 13px; line-height: 1.7; }
.ex-label { font-size: 11px; color: var(--muted); letter-spacing: 1px; margin-bottom: 4px; }
.ex-yue { font-weight: 600; }
.ex-jp { font-size: 12px; color: var(--primary-2); font-family: ui-monospace, Menlo, monospace; }
.ex-cn { color: var(--text-2); }

.detail-actions { display: flex; gap: 8px; margin-top: 12px; }
.pill-btn {
  flex: 1;
  padding: 10px; border-radius: 11px;
  font-size: 13px; font-weight: 600;
  background: var(--bg-2); color: var(--text-2);
}
.pill-btn.primary { background: var(--primary); color: #fff; }
.pill-btn.ok { background: var(--green-soft); color: var(--green); }

/* ============ 我的 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 20px; }
.stat {
  background: var(--card); border-radius: 15px; padding: 16px 12px;
  text-align: center; box-shadow: var(--shadow);
}
.stat-num { font-size: 24px; font-weight: 800; color: var(--primary-2); }
.stat-label { margin-top: 4px; font-size: 11.5px; color: var(--muted); }

.level-card {
  background: var(--card); border-radius: var(--r); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.level-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.level-name { font-size: 15px; font-weight: 700; }
.level-tag { font-size: 11px; padding: 3px 9px; border-radius: 99px; background: var(--bg-2); color: var(--text-2); }

.reset-btn {
  width: 100%; padding: 13px; border-radius: 13px;
  background: var(--card); color: #B4451F;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
}

/* ============ 底部导航 ============ */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex;
  max-width: 760px; margin: 0 auto;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab {
  flex: 1; padding: 11px 0 13px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab.active { color: var(--primary); }
.tab .ico { font-size: 18px; line-height: 1; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(10px);
  background: rgba(43,33,24,.92); color: #fff;
  font-size: 13px; padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 200;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 空状态 */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.empty .big { font-size: 40px; display: block; margin-bottom: 12px; }

/* ============ 故事卡片 ============ */
.story-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.story-head { margin-bottom: 12px; }
.story-title { font-size: 19px; font-weight: 800; letter-spacing: .5px; }
.story-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }

.story-line { padding: 11px 0; border-bottom: 1px dashed var(--line); }
.story-line:last-child { border-bottom: none; }
.story-yue {
  font-size: 15.5px; line-height: 1.75; font-weight: 600;
  cursor: pointer;
}
.story-yue:active { color: var(--primary); }
.story-cn { margin-top: 5px; font-size: 13px; color: var(--text-2); line-height: 1.65; }

.story-actions { display: flex; gap: 8px; margin-top: 14px; }

.story-words { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.word-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 4px; border-radius: 8px;
  cursor: pointer;
}
.word-row:active { background: var(--bg-2); }
.w-yue { font-weight: 700; font-size: 14.5px; min-width: 62px; }
.w-jp { font-size: 11.5px; color: var(--primary-2); font-family: ui-monospace, Menlo, monospace; flex: 1; }
.w-cn { font-size: 12.5px; color: var(--text-2); }

/* 发音提示条 */
.speak-hint {
  display: flex; align-items: center; gap: 8px;
  background: var(--green-soft); color: var(--green);
  font-size: 12.5px; padding: 9px 13px; border-radius: 12px;
  margin-bottom: 12px; line-height: 1.5;
}

/* 列表里的播放键 & 已学会标记 */
.icon-btn.play {
  font-size: 17px;
  color: var(--primary);
  background: var(--primary-soft);
}
.icon-btn.play:active { transform: scale(.9); }
.learned-dot { color: var(--green); font-size: 12px; margin-right: 5px; font-weight: 700; }

/* 播放三角图标 */
.icon-btn.play svg { width: 15px; height: 15px; fill: currentColor; display: block; }
.pill-btn .btn-ico { width: 14px; height: 14px; fill: currentColor; vertical-align: -2px; margin-right: 4px; }
