/* ============================================================
   LinguaVerse — Glassmorphism / Neumorphic design system
   RTL by default (Arabic UI), LTR islands for target content
   ============================================================ */

:root {
  --accent: #3b82f6;
  --accent-2: #8b5cf6;
  --bg: #eef2ff;
  --bg-2: #f8fafc;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-strong: rgba(255, 255, 255, 0.86);
  --border: rgba(255, 255, 255, 0.75);
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 25px 60px -15px rgba(15, 23, 42, 0.28);
  --neu-in: inset 4px 4px 10px rgba(15, 23, 42, 0.07), inset -4px -4px 10px rgba(255, 255, 255, 0.9);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 22px;
  --radius-sm: 14px;
  --font-ar: 'Cairo', system-ui, sans-serif;
  --font-ltr: 'Inter', system-ui, sans-serif;
  --font-zh: 'Noto Sans SC', 'Inter', sans-serif;
  --header-h: 72px;
  --t: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme='dark'] {
  --bg: #0b1020;
  --bg-2: #0f172a;
  --surface: rgba(30, 41, 59, 0.55);
  --surface-strong: rgba(30, 41, 59, 0.85);
  --border: rgba(148, 163, 184, 0.14);
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #64748b;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 25px 60px -15px rgba(0, 0, 0, 0.75);
  --neu-in: inset 4px 4px 10px rgba(0, 0, 0, 0.45), inset -4px -4px 10px rgba(255, 255, 255, 0.03);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  font-family: var(--font-ar);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--t), color var(--t);
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }

/* --- LTR islands --- */
[dir='ltr'], .ltr { direction: ltr; font-family: var(--font-ltr); text-align: left; }
.ltr.zh, [lang='zh'] { font-family: var(--font-zh); }
.rtl { direction: rtl; font-family: var(--font-ar); text-align: right; }

/* --- Background orbs --- */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-orbs span {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.45;
  animation: float 18s ease-in-out infinite;
}
.bg-orbs span:nth-child(1) { width: 480px; height: 480px; background: var(--accent); top: -120px; right: -120px; }
.bg-orbs span:nth-child(2) { width: 380px; height: 380px; background: var(--accent-2); bottom: -100px; left: -80px; animation-delay: -6s; }
.bg-orbs span:nth-child(3) { width: 300px; height: 300px; background: #ec4899; top: 40%; left: 50%; animation-delay: -12s; opacity: 0.25; }
html[data-theme='dark'] .bg-orbs span { opacity: 0.25; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-30px, 40px) scale(1.08); } }

/* --- Glass --- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  transition: transform var(--t), box-shadow var(--t), background var(--t);
}
.card.hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

/* --- Header --- */
#app-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  border-left: none; border-right: none; border-top: none;
}
.header-inner {
  max-width: 1200px; margin: 0 auto; height: 100%; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.35rem; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px -6px var(--accent);
  transition: background var(--t), box-shadow var(--t);
}
.brand-text span { color: var(--accent); transition: color var(--t); }

.lang-switcher {
  display: flex; gap: 6px; padding: 5px; border-radius: 999px;
  background: var(--bg-2); box-shadow: var(--neu-in);
}
.lang-btn {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  font-weight: 700; font-size: 0.9rem; color: var(--text-2); position: relative;
  transition: all var(--t);
}
.lang-btn .flag { font-size: 1.15rem; line-height: 1; }
.lang-btn:hover { color: var(--text); transform: translateY(-1px); }
.lang-btn.active {
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px -6px var(--accent);
}

