/* Ruche: mobile first, one column; side rail on large screens.
   Colors as tokens (:root), redefined for the dark theme. */
:root, :root[data-theme="light"] {
  --fond: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --code: #e8eaef;            /* code background, readable on --fond */
  --texte: #16181d;
  --discret: #5e636e;
  --bordure: #e1e4e9;
  --accent: #b77a00;          /* hive gold: icons, borders, focus */
  --lien: #8c5c00;            /* gold readable as small text (AA) */
  --miel: #f2b632;            /* fill of the main actions */
  --encre: #2a1d03;           /* text on the honey color */
  --accent-texte: var(--encre);
  --danger: #c4352b;
  --succes: #1f9d57;
  --ombre: 0 1px 2px rgb(16 18 24 / 0.06), 0 8px 24px rgb(16 18 24 / 0.08);

  --police: "Inter var", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,
    "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --police-code: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --marge: 16px;
  --tactile: 44px;
  --entete: 52px;
  --barre: 58px;              /* tab bar, outside the notch */
  --rail: 88px;               /* tab bar as a rail (large screen) */
  --rayon: 14px;
  --largeur: 42rem;
  /* Side margins that respect the notch in landscape. */
  --marge-g: max(var(--marge), env(safe-area-inset-left));
  --marge-d: max(var(--marge), env(safe-area-inset-right));
  /* Hexagon with softened corners: avatars and hive icons. */
  --hexagone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 40'%3E%3Cpath d='M18 3.5 31.5 11.25v17.5L18 36.5 4.5 28.75v-17.5z' stroke='%23000' stroke-width='6' stroke-linejoin='round'/%3E%3C/svg%3E");
  color-scheme: light dark;
}

/* Forced light (data-theme="light") wins over the OS dark mode below. */
:root[data-theme="light"] { color-scheme: light; }

/* Dark tokens, twice: OS dark mode (theme auto) and forced dark. Keep both
   copies identical (TestDarkTokenBlocksMatch). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #121318;
    --surface: #1a1c22;
    --surface-2: #23262d;
    --code: #22252c;
    --texte: #eceef2;
    --discret: #9ca1ac;
    --bordure: #2b2e36;
    --accent: #e6a92a;
    --lien: #f2b84a;
    --miel: #eeae2f;
    --encre: #1d1402;
    --danger: #ff7a6e;
    --succes: #4cc985;
    --ombre: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px rgb(0 0 0 / 0.35);
  }
}

:root[data-theme="dark"] {
  --fond: #121318;
  --surface: #1a1c22;
  --surface-2: #23262d;
  --code: #22252c;
  --texte: #eceef2;
  --discret: #9ca1ac;
  --bordure: #2b2e36;
  --accent: #e6a92a;
  --lien: #f2b84a;
  --miel: #eeae2f;
  --encre: #1d1402;
  --danger: #ff7a6e;
  --succes: #4cc985;
  --ombre: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

/* --- Base --- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 var(--police);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.avec-onglets {
  padding-bottom: calc(var(--barre) + env(safe-area-inset-bottom) + 24px);
}

[hidden] { display: none !important; }

a { color: var(--lien); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }

h1 {
  margin: 20px 0 16px;
  font-size: 1.625rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

h2 {
  margin: 28px 0 10px;
  font-size: 1.0625rem;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.01em;
}

code, pre { font-family: var(--police-code); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: color-mix(in srgb, var(--miel) 40%, transparent); }

.vide, .discret { color: var(--discret); }

.masque {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Header --- */

.entete {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(var(--entete) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--marge-d) 0 var(--marge-g);
  border-bottom: 1px solid color-mix(in srgb, var(--bordure) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
}

.marque {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.marque img { width: 28px; height: 28px; border-radius: 8px; }

.theme { margin: 0 0 0 auto; }   /* theme button, right next to logout */
.deconnexion { margin: 0; }
.deconnexion button { margin-right: -10px; }

.contenu {
  max-width: var(--largeur);
  margin: 0 auto;
  padding: 0 var(--marge-d) var(--marge) var(--marge-g);
}

/* --- Buttons and fields --- */

button, .bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tactile);
  min-width: var(--tactile);
  padding: 0 18px;
  border: 1px solid var(--bordure);
  border-radius: 12px;
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}
button:hover, .bouton:hover { border-color: color-mix(in srgb, var(--texte) 22%, var(--bordure)); }
button:active, .bouton:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }

.bouton.principal, button.principal {
  width: 100%;
  border-color: transparent;
  background: var(--miel);
  color: var(--encre);
  font-weight: 650;
  box-shadow: inset 0 -1px 0 rgb(0 0 0 / 0.12);
}
.bouton.principal:hover, button.principal:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--miel) 88%, var(--encre));
}

button.lien {
  min-width: 0;
  border: 0;
  background: none;
  padding: 0 10px;
  color: var(--discret);
  font-weight: 500;
}
button.lien:hover { color: var(--texte); }

button.icone { padding: 0; width: var(--tactile); border-radius: 50%; }
button.icone svg, .bouton svg { width: 20px; height: 20px; flex: none; }

label { font-size: 0.875rem; font-weight: 600; color: var(--discret); }

input, textarea, select {
  display: block;
  width: 100%;
  min-height: var(--tactile);
  margin-top: 6px;
  padding: 10px 14px;
  border: 1px solid var(--bordure);
  border-radius: 12px;
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-size: 1rem;          /* 16 px: no automatic zoom on iOS */
  font-weight: 400;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { line-height: 1.45; resize: vertical; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--discret) 80%, transparent); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
select {
  appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--discret) 50%),
    linear-gradient(-45deg, transparent 50%, var(--discret) 50%);
  background-position: right 20px center, right 15px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

