:root {
  --bg: #14140f;
  --panel: #1c1d14;
  --card: #23241a;
  --line: #34351f;
  --line-soft: #292a1c;
  --ink: #e8e6d8;
  --ink-dim: #9a9a82;
  --ink-faint: #6b6c58;
  --amber: #e8a33d;
  --amber-dim: #8a6b2c;
  --amber-ink: #1a1608;
  --alert: #c1462f;

  /* Couleurs sémantiques (V2) — chaque paire {texte, fond} est vérifiée au
     ratio de contraste WCAG (formule de luminance relative), pas choisie à
     l'œil : ~7-8:1 pour success/warning/info, utilisées ensemble avec un
     texte/icône (jamais la couleur seule — voir REFONTE DESIGN V2 §5). */
  --success-text: #b6d17e;
  --success-bg: #223018;
  --warning: #c97d3a;
  --warning-text: #dcab7f;
  --warning-bg: #2f2415;
  --info-text: #9ebac6;
  --info-bg: #21272c;

  --display: 'Black Ops One', 'Arial Narrow', sans-serif;
  /* --body : texte courant (V2) — police système lisible, pas de requête
     réseau supplémentaire. --mono : réservée aux éléments d'identité/ambiance
     rétro (labels, horodatages, boot) — jamais tout le texte courant. */
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'Courier Prime', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-image:
    radial-gradient(ellipse at 20% -10%, rgba(232, 163, 61, 0.05), transparent 55%),
    repeating-linear-gradient(180deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 3px);
}

a { color: var(--amber); }

::selection { background: var(--amber); color: var(--amber-ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--panel); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }

*:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

button, input, textarea { font-family: inherit; }

/* ---------- shared: patch insignia ---------- */

.patch {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--amber);
}
.patch svg { width: 58%; height: 58%; }
.patch.lg { width: 64px; height: 64px; border-width: 2px; }
.patch.md { width: 38px; height: 38px; }
.patch.sm { width: 26px; height: 26px; border-width: 1px; }

.patch.commander {
  background: radial-gradient(circle at 35% 30%, #2a2513, var(--panel) 70%);
  border-color: var(--amber-dim);
  box-shadow: 0 0 0 3px rgba(232, 163, 61, 0.08);
}

/* Monogramme (recrues sans glyphe dédié) : la 1re lettre du prénom, dans la
   police d'affichage, pour rester distinct et lisible. */
.patch.mono {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
}
.patch.lg.mono { font-size: 26px; }
.patch.md.mono { font-size: 16px; }
.patch.sm.mono { font-size: 11px; }

/* ---------- boot sequence ---------- */

#boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  font-family: var(--mono);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 2.5rem;
  gap: 0.4rem;
  font-size: 12.5px;
  color: var(--amber-dim);
  letter-spacing: 0.04em;
  /* Filet de sécurité indépendant du JS : disparaît de toute façon après 1.6s,
     même si app.js a planté avant de pouvoir ajouter .hide. */
  animation: bootgone 0s 1.6s forwards;
}
@keyframes bootgone {
  to { visibility: hidden; pointer-events: none; }
}
#boot .line {
  opacity: 0;
  animation: bootline 0.35s ease forwards;
}
#boot .line:nth-child(1) { animation-delay: 0.05s; }
#boot .line:nth-child(2) { animation-delay: 0.35s; }
#boot .line:nth-child(3) { animation-delay: 0.65s; color: var(--amber); }
@keyframes bootline {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}
#boot.hide { display: none; }

@media (prefers-reduced-motion: reduce) {
  #boot { display: none; }
  #boot .line { animation: none; opacity: 1; }
}

/* ---------- login ---------- */

#login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  animation: reveal 0.4s ease 1s forwards;
}
@media (prefers-reduced-motion: reduce) {
  #login { opacity: 1; animation: none; }
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

#login .card {
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 2.2rem 2rem 1.8rem;
  position: relative;
}
#login .card::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid var(--line-soft);
  pointer-events: none;
}

#login .mark { display: flex; justify-content: center; margin-bottom: 1.1rem; }

#login h1 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
  text-align: center;
  letter-spacing: 0.03em;
  color: var(--ink);
  margin: 0 0 0.3rem;
  text-wrap: balance;
}
#login .subtitle {
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber-dim);
  margin: 0 0 1.6rem;
}

