/* ============================================================================
   TYPE-BAC.CSS — pages « Type Bac » (liste, sujet, exercice, suivi) — 20/09/2026
   ----------------------------------------------------------------------------
   Préfixe unique `.tb-`. Couleurs, rayons, ombres et z-index : UNIQUEMENT les
   tokens de styles.css (DESIGN-SYSTEM.md §1). Aucun !important, aucun mode nuit.
   Mouvement : transitions courtes + apparition échelonnée des cartes, coupés par
   `prefers-reduced-motion`.
   ============================================================================ */

/* Grille à piste minmax(0,1fr) : la page ne peut JAMAIS imposer sa largeur intrinsèque à <main>
   (flex: 1 sans min-width) — sinon la rangée de filtres défilante et les titres MathJax insécables
   élargissent tout l'écran sur mobile (mesuré : 966 px pour un écran de 390). */
.tb-page { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); max-width: 1120px; margin: 0 auto; color: var(--text-primary); }
.tb-page--etroit { max-width: 920px; }

/* ---------- Retour ---------- */
.tb-back {
  display: inline-flex; align-items: center; gap: 8px;
  justify-self: start; padding: 6px 12px 6px 8px; margin-bottom: 16px;
  border: 0; border-radius: var(--radius-full); background: transparent;
  color: var(--slate-500); font-size: var(--font-base); font-weight: 600; cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.tb-back:hover { background: var(--bg-card); color: var(--slate-800); transform: translateX(-2px); }

/* ---------- En-tête ---------- */
.tb-hero {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 20px;
}
.tb-hero h2 { margin: 0; font-size: var(--font-3xl); font-weight: 800; letter-spacing: -0.02em; color: var(--slate-900); }
.tb-hero p { margin: 6px 0 0; color: var(--slate-500); font-size: var(--font-base); }
.tb-hero-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.tb-stat {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 8px 14px;
  background: var(--bg-card); border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  font-size: var(--font-sm); color: var(--slate-500);
}
.tb-stat strong { font-size: var(--font-xl); font-weight: 800; color: var(--slate-900); }
.tb-stat--ok strong { color: var(--emerald-600); }

/* ---------- Barre d'outils (recherche + filtres) ---------- */
.tb-toolbar {
  position: relative; z-index: var(--z-dropdown);
  display: grid; grid-template-columns: minmax(0, 1fr);
  padding: 14px; margin-bottom: 18px;
  background: var(--bg-card); border: 1px solid var(--border-default);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
}
@media (min-width: 900px) {
  .tb-toolbar { position: sticky; top: 12px; }
  .tb-toolbar.tb-stuck { box-shadow: var(--shadow-lg); }
  @supports ((-webkit-backdrop-filter: blur(8px)) or (backdrop-filter: blur(8px))) {
    .tb-toolbar.tb-stuck { background: rgba(255, 255, 255, 0.86); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  }
}

.tb-search { position: relative; display: flex; align-items: center; }
.tb-search-icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--slate-400); pointer-events: none; }
.tb-search input {
  width: 100%; height: 48px; padding: 0 84px 0 44px;
  border: 1.5px solid var(--slate-200); border-radius: var(--radius-lg);
  background: var(--slate-50); color: var(--slate-900); font-size: var(--font-lg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  -webkit-appearance: none; appearance: none;
}
.tb-search input::placeholder { color: var(--slate-400); }
.tb-search input::-webkit-search-cancel-button { display: none; }
.tb-search input:focus { outline: none; background: var(--bg-card); border-color: var(--primary-500); box-shadow: 0 0 0 4px var(--primary-100); }
.tb-kbd {
  position: absolute; right: 14px; padding: 2px 8px; border: 1px solid var(--slate-200); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--slate-400); font-size: var(--font-sm); font-family: inherit; pointer-events: none;
}
.tb-search input:focus ~ .tb-kbd, .tb-search.tb-has-value .tb-kbd { display: none; }
.tb-search-clear {
  position: absolute; right: 10px; width: 28px; height: 28px; display: none; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius-full); background: var(--slate-200); color: var(--slate-600); cursor: pointer; font-size: var(--font-sm);
  transition: background var(--transition-fast);
}
.tb-search.tb-has-value .tb-search-clear { display: inline-flex; }
.tb-search-clear:hover { background: var(--slate-300); }