input[type="checkbox"], input[type="radio"] {
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

small { display: block; margin-top: 6px; font-size: 0.8125rem; }

form > p, .profil > p { margin: 0 0 18px; }

fieldset {
  margin: 0 0 18px;
  padding: 4px 16px 6px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: var(--surface);
}
legend { padding: 0 6px; font-size: 0.875rem; font-weight: 600; color: var(--discret); }
fieldset label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tactile);
  color: var(--texte);
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
}
fieldset label + label { border-top: 1px solid var(--bordure); }
fieldset .vide { display: block; padding: 10px 0; }
/* Lone checkbox outside a fieldset (« Dossier principal ») */
p > label:has(> input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tactile);
  color: var(--texte);
  font-size: 1rem;
  font-weight: 400;
}

.erreur-form, .erreur-saisie {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  color: var(--danger);
  font-weight: 550;
}

details {
  margin: 0 0 18px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: var(--surface);
}
details details { margin: 0; border: 0; border-top: 1px solid var(--bordure); border-radius: 0; }
summary {
  display: flex;
  align-items: center;
  min-height: var(--tactile);
  padding: 0 16px;
  cursor: pointer;
  font-weight: 550;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 12px;
  border-right: 2px solid var(--discret);
  border-bottom: 2px solid var(--discret);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
details[open] > summary::before { transform: rotate(45deg); }
details pre { margin: 0; padding: 0 16px 14px; font-size: 0.8125rem; color: var(--discret); }

/* --- Hexagonal avatars --- */
/* The tint comes from the last digit of the agent id (data-teinte):
   stable from one page to another, without server-side computation. */

[data-teinte$="0"] { --teinte: #e0a526; }
[data-teinte$="1"] { --teinte: #1fa3a3; }
[data-teinte$="2"] { --teinte: #7b61d1; }
[data-teinte$="3"] { --teinte: #d9577a; }
[data-teinte$="4"] { --teinte: #2f8fdc; }
[data-teinte$="5"] { --teinte: #6aa62f; }
[data-teinte$="6"] { --teinte: #e0703a; }
[data-teinte$="7"] { --teinte: #4b63c9; }
[data-teinte$="8"] { --teinte: #1d9c6a; }
[data-teinte$="9"] { --teinte: #8a8f99; }
.message-human { --teinte: var(--miel); }

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 40px;
  background: color-mix(in srgb, var(--teinte, var(--discret)) 24%, var(--surface));
  color: color-mix(in srgb, var(--teinte, var(--discret)) 70%, var(--texte));
  font-size: 19px;
  line-height: 1;
  -webkit-mask: var(--hexagone) center / 100% 100% no-repeat;
  mask: var(--hexagone) center / 100% 100% no-repeat;
  user-select: none;
}
.message-human .avatar { background: var(--miel); color: var(--encre); }
.avatar-grand { width: 72px; height: 80px; font-size: 38px; }

/* Initial: the full name is in the DOM, only the first letter shows. */
.initiale {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
  font-size: 0;
  line-height: 40px;
}
.initiale::first-letter { font-size: 15px; font-weight: 700; text-transform: uppercase; }
.avatar-grand .initiale { line-height: 80px; }
.avatar-grand .initiale::first-letter { font-size: 30px; }

/* --- Grouped lists (spaces, to review, agents, turns, repos) --- */

.liste-espaces, .agents, .tours, .liste-dossiers {
  margin: 12px 0 20px;
  padding: 0;
  list-style: none;
  border: 1px solid var(--bordure);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}
.liste-espaces > li, .agents > li, .tours > li, .liste-dossiers > li {
  position: relative;
  padding: 13px 16px;
  overflow-wrap: anywhere;
}
.liste-espaces > li + li, .agents > li + li, .tours > li + li, .liste-dossiers > li + li { border-top: 1px solid var(--bordure); }

/* The whole row is clickable (stretched link), with a chevron. */
.liste-espaces > li > a:first-child,
.tours > li > a:first-child { color: var(--texte); text-decoration: none; }
.liste-espaces > li > a:first-child::after,
.tours > li > a:first-child::after,
.ligne-agent .ligne-lien::after { content: ""; position: absolute; inset: 0; }
.liste-espaces > li:has(> a:first-child),
.tours > li:has(> a:first-child),
.ligne-agent { padding-right: 40px; }
.liste-espaces > li:has(> a:first-child)::before,
.tours > li:has(> a:first-child)::before,
.ligne-agent::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 16px;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-top: 2px solid color-mix(in srgb, var(--discret) 60%, transparent);
  border-right: 2px solid color-mix(in srgb, var(--discret) 60%, transparent);
  transform: rotate(45deg);
}
.liste-espaces > li:active, .tours > li:active, .ligne-agent:active { background: var(--surface-2); }
@media (hover: hover) {
  .liste-espaces > li:has(> a:first-child):hover, .tours > li:has(> a:first-child):hover,
  .ligne-agent:hover { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
}

.liste-espaces strong { font-weight: 600; }
.liste-espaces .discret { font-size: 0.875rem; }
.liste-espaces .a-toi, .pastille {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: 0.1em;
}
.liste-espaces .a-toi { margin-left: 6px; background: var(--miel); color: var(--encre); }

/* Agents */
.ligne-agent {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 12px;
  align-items: center;
}
.ligne-corps { min-width: 0; }
.ligne-agent .ligne-lien { color: var(--texte); text-decoration: none; }
.ligne-agent .ligne-lien strong { font-weight: 650; }
.ligne-agent .nom { color: var(--discret); }
.ligne-agent .discret { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.8125rem; }
.ligne-agent.en-pause .avatar { filter: grayscale(1); opacity: 0.6; }
.ecrit-dans { position: relative; z-index: 1; margin-top: 4px; font-size: 0.8125rem; }
.ecrit-dans a { display: inline-flex; align-items: flex-start; gap: 7px; min-height: 28px; font-weight: 550; text-decoration: none; }
.ecrit-dans a::before {
  content: "";
  flex: none;
  margin-top: 0.45em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulsation 1.4s ease-in-out infinite;
}

.etat { display: inline-flex; align-items: center; gap: 6px; }
.etat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--succes); }
.etat-pause::before { background: var(--discret); }

/* Turns */
.tours > li { display: flex; flex-direction: column; gap: 2px; }
.tours a { font-weight: 550; }
.tour-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.8125rem; color: var(--discret); }

/* Repos */
.liste-dossiers code { font-size: 0.8125rem; color: var(--discret); overflow-wrap: anywhere; }
.liste-dossiers form { margin: 6px 0 0 -10px; }
.liste-dossiers button.lien { color: var(--danger); min-height: 36px; }
.etat-dossier { font-size: 0.8125rem; font-weight: 550; }

/* --- Banners --- */

.bandeau-pause {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 9px var(--marge-d) 9px var(--marge-g);
  background: var(--miel);
  color: var(--encre);
  font-size: 0.875rem;
  font-weight: 650;
  text-align: center;
}
.bandeau-pause::before {
  content: "";
  width: 10px;
  height: 12px;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor;
}
/* Engine quota exhausted: thinner than the global pause, links to
   /resources. */
.bandeau-quota {
  margin: 0;
  padding: 6px var(--marge-d) 6px var(--marge-g);
  background: color-mix(in srgb, var(--danger) 16%, var(--surface));
  color: var(--texte);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
}
.bandeau-quota a { color: inherit; }

/* --- Tab bar --- */

.onglets {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-top: 1px solid color-mix(in srgb, var(--bordure) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
}

.onglets a {
  display: flex;
  flex-direction: column-reverse;  /* the label comes before the icon in the HTML */
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--barre);
  color: var(--discret);
  font-size: 0.6875rem;
  font-weight: 550;
  letter-spacing: 0.01em;
  text-decoration: none;
}
.onglets svg {
  width: 52px;
  height: 28px;
  padding: 3px 14px;
  border-radius: 999px;
  transition: background-color 0.2s, color 0.2s;
}
.onglets a:active svg { background: var(--surface-2); }
.onglets a[aria-current="page"] { color: var(--lien); font-weight: 700; }
.onglets a[aria-current="page"] svg {
  background: color-mix(in srgb, var(--miel) 26%, transparent);
  color: color-mix(in srgb, var(--accent) 80%, var(--texte));
}

/* --- Login, error --- */

.connexion, .erreur {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 22rem;
  margin: 18vh auto 0;
  text-align: center;
}
.connexion .logo { width: 88px; height: 88px; border-radius: 24px; box-shadow: var(--ombre); }
.connexion h1 { margin: 24px 0 6px; font-size: 2rem; letter-spacing: -0.03em; }
.connexion p { margin: 0 0 32px; color: var(--discret); }
.erreur h1 { font-size: 1.25rem; }
.bouton.annuler { width: 100%; }
.erreur::before {
  content: "";
  width: 56px;
  height: 62px;
  margin-bottom: 8px;
  background: color-mix(in srgb, var(--danger) 18%, var(--surface));
  -webkit-mask: var(--hexagone) center / 100% 100% no-repeat;
  mask: var(--hexagone) center / 100% 100% no-repeat;
}

/* --- Empty states --- */

p.vide, .accueil-vide {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 24px 0;
  padding: 36px 24px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  text-align: center;
}
p.vide::before, .accueil-vide::before {
  content: "";
  width: 44px;
  height: 49px;
  margin-bottom: 14px;
  background: color-mix(in srgb, var(--miel) 30%, var(--surface));
  -webkit-mask: var(--hexagone) center / 100% 100% no-repeat;
  mask: var(--hexagone) center / 100% 100% no-repeat;
}

/* --- Settings: sections as cards --- */

.groupe {
  margin: 0 0 14px;
  padding: 16px;
  border: 1px solid var(--bordure);
  border-radius: 16px;
  background: var(--surface);
}
.groupe h2 { margin: 0 0 6px; font-size: 0.9375rem; }
.groupe p { margin: 0 0 12px; color: var(--discret); }
.groupe > :last-child, .groupe form > :last-child { margin-bottom: 0; }

/* Notifications card: one block per subscribed device. */
.push-activer { margin: 0 0 12px; }
.push-activer button { margin-bottom: 8px; }
.groupe .push-confirme { color: var(--texte); font-weight: 550; }
.appareils { margin: 0 0 12px; padding: 0; list-style: none; }
.appareil { padding: 12px 0; border-top: 1px solid var(--bordure); }
.appareil p { margin-bottom: 8px; }
.appareil strong { color: var(--texte); }
.groupe .appareil-alerte { color: var(--texte); font-weight: 550; }
.push-genres fieldset { margin: 0 0 8px; padding: 0; border: 0; }
.push-genres legend { margin-bottom: 4px; color: var(--discret); font-size: 0.875rem; }
.push-genres label { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.appareil form { display: inline-block; margin: 0 8px 0 0; vertical-align: top; }
.appareil form.push-genres { display: block; margin-bottom: 8px; }

/* --- Agent profile --- */

.profil-entete {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0 16px;
}
.profil-entete h1 { margin: 0; font-size: 1.5rem; }
.profil-entete p { margin: 2px 0 0; }

.statut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 24px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--bordure);
  border-radius: 16px;
  background: var(--surface);
}
.statut .etat { color: var(--texte); font-weight: 550; }

/* --- Thread: header, banners, messages --- */

.fil-retour { margin-top: 10px; margin-left: -10px; font-size: 0.9375rem; }
.fil-retour a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--discret);
  font-weight: 550;
  text-decoration: none;
}
.fil-retour a:hover { color: var(--texte); background: var(--surface-2); }
.fil-retour svg { width: 18px; height: 18px; }
.fil h1 { margin: 2px 0 14px; font-size: 1.3125rem; line-height: 1.25; }

.bandeau-a-toi {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 0.9375rem;
}
.bandeau-a-toi {
  border: 1px solid color-mix(in srgb, var(--miel) 55%, transparent);
  background: color-mix(in srgb, var(--miel) 18%, var(--surface));
  color: var(--texte);
  font-weight: 600;
}
.bandeau-a-toi::before {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Messages: reusable outside a thread (space stream). */
.messages { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }

/* Without avatar (system root message of a thread), the body stays in the
   second column. */
.message > .message-corps { grid-column: 2; }

.message {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 12px;
  align-items: start;
  padding: 10px 8px;
  border-radius: var(--rayon);
  overflow-wrap: anywhere;
}
.message-corps { min-width: 0; }
.message-human { background: color-mix(in srgb, var(--miel) 10%, transparent); }
/* The sender check of a customer message. */
.verif { font-size: 0.75rem; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--discret); }
.verif-verified { color: var(--encre); }
.verif-failed { color: var(--erreur, #b3261e); font-weight: 600; }
/* A customer message (SAV): untrusted text from outside Ruche. */
.message-customer {
  background: var(--surface-2);
  border-left: 3px solid var(--discret);
}

.message-system {
  display: flex;
  justify-content: center;
  padding: 6px 8px;
}
.message-system .message-corps {
  max-width: 90%;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--discret);
  font-size: 0.8125rem;
  text-align: center;
}
.message-system .message-entete { display: none; }
.message-system .message-texte { font-size: inherit; }
.message-system .message-texte > * { margin: 0; }

.message-entete {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 20px;
  font-size: 0.75rem;
  color: var(--discret);
  font-variant-numeric: tabular-nums;
}
.message-entete .auteur {
  overflow: hidden;
  color: var(--texte);
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.005em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--discret);
  font-variant-numeric: tabular-nums;
}
.message-meta span {
  padding: 1px 8px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
}
/* Implicit addressees of a human reply ("→ @dev") */
.message-destinataires {
  display: inline-block;
  margin: 6px 0 0;
  padding: 1px 8px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--discret);
}

/* Message markdown */
.message-texte { font-size: 0.96875rem; line-height: 1.55; }
.message-texte > :first-child { margin-top: 2px; }
.message-texte > :last-child { margin-bottom: 0; }
.message-texte p, .message-texte ul, .message-texte ol,
.message-texte blockquote, .message-texte pre, .message-texte table { margin: 0 0 10px; }
.message-texte ul, .message-texte ol { padding-left: 1.35em; }
.message-texte li { margin: 2px 0; }
.message-texte li::marker { color: var(--discret); }
.message-texte li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.35em; }
.message-texte li > input[type="checkbox"] { display: inline-block; width: 16px; height: 16px; margin: 0 8px 0 0; vertical-align: -0.15em; }
.message-texte h1, .message-texte h2, .message-texte h3,
.message-texte h4, .message-texte h5, .message-texte h6 {
  margin: 16px 0 6px;
  font-size: 1rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.message-texte h1 { font-size: 1.125rem; }
.message-texte h2 { font-size: 1.0625rem; }
.message-texte strong { font-weight: 650; }
.message-texte a { overflow-wrap: anywhere; }
.message-texte hr { height: 1px; margin: 14px 0; border: 0; background: var(--bordure); }
.message-texte blockquote {
  padding: 2px 0 2px 12px;
  border-left: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--discret);
}
.message-texte blockquote > :last-child { margin-bottom: 0; }
.message-texte code {
  padding: 0.1em 0.38em;
  border-radius: 6px;
  background: var(--code);
  font-size: 0.84em;
}
.message-texte pre {
  overflow-x: auto;
  padding: 12px 14px;
  border: 1px solid var(--bordure);
  border-radius: 12px;
  background: var(--code);
  font-size: 0.8125rem;
  line-height: 1.55;
  -webkit-overflow-scrolling: touch;
  tab-size: 4;
}
.message-texte pre code { padding: 0; background: none; font-size: inherit; }
.message-texte table {
  display: block;
  max-width: 100%;
  width: max-content;
  overflow-x: auto;
  border: 1px solid var(--bordure);
  border-radius: 12px;
  border-spacing: 0;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
.message-texte th, .message-texte td { padding: 7px 12px; text-align: left; vertical-align: top; }
.message-texte th { background: var(--surface-2); font-weight: 600; }
.message-texte tr + tr td, .message-texte tbody tr:first-child td { border-top: 1px solid var(--bordure); }
.message-texte th + th, .message-texte td + td { border-left: 1px solid var(--bordure); }
.message-texte img { max-width: 100%; border-radius: 10px; }
.message-texte del { color: var(--discret); }

/* « @x écrit… » */
.ecrit {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0;
  padding: 6px 14px 6px 12px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  background: var(--surface);
  color: var(--discret);
  font-size: 0.8125rem;
  font-weight: 550;
  max-width: 100%;
  overflow-wrap: anywhere; /* long tool names (mcp__…) */
}
.ecrit::before {
  content: "";
  width: 5px;
  height: 5px;
  margin: 0 10px 0 2px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 7px 0 0 currentColor, 14px 0 0 currentColor;
  animation: points 1.2s ease-in-out infinite;
}


/* --- Input area stuck at the bottom, above the tab bar --- */

body:has(.saisie-fil) {
  padding-bottom: calc(var(--barre) + env(safe-area-inset-bottom) + 92px);
}
.saisie-fil {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--barre) + env(safe-area-inset-bottom));
  z-index: 19;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px max(var(--marge-d), calc((100vw - var(--largeur)) / 2 + var(--marge)))
    8px max(var(--marge-g), calc((100vw - var(--largeur)) / 2 + var(--marge)));
  border-top: 1px solid color-mix(in srgb, var(--bordure) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
}
.saisie-fil textarea {
  flex: 1;
  min-height: var(--tactile);
  max-height: 160px;
  margin: 0;
  padding: 10px 16px;
  border-radius: 22px;
  background: var(--fond);
  resize: none;
}
.saisie-fil .envoyer {
  flex: none;
  width: var(--tactile);
  height: var(--tactile);
  padding: 0;
  border-radius: 50%;
  font-size: 1.125rem;
}
.saisie-fil .envoyer svg { width: 22px; height: 22px; }
.saisie-fil.echec textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}

/* Secret message: the 🔒 toggle (a checkbox, works without JavaScript)
   and the textarea in secret mode. */
.secret-bascule {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--tactile);
  height: var(--tactile);
  border: 1px solid var(--bordure);
  border-radius: 50%;
  background: var(--fond);
  font-size: 1.125rem;
  cursor: pointer;
  filter: grayscale(1);
  opacity: 0.7;
}
.secret-case:focus-visible + .secret-bascule { outline: 2px solid var(--accent); outline-offset: 2px; }
.secret-case:checked + .secret-bascule {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--miel) 28%, var(--surface));
  filter: none;
  opacity: 1;
}
.saisie-fil:has(.secret-case:checked) textarea {
  border: 2px dashed var(--accent);
  background: color-mix(in srgb, var(--miel) 12%, var(--fond));
  font-family: var(--police-code);
}
.alerte-secret {
  position: absolute;
  left: max(var(--marge-g), calc((100vw - var(--largeur)) / 2 + var(--marge)));
  right: max(var(--marge-d), calc((100vw - var(--largeur)) / 2 + var(--marge)));
  bottom: 100%;
  margin: 0 0 6px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--ombre);
}
.alerte-secret:empty { display: none; }
.secret-cible {
  position: absolute;
  right: max(var(--marge-d), calc((100vw - var(--largeur)) / 2 + var(--marge)));
  bottom: 100%;
  margin: 0 0 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--miel) 28%, var(--surface));
  color: var(--encre);
  font-size: 0.875rem;
}
.secret-cible[hidden] { display: none; }
.alerte-secret p { margin: 0 0 8px; }
.alerte-secret-choix { display: flex; flex-wrap: wrap; gap: 8px; }
.secret-confirmation textarea { width: 100%; font-family: var(--police-code); }

