/* Composants réutilisables. Convention : bloc / bloc-element / modificateur is-*. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font);
  transition: background var(--dur), border-color var(--dur), transform var(--dur-fast);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--card-hov); border-color: var(--border2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--red-solid); color: #fff; border-color: var(--red-solid); font-weight: 700; }
.btn.primary:hover { filter: brightness(0.92); }
.btn.primary:active { filter: brightness(0.82); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--card2); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-subtle); }
.btn.is-on { background: var(--red); color: #fff; border-color: var(--red); }
.btn.is-loading { color: transparent; pointer-events: none; position: relative; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  color: var(--text);
  animation: btn-spin 0.7s linear infinite;
}
.btn.primary.is-loading::after { color: #fff; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn-sm { padding: 7px 13px; font-size: var(--text-xs); border-radius: 8px; min-height: 38px; }
.btn-lg { padding: 14px 24px; font-size: var(--text-md); border-radius: var(--radius); min-height: 52px; }
.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-5);
}
.card-sm { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm); }
.card-md { padding: var(--sp-5) var(--sp-6); }
.card-lg { padding: var(--sp-6); }

.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 14px 10px;
  text-align: center;
  flex: 1;
  min-width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-tile-icon { color: var(--text3); }
.stat-tile-icon.is-warn { color: var(--amber); }
.stat-tile-icon.is-danger { color: var(--red); }
.stat-tile-icon.is-ok { color: var(--green); }
.stat-tile-icon.is-info { color: var(--blue); }
.stat-tile-icon.is-muted { color: var(--text3); }
.stat-tile-value {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.stat-tile-label {
  font-size: var(--text-xs);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font);
  color: var(--text2);
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.pill:hover { background: var(--card-hov); }
.pill.is-on { background: var(--red); color: #fff; border-color: var(--red); }
.pill-count { font-size: var(--text-xs); opacity: 0.7; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family: var(--font);
  min-height: 44px;
  transition: border-color var(--dur);
}
.input:focus { border-color: var(--blue); outline: none; }
.input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.input::placeholder { color: var(--text3); }
.hint { font-size: var(--text-xs); color: var(--text3); }
.err { font-size: var(--text-xs); color: var(--red); font-weight: 600; }
/* La couleur ne peut pas être le seul indicateur d'erreur (SC 1.4.1). */
.err::before { content: "\26A0\FE0E  "; }
.field.has-error .input { border-color: var(--red); }

.prog-bar {
  height: 6px;
  background: var(--card2);
  border-radius: 3px;
  overflow: hidden;
}
.prog-bar i {
  display: block;
  height: 100%;
  background: var(--red);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.prog-bar.thin { height: 3px; border-radius: 2px; }
.prog-bar.green i { background: var(--green); }
.prog-bar.amber i { background: var(--amber); }
.prog-bar.blue i { background: var(--blue); }
.prog-bar.muted i { background: var(--text3); }

.ring { position: relative; width: 92px; height: 92px; flex-shrink: 0; }
.ring-svg { transform: rotate(-90deg); width: 92px; height: 92px; }
.ring-bg { fill: none; stroke: var(--card2); stroke-width: 6; }
.ring-fg {
  fill: none;
  stroke: var(--red);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.ring-value { font-size: var(--text-lg); font-weight: 800; letter-spacing: -0.02em; }
.ring-caption { font-size: var(--text-xs); color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; }
.ring.ring-sm { width: 64px; height: 64px; }
.ring.ring-sm .ring-svg { width: 64px; height: 64px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text2);
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--card2);
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.badge.is-warn { color: var(--amber); background: var(--amber-subtle); }
.badge.is-danger { color: var(--red); background: var(--red-subtle); }
.badge.is-ok { color: var(--green); background: var(--green-subtle); }
.badge.is-info { color: var(--blue); background: var(--blue-subtle); }
.badge.is-muted { color: var(--text3); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--card2);
  color: var(--text2);
}
.chip.is-new { background: var(--blue-subtle); color: var(--blue); }
.chip.is-weak { background: var(--red-subtle); color: var(--red); }
.chip.is-mastered { background: var(--green-subtle); color: var(--green); }