.tb-filters { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tb-filters::-webkit-scrollbar { display: none; }
.tb-fbtn {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border: 1px solid var(--slate-200); border-radius: var(--radius-full); background: var(--bg-card);
  color: var(--slate-700); font-size: var(--font-base); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}
.tb-fbtn:hover { border-color: var(--primary-200); background: var(--primary-50); }
.tb-fbtn svg { width: 14px; height: 14px; color: var(--slate-400); transition: transform var(--transition-fast); }
.tb-fbtn[aria-expanded="true"] { border-color: var(--primary-500); box-shadow: 0 0 0 3px var(--primary-100); }
.tb-fbtn[aria-expanded="true"] svg { transform: rotate(180deg); }
.tb-fbtn.tb-on { border-color: var(--primary-500); background: var(--primary-50); color: var(--primary-700); }
.tb-fbtn:disabled { opacity: 0.5; cursor: default; }
.tb-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-full); background: var(--primary-600); color: var(--bg-card); font-size: var(--font-sm); font-weight: 700;
}

/* Panneau d'un filtre */
.tb-popover {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  max-height: min(60vh, 440px); overflow-y: auto; overscroll-behavior: contain;
  padding: 16px; background: var(--bg-card); border: 1px solid var(--border-default);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
  animation: tb-pop var(--transition-fast) ease-out;
}
.tb-popover[hidden] { display: none; }
.tb-popover-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tb-popover-head h3 { margin: 0; font-size: var(--font-base); font-weight: 700; color: var(--slate-900); }
.tb-popover-head p { margin: 2px 0 0; font-size: var(--font-sm); color: var(--slate-500); }
.tb-popover-sub { margin: 14px 0 8px; font-size: var(--font-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate-400); }
.tb-popover-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--slate-100); }
.tb-link { border: 0; background: transparent; color: var(--slate-500); font-size: var(--font-base); font-weight: 600; cursor: pointer; padding: 6px 8px; border-radius: var(--radius-md); }
.tb-link:hover { color: var(--danger-600); background: var(--slate-50); }
.tb-backdrop { display: none; }

.tb-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.tb-pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 7px 12px;
  border: 1px solid var(--slate-200); border-radius: var(--radius-full); background: var(--bg-card);
  color: var(--slate-700); font-size: var(--font-base); font-weight: 500; cursor: pointer; text-align: left;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.tb-pill:hover { border-color: var(--primary-200); background: var(--primary-50); }
.tb-pill:active { transform: scale(0.97); }
.tb-pill small { color: var(--slate-400); font-size: var(--font-sm); font-weight: 600; }
.tb-pill.tb-on { border-color: var(--primary-600); background: var(--primary-600); color: var(--bg-card); font-weight: 600; }
.tb-pill.tb-on small { color: var(--primary-200); }

/* Filtres actifs */
.tb-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tb-chips:not(:empty) { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--slate-100); }
.tb-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 4px 4px 4px 10px;
  border-radius: var(--radius-full); background: var(--primary-50); color: var(--primary-700);
  font-size: var(--font-sm); font-weight: 600; animation: tb-pop var(--transition-fast) ease-out;
}
.tb-chip--notion { background: var(--warning-50); color: var(--warning-700); }
.tb-chip--autre { background: var(--slate-100); color: var(--slate-700); }
.tb-chip button {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  border: 0; border-radius: var(--radius-full); background: transparent; color: inherit; cursor: pointer; font-size: var(--font-xs);
}
.tb-chip button:hover { background: rgba(15, 23, 42, 0.1); }
.tb-chips .tb-link { margin-left: auto; font-size: var(--font-sm); }

