:root,
html[data-theme="dark"] {
  --bg: #10141c;
  --surface: #1a2130;
  --surface-2: #212a3d;
  --border: #2c3750;
  --text: #e7ebf2;
  --text-muted: #8d97ac;
  --accent: #e8a33d;
  --accent-cyan: #2dd4bf;
  --cat-reseaux: #4f8fe8;
  --cat-cyber: #e8615d;
  --cat-dev: #2dd4bf;
  --cat-general: #b98ce8;
  --cat-stage: #e8a33d;
  --font-display: 'IBM Plex Mono', monospace;
  --font-body: 'IBM Plex Sans', sans-serif;
  --radius: 8px;
}

html[data-theme="light"] {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f3f6fb;
  --border: #c7d4e3;
  --text: #1c3554;
  --text-muted: #5b7089;
  --accent: #2d5fa3;
  --accent-cyan: #2dd4bf;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 16px;
}
.brand {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand-accent { color: var(--accent); }

.mode-toggle { display: flex; gap: 8px; }
.mode-btn {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.mode-btn:hover { border-color: var(--accent); color: var(--text); }
.mode-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232, 163, 61, 0.1);
}

.theme-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }
.theme-btn .icon-sun, .theme-btn .icon-moon { display: none; }
html[data-theme="dark"] .theme-btn .icon-moon { display: block; }
html[data-theme="light"] .theme-btn .icon-sun { display: block; }

.menu-wrapper { position: relative; }
.menu-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.menu-icon, .menu-icon::before, .menu-icon::after {
  content: "";
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text);
  position: relative;
}
.menu-icon::before { position: absolute; top: -5px; left: 0; }
.menu-icon::after { position: absolute; top: 5px; left: 0; }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 210px;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.dropdown-menu.open { display: flex; }
.dropdown-menu a {
  padding: 10px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.dropdown-menu a:last-child { border-bottom: none; }
.dropdown-menu a:hover { background: var(--surface-2); }

.tab-bar {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 20px;
  overflow-x: auto;
}
.tab-link {
  font-family: var(--font-display);
  font-size: 12.5px;
  padding: 9px 16px 8px;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  white-space: nowrap;
  position: relative;
  top: 1px;
}
.tab-link:hover { color: var(--text); background: var(--surface); }
.tab-link.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 1px solid var(--surface);
}
.tab-divider { width: 1px; align-self: stretch; background: var(--border); margin: 8px 6px; }
.tab-group { display: none; gap: 2px; }

main { max-width: 960px; margin: 0 auto; padding: 32px 24px 64px; }
.breadcrumb {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
}
h1 { font-family: var(--font-display); font-weight: 500; font-size: 26px; margin: 0 0 24px; }
h2 { font-family: var(--font-display); font-weight: 500; font-size: 18px; margin: 32px 0 12px; padding-top: 8px; border-top: 1px solid var(--border); }
h2:first-of-type { border-top: none; padding-top: 0; }
h3 { font-family: var(--font-display); font-weight: 500; font-size: 15px; margin: 24px 0 10px; color: var(--text-muted); }
p { margin: 0 0 14px; }
ul, ol { padding-left: 20px; }
li { margin-bottom: 8px; }

.back-link { display: inline-block; font-family: var(--font-display); font-size: 12px; color: var(--accent); margin-bottom: 16px; }

.toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 28px; }
.toc p { font-family: var(--font-display); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 0 0 8px; }
.toc ul { margin: 0; padding-left: 18px; }
.toc li { margin-bottom: 4px; font-size: 13px; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--accent); }

code {
  font-family: var(--font-display);
  font-size: 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 18px;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
pre.ascii code { color: var(--text-muted); white-space: pre; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 20px;
  font-size: 13.5px;
}
th, td {
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--border);
}
th {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
}
td { background: var(--surface); }

.tip {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 18px;
  font-size: 14px;
}

.intro { color: var(--text-muted); max-width: 640px; margin-bottom: 32px; }

.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 24px; }
.quick-link-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--card-color, var(--accent));
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: transform .15s ease;
}
.quick-link-card:hover { transform: translateY(-2px); }
.quick-link-card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 500; }
.quick-link-card p { margin: 0; font-size: 13px; color: var(--text-muted); }

.fiche-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.fiche-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--card-color, var(--accent));
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: transform .15s ease, border-color .15s ease;
}
.fiche-card:hover { transform: translateY(-2px); }
.fiche-card .tag {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.fiche-card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 500; }
.fiche-card p { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); }
.fiche-card .fiche-link { font-size: 13px; color: var(--accent); }

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.quiz-question { font-size: 15px; margin: 0 0 14px; font-weight: 500; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  width: 100%;
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option.correct { border-color: var(--accent-cyan); background: rgba(45, 212, 191, 0.1); }
.quiz-option.incorrect { border-color: var(--cat-cyber); background: rgba(232, 97, 93, 0.1); }
.quiz-result { font-family: var(--font-display); font-size: 13px; color: var(--text-muted); margin-top: 10px; min-height: 16px; }

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

.btn {
  font-family: var(--font-display);
  font-size: 13px;
  background: var(--accent);
  color: #10141c;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn:hover { opacity: 0.9; }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .header-bar { padding: 12px 16px; flex-wrap: wrap; }
  main { padding: 24px 16px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
