:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --text: #1a1e2b;
  --muted: #667085;
  --border: #e4e7ee;
  --accent: #5654d4;
  --accent-strong: #4442b8;
  --accent-soft: #ecebff;
  --accent-text: #ffffff;
  --success: #15803d;
  --success-soft: #e3f6e9;
  --warn: #b45309;
  --warn-soft: #fdf1dc;
  --danger: #c62828;
  --danger-soft: #fde8e8;
  --lv-a: #16a34a;
  --lv-b: #2563eb;
  --lv-c: #9333ea;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --surface: #171a23;
    --surface-2: #1f2330;
    --text: #e8eaf1;
    --muted: #98a2b6;
    --border: #2a2f3d;
    --accent: #8d8cf7;
    --accent-strong: #a5a4ff;
    --accent-soft: #262a4d;
    --accent-text: #11122a;
    --success: #4ade80;
    --success-soft: #16301f;
    --warn: #fbbf24;
    --warn-soft: #33270f;
    --danger: #f87171;
    --danger-soft: #3a1818;
    --lv-a: #4ade80;
    --lv-b: #60a5fa;
    --lv-c: #c084fc;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; letter-spacing: -0.02em; }
h2 { font-size: 18px; letter-spacing: -0.01em; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--text); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #c056d6);
  color: #fff; font-weight: 800; font-size: 18px;
}
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 550;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding-left: 8px; font-weight: 600; font-size: 14px; }
.sidebar-username { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-level .mini-level {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
}
.sidebar-level .bar { margin-top: 6px; }

.main { flex: 1; min-width: 0; padding: 32px 40px 60px; }
.page { max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card > h2 { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }

/* ---------- Controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.big { padding: 14px 26px; font-size: 16px; }
.btn.sm { padding: 6px 12px; font-size: 13px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 999px; border: none;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 15px;
  display: inline-grid; place-items: center; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

input[type="text"], input[type="search"], input[type="password"], textarea, select {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 80px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.tag.success { background: var(--success-soft); color: var(--success); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

.form-error { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14px; }

/* ---------- Login ---------- */
.logged-out .sidebar { display: none; }
.auth-wrap { min-height: calc(100vh - 92px); display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; padding: 32px; }
.auth-card .brand { padding: 0; }
.auth-card .tabs { width: 100%; }
.auth-card .tabs button { flex: 1; }

/* ---------- Level & progress ---------- */

.level-badge {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 24px; padding: 0 8px; border-radius: 8px;
  font-weight: 800; font-size: 13px; color: #fff; background: var(--lv-b);
}
.level-badge.lv-A { background: var(--lv-a); }
.level-badge.lv-B { background: var(--lv-b); }
.level-badge.lv-C { background: var(--lv-c); }
.level-badge.xl { min-width: 84px; height: 64px; font-size: 32px; border-radius: 18px; }
.level-badge.lg { min-width: 56px; height: 44px; font-size: 22px; border-radius: 13px; }
@media (prefers-color-scheme: dark) { .level-badge { color: #0e1016; } }

.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #c056d6);
  transition: width 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar.thin { height: 6px; }

.level-card { display: flex; flex-direction: column; gap: 16px; }
.level-card .level-row { display: flex; align-items: center; gap: 16px; }
.level-card .level-name { font-size: 22px; font-weight: 750; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { color: var(--muted); font-size: 13px; }

.skills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; }
.skill-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }

/* ---------- Topic cards ---------- */

.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.topic-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  box-shadow: var(--shadow); transition: transform 0.15s, border-color 0.15s;
}
.topic-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.topic-icon { font-size: 30px; line-height: 1; }
.topic-title { font-weight: 700; font-size: 16px; }
.topic-sub { color: var(--muted); font-size: 13px; }
.topic-card p { color: var(--muted); font-size: 14px; flex: 1; }
.topic-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.special-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.special-card {
  display: flex; flex-direction: column; gap: 8px; padding: 20px;
  border-radius: var(--radius); color: var(--text); border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
}
.special-card .topic-icon { font-size: 28px; }
.special-card form { display: flex; gap: 8px; margin-top: 4px; }

/* ---------- Onboarding ---------- */

.hero {
  padding: 40px; border-radius: 24px; color: #fff;
  background: radial-gradient(circle at 85% 15%, #c056d6 0, transparent 45%), linear-gradient(135deg, #4b49c9, #6d4fe0);
  display: flex; flex-direction: column; gap: 18px;
}
.hero h1 { font-size: 32px; }
.hero p { max-width: 620px; opacity: 0.92; font-size: 16px; }
.hero .btn.primary { background: #fff; color: #3d3bb5; border-color: #fff; }
.hero input { max-width: 340px; background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
.hero input::placeholder { color: rgba(255, 255, 255, 0.7); }
.level-pick { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.level-pick button {
  padding: 14px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.level-pick button:hover { border-color: var(--accent); }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.step-num {
  width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; margin-bottom: 8px;
}

/* ---------- Lists ---------- */

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 4px;
  border-bottom: 1px solid var(--border); color: var(--text);
}
.list-item:last-child { border-bottom: none; }
a.list-item:hover { background: var(--surface-2); border-radius: var(--radius-sm); }
.list-item .li-icon { font-size: 22px; width: 32px; text-align: center; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { color: var(--muted); font-size: 13px; }
.score-pill { font-weight: 800; font-size: 15px; min-width: 42px; text-align: right; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

.mistake { padding: 12px 0; border-bottom: 1px solid var(--border); }
.mistake:last-child { border-bottom: none; }
.mistake-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 650; }

.wrong { color: var(--danger); text-decoration: line-through; text-decoration-thickness: 1px; }
.right { color: var(--success); font-weight: 600; }

/* ---------- Session ---------- */

.session { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; height: calc(100vh - 64px); }
.session-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.session-head .title { flex: 1; min-width: 200px; }
.session-head .title h1 { font-size: 22px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); padding: 6px 12px; border-radius: 999px; background: var(--surface-2); }

.session-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; }
.stage {
  min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}

.live-area { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tutor-bar { display: flex; align-items: center; gap: 20px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.avatar {
  --pulse: 1;
  position: relative; width: 52px; height: 52px; border-radius: 999px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), #c056d6);
}
.avatar::before {
  content: ""; position: absolute; inset: -5px; border-radius: inherit;
  border: 2px solid var(--accent); opacity: 0; transform: scale(var(--pulse));
  transition: transform 0.08s linear, opacity 0.2s;
}
.avatar.speaking::before { opacity: 0.55; }
.tutor-info { flex: 1; min-width: 0; }
.tutor-name { font-weight: 750; }
.status-text { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--muted); }
.status-dot.live { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.status-dot.warn { background: var(--warn); }

.transcript { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.msg { max-width: 78%; display: flex; flex-direction: column; gap: 4px; }
.msg-text { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.tutor { align-self: flex-start; }
.msg.tutor .msg-text { background: var(--surface-2); border-top-left-radius: 4px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .msg-text { background: var(--accent); color: var(--accent-text); border-top-right-radius: 4px; }
.msg.live .msg-text { opacity: 0.7; }
.msg.live .msg-tools { display: none; }
.msg-tools { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.msg:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
.msg-tools button { border: none; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.msg-tools button:hover { background: var(--surface-2); color: var(--text); }
.translation { font-size: 13px; color: var(--muted); padding: 0 6px; font-style: italic; }
.sys-msg { align-self: center; font-size: 13px; color: var(--muted); background: var(--surface-2); padding: 4px 12px; border-radius: 999px; }

.helpers { display: flex; gap: 8px; padding: 0 16px 10px; overflow-x: auto; scrollbar-width: none; }
.helpers .chip { font-size: 13px; padding: 6px 12px; flex-shrink: 0; }

.composer { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.composer input { border-radius: 999px; }
.mic-btn {
  --mic: 0;
  position: relative; width: 52px; height: 52px; border-radius: 999px; flex-shrink: 0;
  border: none; cursor: pointer; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
}
.mic-btn::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--accent);
  opacity: 0.25; transform: scale(calc(1 + var(--mic) * 0.45)); transition: transform 0.1s linear; z-index: -1;
}
.mic-btn { isolation: isolate; }
.mic-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mic-btn.off { background: var(--surface-2); color: var(--danger); }
.mic-btn.off::before { display: none; }

.start-panel { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; padding: 32px; }
.start-panel .big-avatar { width: 96px; height: 96px; font-size: 40px; }
.start-panel p { max-width: 460px; color: var(--muted); }
.tips { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); text-align: left; }

.lesson-panel { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.lesson-panel .card { padding: 18px; }
.lesson-panel h3 { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.vocab-item { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.vocab-item:last-child { border-bottom: none; }
.vocab-item .w { font-weight: 700; }
.vocab-item .m { color: var(--muted); font-size: 14px; }
.vocab-item .ex { font-size: 13px; font-style: italic; color: var(--muted); margin-top: 2px; }
.grammar-box { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.grammar-box ul, .q-list { margin: 8px 0 0; padding-left: 18px; }
.q-list li { margin-bottom: 6px; }

.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px);
}
.overlay-box { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 32px; max-width: 420px; }
.spinner { width: 42px; height: 42px; border-radius: 999px; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 80px 20px; color: var(--muted); }

.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 550; }
.banner.error { background: var(--danger-soft); color: var(--danger); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--accent-soft); color: var(--accent); }

/* ---------- Results ---------- */

.result-hero { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.placement-reveal { text-align: center; padding: 36px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.placement-reveal .level-name { font-size: 26px; font-weight: 800; }
.placement-reveal p { max-width: 620px; }
.levelup {
  padding: 18px 20px; border-radius: var(--radius); color: #fff; font-weight: 700; font-size: 17px;
  background: linear-gradient(135deg, #16a34a, #0ea5e9); animation: pop 0.5s ease-out;
}
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.score-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.score-ring { --value: 0; --color: var(--accent); display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.score-ring .ring {
  width: 92px; height: 92px; border-radius: 999px; display: grid; place-items: center;
  background: conic-gradient(var(--color) calc(var(--value) * 1%), var(--surface-2) 0);
}
.score-ring .ring::after {
  content: attr(data-value); width: 72px; height: 72px; border-radius: 999px; background: var(--surface);
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
}
.correction { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; }
.bullets { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

details.transcript-box summary { cursor: pointer; font-weight: 650; }
details.transcript-box .lines { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.line b { color: var(--accent); }

/* ---------- Words ---------- */

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); width: fit-content; }
.tabs button { border: none; background: none; padding: 8px 18px; border-radius: 999px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.word-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.word-row:last-child { border-bottom: none; }
.word-row .wr-main { flex: 1; min-width: 0; }
.word-row .w { font-weight: 750; font-size: 16px; }
.word-row.mastered .w { color: var(--success); }
.word-row .ex { font-style: italic; color: var(--muted); font-size: 14px; }

.flashcard {
  width: min(460px, 92vw); min-height: 300px; padding: 32px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center;
}
.flashcard .fc-word { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.flashcard .fc-meaning { font-size: 20px; font-weight: 650; color: var(--accent); }

/* ---------- Costs ---------- */

.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 0 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; white-space: nowrap; }
.data-table tfoot td { border-bottom: none; font-weight: 700; }
.data-table th:first-child, .data-table td:first-child { padding-left: 4px; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.share { height: 4px; margin-top: 6px; margin-left: auto; width: 96px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.share span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.cost-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.cost-value { font-weight: 700; font-variant-numeric: tabular-nums; }

.cost-chart { padding-left: 52px; }
.cc-plot { position: relative; height: 180px; }
.cc-tick { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--border); }
.cc-tick span {
  position: absolute; right: calc(100% + 8px); transform: translateY(-50%);
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.cc-bars { position: absolute; inset: 0; display: flex; gap: 2px; }
.cc-col { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.cc-col span { width: min(24px, 100%); background: var(--accent); border-radius: 4px 4px 0 0; }
.cc-col:hover span, .cc-col:focus-visible span { background: var(--accent-strong); }
.cc-col:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-soft); border-radius: 4px; }
.cc-axis { display: flex; gap: 2px; height: 22px; margin-top: 6px; }
.cc-axis div { flex: 1; min-width: 0; display: flex; justify-content: center; }
.cc-axis span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cc-tip {
  position: absolute; z-index: 5; transform: translate(-50%, -100%); pointer-events: none;
  min-width: 140px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 13px; white-space: nowrap;
}
.cc-tip-value { font-size: 16px; font-weight: 800; }
.cc-tip-row { display: flex; justify-content: space-between; gap: 16px; margin-top: 4px; }
.cc-tip-row span { color: var(--muted); }

/* ---------- Toasts ---------- */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px; border-radius: var(--radius-sm); background: var(--text); color: var(--bg);
  box-shadow: var(--shadow); max-width: 380px; font-weight: 550; animation: pop 0.25s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }

/* ---------- Responsive ---------- */

@media (max-width: 1020px) {
  .session-body { grid-template-columns: 1fr; }
  .lesson-panel { max-height: none; }
  .session { height: auto; }
  .stage { height: 72vh; }
  .score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; z-index: 40;
    width: auto; height: auto; flex-direction: row; padding: 6px 8px;
    border-right: none; border-top: 1px solid var(--border);
  }
  .brand, .sidebar-bottom { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11px; }
  .main { padding: 20px 16px 96px; }
  .grid-2, .grid-3, .special-grid, .steps, .skills { grid-template-columns: 1fr; }
  .level-pick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .data-table .hide-sm { display: none; }
  .hero { padding: 26px 20px; }
  .hero h1 { font-size: 26px; }
  .msg { max-width: 90%; }
  .stage { height: calc(100vh - 210px); }
}
