/* ============================================================
   PYAVENTURE — CSS PRINCIPAL
   Police : Nunito (Google Fonts)
   Thème : Sombre avec accents colorés, enfants 10 ans
   ============================================================ */

:root {
  --primary: #6C63FF;
  --secondary: #FF6584;
  --accent-green: #43E97B;
  --accent-orange: #FA8231;
  --accent-cyan: #3DC1D3;
  --bg-dark: #0F0E17;
  --bg-card: #1a1933;
  --bg-card2: #1e1d35;
  --border-subtle: rgba(255,255,255,0.08);
  --text-main: #e8e6f0;
  --text-muted: #9994b8;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.35);
  --shadow-sm: 0 4px 16px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
}

/* ──────── SCROLLBAR ──────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: #3a3860; border-radius: 4px; }

/* ──────── NAVBAR ──────── */
.py-aventure-nav {
  background: rgba(15,14,23,0.92) !important;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 1000;
}
.brand-snake { font-size: 1.6rem; }
.brand-name {
  font-size: 1.3rem; font-weight: 900;
  background: linear-gradient(135deg, #6C63FF, #FF6584);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.navbar .nav-link { color: var(--text-muted) !important; font-weight: 600; transition: color .2s; }
.navbar .nav-link:hover { color: white !important; }
.nav-xp-badge {
  background: linear-gradient(135deg, #6C63FF22, #FF658422);
  border: 1px solid #6C63FF44;
  border-radius: 20px; padding: 4px 12px;
  font-weight: 700; font-size: .85rem; color: #b8b4ff;
  display: flex; align-items: center; gap: 5px;
}
.nav-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem; color: white;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}
.text-danger-soft { color: #ff8fa3 !important; }

/* ──────── FOOTER ──────── */
.py-aventure-footer {
  background: rgba(0,0,0,0.3);
  border-top: 1px solid var(--border-subtle);
  padding: 24px 0;
}
.footer-text { color: var(--text-muted); font-weight: 600; }
.footer-sub { color: #554f7a; font-size: .85rem; }

/* ──────── GRADIENT TEXT ──────── */
.gradient-text {
  background: linear-gradient(135deg, #6C63FF, #FF6584, #43E97B);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ═══════════════════════════════════════════════════════════
   LANDING PAGE
   ═══════════════════════════════════════════════════════════ */
.hero-section {
  position: relative; overflow: hidden;
  min-height: 92vh;
  display: flex; align-items: center;
  background: radial-gradient(ellipse at 50% 0%, #1e1a4a 0%, var(--bg-dark) 65%);
}
.hero-bg-anim { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floating-code {
  position: absolute; opacity: .06; font-family: 'Courier New', monospace;
  font-size: clamp(0.7rem, 1.5vw, 1rem); color: #a0a0ff; white-space: nowrap;
  animation: floatCode 15s linear infinite;
}
.floating-code:nth-child(1)  { left:5%;  top:20%; animation-duration:18s; }
.floating-code:nth-child(2)  { left:60%; top:10%; animation-duration:22s; }
.floating-code:nth-child(3)  { left:80%; top:50%; animation-duration:16s; }
.floating-code:nth-child(4)  { left:20%; top:70%; animation-duration:20s; }
.floating-code:nth-child(5)  { left:45%; top:80%; animation-duration:14s; }
.floating-code:nth-child(6)  { left:75%; top:75%; animation-duration:19s; }
@keyframes floatCode {
  from { transform: translateY(0); opacity:.06; }
  50%  { opacity:.12; }
  to   { transform: translateY(-30px); opacity:.06; }
}
.hero-content { position: relative; z-index: 2; padding: 60px 20px; }
.hero-mascot { font-size: clamp(4rem, 10vw, 7rem); margin-bottom: 16px; animation: bounce 2s ease-in-out infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }
.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 900;
  color: white; margin-bottom: 16px;
}
.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.25rem); color: var(--text-muted);
  max-width: 600px; margin: 0 auto 32px;
}
.hero-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 32px; }
.btn-hero-primary {
  background: linear-gradient(135deg, var(--primary), #9c63ff);
  color: white; border: none; border-radius: 50px;
  padding: 14px 32px; font-weight: 800; font-size: 1.1rem;
  box-shadow: 0 8px 30px rgba(108,99,255,.4);
  transition: transform .2s, box-shadow .2s; text-decoration: none;
}
.btn-hero-primary:hover { transform: translateY(-3px); box-shadow: 0 12px 40px rgba(108,99,255,.5); color: white; }
.btn-hero-secondary {
  background: rgba(255,255,255,.08); color: var(--text-main);
  border: 1px solid var(--border-subtle); border-radius: 50px;
  padding: 14px 32px; font-weight: 700; font-size: 1.05rem;
  transition: background .2s; text-decoration: none;
}
.btn-hero-secondary:hover { background: rgba(255,255,255,.14); color: white; }
.hero-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.stat-pill {
  background: rgba(255,255,255,.06); border: 1px solid var(--border-subtle);
  border-radius: 30px; padding: 6px 16px; font-size: .9rem; font-weight: 600;
}

/* Features */
.features-section { background: rgba(255,255,255,.02); }
.section-title { font-size: 2rem; font-weight: 900; color: white; }
.feature-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); padding: 28px; height: 100%;
  transition: transform .2s, border-color .2s;
}
.feature-card:hover { transform: translateY(-4px); border-color: var(--primary); }
.feature-icon { font-size: 2.5rem; margin-bottom: 12px; }
.feature-card h3 { font-weight: 800; color: white; font-size: 1.1rem; }
.feature-card p { color: var(--text-muted); margin: 0; }

/* Chapters preview */
.chapter-preview-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: 16px;
  display: flex; align-items: center; gap: 12px;
  transition: transform .15s, border-color .15s;
}
.chapter-preview-card:hover { transform: translateX(4px); border-color: var(--primary); }
.chapter-num {
  font-size: 1.5rem; font-weight: 900;
  color: var(--primary); min-width: 32px;
}
.chapter-icon-preview { font-size: 1.8rem; }
.chapter-title-preview { font-weight: 800; color: white; font-size: .95rem; }
.chapter-desc-preview { font-size: .82rem; color: var(--text-muted); }

/* CTA */
.cta-box {
  background: linear-gradient(135deg, #1e1a4a, #2a1a3e);
  border: 1px solid #6C63FF33; border-radius: 24px;
  padding: 60px 40px; max-width: 700px; margin: auto;
}
.cta-title { font-size: 2rem; font-weight: 900; color: white; }
.cta-subtitle { color: var(--text-muted); margin-bottom: 28px; }

/* ═══════════════════════════════════════════════════════════
   AUTH PAGES
   ═══════════════════════════════════════════════════════════ */
.auth-page {
  min-height: 85vh; display: flex; align-items: center;
  padding: 40px 16px;
  background: radial-gradient(ellipse at 50% 0%, #1e1a4a 0%, var(--bg-dark) 70%);
}
.auth-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 24px; padding: 40px 36px;
  box-shadow: var(--shadow);
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-mascot { font-size: 3.5rem; margin-bottom: 8px; }
.auth-title { font-size: 1.8rem; font-weight: 900; color: white; margin: 0; }
.auth-subtitle { color: var(--text-muted); margin: 4px 0 0; }
.form-group-custom { margin-bottom: 18px; }
.form-label-custom {
  display: flex; align-items: center; gap: 6px;
  font-weight: 700; color: var(--text-muted); font-size: .9rem; margin-bottom: 6px;
}
.form-control-custom {
  width: 100%; background: rgba(255,255,255,.05);
  border: 1.5px solid var(--border-subtle); border-radius: var(--radius-sm);
  color: white; padding: 11px 14px; font-size: 1rem; font-family: inherit;
  transition: border-color .2s;
}
.form-control-custom:focus {
  outline: none; border-color: var(--primary);
  background: rgba(108,99,255,.07);
}
.form-control-custom::placeholder { color: #554f7a; }
.form-hint { color: #554f7a; font-size: .78rem; margin-top: 4px; display: block; }
.btn-auth {
  width: 100%; background: linear-gradient(135deg, var(--primary), #9c63ff);
  color: white; border: none; border-radius: 50px;
  padding: 13px; font-size: 1.05rem; font-weight: 800;
  cursor: pointer; transition: transform .2s, box-shadow .2s;
  margin-top: 8px;
}
.btn-auth:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(108,99,255,.45); }
.auth-footer { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: .9rem; }
.auth-link { color: var(--primary); font-weight: 700; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.alert-danger-custom {
  background: rgba(255,82,82,.12); border: 1px solid rgba(255,82,82,.3);
  border-radius: var(--radius-sm); color: #ff8fa3; padding: 12px 16px;
  margin-bottom: 18px; font-weight: 600;
}
.terms-check {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 16px; font-size: .88rem; color: var(--text-muted);
}
.terms-check input { margin-top: 3px; accent-color: var(--primary); }

/* ═══════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════ */
.dashboard-page { min-height: 85vh; }

/* User hero card */
.user-hero-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card2));
  border: 1px solid var(--border-subtle); border-radius: var(--radius);
  padding: 24px 28px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px; flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.user-hero-left { display: flex; align-items: center; gap: 18px; }
.user-avatar-big {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 900; color: white;
  box-shadow: 0 0 0 4px rgba(255,255,255,.1), var(--shadow-sm);
  flex-shrink: 0;
}
.user-hero-name { font-size: 1.5rem; font-weight: 900; color: white; margin-bottom: 4px; }
.user-level-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.07); border-radius: 30px;
  padding: 4px 14px; font-size: .9rem; font-weight: 700; color: #b8b4ff;
}
.level-num {
  background: linear-gradient(135deg, var(--primary), #9c63ff);
  color: white; border-radius: 30px; padding: 2px 10px; font-size: .8rem;
}
.xp-bar-wrapper { margin-top: 8px; }
.xp-bar-track {
  height: 8px; background: rgba(255,255,255,.08);
  border-radius: 4px; overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-green));
  border-radius: 4px; transition: width .6s ease;
}
.xp-bar-label { font-size: .78rem; color: var(--text-muted); margin-top: 3px; display: block; }
.user-hero-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.hero-stat { text-align: center; }
.hero-stat-num { font-size: 1.8rem; font-weight: 900; color: white; }
.hero-stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 600; }

/* Progress bar big */
.overall-progress {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: 16px 20px;
}
.progress-label { font-weight: 700; color: var(--text-muted); font-size: .9rem; }
.progress-pct { font-weight: 900; color: var(--primary); }
.progress-bar-big {
  height: 18px; background: rgba(255,255,255,.06);
  border-radius: 9px; overflow: hidden;
}
.progress-bar-big-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-green));
  border-radius: 9px; transition: width .7s ease;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 8px; font-size: .72rem; font-weight: 800; color: white;
}

