/* ==========================================================================
   Item 176 · 286 — Diarrhée aiguë infectieuse + TIAC
   ========================================================================== */

:root {
  /* Tokens locaux (alignés sur autres items infectio) */
  --paper:    var(--bg-card);
  --paper-2:  #fffcf5;
  --rule:     #d7ccb4;
  --rule-2:   var(--accent-dash);
  --bg-2:     #ece5d6;
  --bg-3:     #e4dcc8;
  --ink-2:    #524a3e;
  --ink-3:    #8a8270;
  --ink-4:    #b2a98f;
  --danger:   #a52a1a;
  --warn:     #8a5a12;
  --ok:       #4e6a2f;

  /* Familles structurelles 176-286 */
  --fam-dx:        #2f5e6b;            /* bleu profond (examens / diagnostic) */
  --fam-dx-bg:     #d4eaf0;
  --fam-th:        var(--ok);          /* vert (PEC / thérapeutique) */
  --fam-th-bg:     #e2eccf;
  --fam-pec:       #c27a2c;            /* ocre (pédiatrie / PEC nourrisson) */
  --fam-pec-bg:    #f6e4cb;
  --fam-fdr:       var(--warn);        /* ambré (TIAC / pièges) */
  --fam-fdr-bg:    #f6ead0;

  /* Familles thématiques */
  --fam-urg:       var(--danger);
  --fam-urg-bg:    #f3dccf;
  --fam-synd:      var(--spe-infectio);
  --fam-synd-bg:   #f1d8cd;
  --fam-germe:     #a83232;
  --fam-germe-bg:  #fde2e2;
  --fam-cdiff:     #5b21b6;
  --fam-cdiff-bg:  #ede9fe;
  --fam-pedi:      var(--fam-pec);
  --fam-pedi-bg:   var(--fam-pec-bg);
  --fam-tiac:      var(--warn);
  --fam-tiac-bg:   #f6ead0;
  --fam-def:       var(--ink);
  --fam-def-bg:    var(--bg-2);

  /* Couleurs syndromes (3 syndromes onglet 05) */
  --fam-cholera:    #3aa6ce;
  --fam-cholera-bg: #d4eaf4;
  --fam-dysent:     var(--danger);
  --fam-dysent-bg:  #f3dccf;
  --fam-gastro:     #d97706;
  --fam-gastro-bg:  #fef3c7;
}

/* Élargissement local */
.content { max-width: 1400px; }

/* Fade léger au changement d'onglet */
@keyframes diarrhee-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.content-panel.active { animation: diarrhee-fadeIn .35s ease-out; }

/* Utilitaires textuels */
.mono   { font-family: var(--font-mono); font-feature-settings: "ss01"; }
.serif  { font-family: var(--font-serif); font-optical-sizing: auto; }
.muted  { color: var(--ink-3); }
.danger { color: var(--danger); }
.warn   { color: var(--warn); }
.ok     { color: var(--ok); }

/* =========================================================
   Sous-titres de section (numéro · titre · règle · hint)
   ========================================================= */
.sec-title       { display: flex; align-items: baseline; gap: 16px; margin: 36px 0 18px; flex-wrap: wrap; }
.sec-num         { font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em; color: var(--ink-3); text-transform: uppercase; }
.sec-title h2    { font-family: var(--font-serif); font-weight: 500; font-size: 30px; letter-spacing: -.01em; margin: 0; line-height: 1; }
.sec-title .rule { flex: 1; height: 1px; background: var(--rule); margin-bottom: 8px; min-width: 40px; }
.sec-title .hint { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); letter-spacing: .06em; }

/* Tag Rang */
.rang-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 2px;
  border: 1px solid var(--rule-2); color: var(--ink-2); background: var(--paper);
  vertical-align: middle;
}
.rang-tag.rang-a { color: var(--ok);    border-color: color-mix(in oklab, var(--ok) 40%, var(--rule-2)); }
.rang-tag.rang-b { color: var(--ink-3); border-color: var(--rule-2); }