/* ---------- Barre de résultats ---------- */
.tb-resultbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 36px; }
.tb-resultbar p { margin: 0; color: var(--slate-500); font-size: var(--font-base); }
.tb-resultbar p strong { color: var(--slate-900); font-weight: 800; }
.tb-resultbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tb-select {
  height: 36px; padding: 0 30px 0 12px; border: 1px solid var(--slate-200); border-radius: var(--radius-full);
  background: var(--bg-card); color: var(--slate-700); font-size: var(--font-base); font-weight: 600; cursor: pointer;
}
.tb-ghost {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--slate-200); border-radius: var(--radius-full); background: var(--bg-card);
  color: var(--slate-700); font-size: var(--font-base); font-weight: 600; cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}
.tb-ghost:hover { border-color: var(--primary-200); background: var(--primary-50); }
.tb-ghost:active { transform: scale(0.97); }
.tb-seg { display: inline-flex; padding: 3px; border-radius: var(--radius-full); background: var(--slate-200); }
.tb-seg button {
  height: 30px; padding: 0 14px; border: 0; border-radius: var(--radius-full); background: transparent;
  color: var(--slate-600); font-size: var(--font-base); font-weight: 600; cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}
.tb-seg button.tb-on { background: var(--bg-card); color: var(--slate-900); box-shadow: var(--shadow-sm); }

/* ---------- Grilles & cartes ---------- */
.tb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.tb-grid--exos { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }

.tb-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 18px;
  background: var(--bg-card); border: 1px solid var(--border-default); border-radius: var(--radius-xl);
  text-align: left; cursor: pointer; font: inherit; color: inherit;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  animation: tb-in 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 28ms);
}
.tb-card:hover { transform: translateY(-3px); border-color: var(--primary-200); box-shadow: var(--shadow-lg); }
.tb-card:focus-visible { outline: none; border-color: var(--primary-500); box-shadow: 0 0 0 4px var(--primary-100); }
.tb-card:active { transform: translateY(-1px); }
.tb-card--fait { border-color: var(--emerald-100); background: linear-gradient(180deg, var(--emerald-50) 0, var(--bg-card) 56px); }

.tb-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tb-ref { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--font-sm); font-weight: 700; color: var(--slate-500); }
.tb-ref b { padding: 2px 8px; border-radius: var(--radius-sm); background: var(--primary-50); color: var(--primary-700); font-weight: 800; }
.tb-card-title { margin: 0; font-size: var(--font-lg); font-weight: 700; line-height: 1.35; color: var(--slate-900); overflow-wrap: anywhere; }
.tb-card-title--xl { font-size: var(--font-xl); }
.tb-card-sub { margin: -4px 0 0; font-size: var(--font-2xl); font-weight: 800; color: var(--primary-600); letter-spacing: -0.01em; }
.tb-attente .tb-card-title, .tb-attente .tb-raison { visibility: hidden; }

.tb-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tb-tag { padding: 3px 9px; border-radius: var(--radius-full); background: var(--slate-100); color: var(--slate-600); font-size: var(--font-sm); font-weight: 600; }
.tb-tag--type { background: var(--warning-100); color: var(--warning-700); }
.tb-raison { margin: 0; display: flex; gap: 6px; font-size: var(--font-sm); font-weight: 600; color: var(--warning-700); }
.tb-raison--faible { color: var(--slate-400); font-weight: 500; }

.tb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--slate-100); font-size: var(--font-sm); color: var(--slate-500); }
.tb-meta span { display: inline-flex; align-items: center; gap: 5px; }
.tb-dots { display: inline-flex; gap: 3px; }
.tb-dots i { width: 7px; height: 7px; border-radius: var(--radius-full); background: var(--slate-200); }
.tb-dots i.tb-on { background: var(--warning-500); }
.tb-niv { font-weight: 700; color: var(--slate-700); }