.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.4rem;
}

#login input {
  width: 100%;
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0.08em;
  margin-bottom: 1.1rem;
}
#login input::placeholder { color: var(--ink-faint); }

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--amber);
  color: var(--amber-ink);
  border: none;
  font-family: var(--body);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn-primary:hover { background: #f0b158; }
.btn-primary:active { transform: translateY(1px); }

.err {
  color: var(--alert);
  font-size: 11.5px;
  min-height: 1.4em;
  margin-top: 0.7rem;
  text-align: center;
}

/* ---------- app shell ---------- */

#app {
  display: none;
  height: 100vh;
  /* minmax(0, 1fr) — sans le min 0, une piste 1fr ne rétrécit jamais sous la
     largeur de son contenu, donc le bandeau de recrues (défilement horizontal)
     élargissait toute l'appli au lieu de défiler à l'intérieur. */
  grid-template-columns: 250px minmax(0, 1fr);
}
#app.active { display: grid; }

aside {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* Le panneau de l'escouade : barre latérale normale sur ordinateur ; sur
   portable il devient un menu déroulant ancré sous l'en-tête (media-query plus
   bas), déclenché en tapant sur l'en-tête lui-même. */
.roster-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* L'en-tête sert de titre sur ordinateur et de sélecteur d'agent sur portable.
   Bouton « nu » : sur ordinateur il ressemble exactement à l'ancien titre. */
.header-agent {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 0 1 auto;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: default;
}
.header-agent-text { min-width: 0; }
.header-chevron { display: none; }

.aside-head {
  padding: 1.1rem 1.1rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
.aside-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.sidebar-collapse-btn { margin: 0; flex: none; }
.roster-search { margin-top: 0.7rem; }
.roster-search input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 12.5px;
}
.roster-search input::placeholder { color: var(--ink-faint); }
.recruit.search-hide { display: none; }

/* Sidebar repliée : rail d'icônes (V2) — préférence mémorisée localement
   (localStorage), jamais envoyée au serveur, purement une préférence
   d'affichage. */
/* Scopé à l'ordinateur (>900px) : sous 900px, #app.active passe en une
   seule colonne (voir plus bas) — le repli en rail n'a pas de sens dans le
   tiroir mobile et ne doit jamais lui reprendre sa mise en page. */
@media (min-width: 901px) {
  #app.sidebar-collapsed.active { grid-template-columns: 68px minmax(0, 1fr); }
  #app.sidebar-collapsed .roster-search,
  #app.sidebar-collapsed .aside-head .eyebrow,
  #app.sidebar-collapsed .aside-head .count,
  #app.sidebar-collapsed .recruit .info { display: none; }
  #app.sidebar-collapsed .aside-head-row { justify-content: center; }
  #app.sidebar-collapsed .recruit,
  #app.sidebar-collapsed button.commandement { justify-content: center; }
}
#app.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
.aside-head .eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  text-transform: uppercase;
  margin: 0 0 0.15rem;
}
.aside-head .count {
  font-size: 12.5px;
  color: var(--ink-dim);
}
.aside-head .count b { color: var(--amber); font-weight: 700; }

#roster {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem;
}

.recruit {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.55rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 0.15rem;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.recruit:hover { background: var(--line-soft); }
.recruit.active {
  background: var(--line-soft);
  border-color: var(--amber-dim);
}
.recruit .info { min-width: 0; padding-top: 1px; }

button.commandement {
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  margin: 0;
  padding: 0.85rem 1.1rem;
}
button.commandement .name { font-family: var(--display); font-size: 13px; letter-spacing: 0.02em; }
.recruit .name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.recruit .domain {
  font-size: 10.5px;
  color: var(--ink-dim);
  line-height: 1.4;
  margin-top: 1px;
}
.recruit .since {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
  margin-top: 3px;
}

.empty-roster {
  font-size: 11.5px;
  color: var(--ink-faint);
  padding: 0.6rem 0.5rem;
  font-style: italic;
}

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

header.console-head {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
header.console-head h1 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.02em;
}
header.console-head .subtitle {
  font-size: 11.5px;
  color: var(--ink-dim);
  margin: 3px 0 0;
}
header.console-head .status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
header.console-head .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(232,163,61,0.6);
  animation: pulse 2.4s infinite;
}
@media (prefers-reduced-motion: reduce) { header.console-head .dot { animation: none; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(232,163,61,0.5); }
  70% { box-shadow: 0 0 0 6px rgba(232,163,61,0); }
  100% { box-shadow: 0 0 0 0 rgba(232,163,61,0); }
}