/* Badges */
.section-subtitle { font-size: 1.1rem; font-weight: 800; color: white; }
.badges-section { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 18px; }
.badges-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.badge-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 14px; border-radius: 12px; min-width: 70px; text-align: center;
  font-size: .75rem; font-weight: 700; transition: transform .2s;
}
.badge-item.earned { background: rgba(255,255,255,.08); color: white; cursor: default; }
.badge-item.earned:hover { transform: scale(1.1); }
.badge-item.locked { background: rgba(255,255,255,.03); color: #554f7a; opacity: .5; }
.badge-icon { font-size: 1.8rem; }
.badge-name { font-size: .72rem; }

/* Chapter cards */
.chapter-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); overflow: hidden;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.chapter-card.available { cursor: pointer; }
.chapter-card.available:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.chapter-card.completed { border-color: rgba(67,233,123,.25); cursor: pointer; }
.chapter-card.completed:hover { transform: translateY(-3px); border-color: rgba(67,233,123,.5); }
.chapter-card.locked { opacity: .6; cursor: not-allowed; }
.chapter-card-header {
  position: relative; padding: 20px; display: flex;
  align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border-subtle);
}
.chapter-number {
  position: absolute; top: 10px; left: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: .85rem; color: white;
}
.chapter-icon-big { font-size: 3rem; }
.chapter-badge-complete { position: absolute; top: 10px; right: 10px; font-size: 1.2rem; }
.chapter-badge-lock { position: absolute; top: 10px; right: 10px; font-size: 1.2rem; }
.chapter-card-body { padding: 16px; }
.chapter-card-title { font-weight: 800; color: white; font-size: 1.05rem; margin-bottom: 4px; }
.chapter-card-desc { color: var(--text-muted); font-size: .85rem; margin-bottom: 10px; }
.chapter-card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.meta-item { font-size: .8rem; color: var(--text-muted); font-weight: 600; }
.quiz-score-badge {
  background: rgba(67,233,123,.1); border: 1px solid rgba(67,233,123,.2);
  border-radius: 8px; padding: 3px 10px; font-size: .8rem;
  color: var(--accent-green); font-weight: 700; margin-bottom: 8px;
  display: inline-block;
}
.btn-chapter-go {
  color: white; border-radius: 10px; padding: 9px;
  font-weight: 800; font-size: .9rem; text-align: center; cursor: pointer;
  transition: opacity .2s;
}
.btn-chapter-go:hover { opacity: .85; }
.btn-chapter-done {
  background: rgba(67,233,123,.12); border: 1px solid rgba(67,233,123,.2);
  color: var(--accent-green); border-radius: 10px; padding: 9px;
  font-weight: 800; font-size: .9rem; text-align: center; cursor: pointer;
}
.chapter-lock-msg {
  text-align: center; color: var(--text-muted); font-size: .85rem;
  padding: 8px; font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   CHAPTER PAGE
   ═══════════════════════════════════════════════════════════ */
.chapter-breadcrumb {
  background: rgba(0,0,0,.3); border-bottom: 1px solid var(--border-subtle);
  padding: 10px 0; font-size: .88rem; color: var(--text-muted);
}
.chapter-breadcrumb a { color: var(--primary); text-decoration: none; font-weight: 600; }
.chapter-breadcrumb a:hover { text-decoration: underline; }
.bc-sep { margin: 0 8px; }
.chapter-hero { padding: 32px 0; border-bottom: 1px solid var(--border-subtle); }
.chapter-hero-content { display: flex; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.chapter-hero-icon { font-size: 4rem; line-height: 1; }
.chapter-hero-num { font-weight: 800; font-size: .95rem; margin-bottom: 4px; }
.chapter-hero-title { font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 900; color: white; margin-bottom: 6px; }
.chapter-hero-desc { color: var(--text-muted); margin-bottom: 10px; }
.chapter-hero-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-chip {
  background: rgba(255,255,255,.07); border: 1px solid var(--border-subtle);
  border-radius: 20px; padding: 4px 12px; font-size: .82rem; font-weight: 700;
}
.done-chip { background: rgba(67,233,123,.12); border-color: rgba(67,233,123,.2); color: var(--accent-green); }

/* Lesson cards */
.lesson-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); overflow: hidden;
}
.lesson-header {
  padding: 16px 20px; border-bottom: 3px solid var(--primary);
  background: rgba(255,255,255,.03);
}
.lesson-title { font-size: 1.1rem; font-weight: 800; color: white; margin: 0; }
.lesson-content { padding: 20px; color: var(--text-main); line-height: 1.7; }
.lesson-content p { margin-bottom: 12px; }
.lesson-content ul { padding-left: 24px; }
.lesson-content li { margin-bottom: 6px; }
.lesson-content code {
  background: rgba(108,99,255,.15); color: #b8b4ff;
  border-radius: 5px; padding: 1px 7px; font-size: .9em;
  font-family: 'Courier New', monospace;
}
.lesson-content pre {
  background: #151424; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto;
  font-family: 'Courier New', monospace; font-size: .88rem; color: #b8b4ff;
}
.syntax-block {
  background: #151424; border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px; font-family: 'Courier New', monospace;
  font-size: .9rem; color: #b8b4ff; overflow-x: auto;
  display: block; white-space: pre-wrap;
}

