/* Passages (#/runs) : prototype Passages.dc.html.
   Styles propres à cet écran (refonte du prototype v73) : un fichier par écran, chargé par index.html après
   shell.css. Téléphone : @media (max-width: 767px), comme la coque. Classes « ps- » ; les anciennes règles
   .card--run / .runform / .prog / .pstep / .pieces d'app.css sont reprises ici, à l'intérieur de .ps seulement
   (l'Accueil garde les siennes). */

.ps {
  --ps-bad-bg: #FBE9E7; --ps-bad-ink: #7A1D13; --ps-bad-mark: #A1271B;
  --ps-info-bg: #DCEBF2; --ps-info-ink: #163E50;
  --ps-row-line: #EEF2EA; --ps-off: #C2CEC5; --ps-on-bg: #E3F1E7; --ps-step-todo: #5A6B60;
  display: flex; flex-direction: column; gap: 16px;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .ps {
    --ps-bad-bg: var(--app-bad-bg); --ps-bad-ink: var(--app-bad-ink); --ps-bad-mark: var(--app-bad-dot);
    --ps-info-bg: var(--fr-surface-2); --ps-info-ink: var(--fr-ink);
    --ps-row-line: var(--fr-line); --ps-off: var(--fr-line); --ps-on-bg: var(--fr-ok-soft); --ps-step-todo: var(--fr-muted);
  }
}
:root[data-theme="dark"] .ps {
  --ps-bad-bg: var(--app-bad-bg); --ps-bad-ink: var(--app-bad-ink); --ps-bad-mark: var(--app-bad-dot);
  --ps-info-bg: var(--fr-surface-2); --ps-info-ink: var(--fr-ink);
  --ps-row-line: var(--fr-line); --ps-off: var(--fr-line); --ps-on-bg: var(--fr-ok-soft); --ps-step-todo: var(--fr-muted);
}

.ps [hidden] { display: none !important; }
.ps p { margin: 0; }
.ps > .page-head { margin-bottom: 4px; }
.ps > .page-head .lede { margin-top: 6px; }
.ps-todo-box:empty { display: none; }
.ps .tag--info { background: var(--ps-info-bg); color: var(--ps-info-ink); }
.ps .tag--warn { background: var(--app-soft); color: var(--app-soft-ink); }
.ps .tag--bad { background: var(--app-bad-bg); color: var(--app-bad-ink); }

/* Cartes */
.ps-card { padding: 24px; background: var(--app-surface); border: 1px solid var(--fr-line); border-radius: 12px; box-shadow: var(--fr-shadow-1); min-width: 0; }
.ps-card > h2 { margin: 0 0 12px; font-size: 18px; font-weight: 700; line-height: 1.3; }
.ps-launch > h2 { margin-bottom: 14px; }

/* À faire */
.ps-todo { padding: 14px 18px; background: var(--ps-bad-bg); color: var(--ps-bad-ink); border-radius: 12px; }
.ps-todo h2 { margin: 0 0 6px; font-size: 16px; font-weight: 800; }
.ps-todo__list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ps-todo__item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.ps-todo__text { flex: 1 1 360px; min-width: 0; }
.ps-todo__title { color: inherit; font-size: 15px; font-weight: 700; text-decoration: underline; }
.ps-todo__title:hover { color: inherit; text-decoration-thickness: 2px; }
.ps-todo__why { margin-top: 2px !important; font-size: 14px; }
.ps-todo__btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 18px; border-radius: 12px;
  background: var(--ps-bad-ink); color: var(--ps-bad-bg); font-size: 14px; font-weight: 700; line-height: 1.2; text-decoration: none; }