#thread {
  flex: 1;
  overflow-y: auto;
  padding: 1.3rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
#thread:empty { display: none; }

/* ---------- Écran d'accueil (V2) ---------- */
/* Affiché uniquement quand #thread est vide (aucune conversation dans cette
   session — la conversation n'est jamais persistée entre rechargements,
   voir showApp()) ; masqué dès la première entrée (voir addEntry()). */
#home-screen {
  flex: 1;
  overflow-y: auto;
  padding: 1.6rem 1.5rem;
}
#home-screen.hide { display: none; }
#home-title {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 400;
  margin: 0 0 0.5rem;
  letter-spacing: 0.01em;
  text-wrap: balance;
}
#home-subtitle {
  font-size: 13.5px;
  color: var(--ink-dim);
  margin: 0 0 1.4rem;
  max-width: 60ch;
}
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.6rem;
}
.quick-action {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.75rem 0.85rem;
  color: var(--ink);
  font-family: var(--body);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.quick-action:hover { border-color: var(--amber-dim); background: var(--line-soft); }
.quick-action .qa-icon { font-size: 15px; margin-right: 0.4rem; }
.quick-action .qa-hint {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-faint);
  margin-top: 0.3rem;
}
.summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 0 0 0.2rem;
}
.summary-sub { font-size: 11px; color: var(--ink-faint); margin: 0 0 0.7rem; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}
.summary-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.7rem 0.8rem;
}
.summary-tile .val {
  font-family: var(--display);
  font-size: 20px;
  color: var(--amber);
  letter-spacing: 0.02em;
}
.summary-tile .val.muted { font-family: var(--body); font-size: 12px; font-style: italic; color: var(--ink-faint); }
.summary-tile .lbl { font-size: 11px; color: var(--ink-dim); margin-top: 0.2rem; }
.summary-tile.disabled { opacity: 0.65; border-style: dashed; }

