/* Page « LLM maison » — thème « Abysses ».

   L'identité de la page : on plonge dans le modèle. Le Liquid Glass d'Apple
   devient de l'eau. La lumière de la surface ondule en haut (caustiques,
   assets/abysses.js) et s'éteint à mesure qu'on descend dans la page ; une
   neige marine dérive ; une jauge de profondeur sert de plan aux
   explications. Une eau profonde et sombre : la lumière reste rare.
   (L'accueil est en « 8 bits moderne », Clef en « pastel sans ombres ».)

   Sous l'eau, la grammaire reste celle d'Apple en mode sombre :
   - la police système (SF Pro sur les appareils Apple), avec l'approche
     typographique d'apple.com : interlettrage négatif qui se resserre quand le
     texte grandit, interlignage qui se resserre aussi ;
   - les couleurs système d'iOS : fond noir, cellules #1c1c1e, remplissages
     gris translucides, libellés secondaires à 60 %, et le bleu système ;
   - des matières : une barre de navigation en verre flottant, des cartes
     opaques en dessous (on n'empile jamais deux verres) ;
   - des coins concentriques : un élément intérieur a le rayon du parent moins
     la marge qui les sépare ;
   - des contrôles d'iOS : contrôle segmenté, curseurs, interrupteur, bulles
     de messages, champ de saisie en capsule avec son bouton ↑ ;
   - des ressorts plutôt que des courbes figées (linear() échantillonne la
     réponse d'un ressort : amortissement 1 par défaut, 0,8 seulement pour ce
     qui « claque », comme l'interrupteur).
   Toujours pas d'ombre portée : la hiérarchie vient des surfaces. */
:root {
  --bg: #000;
  --cell: #1c1c1e;              /* secondarySystemBackground */
  --cell-2: #2c2c2e;            /* tertiarySystemBackground */
  --bubble: #333336;            /* bulle reçue : un cran au-dessus de la carte */
  --fill: rgba(120, 120, 128, .36);    /* systemFill */
  --fill-2: rgba(120, 120, 128, .24);  /* tertiarySystemFill */
  --fill-3: rgba(118, 118, 128, .18);  /* quaternarySystemFill */
  --sep: rgba(84, 84, 88, .65);        /* separator */
  --text: #fff;
  --dim: rgba(235, 235, 245, .6);      /* secondaryLabel */
  --faint: rgba(235, 235, 245, .42);   /* entre secondaire et tertiaire : reste lisible */
  --accent: #0a84ff;                   /* systemBlue, mode sombre */
  --accent-rgb: 80, 170, 255;          /* bleu d'eau : carte d'attention (lu par llm.js), soulignements */
  --accent-hi: #409cff;
  --accent-soft: rgba(10, 132, 255, .18);
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Helvetica Neue', system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Helvetica Neue', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  /* Rayons concentriques : carte 28, marge intérieure 8, contrôle 20. */
  --r-carte: 28px;
  --r-bloc: 20px;
  --r-ctrl: 12px;
  /* Ressorts : amortissement 1 (réponse 0,35 s), et 0,8 pour les contrôles
     physiques. Durée = temps de stabilisation, pas un choix arbitraire. */
  --ressort: linear(0, .075, .227, .39, .536, .656, .75, .821, .873, .911, .938, .957, .971, .98, .986, .991, .994, .996, .997, .998, 1);
  --ressort-rebond: linear(0, .079, .248, .436, .608, .747, .851, .922, .968, .995, 1.009, 1.014, 1.015, 1.013, 1.01, 1.008, 1.005, 1.003, 1.002, 1.001, 1);
  --t-ressort: .5s;
  --verre: blur(30px) saturate(180%);
}

* { box-sizing: border-box; }
/* Pas de scroll-behavior: smooth : c'est llm.js qui fait glisser la page
   vers les ancres, avec un ressort interruptible. */