#toasts {
  position: fixed;
  top: calc(20px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in var(--dur-slow) ease;
  max-width: calc(100vw - 48px);
}
.toast.is-leaving { animation: toast-out var(--dur-slow) ease forwards; }
.toast-ok { border-color: var(--green); }
.toast-ok .icon { color: var(--green); }
.toast-warn { border-color: var(--amber); }
.toast-warn .icon { color: var(--amber); }
.toast-err { border-color: var(--red); }
.toast-err .icon { color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

#modal-root { position: relative; z-index: 400; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 400;
  animation: overlay-in var(--dur) ease;
}
@media (min-width: 560px) {
  .modal-overlay { align-items: center; }
}
@keyframes overlay-in { from { opacity: 0; } }
.modal {
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
  width: 100%;
  max-width: 440px;
  max-height: 85dvh;
  overflow-y: auto;
  animation: modal-in var(--dur-slow) ease;
}
@media (min-width: 560px) {
  .modal { border-radius: var(--radius-lg); margin: var(--sp-4); }
}
@keyframes modal-in { from { opacity: 0; transform: translateY(24px); } }
.modal-title { margin-bottom: var(--sp-3); }
.modal-body { font-size: var(--text-base); color: var(--text2); line-height: 1.6; }
.modal-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-5); flex-wrap: wrap; }
.modal-actions .btn { flex: 1; min-width: 120px; }

.sheet {
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: var(--sp-5) var(--sp-6) calc(var(--sp-6) + var(--safe-b));
  width: 100%;
  max-width: 560px;
  max-height: 85dvh;
  overflow-y: auto;
  animation: modal-in var(--dur-slow) ease;
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border2);
  margin: 0 auto var(--sp-4);
}
.sheet-title { margin-bottom: var(--sp-3); }
.sheet-body { font-size: var(--text-base); color: var(--text2); line-height: 1.6; }

.appbar {
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-t);
}
.appbar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--appbar-h);
}
.appbar-title {
  font-size: var(--text-lg);
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appbar-user {
  margin-right: auto;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appbar-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.appbar-actions .btn-icon { color: var(--text2); background: transparent; border-color: transparent; }
.appbar-actions .btn-icon:hover { background: var(--card2); color: var(--text); }
.appbar-fs { font-size: var(--text-xs); font-weight: 800; }

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  /* box-sizing: border-box -> le rembourrage de sécurité doit S'AJOUTER à la hauteur de la barre,
     sinon il la mange et écrase icônes et libellés en mode application iOS (indicateur d'accueil). */
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: 0;
  color: var(--text3);
  flex: 1 1 0;
  min-width: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
  padding: 6px 2px;
  border-radius: 12px;
  position: relative;
  min-height: 44px;
  transition: color var(--dur);
}
.nav-item .icon { font-size: 1.3rem; transition: transform var(--dur); }
.nav-item.is-active { color: var(--red); }
.nav-item.is-active .icon { transform: scale(1.12); }
.nav-item::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 30%;
  right: 30%;
  height: 2px;
  background: var(--red);
  border-radius: 0 0 4px 4px;
  transform: scaleX(0);
  transition: transform var(--dur-slow);
}
.nav-item.is-active::after { transform: scaleX(1); }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
@media (max-width: 360px) { .nav-label { font-size: 0.6rem; } }

.qcard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 26px 22px;
}
[data-theme="dark"] .qcard { border-color: var(--border2); box-shadow: none; }

/* Le changement de question doit se voir : c'est le seul mouvement de l'écran, il dit « suivante ».
   base.css neutralise déjà les animations sous prefers-reduced-motion. */
.qcard { animation: qcard-in 160ms ease-out; }
@keyframes qcard-in { from { opacity: 0; transform: translateY(8px); } }
.qcard-tag {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text2);
  margin-bottom: var(--sp-4);
  font-weight: 600;
}
/* Le nom du chapitre reste sur une ligne : sinon le type de question se retrouve à cheval sur deux
   lignes de titre et l'en-tête mange la place de l'énoncé. */
.qcard-tag > span:not(.qcard-type) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.chapter-code {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font: 800 11px/1 var(--font-mono);
  letter-spacing: 0.02em;
  color: var(--ch-color, var(--text2));
  background: color-mix(in srgb, var(--ch-color, var(--text3)) 16%, transparent);
  flex-shrink: 0;
}
.chapter-code-sm { width: 22px; height: 22px; border-radius: 6px; font-size: 9px; }

/* Filet chevronné : marquage arrière des engins, reconnaissable d'un pompier, abstrait pour les
   autres. Jamais plus de 6 px, et le jaune ne sert jamais de couleur de texte. */