.ps-todo__btn:hover { color: var(--ps-bad-bg); filter: brightness(1.15); }
.ps-todo a:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* Lancer un passage : tout sur une ligne, le bouton vert au bout */
.ps-form { display: flex; flex-direction: column; gap: 12px; }
.ps-form > div:empty { display: none; }
.ps-line { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.ps .field { gap: 4px; }
.ps .field__label { font-size: 14px; font-weight: 500; }
.ps-portal { flex: 0 1 200px; min-width: 160px; }
.ps .ps-form .input, .ps .ps-form .select { min-height: 40px; padding: 8px 12px; border: 1px solid var(--app-line-strong); border-radius: 8px;
  background-color: var(--app-surface); color: var(--app-ink); font-size: 16px; }
.ps .ps-form .select { padding-right: 36px; }
.ps-period { flex: none; display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; border: 0; min-width: 0; }
.ps-period legend { padding: 0 0 4px; }
.ps-period__choices { display: flex; align-items: center; gap: 16px; min-height: 40px; }
.ps-radio { display: flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; }
.ps-radio input { width: 18px; height: 18px; }
.ps-dates { flex: 1 1 340px; display: flex; gap: 12px 16px; min-width: 0; }
.ps-dates > .field { flex: 1 1 0; }
.ps-one { flex: 1 1 340px; }
.ps-line > .btn--primary { flex: none; min-height: 40px; padding: 0 20px; border-radius: 12px; font-size: 15px; font-weight: 700; }
.ps-error { padding: 10px 14px; border-radius: 10px; background: var(--ps-bad-bg); color: var(--ps-bad-ink); font-size: 15px; }
.ps-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 14px; color: var(--app-muted); }
.ps-more { padding: 0; border: 0; background: transparent; color: var(--fr-brand); font: inherit; font-size: 14px; font-weight: 700;
  text-decoration: underline; cursor: pointer; }
.ps-more:focus-visible { outline: 2px solid var(--fr-primary); outline-offset: 2px; border-radius: 4px; }
.ps-options { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; background: var(--app-bg); border-radius: 10px; }
.ps-group { display: flex; align-items: flex-start; gap: 8px; }
.ps-group__label { flex: none; width: 104px; padding-top: 7px; font-size: 14px; font-weight: 600; }
.ps-chips { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ps-chips > .ps-chips { display: contents; }
.ps-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px; border: 1px solid var(--ps-off);
  border-radius: 999px; background: var(--app-surface); font-size: 14px; font-weight: 500; cursor: pointer; }