html { scrollbar-color: rgba(255, 255, 255, .22) transparent; }
body {
  /* L'eau, de la surface aux abysses : le dégradé suit toute la hauteur de
     la page (il défile avec elle). En haut, une eau bleue encore éclairée ;
     au fond, le noir. C'est lui que l'on voit sans WebGL. */
  background: linear-gradient(180deg, #04182e 0%, #031223 9%, #020b17 26%, #01060e 52%, #000307 78%, #000 100%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  letter-spacing: -.022em;            /* le réglage d'apple.com à 17 px */
  line-height: 1.47;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  opacity: 0; transform: translateY(8px);
  transition: opacity .5s ease, transform .5s var(--ressort);
}
body.is-ready { opacity: 1; transform: none; }
body.is-leaving { opacity: 0; transform: translateY(-8px); transition-duration: .18s; }
a { color: inherit; }
::selection { background: rgba(10, 132, 255, .5); color: #fff; }
.mono { font-size: 13px; letter-spacing: -.005em; }
.wrap { margin: 0 auto; max-width: 1080px; padding: 0 22px; width: 100%; }
.sr { clip: rect(0 0 0 0); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }
:focus-visible { outline: 3px solid rgba(10, 132, 255, .7); outline-offset: 2px; }
a, button, textarea, input, label { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* ---------- Matières ---------- */
.panel { background: var(--cell); border-radius: var(--r-carte); overflow: hidden; }
.panel-in { height: 100%; }
.widget { background: var(--cell-2); border-radius: var(--r-bloc); margin-top: 24px; padding: 18px 18px 20px; }

/* Barre de navigation : du verre qui flotte, le contenu défile dessous.
   Un liseré clair en haut tient lieu de reflet ; pas d'ombre. */
.top {
  align-items: center;
  -webkit-backdrop-filter: var(--verre);
  backdrop-filter: var(--verre);
  background: rgba(30, 30, 32, .62);
  border: .5px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  box-shadow: inset 0 .5px 0 rgba(255, 255, 255, .18);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 12px auto 0;
  max-width: 1080px;
  padding: 6px 6px 6px 20px;
  position: sticky;
  top: 12px;
  width: calc(100% - 24px);
  z-index: 30;
}
.top a { text-decoration: none; }
.wordmark { font-size: 15px; font-weight: 600; letter-spacing: -.016em; }
.wordmark span { color: var(--dim); font-weight: 400; }
/* Bascule FR / EN : un petit contrôle segmenté, la langue active en verre. */
.top-droite { align-items: center; display: flex; gap: 8px; }
.lang { background: var(--fill-3); border-radius: 999px; display: flex; gap: 2px; padding: 2px; }
.lang button { background: transparent; border: 0; border-radius: 999px; color: var(--dim); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .02em; padding: 6px 10px; transition: background-color .2s ease, color .2s ease, transform var(--t-ressort) var(--ressort); }
.lang button:hover { color: var(--text); }
.lang button.is-on { background: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .08)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .32), inset 0 0 0 .5px rgba(255, 255, 255, .16); color: var(--text); }
.lang button:active { transform: scale(.92); transition-duration: .1s; }
@media (max-width: 560px) { .wordmark span { display: none; } }
/* Bouton « gris teinté » d'iOS, en capsule, concentrique avec la barre. */
.back { background: var(--fill-2); border-radius: 999px; color: var(--accent-hi); font-size: 15px; font-weight: 500; padding: 8px 16px; transition: background-color .2s ease, transform var(--t-ressort) var(--ressort); }
.back:hover { background: var(--fill); }

/* ---------- Accueil ---------- */
.accueil { align-items: center; display: flex; min-height: calc(100svh - 64px); padding: 3vh 0 4vh; }
.accueil-in { max-width: 720px; }
h1 {
  font-family: var(--display);
  font-size: clamp(34px, 5.2vw, 56px);
  font-weight: 700;
  letter-spacing: -.028em;            /* plus c'est grand, plus c'est serré */
  line-height: 1.07;
  margin: 8px auto 28px;
  text-align: center;
  text-wrap: balance;
}
h1 em {
  background: linear-gradient(90deg, #0a84ff, #64d2ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: var(--accent);
  font-style: normal;
  -webkit-text-fill-color: transparent;
}
.descendre { border-radius: 999px; color: var(--accent-hi); display: block; font-size: 15px; margin: 18px auto 0; padding: 8px 14px; text-align: center; text-decoration: none; transition: background-color .2s ease; width: fit-content; }
.descendre:hover { background: var(--fill-3); }

/* ---------- Le chat ---------- */
.chat { display: flex; flex-direction: column; height: min(60vh, 620px); min-height: 440px; }
.chat .panel-in { display: flex; flex-direction: column; height: 100%; }

/* Contrôle segmenté d'iOS. Il se matérialise pendant une réponse (flou et
   échelle avec l'opacité : une matière qui arrive, pas un simple fondu). */
.pipeline {
  background: var(--fill-2);
  border-radius: 10px;
  display: flex;
  filter: blur(6px);
  gap: 2px;
  margin: 0 14px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 2px;
  transform: scale(.98);
  transition: max-height var(--t-ressort) var(--ressort), opacity .3s ease, filter .35s ease, transform var(--t-ressort) var(--ressort), margin var(--t-ressort) var(--ressort), padding var(--t-ressort) var(--ressort);
}
.chat.en-cours .pipeline { filter: none; margin-top: 14px; max-height: 80px; opacity: 1; padding: 2px; transform: none; }
.etape { border-radius: 8px; color: var(--text); flex: 1 1 0; font-size: 13px; font-weight: 500; letter-spacing: -.008em; min-width: 0; overflow: hidden; padding: 6px 4px; text-align: center; text-decoration: none; text-overflow: ellipsis; transition: background-color .25s ease; white-space: nowrap; }
.etape small { display: none; }
.etape.actif { background: #636366; }

.messages { display: flex; flex: 1; flex-direction: column; gap: 4px; min-height: 0; overflow-y: auto; padding: 20px 16px; scroll-behavior: smooth; }
.msg { display: flex; flex-direction: column; max-width: 78%; }
.msg + .msg { margin-top: 10px; }
.msg .qui { clip: rect(0 0 0 0); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }
.msg .corps { border-radius: 20px; font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; padding: 8px 14px; }
/* Bulles d'iMessage : la vôtre en bleu à droite, celle du modèle en gris à
   gauche. Chacune naît du côté d'où elle vient : la vôtre monte du champ de
   saisie, celle du modèle s'ouvre depuis la gauche. */
.msg.user { align-self: flex-end; animation: bulle var(--t-ressort) var(--ressort) both; transform-origin: 100% 100%; }
.msg.user .corps { background: var(--accent); border-bottom-right-radius: 6px; color: #fff; white-space: pre-wrap; }
.msg.modele { align-self: flex-start; animation: bulle var(--t-ressort) var(--ressort) both; transform-origin: 0 100%; }
.msg.modele .corps { background: var(--bubble); border-bottom-left-radius: 6px; }
@keyframes bulle { from { opacity: 0; transform: translateY(14px) scale(.92); } to { opacity: 1; transform: none; } }
/* Chaque mot garde la trace de sa probabilité : plus le trait est marqué,
   plus il était attendu. */
.tok { animation: pose .6s ease; background: linear-gradient(to top, rgba(var(--accent-rgb), calc(.15 + var(--p, 1) * .85)) 0 2px, transparent 2px); border-radius: 2px; }
@keyframes pose { from { background-color: rgba(var(--accent-rgb), .3); } to { background-color: transparent; } }
.curseur { animation: clign 1s ease-in-out infinite; background: var(--accent); border-radius: 1px; display: inline-block; height: 1.1em; margin-left: 2px; vertical-align: text-bottom; width: 2px; }
@keyframes clign { 50% { opacity: .2; } }

.vide { align-items: center; display: flex; flex-direction: column; gap: 16px; margin: auto; text-align: center; }
.vide p { color: var(--dim); font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 0 8px; }
.sugg { background: var(--fill-2); border: 0; border-radius: 999px; color: var(--text); cursor: pointer; font: inherit; font-size: 15px; padding: 8px 15px; transition: background-color .2s ease, transform var(--t-ressort) var(--ressort); }
.sugg:hover { background: var(--fill); }

/* Champ de saisie d'iMessage : une capsule, le bouton ↑ à l'intérieur.
   Coins concentriques : capsule de 40 px, bouton de 30 px, marge de 5 px. */
.saisie { align-items: flex-end; background: var(--bg); border: 1px solid var(--sep); border-radius: 22px; display: flex; gap: 6px; margin: 6px 12px 8px; padding: 4px 4px 4px 14px; transition: border-color .2s ease; }
.saisie:focus-within { border-color: rgba(10, 132, 255, .8); }
.saisie textarea { background: transparent; border: 0; color: var(--text); flex: 1; font: inherit; line-height: 1.35; max-height: 140px; min-height: 34px; padding: 7px 0 6px; resize: none; }
.saisie textarea:focus { outline: none; }
.saisie textarea::placeholder { color: var(--faint); }
.envoi { align-items: center; background: var(--accent); border: 0; border-radius: 50%; color: #fff; cursor: pointer; display: flex; flex: none; height: 32px; justify-content: center; margin-bottom: 1px; padding: 0; transition: background-color .2s ease, transform var(--t-ressort) var(--ressort); width: 32px; }
.envoi svg { height: 18px; width: 18px; }
.envoi .ico-stop, .envoi.stop .ico-envoyer { display: none; }
.envoi.stop .ico-stop { display: block; }
.envoi.stop { background: var(--fill); }
.envoi:hover { background: #2490ff; }
.envoi.stop:hover { background: rgba(120, 120, 128, .48); }

.statut { align-items: center; color: var(--faint); display: flex; font-size: 12px; gap: 6px; justify-content: center; letter-spacing: 0; margin: 0; padding: 0 20px 14px; }
.statut .ia { color: inherit; text-decoration: none; }
.statut .ia:hover { color: var(--dim); text-decoration: underline; }
.led { background: rgba(235, 235, 245, .3); border-radius: 50%; height: 6px; width: 6px; }
.led.vif { animation: clign 1s ease-in-out infinite; background: var(--accent); }

/* Boutons d'iOS : « rempli » en bleu, « gris teinté » avec un texte bleu. */
.btn { background: var(--accent); border: 0; border-radius: 999px; color: #fff; cursor: pointer; font: inherit; font-size: 15px; font-weight: 600; padding: 9px 18px; transition: background-color .2s ease, transform var(--t-ressort) var(--ressort); }
.btn:hover { background: #2490ff; }
.btn.sec { background: var(--fill-2); color: var(--accent-hi); }
.btn.sec:hover { background: var(--fill); }
.btn:disabled { cursor: not-allowed; opacity: .4; }

/* ---------- Détails ---------- */
.details { padding: 14vh 22px 4vh; }
.details h2, .explique h2 { font-family: var(--display); font-size: clamp(30px, 4.2vw, 48px); font-weight: 700; letter-spacing: -.026em; line-height: 1.08; margin: 0; max-width: 18ch; }
.details h2 em, .explique h2 em { color: var(--accent-hi); font-style: normal; }
.details .lead { color: var(--dim); font-size: 19px; letter-spacing: -.021em; line-height: 1.42; margin: 14px 0 0; max-width: 58ch; }
.faits { color: var(--dim); display: flex; flex-wrap: wrap; font-size: 15px; gap: 6px 22px; margin-top: 18px; }
.fait b { color: var(--text); font-weight: 600; margin-right: 5px; }
.insp { align-items: start; display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 36px; }

/* ---------- Inspecteur ---------- */
.bloc { padding: 20px 20px 6px; }
.bloc:last-child { padding-bottom: 20px; }
.bloc + .bloc { border-top: .5px solid var(--sep); margin-top: 14px; padding-top: 18px; }
.bloc h3 { font-family: var(--display); font-size: 17px; font-weight: 600; letter-spacing: -.022em; margin: 0 0 12px; }
.bloc h3 span { display: none; }
.jetons { display: flex; flex-wrap: wrap; gap: 4px; min-height: 28px; }
.jeton { background: var(--fill-2); border-radius: 8px; font-size: 13px; letter-spacing: -.005em; padding: 3px 8px; white-space: pre; }
.jeton i { color: var(--faint); font-size: 11px; font-style: normal; margin-left: 5px; }
#jetons-ctx .jeton i { display: none; }
.jeton.nouveau { animation: pose .7s ease; background: var(--accent-soft); color: var(--accent-hi); }
.probs { display: grid; gap: 9px; }
.prob { align-items: center; color: var(--dim); display: grid; font-size: 13px; gap: 10px; grid-template-columns: 5.2rem 1fr 2.8rem; letter-spacing: -.005em; }
.prob .mot { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: pre; }
.prob .barre { background: var(--fill-2); border-radius: 999px; height: 4px; overflow: hidden; }
.prob .barre i { background: rgba(var(--accent-rgb), .55); border-radius: 999px; display: block; height: 100%; transition: width .45s var(--ressort); width: 0; }
.prob .pct { font-variant-numeric: tabular-nums; text-align: right; }
.prob.choisi .mot, .prob.choisi .pct { color: var(--accent-hi); font-weight: 600; }
.prob.choisi .barre i { background: var(--accent); }
#attention { background: var(--fill-3); border-radius: 12px; display: block; height: 150px; image-rendering: pixelated; width: 100%; }
.couches { align-items: end; display: grid; gap: 6px; grid-auto-flow: column; grid-auto-columns: 1fr; height: 60px; }
.couche { background: var(--accent); border-radius: 6px; min-height: 6px; opacity: .85; transition: height .45s var(--ressort); }

/* Réglages : des lignes de cellule, comme dans l'app Réglages. */
.reglages { display: grid; gap: 4px; }
.reglage { align-items: center; display: grid; gap: 12px; grid-template-columns: 6.6rem 1fr 3.8rem; min-height: 44px; }
.reglage label { color: var(--text); font-size: 15px; }
.reglage output { color: var(--dim); font-size: 15px; font-variant-numeric: tabular-nums; text-align: right; }
.pas-a-pas { align-items: center; border-top: .5px solid var(--sep); display: flex; gap: 12px; justify-content: space-between; margin-top: 6px; min-height: 52px; padding-top: 6px; }
.pas-a-pas .pas { align-items: center; cursor: pointer; display: flex; flex: 1; font-size: 15px; gap: 12px; justify-content: space-between; }
.stats { color: var(--dim); display: flex; flex-wrap: wrap; font-size: 15px; gap: 6px 18px; }
.stats b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

/* Curseur d'iOS : piste fine, remplissage bleu à gauche (--p, posé par
   llm.js), pastille blanche de 28 px qui grossit sous le doigt. */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; height: 32px; margin: 0; touch-action: none; width: 100%; }
input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--fill) var(--p, 50%)); border-radius: 2px; height: 4px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; background: #fff; border: 0; border-radius: 50%; height: 26px; margin-top: -11px; transition: transform .35s var(--ressort-rebond); width: 26px; }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]::-moz-range-track { background: var(--fill); border-radius: 2px; height: 4px; }
input[type=range]::-moz-range-progress { background: var(--accent); border-radius: 2px; height: 4px; }
input[type=range]::-moz-range-thumb { background: #fff; border: 0; border-radius: 50%; height: 26px; transition: transform .35s var(--ressort-rebond); width: 26px; }
input[type=range]:active::-moz-range-thumb { transform: scale(1.12); }

/* Interrupteur d'iOS. La pastille s'étire sous le doigt et glisse avec un
   léger rebond : c'est un geste physique, l'élan a sa place ici. */
.interrupteur { -webkit-appearance: none; appearance: none; background: var(--fill); border-radius: 999px; cursor: pointer; flex: none; height: 31px; margin: 0; position: relative; transition: background-color .25s ease; width: 51px; }
.interrupteur::before { background: #fff; border-radius: 999px; content: ''; height: 27px; left: 2px; position: absolute; top: 2px; transition: transform .45s var(--ressort-rebond), width .25s var(--ressort); width: 27px; }
.interrupteur:checked { background: var(--accent); }
.interrupteur:checked::before { transform: translateX(20px); }
.interrupteur:active::before { width: 33px; }
.interrupteur:checked:active::before { transform: translateX(14px); }

/* ---------- Explications ---------- */
.explique { padding: 14vh 0 6vh; }
.explique-tete { display: grid; gap: 48px; grid-template-columns: minmax(0, .55fr) minmax(0, 1fr); }
.explique-tete p { color: var(--dim); font-size: 19px; letter-spacing: -.021em; line-height: 1.42; margin: 0; max-width: 58ch; }
.sections { counter-reset: s; display: grid; gap: 8px; margin-top: 7vh; }
.section { border-radius: var(--r-carte); display: grid; gap: 48px; grid-template-columns: minmax(0, .55fr) minmax(0, 1fr); padding: 34px 28px; scroll-margin-top: 90px; transition: background-color .5s ease; }
.section > div:first-child::before { color: var(--accent-hi); content: counter(s); counter-increment: s; display: block; font-family: var(--display); font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.section h3 { font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: -.024em; line-height: 1.14; margin: 4px 0 0; }
.section .texte p { color: var(--dim); font-size: 17px; line-height: 1.53; margin: 0 0 14px; max-width: 60ch; }
.section .texte p:last-of-type { margin-bottom: 0; }
.section .texte strong, .section .texte em { color: var(--text); font-weight: 600; }
.section .texte em { font-style: normal; }
.section .texte code { background: var(--fill-2); border-radius: 6px; font-family: var(--mono); font-size: .86em; letter-spacing: 0; padding: 1px 6px; }
.section.regard .widget { background: var(--cell-2); }
.widget > .mono { color: var(--dim); display: block; font-size: 13px; font-weight: 600; letter-spacing: -.005em; margin-bottom: 12px; }
.widget input[type=text] { background: var(--fill-3); border: 1px solid transparent; border-radius: var(--r-ctrl); color: var(--text); font: inherit; margin-bottom: 14px; padding: 10px 13px; width: 100%; }
.widget input[type=text]:focus { border-color: rgba(10, 132, 255, .8); outline: none; }
.note { background: var(--accent-soft); border-radius: 14px; color: var(--text); font-size: 15px; line-height: 1.45; margin: 22px 0 0; padding: 12px 16px; }

/* ---------- Pied de page ---------- */
.pied { align-items: center; border-top: .5px solid var(--sep); color: var(--faint); display: flex; flex-wrap: wrap; font-size: 12px; gap: 12px 24px; justify-content: space-between; letter-spacing: 0; margin: 4vh auto 0; max-width: 1080px; padding: 18px 22px 40px; }
.pied nav { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.pied a { color: var(--dim); text-decoration: none; }
.pied a:hover { color: var(--text); text-decoration: underline; }

/* ---------- Appui : immédiat, puis le ressort ramène ---------- */
.btn:active, .sugg:active, .back:active, .envoi:active { transform: scale(.94); transition-duration: .1s; }
.descendre:active, .etape:active, .wordmark:active, .pied a:active { opacity: .55; }

@media (hover: none) {
  .back:hover, .sugg:hover { background: var(--fill-2); }
  .descendre:hover { background: transparent; }
  .btn:hover, .envoi:hover { background: var(--accent); }
  .btn.sec:hover { background: var(--fill-2); }
  .envoi.stop:hover { background: var(--fill); }
}
@media (pointer: coarse) {
  .wordmark, .descendre, .pied a { position: relative; }
  .wordmark::before, .pied a::before { content: ''; inset: -12px -6px; position: absolute; }
  .descendre::before { content: ''; inset: -6px -4px; position: absolute; }
  .etape { padding-bottom: 10px; padding-top: 10px; }
  .envoi { height: 34px; width: 34px; }
}

@media (max-width: 980px) {
  .insp, .explique-tete, .section { grid-template-columns: 1fr; }
  .explique-tete, .section { gap: 14px; }
}
@media (max-width: 560px) {
  .top { padding-left: 16px; top: 8px; width: calc(100% - 16px); }
  .chat { height: min(66svh, 580px); min-height: 400px; }
  .pipeline, .chat.en-cours .pipeline { margin-left: 10px; margin-right: 10px; }
  .etape { font-size: 11px; letter-spacing: 0; }
  .messages { padding: 16px 12px; }
  .msg { max-width: 88%; }
  .saisie { margin: 4px 8px 8px; }
  .section { padding: 26px 18px; }
  .reglage { grid-template-columns: 6rem 1fr 3.6rem; }
  .prob { grid-template-columns: 4.5rem 1fr 2.6rem; }
}

/* =====================================================================
   Liquid Glass
   ---------------------------------------------------------------------
   Une seule recette, en trois couches :
   1. le corps : un dégradé clair presque transparent, plus un flou et une
      saturation de ce qui passe dessous (seulement pour les surfaces posées
      sur le fond : on n'empile jamais deux verres floutés) ;
   2. la tranche : un liseré dont la lumière vient d'en haut à gauche et
      ressort en bas à droite (dégradé masqué en anneau) ;
   3. le reflet : une ligne claire intérieure en haut, une plus discrète en
      bas. Aucune ombre portée.
   Plus la surface est grande, plus le verre est épais (flou plus fort). Les
   petits éléments posés dans un verre sont du verre « clair » : la tranche
   et le reflet, sans second flou. */
:root {
  --verre-corps: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .035));
  --verre-reflet: inset 0 1px 0 rgba(255, 255, 255, .26), inset 0 -1px 0 rgba(255, 255, 255, .06);
  --verre-epais: blur(40px) saturate(170%);
  --verre-fin: blur(18px) saturate(180%);
  --tranche: linear-gradient(135deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .08) 35%, rgba(255, 255, 255, .04) 65%, rgba(255, 255, 255, .3));
}
.panel, .top, .widget, .descendre, .section, .sugg, .back, .jeton, .envoi, .btn, .note, .msg.user .corps { position: relative; }
/* La tranche : un anneau d'un pixel, peint par un dégradé et masqué au centre. */
.panel::after, .top::after, .widget::after, .descendre::after, .section::after,
.sugg::after, .back::after, .envoi::after, .btn::after, .note::after {
  background: var(--tranche);
  border-radius: inherit;
  content: '';
  inset: 0;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  padding: 1px;
  pointer-events: none;
  position: absolute;
}

/* Verre épais : les grandes surfaces posées sur le fond. */
.panel {
  -webkit-backdrop-filter: var(--verre-epais);
  backdrop-filter: var(--verre-epais);
  background: linear-gradient(180deg, rgba(44, 44, 48, .62), rgba(28, 28, 30, .55));
  box-shadow: var(--verre-reflet);
}
.top {
  -webkit-backdrop-filter: var(--verre-fin);
  backdrop-filter: var(--verre-fin);
  background: linear-gradient(180deg, rgba(60, 60, 66, .5), rgba(30, 30, 34, .42));
  border: 0;
  box-shadow: var(--verre-reflet);
}
/* La section qu'on lit se couvre de verre. Un dégradé ne s'anime pas : le
   verre vit donc sur un calque (::before) dont seule l'opacité change, et la
   tranche (::after) suit le même fondu. */
.section { isolation: isolate; }
.section.regard { background: transparent; }
.section::before {
  -webkit-backdrop-filter: var(--verre-epais);
  backdrop-filter: var(--verre-epais);
  background: linear-gradient(180deg, rgba(44, 44, 48, .5), rgba(28, 28, 30, .42));
  border-radius: inherit;
  box-shadow: var(--verre-reflet);
  content: '';
  inset: 0;
  opacity: 0;
  position: absolute;
  transition: opacity .5s ease;
  z-index: -1;
}
.section::after { opacity: 0; transition: opacity .5s ease; }
.section.regard::before, .section.regard::after { opacity: 1; }
/* Le bouton « Comment ça marche » : une capsule de verre qui flotte. */
.descendre {
  -webkit-backdrop-filter: var(--verre-fin);
  backdrop-filter: var(--verre-fin);
  background: var(--verre-corps);
  box-shadow: var(--verre-reflet);
  color: var(--text);
  font-weight: 500;
  padding: 10px 18px;
  transition: background-color .2s ease, transform var(--t-ressort) var(--ressort);
}
.descendre:hover { background: linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .06)); }
.descendre:active { transform: scale(.95); transition-duration: .1s; }

/* Verre clair : dans un verre, pas de second flou. */
.widget, .section.regard .widget { background: var(--verre-corps); box-shadow: var(--verre-reflet); }
.sugg, .back { background: var(--verre-corps); box-shadow: var(--verre-reflet); }
.sugg:hover, .back:hover { background: linear-gradient(180deg, rgba(255, 255, 255, .17), rgba(255, 255, 255, .07)); }
.note { background: linear-gradient(180deg, rgba(10, 132, 255, .26), rgba(10, 132, 255, .12)); box-shadow: var(--verre-reflet); }

/* Les pastilles de jetons : des perles de verre. Le nouveau jeton est une
   perle teintée de bleu. */
.jeton { background: linear-gradient(180deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .04)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .24), inset 0 0 0 .5px rgba(255, 255, 255, .12); }
.jeton.nouveau { background: linear-gradient(180deg, rgba(64, 156, 255, .55), rgba(10, 132, 255, .25)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 0 0 .5px rgba(160, 205, 255, .4); color: #fff; }

/* Verre teinté : les actions principales, du bleu qui laisse passer la
   lumière, avec son reflet. */
.envoi, .btn { background: linear-gradient(180deg, #3d9cff, #0a84ff 60%, #0a74e6); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -1px 0 rgba(0, 0, 0, .12); }
.envoi:hover, .btn:hover { background: linear-gradient(180deg, #55a8ff, #1a8cff 60%, #0a7cf0); }
.envoi.stop, .btn.sec { background: var(--verre-corps); box-shadow: var(--verre-reflet); }
.envoi.stop:hover, .btn.sec:hover { background: linear-gradient(180deg, rgba(255, 255, 255, .17), rgba(255, 255, 255, .07)); }
.msg.user .corps { background: linear-gradient(180deg, #2a93ff, #0a84ff 55%, #0a78ea); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .32); }

/* Contrôle segmenté : une pastille de verre glisse d'une étape à l'autre
   (left et width en transition : elle repart de là où elle est, on peut la
   relancer en plein vol). Elle s'étire un peu pendant le trajet. */
.pipeline { position: relative; }
.pipeline::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, .24), rgba(255, 255, 255, .1));
  border-radius: 8px;
  bottom: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 0 0 .5px rgba(255, 255, 255, .22);
  content: '';
  left: var(--x, 0);
  opacity: 0;
  position: absolute;
  top: 2px;
  transition: left .45s var(--ressort), width .45s var(--ressort), opacity .2s ease;
  width: var(--w, 0);
}
.pipeline.a-pouce::before { opacity: 1; }
.etape { position: relative; z-index: 1; }
.etape.actif { background: transparent; font-weight: 600; }

/* Barres : des tubes de verre bleu, une lumière sur le dessus. */
.couche { background: linear-gradient(180deg, rgba(120, 190, 255, .95), rgba(10, 132, 255, .78)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), inset 0 0 0 .5px rgba(255, 255, 255, .25); opacity: 1; }
.prob .barre { box-shadow: inset 0 1px 1px rgba(0, 0, 0, .25); height: 6px; }
.prob .barre i { background: linear-gradient(180deg, rgba(120, 190, 255, .7), rgba(10, 132, 255, .5)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4); }
.prob.choisi .barre i { background: linear-gradient(180deg, #64b4ff, #0a84ff); }

/* Curseurs : une pastille en capsule. Au repos, du verre blanc ; dès qu'on
   la saisit, elle devient une lentille claire qui grossit (comme sur iOS) et
   laisse voir la piste à travers elle. */
input[type=range]::-webkit-slider-runnable-track { box-shadow: inset 0 1px 1px rgba(0, 0, 0, .3); height: 5px; }
input[type=range]::-webkit-slider-thumb {
  background: linear-gradient(180deg, #fff, #e4e6ec);
  border-radius: 999px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .08), inset 0 0 0 .5px rgba(255, 255, 255, .9);
  height: 24px;
  margin-top: -9.5px;
  transition: transform .4s var(--ressort-rebond), background-color .2s ease;
  width: 38px;
}
input[type=range]:active::-webkit-slider-thumb {
  background: linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, .06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -1px 0 rgba(255, 255, 255, .2), inset 0 0 0 1px rgba(255, 255, 255, .45);
  transform: scale(1.35, 1.3);
}
input[type=range]::-moz-range-thumb { background: linear-gradient(180deg, #fff, #e4e6ec); border-radius: 999px; height: 24px; width: 38px; }
input[type=range]:active::-moz-range-thumb { background: rgba(255, 255, 255, .2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 0 0 1px rgba(255, 255, 255, .45); transform: scale(1.35, 1.3); }

/* Interrupteur : la piste est une rainure ; la pastille, saisie, devient
   une lentille de verre qui déborde de la piste, puis se repose. */
.interrupteur { box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35); }
.interrupteur:checked { background: linear-gradient(180deg, #3d9cff, #0a84ff); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25), inset 0 0 0 .5px rgba(255, 255, 255, .2); }
.interrupteur::before {
  background: linear-gradient(180deg, #fff, #e4e6ec);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .08);
  transition: transform .45s var(--ressort-rebond), width .3s var(--ressort), background-color .2s ease, height .3s var(--ressort), top .3s var(--ressort), left .3s var(--ressort);
}
.interrupteur:active::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, .08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), inset 0 0 0 1px rgba(255, 255, 255, .5);
  height: 35px;
  left: -2px;
  top: -2px;
  width: 41px;
}
.interrupteur:checked:active::before { transform: translateX(14px); }

/* Les bulles se matérialisent : le flou se dissipe en même temps qu'elles
   arrivent, comme une matière qui se forme plutôt qu'un simple fondu. */
@keyframes bulle { from { filter: blur(6px); opacity: 0; transform: translateY(14px) scale(.92); } to { filter: none; opacity: 1; transform: none; } }

@media (hover: none) {
  .sugg:hover, .back:hover, .descendre:hover { background: var(--verre-corps); }
  .envoi:hover, .btn:hover { background: linear-gradient(180deg, #3d9cff, #0a84ff 60%, #0a74e6); }
  .envoi.stop:hover, .btn.sec:hover { background: var(--verre-corps); }
}

/* =====================================================================
   Abysses
   ===================================================================== */
/* L'eau vivante (caustiques, neige marine) : derrière tout, et elle n'arrive
   qu'une fois sa première image prête. */
#abysses { height: 100%; inset: 0; opacity: 0; pointer-events: none; position: fixed; transition: opacity 2.2s ease .2s; width: 100%; z-index: 0; }
html.eau-on #abysses { opacity: 1; }
main, .pied { position: relative; z-index: 1; }
.messages { scroll-behavior: smooth; }
.saisie { background: rgba(0, 4, 10, .6); border-color: rgba(170, 220, 255, .13); }
.msg.modele .corps::before { color: var(--faint); content: '…'; }   /* il continue ta phrase */
.msg.modele .corps { white-space: pre-wrap; }   /* les dialogues vont à la ligne, comme dans ses livres */
.msg.modele .corps { background: linear-gradient(180deg, rgba(40, 62, 92, .5), rgba(22, 36, 58, .45)); box-shadow: inset 0 1px 0 rgba(200, 230, 255, .12), inset 0 0 0 .5px rgba(170, 220, 255, .1); }
/* Un verre plus sombre : de l'eau profonde, pas une vitre éclairée. */
.panel, .section::before { background: linear-gradient(180deg, rgba(14, 20, 30, .72), rgba(6, 9, 15, .68)); }
.top { background: linear-gradient(180deg, rgba(18, 26, 38, .62), rgba(6, 10, 16, .55)); }
.descendre, .widget, .section.regard .widget { background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02)); }

/* Sous l'eau, la lumière vient d'en haut : la tranche du verre est plus
   claire, et plus bleue, sur son bord supérieur. */
:root {
  --tranche: linear-gradient(180deg, rgba(170, 220, 255, .32), rgba(255, 255, 255, .05) 38%, rgba(255, 255, 255, .02) 70%, rgba(120, 190, 255, .12));
  /* Le reflet d'une bulle d'air : un éclat rond en haut à gauche. */
  --bulle-reflet: radial-gradient(55% 60% at 28% 18%, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 62%);
  --verre-reflet: inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 -1px 0 rgba(255, 255, 255, .04);
}

/* Les « nœuds » deviennent des bulles : jetons, suggestions, pastilles. */
.jeton, .sugg, .back { background: var(--bulle-reflet), var(--verre-corps); }
.jeton.nouveau { background: var(--bulle-reflet), linear-gradient(180deg, rgba(80, 170, 255, .5), rgba(10, 132, 255, .22)); }
.sugg:hover, .back:hover { background: var(--bulle-reflet), linear-gradient(180deg, rgba(255, 255, 255, .17), rgba(255, 255, 255, .07)); }
.envoi { background: var(--bulle-reflet), linear-gradient(180deg, #3d9cff, #0a84ff 60%, #0a74e6); }
input[type=range]:active::-webkit-slider-thumb { background: var(--bulle-reflet), linear-gradient(180deg, rgba(170, 220, 255, .25), rgba(80, 170, 255, .08)); }
.interrupteur:active::before { background: var(--bulle-reflet), linear-gradient(180deg, rgba(170, 220, 255, .28), rgba(80, 170, 255, .08)); }

/* Couches et jetons : pas de verre bombé ici, un rendu plat et net.
   - Les couches sont des colonnes de lumière : un trait clair au sommet (la
     valeur), et une lueur qui s'éteint vers le bas, comme un rai dans l'eau.
   - Les jetons sont de simples contours fins ; le dernier tiré est teinté
     de bleu, sans reflet. */
.couche {
  background: linear-gradient(180deg, rgba(var(--accent-rgb), .55), rgba(var(--accent-rgb), .04));
  border-radius: 3px 3px 0 0;
  box-shadow: inset 0 2px 0 #8cc8ff;
  opacity: 1;
}
.jeton {
  background: transparent;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(170, 220, 255, .16);
  color: var(--dim);
}
.jeton.nouveau {
  background: rgba(var(--accent-rgb), .14);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .55);
  color: #cfe6ff;
}
#jetons-ctx .jeton:not(.nouveau) { color: var(--text); }

/* Jauge de profondeur, sur le bord droit : n'apparaît qu'une fois sous la
   surface. Chaque point est une explication ; la pastille donne la profondeur. */
.jauge { bottom: 14vh; opacity: 0; pointer-events: none; position: fixed; right: 26px; top: 16vh; transform: translateX(12px); transition: opacity .4s ease, transform var(--t-ressort) var(--ressort); width: 20px; z-index: 20; }
.jauge.plonge { opacity: 1; pointer-events: auto; transform: none; }
.jauge-ligne { background: linear-gradient(rgba(170, 220, 255, .55), rgba(170, 220, 255, .06)); bottom: 0; left: 50%; position: absolute; top: 0; width: 1px; }
.jauge-point {
  background: var(--bulle-reflet), rgba(120, 190, 255, .3);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(200, 230, 255, .45);
  height: 10px;
  left: 50%;
  margin: -5px 0 0 -5px;
  position: absolute;
  transition: transform .45s var(--ressort-rebond), background-color .3s ease;
  width: 10px;
}
.jauge-point::before { content: ''; inset: -10px; position: absolute; }
.jauge-point.ici { background: var(--bulle-reflet), var(--accent-hi); transform: scale(1.5); }
.jauge-point:hover { transform: scale(1.5); }
.jauge-point:active { transform: scale(1.2); transition-duration: .1s; }
/* Le titre de l'étape, en bulle, au survol ou au focus clavier. */
.jauge-point span {
  -webkit-backdrop-filter: var(--verre-fin);
  backdrop-filter: var(--verre-fin);
  background: rgba(20, 40, 70, .6);
  border-radius: 999px;
  box-shadow: inset 0 0 0 .5px rgba(200, 230, 255, .35), inset 0 1px 0 rgba(255, 255, 255, .2);
  color: var(--text);
  font-size: 13px;
  opacity: 0;
  padding: 5px 11px;
  pointer-events: none;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translate(8px, -50%) scale(.95);
  transform-origin: 100% 50%;
  transition: opacity .2s ease, transform .35s var(--ressort);
  white-space: nowrap;
}
.jauge-point.ici span, .jauge-point:hover span, .jauge-point:focus-visible span { transform: translate(0, -50%) scale(.667); }
.jauge-point:hover span, .jauge-point:focus-visible span { opacity: 1; }
.jauge-niveau {
  -webkit-backdrop-filter: var(--verre-fin);
  backdrop-filter: var(--verre-fin);
  background: var(--bulle-reflet), rgba(20, 40, 70, .55);
  border-radius: 999px;
  box-shadow: inset 0 0 0 .5px rgba(200, 230, 255, .4), inset 0 1px 0 rgba(255, 255, 255, .22);
  color: var(--dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 3px 9px;
  position: absolute;
  right: 18px;
  transform: translateY(-50%);
  white-space: nowrap;
}
.jauge-niveau b { color: var(--text); font-weight: 600; }
@media (max-width: 1180px) { .jauge { display: none; } }

/* ---------- Réglages du système ---------- */
@media (prefers-reduced-motion: reduce) {
  html, .messages { scroll-behavior: auto; }
  body { transform: none; transition: opacity .2s ease; }
  .msg.user, .msg.modele { animation: fondu .2s ease both; }
  @keyframes fondu { from { opacity: 0; } to { opacity: 1; } }
  .pipeline { filter: none; transform: none; transition: opacity .2s ease; }
  .tok, .jeton.nouveau, .led.vif, .curseur { animation: none; }
  .prob .barre i, .couche { transition: none; }
  .btn:active, .sugg:active, .back:active, .envoi:active, .descendre:active { transform: none; }
  .interrupteur::before { transition: transform .15s ease, background-color .15s ease; }
  input[type=range]::-webkit-slider-thumb { transition: none; }
  input[type=range]:active::-webkit-slider-thumb, input[type=range]:active::-moz-range-thumb { transform: none; }
  .pipeline::before { transition: opacity .2s ease; }
  .jauge, .jauge-point, .jauge-point span { transition: opacity .2s ease; }
}
/* Moins de transparence : le verre devient une surface pleine. */
@media (prefers-reduced-transparency: reduce) {
  body { background: var(--bg); }
  .top, .panel, .section::before, .descendre { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--cell); }
  .widget, .section.regard .widget { background: var(--cell-2); }
  .jauge-niveau, .jauge-point span { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--cell-2); }
}
@media (prefers-contrast: more) {
  :root { --dim: rgba(235, 235, 245, .82); --faint: rgba(235, 235, 245, .68); --sep: rgba(235, 235, 245, .45); --fill-2: rgba(120, 120, 128, .45); }
  .panel { box-shadow: inset 0 0 0 1px var(--sep); }
}
