:root {
  --bg: #fff7f3;
  --card: #ffffff;
  --ink: #3d2c28;
  --muted: #9d8a86;
  --accent: #ff7fa3;
  --accent-soft: #ffe4ec;
  --accent2: #ffb26b;
  --accent2-soft: #fff0dd;
  --line: #f3e6e0;
  --blue: #6ec1e4;
  --blue-soft: #e4f4fb;
  --green: #6fbf8b;
  --green-soft: #e5f5ea;
  --radius: 18px;
  --shadow: 0 6px 18px rgba(180, 130, 120, .10);
  --tabbar-h: 62px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body { overscroll-behavior-y: none; }

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; }

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  background: linear-gradient(180deg, #ffeef3 0%, rgba(255, 247, 243, .96) 100%);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
#topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#title-main { font-size: 18px; font-weight: 700; letter-spacing: .2px; }
#title-sub { font-size: 12px; color: var(--muted); }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; background: #fff; box-shadow: var(--shadow);
  font-size: 20px; line-height: 1;
}
.icon-btn.stop { color: #e2557a; font-size: 14px; }
.hidden { display: none !important; }

/* ---------- 主区域 ---------- */
#view { padding: 14px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px); }

.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 4px 10px; letter-spacing: .3px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 13px; }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 14px;
  background: var(--accent-soft); color: #c8446c; font-weight: 600;
  border: 1px solid transparent;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, #ff9bb6, #ff7fa3); color: #fff; box-shadow: 0 6px 14px rgba(255, 127, 163, .35); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); font-weight: 500; }
