:root {
  --primary: #0f4c81;
  --accent: #f2a900;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #6b7684;
  --line: #e3e8ef;
  --ok: #1f8a4c;
  --warn: #c0392b;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(16, 32, 64, 0.06);
}
[data-mode="dark"] {
  --bg: #0f1419; --card: #182028; --text: #e8edf3; --muted: #97a3b1; --line: #27313c; --shadow: 0 2px 12px rgba(0,0,0,0.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--primary); color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .3px; text-decoration: none; color: #fff; }
.topbar .brand img { height: 30px; width: auto; border-radius: 6px; background: #fff; padding: 2px; }
.topbar .brand small { font-weight: 400; opacity: .85; font-size: 12px; display: block; line-height: 1; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 13px; opacity: .95; }
.topbar .pill { white-space: nowrap; background: var(--accent); color: #1b2430; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.topbar button { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: 6px 10px; }
.nav { position: sticky; top: 52px; z-index: 19; background: var(--card); border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; padding: 0 8px; }
.nav a { white-space: nowrap; padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; }
.nav a.active { color: var(--primary); border-bottom-color: var(--accent); }
main { max-width: 980px; margin: 0 auto; padding: 18px 14px 80px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; border: 1px solid var(--line); }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--line); color: var(--text); }
.badge.p { background: var(--primary); color: #fff; }
.badge.a { background: var(--accent); color: #1b2430; }
.badge.ok { background: #d9f2e3; color: var(--ok); }
.badge.warn { background: #fde3e0; color: var(--warn); }
[data-mode="dark"] .badge.ok { background: #16432a; } [data-mode="dark"] .badge.warn { background: #4a1d19; }
.btn { background: var(--primary); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.btn.accent { background: var(--accent); color: #1b2430; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: var(--warn); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
label.f { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); }
textarea { min-height: 90px; resize: vertical; }
.auth-wrap { max-width: 420px; margin: 40px auto; }
.auth-wrap .logo { text-align: center; margin-bottom: 14px; }
.auth-wrap .logo img { height: 64px; }
.error { color: var(--warn); font-size: 14px; margin-top: 8px; }
.notice { background: #fff7df; border: 1px solid #f2d27a; color: #6b4e00; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
[data-mode="dark"] .notice { background: #3a2f10; border-color: #6a5a1f; color: #f6e3a1; }

/* stats */
.stat { text-align: center; padding: 14px 8px; }
.stat .n { font-size: 30px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 6px; }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }

/* units */
.unit { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.unit:last-child { border-bottom: 0; }
.unit .num { width: 36px; height: 36px; border-radius: 10px; background: var(--line); display: grid; place-items: center; font-weight: 800; color: var(--primary); flex: none; }
.unit .t { flex: 1; }
.unit .t b { display: block; }
.unit .steps { display: flex; gap: 4px; }
.unit .steps i { width: 10px; height: 10px; border-radius: 3px; background: var(--line); display: block; }
.unit .steps i.done { background: var(--ok); }
.unit .steps i.half { background: var(--accent); }
.locked { opacity: .5; }

/* speaking */
.mic { width: 86px; height: 86px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 34px; display: grid; place-items: center; margin: 10px auto; box-shadow: 0 6px 20px rgba(15,76,129,.35); transition: transform .15s; }
.mic.rec { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1);} 50% { transform: scale(1.07);} 100% { transform: scale(1);} }
.transcript { min-height: 56px; background: var(--bg); border-radius: 10px; padding: 12px; font-size: 17px; }
.target { font-size: 22px; font-weight: 600; line-height: 1.4; }
.target .w.ok { color: var(--ok); } .target .w.miss { color: var(--warn); text-decoration: underline wavy; }
.feedback { border-left: 4px solid var(--accent); padding: 10px 14px; background: var(--bg); border-radius: 0 10px 10px 0; margin-top: 12px; }
.feedback .score { font-size: 28px; font-weight: 800; }
.err { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 6px 0; font-size: 14px; }
.err .w { color: var(--warn); text-decoration: line-through; }
.err .r { color: var(--ok); font-weight: 700; }
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 50vh; overflow-y: auto; padding: 6px 2px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 15px; }
.msg.ai { background: var(--bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .recast { font-size: 13px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(255,255,255,.4); opacity: .95; }
.step-tabs { display: flex; gap: 6px; margin: 10px 0; }
.step-tabs button { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 600; }
.step-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.step-tabs button.done::after { content: " ✓"; color: var(--accent); }
.timer { font-size: 40px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; color: var(--primary); }
.srs-card { text-align: center; padding: 20px; }
.srs-card .cue { font-size: 15px; color: var(--muted); }
.srs-card .wrong { font-size: 22px; color: var(--warn); text-decoration: line-through; margin: 10px 0 4px; }
.srs-card .right { font-size: 24px; color: var(--ok); font-weight: 700; }
.chip { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 13px; margin: 3px 3px 0 0; }
.method ol { padding-left: 20px; }
.method li { margin-bottom: 10px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.bars { display: flex; gap: 3px; align-items: flex-end; height: 70px; }
.bars div { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b2430; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: 0 4px 20px rgba(0,0,0,.3); }
@media (max-width: 600px) { main { padding: 12px 10px 80px; } .target { font-size: 19px; } .topbar .user { display: none; } }
