/* Charte reprise de dumplingsandmore.fr :
   navy #1b1f2f · brique #c9372c · bleu #264fc2 · ambre #f6a623 · rose #e9b8b3
   Typographies du site : Manrope (interface) et Roboto Slab (titres). */

@font-face {
  font-family: "Manrope";
  src: url("fonts/Manrope.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-display: swap;
}

@font-face {
  font-family: "Roboto Slab";
  src: url("fonts/RobotoSlab.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #12151f;
  --panel: #1b1f2f;
  --panel-2: #252a3c;
  --line: #323848;
  --text: #f0ebe6;
  --muted: #969db2;
  --accent: #c9372c;         /* brique : identité, focus, sélection */
  --link: #6d8ce8;           /* bleu du site, éclairci pour le fond sombre */
  --ok: #2f9e73;             /* validé */
  --warn: #f6a623;           /* à revoir */
  --danger: #d2412f;         /* rejeté */
  --edit: #e9b8b3;           /* rose poudré : ligne modifiée */
  --radius: 8px;
  --sidebar: 272px;
  --font: "Manrope", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-title: "Roboto Slab", Georgia, serif;
}

[data-theme="light"] {
  --bg: #f7f3ef;
  --panel: #ffffff;
  --panel-2: #f0e9e3;
  --line: #e2d8d0;
  --text: #1b1f2f;
  --muted: #6c7183;
  --link: #264fc2;
  --ok: #227a58;
  --danger: #c9372c;
}

* { box-sizing: border-box; }

/* Indispensable : nos règles `display: flex` l'emportent sur la feuille de style
   du navigateur, donc l'attribut `hidden` seul ne masque rien. */
[hidden] { display: none !important; }

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

body {
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, .brand, #ctx-title, #project-name {
  font-family: var(--font-title);
  font-weight: 600;
  letter-spacing: -0.01em;
}

button, input, textarea { font: inherit; color: inherit; }

code {
  background: var(--panel-2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
}

kbd {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
}

.hint { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ sidebar */

#sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
  font-size: 17px;
  letter-spacing: 0.01em;
  color: var(--accent);
}

.back-link {
  display: block;
  margin: 12px 10px 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}
.back-link:hover { color: var(--text); background: var(--panel-2); }

.side-block { padding: 12px 10px 4px; }
.side-block h2, .side-block summary {
  margin: 0 0 8px;
  padding: 0 6px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: default;
}
.side-block summary { cursor: pointer; list-style: none; }
.side-block summary::-webkit-details-marker { display: none; }
.side-block summary::before { content: "▸ "; }
details[open] > summary::before { content: "▾ "; }

.pill {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
}

#sidebar .projects {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.projects li {
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 3px;
}
.projects li:hover { background: var(--panel-2); }
.projects li.active { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }

.proj-name {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proj-sub { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.mini {
  height: 3px;
  background: var(--panel-2);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.mini > i { display: block; height: 100%; background: var(--ok); }

.side-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.side-foot .hint { margin: 8px 0 0; }

/* ------------------------------------------------------- volets repliables */

/* Sur grand écran le volet reste dans le flux et se replie par une marge
   négative : le poste de travail récupère la place. Sous le point de rupture
   il passe en superposition (voir la requête média en fin de fichier).
   Aucune classe sur <body> = volet déplié sur grand écran, replié sur mobile :
   l'état par défaut est donc déjà le bon avant même que le script s'exécute. */
#sidebar { transition: margin-left 0.2s ease; }
body.nav-hidden #sidebar { margin-left: calc(-1 * var(--sidebar)); }

.brand-actions { display: flex; gap: 2px; }
#nav-toggle { flex-shrink: 0; font-size: 17px; line-height: 1; padding: 4px 9px; }

#scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.55);
}
#scrim:hover { filter: none; }

/* Libellés courts : seuls affichés quand la barre d'actions passe en colonne. */
.lbl-short { display: none; }

/* ------------------------------------------------------------------ boutons */

button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  background: var(--panel-2);
  transition: filter 0.12s;
}
button:hover { filter: brightness(1.15); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* L'action principale est la validation : elle porte la couleur « validé »,
   pas le brique de marque, qui reste réservé à l'identité et au rejet. */
.primary { background: var(--ok); color: #fff; font-weight: 600; }
.warn { background: transparent; border-color: var(--warn); color: var(--warn); }
.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.ghost:hover { color: var(--text); }
.small { padding: 5px 10px; font-size: 13px; }
.icon { background: transparent; padding: 4px 8px; color: var(--muted); }

/* ------------------------------------------------------------------ main */

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.centered {
  margin: auto;
  max-width: 620px;
  padding: 32px;
  text-align: center;
}
.centered h1 { font-size: 22px; }

#workspace { display: flex; flex-direction: column; height: 100%; min-height: 0; }

#topbar {
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#project-name { margin: 0; flex: 1; min-width: 0; font-size: 16px; font-weight: 650; }
.counters { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.counters .sep { opacity: 0.4; }

.progress {
  display: flex;
  height: 6px;
  margin: 10px -20px 0;
  background: var(--panel-2);
}
.bar { height: 100%; transition: width 0.2s; }
.bar.validated { background: var(--ok); }
.bar.review { background: var(--warn); }
.bar.rejected { background: var(--danger); }

.banner {
  margin: 10px 20px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.banner.error { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.banner span { flex: 1; }

#scroll { flex: 1; overflow-y: auto; padding: 18px 20px 8px; min-height: 0; }

.context { margin-bottom: 14px; }
.context-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
#ctx-title { margin: 0; font-size: 19px; line-height: 1.3; }
.context-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.context-meta a { color: var(--link); font-size: 13px; text-decoration: none; }
.context-meta a:hover { text-decoration: underline; }
.description { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.tag {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.tag.champ { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tag.edited { border-color: var(--edit); color: var(--edit); }
.tag.validated { border-color: var(--ok); color: var(--ok); }
.tag.review { border-color: var(--warn); color: var(--warn); }
.tag.rejected { border-color: var(--danger); color: var(--danger); }

.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panes.solo { grid-template-columns: 1fr; }

.pane { display: flex; flex-direction: column; min-width: 0; }
.pane-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.readonly, #editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 190px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.readonly { color: var(--muted); overflow-y: auto; max-height: 46vh; }

#editor {
  width: 100%;
  resize: vertical;
  outline: none;
  line-height: 1.6;
}
#editor:focus { border-color: var(--accent); }

#diff-box { margin-top: 16px; }
#diff ins { background: color-mix(in srgb, var(--ok) 28%, transparent); text-decoration: none; }
#diff del { background: color-mix(in srgb, var(--danger) 28%, transparent); }

.signals {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 4px;
  flex-wrap: wrap;
}
.issues { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 220px; }
.issue {
  font-size: 12px;
  border-radius: 20px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.issue.warn { border-color: var(--warn); color: var(--warn); }
.issue.dup { border-color: var(--edit); color: var(--edit); cursor: pointer; }

#note {
  flex: 1;
  min-width: 240px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
}
#note:focus { border-color: var(--accent); }

#actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
#actions .left, #actions .right { display: flex; gap: 8px; align-items: center; }
.check { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------------ drawer */

#drawer {
  width: 320px;
  flex: 0 0 320px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.drawer-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
#drawer-search {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  outline: none;
}
#drawer-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
#drawer-list li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
#drawer-list li:hover { background: var(--panel-2); }
#drawer-list li.active { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
#drawer-list .num { color: var(--muted); width: 42px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
#drawer-list .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--line); }
.dot.validated { background: var(--ok); }
.dot.review { background: var(--warn); }
.dot.rejected { background: var(--danger); }
.drawer-foot { padding: 10px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------ divers */

.mapper-grid { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; text-align: left; margin: 20px 0; }
.mapper-grid select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  width: 100%;
}
.row-actions { display: flex; justify-content: center; gap: 10px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 26px;
  max-width: 460px;
  width: 100%;
}
.modal-box h2 { margin-top: 0; font-size: 17px; }
.modal-box table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.modal-box td { padding: 5px 0; font-size: 14px; }
.modal-box td:first-child { width: 130px; white-space: nowrap; }

#toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 14px;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

/* ------------------------------------------------------------- menu d'accueil */

/* La page d'accueil n'a pas de volet : on rend au corps un flux normal. */
body.home { display: block; }

#home {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 16px;
}

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.brand-title { margin: 0; font-size: 26px; color: var(--accent); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.12s;
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; }
.tile-name { font-family: var(--font-title); font-size: 19px; font-weight: 600; }
.tile-desc { color: var(--muted); font-size: 14px; }
.tile .tag { margin-top: 6px; }
.tag.todo { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ rapports */

/* Le volet défile en entier : les mois s'empilent au fil des semaines. */
.report-months { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 12px; }

#reader { display: flex; flex-direction: column; height: 100%; min-height: 0; }
#reader #topbar { padding-bottom: 12px; }
#report-title { margin: 0; flex: 1; min-width: 0; font-size: 16px; font-weight: 650; }
.discuss-link {
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.discuss-link:hover { color: var(--text); border-color: var(--accent); }

.report { max-width: 760px; margin: 0 auto; font-size: 16px; line-height: 1.65; }
.report .line { white-space: pre-wrap; overflow-wrap: anywhere; }
.report .gap { height: 0.7em; }
.report h3 {
  margin: 14px 0 2px;
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}
.report strong { font-weight: 700; }

/* ------------------------------------------------------------------ assistant */

.side-actions { display: flex; flex-direction: column; gap: 6px; padding: 12px 10px 0; }
.side-actions button { width: 100%; text-align: left; }
.conv-block { flex: 1; min-height: 0; overflow-y: auto; }
.proj-sub .sub-cost { flex-shrink: 0; margin-left: 8px; }
.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--link);
  font-size: inherit;
  cursor: pointer;
}

#chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
#chat #topbar { padding-bottom: 12px; }
#chat-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#chat .banner { margin-bottom: 4px; }

.intro, .thread, #live { max-width: 820px; margin-left: auto; margin-right: auto; }
.intro { padding: 8px 0 16px; }
.intro h2 { margin: 0 0 8px; font-size: 19px; }
.intro ul { padding-left: 20px; }
.intro li { margin-bottom: 4px; }

.thread { display: flex; flex-direction: column; gap: 10px; }

.msg { line-height: 1.6; overflow-wrap: anywhere; }
.msg.user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--panel-2);
  border-radius: 12px 12px 4px 12px;
  padding: 10px 14px;
  white-space: pre-wrap;
}
.msg-author { font-size: 12px; color: var(--muted); font-weight: 600; }
.msg-author:empty { display: none; }
.msg.assistant > :first-child { margin-top: 0; }
.msg.assistant > :last-child { margin-bottom: 0; }
.msg.assistant p, .msg.assistant ul, .msg.assistant ol { margin: 0 0 10px; }
.msg.assistant ul, .msg.assistant ol { padding-left: 22px; }
.msg.assistant h3, .msg.assistant h4, .msg.assistant h5 {
  margin: 14px 0 6px;
  font-family: var(--font-title);
  font-size: 16px;
}
.msg.assistant a { color: var(--link); }
.msg.assistant pre, .tool-details pre, .permission pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 6px 0;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 340px;
  overflow-y: auto;
}
.msg.assistant pre code { background: none; padding: 0; }
.table-wrap { overflow-x: auto; margin: 0 0 10px; }
.msg.assistant table { border-collapse: collapse; font-size: 14px; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.msg.assistant th { background: var(--panel-2); }
.msg.error {
  border: 1px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-radius: var(--radius);
  padding: 10px 14px;
}
#live { margin-top: 10px; opacity: 0.85; }
.caret {
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--muted);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.tool { font-size: 13px; color: var(--muted); }
.tool summary {
  display: flex;
  align-items: baseline;
  gap: 7px;
  cursor: pointer;
  list-style: none;
  padding: 2px 0;
}
.tool summary::-webkit-details-marker { display: none; }
.tool-label { font-weight: 600; flex-shrink: 0; }
.tool-subject { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-status { margin-left: auto; flex-shrink: 0; color: var(--ok); }
.tool.failed .tool-status { color: var(--danger); }
.tool.danger .tool-label { color: var(--warn); }
.tool-error { margin: -6px 0 0 24px; font-size: 12px; color: var(--danger); }
pre.del { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--panel)); }
pre.ins { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--panel)); }
pre.result { color: var(--muted); }
.todos { margin: 6px 0; padding-left: 20px; }
.todos .completed { text-decoration: line-through; opacity: 0.6; }
.todos .in_progress { color: var(--text); font-weight: 600; }

.permission {
  border: 1px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 7%, var(--panel));
  border-radius: 12px;
  padding: 12px 14px;
}
.permission.danger { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--panel)); }
.permission.allowed { border-color: var(--ok); background: var(--panel); }
.permission.refused { border-color: var(--line); background: var(--panel); opacity: 0.8; }
.permission-head { font-size: 14px; }
.permission-subject { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.permission-warning { margin: 8px 0 0; font-size: 13px; color: var(--danger); font-weight: 600; }
.permission-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.permission-note {
  flex: 1;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  outline: none;
}
.permission-note:focus { border-color: var(--accent); }
.permission-verdict { margin: 8px 0 0; font-size: 13px; font-weight: 600; }
.permission.allowed .permission-verdict { color: var(--ok); }
.permission.refused .permission-verdict { color: var(--muted); }

.turn-end { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

#composer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom, 0px));
}
#composer textarea {
  display: block;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  min-height: 70px;
  max-height: 40vh;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
  line-height: 1.5;
}
#composer textarea:focus { border-color: var(--accent); }
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  max-width: 820px;
  margin: 8px auto 0;
}
.composer-actions .hint { margin-right: auto; }
.working { max-width: 820px; margin: 0 auto 8px; font-size: 13px; color: var(--muted); }
.pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 1.2s ease-in-out infinite;
}
.pulse.warn { background: var(--warn); }
@keyframes pulse { 50% { opacity: 0.25; } }

