:root {
  --bg: #0e1116;
  --panel: #151a22;
  --panel-2: #1b212b;
  --line: #262e3b;
  --text: #d7dee9;
  --muted: #8b97a8;
  --accent: #f0a04b;
  --accent-2: #6cb6ff;
  --ok: #6ddf8f;
  --ko: #ff7b72;
  --warn: #e3b341;
  --scroll: #333d4d;
  --scroll-hover: #4a586e;
  --radius: 10px;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* La barre de defilement par defaut de Chrome sous Linux est large et claire :
   sur un exercice elle tombe pile entre les deux volets, et se voit plus que le
   contenu. On la rend fine et sombre partout. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) transparent;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
}

body { display: flex; }

button { font-family: inherit; font-size: 14px; cursor: pointer; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- */
/* Barre laterale                                                     */
/* ---------------------------------------------------------------- */

/* display:flex ci-dessous l'emporterait sur l'attribut hidden : on le neutralise. */
#sidebar[hidden] { display: none; }

#sidebar {
  width: 268px;
  min-width: 268px;
  height: 100vh;
  height: 100dvh;
  /* Seule la liste des jours defile : les liens de reference et le bouton de
     remise a zero restent atteignables sans scroller toute la barre. */
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.back-home {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  padding: 2px 0;
}
.back-home:hover { color: var(--text); text-decoration: none; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand:hover .brand-title { color: var(--accent); }

/* La marque est une boite de hauteur fixe : les accolades et le logo sont
   centres par le flex, pas par les metriques de la police. */
.brand-mark, .lab-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1;
  font-family: var(--mono);
  color: var(--accent);
  background: var(--panel-2);
  border: 1px solid var(--line);
  flex: none;
}
.brand-mark {
  font-size: 20px;
  height: 36px;
  min-width: 44px;
  padding: 0 8px;
  border-radius: 8px;
}
.mark-logo { width: 1.05em; height: 1.05em; display: block; }
.mark-brace { display: block; }
.brand-title { font-weight: 650; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--muted); }

.global-progress { font-size: 12px; color: var(--muted); }
.gp-head { display: flex; justify-content: space-between; margin-bottom: 5px; }

.bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffcf87); transition: width .3s; }

#daylist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-right: -6px;
  padding-right: 6px;
}

