/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #f7df1e;
  --primary-dark: #e6c800;
  --primary-glow: rgba(247,223,30,0.3);
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --bg4: #22222f;
  --surface: #1e1e2e;
  --surface2: #252535;
  --surface3: #2d2d40;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(247,223,30,0.2);
  --text: #e8e8f0;
  --text2: #9898b0;
  --text3: #6060780;
  --green: #00e676;
  --green-dark: #00c853;
  --blue: #448aff;
  --purple: #e040fb;
  --orange: #ff6d00;
  --red: #ff1744;
  --cyan: #00e5ff;
  --pink: #f50057;
  --gold: #ffd600;
  --font-mono: 'Courier New', 'Monaco', 'Cascadia Code', monospace;
  --font-ar: 'Segoe UI', Tahoma, Arial, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px var(--primary-glow);
  --nav-h: 70px;
  --transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-ar);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#app { width: 100%; max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; overflow: hidden; background: var(--bg); }

/* ===== SPLASH SCREEN ===== */
#splash-screen {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; flex-direction: column;
}
.splash-content { text-align: center; animation: splashFadeIn 0.8s ease; }
.splash-logo { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 12px; }
.logo-js {
  font-size: 52px; font-weight: 900; color: var(--bg);
  background: var(--primary); padding: 4px 16px; border-radius: 12px;
  font-family: var(--font-mono); letter-spacing: -2px;
  box-shadow: 0 0 40px var(--primary-glow);
}
.logo-master { font-size: 36px; font-weight: 800; color: var(--text); letter-spacing: 2px; }
.splash-tagline { color: var(--text2); font-size: 16px; margin-bottom: 40px; letter-spacing: 1px; }
.splash-loader { width: 200px; height: 4px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.loader-bar { height: 100%; background: var(--primary); border-radius: 4px; animation: loaderAnim 2s ease-in-out; }
@keyframes loaderAnim { from { width: 0 } to { width: 100% } }
@keyframes splashFadeIn { from { opacity:0; transform: translateY(30px) } to { opacity:1; transform: translateY(0) } }

/* ===== PAGES ===== */
.page { display: none; min-height: calc(100vh - var(--nav-h)); padding-bottom: calc(var(--nav-h) + 20px); overflow-y: auto; overflow-x: hidden; }
.page.active { display: block; animation: pageIn 0.35s cubic-bezier(0.4,0,0.2,1); }
@keyframes pageIn { from { opacity:0; transform: translateX(20px) } to { opacity:1; transform: translateX(0) } }
.page-slide-left { animation: pageSlideLeft 0.35s cubic-bezier(0.4,0,0.2,1); }
@keyframes pageSlideLeft { from { opacity:0; transform: translateX(-20px) } to { opacity:1; transform: translateX(0) } }

/* ===== BOTTOM NAV ===== */
#bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: var(--nav-h);
  background: rgba(17,17,24,0.95); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 1000; padding: 0 8px;
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 8px 16px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--text2); cursor: pointer;
  transition: var(--transition); flex: 1; position: relative;
}
.nav-btn i { font-size: 20px; transition: var(--transition); }
.nav-btn span { font-size: 10px; font-weight: 600; transition: var(--transition); }
.nav-btn.active { color: var(--primary); }
.nav-btn.active i { transform: translateY(-2px); filter: drop-shadow(0 0 8px var(--primary)); }
.nav-btn:active { transform: scale(0.9); }
.nav-btn.active::after {
  content: ''; position: absolute; bottom: -1px;
  width: 30px; height: 3px; background: var(--primary);
  border-radius: 3px 3px 0 0;
}

/* ===== PAGE HEADER ===== */
.page-header {
  padding: 20px 20px 16px;
  background: linear-gradient(180deg, var(--bg2) 0%, transparent 100%);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px);
}
.page-header h1 { font-size: 24px; font-weight: 800; color: var(--text); }
.page-header .subtitle { font-size: 13px; color: var(--text2); margin-top: 2px; }
.header-badge { background: var(--primary); color: var(--bg); font-size: 11px; font-weight: 800; padding: 2px 10px; border-radius: 20px; display: inline-block; margin-right: 8px; }

