/* Learner app — professional layout for an adult learner (large, calm, high-contrast; no emoji, no cartoon).
   Pattern: top bar (close · progress · count) → content → fixed footer (primary action / result sheet). */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --ink: #101828; --ink-2: #344054; --muted: #667085; --line: #e4e7ec;
  --brand: #1e3a5f; --brand-ink: #ffffff; --brand-soft: #e8eef5; --brand-line: #b9c9dc;
  --ok: #067647; --ok-bg: #ecfdf3; --ok-line: #abefc6;
  --bad: #b42318; --bad-bg: #fef3f2; --bad-line: #fecdca;
  --warn: #b54708; --warn-bg: #fffaeb;
  --note: #f9fafb; --focus: #2e90fa; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --r: 14px; --tap: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111d; --surface: #161b26; --ink: #f5f5f6; --ink-2: #cecfd2; --muted: #94969c; --line: #333741;
    --brand: #8fb3dc; --brand-ink: #0c111d; --brand-soft: #1c2a3d; --brand-line: #3b5677;
    --ok: #47cd89; --ok-bg: #0b2a1b; --ok-line: #1f5e3d; --bad: #f97066; --bad-bg: #3a1513; --bad-line: #6b2a24;
    --warn: #fdb022; --warn-bg: #3a2a0a;
    --note: #1b2130; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 19px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.page { flex: 1; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 12px) 16px 0; }
.content { flex: 1; display: flex; flex-direction: column; gap: 18px; padding: 8px 0 calc(240px + env(safe-area-inset-bottom)); }
.icon { width: 24px; height: 24px; flex: none; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 14px; min-height: 48px; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--muted);
           display: grid; place-items: center; padding: 0; cursor: pointer; }
.iconbtn:active { background: var(--line); }
.progress { flex: 1; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .35s ease; }
.count { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* ---------- text ---------- */
h1 { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 21px; font-weight: 650; margin: 0; }
.label { font-size: 13px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.lead { font-size: 21px; line-height: 1.4; color: var(--ink-2); margin: 0; }
.meaning { font-size: 24px; font-weight: 650; line-height: 1.3; margin: 0; }
.en { font-size: 34px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; }
.sub { font-size: 16px; color: var(--muted); }
.phon { font-size: 18px; color: var(--muted); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.note { background: var(--note); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 10px;
        padding: 12px 14px; font-size: 17px; color: var(--ink-2); }
.situation { font-size: 18px; color: var(--ink-2); background: var(--note); border-radius: 10px; padding: 10px 14px; }
.row { display: flex; gap: 12px; align-items: center; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; }
.grow { flex: 1; }
.hidden, [hidden] { display: none !important; }

/* ---------- buttons ---------- */
button { font: inherit; color: inherit; }
.btn { min-height: var(--tap); border-radius: var(--r); border: 1.5px solid var(--line); background: var(--surface);
       font-size: 18px; font-weight: 650; padding: 0 20px; width: 100%; cursor: pointer; display: inline-flex;
       align-items: center; justify-content: center; gap: 10px; touch-action: manipulation; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .opt:focus-visible, .iconbtn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:disabled { background: var(--line); border-color: var(--line); color: var(--muted); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; font-size: 17px; padding: 8px 0; cursor: pointer; }

/* ---------- home ---------- */
.date { font-size: 16px; color: var(--muted); margin-top: 4px; }
.lesson { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; min-height: 84px; }
.lesson .ic { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.lesson.primary .ic { background: rgba(255,255,255,.14); color: var(--brand-ink); }
.lesson .t { font-size: 19px; font-weight: 700; }
.lesson .d { font-size: 15px; font-weight: 400; opacity: .8; margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); line-height: 1.25; display: block; }

/* ---------- audio controls ---------- */
.audio { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 0; }
.play { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink);
        display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); }
.play .icon { width: 34px; height: 34px; }
.slow { height: 44px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2);
        font-size: 15px; font-weight: 600; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.slow .icon { width: 18px; height: 18px; }
.mini-play { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface);
             color: var(--brand); display: grid; place-items: center; cursor: pointer; flex: none; }
.mini-play .icon { width: 20px; height: 20px; }

/* ---------- options ---------- */
.opt { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 12px 14px; text-align: left;
       background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); font-size: 20px; cursor: pointer;
       box-shadow: var(--shadow); }
.opt .k { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: 15px;
          font-weight: 700; display: grid; place-items: center; flex: none; }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.right .k { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .k { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }
.opt.dim { opacity: .45; }

/* ---------- word tiles ---------- */
.answer-line { min-height: 72px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 0 12px; align-content: flex-start; }
.bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.tile { min-height: 52px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
        font-size: 20px; font-weight: 600; cursor: pointer; box-shadow: 0 2px 0 var(--line); }
.tile.used { visibility: hidden; }

/* ---------- speaking ---------- */
.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0; }
.mic { width: 88px; height: 88px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink);
       display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); position: relative; }
.mic .icon { width: 36px; height: 36px; }
.mic.rec { background: var(--bad); color: #fff; }
.mic.rec::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 3px solid var(--bad); opacity: .5;
                  animation: ring 1.2s ease-out infinite; }
