:root {
  --text: #1a1a1a;
  --text-muted: #555;
  --bg: #f5f5f3;
  --bg-section: #eeedeb;
  --border: #ddddd9;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --sidebar-width: 280px;
  --content-max: 820px;
  font-size: 16px;
}

/* Dark mode via OS preference */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --text: #e5e5e5;
    --text-muted: #a1a1aa;
    --bg: #0a0a0a;
    --bg-section: #141414;
    --border: #262626;
    --accent: #60a5fa;
    --accent-light: #1e293b;
  }
}

/* Dark mode via manual toggle */
:root.dark {
  --text: #e5e5e5;
  --text-muted: #a1a1aa;
  --bg: #0a0a0a;
  --bg-section: #141414;
  --border: #262626;
  --accent: #60a5fa;
  --accent-light: #1e293b;
}

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

/* ========== ACCESSIBILITY ========== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 200;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: 0 0 6px 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* Screen-reader only text (visually hidden but accessible) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* External link indicator (visual hint for new tab) */
.chapter a[target="_blank"]::after,
footer a[target="_blank"]::after {
  content: " \2197";
  font-size: 0.75em;
  vertical-align: super;
}

/* Focus visible for all interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

/* ========== NAV ========== */
#topnav {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1.5rem;
  z-index: 100;
}

.nav-brand a {
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-center {
  flex: 1;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-github {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
  white-space: nowrap;
}

.btn-github:hover { border-color: var(--text); }

/* ========== LAYOUT ========== */
.layout-wrapper {
  display: flex;
  min-height: calc(100vh - 50px);
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: sticky;
  top: 50px;
  height: calc(100vh - 50px);
  overflow-y: auto;
  background: var(--bg);
}

/* ========== SEARCH ========== */
.nav-search {
  padding: 0.75rem 1.25rem;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.nav-search input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.82rem;
  transition: border-color 0.15s;
}

.nav-search input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.nav-search input::placeholder {
  color: var(--text-muted);
}

#search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 1.25rem;
  right: 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  display: block;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.search-active {
  background: var(--accent-light);
}

.search-result-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

.search-result-body {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.3;
}

.search-no-result {
  padding: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

#side-nav {
  display: flex;
  flex-direction: column;
}

#side-nav a {
  display: block;
  padding: 0.45rem 1.25rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  line-height: 1.4;
}

#side-nav a:hover {
  color: var(--text);
  background: var(--bg-section);
  border-left-color: var(--border);
}

#side-nav a.active {
  color: var(--accent);
  background: var(--accent-light);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* Hierarchical sidebar */
.nav-home {
  display: block;
  padding: 0.5rem 1.25rem;
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.nav-home:hover { color: var(--accent); }

.nav-chapter { margin-bottom: 0.15rem; }

.nav-chapter-title {
  display: block;
  padding: 0.4rem 1.25rem;
  font-weight: 600;
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.nav-chapter-title:hover {
  color: var(--accent);
  background: var(--bg-section);
}

.nav-chapter-title.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-light);
}

.nav-sections {
  display: none;
}

.nav-chapter.open .nav-sections {
  display: block;
}

