:root {
  --bg: #f4f6fb; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --primary: #2563eb; --primary-ink: #ffffff; --es: #f59e0b; --en: #2563eb;
  --ok: #16a34a; --ok-bg: #dcfce7; --bad: #dc2626; --bad-bg: #fee2e2; --maybe: #b45309; --maybe-bg: #fef3c7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --card: #131c31; --text: #e2e8f0; --muted: #94a3b8; --line: #23304b;
    --primary: #3b82f6; --ok: #4ade80; --ok-bg: #12351f; --bad: #f87171; --bad-bg: #3b1416; --maybe: #fbbf24; --maybe-bg: #3a2a0a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.screen { max-width: 560px; margin: 0 auto; padding: 12px 16px 40px; }

.login-box { margin-top: 18vh; text-align: center; }
.logo { width: 72px; height: 72px; margin: 0 auto 8px; border-radius: 20px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 28px; }
#codeRow { margin-top: 12px; }
input { width: 100%; font: inherit; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); }
#codeInput { text-align: center; font-size: 22px; letter-spacing: 6px; margin-bottom: 10px; }
.msg { min-height: 1.4em; color: var(--bad); }

.top { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; text-align: center; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; }
.stat .big { font-size: 22px; font-weight: 800; color: var(--text); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 9px; font: inherit; font-weight: 600; }
.tabs button.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 12px; }
h1 { margin: 6px 0; } h2 { margin: 0 0 4px; font-size: 20px; }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.wide { width: 100%; padding: 14px; }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--muted); font: inherit; text-decoration: underline; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.row.end { justify-content: space-between; margin-top: 16px; }
.play { flex: 1; }

.mic { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 150px; height: 150px; margin: 18px auto; border-radius: 50%; border: 0; color: #fff; font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.mic svg { width: 56px; height: 56px; fill: currentColor; }
.mic.es { background: var(--es); }
.mic.en { background: var(--en); }
.mic.rec { background: var(--bad) !important; animation: pulse 1.1s infinite; }
.mic:disabled { opacity: .5; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.text-row { display: flex; gap: 8px; }
.es-text { color: var(--muted); margin: 0 0 6px; }
.en-text { font-size: 24px; font-weight: 700; line-height: 1.35; margin: 0; }
.en-text .w { cursor: pointer; border-radius: 6px; padding: 0 2px; }
.en-text .w.error { color: var(--bad); background: var(--bad-bg); text-decoration: underline wavy; }
.en-text .w.maybe { color: var(--maybe); background: var(--maybe-bg); }
.en-text.passed .w { color: var(--ok); }
.note { color: var(--muted); font-size: 14px; margin: 4px 0; }
.chip { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; border: 1px dashed var(--line); background: transparent; color: var(--text); border-radius: 12px; padding: 8px 12px; margin-top: 6px; }

.score-row { display: flex; gap: 14px; align-items: center; }
.score { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 22px; flex: none; background: var(--bad-bg); color: var(--bad); }
.score.ok { background: var(--ok-bg); color: var(--ok); }
.verdict { font-weight: 800; font-size: 18px; }
.fluency { font-size: 15px; }
.issues { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.issues li { border-radius: 12px; padding: 10px 12px; background: var(--bad-bg); }
.issues li.maybe { background: var(--maybe-bg); }
.issues .iw { font-weight: 800; font-size: 18px; }
.issues .ipa { color: var(--muted); font-family: ui-monospace, monospace; margin-left: 6px; }
.issues .tag { font-size: 12px; font-weight: 700; text-transform: uppercase; margin-left: 6px; color: var(--muted); }
.issues p { margin: 4px 0; font-size: 15px; }
.issues .row { margin: 6px 0 0; }
.issues .btn { padding: 6px 10px; font-size: 14px; }

.plist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.plist li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; }
.plist .en { font-weight: 700; }
.plist .es { color: var(--muted); font-size: 14px; }
.plist .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--maybe-bg); color: var(--maybe); margin-left: 6px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.busy { position: fixed; inset: auto 0 24px 0; margin: 0 auto; width: max-content; max-width: 90vw; display: flex; gap: 10px; align-items: center; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; z-index: 10; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 10px 16px; border-radius: 12px; max-width: 90vw; z-index: 11; }
.foot { text-align: center; margin-top: 20px; }