/* Fun fact */
.fun-fact {
  background: rgba(108,99,255,.08); border: 1px solid rgba(108,99,255,.2);
  border-radius: var(--radius-sm); padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start; margin: 12px 0;
}
.fun-fact-icon { font-size: 1.5rem; flex-shrink: 0; }

/* Visual boxes (for variables lesson) */
.visual-box, .types-grid, .operators-grid {
  display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0;
}
.box-item {
  background: rgba(255,255,255,.06); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: 12px 16px; text-align: center;
}
.box-label { font-weight: 800; color: var(--primary); display: block; font-size: .9rem; }
.box-value { font-family: 'Courier New',monospace; color: var(--accent-green); display: block; }
.type-card {
  border: 2px solid; border-radius: var(--radius-sm); padding: 14px;
  text-align: center; min-width: 110px; flex: 1;
}
.type-icon { font-size: 1.6rem; margin-bottom: 4px; }
.type-name { font-weight: 800; font-size: .88rem; color: white; margin-bottom: 4px; }
.type-example { font-family: 'Courier New',monospace; font-size: .82rem; color: var(--text-muted); }
.op-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: rgba(255,255,255,.05); border-radius: 8px; }
.op-item code { background: none; color: var(--accent-orange); font-size: 1.1rem; font-weight: 900; }
.op-item span { color: var(--text-muted); font-size: .9rem; }