@media (max-width: 900px) {
  .quick-actions { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.entry {
  display: flex;
  gap: 0.65rem;
  max-width: 76%;
  animation: rise 0.25s ease;
}
@media (prefers-reduced-motion: reduce) { .entry { animation: none; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.entry.user { align-self: flex-end; flex-direction: row-reverse; }
.entry.system { align-self: flex-start; }

.bubble {
  padding: 0.7rem 0.9rem;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  min-width: 0;
}
.entry.user .bubble {
  background: var(--amber);
  color: var(--amber-ink);
  border-radius: 3px;
}
.entry.system .bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 3px;
}
/* États réels déjà distingués par badge (icône+texte) — le bord/fond ne fait
   que renforcer visuellement un état qui existe déjà, jamais une info
   supplémentaire portée par la seule couleur (décision 5). */
/* Même spécificité que .entry.system .bubble (3 classes) — sinon ce dernier
   l'emporte quel que soit l'ordre des règles, et rien ne s'affiche. */
.entry.entry-pending .bubble { border-color: var(--warning); background: var(--warning-bg); }
.entry.entry-error .bubble { border-color: var(--alert); background: #362818; }

.generated-visual {
  display: block;
  max-width: 320px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-bottom: 0.5rem;
}

.meta-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.entry.user .meta-line { justify-content: flex-end; }
.meta-line .who { color: var(--ink-dim); font-weight: 700; }
.agent-id-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-faint);
  background: var(--line-soft);
  padding: 0 4px;
  border-radius: 2px;
}
.meta-line .time { font-family: var(--mono); color: var(--ink-faint); }
.meta-line .badge-new {
  background: rgba(232,163,61,0.15);
  color: var(--amber);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 9px;
}
.meta-line .badge-published {
  background: var(--success-bg);
  color: var(--success-text);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 9px;
  text-decoration: none;
}
.meta-line .badge-published:hover { text-decoration: underline; }
.meta-line .badge-blocked {
  background: rgba(193,70,47,0.18);
  color: var(--alert);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 9px;
}
/* Distinctes de .badge-blocked (décision 5) : "programmé" et "en attente" ne
   sont pas des échecs — seule .badge-blocked (⚠, refus, annulation) garde la
   couleur d'alerte. */
.meta-line .badge-scheduled {
  background: var(--info-bg);
  color: var(--info-text);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 9px;
}
.meta-line .badge-pending {
  background: var(--warning-bg);
  color: var(--warning-text);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 9px;
}
.meta-line .badge-article {
  background: rgba(138,107,44,0.22);
  color: var(--amber-dim);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 9px;
}
.handoff-note {
  font-size: 10.5px;
  font-style: italic;
  color: var(--ink-faint);
  margin-bottom: 0.3rem;
}
.publish-note {
  font-size: 11px;
  color: var(--alert);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.approval-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.6rem;
}
.approval-actions .btn-primary,
.approval-actions .btn-secondary {
  width: auto;
  padding: 8px 1.1rem;
  font-size: 11px;
}
.btn-secondary {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  font-family: var(--body);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--alert); color: var(--alert); }
.approval-actions button:disabled { opacity: 0.5; cursor: default; }

.thinking .bubble {
  color: var(--ink-dim);
  font-style: italic;
}
.thinking .patch { animation: blink 1.1s infinite; }
@media (prefers-reduced-motion: reduce) { .thinking .patch { animation: none; } }
@keyframes blink { 50% { opacity: 0.35; } }

form#composer {
  display: flex;
  align-items: flex-end;
  gap: 0.7rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
form#composer textarea {
  flex: 1;
  resize: none;
  height: 46px;
  max-height: 160px;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color 0.15s ease;
}
form#composer textarea::placeholder { color: var(--ink-faint); }
form#composer textarea:disabled { opacity: 0.6; }
form#composer .btn-primary { width: auto; padding: 0 1.4rem; height: 46px; }
form#composer .btn-primary:disabled { opacity: 0.6; cursor: default; }
@media (prefers-reduced-motion: reduce) { form#composer textarea { transition: none; } }

/* ---------- settings overlay ---------- */

.icon-btn {
  position: relative;
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  width: 32px;
  height: 32px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 15px;
  margin-left: 0.6rem;
  flex: none;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }

/* Menu « ⋯ » (portable uniquement) : masqués par défaut sur ordinateur. */
.more-btn { display: none; }
.more-menu { display: none; }

/* ---------- Sélecteur de site (espace de travail actif) ---------- */
.site-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
  margin-left: 0.9rem;
  padding: 5px 0.7rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 11.5px;
  cursor: pointer;
  max-width: 190px;
}
.site-chip:hover { border-color: var(--amber-dim); }

.mode-toggle {
  display: flex;
  flex: none;
  margin-left: 0.6rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}
.mode-toggle button {
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--body);
  font-weight: 700;
  font-size: 11.5px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
}
.mode-toggle button.active { background: var(--amber); color: var(--amber-ink); }
.expert-only { display: none; }
body[data-ui-mode="expert"] .expert-only { display: block; }
body[data-ui-mode="expert"] .expert-only.inline { display: inline; }
.site-chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.site-chip-arrow { flex: none; color: var(--amber); font-size: 10px; }

.site-menu {
  position: absolute;
  top: 100%;
  left: 1rem;
  z-index: 46;
  min-width: 230px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.site-menu.hide { display: none; }
.site-menu-title {
  margin: 0;
  padding: 0.6rem 0.9rem 0.4rem;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.site-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid var(--line-soft);
  color: var(--ink);
  font-family: var(--body);
  font-size: 13px;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
}
.site-menu button:hover { background: var(--line-soft); }
.site-menu button.active { color: var(--amber); font-weight: 700; }
.site-menu-new { color: var(--amber-dim) !important; }
/* L'en-tête doit être le repère de position du menu. */
header.console-head { position: relative; }

/* ---------- Documents & fichiers d'un site ---------- */
.site-file-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
}
.site-file-ico { flex: none; }
.site-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}
.site-file-meta { flex: none; font-size: 10.5px; color: var(--ink-faint); }
.site-file-del {
  flex: none;
  background: none;
  border: none;
  color: var(--alert);
  cursor: pointer;
  font-size: 13px;
  padding: 0 0.2rem;
}