/* ===== HOME PAGE ===== */
.home-hero {
  margin: 0; padding: 24px 20px 20px;
  background: linear-gradient(135deg, var(--bg2) 0%, var(--bg3) 100%);
  position: relative; overflow: hidden;
}
.home-hero::before {
  content: ''; position: absolute; top: -50%; right: -20%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  pointer-events: none;
}
.home-greeting { font-size: 13px; color: var(--text2); margin-bottom: 4px; }
.home-title { font-size: 26px; font-weight: 900; color: var(--text); line-height: 1.2; }
.home-title span { color: var(--primary); }
.home-subtitle { font-size: 13px; color: var(--text2); margin-top: 8px; line-height: 1.5; }
.daily-goal-card {
  margin: 16px 0 0;
  background: var(--surface2); border-radius: var(--radius);
  padding: 16px; border: 1px solid var(--border);
}
.goal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.goal-title { font-size: 13px; color: var(--text2); }
.goal-count { font-size: 13px; font-weight: 700; color: var(--primary); }
.goal-bar { height: 8px; background: var(--bg3); border-radius: 8px; overflow: hidden; }
.goal-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 8px; transition: width 1s ease; }

.section-title { font-size: 16px; font-weight: 800; color: var(--text); padding: 20px 20px 12px; display: flex; align-items: center; gap: 8px; }
.section-title i { color: var(--primary); font-size: 14px; }

/* Stats Row */
.stats-row { display: flex; gap: 12px; padding: 0 20px; }
.stat-card {
  flex: 1; background: var(--surface); border-radius: var(--radius);
  padding: 14px 12px; border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: var(--transition);
}
.stat-card:active { transform: scale(0.96); }
.stat-number { font-size: 22px; font-weight: 900; color: var(--primary); font-family: var(--font-mono); }
.stat-label { font-size: 11px; color: var(--text2); text-align: center; }

/* Continue Card */
.continue-card {
  margin: 0 20px; background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border-radius: var(--radius); padding: 18px; border: 1px solid var(--border2);
  cursor: pointer; transition: var(--transition); position: relative; overflow: hidden;
}
.continue-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}
.continue-card:active { transform: scale(0.98); }
.continue-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.continue-title { font-size: 17px; font-weight: 800; color: var(--text); }
.continue-chapter { font-size: 12px; color: var(--primary); margin-top: 4px; }
.continue-arrow { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--primary); font-size: 20px; }
.continue-progress { margin-top: 12px; }
.continue-progress-bar { height: 6px; background: var(--bg3); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.continue-progress-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width 1s ease; }

/* Chapter Cards Home */
.chapters-scroll { display: flex; gap: 14px; padding: 0 20px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x mandatory; }
.chapters-scroll::-webkit-scrollbar { display: none; }
.chapter-mini-card {
  min-width: 150px; background: var(--surface); border-radius: var(--radius);
  padding: 16px; border: 1px solid var(--border); cursor: pointer;
  transition: var(--transition); scroll-snap-align: start; position: relative; overflow: hidden;
  flex-shrink: 0;
}
.chapter-mini-card.locked { opacity: 0.5; }
.chapter-mini-card:active { transform: scale(0.95); }
.chapter-mini-icon { font-size: 28px; margin-bottom: 10px; display: block; }
.chapter-mini-title { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.3; }
.chapter-mini-count { font-size: 11px; color: var(--text2); margin-top: 4px; }
.chapter-mini-badge {
  position: absolute; top: 10px; left: 10px;
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
}
.badge-beginner { background: rgba(0,230,118,0.15); color: var(--green); }
.badge-intermediate { background: rgba(68,138,255,0.15); color: var(--blue); }
.badge-advanced { background: rgba(224,64,251,0.15); color: var(--purple); }
.badge-expert { background: rgba(255,109,0,0.15); color: var(--orange); }
.badge-master { background: rgba(245,0,87,0.15); color: var(--pink); }
.chapter-mini-progress-bar { height: 3px; background: var(--bg3); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.chapter-mini-progress-fill { height: 100%; background: var(--primary); border-radius: 3px; }

/* Tip Card */
.tip-card {
  margin: 0 20px; background: linear-gradient(135deg, rgba(247,223,30,0.08) 0%, rgba(247,223,30,0.02) 100%);
  border-radius: var(--radius); padding: 16px; border: 1px solid var(--border2);
}
.tip-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tip-header i { color: var(--primary); }
.tip-header span { font-size: 12px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 1px; }
.tip-text { font-size: 13px; color: var(--text); line-height: 1.6; }
.tip-code { font-family: var(--font-mono); background: var(--bg3); padding: 2px 6px; border-radius: 4px; color: var(--primary); font-size: 12px; }

/* ===== CHAPTERS PAGE ===== */
.search-box {
  margin: 0 20px 16px; position: relative;
}
.search-box input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px 12px 44px;
  color: var(--text); font-size: 14px; font-family: var(--font-ar);
  outline: none; transition: var(--transition);
}
.search-box input:focus { border-color: var(--primary); }
.search-box input::placeholder { color: var(--text2); }
.search-box i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text2); font-size: 16px; }

