/* ========================================
   FORMATION SÉCURITÉ - DESIGN SYSTEM
   Direction : éditorial juridique sobre
   Typo : Newsreader (serif display) + IBM Plex Sans + IBM Plex Mono
   ======================================== */

:root {
  /* === Couleurs principales (bleu nuit officiel + accent sépia) === */
  --primary: #1d3557;
  --primary-light: #457b9d;
  --primary-dark: #0f1e30;
  --accent: #b07a4d;
  --accent-dark: #8a5a36;

  /* === Sémantique (sobres, désaturées) === */
  --success: #2d6a4f;
  --danger:  #b22c30;
  --warning: #b45309;
  --info:    #2c5e8b;

  /* === Neutres (papier crème / encre) === */
  --bg: #faf8f3;
  --bg-card: #ffffff;
  --bg-soft: #f3efe6;
  --bg-dark: #0f1117;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #e6e0d3;
  --border-strong: #c9c1ad;

  /* === Typographie === */
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --measure: 70ch;

  /* === Spacing / radius === */
  --radius: 8px;
  --radius-lg: 14px;
  --radius-sm: 4px;
  --shadow:    0 1px 2px rgba(20, 18, 12, 0.04), 0 1px 3px rgba(20, 18, 12, 0.06);
  --shadow-lg: 0 4px 8px rgba(20, 18, 12, 0.06), 0 12px 28px rgba(20, 18, 12, 0.08);

  color-scheme: light;
}

/* Dark mode - encre profonde, papier inversé */
body.dark {
  --bg: #0e1015;
  --bg-card: #161922;
  --bg-soft: #1c202b;
  --text: #e8e6e0;
  --text-muted: #8e8d8a;
  --border: #262a35;
  --border-strong: #3a3f4d;
  --primary: #93c5fd;
  --primary-light: #bfdbfe;
  --primary-dark: #e0ecff;
  --accent: #d4a373;
  --accent-dark: #b58a5f;
  --success: #5fb988;
  --danger:  #e5777a;
  --warning: #d4a155;
  --info:    #79a8d4;
  color-scheme: dark;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-feature-settings: 'kern', 'liga', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background 0.25s ease, color 0.25s ease;
}

/* Sélection de texte sobre */
::selection {
  background: var(--primary);
  color: #fff;
}
body.dark ::selection {
  background: var(--primary);
  color: var(--bg);
}

/* Focus visible accessible (clavier) */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Headings : serif display */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h5, h6 {
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0;
}

/* ========================================
   HEADER & NAVIGATION
   ======================================== */
.navbar {
  background: var(--bg-card);
  color: var(--text);
  padding: 0.85rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(8px);
}
body.dark .navbar {
  background: rgba(22, 25, 34, 0.92);
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
}

.logo-icon {
  font-size: 1.5rem;
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

/* ========================================
   CONTAINER & LAYOUT
   ======================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.hero {
  text-align: left;
  padding: 3.5rem 2.5rem 3rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 2rem auto;
  max-width: 1200px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--primary);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  margin-bottom: 0.85rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  max-width: 24ch;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0;
  line-height: 1.55;
}

.hero-stats {
  display: flex;
  gap: 2rem;
  margin-top: 2rem;
  flex-wrap: wrap;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.stat {
  background: transparent;
  padding: 0;
  border: none;
  border-radius: 0;
  backdrop-filter: none;
  min-width: 0;
}

.stat-number {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 600;
  display: block;
  color: var(--primary);
  letter-spacing: -0.015em;
  line-height: 1;
}
body.dark .stat-number { color: var(--primary-light); }

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.4rem;
  display: block;
}

/* ========================================
   CARDS / MODULES GRID
   ======================================== */
.section-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  margin: 3rem 0 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 2px;
  background: var(--accent);
  vertical-align: middle;
  margin-right: 0.85rem;
  margin-bottom: 0.3em;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.module-card {
  background: var(--bg-card);
  padding: 1.4rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: none;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary-light);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.module-card:hover {
  border-color: var(--border-strong);
  border-left-color: var(--primary);
  background: var(--bg-card);
  transform: translateY(-1px);
}

.module-card.danger { border-left-color: var(--danger); }
.module-card.warning { border-left-color: var(--warning); }
.module-card.success { border-left-color: var(--success); }
.module-card.info { border-left-color: var(--info); }
.module-card.accent { border-left-color: var(--accent); }

.module-icon {
  font-size: 1.85rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.module-card h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
  color: var(--text);
}

body.dark .module-card h3 {
  color: var(--text);
}

.module-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  flex-grow: 1;
}

.module-tag {
  display: inline-block;
  background: var(--bg-soft);
  color: var(--text-muted);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1rem;
  align-self: flex-start;
}

/* ========================================
   CONTENT PAGES
   ======================================== */