.btn.warm { background: var(--accent2-soft); color: #b96c1e; }
.btn.blue { background: var(--blue-soft); color: #2b7fa3; }
.btn.green { background: var(--green-soft); color: #2f7d50; }
.btn.block { width: 100%; }
.btn.tiny { padding: 8px 12px; border-radius: 11px; font-size: 13px; }
.btn:disabled { opacity: .5; }

/* 正在播放的那句：小喇叭闪烁 */
@keyframes speakBlink {
  0%, 100% { box-shadow: 0 6px 14px rgba(255, 127, 163, .45); opacity: 1; }
  50% { box-shadow: 0 0 0 6px rgba(255, 127, 163, .18); opacity: .55; }
}
.btn.blink { animation: speakBlink 1.05s ease-in-out infinite; }
.btn.paused { background: var(--accent2-soft); color: #b96c1e; }

/* ---------- 首页场景网格 ---------- */
.scene-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.scene-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 14px; text-align: left; display: flex; flex-direction: column; gap: 4px;
}
.scene-card:active { transform: scale(.98); }
.scene-card .emoji { font-size: 28px; line-height: 1.1; }
.scene-card .name { font-weight: 700; font-size: 16px; }
.scene-card .en { font-size: 12px; color: var(--muted); }
.scene-card .count { font-size: 11px; color: var(--accent); margin-top: 4px; font-weight: 600; }

/* ---------- 短句卡 ---------- */
.phrase {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 10px;
}
.phrase-head { display: flex; align-items: flex-start; gap: 10px; }
.phrase-en { flex: 1; font-size: 19px; line-height: 1.55; font-weight: 500; }
.phrase-en .word { border-bottom: 2px dotted rgba(255, 127, 163, .45); }
.phrase-en .word:active { background: var(--accent-soft); border-radius: 6px; }
.phrase-en .word.playing { background: #ffe08a; border-radius: 6px; }

/* 单词与它对应的那段音标，用同一种底色标出来（奇偶两种，方便左右对应） */
.phrase-en .word.t0, .phrase-ipa .ipa-seg.t0 { background: linear-gradient(transparent 58%, #ffe6a8 58%); }
.phrase-en .word.t1, .phrase-ipa .ipa-seg.t1 { background: linear-gradient(transparent 58%, #d5ebff 58%); }
.phrase-ipa {
  font-size: 13.5px; color: #6b5a55; margin-top: 5px; line-height: 1.75;
  word-break: break-word; letter-spacing: .2px;
}
.phrase-ipa .ipa-seg { padding: 0 1px; border-radius: 4px; }

/* 单词卡片里：字母和音标按音节用同样的色块 */
.sylc { padding: 0 2px; border-radius: 6px; }
.syl0 { background: #ffe6a8; }
.syl1 { background: #d5ebff; }
.syl2 { background: #d8f3d8; }
.syl3 { background: #ffd9e8; }
.word-big .sylc, .ipa .sylc { line-height: 1.7; }

/* 单词卡片里的「逐音读」列表样式（表格已移除，样式留着备用） */
.ph-rows { margin-top: 4px; }
.ph-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.ph-row:last-child { border-bottom: none; }
.ph-letters { font-weight: 700; font-size: 17px; min-width: 52px; text-align: center; }
.ph-ipa { color: #2b7fa3; font-size: 15px; min-width: 66px; }
.phrase-cn { font-size: 14px; color: var(--muted); margin-top: 8px; }
.lvl {
  flex: none; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--accent2-soft); color: #b96c1e; margin-top: 4px;
}
.phrase-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- 单词卡（顶栏同款操作） ---------- */
.word-big { font-size: 30px; font-weight: 700; letter-spacing: .5px; }
.ipa { font-size: 17px; color: var(--accent); font-family: "Segoe UI", system-ui, sans-serif; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: var(--blue-soft); color: #2b7fa3; margin: 2px 6px 2px 0; }
.quote { background: #fffaf6; border-left: 3px solid var(--accent2); padding: 8px 10px; border-radius: 8px; font-size: 14px; margin-top: 8px; }

/* ---------- 生词 / 复习 ---------- */
.vocab-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.vocab-item + .vocab-item { border-top: 1px solid var(--line); }
.vocab-word { font-weight: 700; font-size: 17px; }
.empty { text-align: center; color: var(--muted); padding: 36px 18px; line-height: 1.8; }
.empty .big { font-size: 40px; display: block; margin-bottom: 10px; }

.flashcard {
  background: linear-gradient(160deg, #fff, #fff6f8);
  border-radius: 22px; box-shadow: var(--shadow); padding: 28px 20px; text-align: center;
  min-height: 240px; display: flex; flex-direction: column; justify-content: center; gap: 10px;
}
.flashcard .front { font-size: 34px; font-weight: 700; }
.progress { height: 6px; background: #ffe6ee; border-radius: 999px; overflow: hidden; margin: 14px 4px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #ffb26b, #ff7fa3); }

/* ---------- 表单 ---------- */
input[type="text"], textarea, select, input[type="password"], input[type="number"] {
  width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: #fffdfc; color: var(--ink);
  font-family: inherit; font-size: 15px;
}
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

/* ---------- Tabbar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 720px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 4px);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
#tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; border-radius: 12px; }
#tabbar a .ico { font-size: 20px; line-height: 1; }
#tabbar a.active { color: #e2557a; font-weight: 700; }
#tabbar a.active .ico { transform: translateY(-1px); }

/* ---------- 底部弹层 ---------- */
.mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(60, 40, 40, .35);
  display: flex; align-items: flex-end; justify-content: center;
}
#sheet {
  width: 100%; max-width: 720px; background: #fff;
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(env(safe-area-inset-bottom, 0px) + 22px);
  max-height: 86vh; overflow-y: auto;
  animation: slideUp .22s ease-out;
}
.sheet-grip { width: 42px; height: 5px; border-radius: 999px; background: #f0e0e6; margin: 4px auto 12px; }
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

#modal-mask { align-items: center; }
#modal {
  width: calc(100% - 32px); max-width: 520px; background: #fff; border-radius: 20px;
  padding: 18px; max-height: 84vh; overflow-y: auto;
}
#modal h3 { margin: 0 0 12px; font-size: 17px; }
#modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- Toast / miniplayer ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 30px); transform: translateX(-50%);
  background: rgba(61, 44, 40, .92); color: #fff; padding: 10px 16px; border-radius: 14px;
  font-size: 14px; z-index: 90; max-width: 84vw; text-align: center;
}
#miniplayer {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 40; display: flex; align-items: center; gap: 12px;
  background: rgba(61, 44, 40, .94); color: #fff; padding: 10px 14px; border-radius: 999px;
  font-size: 13px; max-width: 88vw;
}
#miniplayer button { background: rgba(255, 255, 255, .18); color: #fff; padding: 5px 12px; border-radius: 999px; font-size: 12px; }
#miniplayer-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }

@media (min-width: 560px) {
  .scene-grid { grid-template-columns: repeat(3, 1fr); }
}