.tb-badge { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; padding: 3px 9px; border-radius: var(--radius-full); font-size: var(--font-sm); font-weight: 700; white-space: nowrap; }
.tb-badge--fait { background: var(--emerald-100); color: var(--emerald-700); }
.tb-badge--eleves { background: var(--primary-50); color: var(--primary-700); }
.tb-badge--afaire { background: var(--warning-100); color: var(--warning-700); }

.tb-progress { height: 6px; border-radius: var(--radius-full); background: var(--slate-100); overflow: hidden; }
.tb-progress i { display: block; height: 100%; border-radius: var(--radius-full); background: var(--emerald-500); transition: width var(--transition-speed) ease; }

.tb-more { display: flex; justify-content: center; margin-top: 20px; }
.tb-empty { padding: 56px 16px; text-align: center; color: var(--slate-500); animation: tb-in 0.3s ease both; }
.tb-empty-icon { font-size: 44px; margin-bottom: 10px; }
.tb-empty h3 { margin: 0 0 6px; font-size: var(--font-xl); font-weight: 700; color: var(--slate-800); }
.tb-empty p { margin: 0 0 16px; }

/* ---------- Pages sujet & exercice ---------- */
.tb-banner {
  display: flex; align-items: center; gap: 16px; padding: 22px; margin-bottom: 20px;
  border-radius: var(--radius-xl); color: var(--bg-card);
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--info-500) 100%);
  box-shadow: var(--shadow-md); animation: tb-in 0.3s ease both;
}
.tb-banner-num { flex: 0 0 auto; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-lg); background: rgba(255, 255, 255, 0.18); font-size: var(--font-2xl); font-weight: 800; }
.tb-banner small { display: block; font-size: var(--font-base); opacity: 0.85; }
.tb-banner h2 { margin: 2px 0 0; font-size: var(--font-2xl); font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.tb-banner-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: var(--font-base); }
.tb-banner-meta span { display: inline-flex; align-items: center; gap: 6px; }
.tb-banner .tb-niv { color: inherit; }
.tb-banner .tb-dots i { background: rgba(255, 255, 255, 0.3); }
.tb-banner .tb-dots i.tb-on { background: var(--warning-400); }

/* ---------- Suivi (élève / prof) ---------- */
.tb-suivi { margin-top: 20px; padding: 20px; background: var(--bg-card); border: 1px solid var(--border-default); border-radius: var(--radius-xl); animation: tb-in 0.3s ease both; }
.tb-suivi-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.tb-suivi-head h3 { margin: 0; font-size: var(--font-xl); font-weight: 800; color: var(--slate-900); }
.tb-suivi-note { margin: 0 0 14px; font-size: var(--font-base); color: var(--slate-500); }
.tb-chrono { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; border-radius: var(--radius-full); background: var(--slate-100); }
.tb-chrono output { font-variant-numeric: tabular-nums; font-size: var(--font-lg); font-weight: 800; color: var(--slate-800); min-width: 54px; }
.tb-chrono.tb-run { background: var(--primary-50); }
.tb-chrono.tb-run output { color: var(--primary-700); }
.tb-chrono button { height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-full); background: var(--bg-card); color: var(--slate-700); font-size: var(--font-sm); font-weight: 700; cursor: pointer; box-shadow: var(--shadow-sm); }
.tb-chrono button:hover { color: var(--primary-700); }

.tb-histo { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.tb-histo li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 12px; border-radius: var(--radius-lg); background: var(--slate-50); font-size: var(--font-base); color: var(--slate-600); }
.tb-histo li.tb-ok { background: var(--emerald-50); }
.tb-histo li strong { color: var(--slate-900); }
.tb-histo li .tb-link { margin-left: auto; font-size: var(--font-sm); }
.tb-stars-ro { color: var(--warning-500); letter-spacing: 1px; }

