/* =========================================================
   Mathemator — refonte « encyclopédie imprimée »
   Design tokens & styles (vanilla CSS, aplat façon papier)
   ========================================================= */

:root {
  color-scheme: light;
  /* Fonds */
  --page: #eae5d9;
  --app: #f7f4ed;
  --card: #fffdf8;
  --soft: #f2eee3;
  --panel: #efe9da;
  /* Encre & textes */
  --ink: #211f1a;
  --ink-2: #56514a;
  --ink-3: #6f6a5e;
  --mut: #9b9585;
  --mut-2: #8a857a;
  --mut-3: #b3ac9a;
  /* Accent brique */
  --accent: #8a4a2c;
  --accent-hover: #6d3a22;
  /* Filets */
  --line: #d8d1c0;
  --line-2: #e4ddcd;
  --line-3: #efe9da;
  /* Sémantique */
  --ok: #3f6b4f;
  --ok-bg: #e9efe4;
  --ok-bd: #5c7a5a;
  --bad-bg: #f3e2da;
  --bad-bd: #a4573a;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --hatch: repeating-linear-gradient(45deg, rgba(60, 48, 30, 0.06) 0 6px, transparent 6px 14px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input:focus, button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

/* ===================== APP SHELL ===================== */
#app {
  width: 100%;
  max-width: 468px;
  margin: 0 auto;
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--app);
  border-radius: 4px;
}

@media (min-width: 500px) {
  body { padding: 0; display: grid; place-items: center; }
  #app {
    height: min(920px, calc(100dvh - 40px));
    min-height: 640px;
    border: 1px solid var(--line);
    box-shadow: 0 24px 60px rgba(40, 34, 22, 0.18);
  }
}

/* ===================== MASTHEAD ===================== */
.masthead {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px 12px;
  background: var(--app);
  border-bottom: 3px double #c9c0ab;
}
.menu-btn {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 13px 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--card);
}
.menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
}
.masthead-title { flex: 1; min-width: 0; }
.masthead-title .eyebrow {
  margin: 0 0 2px;
  font-size: 9px;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.masthead-title h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1;
}
.chapter-label {
  flex: none;
  max-width: 92px;
  margin: 0;
  text-align: right;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.15;
  color: var(--ink-3);
}

/* ===================== MAIN / SCREEN ===================== */
.screen {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px 28px;
  -webkit-overflow-scrolling: touch;
}

/* ---- Typographic helpers ---- */
.eyebrow-brick {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.section-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 0 12px;
}
.section-rule .eyebrow-brick { flex: none; }
.section-rule .fill { flex: 1; border-top: 1px solid var(--line-2); }
.section-rule .aside { flex: none; font-size: 11px; color: var(--mut); }
.section-rule .see-all {
  flex: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.section-rule .see-all:hover { text-decoration: underline; }
/* Focus visible pour la navigation clavier */
.open-card:focus-visible,
.chip:focus-visible,
.universe:focus-visible,
.biblio-row:focus-visible,
.exercise-row:focus-visible,
.calc-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.serif { font-family: var(--serif); }
.muted { color: var(--ink-3); }

/* ===================== ACCUEIL ===================== */
.hero {
  padding: 26px 0 20px;
  border-bottom: 1px solid var(--line-2);
}
.hero h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.12;
  text-wrap: pretty;
}
.hero p {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-3);
}

.daily-card {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 16px;
}
.daily-card .kicker {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--mut);
  font-weight: 600;
}
.daily-card h3 {
  margin: 6px 0 8px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
}
.daily-card p.body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pill {
  font-size: 11px;
  padding: 4px 9px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--ink-3);
}
.pill.accent { color: var(--accent); font-weight: 600; }

.quote {
  margin: 14px 0 0;
  padding: 14px 16px;
  border-left: 2px solid var(--accent);
  background: var(--soft);
}
.quote p {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  line-height: 1.45;
}
.quote footer { margin-top: 6px; font-size: 12px; color: var(--ink-3); }