.nav-sections a {
  display: block;
  padding: 0.25rem 1.25rem 0.25rem 2rem;
  font-size: 0.75rem;
  text-decoration: none;
  color: var(--text-muted);
  border-left: 3px solid transparent;
  transition: all 0.15s;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-sections a:hover {
  color: var(--text);
  background: var(--bg-section);
}

.nav-sections a.active {
  color: var(--accent);
  background: var(--accent-light);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-group-label {
  padding: 0.6rem 1.25rem 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.nav-group-label:first-child {
  margin-top: 0;
}

.nav-utils {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ========== MAIN CONTENT ========== */
main#content {
  flex: 1;
  max-width: 960px;
  padding: 0 3rem 4rem;
  overflow-x: hidden;
}

/* ========== HERO ========== */
#hero {
  margin: 3rem 0 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

#hero h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.tagline {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ========== CHAPTERS ========== */
.chapter {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}

.chapter:last-child { border-bottom: none; }

/* Titres dans le contenu genere par markdown */
.chapter h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-top: 1.5rem;
  letter-spacing: -0.02em;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.chapter h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  padding-top: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

.chapter h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--accent);
}

.chapter h4 {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 1.2rem 0 0.4rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.78rem;
}

/* Copy button on code blocks */
.code-wrapper {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  background: rgba(255,255,255,0.1);
  color: #999;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.copy-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.copy-btn.copied {
  color: #22c55e;
  border-color: #22c55e;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb .sep {
  margin: 0 0.3rem;
}

/* Last updated badge */
.last-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.chapter p {
  color: var(--text);
  font-size: 0.92rem;
  margin-bottom: 0.8rem;
}

.chapter ul, .chapter ol {
  margin: 0.5rem 0 1rem 1.5rem;
  font-size: 0.92rem;
}

.chapter li {
  margin-bottom: 0.3rem;
}

.chapter a {
  color: var(--accent);
  text-decoration: none;
}

.chapter a:hover {
  text-decoration: underline;
}

/* ========== TABLES ========== */
.chapter table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.85rem;
}

.chapter th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.chapter td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.chapter tr:nth-child(even) {
  background: var(--bg-section);
}

.chapter tr:last-child td {
  border-bottom: none;
}

/* ========== CODE ========== */
.chapter code {
  background: var(--bg-section);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}

.chapter pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.chapter pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* ========== BLOCKQUOTES (Principes, Notes) ========== */
.chapter blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  border-radius: 0 6px 6px 0;
  font-size: 0.9rem;
}

.chapter blockquote p {
  margin-bottom: 0.3rem;
}

/* ========== HR ========== */
.chapter hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ========== STRONG / EM ========== */
.chapter strong {
  font-weight: 600;
}

/* ========== FOOTER ========== */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover { color: var(--text); }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar {
    display: none;
    position: fixed;
    top: 50px;
    left: 0;
    width: 280px;
    height: calc(100vh - 50px);
    z-index: 99;
    background: var(--bg);
    box-shadow: 4px 0 12px rgba(0,0,0,0.08);
  }

  .sidebar.open {
    display: block;
  }

  .menu-toggle {
    display: block;
  }

  main#content {
    padding: 0 1.25rem 4rem;
  }

  .chapter pre {
    font-size: 0.75rem;
  }
}

@media (max-width: 640px) {
  #hero h1 { font-size: 1.5rem; }
  .chapter h1 { font-size: 1.3rem; }
  .chapter h2 { font-size: 1.1rem; }
  .chapter table { font-size: 0.78rem; }
}

/* ========== LANDING PAGE ========== */
.landing {
  max-width: 820px;
  padding: 0 2.5rem 4rem;
}

.landing-hero {
  margin: 2rem 0 1.5rem;
  text-align: center;
}

.landing-hero h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
}

.landing-hero .lead {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 1rem;
  line-height: 1.5;
}

.landing-hero .hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.btn-primary {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.9rem;
  text-decoration: none;
  transition: border-color 0.15s;
}

.btn-secondary:hover { border-color: var(--text); }

.landing-section {
  margin: 2rem 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.landing-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.landing-section p {
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.audience-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin: 0.75rem 0;
}

.audience-card {
  padding: 0.75rem 1rem;
  background: var(--bg-section);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.audience-card strong {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.82rem;
}

.audience-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.path-list {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
}

.path-list li {
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent);
  margin-bottom: 0.5rem;
  background: var(--accent-light);
  border-radius: 0 4px 4px 0;
}

.path-list li strong {
  display: inline;
  font-size: 0.85rem;
  margin-right: 0.3rem;
}

.path-list li span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.chapter-card {
  display: block;
  padding: 0.6rem 0.85rem;
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}

.chapter-card:hover {
  border-color: var(--accent);
}

.chapter-card .num {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.chapter-card .card-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin: 0.1rem 0;
}

.chapter-card .card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ========== CHECKLIST ========== */
.checklist-group {
  margin: 1.5rem 0;
}

.checklist-group h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.88rem;
}

.checklist-item input[type="checkbox"] {
  margin-top: 0.3rem;
  accent-color: var(--accent);
}