.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px;
  border: 0; border-radius: var(--radius-lg); background: var(--emerald-600); color: var(--bg-card);
  font-size: var(--font-lg); font-weight: 700; cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.tb-btn:hover { background: var(--emerald-700); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.tb-btn:active { transform: translateY(0); }
.tb-btn[hidden] { display: none; }
.tb-btn:disabled { opacity: 0.6; cursor: default; transform: none; box-shadow: none; }
.tb-btn--plat { background: var(--slate-100); color: var(--slate-700); }
.tb-btn--plat:hover { background: var(--slate-200); box-shadow: none; }

.tb-form { display: grid; gap: 18px; padding-top: 4px; animation: tb-in 0.25s ease both; }
.tb-form[hidden] { display: none; }
.tb-field > label, .tb-field > span { display: block; margin-bottom: 8px; font-size: var(--font-base); font-weight: 700; color: var(--slate-800); }
.tb-field > span em { font-style: normal; font-weight: 500; color: var(--slate-400); }
.tb-stars { display: inline-flex; gap: 4px; }
.tb-stars button { width: 44px; height: 44px; border: 0; border-radius: var(--radius-lg); background: transparent; color: var(--slate-300); font-size: 30px; line-height: 1; cursor: pointer; transition: transform var(--transition-fast), color var(--transition-fast); }
.tb-stars button:hover { transform: scale(1.15); }
.tb-stars button.tb-on { color: var(--warning-400); }
.tb-stars-label { margin-left: 10px; font-size: var(--font-base); font-weight: 600; color: var(--slate-500); }
.tb-temps { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tb-temps input { width: 96px; height: 40px; padding: 0 12px; border: 1.5px solid var(--slate-200); border-radius: var(--radius-lg); font-size: var(--font-lg); font-weight: 700; color: var(--slate-900); }
.tb-temps input[type="date"] { width: auto; min-width: 160px; font-weight: 600; }
.tb-select-eleve { width: 100%; max-width: 360px; height: 40px; border-radius: var(--radius-lg); }
.tb-temps input:focus { outline: none; border-color: var(--primary-500); box-shadow: 0 0 0 4px var(--primary-100); }
.tb-form-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Modale « ressenti » (exercice assigné marqué fait) — structure .modal-overlay du design system ---------- */
.tb-modal-overlay { z-index: var(--z-modal-elevated); }
.tb-modal { max-width: 520px; }
.tb-modal-titre { font-size: var(--font-xl); font-weight: 800; color: var(--slate-900); }
.tb-modal .modal-f { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Fiche élève (prof) : exercices cherchés ---------- */
.tb-fiche { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tb-fiche li { display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-card); font-size: var(--font-sm); color: var(--slate-600); }
.tb-fiche li.tb-ok { border-color: var(--emerald-100); }
.tb-fiche-titre { font-weight: 600; color: var(--slate-800); overflow-wrap: anywhere; }
.tb-fiche-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tb-fiche-resume { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

/* ---------- Alerte « déjà fait » à l'assignation ---------- */
.tb-alerte { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--warning-100); border-radius: var(--radius-md); background: var(--warning-50); color: var(--warning-700); font-size: var(--font-sm); }
.tb-alerte strong { display: block; margin-bottom: 4px; }
.tb-alerte ul { margin: 0; padding-left: 18px; }

.tb-voir-exos { margin-left: 8px; padding: 2px 8px; border: 1px solid var(--primary-200); border-radius: var(--radius-full); background: var(--bg-card); color: var(--primary-700); font-size: var(--font-sm); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tb-voir-exos:hover { background: var(--primary-50); }

/* ---------- Rappel « déjà cherché » en tête de la page exercice ---------- */
.tb-deja { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin: -8px 0 16px; border: 1px solid var(--emerald-100); border-radius: var(--radius-lg); background: var(--emerald-50); animation: tb-in 0.3s ease both; }
.tb-deja-ico { flex: 0 0 auto; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); background: var(--emerald-100); color: var(--emerald-700); font-weight: 800; }
.tb-deja div { display: grid; gap: 2px; min-width: 0; flex: 1; }
.tb-deja strong { color: var(--slate-900); font-size: var(--font-base); }
.tb-deja span { color: var(--slate-600); font-size: var(--font-sm); }

/* ---------- Statistiques (type-bac-stats.js) : des tableaux « ligne × année », moyenne en dernière colonne ---------- */
.tb-panel { padding: 20px; margin-bottom: 16px; background: var(--bg-card); border: 1px solid var(--border-default); border-radius: var(--radius-xl); animation: tb-in 0.3s ease both; }
.tb-panel-head { margin-bottom: 14px; }
.tb-panel-head--ligne { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.tb-panel-head h3 { margin: 0; font-size: var(--font-xl); font-weight: 800; color: var(--slate-900); }
.tb-panel-head p { margin: 4px 0 0; font-size: var(--font-base); color: var(--slate-500); }
.tb-panel h4 { margin: 18px 0 8px; font-size: var(--font-base); font-weight: 700; color: var(--slate-800); }
.tb-panel h4 small, .tb-note small { font-weight: 500; color: var(--slate-400); }
.tb-note { margin: 12px 0 0; font-size: var(--font-base); color: var(--slate-600); line-height: 1.5; }
.tb-periode { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-size: var(--font-base); color: var(--slate-500); }
.tb-periode-borne { display: inline-flex; align-items: center; gap: 6px; }
.tb-periode-borne .tb-select { min-width: 0; }

.tb-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tb-kpis--compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.tb-kpi { display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--slate-50); }
.tb-kpi strong { font-size: var(--font-2xl); font-weight: 800; color: var(--slate-900); letter-spacing: -0.01em; }
.tb-kpis--compact .tb-kpi strong { font-size: var(--font-xl); }
.tb-kpi span { font-size: var(--font-sm); color: var(--slate-500); }

/* tableau : un seul ton, 3 classes + « absent » (rampe validée), toutes les valeurs écrites */
.tb-heat-wrap { overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
.tb-heat { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: var(--font-sm); }
.tb-heat thead th { padding: 6px 8px; font-weight: 700; color: var(--slate-600); text-align: center; white-space: nowrap; vertical-align: bottom; }
.tb-heat thead th.tb-hors { color: var(--slate-400); font-weight: 500; }
.tb-heat thead th.tb-dans { border-bottom: 2px solid var(--primary-600); }
.tb-heat thead th.tb-col-nom { text-align: left; }
.tb-heat thead th.tb-col-moy small { display: block; font-weight: 500; color: var(--slate-400); }
.tb-heat th[scope="row"] { padding: 6px 8px; text-align: left; font-weight: 600; color: var(--slate-800); min-width: 190px; }
.tb-heat td { min-width: 50px; padding: 8px 4px; border-radius: var(--radius-sm); text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; cursor: default; }
.tb-heat td.tb-hors { opacity: 0.55; }
.tb-heat td.tb-rang { min-width: 28px; font-weight: 600; color: var(--slate-400); }
.tb-heat td.tb-moy { min-width: 96px; padding: 4px 8px; text-align: left; background: var(--slate-50); }
.tb-heat td.tb-moy b { display: block; font-size: var(--font-base); color: var(--slate-900); }
.tb-heat td.tb-suivi-cell { min-width: 70px; color: var(--slate-500); font-weight: 500; white-space: nowrap; }
.tb-heat td.tb-suivi-cell b { color: var(--emerald-700); }
.tb-heat-0 { background: var(--slate-100); color: var(--slate-400); }
.tb-heat-1 { background: var(--primary-400); color: var(--slate-900); }
.tb-heat-2 { background: var(--primary-600); color: var(--bg-card); }
.tb-heat-3 { background: var(--primary-900); color: var(--bg-card); }
.tb-bar-track { display: block; height: 6px; margin-top: 3px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--slate-200); overflow: hidden; }
.tb-bar-track i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--primary-600); }

.tb-deplier { display: inline-flex; align-items: center; gap: 8px; width: 100%; padding: 2px 0; border: 0; background: transparent; font: inherit; font-weight: 700; color: var(--slate-900); text-align: left; cursor: pointer; }
.tb-deplier:hover { color: var(--primary-700); }
.tb-chevron { display: inline-block; width: 10px; color: var(--slate-400); font-size: var(--font-lg); transition: transform var(--transition-fast); }
.tb-ligne.tb-ouverte .tb-chevron { transform: rotate(90deg); }
.tb-ligne.tb-ouverte th[scope="row"] { background: var(--primary-50); border-radius: var(--radius-sm); }
.tb-heat tr.tb-detail > td { padding: 0; text-align: left; font-weight: 400; background: transparent; }
.tb-heat tr.tb-detail[hidden] { display: none; }
.tb-detail-corps { margin: 4px 0 12px; padding: 16px; border: 1px solid var(--primary-200); border-radius: var(--radius-lg); background: var(--bg-card); animation: tb-in 0.25s ease both; }
.tb-heat--meth th[scope="row"] { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; font-weight: 500; min-width: 260px; }
.tb-meth-nom { flex: 1; min-width: 160px; overflow-wrap: anywhere; }
.tb-nb-fiches { flex: none; font-size: var(--font-sm); font-weight: 600; color: var(--slate-400); white-space: nowrap; }
.tb-ligne--isolee > th { padding-left: 22px; }
.tb-panel-outils { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tb-meth-actions { display: inline-flex; align-items: center; gap: 4px; }
.tb-meth-actions .tb-link { padding: 2px 6px; font-size: var(--font-sm); }
.tb-meth-actions .tb-link:hover { color: var(--primary-700); }

.tb-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 12px; font-size: var(--font-sm); color: var(--slate-600); }
.tb-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tb-legend i { width: 14px; height: 14px; border-radius: 3px; }
.tb-legend-note { margin-left: auto; color: var(--slate-400); }

.tb-tip { position: absolute; z-index: var(--z-tooltip); max-width: 320px; padding: 6px 10px; border-radius: var(--radius-md); background: var(--slate-900); color: var(--bg-card); font-size: var(--font-sm); line-height: 1.35; pointer-events: none; box-shadow: var(--shadow-lg); }
.tb-tip[hidden] { display: none; }

/* ---------- Mouvement ---------- */
@keyframes tb-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes tb-pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes tb-sheet { from { transform: translateY(100%); } to { transform: none; } }

::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.22s; }