/* Familles couleurs (utilitaires composants) */
.fam-urg     { --fam: var(--fam-urg);     --fam-bg: var(--fam-urg-bg); }
.fam-synd    { --fam: var(--fam-synd);    --fam-bg: var(--fam-synd-bg); }
.fam-dx      { --fam: var(--fam-dx);      --fam-bg: var(--fam-dx-bg); }
.fam-germe   { --fam: var(--fam-germe);   --fam-bg: var(--fam-germe-bg); }
.fam-th      { --fam: var(--fam-th);      --fam-bg: var(--fam-th-bg); }
.fam-cdiff   { --fam: var(--fam-cdiff);   --fam-bg: var(--fam-cdiff-bg); }
.fam-pedi    { --fam: var(--fam-pedi);    --fam-bg: var(--fam-pedi-bg); }
.fam-tiac    { --fam: var(--fam-tiac);    --fam-bg: var(--fam-tiac-bg); }
.fam-def     { --fam: var(--fam-def);     --fam-bg: var(--fam-def-bg); }
.fam-cholera { --fam: var(--fam-cholera); --fam-bg: var(--fam-cholera-bg); }
.fam-dysent  { --fam: var(--fam-dysent);  --fam-bg: var(--fam-dysent-bg); }
.fam-gastro  { --fam: var(--fam-gastro);  --fam-bg: var(--fam-gastro-bg); }

/* =========================================================
   Vignette d'amorce
   ========================================================= */
.vignette {
  background: var(--paper); border: 1px solid var(--rule);
  border-left: 4px solid var(--spe-infectio);
  border-radius: 4px; padding: 22px 26px; margin: 18px 0;
}
.vignette .vg-tag {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--spe-infectio); margin-bottom: 8px;
}
.vignette p { margin: 0 0 14px; line-height: 1.6; }
.vignette .vg-trap {
  background: var(--bg-2); border-left: 3px solid var(--ink); border-radius: 3px;
  padding: 12px 14px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2);
}

/* =========================================================
   Keypoints
   ========================================================= */
.keypoints { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.keypoint {
  background: var(--paper); border: 1px solid var(--rule);
  border-left: 3px solid var(--spe-infectio);
  border-radius: 4px; padding: 16px 18px; display: flex; gap: 14px;
}
.keypoint .kp-n {
  font-family: var(--font-serif); font-style: italic; font-size: 28px;
  color: var(--spe-infectio); line-height: 1; min-width: 28px;
}
.keypoint p { margin: 0; font-size: 13.5px; line-height: 1.55; }

/* =========================================================
   Def-cards
   ========================================================= */
.def-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.def-card {
  background: var(--paper); border: 1px solid var(--rule);
  border-top: 3px solid var(--fam, var(--ink));
  border-radius: 4px; padding: 16px 18px;
}
.def-card .def-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.def-card h3 { font-family: var(--font-serif); font-size: 17px; font-weight: 500; margin: 0; }
.def-card .def-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; color: var(--ink-3); text-transform: uppercase; }
.def-card p { margin: 0 0 8px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.def-card .def-pillar {
  border-top: 1px dashed var(--rule); padding-top: 8px; font-size: 12.5px;
  color: var(--ink-2); font-style: italic;
}

/* =========================================================
   Alertes cliniques rouge
   ========================================================= */
.alert-clinical {
  display: flex; gap: 14px; background: #f3dccf; border: 1px solid var(--danger);
  border-radius: 4px; padding: 14px 16px; margin: 14px 0;
}
.alert-clinical .alert-icon {
  width: 32px; height: 32px; min-width: 32px; border-radius: 50%; background: var(--danger);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-weight: 600; font-size: 20px;
}
.alert-clinical h4 { margin: 0 0 6px; font-family: var(--font-serif); font-weight: 500; font-size: 15.5px; color: var(--danger); }
.alert-clinical ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.alert-clinical p  { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-2); }

/* =========================================================
   Tableaux natifs (matrix)
   ========================================================= */