.ps-chip:has(input:checked) { border-color: var(--app-primary); background: var(--ps-on-bg); }
.ps-chip input { width: 16px; height: 16px; border-radius: 4px; }
.ps-dry { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.ps-dry input { width: 18px; height: 18px; }
.ps-dry strong { font-weight: 600; }
.ps-dry__text { color: var(--fr-muted); }
.ps-none { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; color: var(--app-muted); }

/* Derniers passages */
.ps-history { padding: 8px 24px; }
.ps-history > h2 { margin: 8px 0 4px; }
.ps-list { margin: 0; padding: 0; list-style: none; }
.ps-item { position: relative; border-top: 1px solid var(--ps-row-line); }
.ps-row { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 60px; padding: 10px 0; color: var(--app-ink); text-decoration: none; }
.ps-row:hover { color: var(--app-ink); }
.ps-row:hover .ps-row__title { text-decoration: underline; }
.ps-row:focus-visible { outline: 2px solid var(--fr-primary); outline-offset: 2px; border-radius: 6px; }
.ps-row__tag { flex: none; width: 92px; }
.ps-row__text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.ps-row__title { display: block; font-size: 15px; font-weight: 600; }
.ps-row__sub { display: block; margin-top: 2px; font-size: 13px; color: var(--app-muted); }
.ps-row .ps-row__bar { flex: none; width: 140px; height: 8px; }
.ps-row__brief { flex: none; width: 260px; font-size: 14px; color: var(--app-muted); text-align: right; }
.ps-row__go { flex: none; font-size: 22px; line-height: 1; color: var(--fr-muted); }
.ps-empty { padding: 12px 0 16px; font-size: 14px; color: var(--app-muted); }

/* Détail */
.ps-back a { color: var(--fr-brand); font-size: 15px; font-weight: 600; text-decoration: underline; }
.ps-detail { display: flex; flex-direction: column; gap: 16px; }
.ps-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; }
.ps-head__text { flex: 1 1 480px; min-width: 0; }
.ps-head h1 { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.ps-head__state { margin-top: 8px !important; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 15px; color: var(--app-muted); }
.ps-head__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ps-head__actions .btn { min-height: 40px; border-radius: 12px; font-weight: 700; }
.ps-head__actions .btn--secondary { padding: 0 16px; border-color: var(--app-line); font-size: 14px; }
.ps-head__actions .btn--primary { padding: 0 20px; font-size: 15px; }
.ps-stopped { padding: 12px 16px; border-radius: 12px; background: var(--ps-bad-bg); color: var(--ps-bad-ink); }
.ps-stopped__title { font-weight: 700; }
.ps-stopped p + p { margin-top: 4px; font-size: 15px; }
.ps-detail .prog { margin-top: 0; gap: 10px; }
.ps-detail .prog__pct { font-size: 14px; }
.ps-detail .prog__pct strong { font-size: 18px; }
.ps-detail .prog__pct .small { font-size: 14px; color: var(--app-muted); }
.ps-detail .pstep { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 4px 0 0; padding: 0; list-style: none; }
.ps-detail .pstep__i { gap: 8px; padding: 0; border: 0; font-weight: 500; color: var(--ps-step-todo); }
.ps-detail .pstep__mark { width: 26px; height: 26px; box-sizing: border-box; border: 2px solid var(--ps-off); background: var(--app-surface);
  color: var(--ps-step-todo); font-weight: 700; }
.ps-detail .pstep__i--done, .ps-detail .pstep__i--current { color: var(--app-ink); }
.ps-detail .pstep__i--done .pstep__mark { border-color: var(--app-primary); background: var(--app-primary); color: var(--app-on-primary); }
.ps-detail .pstep__i--current .pstep__mark { border-color: var(--app-primary); background: var(--app-surface); color: var(--app-primary); }
.ps-detail .pstep__i--bad { color: var(--ps-bad-ink); }
.ps-detail .pstep__i--bad .pstep__mark { border-color: var(--ps-bad-mark); background: var(--ps-bad-mark); color: #FFFFFF; }
.ps-detail .pieces { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.ps-detail .pieces__i { flex-wrap: nowrap; gap: 8px; padding: 8px 12px; border: 0; border-radius: 8px; background: var(--app-bg); min-width: 0; }
.ps-detail .pieces__k { padding: 0; border-radius: 0; background: none; color: var(--app-ink); font-size: 14px; font-weight: 600; text-transform: none; letter-spacing: normal; }
.ps-detail .pieces__i > span + span { color: var(--app-muted); }
.ps-detail .pieces + .small { margin-top: 8px; font-size: 14px; color: var(--app-muted); }
.ps-detail .ps-card > .small.muted { font-size: 14px; color: var(--app-muted); }
.ps-facts { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 24px; }
.ps-facts > div { min-width: 0; overflow-wrap: anywhere; }
.ps-facts dt { font-size: 13px; color: var(--fr-muted); }
.ps-facts dd { margin: 2px 0 0; font-size: 15px; font-weight: 500; }

/* Téléphone et tablette (le doigt, jusqu'à 1 199 px ; audit EC-13) : « Modifier » et le titre d'une tâche gardent leur
   dessin de lien, leur zone touchée s'agrandit (fos-slow-9) */
@media (max-width: 1199px) {
  .ps-more, .ps-todo__title { position: relative; }
  .ps-more::before { content: ""; position: absolute; inset: -12px -4px; }
  .ps-todo__title::before { content: ""; position: absolute; inset: -11px 0; }
}

/* Téléphone : pas de maquette ; tout s'empile, rien ne déborde à 375 px */
@media (max-width: 767px) {
  /* doigt : 44 px (fos-slow-9) */
  .ps-radio, .ps .ps-form .input, .ps .ps-form .select, .ps-line > .btn--primary { min-height: 44px; }
  .ps-card { padding: 16px; }
  .ps-history { padding: 4px 16px; }
  .ps-portal, .ps-period, .ps-dates, .ps-one, .ps-line > .btn--primary { flex: 1 1 100%; }
  .ps-period__choices { flex-wrap: wrap; gap: 8px 16px; }
  .ps-group { flex-direction: column; gap: 6px; }
  .ps-group__label { width: auto; padding-top: 0; }
  .ps-row { flex-wrap: wrap; gap: 6px 12px; padding-right: 24px; }
  .ps-row__tag { width: auto; }
  .ps-row__text { order: 2; flex: 1 1 100%; }
  .ps-row .ps-row__bar { order: 3; flex: 1 1 100%; width: auto; }
  .ps-row__brief { order: 4; width: auto; text-align: left; }
  .ps-row__brief:empty { display: none; }
  .ps-row__go { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
  .ps-head h1 { font-size: 22px; }
  .ps-detail .pstep { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ps-detail .pieces { grid-template-columns: minmax(0, 1fr); }
  .ps-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