.champ-mentions { position: relative; margin: 0 0 18px; }

.suggestions {
  position: absolute;
  left: var(--marge-g);
  right: var(--marge-d);
  bottom: 100%;
  z-index: 30;
  max-height: 40vh;
  overflow-y: auto;
  margin: 0 0 6px;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--bordure);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--ombre);
}
.saisie-fil .suggestions {
  left: max(var(--marge-g), calc((100vw - var(--largeur)) / 2 + var(--marge)));
  right: max(var(--marge-d), calc((100vw - var(--largeur)) / 2 + var(--marge)));
}
.champ-mentions .suggestions { left: 0; right: 0; }
.suggestions li {
  display: flex;
  align-items: center;
  min-height: var(--tactile);
  padding: 0 12px;
  border-radius: 10px;
  cursor: pointer;
}
.suggestions li[aria-selected="true"] { background: color-mix(in srgb, var(--miel) 20%, var(--surface)); }

/* --- Space page --- */

.espace-entete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.espace-entete h1 { margin-bottom: 4px; }
.espace-entete p { margin: 0 0 8px; }
.reglages-espace {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--tactile);
  height: var(--tactile);
  margin-top: 12px;
  margin-right: -6px;
  border-radius: 50%;
  color: var(--discret);
  font-size: 1.25rem;
  text-decoration: none;
}
.reglages-espace:hover { background: var(--surface-2); color: var(--texte); }

