:root {
  --bg: #0f1226;
  --bg2: #1a1f3d;
  --fg: #f4f4ff;
  --muted: #9aa1c9;
  --accent: #7c5cff;
  --accent2: #21d4a8;
  --bad: #ff6b8a;
  --good: #4ade80;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, system-ui, Inter, sans-serif;
  background: radial-gradient(1200px 800px at 20% 0%, #2a1f5c 0%, var(--bg) 50%);
  color: var(--fg);
  min-height: 100vh;
}
#app { max-width: 720px; margin: 0 auto; padding: 32px 20px 80px; }
h1 { font-weight: 800; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-weight: 700; margin: 0 0 16px; }
.sub { color: var(--muted); margin-bottom: 24px; }
.card {
  background: linear-gradient(180deg, var(--bg2) 0%, #161a35 100%);
  border: 1px solid #2a2f55;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  background: #0c0f24; color: var(--fg);
  border: 1px solid #2a2f55; font-size: 16px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
button {
  background: linear-gradient(135deg, var(--accent), #5a3dff);
  color: white; border: none; border-radius: 12px;
  padding: 13px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: transform .1s;
}
button:hover { transform: translateY(-1px); }
button.ghost { background: transparent; border: 1px solid #3a3f65; }
button.mic { background: linear-gradient(135deg, var(--accent2), #14a37f); }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.lang-row { display: grid; grid-template-columns: 1fr 100px 40px; gap: 8px; align-items: end; margin-bottom: 8px; }
.checkbox { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.checkbox input { width: auto; }
.sentence {
  font-size: 22px; line-height: 1.4; padding: 18px;
  background: #0c0f24; border-radius: 14px; border-left: 4px solid var(--accent);
  margin: 16px 0;
}
.hint { color: var(--muted); font-size: 13px; margin-top: 8px; font-style: italic; }
.hud-greeting {
  font-size: 22px; font-weight: 800; margin: 0 0 14px;
  letter-spacing: -0.02em;
}
.stats-bar {
  display: flex; align-items: stretch;
  background: linear-gradient(135deg, #1e1a40 0%, #161a35 100%);
  border: 1px solid #2a2f55; border-radius: 18px;
  margin-bottom: 14px; overflow: hidden;
}
.stat-block {
  flex: 1; padding: 14px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-block--xp {
  flex: 2;
  border-left: 1px solid #2a2f55;
  border-right: 1px solid #2a2f55;
}
.stat-block--streak {
  background: linear-gradient(135deg, rgba(255,138,0,.12), rgba(255,61,127,.12));
}
.stat-label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); font-weight: 600;
}
.stat-value {
  font-size: 17px; font-weight: 800; color: var(--fg);
}
.streak-val {
  font-size: 22px;
  background: linear-gradient(135deg, #ff8a00, #ff3d7f);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-sub { font-size: 11px; color: var(--muted); }
.nav-tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.nav-tab {
  flex: 1; background: transparent;
  border: 1px solid #2a2f55; border-radius: 12px;
  color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 9px 12px; cursor: pointer; transition: all .15s;
}
.nav-tab:hover { background: #1c2148; color: var(--fg); transform: none; }
.feedback { padding: 16px; border-radius: 12px; margin-top: 16px; }
.feedback.good { background: rgba(74,222,128,.12); border: 1px solid var(--good); }
.feedback.bad { background: rgba(255,107,138,.12); border: 1px solid var(--bad); }
.score { font-size: 32px; font-weight: 800; }
.hud { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.chip {
  background: #1c2148; padding: 8px 14px; border-radius: 999px;
  font-size: 13px; color: var(--muted); border: 1px solid #2a2f55;
}
.chip strong { color: var(--fg); }
.streak { background: linear-gradient(135deg, #ff8a00, #ff3d7f); color: white; border: none; }
.confetti {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
}
.badge {
  display: inline-block; padding: 6px 12px; background: var(--accent2);
  color: #052b22; border-radius: 999px; font-weight: 700; margin-right: 6px;
  animation: pop .4s ease;
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid #ffffff44; border-top-color: white; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tabs { display: flex; gap: 8px; margin: 12px 0; }
.tabs button { flex: 1; }
.tabs button.active { outline: 2px solid var(--accent); }
small.recording { color: var(--bad); font-weight: 700; }
.xp-chip { display: flex; flex-direction: column; gap: 4px; min-width: 80px; }
.xp-bar { width: 100%; height: 4px; background: #2a2f55; border-radius: 999px; overflow: hidden; }
.xp-bar-large { height: 8px; background: #2a2f55; border-radius: 999px; overflow: hidden; }
.xp-bar .xp-fill, .xp-bar-large .xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 999px;
  transition: width .4s ease;
}
.lesson-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.lesson-modal {
  background: linear-gradient(160deg, #1e1640 0%, #161a35 100%);
  border: 1px solid var(--accent);
  border-radius: 24px; padding: 28px; max-width: 520px; width: 100%;
  box-shadow: 0 0 60px rgba(124,92,255,.35);
  animation: slide-up .25s ease;
}
@keyframes slide-up { from { transform: translateY(20px); opacity:0; } to { transform: translateY(0); opacity:1; } }
.lesson-modal h3 { margin: 0 0 16px; font-size: 18px; }
.lesson-section { margin-bottom: 14px; }
.lesson-section strong { color: var(--accent2); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 4px; }
.lesson-example { font-family: monospace; font-size: 14px; padding: 3px 0; }
.lesson-example.wrong { color: var(--bad); }
.lesson-example.right { color: var(--good); margin-bottom: 8px; }
.levelup-toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white; padding: 14px 28px; border-radius: 999px;
  font-weight: 700; font-size: 16px; z-index: 1000; white-space: nowrap;
  box-shadow: 0 8px 32px rgba(124,92,255,.4);
  animation: toast-in .4s ease, toast-out .5s ease 2.5s forwards;
}
@keyframes toast-in { from { transform: translateX(-50%) translateY(20px); opacity:0; } to { transform: translateX(-50%) translateY(0); opacity:1; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(-50%) translateY(10px); } }