/* Planning list (chapter 9) */
.planning-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.plan-item { background: rgba(255,255,255,.05); border-radius: 8px; padding: 10px 14px; font-weight: 600; }
.ideas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.idea-card { background: rgba(255,255,255,.05); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 16px; text-align: center; }
.idea-icon { font-size: 1.8rem; margin-bottom: 6px; }
.idea-title { font-weight: 800; color: white; font-size: .9rem; margin-bottom: 4px; }
.idea-desc { font-size: .8rem; color: var(--text-muted); }
.congrats-box {
  background: linear-gradient(135deg, rgba(108,99,255,.15), rgba(67,233,123,.15));
  border: 1px solid rgba(108,99,255,.3); border-radius: var(--radius);
  padding: 24px; text-align: center; margin-top: 16px;
}
.congrats-box h3 { color: white; font-size: 1.4rem; margin-bottom: 8px; }
.congrats-box p { color: var(--text-muted); margin: 0; }

/* Code blocks / editor */
.code-block-wrapper {
  margin: 0; border-top: 1px solid var(--border-subtle);
}
.code-block-header {
  background: #0d0c1a; padding: 8px 14px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: .82rem; font-weight: 700; color: var(--text-muted);
}
.btn-run-example {
  background: linear-gradient(135deg, #43E97B, #38f9d7);
  color: #0d1f0d; border: none; border-radius: 20px;
  padding: 5px 14px; font-weight: 800; font-size: .82rem; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.btn-run-example:hover { transform: scale(1.05); box-shadow: 0 4px 15px rgba(67,233,123,.4); }
.btn-hint {
  background: rgba(250,130,49,.12); color: var(--accent-orange);
  border: 1px solid rgba(250,130,49,.2); border-radius: 20px;
  padding: 5px 12px; font-weight: 700; font-size: .82rem; cursor: pointer;
}
.code-explanation {
  background: rgba(108,99,255,.06); border-top: 1px solid rgba(108,99,255,.15);
  padding: 10px 14px; display: flex; gap: 10px; align-items: flex-start;
  font-size: .88rem; color: var(--text-muted);
}
.ce-icon { font-size: 1.1rem; flex-shrink: 0; }
.code-output {
  background: #080712; border-top: 1px solid var(--border-subtle); padding: 12px 14px;
}
.output-header { font-size: .8rem; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.output-content {
  font-family: 'Courier New', monospace; font-size: .9rem;
  color: var(--accent-green); margin: 0; white-space: pre-wrap; word-break: break-word;
}
.output-error { color: #ff8fa3 !important; }

/* Exercise section */
.exercise-header {
  padding: 16px 20px; border-bottom: 3px solid var(--accent-orange);
  background: rgba(255,255,255,.03);
}
.exercise-title { font-size: 1.05rem; font-weight: 800; color: white; margin: 0; }
.exercise-description { padding: 16px 20px; color: var(--text-main); background: rgba(250,130,49,.05); border-bottom: 1px solid var(--border-subtle); }
.exercise-editor-wrap {}
.solution-panel { background: rgba(67,233,123,.05); border-top: 1px solid rgba(67,233,123,.2); padding: 14px; }
.solution-header { font-size: .8rem; font-weight: 700; color: var(--accent-green); margin-bottom: 6px; }
.solution-code { font-family: 'Courier New', monospace; font-size: .88rem; color: #a8f0c0; margin: 0; white-space: pre; }

/* CodeMirror override */
.CodeMirror {
  font-family: 'Courier New', monospace !important;
  font-size: 0.92rem !important;
  min-height: 120px;
  border-radius: 0;
}
.CodeMirror-scroll { min-height: 120px; }

/* Mini-game section */
.mini-game-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); overflow: hidden;
}
.mini-game-header {
  padding: 18px 20px; display: flex; gap: 14px;
  align-items: center; border-bottom: 1px solid var(--border-subtle);
}
.mini-game-icon { font-size: 2.2rem; }
.mini-game-title { font-weight: 800; color: white; margin: 0 0 2px; font-size: 1.05rem; }
.mini-game-desc { color: var(--text-muted); margin: 0; font-size: .88rem; }
.mini-game-content { padding: 20px; }

/* Fill blank game */
.fill-blank-question {
  background: rgba(255,255,255,.04); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: 16px; margin-bottom: 14px;
}
.fb-instruction { font-size: .92rem; color: var(--text-primary); font-weight: 600; margin-bottom: 8px; }
.fb-code { font-family: 'Courier New', monospace; font-size: .95rem; color: #b8b4ff; margin-bottom: 10px; }
.fb-hint { font-size: .82rem; color: var(--text-muted); margin-bottom: 8px; }
.fb-input {
  background: rgba(255,255,255,.05); border: 1.5px solid var(--border-subtle);
  border-radius: 8px; color: white; padding: 8px 12px; font-size: .9rem;
  width: 100%; font-family: 'Courier New', monospace; transition: border-color .2s;
}
.fb-input:focus { outline: none; border-color: var(--primary); }
.fb-result-ok { border-color: var(--accent-green) !important; background: rgba(67,233,123,.08) !important; }
.fb-result-bad { border-color: #ff6584 !important; background: rgba(255,101,132,.08) !important; }

/* Type match game */
.type-match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tm-value {
  background: rgba(255,255,255,.05); border: 2px solid var(--border-subtle);
  border-radius: 10px; padding: 10px; text-align: center;
  font-family: 'Courier New', monospace; font-size: .9rem; color: white;
  cursor: pointer; transition: border-color .2s;
}
.tm-value.selected { border-color: var(--primary); background: rgba(108,99,255,.1); }
.tm-type-btn {
  background: rgba(255,255,255,.03); border: 2px solid var(--border-subtle);
  border-radius: 10px; padding: 10px; text-align: center;
  font-weight: 700; font-size: .9rem; cursor: pointer; transition: all .2s;
}
.tm-type-btn:hover { border-color: var(--accent-cyan); }
.tm-matched { border-color: var(--accent-green) !important; background: rgba(67,233,123,.08) !important; color: var(--accent-green) !important; }

/* Math race game */
.math-race-question {
  text-align: center; margin-bottom: 20px;
}
.mr-expr {
  font-size: 2.5rem; font-weight: 900; color: white; font-family: 'Courier New', monospace;
  margin-bottom: 16px;
}
.mr-input {
  font-size: 1.5rem; text-align: center; background: rgba(255,255,255,.06);
  border: 2px solid var(--border-subtle); border-radius: 14px;
  color: white; padding: 10px 20px; width: 150px; font-family: 'Courier New', monospace;
}
.mr-input:focus { outline: none; border-color: var(--primary); }
.mr-timer { font-size: 1.1rem; color: var(--text-muted); font-weight: 700; margin-bottom: 8px; }
.mr-score { font-size: 1.4rem; font-weight: 900; color: var(--accent-green); margin-top: 10px; }

/* Quiz section */
.quiz-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); overflow: hidden;
}
.quiz-header {
  padding: 18px 20px; display: flex; gap: 14px;
  align-items: center; border-bottom: 1px solid var(--border-subtle);
}
.quiz-icon { font-size: 2rem; }
.quiz-title { font-weight: 800; color: white; margin: 0 0 2px; }
.quiz-subtitle { color: var(--text-muted); margin: 0; font-size: .88rem; }
.quiz-start-area { padding: 28px 20px; text-align: center; color: var(--text-muted); }
.btn-start-quiz {
  color: white; border: none; border-radius: 50px;
  padding: 13px 32px; font-size: 1.05rem; font-weight: 800;
  cursor: pointer; transition: transform .2s, opacity .2s;
  margin-top: 12px;
}
.btn-start-quiz:hover { transform: scale(1.04); opacity: .9; }
.quiz-already-done {
  padding: 20px; background: rgba(67,233,123,.06);
  border-bottom: 1px solid rgba(67,233,123,.15);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.qad-score { font-weight: 700; color: var(--accent-green); }
.btn-retry-quiz {
  background: rgba(67,233,123,.12); border: 1px solid rgba(67,233,123,.2);
  color: var(--accent-green); border-radius: 20px; padding: 6px 16px;
  font-weight: 700; font-size: .88rem; cursor: pointer;
}

/* Quiz timer (chapitre 3) */
.quiz-timer-bar { padding: 10px 20px 0; font-size: .88rem; color: var(--text-muted); font-weight: 600; }
.quiz-timer-badge { display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; padding: 2px 10px; border-radius: 20px; font-weight: 800;
  font-size: .95rem; transition: background .3s, color .3s; }
.timer-ok      { background: rgba(67,233,123,.15); color: #43e97b; }
.timer-warning { background: rgba(250,130,49,.15);  color: #FA8231; }
.timer-urgent  { background: rgba(255,101,132,.2);  color: #ff6584; animation: pulse-timer .5s infinite alternate; }
@keyframes pulse-timer { from { transform: scale(1); } to { transform: scale(1.15); } }

/* Quiz questions */
.quiz-question { padding: 20px; }
.qq-progress { font-size: .82rem; color: var(--text-muted); font-weight: 700; margin-bottom: 12px; }
.qq-text { font-size: 1.05rem; font-weight: 700; color: white; margin-bottom: 16px; line-height: 1.4; }
.qq-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.qq-option {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.04); border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: 12px 14px;
  cursor: pointer; transition: all .2s; font-weight: 600;
}
.qq-option:hover { border-color: var(--primary); background: rgba(108,99,255,.08); }
.qq-opt-letter {
  background: rgba(255,255,255,.08); border-radius: 6px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: .82rem; flex-shrink: 0;
}
.qq-option.correct { border-color: var(--accent-green) !important; background: rgba(67,233,123,.12) !important; color: var(--accent-green); }
.qq-option.incorrect { border-color: #ff6584 !important; background: rgba(255,101,132,.12) !important; color: #ff8fa3; }
.qq-explanation {
  background: rgba(108,99,255,.07); border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0; padding: 10px 14px;
  font-size: .88rem; color: var(--text-main); margin-bottom: 14px;
}
.btn-next-q {
  background: linear-gradient(135deg, var(--primary), #9c63ff);
  color: white; border: none; border-radius: 50px;
  padding: 10px 24px; font-weight: 800; cursor: pointer;
  transition: transform .15s;
}
.btn-next-q:hover { transform: scale(1.03); }

/* Quiz results */
.quiz-results-wrap { padding: 24px; text-align: center; }
.qr-emoji { font-size: 4rem; margin-bottom: 8px; }
.qr-title { font-size: 1.6rem; font-weight: 900; color: white; margin-bottom: 4px; }
.qr-score { font-size: 2rem; font-weight: 900; margin-bottom: 20px; }
.qr-score.perfect { color: var(--accent-green); }
.qr-score.good { color: var(--accent-orange); }
.qr-score.ok { color: var(--secondary); }
.quiz-detail-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--border-subtle); text-align: left;
}
.qdr-icon { font-size: 1.2rem; flex-shrink: 0; }
.qdr-question { font-weight: 600; color: white; font-size: .9rem; }
.qdr-expl { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.btn-complete-chapter {
  color: white; border: none; border-radius: 50px;
  padding: 16px 40px; font-size: 1.1rem; font-weight: 800;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
}
.btn-complete-chapter:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.chapter-completed-banner {
  background: rgba(67,233,123,.08); border: 1px solid rgba(67,233,123,.2);
  border-radius: var(--radius); padding: 20px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: 1.05rem; font-weight: 700; color: var(--accent-green);
}
.btn-next-chapter {
  background: linear-gradient(135deg, var(--primary), #9c63ff);
  color: white; border-radius: 30px; padding: 10px 24px;
  font-weight: 800; text-decoration: none; margin-left: auto;
}

/* Sidebar */
.chapter-sidebar { position: sticky; top: 80px; }
.sidebar-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: 16px;
}
.sidebar-title { font-size: .9rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.sidebar-toc { list-style: none; padding: 0; margin: 0; }
.toc-item { margin-bottom: 4px; }
.toc-link {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); text-decoration: none; font-size: .88rem;
  font-weight: 600; padding: 6px 8px; border-radius: 8px; transition: all .15s;
}
.toc-link:hover { background: rgba(255,255,255,.05); color: white; }
.chapter-nav-list { display: flex; flex-direction: column; gap: 4px; }
.chapter-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; text-decoration: none;
  border: 1px solid transparent; color: var(--text-muted);
  font-size: .85rem; font-weight: 600; transition: all .15s;
}
.chapter-nav-item:hover { background: rgba(255,255,255,.05); color: white; }
.chapter-nav-item.active { background: rgba(108,99,255,.1); color: white; border-color: var(--primary); }
.cnav-icon { font-size: 1rem; }
.sidebar-level { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.sl-icon { font-size: 1.8rem; }
.sl-title { font-weight: 800; color: white; font-size: .9rem; }
.sl-xp { font-size: .82rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   PROFILE PAGE
   ═══════════════════════════════════════════════════════════ */
.profile-page { min-height: 85vh; }
.profile-header-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card2));
  border: 1px solid var(--border-subtle); border-radius: var(--radius);
  padding: 28px 32px; display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap;
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar-xl {
  width: 90px; height: 90px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; font-weight: 900; color: white;
  box-shadow: 0 0 0 4px rgba(255,255,255,.1);
}
.profile-level-ring {
  position: absolute; bottom: -4px; right: -4px;
  background: var(--primary); color: white; font-weight: 900;
  width: 30px; height: 30px; border-radius: 50%; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-dark);
}
.profile-username { font-size: 2rem; font-weight: 900; color: white; margin-bottom: 6px; }
.profile-title-badge {
  display: inline-flex; background: rgba(255,255,255,.07); border-radius: 30px;
  padding: 5px 16px; font-size: .95rem; font-weight: 700; color: #b8b4ff; margin-bottom: 10px;
}
.profile-xp-row { display: flex; gap: 20px; flex-wrap: wrap; color: var(--text-muted); font-size: .9rem; }
.profile-xp-row strong { color: white; }
.profile-stat-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); padding: 20px;
}
.profile-section-title { font-size: 1rem; font-weight: 800; color: white; margin-bottom: 16px; }
.stat-row { display: flex; gap: 10px; }
.stat-box {
  flex: 1; background: rgba(255,255,255,.05); border-radius: 12px; padding: 14px;
  text-align: center;
}
.stat-box-num { font-size: 1.8rem; font-weight: 900; color: white; }
.stat-box-label { font-size: .78rem; color: var(--text-muted); font-weight: 600; }
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.badge-card {
  position: relative; border-radius: 12px; padding: 14px 10px; text-align: center;
  border: 1px solid var(--border-subtle);
}
.badge-card.badge-earned { background: rgba(255,255,255,.07); }
.badge-card.badge-locked { opacity: .35; background: rgba(255,255,255,.03); }
.badge-card-icon { font-size: 1.8rem; margin-bottom: 6px; }
.badge-card-name { font-size: .78rem; font-weight: 800; color: white; margin-bottom: 2px; }
.badge-card-desc { font-size: .7rem; color: var(--text-muted); }
.badge-lock-overlay { font-size: 1rem; margin-top: 4px; }
.chapter-progress-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.chapter-progress-row:last-child { border-bottom: none; }
.cp-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.cp-title { font-weight: 700; color: white; font-size: .9rem; }
.cp-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.cp-badge { font-size: .75rem; border-radius: 6px; padding: 2px 8px; font-weight: 700; }
.cp-done { background: rgba(67,233,123,.12); color: var(--accent-green); }
.cp-locked { background: rgba(255,255,255,.05); color: var(--text-muted); }
.cp-available { background: rgba(108,99,255,.12); color: #b8b4ff; }
.cp-xp { font-size: .75rem; color: var(--accent-orange); font-weight: 700; }
.cp-quiz { font-size: .75rem; color: var(--accent-cyan); font-weight: 700; }
.cp-action { margin-left: auto; }
.btn-cp {
  background: rgba(255,255,255,.06); border: 1px solid var(--border-subtle);
  color: var(--text-muted); border-radius: 8px; padding: 4px 12px;
  font-size: .8rem; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.quiz-history-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.quiz-history-row:last-child { border-bottom: none; }
.qh-icon { font-size: 1.4rem; }
.qh-title { font-weight: 700; color: white; font-size: .9rem; }
.qh-date { font-size: .78rem; color: var(--text-muted); }
.qh-score {
  margin-left: auto; font-size: 1rem; font-weight: 900;
  background: rgba(255,255,255,.07); border-radius: 10px; padding: 4px 12px;
}
.qh-score.perfect { color: var(--accent-green); background: rgba(67,233,123,.1); }
.qh-score.good { color: var(--accent-orange); background: rgba(250,130,49,.1); }
.qh-score.ok { color: var(--secondary); }

/* ──────── TOAST NOTIFICATIONS ──────── */
.toast-custom {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 14px; padding: 12px 16px; color: white;
  box-shadow: var(--shadow); min-width: 240px;
}
.toast-custom.toast-success { border-color: rgba(67,233,123,.3); }
.toast-custom.toast-badge { border-color: rgba(253,203,110,.3); }

/* ──────── CONFETTI ANIMATION ──────── */
@keyframes confettiFall {
  from { transform: translateY(-10px) rotate(0deg); opacity:1; }
  to   { transform: translateY(100vh) rotate(720deg); opacity:0; }
}
.confetti-piece {
  position: fixed; width: 10px; height: 10px;
  border-radius: 2px; pointer-events: none; z-index: 9999;
  animation: confettiFall linear forwards;
}

/* ──────── RESPONSIVE ──────── */
@media (max-width: 768px) {
  .user-hero-card { flex-direction: column; }
  .user-hero-stats { justify-content: space-around; width: 100%; }
  .chapter-hero-content { gap: 14px; }
  .profile-header-card { flex-direction: column; align-items: center; text-align: center; }
  .profile-xp-row { justify-content: center; }
  .auth-card { padding: 28px 20px; }
  .chapter-sidebar { position: static; }
  .hero-title { font-size: 2rem; }
  .type-match-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .brand-name { font-size: 1.1rem; }
  .hero-mascot { font-size: 3.5rem; }
  .cta-box { padding: 36px 20px; }
  .ideas-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   TTS — Barre de lecture
   ═══════════════════════════════════════════════════════════ */
.tts-bar-wrapper {
  background: rgba(108,99,255,.07);
  border-bottom: 1px solid rgba(108,99,255,.18);
  padding: 10px 0;
  position: sticky; top: 58px; z-index: 99;
  backdrop-filter: blur(10px);
}
#tts-bar { min-height: 36px; }

.tts-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.tts-btn-main {
  background: linear-gradient(135deg, #6C63FF, #9c63ff);
  color: white; border: none; border-radius: 30px;
  padding: 8px 18px; font-size: .9rem; font-weight: 800;
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  display: flex; align-items: center; gap: 6px;
}
.tts-btn-main:hover { transform: scale(1.04); box-shadow: 0 4px 16px rgba(108,99,255,.4); }

.tts-btn-stop {
  background: rgba(255,101,132,.15); color: #ff6584;
  border: 1px solid rgba(255,101,132,.3); border-radius: 50%;
  width: 36px; height: 36px; font-size: 1rem;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.tts-btn-stop:hover { background: rgba(255,101,132,.3); }

.tts-speed {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--text-muted); font-weight: 600;
}
.tts-speed input[type=range] {
  width: 80px; accent-color: var(--primary);
  cursor: pointer;
}
#tts-rate-val { min-width: 32px; color: var(--primary); font-weight: 800; }

.tts-now-playing {
  display: flex; align-items: center; gap: 8px;
  font-size: .82rem; color: #b8b4ff; font-weight: 600; margin-top: 6px;
  animation: pulse-tts 2s ease-in-out infinite;
}
@keyframes pulse-tts {
  0%,100% { opacity: 1; }
  50%      { opacity: .6; }
}

.tts-fallback-note {
  font-size: .75rem; color: var(--text-muted); font-style: italic; margin-top: 4px;
}

/* Section en cours de lecture */
.tts-reading {
  border-color: rgba(108,99,255,.5) !important;
  box-shadow: 0 0 0 2px rgba(108,99,255,.25), var(--shadow-sm) !important;
  transition: box-shadow .3s, border-color .3s;
}
.tts-reading .lesson-header,
.tts-reading .exercise-header {
  background: rgba(108,99,255,.08) !important;
}

@media (max-width: 576px) {
  .tts-speed { display: none; } /* simplifié sur mobile */
  .tts-btn-main { font-size: .82rem; padding: 7px 14px; }
}