.nav-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--alert);
  color: #fff;
  font-family: var(--body);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-sizing: border-box;
}
.nav-badge.hide { display: none; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.overlay.hide { display: none; }
.settings-section.hide { display: none; }

.settings-card {
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.3rem;
  border-bottom: 1px solid var(--line);
}
.settings-head h2 {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 400;
  margin: 0;
}

.settings-section {
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid var(--line);
}
.settings-section:last-child { border-bottom: none; }
.settings-section h3 {
  font-size: 13px;
  letter-spacing: 0.04em;
  margin: 0 0 0.4rem;
  color: var(--ink);
}
.settings-hint {
  font-size: 11.5px;
  color: var(--ink-dim);
  margin: 0 0 0.9rem;
  line-height: 1.5;
}
.settings-section input,
.settings-section select {
  width: 100%;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  margin-bottom: 0.8rem;
  font-family: inherit;
}
.settings-section .btn-primary { width: auto; padding: 8px 1.2rem; font-size: 11.5px; }
.settings-status {
  font-size: 11px;
  color: var(--ink-dim);
  min-height: 1.3em;
  margin: 0.5rem 0 0;
}
.settings-subsection {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}
.settings-subsection .btn-primary { margin-top: 0.3rem; }

.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.team-row .role,
.list-row .role {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber-dim);
  margin-left: 0.5rem;
}
.team-row .remove {
  background: none;
  border: none;
  color: var(--alert);
  cursor: pointer;
  font-size: 11px;
}

.icon-btn.hide { display: none; }

.empty-list {
  font-size: 11.5px;
  color: var(--ink-faint);
  font-style: italic;
}

.list-row {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.list-row:last-child { border-bottom: none; }

.list-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.list-row-top .who { font-weight: 700; }
.list-row-top .time { color: var(--ink-faint); font-size: 10.5px; }

.list-row-text {
  margin: 0.35rem 0 0;
  color: var(--ink-dim);
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.mission-status {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 2px;
}
.mission-status.done { background: var(--success-bg); color: var(--success-text); }
.mission-status.failed { background: rgba(193,70,47,0.18); color: var(--alert); }
.mission-status.in_progress { background: rgba(232,163,61,0.18); color: var(--amber); }
/* Icône + texte, jamais la couleur seule (décision 5 de la refonte V2). */
.mission-status.done::before { content: "✓ "; }
.mission-status.failed::before { content: "✕ "; }
.mission-status.in_progress::before { content: "🔄 "; }

.link-btn {
  width: auto;
  margin-top: 0.35rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--amber-dim);
  font-family: var(--body);
  font-size: 10.5px;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--amber); }

.mission-filter-banner { display: flex; align-items: center; gap: 0.4rem; }

.usage-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line-soft);
}
.usage-pagination .toggle-btn { width: auto; flex: 0 0 auto; }
#usage-page-info { flex: 1; text-align: center; }

.toggle-btn {
  width: auto;
  padding: 6px 0.9rem;
  font-size: 10.5px;
  font-family: var(--body);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
}
.toggle-btn.on { border-color: var(--amber-dim); color: var(--amber-dim); }
.toggle-btn:disabled { opacity: 0.5; cursor: default; }

.article-card {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.8rem;
  margin-bottom: 0.9rem;
}
.article-card .article-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  margin: 0 0 0.2rem;
}
.article-card .article-meta {
  font-size: 10.5px;
  color: var(--ink-faint);
  margin: 0 0 0.5rem;
}
.article-card .article-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}
.article-card .kw {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 2px;
  background: var(--line-soft);
  color: var(--ink-dim);
}
.article-card .article-metadesc {
  font-size: 11px;
  font-style: italic;
  color: var(--ink-dim);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}
.article-card .generated-visual { max-width: 200px; margin-bottom: 0.5rem; }
.article-card .article-body {
  max-height: 220px;
  overflow-y: auto;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  padding: 0.6rem;
  white-space: pre-wrap;
  margin-bottom: 0.6rem;
}
.article-card .article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.article-card .article-actions button {
  width: auto;
  padding: 7px 0.9rem;
  font-size: 10.5px;
}
.copy-feedback {
  font-size: 10.5px;
  color: var(--amber-dim);
  margin-left: 0.4rem;
  align-self: center;
}