.chevron-rail {
  height: 6px;
  background: repeating-linear-gradient(135deg, var(--hiviz) 0 10px, var(--ink) 10px 20px);
}
.qcard-type {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}
.qcard-question { font-size: 1.35rem; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; margin-bottom: var(--sp-5); }
.qcard-choices { display: flex; flex-direction: column; gap: 9px; margin-bottom: 18px; }

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--card2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  min-height: 48px;
  font-size: var(--text-base);
  font-family: var(--font);
  color: var(--text);
  text-align: left;
  line-height: 1.4;
  transition: border-color var(--dur), background var(--dur);
}
.choice-key {
  flex: 0 0 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--card);
  display: grid;
  place-items: center;
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--text3);
  border: 1px solid var(--border);
}
.choice:hover:not(:disabled) { border-color: var(--text3); }
.choice.is-selected { border-color: var(--red); background: var(--red-subtle); }
.choice.is-correct { border-color: var(--green); background: var(--green-subtle); }
.choice.is-correct .choice-key { background: var(--green); color: #fff; border-color: var(--green); }
.choice.is-wrong { border-color: var(--red); background: var(--red-subtle); }
.choice.is-wrong .choice-key { background: var(--red); color: #fff; border-color: var(--red); }

.fb-row { display: flex; gap: 8px; flex-wrap: wrap; }
.fb-btn {
  flex: 1;
  min-width: 64px;
  padding: 11px 8px;
  border-radius: var(--radius-sm);
  min-height: 56px;
  border: 0;
  font-weight: 700;
  font-size: var(--text-sm);
  font-family: var(--font);
  color: #fff;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform var(--dur-fast), filter var(--dur);
}
.fb-btn:active { transform: scale(0.95); }
.fb-btn:hover { filter: brightness(1.08); }
.fb-btn.again { background: var(--fb-again); }
.fb-btn.hard { background: var(--fb-hard); }
.fb-btn.good { background: var(--fb-good); }
.fb-btn.easy { background: var(--fb-easy); }

.answer-box {
  background: var(--green-subtle);
  border-left: 4px solid var(--green);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
  margin-bottom: 16px;
}
.answer-box-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--green);
  font-weight: 700;
  margin-bottom: 6px;
}
.answer-box-value { font-weight: 700; font-size: 1.25rem; line-height: 1.4; }

.explanation {
  font-size: var(--text-base);
  color: var(--text2);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  line-height: 1.55;
  display: flex;
  gap: 8px;
}
.explanation .icon { color: var(--amber); flex-shrink: 0; margin-top: 0.15em; }

.list-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 8px;
}
.list-row:hover { border-color: var(--border2); }
.list-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  font-family: var(--font);
  color: var(--text);
  min-height: 44px;
}
.list-row-head .icon { color: var(--text3); transition: transform var(--dur); flex-shrink: 0; }
.list-row.is-open .list-row-head .icon { transform: rotate(180deg); }
.detail { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.list-row.is-open .detail { display: block; animation: slide-up var(--dur-slow) ease; }
@keyframes slide-up { from { opacity: 0; transform: translateY(8px); } }

.fiche {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 10px;
  overflow: hidden;
}
.fiche > summary {
  padding: 16px 18px;
  font-weight: 700;
  font-size: var(--text-md);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  user-select: none;
  transition: background var(--dur);
}
.fiche > summary::-webkit-details-marker { display: none; }
.fiche > summary .icon { color: var(--text3); transition: transform var(--dur); flex-shrink: 0; }
.fiche[open] > summary .icon { transform: rotate(180deg); }
.fiche > summary:hover { background: var(--card-hov); }
.fiche-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.fiche-body { padding: 0 18px 18px; }
.fiche-body h3 { margin-top: 18px; margin-bottom: 6px; }
.fiche-body h4 { margin-top: 14px; margin-bottom: 4px; }
.fiche-body ul, .fiche-body ol { padding-left: 20px; }
.fiche-body li { margin-bottom: 4px; font-size: var(--text-base); line-height: 1.6; }
.fiche-body table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: var(--text-sm); border-radius: 8px; overflow: hidden; }
.fiche-body th { background: var(--card2); padding: 9px 11px; text-align: left; font-weight: 700; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.03em; color: var(--text2); }
.fiche-body td { padding: 8px 11px; border-bottom: 1px solid var(--border); }
.fiche-body tr:last-child td { border-bottom: 0; }
.fiche-body .note {
  margin: 12px 0;
  padding: 10px 14px;
  background: var(--blue-subtle);
  border: 1px solid var(--blue);
  border-left-width: 4px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--text-sm);
  line-height: 1.6;
}
.fiche-body .warn {
  display: inline;
  background: var(--amber-subtle);
  color: var(--amber);
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  box-decoration-break: clone;
}
.fiche-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }

.fig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
@media (max-width: 480px) { .fig-grid { grid-template-columns: 1fr; } }
.fig-item { background: var(--card2); border-left: 3px solid var(--red); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 10px 12px; font-size: var(--text-sm); }
.fig-item-label { font-weight: 800; color: var(--red); font-size: var(--text-xs); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.03em; }

.empty { text-align: center; padding: 48px 20px; color: var(--text2); }
.empty .icon-xl { margin-bottom: 12px; color: var(--text3); }
.empty-title { font-weight: 700; font-size: var(--text-md); margin-bottom: 4px; color: var(--text); }

.skeleton {
  background: linear-gradient(90deg, var(--card2) 25%, var(--card-hov) 50%, var(--card2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.4s ease infinite;
  border-radius: var(--radius-sm);
  height: 16px;
  margin-bottom: 10px;
}
.skeleton.skeleton-lg { height: 40px; }
.skeleton.skeleton-circle { border-radius: 50%; width: 48px; height: 48px; }
@keyframes skeleton-shine { to { background-position: -200% 0; } }

.heatmap { display: grid; grid-template-columns: repeat(auto-fill, 12px); gap: 4px; }
.heatmap-cell { width: 12px; height: 12px; border-radius: 3px; background: var(--card2); }
.heatmap-cell[data-level="1"] { background: var(--red-subtle); }
.heatmap-cell[data-level="2"] { background: color-mix(in srgb, var(--red) 45%, var(--card2)); }
.heatmap-cell[data-level="3"] { background: color-mix(in srgb, var(--red) 75%, var(--card2)); }
.heatmap-cell[data-level="4"] { background: var(--red); }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bar-chart-bar {
  flex: 1;
  background: var(--red);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
}
.bar-chart-label { font-size: var(--text-xs); color: var(--text3); text-align: center; margin-top: 4px; }

.segmented {
  display: flex;
  background: var(--card2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 8px 10px;
  min-height: 38px;
  border-radius: 8px;
  transition: background var(--dur), color var(--dur);
}
.segmented button.is-on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 46px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--card2);
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: background var(--dur);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform var(--dur);
}
.switch.is-on { background: var(--red-solid); border-color: var(--red-solid); }
.switch.is-on::after { transform: translateX(20px); background: #fff; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card2);
  color: var(--text2);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.avatar.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar.avatar-lg { width: 64px; height: 64px; font-size: var(--text-lg); }

.sync-badge {
  position: fixed;
  top: calc(10px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--amber);
  color: #1a1200;
  font-weight: 700;
  font-size: var(--text-xs);
  padding: 8px 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 32px);
  text-align: left;
  line-height: 1.35;
}
.sync-badge .icon { flex-shrink: 0; }
.sync-badge.show { display: flex; }

#splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
}
.splash-mark { font-size: 2.6rem; }

.update-banner {
  position: fixed;
  left: var(--sp-4);
  right: var(--sp-4);
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--sp-3));
  z-index: 250;
  background: var(--card);
  border: 1px solid var(--border2);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-sm);
}
.update-banner-text { flex: 1; }

.mnemo {
  background: var(--red-subtle);
  color: var(--red);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 800;
  font-size: 0.9em;
  letter-spacing: 0.03em;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--card2);
  color: var(--text2);
  border: 1px solid var(--border);
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  border-top-color: var(--red);
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

.page-header { margin-bottom: var(--sp-5); }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.page-header-text { min-width: 0; }
.page-header-sub { color: var(--text2); font-size: var(--text-sm); margin-top: 4px; }
.page-header-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; flex-wrap: wrap; }

.chapter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 8px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--ch-color, var(--text3)) 14%, var(--card));
  border: 1px solid color-mix(in srgb, var(--ch-color, var(--text3)) 35%, var(--border));
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.prog-bar-wrap { display: flex; flex-direction: column; gap: 6px; }
.prog-bar-label { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--text2); font-weight: 600; }
.prog-bar-pct { color: var(--text); font-weight: 700; }

.list-row-head-text { flex: 1; min-width: 0; text-align: left; }
.list-row-chapter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text3);
  margin-bottom: 4px;
  font-weight: 600;
}
.list-row-q { font-weight: 600; font-size: var(--text-base); }
.list-row-flag { color: var(--amber); flex-shrink: 0; }
.list-row-stats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.list-row-flag-btn { margin-top: 12px; }

