/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:    #0d1117;
  --bg-card:    #161b27;
  --bg-card2:   #1c2235;
  --bg-input:   #1a2030;
  --accent:     #5b4ee8;
  --accent2:    #7c6ff0;
  --gold:       #f5a623;
  --text-1:     #e8eaf0;
  --text-2:     #8b92a8;
  --text-3:     #5a6078;
  --border:     rgba(255,255,255,0.07);
  --border2:    rgba(255,255,255,0.12);
  --danger:     #e05454;
  --success:    #3ecf8e;
  --nav-h:      64px;
  --header-h:   56px;
  --radius:     14px;
  --radius-sm:  8px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text-1);
  font-family: -apple-system, 'SF Pro Display', 'Segoe UI', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ===== HEADER ===== */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.header-user { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  text-transform: uppercase;
  flex-shrink: 0;
}

.header-name { font-size: 15px; font-weight: 600; color: var(--text-1); }

.header-stats { display: flex; align-items: center; gap: 8px; }

.stat-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--border2);
}

.stat-chip.streak {
  background: rgba(91,78,232,0.15);
  color: #a89ef5;
  border-color: rgba(91,78,232,0.3);
}

.stat-chip.coins {
  background: rgba(245,166,35,0.12);
  color: var(--gold);
  border-color: rgba(245,166,35,0.25);
}

.coin-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  display: inline-block;
}

/* ===== PAGES ===== */
.pages {
  position: fixed;
  top: var(--header-h);
  bottom: var(--nav-h);
  left: 0; right: 0;
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 14px 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  -webkit-overflow-scrolling: touch;
}

.page.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ===== PAGE TITLE ===== */
.page-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-align: center;
  color: var(--text-1);
  margin-bottom: 6px;
}

.page-title-underline {
  width: 48px; height: 3px;
  background: var(--accent);
  border-radius: 4px;
  margin: 0 auto 20px;
}

/* ===== COURSE CARDS ===== */
.courses-list { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }

.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
  position: relative;
  overflow: hidden;
}

.course-card:active { transform: scale(0.98); }
.course-card:hover { background: var(--bg-card2); border-color: var(--border2); }