/* ---------- Consommation IA (observabilité) ---------- */

.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}
.usage-stat {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.7rem 0.8rem;
  background: var(--card);
}
.usage-num {
  display: block;
  font-family: var(--display);
  font-size: 20px;
  color: var(--amber);
  letter-spacing: 0.02em;
}
.usage-lbl {
  display: block;
  font-size: 10.5px;
  color: var(--ink-dim);
  margin-top: 0.2rem;
  line-height: 1.3;
}
.usage-subtitle {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin: 0 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}
.usage-list { display: flex; flex-direction: column; }
.usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.usage-row:last-child { border-bottom: none; }
.usage-row-name { font-weight: 700; color: var(--ink); }
.usage-row-val { color: var(--ink-dim); font-size: 11px; }

/* ---------- Tableau de bord admin ---------- */

/* Donnée non encore mesurée : jamais présentée comme une vraie valeur —
   texte plus petit et plus discret que les vrais chiffres du dashboard. */
.usage-stat.not-measured .usage-num {
  font-family: inherit;
  font-size: 11px;
  font-style: italic;
  color: var(--ink-faint);
  letter-spacing: 0;
}
.agent-status-grid { margin: 0.6rem 0; }

/* Filtres d'historique : une simple rangée qui s'enroule sur petit écran,
   jamais de scroll horizontal (voir docs/PROJECT_STATE.md, règles UI). */
.usage-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.usage-filters select {
  flex: 1 1 140px;
  min-width: 0;
}

/* ---------- Suivi GEO ---------- */

.geo-site-group { margin-bottom: 1.1rem; }
.geo-site-title {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink);
  margin: 0 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}
.geo-card {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.7rem;
  margin-bottom: 0.7rem;
}
.geo-card .geo-prompt {
  font-size: 12px;
  color: var(--ink);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}
.geo-engines { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 0.5rem; }
.geo-engine {
  font-size: 11px;
  color: var(--ink-dim);
}
.geo-engine .eng-name { font-weight: 700; color: var(--ink); }
.geo-cited { color: var(--success-text); font-weight: 700; }
.geo-not-cited { color: var(--alert); font-weight: 700; }
.geo-pending { color: var(--ink-faint); font-style: italic; }
.geo-competitors {
  font-size: 10.5px;
  color: var(--ink-faint);
  margin: 0.2rem 0 0;
}
.geo-checked {
  font-size: 9.5px;
  color: var(--ink-faint);
  margin: 0.3rem 0 0;
}
.geo-card-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.geo-card-actions button { width: auto; padding: 6px 0.8rem; font-size: 10.5px; }
.geo-suggestion {
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 11.5px;
}
.geo-suggestion .geo-sug-prompt { color: var(--ink); margin: 0 0 0.3rem; }
.geo-suggestion .geo-sug-meta { color: var(--ink-faint); font-size: 10px; margin: 0 0 0.4rem; }
.geo-suggestion button { width: auto; padding: 5px 0.8rem; font-size: 10px; }

/* ---------- responsive ---------- */

/* ---------- responsive : tablette & petits écrans ---------- */