.pastille {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--discret);
}
.pastille.a-toi { background: var(--miel); color: var(--encre); }

.accueil-vide p { margin: 0 0 6px; }
.agents-dispo { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 14px; }
.agents-dispo span {
  padding: 5px 12px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875rem;
  font-weight: 550;
}

/* --- Large screen: tabs as a rail on the left --- */

@media (min-width: 900px) {
  body.avec-onglets { padding-left: var(--rail); padding-bottom: 32px; }
  body.avec-onglets:has(.saisie-fil) { padding-bottom: 108px; }
  .onglets {
    top: var(--entete);
    right: auto;
    width: var(--rail);
    grid-template-columns: none;
    grid-auto-rows: 76px;
    align-content: start;
    gap: 4px;
    padding: 16px 0;
    border-top: 0;
    border-right: 1px solid var(--bordure);
    background: var(--surface);
  }
  .onglets a { min-height: 0; gap: 4px; font-size: 0.75rem; }
  /* The header and the pause banner also cover the rail. */
  .avec-onglets .entete, .avec-onglets .bandeau-pause, .avec-onglets .bandeau-quota { margin-left: calc(-1 * var(--rail)); }
  .avec-onglets .saisie-fil {
    left: var(--rail);
    bottom: 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    padding-left: max(var(--marge), calc((100vw - var(--rail) - var(--largeur)) / 2 + var(--marge)));
    padding-right: max(var(--marge), calc((100vw - var(--rail) - var(--largeur)) / 2 + var(--marge)));
  }
  .avec-onglets .saisie-fil .suggestions {
    left: max(var(--marge), calc((100vw - var(--rail) - var(--largeur)) / 2 + var(--marge)));
    right: max(var(--marge), calc((100vw - var(--rail) - var(--largeur)) / 2 + var(--marge)));
  }
  h1 { margin-top: 32px; }
}