.course-thumb {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  background: rgba(91,78,232,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(91,78,232,0.3);
}

.course-thumb svg { color: var(--accent2); }

.course-info { flex: 1; min-width: 0; }

.course-name {
  font-size: 15px; font-weight: 700;
  color: var(--text-1);
  margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.course-meta { display: flex; align-items: center; gap: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-blue { background: rgba(91,78,232,0.18); color: #a89ef5; border: 1px solid rgba(91,78,232,0.25); }
.badge-gold { background: rgba(245,166,35,0.15); color: var(--gold); border: 1px solid rgba(245,166,35,0.25); }
.badge-green { background: rgba(62,207,142,0.15); color: var(--success); border: 1px solid rgba(62,207,142,0.25); }
.badge-gray { background: rgba(255,255,255,0.07); color: var(--text-2); border: 1px solid var(--border); }

.course-desc {
  font-size: 12px; color: var(--text-3);
  margin-top: 8px; line-height: 1.5;
}

.course-arrow {
  color: var(--text-3);
  flex-shrink: 0;
}

/* ===== VIDEO LIST (inside course modal) ===== */
.video-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.video-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.video-item:active { transform: scale(0.985); }
.video-item:hover { background: rgba(91,78,232,0.1); border-color: rgba(91,78,232,0.25); }

.video-num {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: rgba(91,78,232,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--accent2);
  flex-shrink: 0;
}

.video-locked .video-num { background: rgba(255,255,255,0.06); color: var(--text-3); }

.video-name { flex: 1; font-size: 13px; color: var(--text-1); line-height: 1.4; }
.video-locked .video-name { color: var(--text-3); }

.video-code { font-size: 11px; color: var(--text-3); font-family: monospace; }

.lock-icon { color: var(--text-3); flex-shrink: 0; }

/* ===== TEST CARDS ===== */
.tests-list { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }

.test-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
}

.test-card:active { transform: scale(0.98); }
.test-card:hover { background: var(--bg-card2); }

.test-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(62,207,142,0.12);
  border: 1px solid rgba(62,207,142,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--success);
}

.test-info { flex: 1; }
.test-name { font-size: 14px; font-weight: 700; color: var(--text-1); margin-bottom: 4px; }
.test-meta { font-size: 12px; color: var(--text-2); }

.test-arrow { color: var(--text-3); }

/* ===== LEADERBOARD ===== */
.leaderboard-list { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }

.lb-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  transition: background 0.15s;
}

.lb-item.me {
  background: rgba(91,78,232,0.12);
  border-color: rgba(91,78,232,0.3);
}

.lb-rank {
  width: 26px; text-align: center;
  font-size: 13px; font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
}

.lb-rank.top1 { color: #ffd700; font-size: 16px; }
.lb-rank.top2 { color: #c0c0c0; font-size: 15px; }
.lb-rank.top3 { color: #cd7f32; font-size: 15px; }

.lb-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0;
}

.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 13px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-group { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.lb-xp { font-size: 13px; font-weight: 700; color: var(--accent2); white-space: nowrap; }

.lb-streak { display: flex; align-items: center; gap: 3px; font-size: 11px; color: #f5813a; margin-left: 4px; }

/* ===== ACCOUNT ===== */
.account-hero {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 0 20px;
}

.account-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: #fff;
  margin-bottom: 12px;
  border: 3px solid rgba(91,78,232,0.4);
}

.account-name { font-size: 18px; font-weight: 700; color: var(--text-1); margin-bottom: 4px; }
.account-id { font-size: 12px; color: var(--text-3); font-family: monospace; }

.account-stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin: 0 0 16px;
}

.acc-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}

.acc-stat-label { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.acc-stat-val { font-size: 22px; font-weight: 800; color: var(--text-1); }
.acc-stat-sm { font-size: 15px; }

.acc-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  color: var(--text-1);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  width: 100%; text-align: center;
}

.btn-secondary:active { transform: scale(0.98); background: var(--bg-card2); }

.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: var(--radius);
  padding: 15px;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  width: 100%;
}

.btn-primary:active { transform: scale(0.98); background: var(--accent2); }

.section-label {
  font-size: 13px; font-weight: 700; color: var(--text-2);
  letter-spacing: 0.5px; text-transform: uppercase;
  margin-bottom: 10px;
}

.inventory-list { display: flex; flex-direction: column; gap: 8px; }

.inv-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
}

.inv-name { color: var(--text-1); font-weight: 600; }
.inv-meta { color: var(--text-3); font-size: 11px; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  background: none; border: none;
  color: var(--text-3);
  font-size: 10px; font-weight: 600;
  cursor: pointer;
  transition: color 0.18s;
  padding: 8px 0;
  letter-spacing: 0.3px;
}

.nav-btn.active { color: var(--accent2); }
.nav-btn.active svg { stroke: var(--accent2); }

.nav-btn svg { transition: stroke 0.18s; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex; align-items: flex-end;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.2s;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 12px 16px 28px;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-drag-handle {
  width: 40px; height: 4px;
  background: var(--border2);
  border-radius: 4px;
  margin: 0 auto 16px;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--text-1); }

.modal-close {
  background: rgba(255,255,255,0.08);
  border: none; color: var(--text-2);
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.modal-body { display: flex; flex-direction: column; gap: 12px; }

/* ===== SKELETON ===== */
.skeleton-card {
  height: 76px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  animation: pulse 1.4s ease-in-out infinite;
  margin-bottom: 12px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%; transform: translateX(-50%);
  background: var(--bg-card2);
  border: 1px solid var(--border2);
  color: var(--text-1);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px; font-weight: 600;
  z-index: 300;
  white-space: nowrap;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(6px); }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px; color: var(--text-3); text-align: center; gap: 10px;
}

.empty-state svg { opacity: 0.4; }
.empty-state p { font-size: 13px; line-height: 1.6; }

/* ===== DIVIDER ===== */
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ===== SAFE AREA (iPhone) ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .pages { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}