.universe {
  display: flex;
  width: 100%;
  gap: 14px;
  align-items: baseline;
  text-align: left;
  padding: 16px 4px;
  border: 0;
  border-bottom: 1px solid var(--line-2);
  background: transparent;
}
.universe .num {
  flex: none;
  width: 26px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  color: var(--accent);
}
.universe .body { flex: 1; min-width: 0; }
.universe .body .name {
  display: block;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
}
.universe .body .desc {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-3);
}
.universe .count { flex: none; font-size: 11px; color: var(--mut); }
.universe .arrow { flex: none; color: var(--accent); }

/* ===================== SOMMAIRE ===================== */
.sommaire-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 0 6px;
}
.sommaire-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}
.icon-close {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--card);
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
}
.menu-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 4px;
}
.menu-group-title .num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--accent);
}
.menu-group-title .name {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.menu-group-title .fill { flex: 1; border-top: 1px solid var(--line-2); }
.menu-item {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  min-height: 44px;
  padding: 10px 4px;
  border: 0;
  border-bottom: 1px solid var(--line-3);
  background: transparent;
}
.menu-item .label {
  font-family: var(--serif);
  font-size: 16.5px;
  font-weight: 600;
  color: var(--ink);
}
.menu-item .arrow { flex: none; color: var(--mut-3); }

/* ===================== EXPLORER ===================== */
.search-input {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 14px;
  background: var(--card);
  font-size: 14px;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 0 4px;
}
.chip-row.scroll { flex-wrap: nowrap; overflow-x: auto; }
.chip {
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.active { background: var(--ink); color: var(--app); border-color: var(--ink); }
.chip.small { min-height: 34px; padding: 0 13px; font-size: 12.5px; color: var(--ink-2); }
.chip.level.active {
  background: var(--soft);
  color: var(--accent);
  border-color: var(--accent);
}
.count-label { margin: 10px 0 0; font-size: 11.5px; color: var(--mut); }

/* Liste mathématiciens */
.person-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
}
.portrait-glyph {
  flex: none;
  width: 46px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  padding: 0;
}
.portrait-glyph.has-img {
  overflow: hidden;
}
.portrait-glyph .vignette-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
  display: block;
}
.portrait-glyph .vignette-flag {
  font-size: 26px;
  line-height: 1;
}
.person-row .info {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0;
}
.person-row .info .name {
  display: block;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}
.person-row .info .meta {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.fav-star {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  font-size: 19px;
  color: var(--accent);
}

/* Domaines */
.domain-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line-2);
}
.row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.domain-row h3, .theorem-card h3, .problem-row h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
}
.domain-row h3 { font-size: 17px; }
.domain-row .fam { flex: none; font-size: 11px; color: var(--mut); }
.domain-row p { margin: 4px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-3); }

/* Cartes de liste cliquables (théorèmes, formules, objets, problèmes) */
.list-card {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 14px 10px 14px 16px;
  width: 100%;
}
.list-card.open-card { cursor: pointer; }
.list-card.open-card:hover { border-color: var(--line); }
.list-card .card-main { flex: 1; min-width: 0; }
.list-card .card-main h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16.5px;
}
.list-card .card-main .fam { flex: none; font-size: 11px; color: var(--mut); }
.list-card .card-main .who { flex: none; font-size: 11px; color: var(--mut); }
.list-card .card-main p { margin: 6px 0 0; font-size: 13px; line-height: 1.55; color: var(--ink-3); }
.list-card .card-main p.desc { font-size: 12.5px; }
.list-card .card-main .formula-box { font-size: 16px; margin: 8px 0; }
.list-card > .fav-star { flex: none; }