/* --- Motion --- */

@keyframes points {
  0%, 100% { box-shadow: 7px 0 0 color-mix(in srgb, currentColor 40%, transparent), 14px 0 0 color-mix(in srgb, currentColor 20%, transparent); opacity: 1; }
  33% { box-shadow: 7px 0 0 currentColor, 14px 0 0 color-mix(in srgb, currentColor 40%, transparent); opacity: 0.4; }
  66% { box-shadow: 7px 0 0 color-mix(in srgb, currentColor 40%, transparent), 14px 0 0 currentColor; opacity: 0.2; }
}
@keyframes pulsation {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Comb channel: flat messages, threads on demand --- */
/* The channel is a flat stream of messages (newest at the bottom); under a
   message that has a thread, the « N réponses » line opens it; under the
   others, a discreet « Répondre en fil ». */
.plus-anciens { display: block; margin: 12px 0 0; text-align: center; font-size: 0.875rem; }
.messages.channel { margin-top: 12px; }
.message { scroll-margin-bottom: 96px; }
.message:target { background: color-mix(in srgb, var(--miel) 12%, transparent); }
.message-fil:empty { display: none; }
.repondre-fil {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 2px 0 0 -6px;
  padding: 0 6px;
  border-radius: 8px;
  color: var(--discret);
  font-size: 0.75rem;
  font-weight: 550;
  text-decoration: none;
}
.repondre-fil:hover, .repondre-fil:focus-visible { background: var(--surface-2); color: var(--texte); }
/* With a mouse, the action shows on hover (or focus); on touch screens it
   stays visible: there is no hover. */
@media (hover: hover) {
  .channel .message .repondre-fil { opacity: 0; transition: opacity 0.12s; }
  .channel .message:hover .repondre-fil, .channel .message .repondre-fil:focus-visible { opacity: 1; }
}
.resume-fil.fil-your_turn .ligne-fil { box-shadow: inset 3px 0 0 var(--miel); }
.ligne-fil .pastille { flex: none; align-self: flex-start; margin-top: 1px; padding: 0 8px; font-size: 0.6875rem; }
/* Thread page: the anchor message, in the channel, above the replies. */
.ancre-fil {
  margin: 0 -8px 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bordure);
}