.mic.busy { background: var(--line); color: var(--muted); }
@keyframes ring { from { transform: scale(.9); opacity: .6; } to { transform: scale(1.25); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mic.rec::after { animation: none; } }
.mic-label { font-size: 16px; color: var(--muted); font-weight: 600; }
.model { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reveal { font-size: 15px; color: var(--brand); background: none; border: 0; padding: 4px 0; cursor: pointer; font-weight: 600; }

/* ---------- dialogue ---------- */
.bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 14px 16px;
          box-shadow: var(--shadow); max-width: 92%; }
.bubble .who { font-size: 13px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.bubble .en { font-size: 26px; }

/* ---------- footer / result sheet ---------- */
.footer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
          padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); z-index: 5; }
.footer-in { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.footer.ok { background: var(--ok-bg); border-top-color: var(--ok-line); }
.footer.bad { background: var(--bad-bg); border-top-color: var(--bad-line); }
.result { display: flex; gap: 10px; align-items: flex-start; }
.result .icon { width: 28px; height: 28px; margin-top: 1px; }
.result .title { font-size: 21px; font-weight: 700; }
.footer.ok .result { color: var(--ok); } .footer.bad .result { color: var(--bad); }
.result .detail { font-size: 17px; color: var(--ink-2); margin-top: 2px; }
.result .detail b { color: var(--ink); }
.btnrow { display: flex; gap: 10px; }
.btnrow > .btn { flex: 1; }

/* ---------- end screen ---------- */
.done-ic { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; margin: 12px auto 0; }
.done-ic .icon { width: 38px; height: 38px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wordlist { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: 16px; }

/* ---------- forms / sheets ---------- */
textarea { font: inherit; font-size: 19px; width: 100%; min-height: 130px; border-radius: var(--r); border: 1.5px solid var(--line);
           padding: 14px; background: var(--surface); color: var(--ink); resize: vertical; }
textarea:focus { outline: 3px solid var(--focus); outline-offset: 1px; }
.sheet-bg { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 10; display: flex; align-items: flex-end; }
.sheet { background: var(--surface); width: 100%; border-radius: 20px 20px 0 0; padding: 22px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-in { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.banner { position: fixed; left: 16px; right: 16px; top: calc(12px + env(safe-area-inset-top)); background: var(--ink); color: var(--bg);
          padding: 12px 16px; border-radius: 12px; font-size: 16px; text-align: center; display: none; z-index: 20; }
.banner.show { display: block; }

/* ---------- recording level + pronunciation detail ---------- */
.meter { display: flex; gap: 4px; align-items: flex-end; height: 28px; }
.meter i { width: 6px; border-radius: 3px; background: var(--line); height: 6px; transition: height .08s linear, background .08s; }
.meter.on i { background: var(--bad); }
.words { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.w { border-radius: 8px; padding: 2px 8px; font-weight: 650; font-size: 17px; border: 1px solid transparent; }
.w.good { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.w.mid { color: var(--warn); background: var(--warn-bg); }
.w.low { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.w small { font-weight: 500; opacity: .8; margin-left: 4px; font-size: 13px; }
.scoreline { font-size: 15px; color: var(--ink-2); margin-top: 4px; }

/* ---------- topic picker ---------- */
.searchbox { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1.5px solid var(--line);
             border-radius: var(--r); padding: 0 14px; min-height: 52px; color: var(--muted); }
.searchbox input { border: 0; outline: 0; background: transparent; font: inherit; font-size: 18px; color: var(--ink); flex: 1; min-width: 0; }
.searchbox:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.tgroup { display: flex; flex-direction: column; gap: 10px; }
.topic { min-height: 70px; font-size: 19px; }
.topic .sub { font-size: 14px; }
.tbar { display: block; height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; max-width: 160px; }
.tbar i { display: block; height: 100%; background: var(--brand); }

/* ---------- home: current topic ---------- */
.content.home { padding-bottom: calc(120px + env(safe-area-inset-bottom)); gap: 22px; }
.cur-title { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin-top: 6px; }
.use { font-size: 18px; color: var(--ink-2); margin: 8px 0 0; line-height: 1.45; }
.facts { font-size: 15px; color: var(--muted); margin-top: 8px; }
.plan { background: var(--brand-soft); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; font-size: 17px; }
.prow { display: flex; justify-content: space-between; gap: 12px; }
.prow span:first-child { color: var(--muted); }
.prow span:last-child { font-weight: 650; text-align: right; }
.due { color: var(--warn); }
.goals { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.goals li { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.goals li.now { background: var(--brand-soft); border-color: transparent; }
.goals .gt { font-weight: 650; font-size: 17px; }
.goals .gt small { font-weight: 400; color: var(--muted); font-size: 14px; }
.goals .ge { color: var(--muted); font-size: 16px; margin-top: 2px; }
.goals li.done .gt::after { content: " ✓"; color: var(--ok); }
.samples { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.phr { display: flex; align-items: center; gap: 12px; }
.pen { font-weight: 650; font-size: 18px; }
.pvi { font-size: 15px; color: var(--muted); }
.btn:disabled { opacity: .5; }