/* Théorèmes */
.theorem-card {
  margin-top: 14px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 14px 16px;
}
.theorem-card h3 { font-size: 16.5px; }
.theorem-card .who { flex: none; font-size: 11px; color: var(--mut); }
.formula-box {
  margin: 10px 0;
  padding: 12px;
  background: var(--soft);
  border-radius: 2px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  overflow-x: auto;
}
.formula-box .katex { font-style: normal; }
.theorem-card p.desc { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }

/* Problèmes */
.problem-row { padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.problem-row .row-head { align-items: center; }
.problem-row h3 { font-size: 16.5px; }
.status-pill {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--card);
}
.status-pill.open { background: var(--accent); }
.status-pill.active { background: var(--mut-2); }
.status-pill.solved { background: var(--ok); }
.problem-row p { margin: 4px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-3); }

/* Bibliothèque */
.biblio-row {
  display: flex;
  gap: 14px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  padding: 16px 4px;
  border: 0;
  border-bottom: 1px solid var(--line-2);
  background: transparent;
}
.biblio-row .num {
  flex: none;
  width: 26px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--accent);
}
.biblio-row .body { flex: 1; min-width: 0; }
.biblio-row .body .name {
  display: block;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}
.biblio-row .body .desc {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.biblio-row .count { flex: none; font-size: 11px; color: var(--mut); }

/* Entrée générique de collection (livres, citations, glossaire, média) */
.entry-row { padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.entry-row h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
}
.entry-row .meta { flex: none; font-size: 11px; color: var(--mut); }
.entry-row p { margin: 4px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-3); }
.back-link {
  margin-top: 14px;
  min-height: 40px;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
}

/* ===================== FICHE DÉTAIL ===================== */
.detail-role {
  margin: 16px 0 4px;
  font-size: 10.5px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--mut);
  font-weight: 600;
}
.detail-name {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
}
.portrait-frame {
  margin: 16px 0;
  height: 170px;
  display: grid;
  place-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--hatch), var(--panel);
  text-align: center;
}
.portrait-frame .glyph {
  font-family: var(--serif);
  font-size: 54px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}
/* Repli « pays » : grand drapeau de nationalité surmontant le glyphe. */
.portrait-frame.is-flag .flag {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}
.portrait-frame.is-flag .glyph {
  font-size: 30px;
  opacity: 0.75;
}
.portrait-frame .cap {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: var(--ink-3);
}
.portrait-frame .cap a {
  color: var(--accent);
  text-decoration: none;
}
.portrait-frame .cap a:hover {
  text-decoration: underline;
}
/* Portrait réel chargé : l'image remplace la trame hachurée et le glyphe. */
.portrait-frame.has-img {
  height: auto;
  padding: 0;
  gap: 0;
  background: var(--panel);
  display: block;
  overflow: hidden;
}
.portrait-frame.has-img .glyph {
  display: none;
}
.portrait-img {
  display: block;
  width: 100%;
  height: 300px;
  object-fit: cover;
  object-position: center 25%;
  border-bottom: 1px solid var(--line-2);
}
.portrait-frame.has-img .cap {
  display: block;
  padding: 8px 12px;
  text-align: left;
}
.detail-bio { margin: 0; font-size: 14.5px; line-height: 1.65; }
.bio-src {
  display: inline-block;
  margin-left: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.bio-src:hover { text-decoration: underline; }
.detail-dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
  font-size: 13px;
}
.detail-dl dt { color: var(--accent); font-weight: 600; }
.detail-dl dd { margin: 0; color: var(--ink-2); }
.fav-button {
  margin-top: 20px;
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}
.fav-button.on { background: var(--accent); color: var(--app); }

.detail-section { margin-top: 20px; }
.detail-section h4 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.detail-section ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
}
.detail-section p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-2);
}
.detail-list { margin: 0; padding-left: 18px; }
/* Formule mise en avant en tête de fiche (théorème, formule, objet) */
.formula-hero {
  margin: 16px 0;
  padding: 18px 14px;
  background: var(--hatch), var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  text-align: center;
  font-size: 17px;
  overflow-x: auto;
}
.formula-hero .katex { font-style: normal; }