#who-input {
  width: 100%;
  margin: 8px 0 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
}

/* ------------------------------------------------------------------ accès */

.home-actions { display: flex; align-items: center; gap: 8px; }

.access-box {
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 16px;
}
.access-box h2 { font-size: 20px; margin: 18px 0 8px; }
.access-box a { color: var(--link); }
.access-code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  margin: 18px 0;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
}
.access-form { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.access-form input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  font-size: 16px;
  outline: none;
}
.access-form input:focus { border-color: var(--accent); }
.pin-error { color: var(--danger); font-weight: 600; }

#access-requests {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 75;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}
.access-request {
  background: var(--panel);
  border: 1px solid var(--warn);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.access-request-code { margin-top: 6px; font-size: 15px; }
.access-request-code b { font-family: ui-monospace, Menlo, monospace; letter-spacing: 0.08em; }
.access-request-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.device-list { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 10px; }
.device {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}
.device.revoked { opacity: 0.55; }
.device-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.device-name { font-weight: 600; }

/* ----------------------------------------------------------- écrans étroits */

/* Dès que deux colonnes de texte deviennent trop maigres pour être lues, on
   empile avant et après. La flèche remplace la lecture gauche→droite perdue :
   sans elle, rien ne dit que le second bloc découle du premier. */
@media (max-width: 1000px) {
  .panes { grid-template-columns: 1fr; gap: 10px; }
  .panes:not(.solo) #pane-avant::after {
    content: "↓";
    display: block;
    margin-top: 8px;
    text-align: center;
    font-size: 15px;
    color: var(--muted);
    opacity: 0.65;
  }
}

