/* PresenceBench (ADR 0006, UI-2) : thème sombre unique d'après
 * docs/design/ui-2/Main.dc.html ; tous les jetons dans tokens.css.
 * La zone #pb-capture et les stimuli sont hors périmètre : les
 * règles .pb-stage/.pb-stimulus/.pb-decoy/.pb-answers/.pb-answer
 * sont inchangées. Aucune ressource externe. */

* {
  box-sizing: border-box;
}

html {
  font-size: 1rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
}

h1 {
  font-size: var(--text-title);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 var(--sp-16);
}

h2 {
  font-size: var(--text-section);
  font-weight: 600;
  margin: var(--sp-32) 0 var(--sp-12);
}

h3 {
  font-size: var(--text-body);
  font-weight: 600;
  margin: 0 0 var(--sp-8);
}

p {
  margin: 0 0 var(--sp-16);
}

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

a:hover {
  color: var(--link-hover);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

code,
.pb-mono {
  font-family: var(--font-mono);
}

/* Coque */
.pb-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.pb-header {
  border-bottom: 1px solid var(--separator);
  background: var(--surface);
}

.pb-header-inner {
  max-width: 80rem;
  margin: 0 auto;
  padding: var(--sp-12) var(--sp-16);
  display: flex;
  align-items: center;
  gap: var(--sp-16);
  flex-wrap: wrap;
}

.pb-brand {
  display: flex;
  flex-direction: column;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.25;
}

.pb-brand-sub {
  color: var(--text-2);
  font-weight: 400;
  font-size: var(--text-meta);
}

.pb-nav {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  background: var(--surface-2);
  border-radius: var(--radius-8);
  padding: var(--sp-4);
}

.pb-nav a {
  color: var(--text-2);
  text-decoration: none;
  padding: var(--sp-8) var(--sp-12);
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-8);
}

.pb-nav a:hover {
  color: var(--text);
  background: var(--separator);
}

.pb-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--bg);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--separator);
}

.pb-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  flex-wrap: wrap;
}

/* « n rôles » dépliable (Operator-Control.dc.html) */
.pb-roles {
  color: var(--text-2);
  font-size: var(--text-meta);
}

.pb-roles summary {
  cursor: pointer;
  list-style: none;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  padding: var(--sp-8) var(--sp-12);
  border-radius: var(--radius-8);
  border: 1px solid var(--separator);
}

.pb-roles summary::after {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: var(--sp-8);
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg) translateY(-2px);
}

.pb-roles[open] summary::after {
  transform: rotate(225deg) translateY(-1px);
}

.pb-roles-list {
  display: flex;
  gap: var(--sp-8);
  flex-wrap: wrap;
  margin-top: var(--sp-8);
}

.pb-roles code {
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius-8);
  padding: var(--sp-4) var(--sp-8);
  font-size: var(--text-meta);
}

/* Sélecteur de langue : cibles de 44 px */
.pb-lang {
  display: flex;
  gap: var(--sp-4);
}

.pb-lang a {
  color: var(--link);
  text-decoration: none;
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-8);
}

.pb-lang a[aria-current="true"] {
  color: var(--text);
  font-weight: 600;
  background: var(--surface-2);
}

.pb-logout {
  margin: 0;
}

/* Bandeau FROZEN */
.pb-banner {
  background: var(--error-bg);
  border-bottom: 1px solid var(--error);
  color: var(--error-light);
  padding: var(--sp-8) var(--sp-16);
  text-align: center;
  font-weight: 600;
}

.pb-main {
  flex: 1;
  max-width: 80rem;
  width: 100%;
  margin: 0 auto;
  padding: var(--sp-24) var(--sp-16) var(--sp-48);
}

.pb-main--narrow {
  max-width: 40rem;
}

.pb-footer {
  border-top: 1px solid var(--separator);
  color: var(--text-2);
  font-size: var(--text-meta);
  padding: var(--sp-16);
  text-align: center;
}

/* Cartes et panneaux */
.pb-panel {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-12);
  padding: var(--sp-24);
  margin-bottom: var(--sp-24);
}

.pb-panel > :first-child {
  margin-top: 0;
}

.pb-panel > :last-child {
  margin-bottom: 0;
}

.pb-panel--sub {
  background: var(--surface-2);
}

.pb-info {
  background: var(--selected-bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-12);
  padding: var(--sp-16);
  margin-bottom: var(--sp-24);
}

.pb-note-warn {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-12);
  color: var(--text-3);
  padding: var(--sp-12) var(--sp-16);
  margin-bottom: var(--sp-24);
}

.pb-note-err {
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius-12);
  color: var(--error-light);
  padding: var(--sp-12) var(--sp-16);
  margin-bottom: var(--sp-16);
}

.pb-empty {
  color: var(--text-2);
  border: 1px dashed var(--separator);
  border-radius: var(--radius-12);
  padding: var(--sp-32);
  text-align: center;
  margin-bottom: var(--sp-24);
}

/* Indicateurs */
.pb-indicators {
  display: flex;
  gap: var(--sp-12);
  flex-wrap: wrap;
  margin-bottom: var(--sp-24);
}