.page-header {
  background: transparent;
  color: var(--text);
  padding: 2rem 0 1.5rem;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  margin-bottom: 2.5rem;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.page-header > p {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: var(--measure);
  margin: 0;
}

.page-header .breadcrumb {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-header .breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.page-header .breadcrumb a:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.content-section {
  background: var(--bg-card);
  padding: 2rem 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  margin-bottom: 1.5rem;
}

.content-section h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  display: block;
}

body.dark .content-section h2 {
  color: var(--text);
}

.content-section h3 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 1.75rem 0 0.65rem;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

body.dark .content-section h3 {
  color: var(--text);
}

.content-section h4 {
  font-family: var(--font-body);
  color: var(--primary);
  margin: 1.5rem 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

body.dark .content-section h4 {
  color: var(--primary-light);
}

.content-section h5 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
}

.content-section p {
  margin-bottom: 1rem;
  max-width: var(--measure);
}

.content-section ul, .content-section ol {
  margin: 0.85rem 0 1rem 1.5rem;
  max-width: var(--measure);
}

.content-section li {
  margin-bottom: 0.45rem;
}

.content-section li::marker {
  color: var(--text-muted);
}

.content-section strong {
  color: var(--text);
  font-weight: 600;
}

.content-section a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color 0.15s;
}
body.dark .content-section a { color: var(--primary-light); }
.content-section a:hover { color: var(--accent-dark); }
body.dark .content-section a:hover { color: var(--accent); }

body.dark .content-section strong {
  color: var(--text);
}

/* ========================================
   INFOBOX / ALERTS
   ======================================== */
.infobox {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-left: 3px solid;
  position: relative;
  background: var(--bg-soft);
  color: var(--text);
}

.infobox > *:last-child { margin-bottom: 0; }

.infobox-title {
  font-family: var(--font-body);
  font-weight: 700;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.infobox.tip     { border-left-color: var(--success); }
.infobox.warning { border-left-color: var(--warning); }
.infobox.danger  { border-left-color: var(--danger); }
.infobox.info    { border-left-color: var(--info); }
.infobox.memo    { border-left-color: var(--accent-dark); background: #f5edd9; }
body.dark .infobox.memo { background: rgba(212, 163, 115, 0.08); }

.infobox.tip     .infobox-title { color: var(--success); }
.infobox.warning .infobox-title { color: var(--warning); }
.infobox.danger  .infobox-title { color: var(--danger); }
.infobox.info    .infobox-title { color: var(--info); }
.infobox.memo    .infobox-title { color: var(--accent-dark); }
body.dark .infobox.memo .infobox-title { color: var(--accent); }

/* ========================================
   TABLEAUX
   ======================================== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  font-size: 0.94rem;
}

table th {
  background: var(--bg-soft);
  color: var(--text);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table tr:hover td {
  background: var(--bg-soft);
}

table tr:last-child td {
  border-bottom: none;
}

table code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

/* ========================================
   MEMO CARDS (mnémoniques)
   ======================================== */
.memo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.memo-card {
  background: var(--bg-soft);
  padding: 1.25rem 1.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-dark);
  color: var(--text);
}

body.dark .memo-card {
  background: rgba(212, 163, 115, 0.06);
  color: var(--text);
  border-left-color: var(--accent);
}

.memo-card .memo-keyword {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0.5rem;
  color: var(--accent-dark);
}

body.dark .memo-card .memo-keyword {
  color: var(--accent);
}

.memo-card ul {
  list-style: none;
  margin: 0.5rem 0 0 0 !important;
}

.memo-card li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.94rem;
}

.memo-card li:last-child {
  border-bottom: none;
}

.memo-card .letter {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-dark);
  margin-right: 0.5rem;
  font-size: 0.95rem;
  display: inline-block;
  min-width: 1.4em;
}

body.dark .memo-card .letter {
  color: var(--accent);
}

/* ========================================
   QCM
   ======================================== */
.qcm-container {
  background: var(--bg-card);
  padding: 1.75rem 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  margin: 1.5rem 0;
}

.qcm-question {
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.qcm-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.qcm-option {
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: var(--text);
}

.qcm-option:hover {
  border-color: var(--primary);
  background: var(--bg-soft);
}

.qcm-option.correct {
  border-color: var(--success);
  background: rgba(45, 106, 79, 0.06);
}

.qcm-option.incorrect {
  border-color: var(--danger);
  background: rgba(178, 44, 48, 0.06);
}

.qcm-feedback {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  display: none;
}

.qcm-feedback.show {
  display: block;
}

.qcm-feedback.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border-left: 4px solid var(--success);
}

.qcm-feedback.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-left: 4px solid var(--danger);
}

/* ========================================
   BOUTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}

body.dark .btn {
  color: var(--bg);
}

.btn:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
body.dark .btn:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-outline:hover {
  background: var(--bg-soft);
  border-color: var(--text-muted);
  color: var(--text);
}

body.dark .btn-outline {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ========================================
   FOOTER
   ======================================== */
footer {
  background: transparent;
  color: var(--text-muted);
  text-align: center;
  padding: 2.5rem 1rem;
  margin-top: 4rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
}

footer p {
  margin: 0;
}

footer a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
footer a:hover { color: var(--primary); }
body.dark footer a:hover { color: var(--primary-light); }

/* ========================================
   ARTICLE / LEGAL BOX
   ======================================== */
.article-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 1.1rem 1.4rem;
  border-radius: var(--radius);
  margin: 1.25rem 0;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
  position: relative;
}

body.dark .article-box {
  background: rgba(147, 197, 253, 0.05);
  border-left-color: var(--primary-light);
}