table.matrix {
  width: 100%; border-collapse: collapse; background: var(--paper);
  border: 1px solid var(--rule); border-radius: 4px; overflow: hidden;
  font-size: 13px; line-height: 1.5;
}
table.matrix th, table.matrix td {
  border: 1px solid var(--rule); padding: 10px 12px; vertical-align: top; text-align: left;
}
table.matrix thead th {
  background: var(--bg-2); color: var(--ink); font-family: var(--font-mono);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
}
table.matrix tbody th { background: var(--paper-2); color: var(--ink-2); font-weight: 500; min-width: 140px; }
table.matrix tr.matrix-section th {
  background: var(--bg-3); color: var(--ink); font-family: var(--font-serif);
  font-weight: 500; font-size: 14px; letter-spacing: 0; text-transform: none;
  padding: 12px 14px; text-align: left; border-top: 2px solid var(--rule-2);
}
table.matrix tr.row-alerte > td,
table.matrix tr.row-alerte > th { background: #f3dccf; }
table.matrix tr.row-piege > td,
table.matrix tr.row-piege > th  { background: #fff7d6; }

/* =========================================================
   Onglet 04 — Schéma physio (côlon/grêle) et germes par méca
   ========================================================= */
.physio-2col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0;
}
.physio-2col svg { width: 100%; height: auto; max-width: 100%; display: block; }

/* =========================================================
   Onglet 08 — Lanes PEC (réhydratation / sympto / ATB)
   ========================================================= */
.lanes {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 14px 0;
}
.lane {
  background: var(--paper); border: 1px solid var(--rule);
  border-top: 4px solid var(--fam, var(--fam-th));
  border-radius: 4px; padding: 16px 18px;
}
.lane h3 {
  font-family: var(--font-serif); font-weight: 500; font-size: 18px;
  margin: 0 0 4px; color: var(--fam, var(--fam-th));
}
.lane .lane-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; color: var(--ink-3); text-transform: uppercase; margin-bottom: 10px; }
.lane h4 { font-family: var(--font-serif); font-weight: 500; font-size: 14px; margin: 12px 0 4px; color: var(--ink); }
.lane ul { margin: 0 0 6px; padding-left: 20px; font-size: 13px; line-height: 1.55; }
.lane li { margin: 4px 0; }
.lane .lane-tag {
  display: inline-block; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .1em; color: var(--paper); background: var(--fam, var(--fam-th));
  padding: 2px 6px; border-radius: 2px; margin-bottom: 8px; text-transform: uppercase;
}

/* Carte hospitalisation + qSOFA */
.crit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0;
}
.crit-card {
  background: var(--paper-2); border: 1px solid var(--rule);
  border-left: 3px solid var(--fam-dx); border-radius: 4px;
  padding: 14px 16px;
}
.crit-card h4 { font-family: var(--font-serif); font-weight: 500; font-size: 16px; margin: 0 0 8px; color: var(--fam-dx); }
.crit-card ul { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.55; }

/* =========================================================
   Onglet 10 — Profils germes (pattern flashcard rubricée)
   ========================================================= */
.profils-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 14px 0;
}
.profils-section-title {
  grid-column: 1 / -1;
  font-family: var(--font-serif); font-weight: 500; font-size: 18px;
  color: var(--fam-germe); margin: 18px 0 -4px;
  border-bottom: 1px dashed var(--rule); padding-bottom: 4px;
}
/* IMPORTANT : profil-card SANS .ludic-card (pattern flashcard rubricée). */
.profil-card {
  background: var(--paper); border: 1px solid var(--rule);
  border-top: 3px solid var(--fam, var(--fam-germe));
  border-radius: 4px; padding: 14px 16px;
}
.profil-card .profil-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 10px; border-bottom: 1px dashed var(--rule); padding-bottom: 6px;
}
.profil-card .profil-head h3 {
  font-family: var(--font-serif); font-size: 16px; font-weight: 500; margin: 0;
  color: var(--fam, var(--fam-germe));
}
.profil-card .profil-head .profil-sub {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em;
  color: var(--ink-3); text-transform: uppercase; text-align: right;
}
.profil-card .profil-block {
  font-size: 12.5px; line-height: 1.55; color: var(--ink-2);
  margin: 6px 0; padding: 4px 6px; border-radius: 2px;
}
.profil-card .profil-block b { color: var(--ink); }
.profil-card .profil-block p { margin: 2px 0 0; display: inline; }