@media (max-width: 900px) {
  /* Portable ET tablette en portrait (≤900px) : UNE seule barre en haut —
     l'en-tête — qui sert aussi de sélecteur d'agent. Toute la hauteur restante
     va à la conversation. Taper l'en-tête déroule l'escouade, ancrée juste
     dessous, par-dessus la conversation. (Au-delà de 900px : barre latérale.) */
  #app.active { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  /* Le nom de l'agent ne doit jamais passer sur deux lignes. */
  header.console-head h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-agent-text { min-width: 0; }
  aside { border: none; }
  /* Le repli en rail d'icônes n'a pas de sens dans le tiroir déroulant
     mobile (déjà ouvert/fermé par l'en-tête agent) — voir REFONTE V2. */
  .sidebar-collapse-btn { display: none; }

  /* L'en-tête devient tappable + une flèche indique qu'on peut dérouler. */
  .header-agent { cursor: pointer; flex: 1; }
  .header-chevron {
    display: inline-block;
    flex: none;
    color: var(--amber);
    font-size: 13px;
    margin-left: 0.15rem;
    transition: transform 0.15s ease;
  }
  #app.menu-open .header-chevron { transform: rotate(180deg); }

  /* Le panneau déroulant : ancré sous l'en-tête (top posé par JS), par-dessus
     la conversation, sans la pousser. */
  .roster-panel {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 40;
    flex: none;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 14px 26px rgba(0, 0, 0, 0.55);
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #app.menu-open .roster-panel { display: block; }
  .aside-head { padding: 0.7rem 1rem 0.5rem; }

  /* Les recrues : une liste verticale de menu, cibles tactiles confortables. */
  #roster { display: block; flex: none; overflow: visible; padding: 0.4rem; }
  .recruit { padding: 0.7rem 0.8rem; gap: 0.7rem; margin-bottom: 0.1rem; }
  .recruit .patch.md { width: 38px; height: 38px; }
  .recruit .name { font-size: 13px; }
  .recruit .domain { font-size: 11px; }
  .recruit .since { display: none; }
  button.commandement { padding: 0.8rem 1rem; }
  .entry { max-width: 92%; }
  header.console-head { padding: 0.85rem 1rem; gap: 0.6rem; position: relative; }
  header.console-head .subtitle { display: none; }

  /* Portable : la barre d'outils déborderait (6+ boutons) → on la remplace par
     un seul « ⋯ » qui ouvre un menu. Le nom de l'agent récupère toute la place. */
  header.console-head .icon-btn:not(.more-btn) { display: none; }
  .more-btn { display: flex; align-items: center; justify-content: center; }
  .more-menu {
    display: block;
    position: absolute;
    top: 100%;
    right: 0.6rem;
    z-index: 45;
    min-width: 210px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
    overflow: hidden;
  }
  .more-menu.hide { display: none; }
  .more-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink);
    font-family: var(--body);
    font-size: 14px;
    padding: 0.8rem 1rem;
    cursor: pointer;
  }
  .more-menu button:last-child { border-bottom: none; }
  .more-menu button:hover, .more-menu button:active { background: var(--line-soft); }
  .more-menu button.hide { display: none; }
  #thread { padding: 1rem; }
  form#composer { padding: 0.8rem 1rem; }

  /* Cibles tactiles plus grandes. */
  .icon-btn { width: 38px; height: 38px; margin-left: 0.4rem; }

  /* < 16px déclenche le zoom automatique d'iOS au focus d'un champ — on force 16px. */
  input, textarea, select,
  #login input,
  .settings-section input, .settings-section select,
  form#composer textarea,
  #geo-suggest-form input { font-size: 16px; }

  /* Les fenêtres (Paramètres, Admin, GEO…) passent en plein écran, plus lisibles au doigt. */
  .overlay { padding: 0; align-items: stretch; }
  .settings-card { max-width: none; max-height: 100vh; min-height: 100vh; border: none; }
  .settings-head { position: sticky; top: 0; background: var(--panel); z-index: 1; }
  .icon-btn { flex: none; }

  /* Images générées : ne pas dépasser la largeur de l'écran. */
  .generated-visual, .article-card .generated-visual { max-width: 100%; }
}

/* ---------- responsive : téléphone ---------- */

@media (max-width: 600px) {
  /* En-tête compact : on masque l'insigne de marque et le texte « en ligne »,
     on rétrécit le titre (avec troncature) pour laisser la place aux boutons d'action. */
  #header-patch { display: none; }
  header.console-head h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Le bloc titre peut rétrécir (troncature) mais ne doit pas grandir, sinon
     il pousse les boutons d'action hors de l'écran. */
  .header-agent-text { min-width: 0; flex: 0 1 auto; }
  /* Le point « En ligne » est décoratif : on le retire sur téléphone pour
     laisser toute la place au nom de l'agent et aux boutons. */
  header.console-head .status { display: none; }
  .icon-btn { width: 34px; height: 34px; margin-left: 0.25rem; font-size: 14px; }

  .entry { max-width: 100%; }
  #thread { padding: 0.8rem; }
  .settings-section { padding: 0.9rem 1rem; }
  .settings-head { padding: 0.9rem 1rem; }
  .article-card .article-body { max-height: 200px; }
}
