/* 粵講粵掂 — mobile-first, 港式茶記配色 */
:root {
  --bg: #FAF6EF;
  --card: #FFFFFF;
  --ink: #2B2622;
  --muted: #8A7F73;
  --brand: #B33A2B;
  --brand-soft: #F6E3DF;
  --gold: #D9A441;
  --green: #2E7D5B;
  --green-soft: #E2F0E9;
  --red: #C0392B;
  --red-soft: #FBE9E7;
  --line: #EAE2D6;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(43, 38, 34, .06), 0 4px 14px rgba(43, 38, 34, .05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "PingFang HK", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  line-height: 1.55;
}
.app { max-width: 520px; margin: 0 auto; padding: 0 14px 96px; min-height: 100vh; }
.boot { text-align: center; color: var(--muted); padding: 48px 0; }

/* ---------- header ---------- */
.hero {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 2px 10px;
}
.hero .logo {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  background: var(--brand); color: #fff; font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0; font-size: 20px; letter-spacing: .5px; }
.hero .sub { font-size: 12px; color: var(--muted); }
.chips { display: flex; gap: 8px; margin: 2px 0 12px; flex-wrap: wrap; }
.chip {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; padding: 4px 10px; color: var(--muted);
}
.chip b { color: var(--brand); font-size: 13px; }

/* ---------- cards & sections ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 6px; font-size: 16px; }
.card .desc { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.sec-title {
  font-size: 13px; color: var(--muted); font-weight: 600;
  margin: 18px 4px 8px; display: flex; align-items: center; gap: 6px;
}
.sec-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* level card */
.level-head { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.level-emoji {
  width: 40px; height: 40px; border-radius: 12px; flex: none; font-size: 22px;
  display: flex; align-items: center; justify-content: center; background: var(--brand-soft);
}
.level-head .lt { flex: 1; min-width: 0; }
.level-head .lt b { font-size: 15px; }
.level-head .lt .ld { font-size: 12px; color: var(--muted); }
.level-head .pct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.lesson-list { margin-top: 10px; display: none; }
details[open] .lesson-list { display: block; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.lesson-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px;
  border-top: 1px dashed var(--line); cursor: pointer;
}
.lesson-row:active { background: var(--bg); }
.lstate { flex: none; width: 24px; height: 24px; border-radius: 50%; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--line); color: var(--muted); }
.lstate.done { background: var(--green); color: #fff; }
.lesson-row .lmain { flex: 1; min-width: 0; }
.lesson-row .lmain b { font-size: 14px; font-weight: 600; display: block; }
.lesson-row .lmain span { font-size: 11px; color: var(--muted); }
.lesson-row .arrow { color: var(--muted); font-size: 14px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600;
  padding: 12px 18px; width: 100%; font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.green { background: var(--green); }
.btn.line { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btnrow { display: flex; gap: 8px; }
.btnrow .btn { flex: 1; }

/* ---------- lesson ---------- */
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px;
  margin: 14px 0 4px; background: none; border: 0; padding: 4px 2px; font-family: inherit; cursor: pointer; }
.lesson-title { margin: 2px 0 10px; font-size: 22px; }
.lesson-title .jp-sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.intro-box {
  background: var(--brand-soft); border-radius: var(--radius); padding: 12px 14px;
  font-size: 14px; margin-bottom: 12px;
}
.intro-box .jp { color: var(--brand); font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.tips { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.tips li { margin: 3px 0; }

/* vocab */
.vcard {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 12px; margin-bottom: 8px;
}
.vmain { flex: 1; min-width: 0; }
.vyue { font-size: 19px; font-weight: 600; }
.vyue.yue { cursor: pointer; }
.vyue .jp-inline { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px;
  font-family: ui-monospace, Menlo, monospace; }
.vtone { font-size: 11px; color: var(--brand); border: 1px solid var(--brand);
  border-radius: 6px; padding: 0 5px; margin-left: 8px; vertical-align: 2px; }
.vm { font-size: 13px; color: var(--muted); margin-top: 1px; }
.vn { font-size: 12px; color: var(--gold); margin-top: 2px; }
.spk {
  flex: none; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.spk:active { background: var(--brand-soft); }

/* sentences */
.sent { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; margin-bottom: 8px; }
.sent .syue { font-size: 17px; font-weight: 600; cursor: pointer; }
.sent .sjp { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; margin: 2px 0; }
.sent .scn { font-size: 13px; color: var(--muted); }
.sent .sbtns { display: flex; gap: 8px; margin-top: 9px; }
.sent .scorebox { margin-top: 8px; font-size: 13px; display: none; }
.scorebox .said { color: var(--muted); margin-top: 3px; }
.match b { font-weight: 600; }
.match .ok { color: var(--green); }
.match .miss { color: var(--red); }
.big-score { font-size: 22px; font-weight: 700; }
.big-score.pass { color: var(--green); }
.big-score.fail { color: var(--red); }

/* dialogue */
.dlg { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.bubble { max-width: 86%; padding: 9px 12px; border-radius: 14px; font-size: 15px; cursor: pointer; }
.bubble .bm { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.bubble.a { align-self: flex-start; background: var(--brand-soft); border-bottom-left-radius: 4px; }
.bubble.b { align-self: flex-end; background: var(--green-soft); border-bottom-right-radius: 4px; }
.bubble .who { font-size: 10px; color: var(--muted); letter-spacing: 1px; }

/* ---------- quiz ---------- */
.qhead { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; }
.qhead .qcount { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.qdots { flex: 1; display: flex; gap: 4px; }
.qdots i { flex: 1; height: 5px; border-radius: 999px; background: var(--line); }
.qdots i.ok { background: var(--green); }
.qdots i.bad { background: var(--red); }
.qdots i.now { background: var(--gold); }
.qtype { font-size: 12px; color: var(--gold); font-weight: 700; letter-spacing: 1px; margin: 10px 2px 4px; }
.qprompt { font-size: 19px; font-weight: 600; margin: 4px 2px 14px; }
.qprompt .hidden-yue { filter: blur(7px); cursor: pointer; transition: filter .25s; }
.qprompt .hidden-yue.revealed { filter: none; }
.qaudio { text-align: center; margin: 18px 0; }
.qaudio .playbig {
  width: 84px; height: 84px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 34px;
  box-shadow: 0 6px 20px rgba(179, 58, 43, .35);
  display: inline-flex; align-items: center; justify-content: center;
}
.qaudio .playbig:active { transform: scale(.96); }
.qaudio .hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.opts { display: flex; flex-direction: column; gap: 9px; }
.opt {
  text-align: left; border: 1.5px solid var(--line); background: var(--card);
  border-radius: 14px; padding: 13px 14px; font-size: 16px; cursor: pointer; font-family: inherit; color: var(--ink);
}
.opt.jp { font-family: inherit; }
.opt small { display: block; color: var(--muted); font-size: 11px; font-family: ui-monospace, Menlo, monospace; margin-top: 2px; }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt:disabled { cursor: default; }
.qfeedback { margin: 12px 2px; font-size: 14px; min-height: 22px; }
.qfeedback.good { color: var(--green); }
.qfeedback.bad { color: var(--red); }

/* mic */
.micbox { text-align: center; padding: 14px 0 4px; }
.mic {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--green); color: #fff; font-size: 30px;
  box-shadow: 0 6px 18px rgba(46, 125, 91, .35);
  display: inline-flex; align-items: center; justify-content: center;
}
.mic.listening { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.micbox .mhint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.micresult { margin-top: 10px; text-align: left; }

/* quiz done */
.qdone { text-align: center; padding: 26px 10px; }
.qdone .emoji { font-size: 44px; }
.qdone h2 { margin: 10px 0 4px; font-size: 22px; }
.qdone p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

/* ---------- review / progress ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }
.empty .e { font-size: 40px; display: block; margin-bottom: 10px; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { font-size: 24px; color: var(--brand); display: block; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- settings ---------- */
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.setrow:last-child { border-bottom: 0; }
.setrow label { flex: 1; }
.setrow select, .setrow input[type=range] { font-family: inherit; }
.setrow select { font-size: 14px; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); max-width: 200px; }
.setrow input[type=range] { width: 130px; accent-color: var(--brand); }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; }
.switch i::before { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::before { transform: translateX(20px); }
.warnbox { background: #FFF7E0; border: 1px solid #F0DFAE; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin: 8px 0; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: center; gap: 0;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto;
}
.tab {
  flex: 1; border: 0; background: none; font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 0; color: var(--muted); font-size: 11px; border-radius: 12px; position: relative;
}
.tab .ticon { font-size: 21px; line-height: 1.2; }
.tab .badge {
  position: absolute; top: 0; right: calc(50% - 22px);
  background: var(--brand); color: #fff; font-size: 10px; min-width: 16px; height: 16px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
  font-weight: 700;
}
.tab.active { color: var(--brand); font-weight: 700; }

/* ---------- misc ---------- */
.hintline { font-size: 12px; color: var(--muted); text-align: center; margin: 14px 0; }
a { color: var(--brand); }
.nowrap { white-space: nowrap; }
.toc-btn { margin-top: 6px; }
.install-box { background: var(--green-soft); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; margin-bottom: 12px; }
.install-box b { color: var(--green); }
