:root {
  --primary: #2c1f80;
  --primary-light: #4338ca;
  --primary-dark: #1e1660;
  --accent: #00a1e3;
  --gradient: linear-gradient(135deg, #2c1f80 0%, #00a1e3 100%);
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #EEF1F6;
  --text: #0F172A;
  --text-2: #5E6B82;
  --text-3: #94A3B8;
  --border: #E2E8F0;
  --success: #10B981;
  --success-bg: #D1FAE5;
  --warning: #F59E0B;
  --warning-bg: #FEF3C7;
  --danger: #EF4444;
  --danger-bg: #FEE2E2;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(44,31,128,.06);
  --shadow-lg: 0 8px 24px rgba(44,31,128,.1);
  --shadow-xl: 0 16px 48px rgba(44,31,128,.14);
  --nav-height: 64px;
  --topbar-height: 60px;
  --transition: cubic-bezier(.4, 0, .2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; }
input, select, textarea {
  font-family: inherit; font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .3s var(--transition), box-shadow .3s var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44,31,128,.1);
}

/* ===== APP SHELL ===== */
#app {
  height: 100%;
  position: relative;
  overflow: hidden;
  max-width: 100%;
  margin: 0 auto;
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity .35s var(--transition), transform .35s var(--transition);
  transform: translateY(20px);
  background: var(--bg);
  z-index: 1;
  will-change: opacity, transform;
}
.screen.active {
  opacity: 1; pointer-events: auto;
  transform: translateY(0);
  z-index: 10;
}

