:root {
  --bg: #fafaf7;
  --text: #1f2933;
  --muted: #5f6b76;
  --primary: #1d5fa8;
  --primary-dark: #154780;
  --accent: #2e7d4f;
  --border: #d9dee3;
  --quote-bg: #eaf2fb;
  --quote-border: #7aaee0;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.65;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 18px 56px;
}

h1, h2, h3, h4 { line-height: 1.3; margin: 1.6em 0 0.5em; }
h1 { font-size: 1.6rem; margin-top: 0.8em; color: var(--primary-dark); }
h2 { font-size: 1.35rem; color: var(--primary-dark); border-bottom: 2px solid var(--border); padding-bottom: 0.2em; }
h3 { font-size: 1.15rem; }

p, ul, ol { margin: 0.8em 0; }
li { margin: 0.3em 0; }

a { color: var(--primary); }

img {
  max-width: 100%;
  height: auto;
}

/* Tableaux : défilement horizontal */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1em 0;
}
table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 0.95rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
th { background: #eef1f4; }

/* Citations : définitions, exemples */
blockquote {
  margin: 1em 0;
  padding: 10px 16px;
  background: var(--quote-bg);
  border-left: 5px solid var(--quote-border);
  border-radius: 0 8px 8px 0;
}
blockquote > :first-child { margin-top: 0; }
blockquote > :last-child { margin-bottom: 0; }

code {
  background: #eceff2;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}
pre {
  overflow-x: auto;
  background: #eceff2;
  padding: 12px;
  border-radius: 8px;
}
pre code { background: none; padding: 0; }

/* Barre de navigation */
.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: var(--primary-dark);
}
.topnav a {
  color: #fff;
  text-decoration: none;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.95rem;
}
.topnav a:hover, .topnav a:focus { background: rgba(255, 255, 255, 0.28); }

/* Correction des exercices */
details {
  margin: 1em 0;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: #f1f8f4;
  overflow: hidden;
}
summary {
  cursor: pointer;
  padding: 14px 16px;
  min-height: 48px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "▶ "; font-size: 0.8em; }
details[open] > summary::before { content: "▼ "; }
details > :not(summary) { margin-left: 16px; margin-right: 16px; }
details > summary + * { margin-top: 12px; }
details > :last-child { margin-bottom: 14px; }

/* Page d'accueil */
.module {
  margin: 1.2em 0;
  padding: 4px 16px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.module h2 { border: 0; font-size: 1.2rem; margin-top: 0.9em; }
.module.soon { opacity: 0.65; }
.chapter { padding: 8px 0; border-top: 1px solid var(--border); }
.chapter h3 { margin: 0.4em 0; font-size: 1.05rem; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 0.4em 0; }
.btn {
  display: inline-block;
  padding: 12px 22px;
  min-height: 48px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  border-radius: 10px;
}
.btn-alt { background: var(--accent); }
.btn:hover, .btn:focus { filter: brightness(0.9); }
.badge {
  display: inline-block;
  padding: 4px 12px;
  background: #e3e7eb;
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.9rem;
}
