:root {
  --bg: #f6f3ea;
  --card: #ffffff;
  --ink: #23302e;
  --muted: #6b7774;
  --line: #e4ded0;
  --brand: #2a8f84;
  --brand-ink: #ffffff;
  --brand-soft: #e2f2ef;
  --accent: #f2a93b;
  --ok: #2e9e5b;
  --ok-soft: #e3f5ea;
  --no: #d9534f;
  --no-soft: #fbe9e8;
  --radius: 16px;
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --base: 17px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b2120;
    --card: #252d2b;
    --ink: #eef2f1;
    --muted: #a4b0ad;
    --line: #36403e;
    --brand: #44b3a6;
    --brand-soft: #22403c;
    --ok-soft: #1f3b2b;
    --no-soft: #4a2726;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--base);
  line-height: 1.55;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.big { --base: 20px; }
body.practicing { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
img { max-width: 100%; }
h1 { font-size: 1.45em; margin: 0 0 4px; }
h2 { font-size: 1.15em; margin: 0 0 10px; }
h3 { font-size: 1.15em; margin: 0 0 12px; }
p { margin: 6px 0; }

.view { max-width: 640px; margin: 0 auto; padding: 12px 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card.accent { border: 2px solid var(--accent); }
.card.two { display: flex; justify-content: space-around; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .82em; }
.hint { color: var(--muted); font-size: .85em; }
.center { text-align: center; }
.note { background: var(--brand-soft); border-radius: 12px; padding: 10px 14px; }
.stat { font-size: 1.6em; font-weight: 700; margin: 0; }
.label { font-weight: 600; margin: 12px 0 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.row.center { justify-content: center; }
label { display: block; margin: 10px 0; }
label input { display: block; width: 100%; margin-top: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); }
label.switch { display: flex; gap: 10px; align-items: flex-start; }
label.switch input { width: auto; margin-top: 4px; }

.primary, .ghost, .small-btn {
  border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 600; min-height: 48px;
}
.primary { background: var(--brand); color: var(--brand-ink); }
.primary.big { width: 100%; font-size: 1.1em; min-height: 56px; margin-top: 8px; }
.primary:disabled { opacity: .5; }
.ghost { background: var(--brand-soft); color: var(--ink); }
.small-btn { min-height: 38px; padding: 6px 14px; font-size: .9em; background: var(--brand); color: var(--brand-ink); }
.small-btn.ghost { background: var(--brand-soft); color: var(--ink); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; }
.danger { background: #c0392b; color: #fff; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; }
.member { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.member:first-of-type { border-top: 0; }
.member-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.member .small-btn { padding: 8px 12px; }
.icon-btn { background: var(--brand-soft); border: 0; border-radius: 50%; width: 40px; height: 40px; font-size: 1.05em; }
.icon-btn.big { width: 48px; height: 48px; font-size: 1.3em; }
.tag { display: inline-block; background: var(--brand-soft); border-radius: 999px; padding: 1px 10px; font-size: .78em; font-weight: 600; }
.tag.gray { background: var(--line); color: var(--muted); }
.chip { display: inline-block; border: 1px dashed var(--line); border-radius: 999px; padding: 2px 10px; margin: 3px; font-size: .82em; color: var(--muted); }
.pill { background: var(--card); border-radius: 999px; padding: 4px 10px; font-weight: 600; font-size: .9em; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--bg); }
.who { display: flex; align-items: center; gap: 6px; background: none; border: 0; font-weight: 600; }
.top-stats { display: flex; gap: 6px; }
.avatar { font-size: 2.2em; line-height: 1; }
.avatar.sm { font-size: 1.4em; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav-item { flex: 1; background: none; border: 0; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; font-size: .82em; color: var(--muted); }
.nav-item.active { color: var(--brand); font-weight: 700; }
.nav-ico { font-size: 1.5em; line-height: 1.2; }

.hero { text-align: center; padding: 24px 0 8px; }
.hero-owl { width: 140px; border-radius: 28px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row-btn { display: block; width: 100%; text-align: left; background: var(--brand-soft); border: 0; border-radius: 12px; padding: 14px; margin: 6px 0; font-weight: 600; }
.learner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.learner { background: var(--brand-soft); border: 0; border-radius: var(--radius); padding: 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 600; }
.learner.add { background: transparent; border: 2px dashed var(--line); }
.avatar-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-pick button { font-size: 1.6em; background: var(--bg); border: 2px solid transparent; border-radius: 12px; width: 52px; height: 52px; }
.avatar-pick button.on { border-color: var(--brand); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 8px 14px; }
.seg button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.seg.small button { padding: 4px 10px; font-size: .85em; }

.hello { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.owl { width: 84px; height: 84px; object-fit: contain; flex: none; border-radius: 22px; }
.owl-emoji { font-size: 56px; }
.plan { list-style: none; padding: 0; margin: 8px 0; }
.plan li { padding: 6px 0; font-size: 1.05em; }
.plan li.ok { color: var(--ok); }
.done-line { font-size: 1.1em; font-weight: 600; }
.plain { padding-left: 1.2em; }
.roadmap li { margin: 8px 0; }

.plants { display: flex; flex-wrap: wrap; gap: 2px; font-size: 1.35em; line-height: 1.25; }
.plant.lv1 { opacity: .75; }
.garden-mini { cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--brand-soft); border: 0; border-radius: 14px; padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 1.3em; }
.tile b { font-size: .7em; }
.tile span { font-size: .55em; color: var(--muted); }
.tile:disabled { opacity: .5; }

.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.unit { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.unit.locked { opacity: .7; }
.unit-icon { font-size: 2em; flex: none; }
.unit-body { flex: 1; min-width: 0; }
.unit-title { font-weight: 700; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.stars { color: var(--accent); letter-spacing: 1px; }
.stars.big { font-size: 2em; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.bar.grow { flex: 1; margin: 0 10px; }
.coming { margin-top: 10px; }

.modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.modal-card { position: relative; background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { align-items: center; } .modal-card { border-radius: 20px; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 40; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px); text-align: center; }
.toast[hidden] { display: none; }

.wb-list { margin: 10px 0; }
.wb-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.wb-pic { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; font-size: 1.2em; }
.wb-text { flex: 1; min-width: 0; }

.cert { text-align: center; border: 3px double var(--accent); border-radius: 16px; padding: 20px; margin-bottom: 14px; }
.cert-small { letter-spacing: 2px; color: var(--muted); }
.cert-badge { font-size: 1.4em; font-weight: 700; }

/* practice */
.practice { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; overflow: auto; }
.practice[hidden] { display: none; }
.p-top { display: flex; align-items: center; padding: calc(10px + env(safe-area-inset-top)) 16px 8px; }
.p-body { flex: 1; max-width: 560px; width: 100%; margin: 0 auto; padding: 8px 16px 24px; display: flex; flex-direction: column; }
.question, .learn { text-align: center; }
.pic { width: min(72vw, 300px); height: min(72vw, 300px); margin: 8px auto; border-radius: 20px; object-fit: cover; display: block; background: var(--card); }
.glyph { display: flex; align-items: center; justify-content: center; font-size: 6em; font-weight: 800; color: var(--brand); }
.glyph.word { font-size: 2.4em; }
.swatch { border: 1px solid var(--line); }
.swatch.rainbow { background: conic-gradient(#e53935, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935); }
.letter { font-size: 2.4em; font-weight: 800; color: var(--accent); }
.letter.sm { font-size: 1.6em; }
.word-line { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.word { font-size: 2.2em; font-weight: 800; letter-spacing: .5px; }
.audio-row { display: inline-flex; gap: 6px; align-items: center; }
.kk { color: var(--muted); margin: 0; }
.pos { font-style: italic; }
.zh { font-size: 1.25em; font-weight: 600; }
.zh.big { font-size: 2em; margin: 30px 0; }
.sentence { background: var(--card); border-radius: 16px; padding: 12px; margin: 12px 0; text-align: left; }
.scene { width: 100%; border-radius: 12px; display: block; margin-bottom: 8px; }
.options { display: grid; gap: 10px; margin-top: 16px; }
.options.pics { grid-template-columns: 1fr 1fr; }
.opt { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 14px; font-size: 1.1em; min-height: 56px; }
.opt.en { font-weight: 700; }
.opt.pic { padding: 6px; }
.opt-pic { width: 100%; aspect-ratio: 1; border-radius: 10px; object-fit: cover; display: flex; font-size: 3em; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--no); background: var(--no-soft); }
.listen-btn { font-size: 3em; width: 120px; height: 120px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; margin: 16px auto; display: block; }
.slots { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.slot { width: 40px; height: 48px; border-bottom: 3px solid var(--brand); font-size: 1.6em; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.tiles { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.tile-l { width: 52px; height: 52px; border-radius: 12px; border: 0; background: var(--card); box-shadow: 0 2px 0 var(--line); font-size: 1.5em; font-weight: 700; }
.tile-l:disabled { opacity: .3; }
.type-in { width: 100%; font-size: 1.6em; text-align: center; padding: 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); margin-top: 12px; }
.p-feedback { position: sticky; bottom: 0; background: var(--bg); padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); max-width: 560px; width: 100%; margin: 0 auto; }
.p-feedback[hidden] { display: none; }
.fb { display: flex; align-items: center; gap: 12px; border-radius: 16px; padding: 10px 14px; }
.fb .owl { width: 64px; height: 64px; }
.fb.ok { background: var(--ok-soft); }
.fb.no { background: var(--no-soft); }
.result { text-align: center; padding: 40px 16px; max-width: 480px; margin: 0 auto; }
.result .owl { width: 140px; height: 140px; }
.score { font-size: 2.6em; font-weight: 800; color: var(--brand); margin: 0; }
.stars-line { font-size: 1.2em; font-weight: 700; margin: 16px 0; }
[hidden] { display: none !important; }