.chapter-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--ch-color, var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-4);
  font-family: var(--font);
  color: var(--text);
  transition: border-color var(--dur), transform var(--dur-fast);
}
.chapter-card:hover { border-color: var(--ch-color, var(--border2)); }
.chapter-card:active { transform: scale(0.99); }
.chapter-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.chapter-card-t { font-weight: 700; font-size: var(--text-base); }
.chapter-card-meta { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--text2); margin-top: 8px; }
.chapter-card-due { color: var(--amber); font-weight: 700; }
.chapter-card-cover {
  font-size: var(--text-xs);
  color: var(--text3);
  margin-top: 4px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.chapter-card-last { font-size: var(--text-xs); color: var(--text3); margin-top: 4px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: 0; }
.switch-row-label { font-weight: 600; font-size: var(--text-base); }

.bar-chart-wrap { display: flex; flex-direction: column; }
.bar-chart-col { flex: 1; display: flex; align-items: flex-end; height: 100%; }
.bar-chart-labels { display: flex; gap: 6px; margin-top: 4px; }
.bar-chart-labels .bar-chart-label { flex: 1; text-align: center; }

.kbd {
  display: inline-block;
  border: 1px solid var(--border2);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: var(--text-xs);
  background: var(--card2);
  color: var(--text2);
}

/* Cibles tactiles : l'interrupteur mesurait 46x26 px et les liens de bas de page 20 px de haut.
   On élargit la zone cliquable sans changer la taille visuelle du composant ni du texte. */
.switch {
  position: relative;
}
.switch::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  min-height: 44px;
  transform: translateY(-50%);
}
.auth-footer a,
.landing-footer a,
.acct-legal a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* Sigles cliquables et bulle de définition.
   Le sigle reste dans le fil du texte : souligné en pointillé, pas de fond ni de bordure, pour ne
   pas transformer un énoncé en champ de boutons. La cible reste tactile grâce au padding. */
.sigle {
  display: inline;
  background: none;
  border: 0;
  padding: 0 1px;
  margin: 0;
  font: inherit;
  color: var(--blue);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  cursor: pointer;
}
.sigle:hover { color: var(--text); background: var(--blue-subtle); border-radius: 3px; }
.sigle[aria-expanded="true"] { background: var(--blue-subtle); border-radius: 3px; color: var(--text); }

.sigle-bulle {
  position: fixed;
  z-index: 200;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-4);
  max-height: 60vh;
  overflow-y: auto;
  animation: sigle-bulle-in 140ms ease-out;
}
@keyframes sigle-bulle-in { from { opacity: 0; transform: translateY(-4px); } }
.sigle-bulle.is-dessus { animation-name: sigle-bulle-in-dessus; }
@keyframes sigle-bulle-in-dessus { from { opacity: 0; transform: translateY(4px); } }
.sigle-bulle-x { position: absolute; top: 4px; right: 4px; color: var(--text3); background: transparent; border-color: transparent; }
.sigle-bulle-tete { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; padding-right: 40px; }
.sigle-bulle-code {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: var(--text-sm);
  color: var(--blue);
  letter-spacing: 0.02em;
}
.sigle-bulle-libelle { font-weight: 700; font-size: var(--text-md); line-height: 1.3; }
.sigle-bulle-def { font-size: var(--text-base); color: var(--text2); margin-top: var(--sp-2); line-height: 1.5; }
.sigle-bulle-voir { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.sigle-bulle-voir-t {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  font-weight: 700;
}
.sigle-bulle-src {
  font-size: var(--text-xs);
  color: var(--text3);
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
}

/* Section glossaire (onglet Fiches) */
.gloss-search { margin-bottom: var(--sp-3); }
.gloss-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.gloss-row {
  display: flex;
  gap: var(--sp-3);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
}
.gloss-row-code {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: var(--text-sm);
  color: var(--blue);
  flex: 0 0 4.5rem;
  padding-top: 2px;
}
.gloss-row-l { font-weight: 700; font-size: var(--text-base); }
.gloss-row-d { font-size: var(--text-sm); color: var(--text2); margin-top: 2px; line-height: 1.5; }
.gloss-row-src { font-size: var(--text-xs); color: var(--text3); margin-top: var(--sp-2); }
.gloss-count { font-size: var(--text-sm); color: var(--text3); margin-bottom: var(--sp-3); }