/* Plus d'icône ::before flottante - on garde sobre */
.article-box::before { content: none; }

.article-box .article-ref {
  font-family: var(--font-body);
  font-weight: 700;
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
}
body.dark .article-box .article-ref { color: var(--primary-light); }

/* ========================================
   PLAIN LANGUAGE EXPLANATION
   ======================================== */
.plain-language {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  padding: 1.1rem 1.4rem;
  border-radius: var(--radius);
  margin: 0.85rem 0 1.5rem 0;
  position: relative;
  color: var(--text);
}

body.dark .plain-language {
  background: rgba(95, 185, 136, 0.05);
}

.plain-language::before { content: none; }

.plain-language .plain-title {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--success);
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.plain-language .example {
  background: var(--bg-soft);
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  font-style: normal;
  border-left: 2px solid var(--success);
  font-size: 0.94rem;
}

body.dark .plain-language .example {
  background: rgba(255,255,255,0.03);
}

/* ========================================
   PROGRESS BAR
   ======================================== */
.progress-bar {
  background: var(--border);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-fill {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  height: 100%;
  transition: width 0.3s ease;
}

/* ========================================
   FLASHCARDS
   ======================================== */
.flashcards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.flashcard {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 180px;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow);
  transition: transform 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-top: 4px solid var(--accent);
}

.flashcard:hover {
  transform: scale(1.02);
}

.flashcard-question {
  font-weight: 600;
  font-size: 1.1rem;
}