.checklist-item.checked label {
  color: var(--text-muted);
  text-decoration: line-through;
}

.checklist-actions {
  display: flex;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.checklist-actions button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.checklist-actions button:hover {
  border-color: var(--text);
}

.checklist-progress {
  margin: 1rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

/* Chapter nav (prev/next) */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.chapter-nav a {
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--accent);
}

.chapter-nav a:hover {
  text-decoration: underline;
}

/* ========== THEME TOGGLE ========== */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
}

/* ========== LANGUAGE TOGGLE ========== */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}

.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.theme-toggle:hover {
  border-color: var(--text);
}

/* ========== GITHUB BADGES ========== */
.github-badges {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.github-badges .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
}

/* ========== EDIT LINK ========== */
.edit-link {
  display: inline-block;
  margin-top: 2rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.15s, color 0.15s;
}

.edit-link:hover {
  color: var(--text);
  border-color: var(--text);
}

/* ========== GISCUS COMMENTS ========== */
.giscus-wrapper {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

/* ========== CODE BLOCKS DARK MODE FIX ========== */
:root.dark .chapter code,
:root.dark .chapter pre {
  background: #1a1a2e;
}

:root.dark .chapter pre code {
  background: none;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) .chapter code,
  :root:not(.light) .chapter pre {
    background: #1a1a2e;
  }

  :root:not(.light) .chapter pre code {
    background: none;
  }
}

/* ========== LEARNING OBJECTIVES (replaces old TOC) ========== */
.learning-objectives {
  margin: 0 0 2rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--lo-bg-start), var(--lo-bg-end));
  border: 1px solid var(--lo-border);
  border-radius: 12px;
  border-left: 4px solid var(--lo-accent);
}

:root {
  --lo-bg-start: #eff6ff;
  --lo-bg-end: #f0fdf4;
  --lo-border: #bfdbfe;
  --lo-accent: #3b82f6;
  --lo-check: #22c55e;
  --lo-text: #1e3a5f;
  --lo-link: #2563eb;
  --bravo-bg-start: #f0fdf4;
  --bravo-bg-end: #fefce8;
  --bravo-border: #86efac;
  --bravo-accent: #22c55e;
  --bravo-text: #14532d;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --lo-bg-start: #0c1929;
    --lo-bg-end: #0a1f12;
    --lo-border: #1e3a5f;
    --lo-accent: #60a5fa;
    --lo-check: #4ade80;
    --lo-text: #bfdbfe;
    --lo-link: #93c5fd;
    --bravo-bg-start: #0a1f12;
    --bravo-bg-end: #1a1c0a;
    --bravo-border: #166534;
    --bravo-accent: #4ade80;
    --bravo-text: #bbf7d0;
  }
}

:root.dark {
  --lo-bg-start: #0c1929;
  --lo-bg-end: #0a1f12;
  --lo-border: #1e3a5f;
  --lo-accent: #60a5fa;
  --lo-check: #4ade80;
  --lo-text: #bfdbfe;
  --lo-link: #93c5fd;
  --bravo-bg-start: #0a1f12;
  --bravo-bg-end: #1a1c0a;
  --bravo-border: #166534;
  --bravo-accent: #4ade80;
  --bravo-text: #bbf7d0;
}

.learning-objectives .lo-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--lo-text);
  margin-bottom: 0.75rem;
  cursor: pointer;
  user-select: none;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font-family: inherit;
  line-height: inherit;
}

.learning-objectives .lo-header .lo-icon {
  font-size: 1.1rem;
}

.learning-objectives .lo-header .lo-arrow {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.learning-objectives.collapsed .lo-arrow {
  transform: rotate(-90deg);
}

.learning-objectives.collapsed .lo-list {
  display: none;
}

.learning-objectives .lo-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.learning-objectives .lo-list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.learning-objectives .lo-list li::before {
  content: "\2713";
  color: var(--lo-check);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.learning-objectives .lo-list a {
  color: var(--lo-link);
  text-decoration: none;
  transition: color 0.15s;
}

.learning-objectives .lo-list a:hover {
  text-decoration: underline;
}

.learning-objectives .lo-list .toc-h3 {
  padding-left: 1.25rem;
}

/* Bravo box at bottom */
.bravo-box {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--bravo-bg-start), var(--bravo-bg-end));
  border: 1px solid var(--bravo-border);
  border-radius: 12px;
  border-left: 4px solid var(--bravo-accent);
  text-align: center;
}