.ligne-fil {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 6px 0 0 -6px;
  padding: 4px 8px 4px 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.8125rem;
  color: var(--discret);
  text-decoration: none;
}
@media (hover: hover) {
  .ligne-fil:hover { border-color: var(--bordure); background: var(--surface); }
  .ligne-fil:hover .ligne-fil-resume { text-decoration: underline; }
}
.ligne-fil:active { background: var(--surface-2); }
.ligne-fil-avatars { display: flex; flex: none; }
.ligne-fil-avatars .avatar {
  width: 22px;
  height: 24px;
  /* Agent tint, even under a human root message. */
  background: color-mix(in srgb, var(--teinte, var(--discret)) 24%, var(--surface));
  color: color-mix(in srgb, var(--teinte, var(--discret)) 70%, var(--texte));
  font-size: 12px;
}
.ligne-fil-avatars .avatar + .avatar { margin-left: -4px; }
.ligne-fil-avatars .initiale { line-height: 24px; }
.ligne-fil-avatars .initiale::first-letter { font-size: 10px; }
.ligne-fil-texte { display: flex; flex-direction: column; min-width: 0; }
.ligne-fil-resume {
  overflow: hidden;
  color: var(--lien);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ligne-fil-agents, .ligne-fil-date { color: var(--discret); font-weight: 500; }
.ligne-fil .extrait { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.resume-fil .ecrit { margin-top: 8px; padding: 3px 12px 3px 10px; font-size: 0.75rem; }

/* --- Agent machine (tranche 1b) --- */
#machine { margin-top: 24px; }
#machine h3 { margin: 16px 0 6px; font-size: 0.9375rem; color: var(--discret); }
.machine-setup {
  margin: 0;
  padding: 10px 12px;
  max-height: 20rem;
  overflow: auto;
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 8px;
  font-size: 0.8125rem;
}
.machine-instantanes { margin: 0 0 12px; padding-left: 20px; }
.machine-instantanes li { padding: 2px 0; }
#machine form { margin-top: 12px; }

/* --- Codex connection --- */
#codex { margin-top: 24px; }
#codex form { margin-top: 12px; }
#codex a { overflow-wrap: anywhere; }
.codex-code { font-size: 1.5rem; letter-spacing: 0.1em; user-select: all; }

/* --- Cells (tranche 1c) --- */
#alveoles { margin-top: 24px; }
.groupe#alveoles { margin-top: 0; }
.alveoles {
  margin: 12px 0 16px;
  padding: 0;
  list-style: none;
  border: 1px solid var(--bordure);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}
.alveoles > li { padding: 13px 16px; overflow-wrap: anywhere; }
.alveoles > li + li { border-top: 1px solid var(--bordure); }
.alveole-entete { display: flex; align-items: center; gap: 8px; }
.alveole-nom { font-family: ui-monospace, monospace; font-size: 0.9375rem; }
.alveole-meta { margin: 2px 0 8px; font-size: 0.8125rem; color: var(--discret); }
.alveole-masque { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 8px; cursor: pointer; }
.valeur-alveole {
  display: inline-block;
  margin: 0 0 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 0.8125rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.alveole-masque .valeur-alveole { margin: 0; }
.alveole-edition textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 0.875rem; }
.alveole-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 16px; margin-top: 8px; }
.alveole-actions label { margin-right: auto; }
.alveole-suppression { margin-top: 4px; text-align: right; }
.alveole-ajout h3 { margin: 0 0 8px; font-size: 0.9375rem; }
.alveole-ajout p { margin: 0 0 10px; }
.alveole-ajout textarea, .alveole-ajout input:not([type]) { width: 100%; }
.lectures { margin: 0; padding-left: 20px; font-size: 0.875rem; }
.lectures li { padding: 2px 0; overflow-wrap: anywhere; }
.memoires { margin-top: 8px; }

/* Routines (« butinages ») of an agent. */
.routines { list-style: none; padding: 0; margin: 0 0 12px; }
.routine { padding: 10px 0; border-top: 1px solid var(--bordure); }
.routine:first-child { border-top: 0; }
.routine-entete { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.routine-meta { margin: 4px 0; font-size: 0.875rem; }
.routine-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.routine-erreur, .routine-error { color: var(--danger); }
.pastille.routine-erreur { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.routine-posted { font-weight: 600; }
.routine-passages ul { padding-left: 18px; font-size: 0.875rem; }
/* --- Salons drawer --- */
/* The logo opens the list of every space (a "salon"): a drawer from the left
   on phones, a persistent sidebar under the tabs on large screens. Without
   JS the logo is a plain link to the spaces list and the drawer stays
   hidden. Each salon is a hexagonal cell tinted like the agent avatars. */

a.marque { color: inherit; text-decoration: none; }
.marque-bouton {
  min-height: var(--tactile);
  margin-left: -8px;
  padding: 0 10px 0 8px;
  border: 0;
  border-radius: 12px;
  background: none;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}
/* Chevron: the logo opens something. */
.marque-bouton::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 2px solid var(--discret);
  border-bottom: 2px solid var(--discret);
  transform: rotate(-45deg);
  transition: transform 0.2s;
}
.marque-bouton[aria-expanded="true"]::after { transform: rotate(45deg); }
.marque-bouton:active { background: var(--surface-2); }

.salons {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: calc(min(86vw, 320px) + env(safe-area-inset-left));
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--surface);
  box-shadow: var(--ombre);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.28s;
}
.salons-ouvert .salons {
  transform: none;
  visibility: visible;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s;
}
.salons-ouvert, .salons-ouvert body { overflow: hidden; }

.salons-voile {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgb(8 9 12 / 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}
.salons-ouvert .salons-voile { opacity: 1; pointer-events: auto; }

.salons-tete {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  min-height: var(--entete);
  padding: 0 6px 0 16px;
  border-bottom: 1px solid var(--bordure);
}

.salons-titre {
  flex: none;
  margin: 14px 20px 6px;
  color: var(--discret);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
}

.salons-liste {
  flex: 1;
  margin: 0;
  padding: 0 0 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}
.salons-vide { padding: 8px 20px; color: var(--discret); font-size: 0.875rem; }

.salon {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin: 1px 8px;
  padding: 4px 10px;
  border-radius: 12px;
  color: var(--texte);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}
.salon:active { background: var(--surface-2); }
@media (hover: hover) {
  .salon:hover { background: var(--surface-2); }
}
.salon[aria-current] {
  background: color-mix(in srgb, var(--miel) 18%, transparent);
  font-weight: 700;
}
.salon[aria-current="page"] { box-shadow: inset 3px 0 0 var(--miel); }

.salon-cellule {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 31px;
  background: color-mix(in srgb, var(--teinte, var(--discret)) 24%, var(--surface));
  color: color-mix(in srgb, var(--teinte, var(--discret)) 70%, var(--texte));
  -webkit-mask: var(--hexagone) center / 100% 100% no-repeat;
  mask: var(--hexagone) center / 100% 100% no-repeat;
}
.salon-cellule .initiale { line-height: 33px; }
.salon-cellule .initiale::first-letter { font-size: 13px; }
.salon-cellule svg { width: 16px; height: 16px; }

.salon-nom {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.salon-a-toi {
  display: inline-grid;
  place-items: center;
  flex: none;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--miel);
  color: var(--encre);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.salon-nouveau {
  flex: none;
  margin-top: 0;
  margin-bottom: 8px;
  color: var(--discret);
  font-weight: 550;
}
.salon-nouveau .salon-cellule { background: var(--surface-2); color: var(--discret); }
.salons-liste + .salon-nouveau { position: relative; margin-top: 4px; }
.salons-liste + .salon-nouveau::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 2px;
  right: 2px;
  border-top: 1px solid var(--bordure);
}

/* Large screen: the rail widens into a sidebar, the four tabs as a strip on
   top, then the salons, always visible. */
@media (min-width: 900px) {
  body.avec-onglets { --rail: 264px; --onglets-bande: 76px; }
  .avec-onglets .onglets {
    bottom: auto;
    height: var(--onglets-bande);
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: auto;
    align-content: stretch;
    gap: 0;
    padding: 6px 8px;
    border-bottom: 1px solid var(--bordure);
  }
  .avec-onglets .onglets a { min-width: 0; gap: 3px; font-size: 0.6875rem; }
  .avec-onglets .onglets svg { width: 48px; padding: 3px 12px; }

  .salons {
    top: calc(var(--entete) + var(--onglets-bande));
    z-index: 20;
    width: var(--rail);
    padding: 0 0 env(safe-area-inset-bottom);
    border-right: 1px solid var(--bordure);
    box-shadow: none;
    transform: none;
    visibility: visible;
    transition: none;
  }
  .salons-tete, .salons-voile { display: none; }
  .salons-ouvert, .salons-ouvert body { overflow: visible; }
  .marque-bouton::after { display: none; }
}

/* --- Resources: quota gauges and consumption tables --- */

.salon-ressources { color: var(--discret); font-weight: 550; }
.salon-ressources .salon-cellule { background: var(--surface-2); color: var(--discret); }
.salon-alerte {
  display: inline-grid;
  place-items: center;
  flex: none;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--danger);
  color: var(--surface);
  font-size: 0.75rem;
  font-weight: 700;
}

.quota-epuise {
  padding: 8px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  color: var(--texte) !important;
  font-weight: 600;
}
.jauge { margin: 0 0 14px; }
.jauge-tete { display: flex; justify-content: space-between; gap: 8px; font-size: 0.875rem; }
.jauge-nom { font-weight: 600; }
.jauge-valeur { font-variant-numeric: tabular-nums; font-weight: 650; }
.jauge-barre {
  height: 10px;
  margin: 6px 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}
.jauge-barre span { display: block; height: 100%; border-radius: inherit; background: var(--miel); }
.jauge-alerte .jauge-barre span { background: color-mix(in srgb, var(--danger) 60%, var(--miel)); }
.jauge-pleine .jauge-barre span { background: var(--danger); }
.groupe .jauge-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0; font-size: 0.8125rem; }
.jauge-badge { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); color: var(--texte); }
.groupe .quota-maj { font-size: 0.8125rem; }

