:root {
  --bg: #f5f7fb; --card: #ffffff; --ink: #18202f; --muted: #5d6779; --line: #e3e7ef;
  --brand: #2f6fed; --brand-ink: #ffffff; --ok: #1f9d55; --mid: #d98a00; --bad: #d64545;
  --ref: #2f6fed; --user: #e0663a; --soft: #eef3fe; --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c; --card: #182030; --ink: #e8edf6; --muted: #9aa6ba; --line: #2a3446;
    --brand: #5b8cff; --soft: #1d2a44; --ref: #6c9bff; --user: #ff8a5c; color-scheme: dark;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #0f141c; --card: #182030; --ink: #e8edf6; --muted: #9aa6ba; --line: #2a3446;
  --brand: #5b8cff; --soft: #1d2a44; --ref: #6c9bff; --user: #ff8a5c; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
header h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 12px; padding: 12px 16px;
  background: var(--brand); color: var(--brand-ink); font-weight: 600; }
button.ghost { background: var(--soft); color: var(--ink); }
button.icon { background: transparent; color: var(--ink); padding: 6px 10px; font-size: 20px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); text-align: left;
  color: var(--ink); font-weight: 500; display: flex; flex-direction: column; gap: 4px; min-height: 104px; }
.tile .em { font-size: 26px; }
.tile small { color: var(--muted); font-weight: 400; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--soft); font-size: 13px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { flex: 1 1 90px; background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.sentence { font-size: 20px; font-weight: 600; margin: 4px 0 12px; }
.mic { width: 84px; height: 84px; border-radius: 50%; font-size: 34px; display: grid; place-items: center;
  margin: 8px auto; box-shadow: 0 6px 20px rgba(47,111,237,.35); }
.mic.rec { background: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.level { height: 6px; width: 140px; margin: 0 auto; background: var(--line); border-radius: 9px; overflow: hidden; }
.level i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s; }
.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.ring { text-align: center; }
.ring svg { width: 72px; height: 72px; }
.ring div { font-size: 13px; color: var(--muted); }
.words { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.w { padding: 6px 10px; border-radius: 10px; font-weight: 600; border: 2px solid transparent; background: var(--soft); color: var(--ink); }
.w.ok { border-color: var(--ok); } .w.mid { border-color: var(--mid); } .w.bad { border-color: var(--bad); }
.phones { font-family: "Segoe UI", "Noto Sans", sans-serif; font-size: 18px; }
.ph-ok { color: var(--ok); } .ph-mid { color: var(--mid); } .ph-bad { color: var(--bad); text-decoration: underline; }
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 4px; border-radius: 3px; vertical-align: middle; margin-right: 4px; }
.fb { padding: 10px 12px; border-left: 4px solid var(--brand); background: var(--soft); border-radius: 10px; margin: 8px 0; }
.fb.ritmo { border-color: var(--mid); } .fb.acento { border-color: var(--user); }
.tip h4 { margin: 0 0 4px; }
.bubbles { display: flex; flex-direction: column; gap: 10px; }
.b { max-width: 88%; padding: 10px 14px; border-radius: 16px; }
.b.coach { background: var(--card); box-shadow: var(--shadow); align-self: flex-start; }
.b.student { background: var(--brand); color: var(--brand-ink); align-self: flex-end; }
.b .extra { font-size: 14px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.chatbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; }
.chatbar input { flex: 1; }
.chatbar .mic { width: 52px; height: 52px; font-size: 22px; margin: 0; box-shadow: none; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; z-index: 20; }
#toast.show { opacity: .95; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 12px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.qr svg { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 12px; }
h2 { font-size: 20px; margin: 8px 0 12px; } h3 { font-size: 17px; margin: 4px 0 8px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.tabs button { flex: 0 0 auto; padding: 8px 12px; }
details summary { cursor: pointer; font-weight: 600; }
.masked { -webkit-text-security: disc; }
.pin-dots { text-align: center; font-size: 28px; letter-spacing: 6px; min-height: 40px; color: var(--ink); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 8px auto 0; }
.pinpad button { font-size: 24px; padding: 16px 0; border-radius: 14px; }
.pinpad [data-ok] { font-size: 16px; }