/* Mobile : les deux volets quittent le flux et se superposent au poste de
   travail, qui garde ainsi toute la largeur. */
@media (max-width: 860px) {
  /* dvh et non vh : la barre d'adresse mobile fausse vh et tronque la barre
     d'actions, qui doit rester atteignable au pouce. */
  html, body { height: 100dvh; }

  #sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 300px);
    flex: none;
    margin-left: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  }
  body.nav-open #sidebar { transform: none; }

  #drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(88vw, 320px);
    flex: none;
    z-index: 60;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: drawer-in 0.22s ease;
  }
  @keyframes drawer-in { from { transform: translateX(100%); } }

  body.nav-open #scrim,
  body.drawer-open #scrim { display: block; }

  /* Cibles tactiles : 44 px, sous quoi le doigt rate le bouton. */
  button { min-height: 44px; padding: 10px 14px; }
  .icon, .small { min-height: 38px; }
  .back-link { padding: 11px 12px; }
  #home { padding: 20px 16px; }
  .lbl-full { display: none; }
  .lbl-short { display: inline; }

  /* 16 px : en dessous, iOS zoome tout seul à la mise au point du champ et
     l'utilisateur se retrouve avec une mise en page décalée. */
  #editor, #note, #drawer-search { font-size: 16px; }

  #topbar { padding: 10px 14px 0; }
  .topbar-line { flex-wrap: wrap; gap: 8px; }
  #project-name, #report-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #chat-title { font-size: 15px; }
  #access-requests { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .device { flex-wrap: wrap; }
  #composer { padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px)); }
  #composer textarea, .permission-note, #who-input { font-size: 16px; }
  #composer textarea { min-height: 56px; }
  .msg.user { max-width: 92%; }
  .report { font-size: 15px; }
  .counters { order: 3; width: 100%; flex-wrap: wrap; gap: 6px; font-size: 12px; }
  .progress { margin: 8px -14px 0; }
  .banner { margin: 10px 14px 0; flex-wrap: wrap; }

  #scroll { padding: 14px 14px 10px; }
  .context-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  #ctx-title { font-size: 17px; }
  .context-meta { flex-wrap: wrap; }

  /* Le volet « avant » est une référence qu'on relit, pas la zone de travail :
     il cède la hauteur à l'éditeur et défile sur lui-même. */
  .readonly { max-height: 30vh; min-height: 110px; }
  #editor { min-height: 160px; }

  .signals { flex-direction: column; align-items: stretch; }
  #note { width: 100%; min-width: 0; }

  #actions {
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  #actions .left { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  #actions .right { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #btn-validate { grid-column: 1 / -1; }

  .modal-box { margin: 0 14px; }
  .mapper-grid { grid-template-columns: 1fr; gap: 4px 0; }
}