/* ===== SPLASH ===== */
#splash {
  background: var(--gradient);
  justify-content: center; align-items: center;
  z-index: 100;
}
.splash-content { text-align: center; color: #fff; }
.splash-logo {
  width: 88px; height: 88px; margin: 0 auto 20px;
  border-radius: 22px;
  overflow: hidden;
  animation: splashPulse 2s ease infinite;
}
.splash-logo img { width: 100%; height: 100%; object-fit: cover; }
@keyframes splashPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,.3); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(255,255,255,0); }
}
.splash-title { font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.splash-sub { margin-top: 10px; opacity: .7; font-size: 14px; }
.splash-loader {
  width: 32px; height: 32px; margin: 24px auto 0;
  border: 2.5px solid rgba(255,255,255,.25); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}

/* ===== LOGIN ===== */
#login {
  justify-content: center; align-items: center; padding: 24px;
  background: var(--bg);
}
.login-wrap { width: 100%; max-width: 380px; text-align: center; }
.login-logo {
  width: 72px; height: 72px; margin: 0 auto 20px;
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 6px 20px rgba(44,31,128,.2);
  transition: transform .3s var(--transition);
}
.login-logo:hover { transform: scale(1.05); }
.login-logo img { width: 100%; height: 100%; object-fit: cover; }
.login-wrap h1 { font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.login-subtitle { color: var(--text-2); margin: 6px 0 28px; font-size: 14px; }
.input-group { position: relative; margin-bottom: 14px; display: flex; align-items: center; }
.input-icon { position: absolute; left: 14px; color: var(--text-3); font-size: 20px; z-index: 1; }
.input-group input[type="tel"],
.input-group input[type="password"] { padding-left: 44px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 20px; }

.btn-primary {
  width: 100%; padding: 14px; border-radius: var(--radius);
  background: var(--gradient); color: #fff;
  font-size: 15px; font-weight: 600;
  transition: transform .15s var(--transition), box-shadow .2s;
  box-shadow: 0 4px 12px rgba(44,31,128,.2);
  position: relative; overflow: hidden;
}
.btn-primary::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(rgba(255,255,255,.1), transparent);
  opacity: 0; transition: opacity .2s;
}
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: scale(.97); box-shadow: 0 2px 8px rgba(44,31,128,.15); }
.btn-primary:disabled { opacity: .5; pointer-events: none; }
.btn-danger {
  width: 100%; padding: 14px; border-radius: var(--radius);
  background: var(--danger); color: #fff;
  font-size: 15px; font-weight: 600; margin-top: 24px;
  transition: transform .15s; box-shadow: 0 4px 12px rgba(239,68,68,.2);
}
.btn-danger:active { transform: scale(.97); }
.btn-finish { background: linear-gradient(135deg, #059669, #10B981); box-shadow: 0 4px 12px rgba(16,185,129,.2); }
.btn-finish:hover { background: linear-gradient(135deg, #047857, #059669); }

/* ===== TOP BAR ===== */
.topbar {
  height: var(--topbar-height);
  padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
  flex-shrink: 0;
  position: relative; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; background: var(--surface-2);
  border: 2px solid var(--surface-2);
}
.topbar-name { font-size: 14px; font-weight: 600; }
.topbar-group { font-size: 12px; color: var(--text-2); }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.points-badge {
  display: flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #FEF3C7, #FDE68A); padding: 5px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600; color: #92400E;
  box-shadow: 0 1px 3px rgba(245,158,11,.15);
}
.points-badge .material-icons-round { font-size: 16px; color: #F59E0B; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: all .2s var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--primary); }

/* ===== PAGES ===== */
.pages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding-bottom: calc(var(--nav-height) + 20px);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.page {
  display: none; padding: 16px;
  animation: pageIn .3s var(--transition);
}
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-header {
  font-size: 24px; font-weight: 700; margin-bottom: 16px;
  padding-top: 4px; letter-spacing: -.3px;
}

/* ===== CALENDAR STRIP ===== */
.calendar-strip {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 0 14px; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.calendar-strip::-webkit-scrollbar { display: none; }
.cal-day {
  flex-shrink: 0; width: 46px; text-align: center;
  padding: 8px 0; border-radius: var(--radius-sm);
  cursor: pointer; transition: all .25s var(--transition);
}
.cal-day:active { transform: scale(.92); }
.cal-day .day-letter { font-size: 11px; color: var(--text-3); font-weight: 500; text-transform: uppercase; }
.cal-day .day-num { font-size: 16px; font-weight: 600; margin-top: 3px; }
.cal-day .day-dot { width: 5px; height: 5px; border-radius: 50%; margin: 4px auto 0; transition: background .3s; }
.cal-day.today { background: var(--gradient); color: #fff; box-shadow: 0 3px 10px rgba(44,31,128,.2); }
.cal-day.today .day-letter { color: rgba(255,255,255,.7); }
.cal-day.selected { background: var(--primary-dark); color: #fff; box-shadow: 0 3px 10px rgba(44,31,128,.15); }
.cal-day.selected .day-letter { color: rgba(255,255,255,.7); }
.cal-day.done .day-dot { background: var(--success); }
.cal-day.partial .day-dot { background: var(--warning); }

/* ===== SECTION TITLE ===== */
.section-title {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0 10px; font-size: 17px; font-weight: 700;
}
.section-date { font-size: 13px; color: var(--text-2); font-weight: 500; }

/* ===== TASK CARDS ===== */
.tasks-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: all .2s var(--transition);
  border: 1px solid transparent;
}
.task-card:active { transform: scale(.98); }
.task-card:hover { box-shadow: var(--shadow-lg); border-color: rgba(44,31,128,.06); }
.task-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
  transition: transform .2s var(--transition);
}
.task-card:hover .task-icon { transform: scale(1.05); }
.task-icon.grammar { background: linear-gradient(135deg, #EDE9FE, #DDD6FE); color: #7C3AED; }
.task-icon.vocabulary { background: linear-gradient(135deg, #DBEAFE, #BFDBFE); color: #2563EB; }
.task-icon.listening { background: linear-gradient(135deg, #FEF3C7, #FDE68A); color: #D97706; }
.task-icon.reading { background: linear-gradient(135deg, #D1FAE5, #A7F3D0); color: #059669; }
.task-icon.homework { background: linear-gradient(135deg, #FCE7F3, #FBCFE8); color: #DB2777; }
.task-info { flex: 1; min-width: 0; }
.task-name { font-size: 14px; font-weight: 600; }
.task-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.task-score {
  font-size: 13px; font-weight: 700; padding: 4px 12px;
  border-radius: 20px; flex-shrink: 0;
}
.task-score.done { background: var(--success-bg); color: #065F46; }
.task-score.partial { background: var(--warning-bg); color: #92400E; }
.task-score.none { background: var(--surface-2); color: var(--text-3); }

/* ===== VOCAB PREVIEW ===== */
.vocab-preview { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.vocab-preview::-webkit-scrollbar { display: none; }
.vocab-card {
  flex-shrink: 0; width: 140px;
  background: var(--surface); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
  transition: transform .2s var(--transition);
}
.vocab-card:hover { transform: translateY(-2px); }
.vocab-card img { width: 100%; height: 80px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 8px; }
.vocab-word { font-size: 13px; font-weight: 600; }
.vocab-trans { font-size: 11px; color: var(--text-2); margin-top: 3px; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  font-size: 11px; color: var(--text-3);
  padding: 6px 0; transition: all .25s var(--transition);
  position: relative;
}
.nav-item .material-icons-round { font-size: 24px; transition: transform .2s var(--transition); }
.nav-item.active { color: var(--primary); font-weight: 600; }
.nav-item.active .material-icons-round { transform: scale(1.1); }
.nav-item::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 0; height: 2.5px; border-radius: 2px;
  background: var(--gradient); transition: width .3s var(--transition);
}
.nav-item.active::before { width: 24px; }

/* ===== TASK VIEW ===== */
.task-header {
  height: 56px; padding: 0 8px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); box-shadow: 0 1px 0 var(--border);
  flex-shrink: 0;
}
.task-view-title { font-size: 16px; font-weight: 600; flex: 1; text-align: center; }
.task-progress-text { font-size: 13px; color: var(--text-2); width: 50px; text-align: right; padding-right: 8px; }
.task-progress-bar { height: 3px; background: var(--surface-2); flex-shrink: 0; }
.task-progress-fill {
  height: 100%; background: var(--gradient);
  transition: width .4s var(--transition);
  width: 0%; border-radius: 0 2px 2px 0;
}
.exercise-area { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.task-footer {
  padding: 12px 16px; background: var(--surface);
  box-shadow: 0 -1px 0 var(--border); flex-shrink: 0;
}

/* ===== EXERCISE STYLES ===== */
.ex-instruction { font-size: 14px; color: var(--text-2); margin-bottom: 16px; line-height: 1.6; }
.ex-passage {
  background: var(--surface-2); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
  font-size: 14px; line-height: 1.75;
}
.ex-passage p { margin-bottom: 8px; }
.ex-audio { width: 100%; margin-bottom: 16px; border-radius: var(--radius-sm); }
.ex-image {
  width: 100%; max-height: 300px; object-fit: contain;
  border-radius: var(--radius); margin-bottom: 16px;
}
.ex-question { font-size: 15px; font-weight: 500; margin-bottom: 12px; line-height: 1.5; }
.ex-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.ex-option {
  padding: 13px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 14px; text-align: left;
  transition: all .2s var(--transition);
  cursor: pointer;
}
.ex-option:hover { border-color: var(--primary-light); background: rgba(44,31,128,.03); }
.ex-option.selected { border-color: var(--primary); background: rgba(44,31,128,.06); color: var(--primary); font-weight: 500; }
.ex-option.correct { border-color: var(--success); background: var(--success-bg); }
.ex-option.wrong { border-color: var(--danger); background: var(--danger-bg); }

.ex-input {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 10px;
  transition: all .2s var(--transition);
}
.ex-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(44,31,128,.08); }
.ex-input.correct { border-color: var(--success); background: var(--success-bg); }
.ex-input.wrong { border-color: var(--danger); background: var(--danger-bg); }

.ex-word-bank { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.ex-word-chip {
  padding: 9px 16px; border-radius: 22px;
  background: var(--surface); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .2s var(--transition); user-select: none;
  border: 1.5px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.ex-word-chip:hover { border-color: var(--primary-light); transform: translateY(-1px); }
.ex-word-chip.used { opacity: .3; pointer-events: none; transform: scale(.95); }
.ex-word-chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

.ex-drop-zone {
  min-height: 48px; padding: 10px 12px; margin-bottom: 12px;
  border: 2px dashed var(--border); border-radius: var(--radius);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  transition: border-color .2s;
}
.ex-drop-zone:has(.ex-word-chip) { border-color: var(--primary-light); border-style: solid; }
.ex-drop-zone .ex-word-chip { background: rgba(44,31,128,.08); border-color: var(--primary); }

.ex-match-left, .ex-match-right { display: flex; flex-direction: column; gap: 8px; }
.ex-match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.match-item {
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); text-align: center;
  font-size: 14px; cursor: pointer; transition: all .2s var(--transition);
}
.match-item:hover { border-color: var(--primary-light); }
.match-item.selected { border-color: var(--primary); background: rgba(44,31,128,.06); }
.match-item.matched { border-color: var(--success); background: var(--success-bg); }

.pic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.pic-item {
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.pic-item img { width: 100%; height: 100px; object-fit: cover; }
.pic-item select {
  width: 100%; border: none; border-top: 1px solid var(--border);
  padding: 8px 10px; font-size: 12px; border-radius: 0;
}

.choose-select {
  display: inline-block; padding: 3px 8px;
  border: 1.5px solid var(--primary); border-radius: 6px;
  background: rgba(44,31,128,.06); font-size: inherit; font-weight: 600;
  color: var(--primary); cursor: pointer;
  min-width: 60px; text-align: center;
}

/* ===== RESULT VIEW ===== */
#result-view { justify-content: center; align-items: center; padding: 24px; }
.result-content { text-align: center; width: 100%; max-width: 340px; }
.result-icon { font-size: 72px; margin-bottom: 16px; animation: resultBounce .5s var(--transition); }
@keyframes resultBounce { 0% { transform: scale(0); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.result-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.result-score { font-size: 52px; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 8px; }
.result-points { font-size: 16px; color: var(--text-2); margin-bottom: 24px; }
.result-details { font-size: 13px; color: var(--text-3); margin-bottom: 24px; }

/* ===== SETTINGS ===== */
.settings-content { flex: 1; overflow-y: auto; padding: 16px; }
.settings-section { margin-bottom: 20px; }
.settings-title { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 8px; }
.settings-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px; background: var(--surface);
  border-radius: var(--radius-sm); margin-bottom: 6px;
  font-size: 14px; transition: background .2s;
}
.settings-item.clickable { cursor: pointer; }
.settings-item.clickable:hover { background: var(--surface-2); }
.settings-item.clickable:active { transform: scale(.99); }
.settings-value { color: var(--text-2); font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.token-text { font-family: 'SF Mono', 'Consolas', monospace; font-size: 10px; }

/* ===== API EXPLORER ===== */
.explorer-content { flex: 1; overflow-y: auto; padding: 16px; }
.explorer-content select { width: auto; display: inline-block; margin-bottom: 0; }
.api-response {
  margin-top: 16px; padding: 14px;
  background: #1a1b2e; color: #c4c9e2;
  border-radius: var(--radius);
  font-size: 12px; overflow-x: auto;
  white-space: pre-wrap; word-break: break-all;
  max-height: 400px; overflow-y: auto;
  font-family: 'SF Mono', 'Consolas', monospace;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.2);
}

/* ===== PROGRESS ===== */
.progress-content { padding: 0; }
.progress-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.progress-label { font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.progress-value { font-size: 26px; font-weight: 700; }
.progress-bar-bg {
  height: 8px; background: var(--surface-2); border-radius: 4px;
  margin-top: 10px; overflow: hidden;
}
.progress-bar-fill { height: 100%; background: var(--gradient); border-radius: 4px; transition: width .6s var(--transition); }

/* ===== LEADERBOARD ===== */
.lb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; background: var(--surface);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  box-shadow: var(--shadow); transition: transform .15s;
}
.lb-item:hover { transform: translateX(2px); }
.lb-rank {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.lb-rank.gold { background: linear-gradient(135deg, #FEF3C7, #FDE68A); color: #92400E; }
.lb-rank.silver { background: linear-gradient(135deg, #E2E8F0, #CBD5E1); color: #475569; }
.lb-rank.bronze { background: linear-gradient(135deg, #FED7AA, #FDBA74); color: #9A3412; }
.lb-rank.normal { background: var(--surface-2); color: var(--text-2); }
.lb-name { flex: 1; font-size: 14px; font-weight: 500; }
.lb-points { font-size: 14px; font-weight: 700; color: var(--primary); }

/* ===== PROFILE ===== */
.profile-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px 20px; text-align: center; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.profile-avatar {
  width: 84px; height: 84px; border-radius: 50%;
  object-fit: cover; margin: 0 auto 14px;
  border: 3px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box,
              var(--gradient) border-box;
}
.profile-name { font-size: 22px; font-weight: 700; }
.profile-phone { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.profile-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 12px; margin-top: 18px;
}
.profile-stat { text-align: center; }
.profile-stat-val { font-size: 22px; font-weight: 700; color: var(--primary); }
.profile-stat-label { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.profile-info-list { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.profile-info-item {
  display: flex; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.profile-info-item:last-child { border-bottom: none; }
.profile-info-label { color: var(--text-2); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--text); color: #fff; padding: 11px 22px;
  border-radius: 24px; font-size: 13px; font-weight: 500;
  opacity: 0; transition: all .35s var(--transition); z-index: 999;
  max-width: calc(100% - 48px); text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===== LOADING ===== */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-placeholder { text-align: center; padding: 40px; color: var(--text-3); }

/* ===== RESPONSIVE ===== */

/* All screens — full width, real website layout */
img, video, canvas { max-width: 100%; height: auto; }

/* Tablet+ (768px): wider layout, bigger cards, grid for tasks */
@media (min-width: 768px) {
  html, body { overflow: auto; }
  #app { height: auto; min-height: 100vh; overflow: visible; }

  .screen {
    position: relative; inset: auto;
    min-height: 100vh;
    transform: none;
  }
  .screen:not(.active) { display: none; }
  .screen.active { display: flex; }

  /* Splash & login centered */
  #splash { min-height: 100vh; position: fixed; inset: 0; }
  #login { min-height: 100vh; }
  .login-wrap { max-width: 420px; }
  .login-logo { width: 80px; height: 80px; border-radius: 20px; }

  /* Main layout — flex column so order works */
  #main { min-height: 100vh; flex-direction: column; }
  .topbar {
    height: 64px; padding: 0 32px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
  }
  .avatar { width: 40px; height: 40px; }
  .topbar-name { font-size: 15px; }

  .pages { padding: 24px 32px 32px; padding-bottom: 32px; }
  .page { padding: 0; }
  .page-header { font-size: 26px; margin-bottom: 20px; }

  /* Tasks in grid on tablet */
  .tasks-list {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
  }
  .task-card { padding: 16px 18px; }
  .task-icon { width: 48px; height: 48px; border-radius: 14px; font-size: 22px; }
  .task-name { font-size: 15px; }

  /* Calendar wider */
  .calendar-strip { gap: 8px; padding: 10px 0 16px; }
  .cal-day { width: 52px; padding: 10px 0; }
  .cal-day .day-num { font-size: 17px; }

  /* Vocab cards */
  .vocab-preview { gap: 14px; }
  .vocab-card { width: 160px; padding: 14px; }
  .vocab-card img { height: 90px; }

  /* Progress grid */
  .progress-content { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .progress-card { margin-bottom: 0; padding: 20px; }
  .progress-value { font-size: 28px; }

  /* Leaderboard */
  .lb-item { padding: 14px 20px; }

  /* Profile wider */
  .profile-card { padding: 28px; max-width: 500px; margin: 0 auto 20px; }
  .profile-avatar { width: 96px; height: 96px; }
  .profile-name { font-size: 24px; }
  .profile-info-list { max-width: 500px; margin: 0 auto; }

  /* Bottom nav as top nav on tablet+ */
  .bottom-nav {
    position: static; height: auto;
    border-top: none; border-bottom: 1px solid var(--border);
    padding: 0 32px;
    order: -1;
  }
  .nav-item { flex: none; padding: 14px 20px; flex-direction: row; gap: 6px; font-size: 13px; }
  .nav-item .material-icons-round { font-size: 20px; }
  .nav-item::before { top: auto; bottom: 0; }
  .nav-item.active::before { width: 100%; }

  /* Settings / explorer wider */
  .settings-content { padding: 24px 32px; max-width: 600px; }
  .explorer-content { padding: 24px 32px; max-width: 700px; }

  /* Task view */
  #task-view { min-height: 100vh; }
  .task-header { padding: 0 24px; }
  .exercise-area { padding: 24px 32px; max-width: 700px; margin: 0 auto; }
  .task-footer { padding: 16px 32px; }
  .task-footer .btn-primary { max-width: 400px; margin: 0 auto; display: block; }

  /* Result */
  #result-view { min-height: 100vh; }
  .result-score { font-size: 56px; }

  /* Settings & API explorer */
  #settings, #api-explorer { min-height: 100vh; }
}

/* Desktop (1024px+): 3-column grid for tasks, wider container */
@media (min-width: 1024px) {
  .topbar { padding: 0 48px; }
  .pages { padding: 28px 48px calc(var(--nav-height) + 28px); max-width: 1200px; margin: 0 auto; }
  .bottom-nav { padding: 0 48px; max-width: 1200px; margin: 0 auto; }

  .tasks-list { grid-template-columns: repeat(3, 1fr); gap: 16px; }

  .progress-content { grid-template-columns: repeat(3, 1fr); gap: 16px; }

  .section-title { font-size: 18px; }

  .exercise-area { max-width: 800px; padding: 28px 48px; }
  .settings-content { max-width: 700px; margin: 0 auto; }
  .explorer-content { max-width: 800px; margin: 0 auto; }

  .login-wrap { max-width: 440px; }
  .login-logo { width: 88px; height: 88px; }
  .login-wrap h1 { font-size: 28px; }

  /* Leaderboard in 2 columns */
  .leaderboard-content { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .lb-item { margin-bottom: 0; }
}

/* Large desktop (1440px+) */
@media (min-width: 1440px) {
  .pages { max-width: 1400px; padding: 32px 64px 96px; }
  .tasks-list { grid-template-columns: repeat(4, 1fr); }
  .progress-content { grid-template-columns: repeat(4, 1fr); }
  .leaderboard-content { grid-template-columns: repeat(3, 1fr); }
}