.day-item {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  border: 1px solid transparent;
}
.day-item:hover { background: var(--panel-2); text-decoration: none; }
.day-item.active { background: var(--panel-2); border-color: var(--line); }
.day-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day-num { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.day-name { font-size: 13.5px; font-weight: 550; }
.day-count { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.day-item .bar { margin-top: 6px; height: 4px; }
.day-item.done .day-num::after { content: " OK"; color: var(--ok); }

.side-links { display: flex; flex-direction: column; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.side-links a { font-size: 13px; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.side-links a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 10px;
}
.ghost:hover { color: var(--text); border-color: var(--muted); }
.ghost.small { font-size: 12px; padding: 5px 8px; }

/* ---------------------------------------------------------------- */
/* Zone principale                                                    */
/* ---------------------------------------------------------------- */

#main { flex: 1; min-width: 0; height: 100vh; height: 100dvh; overflow-y: auto; }

.page { max-width: 980px; margin: 0 auto; padding: 26px 30px 90px; }
.page.wide { max-width: none; padding: 0; height: 100%; }

.crumb { font-size: 12px; color: var(--muted); font-family: var(--mono); margin-bottom: 6px; }
h1.page-title { font-size: 26px; margin: 0 0 6px; letter-spacing: -.2px; }
.page-sub { color: var(--muted); margin: 0 0 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 22px; }
.chip {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.chip.accent { color: var(--accent); border-color: #4a3a24; }

/* ---------------------------------------------------------------- */
/* Page d'accueil : choisir un lab                                    */
/* ---------------------------------------------------------------- */

.page.home { max-width: 1080px; }
.home-hero { margin-bottom: 26px; }
.home-hero .page-title { font-size: 32px; }
.home-hero .page-sub { max-width: 720px; }

.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 14px;
  margin-bottom: 34px;
}

.lab-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
}
.lab-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  background: var(--panel-2);
}
.lab-card-head { display: flex; align-items: center; gap: 12px; }
.lab-mark {
  font-size: 22px;
  height: 42px;
  min-width: 50px;
  padding: 0 10px;
  border-radius: 10px;
}
.lab-id { flex: 1; min-width: 0; }
.lab-title { font-size: 17px; font-weight: 650; letter-spacing: -.2px; }
.lab-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.lab-badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 99px;
  background: #17301f;
  border: 1px solid #2c5a38;
  color: var(--ok);
  white-space: nowrap;
}
.lab-badge.open { background: var(--panel-2); border-color: var(--line); color: var(--accent); }
.lab-tagline { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.lab-card .chips { margin: 0; }
.lab-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}
.lab-go { color: var(--accent); }

/* Sommaire d'un jour */

.steps { display: flex; flex-direction: column; gap: 8px; }
.step-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.step-card:hover { border-color: #3a4557; background: var(--panel-2); text-decoration: none; }
.step-icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 14px;
}
.step-card.done .step-icon { background: #17301f; border-color: #2c5a38; color: var(--ok); }
.step-main { flex: 1; min-width: 0; }
.step-title { font-size: 14.5px; font-weight: 550; }
.step-kind { font-size: 11px; color: var(--muted); font-family: var(--mono); text-transform: uppercase; letter-spacing: .5px; }
.step-go { color: var(--muted); font-family: var(--mono); font-size: 12px; }

/* ---------------------------------------------------------------- */
/* Markdown                                                           */
/* ---------------------------------------------------------------- */

.md { line-height: 1.65; }
.md h1 { font-size: 23px; margin: 26px 0 10px; }
.md h2 { font-size: 19px; margin: 26px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 16px; margin: 20px 0 6px; color: #eaf0f8; }
.md p { margin: 10px 0; }
.md ul, .md ol { margin: 10px 0; padding-left: 22px; }
.md li { margin: 4px 0; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 22px 0; }
.md strong { color: #fff; font-weight: 620; }
.md blockquote { margin: 12px 0; padding: 2px 14px; border-left: 3px solid var(--line); color: var(--muted); }
.md table { border-collapse: collapse; margin: 14px 0; font-size: 14px; width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--panel-2); font-weight: 600; }
.md code { font-family: var(--mono); font-size: 13px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.md pre { margin: 12px 0; }
.md pre code { display: block; padding: 0; background: none; border: none; }

.codeblock {
  position: relative;
  background: #0b0e13;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 14px 0;
}
.codeblock pre { margin: 0; padding: 13px 15px; overflow-x: auto; }
.codeblock code { font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.codeblock .cb-actions { position: absolute; top: 6px; right: 8px; display: flex; gap: 5px; opacity: 0; transition: opacity .15s; }
.codeblock:hover .cb-actions { opacity: 1; }
.cb-actions button { font-size: 11px; padding: 3px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.cb-actions button:hover { color: var(--text); }

/* Encadres */
.callout {
  margin: 14px 0;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  border-left-width: 3px;
}
.callout > .callout-title { font-weight: 620; font-size: 13px; margin-bottom: 4px; letter-spacing: .2px; }
.callout p:first-of-type { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.callout.piege { border-left-color: var(--ko); }
.callout.piege .callout-title { color: var(--ko); }
.callout.astuce { border-left-color: var(--ok); }
.callout.astuce .callout-title { color: var(--ok); }
.callout.python { border-left-color: var(--accent-2); }
.callout.python .callout-title { color: var(--accent-2); }
.callout.note { border-left-color: var(--warn); }
.callout.note .callout-title { color: var(--warn); }
.callout.jury { border-left-color: #c792ea; }
.callout.jury .callout-title { color: #c792ea; }

/* Coloration Java */
.tok-key { color: #f0a04b; }
.tok-str { color: #a5d6a7; }
.tok-com { color: #5d6b7f; font-style: italic; }
.tok-num { color: #d19a66; }
.tok-type { color: #6cb6ff; }
.tok-fn { color: #e6c07b; }
.tok-ann { color: #c792ea; }

/* ---------------------------------------------------------------- */
/* Quiz                                                               */
/* ---------------------------------------------------------------- */

.quiz-q {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 14px 0;
}
.quiz-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.quiz-num { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.quiz-text { font-weight: 550; }
.quiz-options { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.quiz-opt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
  font-size: 14px;
}
.quiz-opt:hover { border-color: #43506a; }
.quiz-opt input { margin-top: 2px; accent-color: var(--accent); }
.quiz-opt.correct { border-color: #2c5a38; background: #142219; }
.quiz-opt.wrong { border-color: #5a2c2c; background: #221414; }
.quiz-opt code { font-family: var(--mono); font-size: 13px; }
.quiz-answer { margin-top: 12px; display: flex; gap: 8px; align-items: center; }
.quiz-answer input[type=text] {
  flex: 1;
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}
.quiz-answer textarea {
  flex: 1;
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 74px;
  resize: vertical;
}
.quiz-feedback { margin-top: 12px; font-size: 14px; padding: 10px 12px; border-radius: 8px; display: none; }
.quiz-feedback.show { display: block; }
.quiz-feedback.ok { background: #142219; border: 1px solid #2c5a38; }
.quiz-feedback.ko { background: #221414; border: 1px solid #5a2c2c; }
.quiz-feedback .fb-title { font-weight: 600; margin-bottom: 4px; }
/* En cas d'erreur la bonne reponse est toujours ecrite noir sur blanc :
   l'explication seule laisse parfois deviner. */
.quiz-feedback .fb-answer {
  margin: 6px 0 2px;
  padding: 7px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  font-size: 13.5px;
}
.quiz-feedback .fb-answer b { color: var(--text); }
.quiz-feedback .fb-answer code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  white-space: pre-wrap;
}
.quiz-score { font-family: var(--mono); font-size: 14px; }

/* ---------------------------------------------------------------- */
/* Exercice : deux volets                                             */
/* ---------------------------------------------------------------- */

.ex-layout { display: flex; height: 100vh; height: 100dvh; position: relative; }
.ex-left {
  /* --ex-editor : part de la largeur donnee a l'editeur, reglee dans la barre laterale. */
  width: calc(100% - var(--ex-editor, 56%));
  min-width: 260px;
  overflow-y: auto;
  padding: 22px 26px 60px;
  border-right: 1px solid var(--line);
}
.ex-right { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Volet de droite replie : l'enonce prend toute la largeur, et un seul bouton
   flottant permet de revenir a l'editeur. */
.reopen-editor { display: none; }
.ex-layout.editor-hidden .ex-right { display: none; }
.ex-layout.editor-hidden .ex-left {
  width: 100%;
  min-width: 0;
  border-right: none;
  padding: 22px 30px 90px;
}
.ex-layout.editor-hidden .ex-left > * { max-width: 900px; margin-left: auto; margin-right: auto; }
.ex-layout.editor-hidden .reopen-editor {
  display: block;
  position: fixed;
  top: 16px;
  right: 22px;
  z-index: 30;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}

.ex-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 550;
}
.btn:hover { border-color: #4a5870; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1206; }
.btn.primary:hover { background: #ffb865; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.icon {
  padding: 6px 9px;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
}
.btn.icon:hover { color: var(--text); }
.kbd { font-family: var(--mono); font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; margin-left: 4px; }

.tabs { display: flex; gap: 2px; padding: 6px 10px 0; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  background: none;
  white-space: nowrap;
}
.tab.active { background: #0b0e13; border-color: var(--line); color: var(--text); }
.tab.dirty::after { content: " *"; color: var(--accent); }

.editor-host { flex: 1; min-height: 0; position: relative; background: #0b0e13; }

.console {
  height: 38%;
  min-height: 120px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.console-tabs { display: flex; gap: 2px; padding: 5px 10px 0; border-bottom: 1px solid var(--line); }
.console-tabs .tab { font-family: var(--sans); }
.console-body { flex: 1; overflow: auto; padding: 10px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; }
.console-body .placeholder { color: var(--muted); font-family: var(--sans); }

.verdict { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.verdict.ok { background: #142219; color: var(--ok); }
.verdict.ko { background: #221414; color: var(--ko); }
.verdict.run { background: var(--panel-2); color: var(--muted); }

.test-row { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.test-head { display: flex; gap: 8px; align-items: center; padding: 7px 11px; background: var(--panel-2); font-size: 12.5px; }
.test-head .dot { width: 8px; height: 8px; border-radius: 99px; background: var(--ko); }
.test-row.ok .test-head .dot { background: var(--ok); }
.test-body { padding: 9px 11px; }

.difftable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.difftable td { padding: 2px 8px; vertical-align: top; border-bottom: 1px solid #1e242e; }
.difftable td.n { color: var(--muted); text-align: right; width: 34px; user-select: none; }
.difftable td.side { white-space: pre-wrap; word-break: break-all; width: 50%; }
.difftable td.exp { border-right: 1px solid var(--line); }
.difftable tr.bad td.exp { color: var(--ok); background: #14201a; }
.difftable tr.bad td.got { color: var(--ko); background: #201414; }
.difftable .eol { color: #445; }
.diff-legend { color: var(--muted); font-size: 11.5px; margin-bottom: 6px; font-family: var(--sans); }

.check-item { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
.check-item .mark { font-family: var(--mono); }
.check-item.ok .mark { color: var(--ok); }
.check-item.ko .mark { color: var(--ko); }

.hints-title { font-size: 17px; margin: 26px 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.hint-box { margin-top: 10px; }
.hint-box summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; }
.hint-box summary:hover { color: var(--text); }

.ex-meta { font-family: var(--mono); font-size: 12.5px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 13px; margin: 12px 0; }
.ex-meta div { margin: 2px 0; }
.ex-meta b { color: var(--text); font-weight: 600; }

.nav-bottom { display: flex; justify-content: space-between; gap: 10px; margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line); }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 99px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spinner {
  width: 13px; height: 13px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 99px;
  display: inline-block;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .ex-layout { flex-direction: column; height: auto; }
  .ex-left { width: auto; min-width: 0; border-right: none; border-bottom: 1px solid var(--line); }
  .ex-right { height: 80vh; }
  .lab-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- */
/* Editeur                                                            */
/* ---------------------------------------------------------------- */

.ed { position: absolute; inset: 0; display: flex; background: #0b0e13; }
.ed-gutter {
  width: 46px;
  padding: 12px 8px 12px 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: #3f4b5e;
  background: #0b0e13;
  border-right: 1px solid var(--line);
  overflow: hidden;
  white-space: pre;
  user-select: none;
}
.ed-area { position: relative; flex: 1; min-width: 0; }
.ed-hl, .ed-input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  tab-size: 4;
  white-space: pre;
  word-wrap: normal;
  border: 0;
}
/* contain : recolorier le calque ne force pas le navigateur a repeindre la
   zone du caret, qui disparaissait quand on gardait Supprimer enfonce. */
.ed-hl { overflow: hidden; pointer-events: none; color: var(--text); contain: layout paint; }
.ed-hl code { font: inherit; }
.ed-input {
  overflow: auto;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--accent);
  outline: none;
}
/* Fond translucide : le texte colore du calque du dessous reste lisible sous
   la selection, qui sinon le recouvre completement. */
.ed-input::selection { background: rgba(88, 143, 214, .34); color: transparent; }

.btn.primary .kbd { color: #6b4a17; border-color: #c07f31; }

.quiz-kind { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-bottom: 6px; }

/* Liste verticale de fichiers, pour les exercices a nombreux fichiers */
.editor-split { flex: 1; min-height: 0; display: flex; }
.filelist {
  width: 186px;
  min-width: 186px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.filelist .tab {
  text-align: left;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filelist .tab.active { background: #0b0e13; border-color: var(--line); color: var(--text); }
.editor-split .editor-host { position: relative; flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- */
/* Barre laterale : replier, regler la largeur de l'editeur           */
/* ---------------------------------------------------------------- */

.side-top { display: flex; align-items: center; gap: 6px; }
.side-top .back-home {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

/* Tout sauf la ligne du haut : ce bloc disparait quand la barre est repliee. */
.side-body { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }

.side-width { display: flex; flex-direction: column; gap: 5px; }
.side-width[hidden] { display: none; }
.side-width-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}
.side-width input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); }

/* Repliee : il ne reste qu'un rail avec le bouton pour la rouvrir. */
body.nav-collapsed #sidebar { width: 48px; min-width: 48px; padding: 16px 8px; }
body.nav-collapsed .side-body { display: none; }
body.nav-collapsed .side-top { justify-content: center; }
body.nav-collapsed .side-top .back-home,
body.nav-collapsed #nav-width { display: none; }

#nav-fab, #nav-backdrop { display: none; }

/* ---------------------------------------------------------------- */
/* Telephone                                                          */
/* ---------------------------------------------------------------- */

@media (max-width: 860px) {
  /* La barre laterale passe par-dessus la page au lieu de lui voler 268 px. */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(86vw, 300px);
    min-width: 0;
    z-index: 60;
    box-shadow: 0 0 40px rgba(0, 0, 0, .6);
    transition: transform .18s ease;
  }
  body.nav-collapsed #sidebar {
    width: min(86vw, 300px);
    min-width: 0;
    padding: 16px 14px;
    transform: translateX(-100%);
  }
  body.nav-collapsed .side-body { display: flex; }
  body.nav-collapsed .side-top { justify-content: flex-start; }
  body.nav-collapsed .side-top .back-home { display: block; }
  body.nav-collapsed #nav-width { display: grid; }

  #nav-fab {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 55;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    font-size: 16px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
  }
  body.nav-collapsed #nav-fab { display: grid; }
  body:not(.nav-collapsed) #nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(5, 7, 10, .6);
  }
  /* Pas de lab ouvert : pas de barre laterale, donc pas de bouton pour l'ouvrir. */
  body.no-nav #nav-fab, body.no-nav #nav-backdrop { display: none; }

  /* Le bouton flottant occupe le coin haut gauche : on lui laisse la place. */
  .page { padding: 54px 16px 70px; }
  body.no-nav .page { padding-top: 22px; }
  .ex-left { padding: 54px 16px 36px; }
  .ex-layout.editor-hidden .ex-left { padding: 54px 16px 70px; }
  .ex-layout.editor-hidden .reopen-editor { top: 10px; right: 12px; }

  /* En colonne, l'editeur et la console ont besoin d'une hauteur explicite. */
  .ex-right { height: auto; }
  .editor-host, .editor-split { min-height: 46vh; }
  .console { height: auto; min-height: 160px; max-height: 46vh; }

  /* Sous 16 px, iOS zoome des qu'on touche le champ : les deux calques
     doivent garder exactement la meme metrique, sinon le texte se decale. */
  .ed-hl, .ed-input { font-size: 16px; padding: 12px 12px; }
  .ed-gutter { width: 54px; font-size: 16px; }

  .kbd { display: none; }
  .ex-toolbar { gap: 6px; padding: 8px 10px; }
  .nav-bottom { flex-direction: column; align-items: stretch; }
  .nav-bottom > .btn { display: block; text-align: center; }
  .nav-bottom > div { display: flex; gap: 8px; }
  .nav-bottom > div > .btn { flex: 1; text-align: center; }
  h1.page-title { font-size: 22px; }
  .difftable td.side { word-break: break-word; }
}