.filter-tabs { display: flex; gap: 8px; padding: 0 20px 16px; overflow-x: auto; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  flex-shrink: 0; padding: 7px 16px; border-radius: 20px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: var(--transition);
  border: 1px solid var(--border); background: var(--surface); color: var(--text2);
}
.filter-tab.active { background: var(--primary); color: var(--bg); border-color: var(--primary); }

.chapter-card {
  margin: 0 20px 12px; background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden; cursor: pointer;
  transition: var(--transition); position: relative;
}
.chapter-card:active { transform: scale(0.98); }
.chapter-card.completed { border-color: rgba(0,230,118,0.3); }
.chapter-card.locked { opacity: 0.5; pointer-events: none; }
.chapter-card-header { display: flex; align-items: center; gap: 14px; padding: 16px; }
.chapter-icon-wrap {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.chapter-info { flex: 1; min-width: 0; }
.chapter-title { font-size: 15px; font-weight: 800; color: var(--text); margin-bottom: 3px; }
.chapter-desc { font-size: 12px; color: var(--text2); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.chapter-lessons-count { font-size: 11px; color: var(--text2); }
.chapter-progress-text { font-size: 11px; font-weight: 700; }
.chapter-status { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.status-done { background: rgba(0,230,118,0.15); color: var(--green); }
.status-active { background: rgba(247,223,30,0.15); color: var(--primary); }
.status-locked { background: var(--bg3); color: var(--text2); }
.chapter-card-footer { padding: 0 16px 14px; }
.chapter-progress-bar-wrap { height: 4px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.chapter-progress-bar-fill { height: 100%; border-radius: 4px; transition: width 1s ease; }

/* ===== LESSON PAGE ===== */
#lesson-page { padding-bottom: calc(var(--nav-h) + 20px); }
.lesson-topbar {
  position: sticky; top: 0; background: rgba(10,10,15,0.95); backdrop-filter: blur(10px);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border); z-index: 10;
}
.back-btn { background: var(--surface); border: none; color: var(--text); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; transition: var(--transition); }
.back-btn:active { background: var(--surface2); transform: scale(0.9); }
.lesson-topbar-info { flex: 1; }
.lesson-topbar-chapter { font-size: 11px; color: var(--text2); }
.lesson-topbar-title { font-size: 15px; font-weight: 800; color: var(--text); }
.xp-badge { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--bg); font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 20px; }

.lesson-progress-top { height: 3px; background: var(--bg3); }
.lesson-progress-top-fill { height: 100%; background: var(--primary); transition: width 0.5s ease; }

.lesson-content { padding: 20px; }
.lesson-title { font-size: 22px; font-weight: 900; color: var(--text); margin-bottom: 6px; }
.lesson-desc { font-size: 14px; color: var(--text2); line-height: 1.6; margin-bottom: 20px; }

/* Content Blocks */
.content-block { margin-bottom: 20px; }
.block-text { font-size: 14px; color: var(--text); line-height: 1.7; }
.block-text strong { color: var(--primary); }
.block-text em { color: var(--cyan); font-style: normal; }

.block-code {
  background: var(--bg2); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
}
.code-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg3); border-bottom: 1px solid var(--border); }
.code-lang { font-size: 12px; color: var(--primary); font-weight: 700; }
.code-copy-btn { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 13px; padding: 4px 8px; border-radius: 6px; transition: var(--transition); }
.code-copy-btn:hover { background: var(--surface); color: var(--text); }
.code-body { padding: 16px; overflow-x: auto; }
.code-body pre { font-family: var(--font-mono); font-size: 13px; line-height: 1.8; color: var(--text); white-space: pre; }