.periode { display: flex; gap: 6px; margin: 0 0 12px; }
.periode a {
  padding: 4px 12px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  color: var(--discret);
  font-size: 0.8125rem;
  text-decoration: none;
}
.periode a[aria-current] { border-color: var(--accent); background: color-mix(in srgb, var(--miel) 18%, transparent); color: var(--texte); font-weight: 650; }
.conso h3 { margin: 14px 0 6px; font-size: 0.875rem; }
.tableau-defile { overflow-x: auto; margin: 0 0 8px; }
.tableau-conso { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.tableau-conso th, .tableau-conso td { padding: 6px 8px; border-bottom: 1px solid var(--bordure); text-align: right; white-space: nowrap; }
.tableau-conso th:first-child { text-align: left; white-space: normal; font-weight: 550; }
.tableau-conso thead th { color: var(--discret); font-weight: 600; }
.tableau-conso td { font-variant-numeric: tabular-nums; }
.groupe .conso-note { margin-top: 8px; font-size: 0.75rem; }

/* Machine recipes and Claude Code upkeep (bee page). */
textarea.code { width: 100%; font-family: ui-monospace, monospace; font-size: 0.875rem; }
.recette-outils { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pastille.danger { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.avis { padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, var(--miel) 18%, var(--surface)); }

/* Workshop (atelier) of a thread: banner under the title. */
.atelier {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  margin: 0 0 1rem;
  font-size: .9rem;
}
.atelier p { margin: 0; }
.atelier-open, .atelier-opening, .atelier-closing {
  padding: .5rem .75rem;
  border-left: 3px solid var(--miel);
  border-radius: 6px;
  background: color-mix(in srgb, var(--miel) 12%, transparent);
}
.atelier form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0; }
.atelier .recette-journal { flex-basis: 100%; }

/* Attachments: the 📎 button of the composer, the chips of the chosen
   files above it, and the files of a message (thumbnails, chips). */
.joindre {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--tactile);
  height: var(--tactile);
  border: 1px solid var(--bordure);
  border-radius: 50%;
  background: var(--fond);
  font-size: 1.125rem;
  cursor: pointer;
}
.fichiers-case:focus-visible + .joindre { outline: 2px solid var(--accent); outline-offset: 2px; }
.pieces-choisies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.saisie-fil .pieces-choisies {
  position: absolute;
  left: max(var(--marge-g), calc((100vw - var(--largeur)) / 2 + var(--marge)));
  bottom: 100%;
  margin: 0 0 6px;
}
.pieces-choisies[hidden] { display: none; }
.pieces-jointes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
.piece {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  background: var(--surface);
  color: var(--encre);
  font-size: 0.875rem;
  text-decoration: none;
}
.piece-nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.piece-taille { opacity: 0.7; }
.piece-expiree { opacity: 0.6; font-style: italic; }
.piece-alerte { margin: 4px 0 0; color: var(--danger); font-size: 0.8125rem; }
.vignette img {
  display: block;
  max-width: min(240px, 100%);
  max-height: 240px;
  border: 1px solid var(--bordure);
  border-radius: 10px;
}
.partage-rayons { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.partage-texte { white-space: pre-wrap; }

/* Approvals: the card of an action a bee proposes, in the review tab and
   under the bee's message; a mail shows as a mail. */
.approbation {
  margin: 8px 0 0;
  padding: .75rem;
  border: 1px solid var(--bordure);
  border-left: 3px solid var(--miel);
  border-radius: 10px;
  background: var(--surface);
  font-size: .9375rem;
}
.approbations .approbation, .approbations-libres .approbation { margin: 0 0 12px; }
.approbation-executed { border-left-color: var(--succes); }
.approbation-unknown { border-left-color: var(--danger); }
.approbation-failed, .approbation-rejected, .approbation-expired { border-left-color: var(--discret); }
.approbation p { margin: .25rem 0; }
.approbation-entete { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; }
.approbation-etat { color: var(--discret); font-size: .8125rem; }
.approbation-titre { font-weight: 600; }
.approbation-apercu {
  max-height: 16rem;
  overflow: auto;
  padding: .5rem;
  border-radius: 6px;
  background: var(--code);
  font-family: var(--police-code);
  font-size: .8125rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mail-entetes { display: grid; grid-template-columns: auto 1fr; gap: .125rem .75rem; margin: .5rem 0; }
.mail-entetes dt { color: var(--discret); }
.mail-entetes dd { margin: 0; overflow-wrap: anywhere; }
.approbation-valider textarea, .approbation-valider input { width: 100%; }
.approbation-refuser { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .5rem 0 0; }
.approbation-refuser input { flex: 1 1 10rem; }
.approbation-resultat { overflow-wrap: anywhere; }
