:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-elev: #1c2330;
  --border: #2d3748;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent2: #f778ba;
  --green: #3fb950;
  --amber: #d29922;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
}

.container { max-width: 980px; margin: 0 auto; padding: 0 20px; }

header {
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
  background: var(--bg-card);
  position: sticky; top: 0; z-index: 10;
}
header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.logo span { color: var(--accent); }
nav a { color: var(--text-dim); text-decoration: none; margin-left: 18px; font-size: .95rem; }
nav a:hover, nav a.active { color: var(--accent); }

.hero { padding: 56px 0 36px; text-align: center; }
.hero h1 { font-size: 2.3rem; margin-bottom: 10px; }
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p { color: var(--text-dim); max-width: 640px; margin: 0 auto; font-size: 1.05rem; }

.progress-global {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 26px;
  margin: 28px 0;
}
.progress-global h3 { font-size: .95rem; color: var(--text-dim); font-weight: 500; margin-bottom: 10px; }
.bar { background: var(--bg-elev); border-radius: 99px; height: 14px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  transition: width .6s ease;
  min-width: 0;
}
.progress-label { text-align: right; font-size: .85rem; color: var(--text-dim); margin-top: 6px; }

.roadmap { padding-bottom: 60px; }
.roadmap h2 { margin: 26px 0 18px; font-size: 1.5rem; }

.phase {
  display: flex;
  gap: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 14px;
  transition: border-color .2s;
}
.phase:hover { border-color: var(--accent); }
.phase.locked { opacity: .55; }
.phase-num {
  flex-shrink: 0;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--mono);
  color: var(--accent);
}
.phase.done .phase-num { background: var(--green); border-color: var(--green); color: #fff; }
.phase.current .phase-num { border-color: var(--accent); box-shadow: 0 0 12px rgba(88,166,255,.4); }
.phase-body { flex: 1; }
.phase-body h3 { font-size: 1.1rem; margin-bottom: 4px; }
.phase-body p { color: var(--text-dim); font-size: .92rem; }
.phase-meta { font-size: .8rem; color: var(--amber); margin-top: 6px; font-family: var(--mono); }
.phase-action { align-self: center; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #0d1117;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  text-decoration: none;
  font-size: .92rem;
  border: none;
  cursor: pointer;
  transition: transform .1s, opacity .2s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn.secondary { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); }
.btn.ghost { background: transparent; color: var(--text-dim); border: 1px dashed var(--border); cursor: default; }

/* ---- Pages leçon ---- */
.lesson { padding: 36px 0 80px; }
.lesson h1 { font-size: 1.9rem; margin-bottom: 6px; }
.lesson .subtitle { color: var(--text-dim); margin-bottom: 30px; }
.lesson h2 { font-size: 1.35rem; margin: 40px 0 14px; color: var(--accent); }
.lesson h3 { font-size: 1.1rem; margin: 24px 0 10px; }
.lesson p, .lesson li { color: #c9d1d9; margin-bottom: 10px; }
.lesson ul, .lesson ol { padding-left: 24px; margin-bottom: 14px; }
.lesson code {
  font-family: var(--mono);
  background: var(--bg-elev);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: .88em;
  color: var(--accent2);
}
.callout {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 14px 18px;
  margin: 18px 0;
  color: var(--text-dim);
}

.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin: 22px 0;
}
.widget h3 { margin-top: 0; display: flex; align-items: center; gap: 8px; }
.widget h3::before { content: '⚡'; }

/* Convertisseur binaire */
.bits { display: flex; gap: 8px; justify-content: center; margin: 18px 0; flex-wrap: wrap; }
.bit {
  width: 56px; height: 56px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 1.5rem;
  font-family: var(--mono);
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.bit.on { background: var(--accent); border-color: var(--accent); color: #0d1117; box-shadow: 0 0 14px rgba(88,166,255,.5); }
.bit-weights { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.bit-weights span { width: 56px; text-align: center; font-size: .78rem; color: var(--text-dim); font-family: var(--mono); }
.decimal-out { text-align: center; font-size: 1.3rem; margin-top: 14px; font-family: var(--mono); }
.decimal-out b { color: var(--accent2); font-size: 1.8rem; }

/* Simulateur de portes */
.gate-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.gate-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
}
.gate-btn.active { background: var(--accent); color: #0d1117; border-color: var(--accent); }
.gate-sim { display: flex; align-items: center; justify-content: center; gap: 26px; margin: 24px 0; flex-wrap: wrap; }
.switches { display: flex; flex-direction: column; gap: 16px; }
.switch {
  width: 70px; height: 44px;
  border-radius: 99px;
  border: 2px solid var(--border);
  background: var(--bg-elev);
  cursor: pointer;
  position: relative;
  transition: all .2s;
}
.switch::after {
  content: '';
  position: absolute;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--text-dim);
  top: 4px; left: 4px;
  transition: all .2s;
}
.switch.on { background: rgba(63,185,80,.25); border-color: var(--green); }
.switch.on::after { left: 30px; background: var(--green); }
.switch-label { font-family: var(--mono); font-size: .85rem; color: var(--text-dim); text-align: center; margin-top: 4px; }
.gate-box {
  width: 110px; height: 90px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg-elev);
}
.lamp {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--bg-elev);
  transition: all .25s;
}
.lamp.on { background: #f7d154; border-color: #f7d154; box-shadow: 0 0 30px rgba(247,209,84,.7); }
.wire { width: 40px; height: 3px; background: var(--border); }
.wire.live { background: var(--green); box-shadow: 0 0 6px rgba(63,185,80,.6); }

table.truth {
  border-collapse: collapse;
  margin: 14px auto;
  font-family: var(--mono);
}
table.truth th, table.truth td {
  border: 1px solid var(--border);
  padding: 8px 22px;
  text-align: center;
}
table.truth th { background: var(--bg-elev); color: var(--accent); }
table.truth tr.hl td { background: rgba(88,166,255,.15); }

/* Quiz */
.quiz-q { margin-bottom: 22px; }
.quiz-q p { font-weight: 600; }
.quiz-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.quiz-opt {
  text-align: left;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  font-size: .95rem;
}
.quiz-opt:hover { border-color: var(--accent); }
.quiz-opt.correct { border-color: var(--green); background: rgba(63,185,80,.15); }
.quiz-opt.wrong { border-color: #f85149; background: rgba(248,81,73,.12); }
.quiz-result { font-weight: 700; margin-top: 14px; font-size: 1.05rem; }

.complete-box { text-align: center; margin: 40px 0; }
.lesson-nav { display: flex; justify-content: space-between; margin-top: 50px; border-top: 1px solid var(--border); padding-top: 22px; }

footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: .85rem;
}