/* Syntax Highlighting */
.kw { color: #c792ea; font-weight: bold; }
.fn { color: #82aaff; }
.str { color: #c3e88d; }
.num { color: #f78c6c; }
.cmt { color: #546e7a; font-style: italic; }
.op { color: #89ddff; }
.var { color: #eeffff; }
.prop { color: #ffcb6b; }
.bool { color: #ff5370; }
.punc { color: #89ddff; }
.cls { color: #ffcb6b; font-weight: bold; }
.tag { color: #f07178; }
.attr { color: #c792ea; }

.block-tip {
  background: rgba(247,223,30,0.06); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px;
}
.block-tip .tip-icon { color: var(--primary); font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.block-tip .tip-content { font-size: 13px; color: var(--text); line-height: 1.6; }
.block-tip .tip-content strong { color: var(--primary); }

.block-warning {
  background: rgba(255,109,0,0.06); border: 1px solid rgba(255,109,0,0.2);
  border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px;
}
.block-warning .warn-icon { color: var(--orange); font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.block-warning .warn-content { font-size: 13px; color: var(--text); line-height: 1.6; }

.block-list { padding-right: 4px; }
.block-list li { font-size: 14px; color: var(--text); line-height: 1.6; padding: 6px 0; padding-right: 20px; position: relative; border-bottom: 1px solid var(--border); }
.block-list li:last-child { border-bottom: none; }
.block-list li::before { content: '▸'; position: absolute; right: 0; color: var(--primary); }

.block-exercise {
  background: linear-gradient(135deg, rgba(68,138,255,0.08) 0%, rgba(68,138,255,0.02) 100%);
  border: 1px solid rgba(68,138,255,0.2); border-radius: var(--radius); padding: 16px;
}
.exercise-label { font-size: 11px; color: var(--blue); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.exercise-text { font-size: 14px; color: var(--text); line-height: 1.6; margin-bottom: 14px; }
.try-btn {
  background: var(--blue); color: white; border: none; padding: 10px 20px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: var(--font-ar); transition: var(--transition);
}
.try-btn:active { transform: scale(0.95); }

/* Lesson Nav */
.lesson-nav { display: flex; gap: 12px; padding: 16px 20px; margin-top: 8px; }
.lesson-nav-btn {
  flex: 1; padding: 14px; border-radius: var(--radius); border: none;
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: var(--font-ar);
  transition: var(--transition); display: flex; align-items: center; justify-content: center; gap: 8px;
}
.lesson-nav-btn:active { transform: scale(0.97); }
.btn-prev { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-next { background: var(--primary); color: var(--bg); }
.btn-next:hover { background: var(--primary-dark); }
.btn-complete { background: linear-gradient(135deg, var(--green), var(--green-dark)); color: white; }

/* Lessons List */
.lessons-list { padding: 0 20px; }
.lesson-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--surface); border-radius: var(--radius-sm);
  margin-bottom: 8px; cursor: pointer; border: 1px solid var(--border);
  transition: var(--transition);
}
.lesson-item:active { background: var(--surface2); transform: scale(0.98); }
.lesson-item.active { border-color: var(--primary); }
.lesson-item.completed { border-color: rgba(0,230,118,0.3); }
.lesson-num { width: 32px; height: 32px; border-radius: 50%; background: var(--bg3); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--text2); flex-shrink: 0; }
.lesson-num.done { background: rgba(0,230,118,0.15); color: var(--green); }
.lesson-num.current { background: var(--primary); color: var(--bg); }
.lesson-item-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.lesson-item-duration { font-size: 11px; color: var(--text2); }
.lesson-item-xp { font-size: 11px; color: var(--primary); font-weight: 700; }

/* ===== CODE EDITOR ===== */
.editor-topbar {
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.editor-title { font-size: 16px; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; }
.editor-title i { color: var(--primary); }
.editor-actions { display: flex; gap: 8px; }
.editor-btn {
  padding: 7px 14px; border-radius: var(--radius-sm); border: none;
  font-size: 12px; font-weight: 700; cursor: pointer; font-family: var(--font-ar);
  transition: var(--transition);
}
.editor-btn:active { transform: scale(0.95); }
.btn-run { background: var(--green); color: var(--bg); }
.btn-clear { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-reset { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

.editor-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg2); }
.editor-tab {
  padding: 10px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text2); border-bottom: 2px solid transparent; transition: var(--transition);
}
.editor-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.editor-wrap { background: var(--bg2); position: relative; }
.code-textarea-wrap { position: relative; }
.line-numbers {
  position: absolute; right: 0; top: 0; bottom: 0; width: 40px;
  background: var(--bg3); border-left: 1px solid var(--border);
  padding: 14px 8px; text-align: center;
  font-family: var(--font-mono); font-size: 12px; color: var(--text2);
  line-height: 1.6; pointer-events: none; overflow: hidden; z-index: 1;
}
#code-editor {
  width: 100%; min-height: 250px; background: var(--bg2);
  border: none; outline: none; resize: none;
  color: var(--text); font-family: var(--font-mono); font-size: 13px;
  line-height: 1.6; padding: 14px 48px 14px 14px; tab-size: 2;
  caret-color: var(--primary); white-space: pre; overflow-x: auto;
}
.editor-output {
  background: var(--bg); border-top: 1px solid var(--border);
  min-height: 120px; max-height: 250px; overflow-y: auto;
}
.output-header { padding: 10px 14px; font-size: 12px; font-weight: 700; color: var(--text2); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.output-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.output-dot.error { background: var(--red); }
.output-content { padding: 12px 14px; font-family: var(--font-mono); font-size: 12px; line-height: 1.7; }
.out-log { color: var(--text); }
.out-error { color: var(--red); }
.out-warn { color: var(--orange); }
.out-result { color: var(--green); }
.out-info { color: var(--cyan); }

.editor-snippets { padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.snippet-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; font-size: 12px; color: var(--text2); cursor: pointer;
  font-family: var(--font-mono); transition: var(--transition);
}
.snippet-btn:active { background: var(--surface2); color: var(--primary); }

/* Challenges */
.challenges-list { padding: 0 20px; }
.challenge-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  margin-bottom: 12px; cursor: pointer; transition: var(--transition); overflow: hidden;
}
.challenge-card:active { transform: scale(0.98); }
.challenge-card-header { padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.challenge-diff { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.diff-easy { background: var(--green); box-shadow: 0 0 8px var(--green); }
.diff-medium { background: var(--primary); box-shadow: 0 0 8px var(--primary); }
.diff-hard { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.diff-expert { background: var(--purple); box-shadow: 0 0 8px var(--purple); }
.challenge-info { flex: 1; }
.challenge-name { font-size: 14px; font-weight: 700; color: var(--text); }
.challenge-desc { font-size: 12px; color: var(--text2); margin-top: 2px; }
.challenge-xp { font-size: 12px; font-weight: 700; color: var(--primary); }

/* ===== QUIZ PAGE ===== */
.quiz-container { padding: 20px; }
.quiz-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.quiz-counter { font-size: 14px; color: var(--text2); }
.quiz-score { font-size: 16px; font-weight: 800; color: var(--primary); }
.quiz-timer { background: var(--surface); border-radius: 20px; padding: 6px 14px; font-size: 14px; font-weight: 700; color: var(--text); font-family: var(--font-mono); }
.quiz-progress-bar { height: 6px; background: var(--bg3); border-radius: 6px; overflow: hidden; margin-bottom: 24px; }
.quiz-progress-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width 0.5s ease; }
.quiz-question { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.5; margin-bottom: 20px; }
.quiz-code { background: var(--bg2); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 20px; font-family: var(--font-mono); font-size: 12px; color: var(--text); line-height: 1.7; border: 1px solid var(--border); overflow-x: auto; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 14px; font-weight: 600; color: var(--text);
  cursor: pointer; text-align: right; font-family: var(--font-ar);
  transition: var(--transition); position: relative; overflow: hidden;
}
.quiz-option:active { transform: scale(0.98); }
.quiz-option.selected { border-color: var(--primary); background: rgba(247,223,30,0.08); color: var(--primary); }
.quiz-option.correct { border-color: var(--green); background: rgba(0,230,118,0.1); color: var(--green); }
.quiz-option.wrong { border-color: var(--red); background: rgba(255,23,68,0.1); color: var(--red); }
.quiz-option.disabled { pointer-events: none; }
.quiz-btn {
  width: 100%; padding: 14px; background: var(--primary); color: var(--bg);
  border: none; border-radius: var(--radius); font-size: 15px; font-weight: 800;
  cursor: pointer; font-family: var(--font-ar); transition: var(--transition);
  margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.quiz-btn:active { transform: scale(0.97); }
.quiz-btn:disabled { opacity: 0.5; pointer-events: none; }
.quiz-result {
  text-align: center; padding: 40px 20px;
}
.result-emoji { font-size: 60px; margin-bottom: 16px; animation: bounceIn 0.6s cubic-bezier(0.68,-0.55,0.265,1.55); }
.result-score { font-size: 48px; font-weight: 900; color: var(--primary); font-family: var(--font-mono); }
.result-label { font-size: 16px; color: var(--text2); margin: 8px 0 24px; }
.result-xp { font-size: 20px; font-weight: 800; color: var(--green); margin-bottom: 32px; }
.result-btns { display: flex; gap: 12px; }
.result-btn { flex: 1; padding: 14px; border-radius: var(--radius); border: none; font-size: 14px; font-weight: 700; cursor: pointer; font-family: var(--font-ar); transition: var(--transition); }
.result-btn:active { transform: scale(0.97); }
.btn-retry { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-continue-quiz { background: var(--primary); color: var(--bg); }
@keyframes bounceIn { from { transform: scale(0.5); opacity: 0; } 60% { transform: scale(1.1); } to { transform: scale(1); opacity: 1; } }

/* Quiz Categories */
.quiz-categories { padding: 0 20px; display: flex; flex-direction: column; gap: 12px; }
.quiz-cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: var(--transition); display: flex; align-items: center; gap: 14px;
}
.quiz-cat-card:active { transform: scale(0.98); }
.quiz-cat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.quiz-cat-info { flex: 1; }
.quiz-cat-name { font-size: 15px; font-weight: 800; color: var(--text); }
.quiz-cat-count { font-size: 12px; color: var(--text2); margin-top: 2px; }
.quiz-cat-arrow { color: var(--text2); font-size: 16px; }
.quiz-best { font-size: 12px; font-weight: 700; margin-top: 4px; }
.quiz-best.perfect { color: var(--green); }
.quiz-best.good { color: var(--blue); }
.quiz-best.none { color: var(--text2); }

/* ===== PROGRESS PAGE ===== */
.progress-hero {
  padding: 24px 20px; text-align: center;
  background: linear-gradient(135deg, var(--bg2) 0%, var(--bg3) 100%);
}
.level-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary); color: var(--bg); padding: 6px 16px;
  border-radius: 20px; font-size: 14px; font-weight: 800; margin-bottom: 16px;
}
.xp-ring { width: 100px; height: 100px; margin: 0 auto 16px; position: relative; }
.xp-ring svg { transform: rotate(-90deg); }
.xp-ring-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.xp-ring-num { font-size: 20px; font-weight: 900; color: var(--primary); font-family: var(--font-mono); display: block; }
.xp-ring-label { font-size: 10px; color: var(--text2); display: block; }
.level-title { font-size: 20px; font-weight: 900; color: var(--text); }
.level-xp-info { font-size: 13px; color: var(--text2); margin-top: 4px; }
.xp-to-next { margin: 16px 0 0; }
.xp-bar-wrap { height: 8px; background: var(--bg3); border-radius: 8px; overflow: hidden; margin-top: 8px; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 8px; transition: width 1.5s ease; }

.progress-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 20px; }
.pstat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.pstat-icon { font-size: 24px; margin-bottom: 8px; }
.pstat-value { font-size: 24px; font-weight: 900; font-family: var(--font-mono); }
.pstat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* Achievements */
.achievements-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 20px; }
.achievement-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; position: relative; overflow: hidden;
  transition: var(--transition);
}
.achievement-card.unlocked { border-color: var(--border2); }
.achievement-card.locked { opacity: 0.5; }
.achievement-icon { font-size: 32px; margin-bottom: 8px; filter: drop-shadow(0 0 10px rgba(247,223,30,0.3)); }
.achievement-card.locked .achievement-icon { filter: grayscale(1); }
.achievement-name { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.achievement-desc { font-size: 11px; color: var(--text2); }
.achievement-unlocked-badge { position: absolute; top: 8px; left: 8px; font-size: 10px; background: var(--primary); color: var(--bg); padding: 2px 6px; border-radius: 10px; font-weight: 700; }

/* Streak Calendar */
.streak-section { padding: 0 20px; }
.streak-info { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.streak-fire { font-size: 32px; animation: flamePulse 1.5s ease-in-out infinite; }
@keyframes flamePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.streak-days { font-size: 36px; font-weight: 900; color: var(--primary); font-family: var(--font-mono); }
.streak-label { font-size: 14px; color: var(--text2); }
.streak-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.streak-day { aspect-ratio: 1; border-radius: 6px; background: var(--bg3); display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--text2); font-weight: 600; }
.streak-day.active { background: var(--primary); color: var(--bg); }
.streak-day.today { background: var(--surface2); border: 2px solid var(--primary); color: var(--primary); }
.streak-day-label { font-size: 10px; color: var(--text2); text-align: center; }

/* ===== NOTIFICATIONS & TOASTS ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-100px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 20px; font-size: 14px; font-weight: 600; color: var(--text);
  z-index: 99999; transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 320px; text-align: center; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }
.toast.xp { border-color: var(--primary); color: var(--primary); }

/* Confetti Canvas */
#confetti-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9998; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 4px; }

/* ===== UTILITIES ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mb-3 { margin-bottom: 12px; }
.text-center { text-align: center; }
.pb-4 { padding-bottom: 16px; }
.hidden { display: none !important; }

/* Color Themes for chapters */
.color-yellow { background: rgba(247,223,30,0.15); }
.color-blue { background: rgba(68,138,255,0.15); }
.color-green { background: rgba(0,230,118,0.15); }
.color-purple { background: rgba(224,64,251,0.15); }
.color-orange { background: rgba(255,109,0,0.15); }
.color-cyan { background: rgba(0,229,255,0.15); }
.color-pink { background: rgba(245,0,87,0.15); }
.color-red { background: rgba(255,23,68,0.15); }
.text-yellow { color: var(--primary); }
.text-blue { color: var(--blue); }
.text-green { color: var(--green); }
.text-purple { color: var(--purple); }
.text-orange { color: var(--orange); }
.text-cyan { color: var(--cyan); }
.text-pink { color: var(--pink); }
.text-red { color: var(--red); }
.border-yellow { border-color: rgba(247,223,30,0.3) !important; }
.border-blue { border-color: rgba(68,138,255,0.3) !important; }
.border-green { border-color: rgba(0,230,118,0.3) !important; }
.border-purple { border-color: rgba(224,64,251,0.3) !important; }
.border-orange { border-color: rgba(255,109,0,0.3) !important; }
.border-cyan { border-color: rgba(0,229,255,0.3) !important; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* Skeleton Loader */
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ===== XP POPUP ===== */
.xp-popup {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg); padding: 10px 24px; border-radius: 30px;
  font-size: 16px; font-weight: 900; z-index: 9998;
  opacity: 0; transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
}
.xp-popup.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.xp-popup.hide { opacity: 0; transform: translateX(-50%) translateY(-30px); }

/* ===== KEYBOARD SHORTCUTS BAR ===== */
.kbd-bar { display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; scrollbar-width: none; background: var(--bg3); border-top: 1px solid var(--border); }
.kbd-bar::-webkit-scrollbar { display: none; }
.kbd-key { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; font-size: 13px; color: var(--text2); cursor: pointer; flex-shrink: 0; font-family: var(--font-mono); transition: var(--transition); }
.kbd-key:active { background: var(--primary); color: var(--bg); border-color: var(--primary); }

/* ===== FULLSCREEN EDITOR ===== */
.editor-fullscreen { position: fixed !important; inset: 0; z-index: 999; border-radius: 0 !important; }

/* ===== SCROLL TO TOP ===== */
.scroll-top-btn {
  position: fixed; bottom: 90px; left: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text2); display: none; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition); z-index: 100;
}
.scroll-top-btn.visible { display: flex; }
.scroll-top-btn:active { transform: scale(0.9); }

/* ===== CHAPTER DETAIL HEADER ===== */
.chapter-detail-hero {
  padding: 20px; text-align: center;
  background: linear-gradient(180deg, var(--bg2) 0%, transparent 100%);
}
.chapter-detail-icon { font-size: 52px; margin-bottom: 12px; display: block; }
.chapter-detail-title { font-size: 22px; font-weight: 900; color: var(--text); }
.chapter-detail-desc { font-size: 13px; color: var(--text2); margin-top: 6px; line-height: 1.5; }
.chapter-detail-meta { display: flex; justify-content: center; gap: 20px; margin-top: 16px; }
.chapter-detail-stat { text-align: center; }
.chapter-detail-stat-num { font-size: 20px; font-weight: 900; color: var(--primary); font-family: var(--font-mono); }
.chapter-detail-stat-label { font-size: 11px; color: var(--text2); }

/* Responsive */
@media (max-width: 360px) {
  .home-title { font-size: 22px; }
  .stat-number { font-size: 18px; }
  .chapter-mini-card { min-width: 130px; }
}