/* ===================== SEGMENTED CONTROL ===================== */
.segmented {
  display: grid;
  margin: 18px 0 0;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.segmented button {
  min-height: 42px;
  border: 0;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.segmented button.active { background: var(--ink); color: var(--app); }

/* ===================== PRATIQUER ===================== */
.exercise-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-2);
  width: 100%;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.exercise-row .info { flex: 1; min-width: 0; }
.exercise-row .title { display: block; font-size: 14.5px; font-weight: 600; }
.exercise-row .meta { display: block; margin-top: 3px; font-size: 12px; color: var(--ink-3); }
.exercise-row .dots { flex: none; font-size: 12px; letter-spacing: 2px; color: var(--accent); }

.quiz-card {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 16px;
}
.quiz-card .progress {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--mut);
  font-weight: 600;
}
.quiz-card h3 {
  margin: 8px 0 14px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
}
.quiz-answers { display: grid; gap: 8px; }
.quiz-answers button {
  min-height: 46px;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
}
.quiz-answers button.correct { background: var(--ok-bg); border-color: var(--ok-bd); }
.quiz-answers button.wrong { background: var(--bad-bg); border-color: var(--bad-bd); }
.quiz-answers button.dim { color: var(--mut-2); }
.quiz-expl {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line-2);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}
.quiz-next {
  margin-top: 12px;
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: 2px;
  background: var(--ink);
  color: var(--app);
  font-weight: 600;
  font-size: 14px;
}

/* Progression */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.stat-cell {
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 12px;
  background: var(--card);
}
.stat-cell strong {
  display: block;
  font-family: var(--serif);
  font-size: 22px;
}
.stat-cell span { font-size: 11px; color: var(--ink-3); }
.bars { margin-top: 18px; display: grid; gap: 12px; }
.bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 5px;
}
.bar-head .name { font-weight: 600; }
.bar-head .pct { color: var(--mut); }
.bar-track {
  height: 7px;
  background: var(--line-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--accent); border-radius: inherit; }
.badge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}
.badge {
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 10px 12px;
  background: var(--card);
  opacity: 0.55;
}
.badge.on { border-color: var(--accent); background: var(--soft); opacity: 1; }
.badge strong { display: block; font-size: 13px; }
.badge span { font-size: 11px; color: var(--ink-3); }

/* Ateliers */
.atelier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.atelier {
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 14px;
  background: var(--card);
  text-align: left;
}
.atelier h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
}
.atelier p { margin: 4px 0 0; font-size: 12px; line-height: 1.45; color: var(--ink-3); }

/* ===================== LABO ===================== */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.tool-card {
  border: 1px solid var(--line-2);
  border-radius: 2px;
  overflow: hidden;
  background: var(--card);
  text-align: left;
  padding: 0;
  width: 100%;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.tool-card:hover {
  border-color: var(--line);
}
.tool-card:hover .thumb {
  color: var(--accent-hover, var(--accent));
}
.tool-card .thumb {
  height: 64px;
  display: grid;
  place-items: center;
  background: var(--hatch), var(--panel);
  border-bottom: 1px solid var(--line-2);
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  color: var(--accent);
}
.tool-card .cap { padding: 10px 12px; }
.tool-card .cap strong { display: block; font-size: 13.5px; }
.tool-card .cap span { font-size: 11.5px; color: var(--ink-3); }

/* Outils interactifs du Labo */
.lab-title {
  margin: 10px 0 2px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}
.lab-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.lab-stage {
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--card);
  overflow: hidden;
  line-height: 0;
}
.lab-stage canvas {
  display: block;
  width: 100%;
  touch-action: none;
  cursor: crosshair;
}
.lab-controls {
  margin-top: 12px;
}
.lab-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-3);
}
.lab-field input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 10px;
  background: var(--app);
  font-family: ui-monospace, Menlo, monospace;
  font-style: normal;
  font-size: 14px;
  box-sizing: border-box;
}
.lab-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.lab-msg {
  margin: 8px 0 0;
  font-size: 12px;
  min-height: 16px;
  color: var(--ink-3);
}
.lab-msg.err {
  color: var(--accent);
}
.lab-readout {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--soft);
  border-radius: 2px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  color: var(--ink);
}