.bravo-box .bravo-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bravo-text);
  margin-bottom: 0.4rem;
}

.bravo-box .bravo-body {
  font-size: 0.82rem;
  color: var(--bravo-text);
  opacity: 0.85;
  line-height: 1.5;
}

.bravo-box .bravo-body a {
  color: var(--bravo-accent);
  text-decoration: none;
  font-weight: 600;
}

.bravo-box .bravo-body a:hover {
  text-decoration: underline;
}

/* Keep old class for backwards compat with cached pages */
.page-toc {
  margin: 0 0 2rem;
  padding: 1rem 1.25rem;
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.page-toc summary {
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  list-style: none;
}

.page-toc summary::before {
  content: "▸ ";
}

.page-toc[open] summary::before {
  content: "▾ ";
}

.page-toc ul {
  margin: 0.5rem 0 0 0;
  padding: 0 0 0 1rem;
  list-style: none;
}

.page-toc li {
  margin: 0.2rem 0;
}

.page-toc a {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.page-toc a:hover {
  color: var(--accent);
}

.page-toc .toc-h3 {
  padding-left: 1rem;
}

/* ========== BACK TO TOP ========== */
#back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

#back-to-top:hover {
  opacity: 0.85;
}

/* ========== BLOCKQUOTE TYPES ========== */
.chapter blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  border-radius: 0 6px 6px 0;
  font-size: 0.88rem;
}

.chapter blockquote p:first-child strong:first-child {
  display: inline-block;
  margin-bottom: 0.2rem;
}

/* Warning blockquotes (contain ATTENTION, SECURITE, IMPORTANT, CRITIQUE) */
.bq-warning {
  border-left-color: #f59e0b !important;
  background: rgba(245, 158, 11, 0.08) !important;
}

/* Success/tip blockquotes (contain Recommandation, Conseil, Astuce) */
.bq-tip {
  border-left-color: #22c55e !important;
  background: rgba(34, 197, 94, 0.06) !important;
}

/* ========== FORM PROGRESS ========== */
.form-progress {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.form-progress-step {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.3s;
}

.form-progress-step.done {
  background: var(--accent);
}

/* ========== ASK WIDGET ========== */
.ask-widget {
  max-width: 640px;
  margin: 1rem 0;
}

.ask-input-row {
  display: flex;
  gap: 0.5rem;
}

.ask-input-row input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.ask-input-row input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.ask-input-row input::placeholder {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.ask-input-row button {
  padding: 0.65rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.ask-input-row button:hover {
  opacity: 0.85;
}

.ask-input-row button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ask-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.4;
}

#ask-answer {
  margin-top: 1rem;
}

.ask-response {
  padding: 1rem 1.25rem;
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.ask-response p {
  margin-bottom: 0.5rem;
}

.ask-response .ask-pages {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.ask-response .ask-pages a {
  display: inline-block;
  margin: 0.2rem 0.3rem 0.2rem 0;
  padding: 0.25rem 0.6rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 6px;
  font-size: 0.78rem;
  text-decoration: none;
  transition: background 0.15s;
}

.ask-response .ask-pages a:hover {
  background: var(--accent);
  color: #fff;
}

.ask-response .ask-noanswer {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

.ask-response .ask-noanswer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.ask-response .ask-noanswer a:hover {
  text-decoration: underline;
}

.ask-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ask-loading .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========== PRINT ========== */
@media print {
  .sidebar, #topnav, .menu-toggle, .nav-actions, .chapter-nav, .theme-toggle, .github-badges, .edit-link, .giscus-wrapper, #back-to-top, .page-toc, .learning-objectives, .bravo-box { display: none !important; }
  main#content, .landing { max-width: 100%; padding: 0; }
  .chapter { page-break-inside: avoid; }
  .chapter pre { white-space: pre-wrap; }
}
