:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16191d;
  --muted: #5d6673;
  --line: #dfe3e8;
  --accent: #1f5f9e;
  --accent-ink: #ffffff;
  --del: #c0392b;
  --tol: #1e7f4a;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --panel: #1d2127;
    --ink: #e8eaed;
    --muted: #9aa4b0;
    --line: #2f353d;
    --accent: #5a9fd8;
    --accent-ink: #0f1216;
    --del: #ef6a5c;
    --tol: #4fc083;
    --warn: #e0b355;
    --warn-bg: #332a14;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 48px;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h1, h2, h3 { line-height: 1.25; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  max-width: 1180px;
  margin: 0 auto;
  padding-block: 20px 12px;
}

.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.topbar-actions { display: flex; gap: 8px; }

main, footer, .settings { max-width: 1180px; margin: 0 auto; }

footer {
  padding-block: 20px;
  color: var(--muted);
  font-size: 14px;
}
footer a { color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.panel h2 { margin: 0 0 12px; font-size: 16px; }
.panel h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
/* `minmax(0, …)` et non `1fr` : une colonne de grille ne descend pas sous la
   largeur min-content de son contenu, et le tableau gnomAD en demande 372 px
   (« Hétérozygotes », « Homozygotes »). Sans ce plancher à zéro, c'est la page
   entière qui déborde sous ~430 px au lieu du seul tableau, qui a son propre
   ascenseur horizontal (.table-wrap). */
@media (max-width: 860px) { .grid { grid-template-columns: minmax(0, 1fr); } }

/* — Formulaire — */

.query { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.grow { flex: 1 1 320px; min-width: 0; }

label, .label { font-weight: 600; font-size: 14px; }

input[type=text], input[type=password], select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  max-width: 100%;
}
input[type=text] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.help { margin: 0; color: var(--muted); font-size: 14px; }

.classes { display: flex; gap: 6px; }
.classes label { cursor: pointer; }
.classes input { position: absolute; opacity: 0; pointer-events: none; }
.classes span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-weight: 600;
}
.classes input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.classes input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  font-weight: 600;
  border-radius: 6px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; }
button.lang { font-variant-numeric: tabular-nums; min-width: 52px; }
button[disabled] { opacity: 0.55; cursor: default; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status { color: var(--tol); font-size: 14px; }

.message {
  max-width: 1180px;
  margin: 0 auto 16px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid currentColor;
}
.message.error { --warn: var(--del); --warn-bg: transparent; }
.message.progress {
  --warn: var(--muted);
  --warn-bg: transparent;
  font-variant-numeric: tabular-nums;
}

/* — Données — */

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 15px; }
/* Lien vers la source d'une valeur (ClinVar, UniProt) : la couleur du texte est
   gardée — le rouge d'un « Pathogenic » compris —, le soulignement pointillé dit
   qu'on peut cliquer. */