.solver {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 16px;
}
.solver h3 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}
.solver .eq {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-3);
}
.coef-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.coef-grid label {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
}
.coef-grid input {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 10px;
  background: var(--app);
  font-size: 14px;
  box-sizing: border-box;
}
.solver-result {
  margin: 12px 0 0;
  padding: 12px;
  background: var(--soft);
  border-radius: 2px;
  font-size: 13.5px;
  line-height: 1.5;
}
.calc-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line-2);
  width: 100%;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.calc-row:hover .name { color: var(--accent); }
.calc-row .info { flex: 1; }
.calc-row .name { display: block; font-size: 14px; font-weight: 600; }
.calc-row .desc { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-3); }
.calc-row .arrow { flex: none; color: var(--mut-3); }

/* Panneaux de calculatrices */
.calc-panel { margin-top: 4px; }
.lab-field.vert {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.lab-field.vert input { flex: none; }
.calc-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-3);
}
.calc-inline label { display: inline-flex; align-items: center; gap: 6px; }
.mtx-cell {
  width: 64px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 8px;
  background: var(--app);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 14px;
  box-sizing: border-box;
}
.mtx-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 8px;
}
.mtx-label {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--accent);
}
.mtx-grid {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 6px;
}
.calc-note { color: var(--accent); font-weight: 600; }
.lab-readout p { margin: 0 0 4px; }
.lab-readout strong { color: var(--ink); }

/* ===================== HISTOIRE ===================== */
.timeline { margin-top: 20px; display: grid; gap: 0; }
.era { display: flex; gap: 14px; }
.era .dates {
  flex: none;
  width: 84px;
  padding-top: 2px;
  text-align: right;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13.5px;
  color: var(--accent);
}
.era .track {
  flex: 1;
  min-width: 0;
  border-left: 2px solid var(--line);
  padding: 0 0 24px 16px;
  position: relative;
}
.era .track .dot {
  position: absolute;
  left: -6px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.era .track h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}
.era .track ul {
  margin: 6px 0 0;
  padding-left: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}

.map-frame {
  margin: 16px 0;
  height: 210px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--hatch), var(--panel);
  overflow: hidden;
  position: relative;
}
.map-frame svg { width: 100%; height: 100%; display: block; }
.map-frame .map-dot { fill: var(--accent); cursor: pointer; }
.map-frame .map-dot:hover { fill: var(--accent-hover); }
.place-row { padding: 13px 0; border-bottom: 1px solid var(--line-2); }
.place-row .row-head { align-items: baseline; }
.place-row strong { font-family: var(--serif); font-size: 15.5px; font-weight: 600; }
.place-row .era-tag { flex: none; font-size: 11px; color: var(--mut); }
.place-row p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-3); }

/* ===================== BOTTOM NAV ===================== */
.bottom-nav {
  flex: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  background: var(--card);
}
.bottom-nav button {
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 1px;
  border: 0;
  border-top: 2px solid transparent;
  background: transparent;
  padding: 8px 2px 10px;
}
.bottom-nav button .num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  line-height: 1;
  color: var(--mut-2);
}
.bottom-nav button .label { font-size: 10.5px; font-weight: 500; color: var(--mut-2); }
.bottom-nav button.active { border-top-color: var(--accent); }
.bottom-nav button.active .num,
.bottom-nav button.active .label { color: var(--ink); }
.bottom-nav button.active .label { font-weight: 700; }

.empty-note {
  margin: 24px 0;
  font-size: 13px;
  color: var(--mut);
  text-align: center;
}

/* Écran de chargement */
.boot {
  flex: 1;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-3);
}