@media (prefers-reduced-motion: reduce) {
  .tb-card, .tb-empty, .tb-banner, .tb-suivi, .tb-form, .tb-popover, .tb-chip { animation: none; }
  .tb-card, .tb-card:hover, .tb-btn:hover, .tb-back:hover { transition: none; transform: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ---------- Mobile : le panneau de filtre devient une feuille basse ---------- */
@media (max-width: 640px) {
  .tb-hero h2 { font-size: var(--font-2xl); }
  .tb-toolbar { padding: 12px; }
  .tb-popover {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: var(--z-modal);
    max-height: 72vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    animation: tb-sheet 0.22s ease-out;
  }
  .tb-backdrop { display: block; position: fixed; inset: 0; z-index: var(--z-modal-backdrop); background: rgba(15, 23, 42, 0.4); }
  .tb-backdrop[hidden] { display: none; }
  .tb-resultbar-actions { width: 100%; justify-content: space-between; }
  .tb-banner { padding: 16px; }
  .tb-banner h2 { font-size: var(--font-xl); }
  .tb-stars button { width: 40px; height: 40px; }
  .tb-panel { padding: 16px; }
  .tb-heat th[scope="row"] { min-width: 150px; }
  .tb-heat--meth th[scope="row"] { min-width: 200px; }
  .tb-legend-note { margin-left: 0; }
}