/* =========================================================
   Onglet 11 — Zoom C. difficile (cards + schéma toxines)
   ========================================================= */
.cdiff-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 14px 0;
}
.cdiff-card {
  background: var(--paper); border: 1px solid var(--rule);
  border-top: 3px solid var(--fam-cdiff);
  border-radius: 4px; padding: 14px 16px;
}
.cdiff-card h3 { font-family: var(--font-serif); font-weight: 500; font-size: 16px; margin: 0 0 8px; color: var(--fam-cdiff); }
.cdiff-card ul { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.55; }

.cdiff-schema-wrap { margin: 18px 0; }
.cdiff-schema-wrap svg { width: 100%; height: auto; max-width: 100%; display: block; }

/* =========================================================
   Onglet 12 — Pédiatrie : déshydratation + plan IV + SRO
   ========================================================= */
.dh-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0;
}
.dh-zone {
  border-radius: 4px; padding: 14px 14px; min-height: 130px;
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--rule);
}
.dh-zone .dh-pct { font-family: var(--font-mono); font-size: 13px; letter-spacing: .1em; color: var(--ink); text-transform: uppercase; font-weight: 600; }
.dh-zone .dh-label { font-family: var(--font-serif); font-size: 14px; font-weight: 500; color: var(--ink); margin-bottom: 4px; }
.dh-zone .dh-signs { font-size: 12px; line-height: 1.5; color: var(--ink-2); }
.dh-zone.zone-mild   { background: #d1fae5; border-color: #8fd1ad; }
.dh-zone.zone-mod    { background: #fef3c7; border-color: #e6c878; }
.dh-zone.zone-sev    { background: #fde2e2; border-color: #e89a9a; }

.pedi-schemas {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0;
}
.pedi-schemas svg { width: 100%; height: auto; max-width: 100%; display: block; }

/* =========================================================
   Onglet 13 — TIAC + pièges (cards + tableau)
   ========================================================= */
.tiac-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 14px 0;
}
.tiac-card {
  background: var(--paper); border: 1px solid var(--rule);
  border-top: 3px solid var(--fam-tiac);
  border-radius: 4px; padding: 14px 16px;
}
.tiac-card h3 { font-family: var(--font-serif); font-weight: 500; font-size: 16px; margin: 0 0 8px; color: var(--fam-tiac); }
.tiac-card ul { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.55; }

/* =========================================================
   Mindmap (template item 194 / 179)
   ========================================================= */
.mmwrap {
  position: relative; background: var(--paper); border: 1px solid var(--rule);
  border-radius: 4px; overflow: hidden; height: 780px;
}
.mmwrap .zctl        { position: absolute; top: 14px; right: 14px; z-index: 10; display: flex; gap: 4px; }
.mmwrap .zctl button {
  width: 34px; height: 34px; border: 1px solid var(--rule-2); background: var(--paper);
  border-radius: 3px; font-family: var(--font-mono); font-size: 14px; color: var(--ink-2);
  cursor: pointer;
}
.mmwrap .zctl button:hover { background: var(--bg-2); }
.mmwrap .zhint {
  position: absolute; left: 14px; bottom: 14px; z-index: 10;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em;
  color: var(--ink-3); background: rgba(255, 252, 245, .85);
  padding: 6px 10px; border-radius: 3px; border: 1px solid var(--rule);
}
.mmwrap svg.canvas {
  width: 100%; height: 100%; display: block; cursor: grab;
  background-image: radial-gradient(circle at 1px 1px, rgba(0,0,0,.035) 1px, transparent 0);
  background-size: 24px 24px;
}
.mmwrap svg.canvas:active { cursor: grabbing; }
.mmwrap svg.canvas .root-circle  { fill: var(--ink); }
.mmwrap svg.canvas .root-text    { fill: var(--paper); font-family: var(--font-serif); font-weight: 500; }
.mmwrap svg.canvas .node-card    { cursor: pointer; transition: filter .2s ease; }
/* Piège : pas de transform au hover (drop-shadow only) */
.mmwrap svg.canvas .node-card:hover          { filter: drop-shadow(0 4px 10px rgba(0,0,0,.18)); }
.mmwrap svg.canvas .node-card:hover .node-bg { stroke-width: 2; }
.mmwrap svg.canvas .node-bg      { fill: #fff; stroke: var(--rule-2); stroke-width: 1; }
.mmwrap svg.canvas .node-bg.star { stroke: var(--danger); stroke-width: 2.5; stroke-dasharray: 5 3; }
.mmwrap svg.canvas .node-accent  { fill: var(--fam, var(--ink)); }
.mmwrap svg.canvas .node-title   { fill: var(--ink); font-family: var(--font-serif); font-weight: 500; font-size: 15px; }
.mmwrap svg.canvas .node-sub     { fill: var(--ink-2); font-size: 11px; }
.mmwrap svg.canvas .node-chip    { fill: #fff; stroke: var(--rule); stroke-width: 1; }
.mmwrap svg.canvas .node-chip-t  { fill: var(--ink-2); font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.mmwrap svg.canvas path.link     { fill: none; stroke: var(--rule-2); stroke-width: 1.2; stroke-dasharray: 3 4; }
.mmwrap svg.canvas path.link.main { stroke-width: 1.4; }
.mmwrap svg.canvas path.link.sat  { stroke: var(--rule-2); stroke-width: 1; stroke-dasharray: 1 5; opacity: .55; }
.mmwrap svg.canvas .ring         { fill: none; stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 5; }

.mmwrap svg.canvas .node-sat               { cursor: pointer; transition: filter .2s ease; }
.mmwrap svg.canvas .node-sat:hover         { filter: drop-shadow(0 3px 8px rgba(0,0,0,.18)); }
.mmwrap svg.canvas .node-sat:hover .sat-bg { fill: var(--ink); }
.mmwrap svg.canvas .node-sat:hover .sat-title { fill: var(--paper); }
.mmwrap svg.canvas .sat-bg                 { fill: var(--bg-2); stroke: var(--ink); stroke-width: 1; }
.mmwrap svg.canvas .sat-title              { fill: var(--ink); font-family: var(--font-serif); font-weight: 500; font-size: 12.5px; }

/* =========================================================
   Algorithme 5 questions (onglet 03) — SVG natif
   ========================================================= */
.algo-svg-wrap { margin: 18px 0; }
.algo-svg-wrap svg { width: 100%; height: auto; max-width: 100%; display: block; }

/* =========================================================
   Dark-mode
   ========================================================= */
body.dark-mode .dh-zone.zone-mild { background: #1f4030; color: #d1fae5; border-color: #3a7a5a; }
body.dark-mode .dh-zone.zone-mod  { background: #4a3e1e; color: #fef3c7; border-color: #7a6a3a; }
body.dark-mode .dh-zone.zone-sev  { background: #4a2424; color: #fde2e2; border-color: #7a3a3a; }
body.dark-mode .dh-zone .dh-label,
body.dark-mode .dh-zone .dh-signs,
body.dark-mode .dh-zone .dh-pct   { color: inherit; }

body.dark-mode table.matrix tr.row-alerte > td,
body.dark-mode table.matrix tr.row-alerte > th { background: #3a1f1f; color: #f3dccf; }
body.dark-mode table.matrix tr.row-piege > td,
body.dark-mode table.matrix tr.row-piege > th  { background: #3a341f; color: #fef3c7; }

/* =========================================================
   Mobile
   ========================================================= */
@media (max-width: 900px) {
  .keypoints, .def-grid, .physio-2col, .lanes, .crit-grid,
  .profils-grid, .cdiff-grid, .pedi-schemas, .tiac-grid, .dh-grid { grid-template-columns: 1fr; }
  .mmwrap       { height: 580px; }
  .sec-title h2 { font-size: 24px; }
}