.header-actions { display: flex; align-items: center; gap: 10px; }
.stat-chip {
  display: flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px;
  font-weight: 800; font-size: 0.9rem; background: var(--bg-2); box-shadow: var(--neu-in);
}
.stat-chip i { color: #f97316; }
.stat-chip.xp i { color: #eab308; }
.stat-chip.pop { animation: pop 0.5s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-2); box-shadow: var(--neu-in); color: var(--text-2); font-size: 1rem;
  transition: all var(--t);
}
.icon-btn:hover { color: var(--accent); transform: rotate(15deg); }

/* --- Main --- */
#app-main { max-width: 1200px; margin: 0 auto; padding: 28px 20px 110px; }
.view { animation: fadeUp 0.45s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.section-title { display: flex; align-items: center; gap: 12px; font-size: 1.4rem; font-weight: 900; margin-bottom: 18px; }
.section-title i { color: var(--accent); }
.section-title small { font-size: 0.85rem; color: var(--text-3); font-weight: 600; margin-inline-start: auto; }

/* --- Hero (dashboard) --- */
.hero {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 28px;
}
.hero-main {
  position: relative; overflow: hidden; color: #fff; border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  min-height: 220px; display: flex; flex-direction: column; justify-content: space-between;
}
.hero-main::after {
  content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); top: -120px; inset-inline-start: -80px;
}
.hero-main h1 { font-size: 1.9rem; font-weight: 900; line-height: 1.25; position: relative; z-index: 1; }
.hero-main p { opacity: 0.9; margin-top: 8px; position: relative; z-index: 1; }
.hero-greeting {
  position: relative; z-index: 1; margin-top: 16px; display: inline-flex; flex-direction: column; gap: 2px;
  padding: 12px 20px; border-radius: 16px; background: rgba(255, 255, 255, 0.18); backdrop-filter: blur(8px);
  font-size: 1.6rem; font-weight: 700; width: fit-content;
}
.hero-greeting .pinyin { font-size: 0.85rem; opacity: 0.85; font-weight: 500; }
.hero-flag { position: absolute; font-size: 7rem; inset-inline-end: 20px; bottom: -20px; opacity: 0.25; transform: rotate(-10deg); }

.hero-side { display: flex; flex-direction: column; gap: 16px; }
.progress-card h3 { font-size: 1rem; font-weight: 800; color: var(--text-2); margin-bottom: 10px; display: flex; justify-content: space-between; }
.progress-bar { height: 12px; border-radius: 999px; background: var(--bg-2); box-shadow: var(--neu-in); overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 999px; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative; overflow: hidden;
}
.progress-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-stat {
  text-align: center; padding: 14px 8px; border-radius: var(--radius-sm);
  background: var(--bg-2); box-shadow: var(--neu-in);
}
.mini-stat .val { font-size: 1.5rem; font-weight: 900; color: var(--accent); line-height: 1.1; }
.mini-stat .lbl { font-size: 0.75rem; color: var(--text-3); font-weight: 700; }

/* --- Learning path --- */
.path { position: relative; display: flex; flex-direction: column; gap: 14px; }
.path-item {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px;
  position: relative; cursor: pointer;
}
.path-item .num {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex-shrink: 0;
  font-size: 1.3rem; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px -6px var(--accent);
}
.path-item.done .num { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 8px 18px -6px #10b981; }
.path-item.locked { opacity: 0.55; filter: grayscale(0.6); }
.path-item.locked .num { background: var(--text-3); box-shadow: none; }
.path-item .info { flex: 1; min-width: 0; }
.path-item .info h4 { font-weight: 800; font-size: 1.05rem; }
.path-item .info p { font-size: 0.85rem; color: var(--text-2); }
.path-item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 0.8rem; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 800; background: var(--bg-2); box-shadow: var(--neu-in); color: var(--text-2);
}
.badge.xp { color: #b45309; background: rgba(251, 191, 36, 0.18); box-shadow: none; }
.badge.type-vocab { color: #1d4ed8; background: rgba(59, 130, 246, 0.15); box-shadow: none; }
.badge.type-quiz { color: #6d28d9; background: rgba(139, 92, 246, 0.15); box-shadow: none; }
.badge.type-roleplay { color: #be185d; background: rgba(236, 72, 153, 0.15); box-shadow: none; }
html[data-theme='dark'] .badge.xp { color: #fcd34d; }
html[data-theme='dark'] .badge.type-vocab { color: #93c5fd; }
html[data-theme='dark'] .badge.type-quiz { color: #c4b5fd; }
html[data-theme='dark'] .badge.type-roleplay { color: #f9a8d4; }

.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 22px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.quick-card {
  padding: 18px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-align: start;
}
.quick-card i { font-size: 1.5rem; color: var(--accent); }
.quick-card b { font-size: 0.95rem; }
.quick-card small { color: var(--text-3); font-size: 0.78rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 14px; font-weight: 800; font-size: 0.95rem;
  transition: all var(--t); position: relative; overflow: hidden;
}
.btn-primary {
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px -8px var(--accent);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -8px var(--accent); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-ghost { background: var(--bg-2); box-shadow: var(--neu-in); color: var(--text-2); }
.btn-ghost:hover { color: var(--accent); }
.btn-success { color: #fff; background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 10px 24px -8px #10b981; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; border-radius: 10px; }

/* --- Tabs / Chips --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 0.9rem;
  background: var(--bg-2); box-shadow: var(--neu-in); color: var(--text-2); transition: all var(--t);
  display: inline-flex; align-items: center; gap: 8px;
}
.chip:hover { color: var(--text); }
.chip.active { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 16px -6px var(--accent); }

/* --- Flashcards --- */
.flash-stage { display: grid; grid-template-columns: 1fr; gap: 20px; max-width: 760px; margin: 0 auto; }
.flash-progress { display: flex; align-items: center; gap: 12px; font-weight: 800; color: var(--text-2); }
.flash-progress .progress-bar { flex: 1; }

.flip-card { perspective: 1400px; height: 380px; cursor: pointer; }
.flip-inner {
  position: relative; width: 100%; height: 100%; transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 28px; padding: 32px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center;
  background: var(--surface-strong); backdrop-filter: blur(20px); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.flip-face.back { transform: rotateY(180deg); background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: #fff; border: none; }
.flip-face .emoji { font-size: 3.6rem; line-height: 1; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.15)); }
.flip-face .word { font-size: 2.4rem; font-weight: 700; line-height: 1.2; }
.flip-face .word.zh { font-size: 3rem; font-family: var(--font-zh); }
.flip-face .pinyin { font-size: 1.25rem; color: var(--accent); font-weight: 600; font-family: var(--font-ltr); }
.flip-face .phonetic { font-size: 1rem; color: var(--text-3); font-family: var(--font-ltr); }
.flip-face .hint { position: absolute; bottom: 18px; font-size: 0.78rem; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.flip-face.back .hint { color: rgba(255, 255, 255, 0.7); }
.flip-face.back .ar-word { font-size: 2.3rem; font-weight: 900; }
.flip-face.back .example { font-size: 1.1rem; opacity: 0.95; margin-top: 6px; padding: 10px 16px; border-radius: 14px; background: rgba(255, 255, 255, 0.15); }
.flip-face.back .example-pinyin { font-size: 0.9rem; opacity: 0.85; font-family: var(--font-ltr); }
.flip-face.back .example-ar { font-size: 0.95rem; opacity: 0.85; }
.audio-btn {
  position: absolute; top: 18px; inset-inline-end: 18px; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.05rem; color: var(--accent);
  background: var(--bg-2); box-shadow: var(--neu-in); transition: all var(--t);
}
.audio-btn:hover { transform: scale(1.1); }
.audio-btn.playing { animation: pulse 0.8s ease infinite; color: #fff; background: var(--accent); }
.flip-face.back .audio-btn { background: rgba(255, 255, 255, 0.2); color: #fff; box-shadow: none; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

.flash-controls { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.flash-controls .btn-know { background: linear-gradient(135deg, #10b981, #059669); color: #fff; box-shadow: 0 10px 24px -8px #10b981; }
.flash-controls .btn-again { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; box-shadow: 0 10px 24px -8px #f59e0b; }
.flash-controls .btn:hover { transform: translateY(-2px); }

.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 28px; }
.vocab-mini {
  padding: 16px; display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.vocab-mini .emoji { font-size: 1.8rem; }
.vocab-mini .w { font-weight: 700; font-size: 1.05rem; }
.vocab-mini .w.zh { font-family: var(--font-zh); }
.vocab-mini .p { font-size: 0.75rem; color: var(--accent); font-family: var(--font-ltr); }
.vocab-mini .a { font-size: 0.85rem; color: var(--text-2); }
.vocab-mini.known { border-color: var(--success); }
.vocab-mini.known .check { color: var(--success); margin-inline-start: auto; }

/* --- Quiz --- */
.quiz-wrap { max-width: 760px; margin: 0 auto; }
.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.quiz-head .progress-bar { flex: 1; }
.quiz-head .q-count { font-weight: 900; color: var(--text-2); white-space: nowrap; }
.lives { display: flex; gap: 4px; }
.lives i { color: #ef4444; transition: all var(--t); }
.lives i.lost { color: var(--text-3); transform: scale(0.8); opacity: 0.4; }

.quiz-card { padding: 30px; }
.quiz-q { font-size: 1.2rem; font-weight: 800; margin-bottom: 8px; }
.quiz-prompt {
  margin: 14px 0 22px; padding: 22px; border-radius: 20px; text-align: center;
  background: var(--bg-2); box-shadow: var(--neu-in);
  font-size: 1.9rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.quiz-prompt.zh { font-family: var(--font-zh); font-size: 2.4rem; }
.quiz-prompt .pinyin { font-size: 1.05rem; color: var(--accent); font-family: var(--font-ltr); font-weight: 600; }
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.option {
  padding: 16px 18px; border-radius: 16px; font-weight: 700; font-size: 1.05rem; text-align: center;
  background: var(--surface-strong); border: 2px solid var(--border); box-shadow: var(--shadow);
  transition: all var(--t); position: relative;
}
.option:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--accent); }
.option.correct { border-color: var(--success); background: rgba(16, 185, 129, 0.15); animation: bounceIn 0.5s; }
.option.wrong { border-color: var(--danger); background: rgba(239, 68, 68, 0.15); animation: shake 0.5s; }
.option:disabled { cursor: default; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes bounceIn { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }

.feedback {
  margin-top: 18px; padding: 16px 18px; border-radius: 16px; display: flex; align-items: flex-start; gap: 12px;
  animation: fadeUp 0.35s ease; font-weight: 600;
}
.feedback.ok { background: rgba(16, 185, 129, 0.15); color: #047857; border: 1px solid rgba(16, 185, 129, 0.35); }
.feedback.bad { background: rgba(239, 68, 68, 0.12); color: #b91c1c; border: 1px solid rgba(239, 68, 68, 0.35); }
html[data-theme='dark'] .feedback.ok { color: #6ee7b7; }
html[data-theme='dark'] .feedback.bad { color: #fca5a5; }
.feedback i { font-size: 1.4rem; margin-top: 2px; }
.feedback .btn { margin-inline-start: auto; align-self: center; }

/* Matching */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  padding: 14px 16px; border-radius: 14px; font-weight: 700; font-size: 1.05rem;
  background: var(--surface-strong); border: 2px solid var(--border); box-shadow: var(--shadow);
  transition: all var(--t); cursor: pointer; text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.match-item .pinyin { font-size: 0.8rem; color: var(--accent); font-family: var(--font-ltr); font-weight: 600; }
.match-item.zh { font-family: var(--font-zh); font-size: 1.3rem; }
.match-item:hover { transform: translateY(-2px); border-color: var(--accent); }
.match-item.selected { border-color: var(--accent); background: rgba(59, 130, 246, 0.12); transform: scale(1.03); }
.match-item.matched { border-color: var(--success); background: rgba(16, 185, 129, 0.15); opacity: 0.7; pointer-events: none; }
.match-item.wrong { animation: shake 0.4s; border-color: var(--danger); }
.match-item.dragging { opacity: 0.5; }
.match-item.drop-over { border-color: var(--accent-2); border-style: dashed; }

/* Quiz result */
.result { text-align: center; padding: 40px 28px; }
.result .trophy { font-size: 5rem; margin-bottom: 10px; animation: bounceIn 0.8s; }
.result h2 { font-size: 1.8rem; font-weight: 900; }
.result .score-ring {
  width: 150px; height: 150px; margin: 20px auto; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--ring, var(--accent)) var(--pct), var(--bg-2) 0); position: relative;
}
.result .score-ring::before { content: ''; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface-strong); }
.result .score-ring span { position: relative; font-size: 2rem; font-weight: 900; }
.result-stats { display: flex; justify-content: center; gap: 24px; margin: 16px 0 24px; color: var(--text-2); font-weight: 700; }
.result-stats b { color: var(--accent); font-size: 1.2rem; }

/* --- Roleplay --- */
.scenario-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.scenario-card { padding: 22px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.scenario-card .ico {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 1.5rem; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 20px -6px var(--accent);
}
.scenario-card h4 { font-size: 1.15rem; font-weight: 800; }
.scenario-card p { font-size: 0.88rem; color: var(--text-2); }
.scenario-card .npc { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-3); margin-top: auto; }

.chat-wrap { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; scroll-padding-bottom: 120px; }
.chat-wrap .choices { scroll-margin-bottom: 120px; }
.chat-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; }
.chat-head .avatar {
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1.3rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.chat-head .who b { display: block; font-size: 1.05rem; }
.chat-head .who small { color: var(--text-3); }
.chat-head .toggle { margin-inline-start: auto; }
.toggle-switch {
  display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; color: var(--text-2); cursor: pointer;
}
.toggle-switch .track {
  width: 44px; height: 24px; border-radius: 999px; background: var(--bg-2); box-shadow: var(--neu-in); position: relative; transition: all var(--t);
}
.toggle-switch .track::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; inset-inline-start: 3px;
  transition: all var(--t); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.toggle-switch.on .track { background: var(--accent); }
.toggle-switch.on .track::after { inset-inline-start: 23px; }

.chat-setting { padding: 12px 18px; border-radius: 14px; font-size: 0.9rem; color: var(--text-2); background: var(--bg-2); box-shadow: var(--neu-in); text-align: center; }
.chat-log { display: flex; flex-direction: column; gap: 14px; padding: 20px; min-height: 300px; max-height: 480px; overflow-y: auto; }
.msg { display: flex; gap: 10px; max-width: 85%; animation: fadeUp 0.35s ease; }
.msg.npc { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex-shrink: 0; font-size: 0.9rem; }
.msg.npc .av { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.msg.user .av { background: linear-gradient(135deg, #10b981, #059669); }
.bubble { padding: 12px 16px; border-radius: 18px; background: var(--surface-strong); border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.msg.npc .bubble { border-start-start-radius: 4px; }
.msg.user .bubble { border-start-end-radius: 4px; background: linear-gradient(135deg, #10b981, #059669); color: #fff; border: none; }
.bubble .txt { font-size: 1.05rem; font-weight: 500; }
.bubble .txt.zh { font-family: var(--font-zh); font-size: 1.2rem; }
.bubble .pinyin { font-size: 0.82rem; color: var(--accent); font-family: var(--font-ltr); }
.msg.user .bubble .pinyin { color: rgba(255, 255, 255, 0.85); }
.bubble .tr { font-size: 0.85rem; color: var(--text-2); border-top: 1px dashed var(--border); padding-top: 4px; margin-top: 2px; }
.msg.user .bubble .tr { color: rgba(255, 255, 255, 0.85); border-color: rgba(255, 255, 255, 0.3); }
.bubble .speak { align-self: flex-start; font-size: 0.8rem; color: var(--accent); margin-top: 4px; }
.msg.user .bubble .speak { color: #fff; }
.typing { display: flex; gap: 4px; padding: 14px 18px; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

.choices { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.choices .lbl { font-size: 0.85rem; color: var(--text-3); font-weight: 700; text-align: center; }
.choice {
  padding: 14px 18px; border-radius: 16px; text-align: start; font-weight: 600;
  background: var(--surface-strong); border: 2px solid var(--border); box-shadow: var(--shadow);
  transition: all var(--t); display: flex; flex-direction: column; gap: 3px;
}
.choice:hover { transform: translateX(-4px); border-color: var(--accent); }
[dir='ltr'] .choice:hover { transform: translateX(4px); }
.choice .zh { font-family: var(--font-zh); font-size: 1.15rem; }
.choice .pinyin { font-size: 0.8rem; color: var(--accent); font-family: var(--font-ltr); }
.choice .tr { font-size: 0.82rem; color: var(--text-3); }
.choice.good { border-color: var(--success); background: rgba(16, 185, 129, 0.15); }
.choice.bad { border-color: var(--danger); background: rgba(239, 68, 68, 0.12); animation: shake 0.4s; }

/* --- Roleplay (guided choices, pronunciation, mode switch) --- */
.rp-mode { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); margin-inline-start: auto; }
.rp-mode button { border: 0; background: transparent; color: var(--text-2); padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 0.8rem; cursor: pointer; transition: all var(--t); white-space: nowrap; }
.rp-mode button.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 6px 14px -6px var(--accent); }
.chat-head .rp-mode + .toggle { margin-inline-start: 0; }
.rp-options { display: flex; flex-direction: column; gap: 10px; }
.choice.rp-opt { flex-direction: row; align-items: center; gap: 12px; cursor: pointer; position: relative; user-select: none; }
.choice.rp-opt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.choice.rp-opt .num { flex: 0 0 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); font-size: 0.85rem; font-weight: 900; color: var(--text-2); }
.choice.rp-opt .body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.choice.rp-opt .speak.mini { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 12px; padding: 0; display: grid; place-items: center; margin: 0; }
.choice.rp-opt.good .num { background: var(--success); color: #fff; border-color: var(--success); }
.choice.rp-opt.bad .num { background: var(--danger); color: #fff; border-color: var(--danger); }
.choice.rp-opt.bad, .choice.rp-opt.dim, .choice.rp-opt[aria-disabled='true'] { cursor: default; }
.choice.rp-opt.bad:hover, .choice.rp-opt.dim:hover, .choice.rp-opt.good:hover { transform: none; }
.choice.rp-opt.dim { opacity: 0.45; }
.rp-feedback:empty { display: none; }
.rp-feedback .fb { padding: 14px 16px; border-radius: 14px; font-size: 0.95rem; animation: bounceIn 0.4s; }
.rp-feedback .fb.good { background: rgba(16, 185, 129, 0.14); border: 1px solid rgba(16, 185, 129, 0.4); color: var(--success); }
.rp-feedback .fb.bad { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.35); color: var(--danger); }
.rp-feedback .fb .why { color: var(--text); margin-top: 6px; font-weight: 600; }
.rp-feedback .fb .hint, .pron .hint { color: var(--text-3); font-size: 0.82rem; margin-top: 4px; }
.rp-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.pron { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.pron .pron-result { flex-basis: 100%; }
.pron .pron-result:empty { display: none; }
.btn-mic { background: linear-gradient(135deg, #ec4899, #8b5cf6); color: #fff; }
.btn-mic.listening { background: linear-gradient(135deg, var(--danger), #f97316); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); } 50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } }
.pron .score { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); animation: bounceIn 0.4s; }
.pron .ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 64px;
  background: conic-gradient(var(--ring, var(--accent)) calc(var(--p) * 1%), var(--border) 0); position: relative; }
.pron .ring::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface-strong); }
.pron .ring b { position: relative; font-size: 0.9rem; }
.pron .score.great { --ring: var(--success); }
.pron .score.ok { --ring: #f59e0b; }
.pron .score.low { --ring: var(--danger); }
.pron .lbl2 { font-size: 0.75rem; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.pron .heard { font-weight: 600; font-family: var(--font-ltr); }
.modal .modal-body p { color: var(--text-2); margin-bottom: 14px; }
.rp-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 6px 0 14px; }
.rp-stats .stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); min-width: 90px; }
.rp-stats .stat i { color: var(--accent); }
.rp-stats .stat b { font-size: 1.2rem; }
.rp-stats .stat span { font-size: 0.72rem; color: var(--text-3); font-weight: 700; }
.modal .bonus { color: #f59e0b; font-weight: 800; margin-bottom: 14px; }
@media (max-width: 720px) {
  .chat-head { flex-wrap: wrap; }
  .rp-mode { order: 5; flex-basis: 100%; justify-content: center; margin-inline-start: 0; }
  .choice.rp-opt .speak.mini { width: 32px; height: 32px; }
}

/* --- Profile / Achievements --- */
.profile-hero { display: flex; align-items: center; gap: 20px; padding: 26px; margin-bottom: 22px; }
.profile-hero .avatar {
  width: 86px; height: 86px; border-radius: 28px; display: grid; place-items: center; font-size: 2.4rem; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 12px 28px -8px var(--accent);
}
.profile-hero h2 { font-size: 1.5rem; font-weight: 900; }
.profile-hero .level { color: var(--text-2); font-weight: 700; }
.profile-hero .xp-bar { margin-top: 10px; }
.profile-hero .xp-bar small { font-size: 0.78rem; color: var(--text-3); display: flex; justify-content: space-between; margin-top: 4px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.ach {
  padding: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.ach .ico {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; color: #fff;
  box-shadow: 0 10px 24px -8px currentColor;
}
.ach.locked { opacity: 0.5; filter: grayscale(1); }
.ach.locked .ico { background: var(--text-3) !important; box-shadow: none; }
.ach b { font-size: 0.95rem; }
.ach small { font-size: 0.78rem; color: var(--text-3); }
.ach.unlocked { animation: bounceIn 0.6s; }
.lang-progress-list { display: flex; flex-direction: column; gap: 12px; }
.lang-progress { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.lang-progress .flag { font-size: 1.8rem; }
.lang-progress .info { flex: 1; }
.lang-progress .info b { display: block; margin-bottom: 6px; }
.lang-progress .pct { font-weight: 900; color: var(--accent); }

/* --- Bottom nav --- */
.bottom-nav {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50;
  display: flex; gap: 4px; padding: 8px; border-radius: 999px; max-width: 720px; width: calc(100% - 32px);
}
.nav-item {
  flex: 1 0 auto; min-width: 58px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px;
  border-radius: 999px; font-size: 0.72rem; font-weight: 800; color: var(--text-3); transition: all var(--t);
}
.nav-item i { font-size: 1.15rem; }
.nav-item:hover { color: var(--text); }
.nav-item.active { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 20px -8px var(--accent); }

/* --- Toast --- */
#toast-container { position: fixed; top: calc(var(--header-h) + 12px); inset-inline-start: 50%; transform: translateX(50%); z-index: 100; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
[dir='ltr'] #toast-container { transform: translateX(-50%); }
.toast {
  padding: 12px 20px; border-radius: 14px; font-weight: 800; display: flex; align-items: center; gap: 10px;
  background: var(--surface-strong); backdrop-filter: blur(16px); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.xp i { color: #eab308; }
.toast.ach i { color: #f59e0b; }
.toast.out { animation: toastOut 0.3s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px); } }

/* --- Modal --- */
.modal-bg { position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; animation: fadeIn 0.25s; }
.modal { max-width: 440px; width: 100%; padding: 32px; text-align: center; animation: bounceIn 0.5s; }
.modal .big { font-size: 4rem; }
.modal h3 { font-size: 1.4rem; font-weight: 900; margin: 8px 0; }
.modal p { color: var(--text-2); }
.modal .btn { margin-top: 20px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 200; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty i { font-size: 3rem; margin-bottom: 12px; display: block; }
.loader { display: grid; place-items: center; padding: 80px; }
.loader i { font-size: 2.4rem; color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Celebration shake on body --- */
.celebrate { animation: celebrate 0.6s; }
@keyframes celebrate { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.01); } }

/* --- Responsive --- */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  :root { --header-h: 64px; }
  .header-inner { padding: 0 10px; gap: 6px; }
  .brand-text { display: none; }
  .brand-logo { width: 38px; height: 38px; border-radius: 12px; }
  .lang-switcher { padding: 4px; gap: 2px; flex: 1; justify-content: center; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .lang-switcher::-webkit-scrollbar { display: none; }
  .lang-btn { padding: 6px 8px; flex-shrink: 0; }
  .lang-btn .name { display: none; }
  .header-actions { gap: 6px; flex-shrink: 0; }
  .stat-chip { padding: 5px 9px; font-size: 0.8rem; gap: 4px; }
  .icon-btn { width: 36px; height: 36px; font-size: 0.9rem; }
  #app-main { padding: 18px 14px 110px; }
  .hero-main h1 { font-size: 1.45rem; }
  .hero-greeting { font-size: 1.3rem; }
  .options { grid-template-columns: 1fr; }
  .flip-card { height: 340px; }
  .flip-face .word { font-size: 1.9rem; }
  .flip-face.back .ar-word { font-size: 1.8rem; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .nav-item span { font-size: 0.65rem; }
  .path-item .meta { display: none; }
  .profile-hero { flex-direction: column; text-align: center; }
  .mini-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 420px) {
  .stat-chip { padding: 6px 9px; }
  .quick-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   v2 additions — onboarding, auth, dropdowns, grammar, levels
   ============================================================ */
.ui-ltr body, body.ui-ltr { font-family: var(--font-ltr); }
body.ui-ltr .rtl { direction: rtl; font-family: var(--font-ar); }
body.ui-ltr .section-title small { margin-inline-start: auto; }

/* Onboarding */
.onboard { max-width: 920px; margin: 20px auto; text-align: center; animation: fadeUp 0.5s ease; }
.onboard-logo {
  width: 84px; height: 84px; border-radius: 28px; margin: 0 auto 18px; display: grid; place-items: center; color: #fff; font-size: 2.2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 16px 36px -10px var(--accent);
}
.onboard-logo.small { width: 60px; height: 60px; font-size: 1.6rem; border-radius: 20px; margin-bottom: 12px; }
.onboard h1 { font-size: 2rem; font-weight: 900; margin-bottom: 10px; }
.onboard h2 { font-size: 1.3rem; font-weight: 800; margin-top: 18px; }
.onboard p { color: var(--text-2); margin: 6px 0 24px; }
.steps { display: flex; justify-content: center; gap: 8px; }
.steps span { width: 40px; height: 6px; border-radius: 999px; background: var(--bg-2); box-shadow: var(--neu-in); transition: all var(--t); }
.steps span.on { background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: none; }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.lang-card { padding: 24px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; border-width: 2px; text-align: center; position: relative; }
.lang-card .flag { font-size: 3rem; line-height: 1; filter: drop-shadow(0 8px 14px rgba(0,0,0,.15)); }
.lang-card b { font-size: 1.2rem; }
.lang-card small { color: var(--text-3); }
.lang-card.selected { border-color: var(--c, var(--accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--accent)) 25%, transparent), var(--shadow-lg); transform: translateY(-4px); }
.lang-card.selected::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; top: 12px; inset-inline-end: 12px; width: 26px; height: 26px; border-radius: 50%; background: var(--c, var(--accent)); color: #fff; display: grid; place-items: center; font-size: .75rem; }
.lang-stats { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; font-size: .75rem; color: var(--text-2); }
.lang-stats i { color: var(--c, var(--accent)); width: 14px; }
.lang-card .greet { margin-top: 8px; padding: 6px 14px; border-radius: 10px; background: var(--bg-2); box-shadow: var(--neu-in); font-weight: 700; font-size: 1.05rem; }
.lang-card .greet small { color: var(--c, var(--accent)); font-weight: 600; }
.onboard-actions { display: flex; justify-content: center; gap: 12px; margin-top: 30px; }

/* Auth */
.auth-wrap { max-width: 460px; margin: 24px auto; animation: fadeUp 0.5s ease; }
.auth-card { padding: 34px 30px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head h2 { font-size: 1.5rem; font-weight: 900; }
.auth-head p { color: var(--text-2); font-size: .9rem; margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-radius: 14px; background: var(--bg-2); box-shadow: var(--neu-in); }
.auth-form label i { color: var(--text-3); }
.auth-form input { flex: 1; border: none; background: none; padding: 14px 0; font: inherit; color: var(--text); outline: none; min-width: 0; }
.auth-form input::placeholder { color: var(--text-3); }
.auth-error { padding: 10px 14px; border-radius: 12px; background: rgba(239,68,68,.12); color: #b91c1c; border: 1px solid rgba(239,68,68,.3); font-weight: 700; font-size: .9rem; }
html[data-theme='dark'] .auth-error { color: #fca5a5; }
.auth-switch { text-align: center; margin-top: 16px; color: var(--text-2); font-size: .9rem; }
.auth-switch button { color: var(--accent); font-weight: 800; }
.auth-divider { text-align: center; color: var(--text-3); margin: 14px 0 10px; position: relative; }
.auth-divider::before, .auth-divider::after { content: ''; position: absolute; top: 50%; width: 42%; height: 1px; background: var(--border); }
.auth-divider::before { inset-inline-start: 0; } .auth-divider::after { inset-inline-end: 0; }
.auth-note { display: block; text-align: center; color: var(--text-3); font-size: .78rem; margin-top: 8px; }

/* Header dropdowns */
.header-center { display: flex; gap: 8px; flex: 1; justify-content: center; min-width: 0; }
.dropdown { position: relative; }
.dd-trigger { display: flex; align-items: center; gap: 10px; padding: 7px 14px; border-radius: 999px; background: var(--bg-2); box-shadow: var(--neu-in); font-weight: 700; transition: all var(--t); max-width: 100%; }
.dd-trigger:hover { color: var(--accent); }
.dd-trigger .flag { font-size: 1.3rem; line-height: 1; }
.dd-trigger > i.fa-globe { color: var(--accent); }
.dd-trigger .fa-chevron-down { font-size: .7rem; color: var(--text-3); transition: transform var(--t); }
.dropdown.open .fa-chevron-down { transform: rotate(180deg); }
.dd-label { display: flex; flex-direction: column; line-height: 1.15; text-align: start; }
.dd-label small { font-size: .65rem; color: var(--text-3); font-weight: 600; }
.dd-label b { font-size: .9rem; }
.dd-menu { position: absolute; top: calc(100% + 8px); inset-inline-start: 0; min-width: 240px; padding: 8px; border-radius: 18px; z-index: 60;
  background: var(--surface-strong); backdrop-filter: blur(20px); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-8px) scale(.98); pointer-events: none; transition: all .2s; display: flex; flex-direction: column; gap: 2px; }
.dd-menu.right { inset-inline-start: auto; inset-inline-end: 0; }
.dropdown.open .dd-menu { opacity: 1; transform: none; pointer-events: auto; }
.dd-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-align: start; font-weight: 600; transition: background var(--t); width: 100%; }
.dd-item:hover { background: var(--bg-2); }
.dd-item.active { color: var(--accent); }
.dd-item .flag { font-size: 1.4rem; }
.dd-item > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; line-height: 1.2; }
.dd-item small { color: var(--text-3); font-size: .75rem; font-weight: 500; }
.dd-item > i:last-child { color: var(--accent); }
.dd-item.danger { color: var(--danger); }
.dd-user { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
.dd-user small { color: var(--text-3); font-size: .78rem; }
.avatar-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important; color: #fff !important; box-shadow: 0 8px 18px -6px var(--accent) !important; }
.avatar-btn:hover { transform: none !important; }

/* Dashboard additions */
.continue-card { display: flex; align-items: center; gap: 18px; margin-bottom: 26px; border: 2px solid var(--accent); }
.continue-card .num { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; color: #fff; font-size: 1.5rem; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex-shrink: 0; }
.continue-card .info { flex: 1; min-width: 0; }
.continue-card small { color: var(--accent); font-weight: 800; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.continue-card h4 { font-size: 1.15rem; font-weight: 900; }
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.level-card { padding: 20px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; cursor: pointer; }
.level-card .lv-ico { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 1.4rem; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.level-card.locked { opacity: .55; filter: grayscale(.7); }
.level-card .progress-bar { width: 100%; }
.level-card small { color: var(--text-3); font-weight: 700; }
.sub-title { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 800; color: var(--text-2); margin: 6px 0 12px; }
.sub-title i:first-child { color: var(--accent); }
.scenario-card.locked { opacity: .55; filter: grayscale(.7); }
.chip.locked { opacity: .55; }
.leaders { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.leaders li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--bg-2); box-shadow: var(--neu-in); font-size: .9rem; }
.leaders .rank { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: .8rem; }
.leaders li:nth-child(1) .rank { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.leaders li:nth-child(2) .rank { background: linear-gradient(135deg, #cbd5e1, #94a3b8); }
.leaders li:nth-child(3) .rank { background: linear-gradient(135deg, #d97706, #b45309); }
.leaders .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaders .nm small { color: var(--accent); }
.leaders b { color: var(--accent); }

/* Grammar reader */
.reader { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.reader .btn-sm { align-self: flex-start; }
.guide { padding: 36px; }
.guide h1 { font-size: 1.9rem; font-weight: 900; margin: 10px 0 8px; }
.guide .intro { color: var(--text-2); font-size: 1.05rem; line-height: 1.7; padding: 16px 18px; border-radius: 16px; background: var(--bg-2); box-shadow: var(--neu-in); margin-bottom: 10px; }
.rule { margin-top: 26px; }
.rule h3 { display: flex; align-items: flex-start; gap: 12px; font-size: 1.1rem; font-weight: 800; line-height: 1.5; margin-bottom: 12px; }
.rule-num { width: 30px; height: 30px; flex-shrink: 0; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: .9rem; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.example { padding: 14px 18px; border-radius: 14px; border-inline-start: 4px solid var(--accent); background: var(--surface-strong); margin: 8px 0 8px 42px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
[dir='rtl'] .example { margin: 8px 42px 8px 0; }
.ex-target { font-size: 1.2rem; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ex-target.zh { font-size: 1.45rem; }
.ex-pinyin { font-size: .9rem; color: var(--accent); font-family: var(--font-ltr); }
.ex-native { font-size: .95rem; color: var(--text-2); }
.speak-inline { color: var(--accent); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-2); box-shadow: var(--neu-in); font-size: .8rem; transition: all var(--t); }
.speak-inline.playing { background: var(--accent); color: #fff; animation: pulse .8s infinite; }
.mini-speak { margin-inline-start: auto; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--accent); background: var(--bg-2); box-shadow: var(--neu-in); font-size: .8rem; flex-shrink: 0; }
.mini-speak.playing { background: var(--accent); color: #fff; }
.vocab-mini .check { margin-inline-start: 4px; }
.vocab-mini .a { font-family: inherit; }

/* Dialogue user turn */
.choice.user-line { cursor: default; border-color: var(--accent); background: rgba(59,130,246,.08); }
.choice.user-line:hover { transform: none; }
.choice.user-line .zh { font-size: 1.25rem; }

@media (max-width: 960px) {
  .level-grid { grid-template-columns: 1fr; }
  .level-card { flex-direction: row; text-align: start; }
  .level-card .progress-bar { flex: 1; }
}
@media (max-width: 720px) {
  .header-center { gap: 4px; }
  .dd-trigger { padding: 6px 10px; gap: 6px; }
  .dd-label small { display: none; }
  .dd-label b { font-size: .8rem; }
  #native-dd .dd-label { display: none; }
  .dd-menu { min-width: 210px; }
  .guide { padding: 22px 18px; }
  .example { margin-inline-start: 0 !important; margin-inline-end: 0 !important; }
  .continue-card { flex-wrap: wrap; }
  .continue-card .btn { width: 100%; }
  .onboard h1 { font-size: 1.5rem; }
  .lang-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .lang-card { padding: 16px 10px; }
  .lang-card .flag { font-size: 2.2rem; }
  .auth-card { padding: 26px 20px; }
  .bottom-nav { max-width: 100%; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; justify-content: flex-start; }
  .bottom-nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 auto; min-width: 64px; padding: 8px 6px; font-size: .62rem; scroll-snap-align: center; white-space: nowrap; }
  .nav-item i { font-size: 1rem; }
}

/* ---------- Word bank ---------- */
.bank-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.bank-head .section-title { margin-bottom: 4px; }
.bank-sub { color: var(--text-2); font-size: .92rem; }
.bank-toolbar { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; margin-bottom: 12px; }
.bank-toolbar .chips { margin-bottom: 0; }
.search { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-radius: 14px; background: var(--bg-2); box-shadow: var(--neu-in); }
.search i { color: var(--text-3); }
.search input { flex: 1; border: none; background: none; padding: 14px 0; font: inherit; font-size: 1.02rem; color: var(--text); outline: none; min-width: 0; }
.search input::-webkit-search-cancel-button { display: none; }
.search .clear { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); background: var(--surface-strong); }
.search .clear.hidden { display: none; }
.bank-meta { color: var(--text-3); font-size: .85rem; font-weight: 700; margin: 4px 4px 10px; }
.bank-meta b { color: var(--accent); font-size: 1.05rem; }
.bank-table-wrap { padding: 0; overflow-x: auto; }
.bank-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.bank-table th { text-align: start; padding: 14px 14px; font-size: .78rem; font-weight: 800; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.bank-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.bank-table tbody tr { transition: background var(--t); scroll-margin-top: calc(var(--header-h) + 16px); }
.bank-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.bank-table tbody tr.known td:first-child { box-shadow: inset 4px 0 0 var(--success); }
[dir='rtl'] .bank-table tbody tr.known td:first-child { box-shadow: inset -4px 0 0 var(--success); }
.bank-table mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 4px; padding: 0 2px; }
.c-audio { width: 48px; text-align: center !important; }
.c-word { font-weight: 700; font-size: 1.08rem; white-space: nowrap; }
.c-word .emoji { margin-inline-end: 8px; }
.c-word .zh { font-size: 1.3rem; }
.c-ph { white-space: nowrap; }
.c-ph .pinyin { color: var(--accent); font-weight: 600; font-family: var(--font-ltr); }
.c-ph .ipa { color: var(--text-2); font-family: var(--font-ltr); font-size: .9rem; }
.c-meaning { font-weight: 700; min-width: 140px; }
.c-ex { min-width: 280px; max-width: 420px; }
.c-ex .ex-t { font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.c-ex .ex-t.zh { font-size: 1.1rem; }
.c-ex .ex-py { color: var(--accent); font-size: .8rem; font-family: var(--font-ltr); }
.c-ex .ex-n { color: var(--text-2); font-size: .88rem; margin-top: 2px; }
.c-act { white-space: nowrap; }
.c-act .btn-sm { padding: 6px 9px; }
.badge.lv-1 { color: #047857; background: rgba(16,185,129,.15); box-shadow: none; }
.badge.lv-2 { color: #b45309; background: rgba(245,158,11,.15); box-shadow: none; }
.badge.lv-3 { color: #6d28d9; background: rgba(139,92,246,.15); box-shadow: none; }
html[data-theme='dark'] .badge.lv-1 { color: #6ee7b7; } html[data-theme='dark'] .badge.lv-2 { color: #fcd34d; } html[data-theme='dark'] .badge.lv-3 { color: #c4b5fd; }
.audio-tag { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--accent); background: var(--bg-2); box-shadow: var(--neu-in); font-size: .85rem; transition: all var(--t); }
.audio-tag:hover { transform: scale(1.1); }
.audio-tag.playing { background: var(--accent); color: #fff; animation: pulse .8s infinite; }
.audio-tag.sm { width: 24px; height: 24px; font-size: .65rem; }
#export-dd .dd-menu a { text-decoration: none; color: inherit; }
@media (max-width: 860px) {
  .bank-table thead { display: none; }
  .bank-table, .bank-table tbody, .bank-table tr, .bank-table td { display: block; }
  .bank-table tr { padding: 14px 14px 12px 14px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 44px 1fr auto; gap: 4px 10px; align-items: start; }
  .bank-table td { padding: 0; border: none; }
  .c-audio { grid-row: 1 / span 2; }
  .c-word { grid-column: 2; }
  .c-ph { grid-column: 2; }
  .c-meaning { grid-column: 2; }
  .c-ex { grid-column: 1 / -1; margin-top: 8px; padding: 10px 12px !important; border-radius: 12px; background: var(--bg-2); min-width: 0; max-width: none; }
  .bank-table td:nth-child(6), .bank-table td:nth-child(7) { grid-column: 1 / span 2; display: inline-block; margin-top: 6px; }
  .bank-table td:nth-child(7) { grid-column: 3; justify-self: end; }
  .c-act { grid-column: 3; grid-row: 1; justify-self: end; }
  .bank-table tbody tr.known td:first-child { box-shadow: none; }
  .bank-table tbody tr.known { box-shadow: inset 4px 0 0 var(--success); }
  .nav-item span { font-size: .58rem; }
}

/* ---------- Grammar Masterclasses ---------- */
.mc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.mc-card { padding: 24px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; border-top: 4px solid var(--mc, var(--accent)); }
.theme-structure { --mc: #3b82f6; } .theme-nouns { --mc: #10b981; } .theme-prepositions { --mc: #f97316; } .theme-tenses { --mc: #8b5cf6; } .theme-pronouns { --mc: #ec4899; } .theme-passive { --mc: #0ea5e9; } .theme-conditional { --mc: #f59e0b; } .theme-modals { --mc: #10b981; } .theme-clauses { --mc: #ef4444; }
.mc-card.locked { opacity: .55; filter: grayscale(.7); }
.mc-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mc-num { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-size: 1.3rem; background: linear-gradient(135deg, var(--mc, var(--accent)), var(--accent-2)); box-shadow: 0 8px 18px -6px var(--mc, var(--accent)); flex-shrink: 0; }
.mc-num.big { width: 68px; height: 68px; font-size: 1.7rem; border-radius: 20px; }
.mc-card.done .mc-num { background: linear-gradient(135deg, #10b981, #059669); }
.mc-card h3 { font-size: 1.2rem; font-weight: 900; line-height: 1.3; }
.mc-card p { color: var(--text-2); font-size: .9rem; flex: 1; }
.mc-target { font-weight: 600; color: var(--mc, var(--accent)); font-size: .95rem; display: flex; flex-direction: column; gap: 2px; }
.mc-target.zh { font-size: 1.15rem; }
.mc-target small { color: var(--text-3); font-weight: 500; font-family: var(--font-ltr); font-size: .78rem; }
.mc-stats { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: .82rem; color: var(--text-3); font-weight: 700; }
.mc-stats i { color: var(--mc, var(--accent)); }
.mc-reader .guide { border-top: 5px solid var(--mc, var(--accent)); }
.mc-head { display: flex; gap: 18px; align-items: flex-start; }
.mc-head h1 { margin: 6px 0 4px; }
.mc-section { margin-top: 34px; }
.mc-section h2 { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; font-weight: 900; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid color-mix(in srgb, var(--mc, var(--accent)) 30%, transparent); }
.mc-section h2 i { color: var(--mc, var(--accent)); }
.mc-section h2 small { margin-inline-start: auto; font-size: .85rem; color: var(--text-3); }
.mc-para { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.mc-para p { line-height: 1.85; font-size: 1.02rem; color: var(--text); }
.mc-para .rule-num { margin-top: 4px; background: linear-gradient(135deg, var(--mc, var(--accent)), var(--accent-2)); }
.formula { padding: 16px 18px; border-radius: 18px; background: var(--bg-2); box-shadow: var(--neu-in); margin-bottom: 14px; }
.formula-label { font-weight: 800; font-size: .85rem; color: var(--text-2); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }
.formula-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.formula-row .block { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 14px; border-radius: 14px; background: var(--surface-strong); border: 2px solid color-mix(in srgb, var(--mc, var(--accent)) 35%, transparent); box-shadow: var(--shadow); min-width: 90px; }
.formula-row .tag { font-size: .68rem; font-weight: 800; color: var(--mc, var(--accent)); text-transform: uppercase; letter-spacing: .04em; font-family: var(--font-ar); direction: rtl; }
body.ui-ltr .formula-row .tag { font-family: var(--font-ltr); direction: ltr; }
.formula-row .sample { font-size: 1.15rem; font-weight: 700; }
.formula-row.zh .sample { font-size: 1.4rem; font-family: var(--font-zh); }
.formula-row .plus { font-size: 1.3rem; font-weight: 900; color: var(--text-3); }
.formula-py { margin-top: 8px; color: var(--mc, var(--accent)); font-family: var(--font-ltr); font-size: .9rem; font-weight: 600; }
.formula-note { margin-top: 10px; font-size: .85rem; color: var(--text-2); display: flex; gap: 8px; align-items: flex-start; }
.formula-note i { color: var(--mc, var(--accent)); margin-top: 3px; }
.mc-examples .example { margin-inline-start: 0 !important; margin-inline-end: 0 !important; border-inline-start-color: var(--mc, var(--accent)); }
.mc-tip { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: color-mix(in srgb, #f59e0b 12%, transparent); border: 1px solid color-mix(in srgb, #f59e0b 35%, transparent); margin-bottom: 10px; }
.mc-tip i { color: #f59e0b; margin-top: 4px; }
.mc-tip p { font-size: .95rem; line-height: 1.7; }
.mc-practice { padding: 22px; border-radius: 20px; background: color-mix(in srgb, var(--mc, var(--accent)) 6%, transparent); border: 1px solid color-mix(in srgb, var(--mc, var(--accent)) 25%, transparent); }
.mc-practice h2 { border: none; padding: 0; }
.mc-qhead { display: flex; justify-content: space-between; align-items: center; }
.mc-options .option { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.mc-options .option.selected { border-color: var(--mc, var(--accent)); background: color-mix(in srgb, var(--mc, var(--accent)) 12%, transparent); transform: scale(1.02); }
.mc-options .opt-py { font-size: .75rem; color: var(--text-3); font-weight: 500; }
.mc-result { text-align: center; padding: 10px 0; }
.mc-result .score-ring { margin: 10px auto 14px; width: 120px; height: 120px; }
.mc-result .score-ring span { font-size: 1.6rem; }
@media (max-width: 720px) {
  .mc-head { flex-direction: column; }
  .formula-row .block { min-width: 70px; padding: 8px 10px; }
  .formula-row .sample { font-size: 1rem; }
  .mc-options { grid-template-columns: 1fr; }
}

/* --- Assessments (hand-authored quizzes) --- */
.as-intro { color: var(--text-2); max-width: 820px; margin-bottom: 14px; line-height: 1.6; }
.as-cert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; margin-bottom: 20px; font-weight: 700; background: var(--surface); border: 1px dashed var(--border); color: var(--text-2); }
.as-cert i { font-size: 1.3rem; color: #0ea5e9; }
.as-cert.ok { background: rgba(14, 165, 233, 0.12); border: 1px solid rgba(14, 165, 233, 0.4); color: #0369a1; }
html[data-theme='dark'] .as-cert.ok { color: #7dd3fc; }
.as-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.as-card { padding: 22px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; position: relative; overflow: hidden; }
.as-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
[dir='rtl'] .as-card::before { inset: 0 0 0 auto; }
.as-card.grammar::before { background: linear-gradient(180deg, #8b5cf6, #ec4899); }
.as-card.passed { border-color: rgba(16, 185, 129, 0.5); }
.as-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.as-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.as-card .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.3rem; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.as-card.grammar .ico { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.as-card h3 { font-size: 1.15rem; font-weight: 900; }
.as-target { font-weight: 700; color: var(--accent); font-family: var(--font-ltr); }
.as-target.zh { font-family: var(--font-zh); font-size: 1.1rem; }
.as-target .pinyin { color: var(--text-3); font-weight: 500; }
.as-card p { color: var(--text-2); font-size: 0.9rem; line-height: 1.55; flex: 1; }
.as-meta { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.8rem; color: var(--text-3); font-weight: 700; }
.as-meta i { color: var(--accent); margin-inline-end: 4px; }
.as-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 0.85rem; font-weight: 700; }
.as-foot .ok { color: var(--success); }
.as-foot .ko { color: #f59e0b; }
.as-foot .pass { color: var(--text-3); font-weight: 600; }
.as-kind { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.as-kind .badge.xp { color: #f59e0b; }
.as-xp-chip { font-weight: 900; color: #f59e0b; white-space: nowrap; }
.as-hint { color: var(--text-3); font-size: 0.85rem; margin-bottom: 14px; }
.as-options .option { display: flex; align-items: center; gap: 12px; text-align: start; }
.as-options .option .key { flex: 0 0 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 0.75rem; font-weight: 900; background: var(--surface); border: 1px solid var(--border); color: var(--text-3); }
.as-options .option.correct .key { background: var(--success); color: #fff; border-color: var(--success); }
.as-options .option.wrong .key { background: var(--danger); color: #fff; border-color: var(--danger); }
.feedback .fb-xp { color: #f59e0b; margin-inline-start: 6px; }
.feedback .fb-answer { font-weight: 700; margin-top: 4px; }
.feedback .fb-why { font-weight: 500; font-size: 0.9rem; margin-top: 4px; line-height: 1.5; }
.match-item.drop { cursor: grab; }
.match-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.order-answer, .order-pool { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px; border-radius: 16px; min-height: 64px; align-items: center; transition: all var(--t); }
.order-answer { background: var(--surface); border: 2px dashed var(--border); margin-bottom: 12px; }
.order-answer.drop-over, .order-pool.drop-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.order-answer.correct { border-style: solid; border-color: var(--success); background: rgba(16, 185, 129, 0.12); }
.order-answer.wrong { border-style: solid; border-color: var(--danger); background: rgba(239, 68, 68, 0.1); animation: shake 0.4s; }
.order-answer .ph { color: var(--text-3); font-size: 0.9rem; font-style: italic; }
.order-pool { background: transparent; border: 2px solid transparent; justify-content: center; }
.tok { padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 1.05rem; cursor: pointer; border: 2px solid var(--border); background: var(--surface-strong); box-shadow: var(--shadow); transition: all var(--t); font-family: inherit; color: var(--text); }
.tok:hover { border-color: var(--accent); transform: translateY(-2px); }
.tok.picked { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.tok.dragging { opacity: 0.4; }
.tok:disabled { cursor: default; transform: none; }
.zh .tok { font-family: var(--font-zh); font-size: 1.2rem; }
.as-result .as-sub { color: var(--text-2); margin-bottom: 14px; }
.as-result .score-ring.pass { --ring: var(--success); }
.as-result .score-ring.fail { --ring: var(--danger); }
.as-result .result-stats { grid-template-columns: repeat(4, 1fr); }
.xp-breakdown { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; font-size: 0.85rem; color: var(--text-2); margin-bottom: 16px; }
.xp-breakdown i { color: #f59e0b; }
.kind-rows { display: flex; flex-direction: column; gap: 8px; max-width: 460px; margin: 0 auto 16px; text-align: start; }
.kind-row { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 10px; font-size: 0.85rem; font-weight: 700; color: var(--text-2); }
.kind-row b { text-align: end; }
.as-newbest { color: var(--success); font-weight: 800; margin-bottom: 12px; }
.as-review { text-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; }
.as-review summary { cursor: pointer; font-weight: 800; color: var(--text-2); }
.as-review ol { list-style: none; margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.as-review li { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-strong); border: 1px solid var(--border); }
.as-review li.ok i { color: var(--success); } .as-review li.ko i { color: var(--danger); }
.as-review li i { margin-top: 3px; }
.as-review .rq { font-weight: 700; font-size: 0.9rem; }
.as-review .rw { color: var(--text-2); font-size: 0.82rem; margin-top: 3px; line-height: 1.5; }
.dash-assess { display: flex; align-items: center; gap: 16px; padding: 18px 20px; margin-bottom: 22px; cursor: pointer; }
.dash-assess .ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-size: 1.4rem; background: linear-gradient(135deg, #0ea5e9, #6366f1); flex: 0 0 52px; }
.dash-assess b { display: block; font-size: 1.05rem; }
.dash-assess small { color: var(--text-2); }
.dash-assess .pills { margin-inline-start: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dash-assess .pill { padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 800; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.dash-assess .pill.ok { color: var(--success); border-color: rgba(16, 185, 129, 0.5); }
@media (max-width: 720px) {
  .as-grid { grid-template-columns: 1fr; }
  .as-result .result-stats { grid-template-columns: repeat(2, 1fr); }
  .kind-row { grid-template-columns: 110px 1fr 40px; }
  .dash-assess { flex-wrap: wrap; } .dash-assess .pills { margin-inline-start: 0; justify-content: flex-start; }
}

/* --- Stories & Short Articles (graded readers) --- */
.st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.st-card { padding: 0; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.st-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.st-cover { height: 110px; display: grid; place-items: center; position: relative; color: #fff; font-size: 2.6rem; background: linear-gradient(135deg, #14b8a6, #0ea5e9); }
.st-card.article .st-cover { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.st-cover .badge { position: absolute; top: 10px; background: rgba(255, 255, 255, 0.92); color: var(--text); }
.st-cover .badge.type { inset-inline-start: 10px; } .st-cover .badge.lvl { inset-inline-end: 10px; }
.st-card.done .st-cover::after { content: '\f058'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; bottom: 8px; inset-inline-end: 12px; font-size: 1.1rem; }
.st-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.st-body h3 { font-size: 1.2rem; font-weight: 900; display: flex; flex-direction: column; gap: 2px; }
.st-body h3 .pinyin { font-size: 0.8rem; color: var(--text-3); font-weight: 500; }
.st-title-native { font-weight: 700; color: var(--accent); }
.st-body p { color: var(--text-2); font-size: 0.9rem; line-height: 1.55; flex: 1; }
.st-wrap { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.st-head { display: flex; align-items: center; gap: 14px; padding: 14px 18px; flex-wrap: wrap; }
.st-head-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-size: 1.2rem; background: linear-gradient(135deg, #14b8a6, #0ea5e9); flex: 0 0 46px; }
.st-head .who { flex: 1; min-width: 200px; }
.st-head .who b { display: block; font-size: 1.1rem; }
.st-head .who b .pinyin { font-size: 0.8rem; color: var(--text-3); font-weight: 500; }
.st-head .who small { color: var(--text-3); }
.st-toggles { display: flex; gap: 14px; flex-wrap: wrap; }
.st-tabs { display: flex; gap: 6px; padding: 5px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.st-tabs button { flex: 1; border: 0; background: transparent; color: var(--text-2); padding: 10px 12px; border-radius: 12px; font-weight: 800; cursor: pointer; font-family: inherit; font-size: 0.9rem; transition: all var(--t); }
.st-tabs button.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 8px 18px -8px var(--accent); }
.st-tabs button .fa-circle-check { color: #a7f3d0; }
.st-tabs button:not(.on) .fa-circle-check { color: var(--success); }
.st-panel { padding: 22px; }
.st-panel.hide-tr .tr { display: none !important; }
.st-panel.hide-py .pinyin { display: none !important; }
.st-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.st-progress { font-weight: 800; color: var(--text-2); font-size: 0.9rem; }
.st-hint { color: var(--text-3); font-size: 0.82rem; margin-inline-start: auto; }
.st-text { display: flex; flex-direction: column; gap: 22px; }
.st-h { display: flex; flex-direction: column; gap: 2px; font-size: 1.2rem; font-weight: 900; padding-bottom: 6px; border-bottom: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.st-h .pinyin { font-size: 0.8rem; color: var(--accent); font-weight: 500; }
.st-h .tr { font-size: 0.9rem; color: var(--text-3); font-weight: 600; }
.st-para { display: flex; flex-direction: column; gap: 6px; }
.st-line { position: relative; padding: 12px 52px 12px 16px; border-radius: 14px; border: 1px solid transparent; transition: all var(--t); cursor: pointer; }
[dir='rtl'] .st-line { padding: 12px 16px 12px 52px; }
.st-line:hover { background: var(--surface); border-color: var(--border); }
.st-line:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.st-line.heard { border-inline-start: 3px solid var(--success); }
.st-line.playing { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: var(--accent); box-shadow: 0 8px 20px -12px var(--accent); }
.st-line .tx { font-size: 1.12rem; line-height: 1.7; font-weight: 600; }
.st-line .tx.zh { font-family: var(--font-zh); font-size: 1.35rem; line-height: 1.9; }
.st-line .pinyin { font-size: 0.85rem; color: var(--accent); font-family: var(--font-ltr); margin-top: 2px; }
.st-line .tr { color: var(--text-2); font-size: 0.95rem; line-height: 1.6; margin-top: 4px; }
.st-line .speak { position: absolute; top: 10px; inset-inline-end: 10px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; padding: 0; margin: 0; }
.st-finish { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.fb.good-inline { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; font-weight: 700; color: var(--success); background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.35); }
.st-section { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 900; margin-bottom: 6px; }
.st-section small { color: var(--text-3); font-weight: 700; }
.spot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.spot-card { padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.spot-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.spot-card .w { font-size: 1.3rem; font-weight: 900; }
.spot-card .w.zh { font-family: var(--font-zh); font-size: 1.6rem; }
.spot-card .pinyin, .spot-card .ph { font-size: 0.82rem; color: var(--accent); font-family: var(--font-ltr); }
.spot-card .ph { color: var(--text-3); }
.spot-actions { display: flex; align-items: center; gap: 8px; }
.spot-actions .speak { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; padding: 0; margin: 0; }
.spot-card .def { color: var(--text); font-size: 0.92rem; line-height: 1.55; flex: 1; }
.spot-ex { padding: 10px 12px; border-radius: 12px; background: var(--surface-strong); border: 1px dashed var(--border); font-size: 0.9rem; }
.spot-ex .ltr { font-weight: 600; } .spot-ex .zh { font-family: var(--font-zh); font-size: 1.05rem; }
.spot-ex .tr { color: var(--text-3); margin-top: 3px; font-size: 0.85rem; }
.spot-ex .speak.mini { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; padding: 0; margin: 0 4px; vertical-align: middle; font-size: 0.7rem; }
.st-qs { list-style: none; display: flex; flex-direction: column; gap: 16px; }
.st-q { padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); transition: border-color var(--t); }
.st-q.ok { border-color: rgba(16, 185, 129, 0.5); } .st-q.ko { border-color: rgba(239, 68, 68, 0.45); }
.st-q-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.st-q-head .num { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-weight: 900; font-size: 0.85rem; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.st-q-head b { flex-basis: 100%; font-size: 1.02rem; line-height: 1.5; }
.st-q-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.st-q-opts .option { display: flex; align-items: center; gap: 10px; text-align: start; }
.st-q-opts .option.tf { justify-content: center; font-size: 1.05rem; }
.st-q-opts .option .key { flex: 0 0 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 0.72rem; font-weight: 900; background: var(--surface-strong); border: 1px solid var(--border); color: var(--text-3); }
.st-q-fb:empty { display: none; }
.st-q-fb { margin-top: 12px; }
.st-result { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; width: 100%; padding: 16px 18px; border-radius: 16px; background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.35); animation: bounceIn 0.4s; }
.st-result.fail { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.3); }
.st-result .trophy { font-size: 2rem; }
.st-result b { font-size: 1.05rem; } .st-result .sub { color: var(--text-2); font-size: 0.9rem; font-weight: 700; }
.st-result-actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .st-grid { grid-template-columns: 1fr; }
  .st-panel { padding: 16px; }
  .st-tabs button { font-size: 0.8rem; padding: 9px 6px; }
  .st-q-opts { grid-template-columns: 1fr; }
  .st-hint { display: none; }
  .st-result-actions { margin-inline-start: 0; }
}
.dash-stories .ico { background: linear-gradient(135deg, #14b8a6, #0ea5e9); }
.profile-hero .mini-stats { flex-wrap: wrap; justify-content: center; }
.continue-card h4 { overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .continue-card { flex-wrap: wrap; }
  .continue-card .info { flex-basis: calc(100% - 78px); }
  .continue-card > .btn { flex-basis: 100%; justify-content: center; }
  .continue-card h4 { font-size: 1.02rem; }
}

/* ---- Listening comprehension items ---- */
.listen-box { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; padding: 16px; margin: 12px 0 16px; border-radius: 16px; background: linear-gradient(135deg, rgba(99,102,241,.10), rgba(14,165,233,.10)); border: 1px dashed rgba(99,102,241,.35); }
.listen-play { width: 60px; height: 60px; border-radius: 50%; padding: 0; font-size: 1.3rem; display: grid; place-items: center; box-shadow: 0 8px 20px rgba(99,102,241,.35); animation: listen-pulse 1.6s ease-in-out infinite; }
.listen-play.played { animation: none; }
.listen-play.speaking { animation: listen-pulse .8s ease-in-out infinite; }
@keyframes listen-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.listen-txt { display: flex; flex-direction: column; gap: 2px; }
.listen-txt b { font-size: 1rem; }
.listen-txt small { color: var(--muted); font-size: .8rem; }
.listen-reveal { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 12px; background: var(--card, #fff); border: 1px solid var(--border, #e5e7eb); font-size: 1.1rem; font-weight: 600; animation: fade-up .35s ease both; }
.listen-reveal .pinyin { font-weight: 400; font-size: .9rem; color: var(--muted); }
.listen-box.revealed { border-style: solid; }
.listen-reveal[hidden] { display: none; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) { .listen-box { padding: 12px; gap: 10px; } .listen-play { width: 52px; height: 52px; } }

/* ---- Stories library (10 readers / language) ---- */
.st-lib { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 16px 18px 14px; margin-bottom: 14px; }
.st-lib-stat { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.st-lib-stat b { font-size: 1.15rem; }
.st-lib-stat span { font-size: .74rem; color: var(--text-3); }
.st-lib-bar { grid-column: 1 / -1; margin-top: 6px; }
.st-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 16px; }
.st-filters .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.st-filters .chip { border: 1px solid var(--border, #e5e7eb); background: var(--card, #fff); color: var(--text-2); border-radius: 999px; padding: 6px 12px; font-size: .82rem; cursor: pointer; transition: all .15s; font-family: inherit; }
.st-filters .chip:hover { border-color: var(--accent); color: var(--accent); }
.st-filters .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.st-count { margin-inline-start: auto; font-size: .82rem; color: var(--text-3); font-weight: 600; }
.st-num { position: absolute; bottom: 8px; inset-inline-start: 12px; font-size: .78rem; font-weight: 700; background: rgba(0,0,0,.28); color: #fff; border-radius: 999px; padding: 2px 9px; }
.st-card { animation: fade-up .4s ease both; }
.st-empty { grid-column: 1 / -1; text-align: center; color: var(--text-3); padding: 30px 0; }
@media (max-width: 640px) { .st-lib { grid-template-columns: repeat(3, 1fr); } .st-lib-stat:nth-child(4), .st-lib-stat:nth-child(5) { display: none; } .st-count { width: 100%; margin: 0; } }

/* ---- Masterclass: common mistakes + table of contents ---- */
.mc-toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 18px; }
.mc-toc a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .8rem; font-weight: 600; color: var(--mc, var(--accent)); background: color-mix(in srgb, var(--mc, var(--accent)) 10%, transparent); text-decoration: none; transition: background .15s; }
.mc-toc a:hover { background: color-mix(in srgb, var(--mc, var(--accent)) 20%, transparent); }
.mistake-list { display: grid; gap: 12px; }
.mistake { border: 1px solid var(--border, #e5e7eb); border-radius: 14px; overflow: hidden; background: var(--card, #fff); animation: fade-up .35s ease both; }
.mk-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.mk-row.wrong { background: rgba(239, 68, 68, .07); }
.mk-row.right { background: rgba(16, 185, 129, .08); border-top: 1px dashed rgba(16, 185, 129, .3); }
.mk-mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: .8rem; flex-shrink: 0; }
.mk-row.wrong .mk-mark { background: #ef4444; } .mk-row.right .mk-mark { background: #10b981; }
.mk-text { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 1.02rem; line-height: 1.45; }
.mk-text s { color: #b91c1c; text-decoration-color: rgba(185, 28, 28, .6); }
.mk-text b { color: #047857; }
.mk-text .pinyin { font-size: .82rem; color: var(--text-3); font-weight: 400; }
.mk-why { padding: 10px 14px 12px; font-size: .9rem; color: var(--text-2); border-top: 1px solid var(--border, #e5e7eb); display: flex; gap: 8px; align-items: flex-start; }
.mk-why i { color: var(--mc, var(--accent)); margin-top: 3px; }
.mc-mistakes .speak-inline { flex-shrink: 0; }
@media (max-width: 640px) { .mk-row { padding: 9px 11px; } .mk-text { font-size: .96rem; } }