a.src-link { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
a.src-link:hover { color: var(--accent); text-decoration-style: solid; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-size: 14px; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }

.del { color: var(--del); font-weight: 600; }
.tol { color: var(--tol); font-weight: 600; }
.na { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.badge.yes { color: var(--tol); border-color: currentColor; }
.badge.no { color: var(--warn); border-color: currentColor; }

.note { color: var(--muted); font-size: 14px; }

/* — Étiquette Epi2Diag —
   L'étiquette se lit à côté du nom du gène ; son détail (syndrome, témoins,
   sensibilité, périmètre) passe en dessous, une information par ligne, pour qu'une
   ligne longue ne pousse pas la nomenclature hors de l'encart. La couleur ne dit
   qu'une chose : ce qu'on peut faire de la signature aujourd'hui. */
.badge.epi { margin-left: 6px; }
.epi-detail { display: block; margin-top: 3px; }
.epi-line { display: block; margin-top: 2px; line-height: 1.45; }
.epi-state { font-weight: 600; }
.epi-state.ready { color: var(--tol); }
.epi-state.partial { color: var(--warn); }
.epi-state.wanted { color: var(--muted); }
.epi-line.caution { color: var(--warn); }
.epi-line a { color: var(--accent); }

.badge.epi.ready { color: var(--tol); border-color: currentColor; }
.badge.epi.partial { color: var(--warn); border-color: currentColor; }
.badge.epi.wanted { color: var(--muted); border-color: var(--muted); }

/* Copie ligne par ligne : chaque nomenclature se recopie seule, dans un champ de
   compte rendu ou dans la barre de recherche d'une base. Le bouton reste visible sans
   survol — il n'y a pas de survol au doigt, et il doit se trouver sans le chercher.
   La valeur garde `flex: 1` pour que tous les boutons de l'encart s'alignent en
   colonne, et `min-width: 0` pour qu'une longue nomenclature se replie au lieu de
   pousser le bouton hors de la ligne. */
.kv dd.has-copy { display: flex; gap: 8px; align-items: baseline; }
.kv dd.has-copy > :first-child { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.copy-mini {
  flex: 0 0 auto;
  padding: 0 6px;
  font-size: 14px;
  font-weight: 400;
  line-height: 19px;
  border-radius: 5px;
  color: var(--muted);
}
.copy-mini:hover { color: var(--ink); border-color: var(--muted); }

/* Affichage progressif : une valeur encore en vol pulse doucement, pour qu'elle ne se
   confonde pas avec un « n.a. » — qui, lui, affirme que la base a répondu sans rien. */
.pending { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.35; } }

/* Le commentaire n'est pas rédigé tant qu'une source manque (voir renderComment). */
textarea.awaiting {
  color: var(--muted);
  font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
  .pending { animation: none; opacity: 0.55; }
}

.phenos { margin: 0; padding-left: 18px; }
.phenos li { margin-bottom: 3px; }

.links { display: grid; gap: 14px; }
.link-group h3 { margin: 0 0 6px; }
.link-list { display: flex; flex-wrap: wrap; gap: 6px; }
.link-list a, .link-list span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  text-decoration: none;
  color: var(--accent);
  font-size: 14px;
}
.link-list a:hover { border-color: var(--accent); }
.link-list span { color: var(--muted); }

textarea {
  width: 100%;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
}

.spin { display: inline-block; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* — Schémas : structure exonique et zoom sur la jonction —
   Aucune couleur dans le SVG lui-même (js/schema.js) : tout est ici, pour que les
   deux thèmes soient traités au même endroit que le reste de l'interface. */

.sch-wrap { margin-bottom: 4px; }
.sch {
  display: block;
  width: 100%;
  /* Un SVG réduit à la largeur d'un téléphone rendrait ses étiquettes illisibles :
     passé ce seuil, c'est le conteneur .table-wrap qui défile. */
  min-width: 680px;
  height: auto;
}

.sch-intron { stroke: var(--line); stroke-width: 2; }
.sch-base { stroke: var(--muted); stroke-width: 0.8; opacity: 0.5; }

.sch-exon { fill: var(--line); stroke: none; }
.sch-exon.cds { fill: var(--muted); }
.sch-exon.hit { fill: var(--accent); opacity: 0.35; }
.sch-exon.cds.hit { fill: var(--accent); opacity: 1; }

/* L'exon dont le saut est en question : un cadre neutre, qui désigne sans qualifier —
   la phase, elle, est écrite au-dessus du schéma et porte la couleur. */
.sch-skip { fill: none; stroke: var(--ink); stroke-width: 1.1; stroke-dasharray: 4 2; opacity: 0.6; }

.sch-junction { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.55; }
.sch-junction-label { fill: var(--muted); font-size: 12px; }

.sch-var { fill: var(--del); stroke: none; }
.sch-mark { stroke: var(--del); stroke-width: 1.6; }
.sch-mark-head { fill: var(--del); }

.sch-num { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sch-end { fill: var(--muted); font-size: 12px; }
.sch-pin { fill: var(--del); font-size: 13px; font-weight: 600; }

.sch-dim { stroke: var(--muted); stroke-width: 1; }
.sch-dim.edge { stroke: var(--del); }
.sch-dim-label { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sch-dim-label.edge { fill: var(--del); font-weight: 600; }

/* Bordure exonique, site canonique : un constat à signaler, pas une valeur neutre. */
.badge.alert { color: var(--del); border-color: currentColor; }

/* Avertissement de structure (désaccord de numérotation, version de transcrit) :
   il doit se lire avant le schéma qu'il relativise. */
.warn-note { color: var(--warn); margin-bottom: 8px; }

/* La jonction touchée ou frôlée : c'est le trait que le schéma doit faire ressortir. */
.sch-junction.edge { stroke: var(--del); opacity: 1; stroke-dasharray: none; }
.sch-junction-label.edge { fill: var(--del); font-weight: 600; }

/* — Classification ACMG —
   Le gris des notes (--muted, 11 px) est le ton de l'application pour ce qui
   accompagne un chiffre. Ici, rien n'accompagne : le texte **est** le critère, on le
   lit ligne à ligne et on coche. Il passe donc en pleine encre, et la hiérarchie se
   fait par la taille et le repère « ⤷ », non par la pâleur. */
#acmg .help,
#acmg .note,
#acmg .crit-body { color: var(--ink); font-size: 14px; }
#acmg .help { margin: 2px 0 6px; }
#acmg h3 { margin: 16px 0 6px; }
#acmg h4 {
  margin: 12px 0 2px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink);
}
#acmg .warn-note { color: var(--warn); }

/* Une ligne à cocher : case, code, puis le fait ou l'intitulé. Le code garde une
   largeur fixe pour que les intitulés s'alignent d'une rubrique à l'autre ;
   « PM2_Supporting » la dépasse et pousse simplement son texte. */
.crit-list { display: block; }
.crit {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 3px 0;
  cursor: pointer;
}
.crit input { flex: 0 0 auto; margin: 0; accent-color: var(--accent); }
.crit-code {
  flex: 0 0 7.5em;
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.crit-body { flex: 1 1 auto; min-width: 0; line-height: 1.45; }
/* La réserve attachée au critère : sous le fait, à part, et lisible. */
.crit-note { display: block; font-size: 14px; opacity: .85; }
.crit-note::before { content: '⤷ '; }
.crit:hover .crit-body { color: var(--ink); }