.pb-indicator {
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius-12);
  padding: var(--sp-16);
  min-width: 11rem;
}

.pb-ind-name {
  color: var(--text-2);
  font-size: var(--text-meta);
}

.pb-ind-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pb-ind-meta {
  color: var(--text-2);
  font-size: var(--text-meta);
}

.pb-ind-na {
  color: var(--warning);
  font-size: 0.95rem;
}

/* Tableaux : boîte à défilement horizontal */
.pb-table-wrap {
  overflow-x: auto;
  margin-bottom: var(--sp-24);
  border: 1px solid var(--separator);
  border-radius: var(--radius-12);
}

table.pb-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
}

.pb-table th,
.pb-table td {
  text-align: left;
  padding: var(--sp-12) var(--sp-16);
  border-bottom: 1px solid var(--separator);
  white-space: nowrap;
}

.pb-table tr:last-child td {
  border-bottom: none;
}

.pb-table th {
  color: var(--text-2);
  font-size: var(--text-meta);
  font-weight: 600;
  background: var(--surface-2);
}

.pb-table a {
  min-height: 1.5rem;
  display: inline-flex;
  align-items: center;
}

/* Formulaires : libellé au-dessus, champs 48 px (56 px
 * participant), police >= 16 px, bordure >= 3:1 */
.pb-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
  margin-bottom: var(--sp-16);
}

.pb-field label,
.pb-field > span:first-child {
  color: var(--text-3);
  font-size: var(--text-meta);
  font-weight: 500;
}

.pb-field select,
.pb-field input[type="text"] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-8);
  padding: 0 var(--sp-12);
  min-height: 3rem;
  font-size: var(--text-body);
  font-family: var(--font-sans);
  width: 100%;
}

.pb-filters {
  display: flex;
  gap: var(--sp-16);
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: var(--sp-24);
}

.pb-filters .pb-field {
  margin-bottom: 0;
}

.pb-hint {
  color: var(--text-2);
  font-size: var(--text-meta);
  margin: 0;
}

/* Boutons : 44 px opérateur, 56 px participant pleine largeur */
.pb-btn {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-8);
  padding: 0 var(--sp-16);
  min-height: 2.75rem;
  font-size: var(--text-body);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-8);
  text-decoration: none;
}

.pb-btn:hover {
  background: var(--link-hover);
}

.pb-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pb-btn--quiet {
  background: transparent;
  color: var(--text-3);
  border: 1px solid var(--field-border);
  font-weight: 500;
}

.pb-btn--quiet:hover {
  color: var(--text);
  background: var(--surface-2);
}

.pb-btn--danger {
  background: var(--error-bg);
  color: var(--error-light);
  border: 1px solid var(--error);
}

.pb-btn--danger:hover {
  background: var(--error);
  color: var(--on-primary);
}

.pb-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-16);
  margin-top: var(--sp-24);
}

.pb-actions .pb-btn {
  min-height: 3.5rem;
}

/* Écrans participant : actions pleine largeur 56 px */
.pb-participant .pb-btn {
  width: 100%;
  min-height: 3.5rem;
}

.pb-participant .pb-lang a,
.pb-participant .pb-choice {
  min-height: 2.75rem;
}

[hidden] {
  display: none !important;
}

/* Champ de code : 56 px, mono 22 px centré */
.pb-field input.pb-code-input {
  min-height: 3.5rem;
  font-family: var(--font-mono);
  font-size: 1.375rem;
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-8);
  padding: 0 var(--sp-12);
  width: 100%;
}

/* Indicateur d'étape + barre de progression */
.pb-step {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  margin-bottom: var(--sp-24);
}

.pb-step-label {
  color: var(--text-2);
  font-size: var(--text-meta);
  white-space: nowrap;
}

.pb-step progress {
  flex: 1;
  height: 0.375rem;
  appearance: none;
  border: none;
  border-radius: 999px;
  background: var(--surface-2);
}

.pb-step progress::-webkit-progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
}

.pb-step progress::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}

.pb-step progress::-moz-progress-bar {
  background: var(--primary);
  border-radius: 999px;
}

/* Cases et options : toute la ligne cliquable, 44 px minimum */
.pb-choice {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  min-height: 2.75rem;
  padding: var(--sp-8) var(--sp-12);
  border: 1px solid var(--separator);
  border-radius: var(--radius-8);
  background: var(--surface-2);
  cursor: pointer;
}

.pb-choice input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.pb-choice:has(input:checked) {
  border-color: var(--primary);
  background: var(--selected-bg);
}

.pb-choice + .pb-choice {
  margin-top: var(--sp-8);
}

/* « préfère ne pas répondre » : ligne en pointillés */
.pb-choice--prefer {
  border-style: dashed;
}

.pb-group {
  border: none;
  margin: 0 0 var(--sp-16);
  padding: 0;
}

.pb-group legend {
  color: var(--text-3);
  font-size: var(--text-meta);
  font-weight: 500;
  padding: 0;
  margin-bottom: var(--sp-8);
}

.pb-group-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-8);
}