.flashcard-answer {
  display: none;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.flashcard.flipped .flashcard-question {
  display: none;
}

.flashcard.flipped .flashcard-answer {
  display: block;
  color: var(--text);
}

.flashcard.flipped {
  background: var(--primary);
  color: white;
  border-color: var(--accent);
}

.flashcard.flipped .flashcard-answer {
  color: white;
}

/* ========================================
   RESPONSIVE - Multi-breakpoints
   ======================================== */

/* Base - Touch-friendly targets minimum 44px */
a, button, .qcm-option, .filter-btn, .module-card {
  min-height: 44px;
}

/* Ensure images never overflow */
img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* Long words break on mobile */
.content-section, .module-card, .qcm-container, .article-box, .plain-language, .infobox, .memo-card, td, th {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* ============= LAPTOP (≤ 1200px) ============= */
@media (max-width: 1200px) {
  .container { max-width: 100%; padding: 1.5rem; }
  .hero { margin: 1.5rem 1rem; }
  .modules-grid { gap: 1.25rem; }
}

/* ============= TABLET (≤ 1024px) ============= */
@media (max-width: 1024px) {
  .nav-container { padding: 0 0.5rem; }
  .nav-links { gap: 0.75rem; }
  .nav-links a { padding: 0.4rem 0.75rem; font-size: 0.95rem; }
  .hero h1 { font-size: 2rem; }
  .hero { padding: 3rem 1.5rem; }
  .modules-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .section-title { font-size: 1.7rem; }
  .page-header h1 { font-size: 1.9rem; }
  .content-section h2 { font-size: 1.6rem; }
  .flashcard-deck { max-width: 100%; }
}

/* ============= MOBILE LARGE (≤ 768px) ============= */
@media (max-width: 768px) {
  /* === NAVIGATION MOBILE : header compact + drawer plein écran === */
  .navbar {
    padding: 0.55rem 0.85rem;
  }
  .nav-container {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    justify-content: space-between;
    flex-wrap: nowrap;
  }
  .logo {
    font-size: 1.05rem;
    justify-content: flex-start;
    flex: 1 1 auto;
    min-width: 0;
  }
  .logo-icon { font-size: 1.3rem; }

  .nav-toggle { display: inline-flex !important; align-items: center; justify-content: center; }

  /* Theme toggle reste visible à droite, pas en absolu */
  .theme-toggle {
    position: static;
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    flex-shrink: 0;
  }

  /* Search trigger conservé entre logo et theme-toggle */
  .search-trigger {
    flex-shrink: 0;
  }

  /* Nav-links transformé en drawer plein écran */
  .nav-links {
    position: fixed;
    top: var(--navbar-h, 56px);
    left: 0;
    right: 0;
    bottom: 0;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 0.5rem 1rem 2rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.2s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 90;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
  }
  .navbar.is-open .nav-links {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav-links li {
    width: 100%;
  }
  .nav-links a {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem 0.85rem;
    font-size: 1.05rem;
    font-weight: 500;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
  }
  .nav-links a:hover,
  .nav-links a:active {
    background: var(--bg-soft);
    color: var(--primary);
  }
  body.dark .nav-links a:hover { color: var(--primary-light); }
  .nav-links li:last-child a { border-bottom: none; }

  /* HERO */
  .hero {
    padding: 2rem 1rem;
    margin: 1rem 0.5rem;
    border-radius: var(--radius);
  }
  .hero h1 { font-size: 1.6rem; margin-bottom: 0.75rem; }
  .hero p { font-size: 0.95rem; }
  .hero-stats { gap: 0.75rem; margin-top: 1.5rem; }
  .stat { padding: 0.75rem 1rem; flex: 1 1 calc(50% - 0.5rem); min-width: 0; }
  .stat-number { font-size: 1.5rem; }
  .stat-label { font-size: 0.8rem; }

  /* CONTAINER & LAYOUT */
  .container { padding: 1rem 0.75rem; }
  .section-title {
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    border-left-width: 4px;
    padding-left: 0.75rem;
  }
  .modules-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .module-card {
    padding: 1.25rem;
  }
  .module-card h3 { font-size: 1.1rem; }
  .module-card p { font-size: 0.9rem; }
  .module-icon { font-size: 2rem; }

  /* PAGE HEADER */
  .page-header {
    padding: 1.5rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
  }
  .page-header h1 { font-size: 1.4rem; line-height: 1.3; }
  .page-header .breadcrumb { font-size: 0.85rem; }

  /* CONTENT */
  .content-section {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
  }
  .content-section h2 {
    font-size: 1.3rem;
    line-height: 1.3;
  }
  .content-section h3 { font-size: 1.1rem; }
  .content-section h4 { font-size: 1rem; }
  .content-section p, .content-section li { font-size: 0.95rem; }
  .content-section ul, .content-section ol { margin-left: 1.25rem; }

  /* INFOBOXES */
  .infobox, .article-box, .plain-language {
    padding: 1rem;
    font-size: 0.95rem;
  }
  .infobox-title { font-size: 1rem; }
  .plain-language .example {
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
  }

  /* TABLES - horizontal scroll forcé */
  .table-wrapper {
    margin: 1rem -0.5rem;
    border-radius: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { font-size: 0.85rem; min-width: 100%; }
  table th, table td {
    padding: 0.6rem 0.5rem;
    white-space: normal;
  }
  table th { font-size: 0.8rem; }

  /* MEMO CARDS */
  .memo-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .memo-card { padding: 1rem; }
  .memo-card .memo-keyword { font-size: 1.4rem; letter-spacing: 1px; }

  /* QCM/QCU */
  .qcm-container { padding: 1rem; }
  .qcm-question { font-size: 1rem; line-height: 1.4; }
  .qcm-option {
    padding: 0.85rem 0.85rem;
    font-size: 0.95rem;
    min-height: 48px;
  }
  .qcm-feedback { padding: 0.85rem; font-size: 0.9rem; }
  .qcu-section-header {
    font-size: 1.05rem !important;
    padding: 1rem !important;
  }
  .qcu-info { font-size: 0.9rem; padding: 0.85rem 1rem; }

  /* BUTTONS */
  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* FLASHCARDS PAGE */
  .deck-card { min-height: 280px !important; }
  .deck-face { padding: 2rem 1.25rem !important; }
  .card-question { font-size: 1.15rem !important; }
  .card-answer { font-size: 0.95rem !important; line-height: 1.6 !important; }
  .deck-controls { gap: 0.5rem; }
  .deck-controls .btn { font-size: 0.85rem; padding: 0.6rem 1rem; }
  .category-filter { gap: 0.4rem; padding: 0 0.5rem; }
  .filter-btn {
    font-size: 0.8rem;
    padding: 0.45rem 0.85rem;
    min-height: 38px;
  }

  /* PROGRESS BAR */
  .progress-bar { height: 10px; }

  /* FOOTER */
  footer { padding: 1.5rem 1rem; font-size: 0.9rem; }
}

/* ============= MOBILE SMALL (≤ 480px) ============= */
@media (max-width: 480px) {
  /* NAVIGATION - drawer hérite du 768px, on ne ré-écrase pas */
  .navbar { padding: 0.5rem 0.75rem; }
  .logo span:not(.logo-icon) {
    font-size: 0.95rem;
  }
  .theme-toggle {
    padding: 0.3rem 0.55rem;
    font-size: 0.9rem;
  }

  /* HERO */
  .hero {
    padding: 1.5rem 0.85rem;
    margin: 0.75rem 0.25rem;
  }
  .hero h1 { font-size: 1.35rem; }
  .hero p { font-size: 0.88rem; }
  .hero-stats {
    flex-direction: column;
    gap: 0.5rem;
  }
  .stat { flex: 1 1 100%; padding: 0.6rem 1rem; }
  .stat-number { font-size: 1.3rem; }

  /* CONTAINER */
  .container { padding: 0.75rem 0.5rem; }

  /* SECTION TITLES */
  .section-title {
    font-size: 1.2rem;
    margin: 1.5rem 0 0.75rem;
  }

  /* CARDS */
  .module-card { padding: 1rem; }
  .module-card h3 { font-size: 1rem; }
  .module-card p { font-size: 0.85rem; }
  .module-icon { font-size: 1.75rem; }

  /* PAGE HEADER */
  .page-header {
    padding: 1.25rem 0.85rem;
    margin-bottom: 1rem;
  }
  .page-header h1 { font-size: 1.2rem; }
  .page-header p { font-size: 0.85rem; }

  /* CONTENT */
  .content-section { padding: 0.85rem 0.75rem; }
  .content-section h2 { font-size: 1.15rem; }
  .content-section h3 { font-size: 1rem; }
  .content-section p, .content-section li { font-size: 0.9rem; }
  .content-section ul, .content-section ol { margin-left: 1rem; }

  /* INFOBOXES */
  .infobox, .article-box, .plain-language {
    padding: 0.85rem;
    margin: 1rem 0;
    font-size: 0.9rem;
  }
  .article-box::before, .plain-language::before { font-size: 1.25rem; }

  /* TABLES - encore plus compact */
  table { font-size: 0.8rem; }
  table th, table td {
    padding: 0.5rem 0.4rem;
  }
  table th { font-size: 0.75rem; }

  /* MEMO CARDS */
  .memo-card { padding: 0.85rem; }
  .memo-card .memo-keyword { font-size: 1.25rem; }
  .memo-card .letter { font-size: 1rem; }

  /* QCM/QCU */
  .qcm-container { padding: 0.85rem; }
  .qcm-question { font-size: 0.95rem; }
  .qcm-option {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
  .qcu-section-header {
    font-size: 0.95rem !important;
    padding: 0.85rem !important;
  }

  /* BUTTONS */
  .btn {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    width: 100%;
    margin: 0.25rem 0;
  }
  /* Sauf btn dans deck-controls (boutons côte à côte) */
  .deck-controls .btn {
    width: auto;
    flex: 1 1 auto;
  }

  /* FLASHCARDS */
  .flashcard-deck { margin: 1rem auto; }
  .deck-card { min-height: 240px !important; }
  .deck-face { padding: 1.5rem 1rem !important; }
  .card-category { font-size: 0.7rem !important; padding: 0.2rem 0.6rem !important; }
  .card-number { font-size: 0.8rem !important; }
  .card-question { font-size: 1rem !important; }
  .card-answer { font-size: 0.88rem !important; }
  .filter-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
  }

  /* FOOTER */
  footer { padding: 1.25rem 0.85rem; font-size: 0.85rem; }

  /* BREADCRUMB */
  .breadcrumb { font-size: 0.8rem; }
}

/* ============= VERY SMALL (≤ 360px) ============= */
@media (max-width: 360px) {
  .hero h1 { font-size: 1.2rem; }
  .module-card h3 { font-size: 0.95rem; }
  .memo-card .memo-keyword { font-size: 1.1rem; }
  table { font-size: 0.75rem; }
}

/* ============= LANDSCAPE MOBILE ============= */
@media (max-height: 500px) and (orientation: landscape) {
  .hero { padding: 1.5rem 1rem; }
  .hero h1 { font-size: 1.4rem; }
  .hero-stats { margin-top: 1rem; }
  .deck-card { min-height: 200px !important; }
  .page-header { padding: 1.25rem 1rem; }
}

/* ============= TOUCH DEVICES - Disable hover effects ============= */
@media (hover: none) and (pointer: coarse) {
  .module-card:hover { transform: none; }
  .flashcard:hover { transform: none; }
  .qcm-option:hover {
    border-color: var(--border);
    background: var(--bg);
  }
  .btn:hover { transform: none; }
}

/* ============= REDUCED MOTION (accessibilité) ============= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .deck-card { transition: none !important; }
}

/* ============= HIGH RESOLUTION SCREENS ============= */
@media (min-width: 1600px) {
  .container, .hero { max-width: 1400px; }
  .modules-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  body { font-size: 17px; }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.module-card, .content-section, .hero {
  animation: fadeIn 0.35s ease-out forwards;
}

/* ========================================
   SEARCH - Style premium intégré
   ======================================== */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.75rem 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  margin-right: 0.5rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  min-height: 36px;
  font-family: inherit;
  min-width: 200px;
}

.search-trigger:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text);
}

.search-trigger-icon {
  font-size: 1rem;
  line-height: 1;
}

.search-trigger-label {
  flex: 1;
  text-align: left;
  white-space: nowrap;
}

.search-trigger-kbd {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ========== DIAGRAMME DUALITÉ JURIDICTIONNELLE (sobre) ========== */
.dj-diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem 1.25rem;
  margin: 1.5rem 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

body.dark .dj-diagram {
  background: rgba(255,255,255,0.02);
}

.dj-title {
  text-align: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.dj-title-icon { font-size: 1.5rem; }

.dj-title > span:nth-child(2) {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.8px;
  color: var(--text);
}

.dj-title-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

.dj-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1rem;
  margin-bottom: 0.6rem;
  align-items: stretch;
}

.dj-headers { margin-bottom: 1rem; }

.dj-badge {
  text-align: center;
  padding: 0.7rem 0.85rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.6px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.dj-badge-admin { border-left: 3px solid var(--primary); }
.dj-badge-jud   { border-left: 3px solid var(--accent-dark); }

.dj-sub-headers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.dj-sub-header {
  text-align: center;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  color: var(--text);
  background: transparent;
  border: 1px dashed var(--border);
}

.dj-degree-label {
  text-align: center;
  margin: 0.8rem 0 0.6rem;
}

.dj-degree-label span {
  display: inline-block;
  padding: 0.3rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.dj-arrows {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1rem;
  margin: 0.2rem 0;
}

.dj-arrow {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  opacity: 0.5;
  line-height: 1;
}

.dj-col-admin,
.dj-col-jud {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.dj-sub-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.dj-sub-col {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.dj-box {
  background: var(--bg);
  color: var(--text);
  padding: 0.75rem 0.85rem;
  border-radius: 6px;
  font-size: 0.92rem;
  line-height: 1.4;
  text-align: center;
  border: 1px solid var(--border);
  transition: transform 0.12s, box-shadow 0.12s;
}

.dj-box:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.dj-box-admin { border-left: 3px solid var(--primary); }
.dj-box-civil { border-left: 3px solid var(--accent-dark); }
.dj-box-penal { border-left: 3px solid var(--danger); }

.dj-box-appel {
  border-left: 3px solid var(--primary-light);
  font-weight: 600;
  padding: 0.85rem;
  font-size: 0.95rem;
}

.dj-box-sommet-admin,
.dj-box-sommet-jud {
  border: 1px solid var(--border);
  border-top: 3px solid;
  padding: 1rem 0.85rem;
  font-size: 1.05rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.dj-box-sommet-admin { border-top-color: var(--success); }
.dj-box-sommet-jud   { border-top-color: var(--danger); }

.dj-crown {
  font-size: 1.1rem;
  opacity: 0.85;
}

.dj-box-sub {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-muted);
  font-style: italic;
}

.dj-special {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border);
}

.dj-special .dj-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.85rem;
}

.dj-special-icon {
  font-size: 1.15rem;
  opacity: 0.85;
}

.dj-box-conflits { border-top: 3px solid var(--accent-dark); }
.dj-box-cjue     { border-top: 3px solid var(--primary); }

/* Responsive : stack vertically on mobile */
@media (max-width: 768px) {
  .dj-row { grid-template-columns: 1fr; gap: 0.5rem; }
  .dj-arrows { display: none; }
  .dj-sub-cols { grid-template-columns: 1fr; }
  .dj-special { grid-template-columns: 1fr; }
  .dj-box { font-size: 0.8rem; }
}

/* ========== MODAL ========== */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 1rem 2rem;
  animation: searchFadeIn 0.18s ease-out;
}

@keyframes searchFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes searchPanelIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.search-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.search-panel {
  position: relative;
  background: var(--bg-card);
  color: var(--text);
  width: 100%;
  max-width: 760px;
  max-height: 78vh;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: searchPanelIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========== INPUT ========== */
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.search-icon {
  font-size: 1.25rem;
  opacity: 0.6;
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.05rem;
  background: transparent;
  color: var(--text);
  padding: 0.4rem 0;
  font-family: inherit;
}

#search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.search-close {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-family: ui-monospace, 'SF Mono', Monaco, Consolas, monospace;
  font-weight: 600;
  transition: all 0.15s;
}

.search-close:hover {
  background: var(--border);
  color: var(--text);
}

/* ========== RESULTS ========== */
.search-results {
  overflow-y: auto;
  flex: 1;
  background: var(--bg);
  scroll-behavior: smooth;
}

.search-results::-webkit-scrollbar { width: 8px; }
.search-results::-webkit-scrollbar-track { background: transparent; }
.search-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.search-summary {
  padding: 0.75rem 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.search-page-result {
  background: var(--bg-card);
  margin: 0.85rem 0.85rem 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.search-page-result:last-child {
  margin-bottom: 0.85rem;
}

.search-page-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1.1rem;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.2px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

body.dark .search-page-header {
  color: var(--primary-light);
  background: var(--bg-soft);
}

.search-page-icon {
  font-size: 1.05rem;
  opacity: 0.85;
  flex-shrink: 0;
}

.search-page-title-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-page-count {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.search-item {
  display: block;
  padding: 0.85rem 1.1rem 0.85rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: background 0.12s, border-left-color 0.12s, padding-left 0.12s;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover,
.search-item.is-selected {
  background: var(--bg);
  border-left-color: var(--accent);
  padding-left: 1.4rem;
}

body.dark .search-item:hover,
body.dark .search-item.is-selected {
  background: rgba(59, 130, 246, 0.06);
}

.search-item.is-selected {
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.18);
}

.search-item-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: var(--text);
  line-height: 1.4;
}

.search-item-arrow {
  margin-left: auto;
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity 0.12s, transform 0.12s;
  font-size: 0.85rem;
  color: var(--accent);
  background: rgba(245, 158, 11, 0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  font-family: ui-monospace, 'SF Mono', Monaco, Consolas, monospace;
}

.search-item:hover .search-item-arrow,
.search-item.is-selected .search-item-arrow {
  opacity: 1;
  transform: translateX(0);
}

.search-item-snippet {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Flash visuel sur la cible quand on arrive via recherche */
@keyframes searchTargetFlash {
  0% { background-color: rgba(245, 158, 11, 0.35); }
  100% { background-color: transparent; }
}
.search-target-flash {
  animation: searchTargetFlash 1.6s ease-out;
  border-radius: 8px;
}

.search-results mark {
  background: rgba(245, 158, 11, 0.25);
  color: inherit;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 700;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

body.dark .search-results mark {
  background: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.search-item-head mark {
  background: rgba(59, 130, 246, 0.22);
}

body.dark .search-item-head mark {
  background: rgba(96, 165, 250, 0.28);
  color: #93c5fd;
}

/* ========== EMPTY / INITIAL STATES ========== */
.search-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

.search-empty::before {
  content: "🔎";
  display: block;
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.search-initial {
  padding: 1.5rem 1.25rem;
}

.search-initial-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.search-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.search-example {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
  font-family: inherit;
}

.search-example:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.search-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.search-footer kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: ui-monospace, 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 1px 0 var(--border);
  margin-right: 0.3rem;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .search-trigger {
    padding: 0.4rem 0.55rem;
    font-size: 0;
  }
  .search-trigger-icon { font-size: 1.15rem; }
  .search-trigger-label,
  .search-trigger-kbd { display: none; }

  .search-modal { padding: 0; }
  .search-panel {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .search-input-wrap { padding: 0.85rem 1rem; }
  #search-input { font-size: 1rem; }
  .search-page-result { margin: 0.5rem; }
  .search-page-title { font-size: 0.95rem; padding: 0.75rem 0.85rem; }
  .search-item { padding: 0.7rem 0.85rem 0.7rem 2.2rem; }
  .search-item::before { left: 0.95rem; }
  .search-footer { font-size: 0.7rem; gap: 0.85rem; }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-soft);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   TABLES RESPONSIVES (mobile : cartes empilées)
   ============================================================ */
@media (max-width: 640px) {
  /* Le wrapper n'a plus besoin de scroll/border : chaque ligne est sa propre carte */
  .table-wrapper:has(.table-responsive) {
    overflow: visible;
    border: none;
    background: transparent;
    margin: 1rem 0;
  }

  .table-responsive,
  .table-responsive tbody,
  .table-responsive tr,
  .table-responsive td {
    display: block;
    width: 100%;
  }

  /* Cache la ligne d'en-têtes (les <th>) : les labels sont injectés sur chaque td */
  .table-responsive .table-responsive-headrow {
    display: none;
  }

  .table-responsive tr {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    padding: 0.85rem 1rem;
    box-shadow: none;
  }

  .table-responsive tr:hover td {
    background: transparent;
  }

  .table-responsive td {
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.94rem;
    line-height: 1.5;
    white-space: normal;
  }

  .table-responsive td:last-child {
    border-bottom: none;
  }

  .table-responsive td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
  }

  /* Première cellule de chaque carte : look "titre" */
  .table-responsive td:first-child {
    padding-top: 0;
  }
  .table-responsive td:first-child:not([data-label]),
  .table-responsive td:first-child strong {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
  }
}

/* ============================================================
   MENU MOBILE (hamburger + drawer)
   ============================================================ */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  padding: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 40px;
  height: 40px;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.nav-toggle:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  position: absolute;
  left: 50%;
  margin-left: -9px;
  transition: transform 0.22s ease, opacity 0.18s ease, top 0.22s ease;
}
.nav-toggle span:nth-child(1) { top: 13px; }
.nav-toggle span:nth-child(2) { top: 19px; }
.nav-toggle span:nth-child(3) { top: 25px; }

.navbar.is-open .nav-toggle span:nth-child(1) {
  top: 19px;
  transform: rotate(45deg);
}
.navbar.is-open .nav-toggle span:nth-child(2) { opacity: 0; }
.navbar.is-open .nav-toggle span:nth-child(3) {
  top: 19px;
  transform: rotate(-45deg);
}

/* ============================================================
   NOUVELLES CLASSES UTILITAIRES (refonte responsive)
   ============================================================ */

/* === Grille d'images d'armes / d'illustrations === */
.weapon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.75rem;
}

.weapon-figure {
  margin: 0;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.weapon-figure:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.weapon-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--bg-soft);
}

.weapon-figure figcaption {
  font-size: 0.85rem;
  color: var(--text);
  padding: 0.5rem 0.6rem 0.65rem;
  font-weight: 600;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

/* === Sous-titre de catégorie d'armes (h5 coloré) === */
.weapon-category-title {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.weapon-category-title::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.85;
}
.weapon-category-title.cat-a { color: var(--danger); }
.weapon-category-title.cat-b { color: var(--warning); }
.weapon-category-title.cat-c { color: var(--accent-dark); }
.weapon-category-title.cat-d { color: var(--success); }
body.dark .weapon-category-title.cat-c { color: var(--accent); }

/* === Liste hiérarchique (hiérarchie des normes) === */
.hierarchy-list {
  font-size: 1rem;
  line-height: 1.7;
  counter-reset: hierarchy;
  list-style: none !important;
  margin-left: 0 !important;
  padding-left: 0;
}
.hierarchy-list li {
  counter-increment: hierarchy;
  position: relative;
  padding: 0.6rem 0.85rem 0.6rem 3rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  margin-bottom: 0.45rem !important;
}
.hierarchy-list li::before {
  content: counter(hierarchy);
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  width: 1.5rem;
  text-align: right;
}
body.dark .hierarchy-list li::before { color: var(--primary-light); }
.hierarchy-list li:nth-child(1) { border-left-color: #b22c30; }
.hierarchy-list li:nth-child(2) { border-left-color: var(--primary); }
.hierarchy-list li:nth-child(3) { border-left-color: var(--primary-light); }
.hierarchy-list li:nth-child(4) { border-left-color: var(--info); }
.hierarchy-list li:nth-child(n+5) { border-left-color: var(--text-muted); }

/* === Stat grid (carrés type Stripe docs) === */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.stat-cell {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}
.stat-cell-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.015em;
  display: block;
  line-height: 1.1;
}
.stat-cell-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.3rem;
  display: block;
}

/* === Kicker (chapeau de section type "Section 3 · Article L.611-1") === */
.kicker {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.4rem;
}

/* === Quote / citation === */
blockquote {
  border-left: 3px solid var(--border-strong);
  padding: 0.5rem 0 0.5rem 1.25rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
}

/* === Code inline (mono) === */
code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ============================================================
   RESPONSIVE AMÉLIORÉ - ≤480px et ≤360px
   ============================================================ */
@media (max-width: 768px) {
  .navbar {
    padding: 0.65rem 1rem;
  }
  .nav-container { gap: 0.4rem; }

  .hero { padding: 2rem 1.25rem 1.75rem; margin: 1rem 0.5rem; }
  .hero h1 { font-size: clamp(1.6rem, 6vw, 2rem); }
  .hero p { font-size: 0.98rem; }
  .hero-stats { gap: 1.25rem; }
  .stat-number { font-size: 1.5rem; }

  .content-section { padding: 1.25rem 1.1rem; }
  .content-section h2 { font-size: 1.35rem; }

  .weapon-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.65rem;
  }
}

@media (max-width: 480px) {
  /* Navbar : règles drawer héritées du bloc 768px - on touche rien ici */
  .container { padding: 0.75rem 0.85rem; }

  .hero { padding: 1.5rem 1.1rem 1.4rem; margin: 0.75rem 0; border-radius: var(--radius-sm); }
  .hero h1 { font-size: 1.45rem; max-width: 100%; }
  .hero p { font-size: 0.9rem; }
  .hero-stats { gap: 1rem; padding-top: 1rem; margin-top: 1.25rem; }
  .stat-number { font-size: 1.3rem; }
  .stat-label { font-size: 0.7rem; }

  .page-header { padding: 1.25rem 0 1rem; margin-bottom: 1.5rem; }
  .page-header h1 { font-size: 1.4rem; }

  .content-section {
    padding: 1rem 0.85rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
  }
  .content-section h2 { font-size: 1.2rem; }
  .content-section h3 { font-size: 1.05rem; }
  .content-section p, .content-section li { font-size: 0.94rem; }

  .article-box, .plain-language, .infobox {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
  }
  .article-box { font-size: 0.85rem; }

  .memo-card { padding: 1rem 1.1rem; }
  .memo-card .memo-keyword { font-size: 1.3rem; }

  .qcm-container { padding: 1rem 0.85rem; border-radius: var(--radius-sm); }

  /* Grille armes : 2 colonnes même sur très petit */
  .weapon-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
  }
  .weapon-figure figcaption { font-size: 0.78rem; padding: 0.4rem 0.4rem 0.5rem; }

  /* Hiérarchie compact */
  .hierarchy-list li {
    padding: 0.5rem 0.7rem 0.5rem 2.5rem;
    font-size: 0.92rem;
  }

  /* Diagramme DJ : tout plus compact */
  .dj-diagram { padding: 1rem 0.75rem; }
  .dj-box { font-size: 0.78rem; padding: 0.55rem 0.6rem; }
  .dj-title > span:nth-child(2) { font-size: 1rem; }
  .dj-title-sub { font-size: 0.8rem; }
  .dj-badge { font-size: 0.78rem; padding: 0.5rem 0.6rem; }
  .dj-sub-header { font-size: 0.72rem; padding: 0.35rem 0.45rem; }
  .dj-degree-label span { font-size: 0.75rem; padding: 0.25rem 0.7rem; }

  /* Section title */
  .section-title { font-size: 1.3rem; margin: 2rem 0 0.85rem; }
  .section-title::before { width: 18px; margin-right: 0.55rem; }

  /* Tables : éviter le nowrap sur th sur très petit */
  table th { white-space: normal; font-size: 0.72rem; }

  /* Search trigger : icône seule */
  .search-trigger { min-width: 0; padding: 0.4rem 0.55rem; }
  .search-trigger-label,
  .search-trigger-kbd { display: none; }

  /* Stat grid */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat-cell { padding: 0.6rem 0.75rem; }
  .stat-cell-value { font-size: 1.15rem; }
}

@media (max-width: 360px) {
  .weapon-grid { gap: 0.45rem; }
  .weapon-figure figcaption { font-size: 0.72rem; }
  .content-section { padding: 0.85rem 0.7rem; }
  .content-section h2 { font-size: 1.1rem; }
  .hero h1 { font-size: 1.25rem; }
  .page-header h1 { font-size: 1.2rem; }
}

/* ============================================================
   PRINT - fiches imprimables propres
   ============================================================ */
@media print {
  .navbar, footer, .theme-toggle, .search-trigger, .nav-links { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .container { max-width: 100%; padding: 0; }
  .content-section { border: none; box-shadow: none; page-break-inside: avoid; padding: 0.5rem 0; }
  .article-box, .plain-language, .infobox, .memo-card { page-break-inside: avoid; }
  a { color: #000; text-decoration: underline; }
  h1, h2, h3 { page-break-after: avoid; }
}