.pb-group-options .pb-choice {
  margin: 0;
}

@media (max-width: 30rem) {
  .pb-group-options {
    grid-template-columns: 1fr;
  }
}

/* Consentement : texte complet, lisible, sans troncature
 * (pas de marqueurs de section dans les fichiers versionnés). */
.pb-consent {
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius-12);
  padding: var(--sp-16);
  white-space: pre-wrap;
  margin-bottom: var(--sp-16);
  color: var(--text-3);
}

.pb-dim {
  color: var(--text-2);
  font-size: var(--text-meta);
}

/* Badges d'état */
.pb-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: var(--sp-4) var(--sp-12);
  font-size: var(--text-meta);
  font-weight: 600;
  background: var(--selected-bg);
  color: var(--link);
}

.pb-badge--open,
.pb-badge--live {
  background: var(--success-bg);
  color: var(--success);
}

.pb-badge--closed {
  background: var(--surface-2);
  color: var(--text-2);
}

.pb-badge--created {
  background: var(--selected-bg);
  color: var(--link);
}

.pb-badge--warn {
  background: var(--warning-bg);
  color: var(--warning);
}

.pb-badge--err {
  background: var(--error-bg);
  color: var(--error-light);
}

.pb-ok {
  color: var(--success);
}

.pb-warn {
  color: var(--warning);
}

.pb-err {
  color: var(--error);
}

.pb-err-box {
  display: flex;
  gap: var(--sp-12);
  align-items: flex-start;
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius-12);
  color: var(--error-light);
  padding: var(--sp-12) var(--sp-16);
  margin-bottom: var(--sp-16);
}

.pb-err-box svg {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Épreuves (E3.4) : scène, stimulus positionné, boutons de
 * réponse, leurre invisible pour l'humain mais présent dans le
 * DOM (mécanisme « decoy_followed » du protocole v5). HORS
 * PÉRIMÈTRE UI-2 : règles inchangées. */
.pb-stage {
  position: relative;
  min-height: 12rem;
  margin: 1rem 0;
  border: 1px solid var(--pb-line, #d0d0d0);
  border-radius: 0.5rem;
}

.pb-stimulus {
  position: absolute;
  font-weight: 700;
  white-space: nowrap;
}

.pb-decoy {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.pb-answers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

.pb-answer {
  min-width: 4.5rem;
  min-height: 3.5rem;
  font-size: 1.5rem;
}

/* Retrait (ADR 0007 §6) : action en bas de chaque écran après
 * l'accord ; code affiché en grand à la fin de la séance. */
.pb-withdraw {
  margin-top: var(--sp-32);
  border-top: 1px solid var(--separator);
  padding-top: var(--sp-16);
}

.pb-code {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  letter-spacing: 0.1em;
  text-align: center;
  padding: var(--sp-12);
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius-8);
  user-select: all;
}

.pb-code-row {
  display: flex;
  gap: var(--sp-12);
  align-items: stretch;
}

.pb-code-row .pb-code {
  flex: 1;
}

.pb-code-row .pb-btn {
  align-self: center;
}

/* Le bouton « Copier le code » reste compact à côté du code,
 * même dans le contexte participant (boutons pleine largeur). */
.pb-participant .pb-code-row .pb-btn {
  width: auto;
  min-height: 2.75rem;
  flex-shrink: 0;
}

/* QR : noir sur blanc, marge de silence 4 modules */
.pb-qr {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-16);
}

.pb-qr svg {
  width: 220px;
  height: 220px;
  background: #fff;
  padding: 1rem;
  border-radius: var(--radius-8);
}

/* Suivi en direct : seul le libellé d'état est annoncé ; la
 * région #pb-live se met à jour sans annonce. */
.pb-live-controls {
  display: flex;
  gap: var(--sp-12);
  align-items: center;
  flex-wrap: wrap;
}

/* Grille des rangs de session (Operator-Sittings.dc.html) */
.pb-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--sp-12);
  list-style: none;
  margin: 0 0 var(--sp-24);
  padding: 0;
}

.pb-card {
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius-12);
  padding: var(--sp-12) var(--sp-16);
}

/* Détail « liste de définitions » du suivi */
.pb-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sp-8) var(--sp-24);
  margin: 0 0 var(--sp-16);
}

.pb-facts dt {
  color: var(--text-2);
  font-size: var(--text-meta);
}

.pb-facts dd {
  margin: 0;
}

/* Progression « transactions x/y » */
.pb-progress {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
}

.pb-progress progress {
  flex: 1;
  height: 0.375rem;
  appearance: none;
  border: none;
  border-radius: 999px;
  background: var(--surface-2);
}

.pb-progress progress::-webkit-progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
}

.pb-progress progress::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}

.pb-progress progress::-moz-progress-bar {
  background: var(--primary);
  border-radius: 999px;
}

.pb-progress-label {
  color: var(--text-2);
  font-size: var(--text-meta);
  white-space: nowrap;
}

/* Deux colonnes pour la page code + QR */
.pb-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-24);
}

@media (max-width: 40rem) {
  .pb-duo {
    grid-template-columns: 1fr;
  }
}
