/* Relevé terrain — feuille de style
   Direction : signalétique industrielle. Barre de tête sombre « cartouche »,
   jaune de sécurité réservé à l'action de capture, codes EESS en semi-condensé. */

@font-face {
  font-family: "Barlow SC";
  src: url("../fonts/bsc-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Barlow SC";
  src: url("../fonts/bsc-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #eceff1;
  --surface: #ffffff;
  --surface-2: #f6f7f8;
  --ink: #15191d;
  --muted: #5b6570;
  --faint: #8a939c;
  --rule: #d3d8dc;
  --bar: #15191d;
  --bar-ink: #f3f5f6;
  --bar-muted: #a6b0b9;
  --signal: #ffc600;
  --on-signal: #15191d;
  --focus: #1f6feb;

  --nc: #c62828;
  --nv: #d97706;
  --c: #2e7d32;
  --hm: #64707c;
  --so: #64707c;
  --nc-bg: #fdecec;
  --nv-bg: #fef3e2;
  --c-bg: #e9f4ea;
  --hm-bg: #eef0f2;

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --display: "Barlow SC", "Arial Narrow", system-ui, sans-serif;
  --body: -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --dock-h: 76px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111417;
    --surface: #1a1e23;
    --surface-2: #20252b;
    --ink: #eceff1;
    --muted: #a3adb7;
    --faint: #7c8792;
    --rule: #2d343b;
    --bar: #0c0f12;
    --bar-ink: #eceff1;
    --bar-muted: #8f9aa5;
    --focus: #6aa7ff;
    --nc: #ef5350;
    --nv: #f59e0b;
    --c: #66bb6a;
    --hm: #9aa4ae;
    --so: #9aa4ae;
    --nc-bg: #3a1a1a;
    --nv-bg: #3a2a12;
    --c-bg: #17301a;
    --hm-bg: #262c32;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111417;
  --surface: #1a1e23;
  --surface-2: #20252b;
  --ink: #eceff1;
  --muted: #a3adb7;
  --faint: #7c8792;
  --rule: #2d343b;
  --bar: #0c0f12;
  --bar-ink: #eceff1;
  --bar-muted: #8f9aa5;
  --focus: #6aa7ff;
  --nc: #ef5350;
  --nv: #f59e0b;
  --c: #66bb6a;
  --hm: #9aa4ae;
  --so: #9aa4ae;
  --nc-bg: #3a1a1a;
  --nv-bg: #3a2a12;
  --c-bg: #17301a;
  --hm-bg: #262c32;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.42 var(--body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Structure ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 100dvh; }
.content {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + var(--safe-bottom));
}
.has-dock .content { padding-bottom: calc(var(--dock-h) + 28px + var(--safe-bottom)); }

/* ---------- Barre de tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar); color: var(--bar-ink);
  padding: calc(var(--safe-top) + 6px) 8px 8px;
}
.topbar-row { display: flex; align-items: center; gap: 4px; max-width: 680px; margin: 0 auto; min-height: 44px; }
.topbar h1 {
  flex: 1; margin: 0; min-width: 0;
  font: 700 21px/1.15 var(--display); letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .sub { display: block; font: 400 13px/1.2 var(--body); color: var(--bar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; padding: 0 8px;
  border: 0; background: transparent; color: inherit; border-radius: var(--radius-m);
}
.icon-btn:active { background: rgba(127,127,127,.18); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn .lbl { font-size: 16px; margin-left: 2px; }

/* ---------- Cartouche (bloc titre du relevé) ---------- */
.cartouche {
  background: var(--bar); color: var(--bar-ink);
  border-top: 1px solid rgba(255,255,255,.08);
}
.cartouche-grid {
  max-width: 680px; margin: 0 auto;
  display: grid; grid-template-columns: 1.3fr 1fr;
  border-left: 1px solid rgba(255,255,255,.14);
}
.cartouche-cell { padding: 8px 12px 10px; border-right: 1px solid rgba(255,255,255,.14); border-bottom: 1px solid rgba(255,255,255,.14); min-width: 0; }
.cartouche-cell.wide { grid-column: 1 / -1; }
.cartouche-cell small { display: block; font-size: 12px; color: var(--bar-muted); }
.cartouche-cell b { display: block; font: 600 18px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cartouche-cell.wide b { white-space: normal; }

/* ---------- Typographie ---------- */
h2.section {
  margin: 26px 2px 8px; font: 700 15px/1.2 var(--display);
  color: var(--muted); letter-spacing: .02em;
}
h2.section:first-child { margin-top: 6px; }
.lead { color: var(--muted); font-size: 15px; margin: 4px 2px 12px; }
.code { font: 700 17px/1.1 var(--display); letter-spacing: .01em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.warn-text { color: var(--nv); }

/* ---------- Listes groupées ---------- */
.group { background: var(--surface); border-radius: var(--radius-l); overflow: hidden; }
.group + .group { margin-top: 12px; }
.row {
  position: relative; display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 56px; padding: 10px 14px;
  background: transparent; border: 0; text-align: left;
}
.row + .row::before { content: ""; position: absolute; left: 14px; right: 0; top: 0; border-top: 1px solid var(--rule); }
button.row:active, a.row:active { background: var(--surface-2); }
a.row { color: inherit; text-decoration: none; }
.row .num { flex: 0 0 34px; font: 700 20px/1 var(--display); color: var(--faint); text-align: center; }
.row .main { flex: 1; min-width: 0; }
.row .title { display: block; font-weight: 600; }
.row .detail { display: block; color: var(--muted); font-size: 14px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .meta { flex: 0 0 auto; color: var(--muted); font-size: 14px; text-align: right; }
.row .chev { flex: 0 0 auto; color: var(--faint); width: 18px; height: 18px; }
.row.bar-nc { box-shadow: inset 4px 0 0 var(--nc); }
.row.bar-nv { box-shadow: inset 4px 0 0 var(--nv); }
.row.bar-c { box-shadow: inset 4px 0 0 var(--c); }
.row.bar-hm, .row.bar-so { box-shadow: inset 4px 0 0 var(--hm); }
.row-thumb { flex: 0 0 52px; width: 52px; height: 52px; border-radius: var(--radius-s); object-fit: cover; background: var(--surface-2); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--hm-bg); color: var(--muted); white-space: nowrap;
}
.badge.nc { background: var(--nc-bg); color: var(--nc); }
.badge.nv { background: var(--nv-bg); color: var(--nv); }
.badge.c { background: var(--c-bg); color: var(--c); }
.badge.signal { background: var(--signal); color: var(--on-signal); }
.badge svg { width: 14px; height: 14px; }

/* ---------- Formulaires ---------- */
.form { background: var(--surface); border-radius: var(--radius-l); padding: 4px 14px; }
.form + .form { margin-top: 12px; }
.field { padding: 12px 0; }
.field + .field { border-top: 1px solid var(--rule); }
.field > label, .field > .label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--faint); margin-top: 6px; }
.input, .textarea {
  display: block; width: 100%;
  padding: 11px 12px; border: 1px solid var(--rule); border-radius: var(--radius-m);
  background: var(--surface-2); font-size: 17px; line-height: 1.35;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--focus); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.textarea { min-height: 96px; resize: none; overflow: hidden; }
.textarea.tall { min-height: 150px; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row .input { flex: 1; min-width: 0; }

.picker {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: var(--radius-m);
  background: var(--surface-2); text-align: left;
}
.picker .val { flex: 1; min-width: 0; }
.picker .val.placeholder { color: var(--faint); }
.picker svg { flex: 0 0 auto; width: 18px; height: 18px; color: var(--faint); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 0; min-width: 52px; min-height: 44px; padding: 8px 6px;
  border: 1px solid var(--rule); border-radius: var(--radius-m);
  background: var(--surface-2); font-weight: 600; font-size: 15px;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.seg button.nc[aria-pressed="true"] { background: var(--nc); border-color: var(--nc); color: #fff; }
.seg button.nv[aria-pressed="true"] { background: var(--nv); border-color: var(--nv); color: #fff; }
.seg button.c[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.seg button.hm[aria-pressed="true"], .seg button.so[aria-pressed="true"] { background: var(--hm); border-color: var(--hm); color: #fff; }

.check-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; width: 100%; background: none; border: 0; text-align: left; }
.check-row + .check-row { border-top: 1px solid var(--rule); }
.box {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 7px;
  border: 2px solid var(--faint); display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
}
.box svg { width: 18px; height: 18px; color: var(--surface); opacity: 0; }
[aria-checked="true"] > .box { background: var(--ink); border-color: var(--ink); }
[aria-checked="true"] > .box svg { opacity: 1; }
.radio .box { border-radius: 50%; }
.check-row .txt { flex: 1; padding-top: 1px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.switch {
  position: relative; flex: 0 0 52px; width: 52px; height: 32px; border-radius: 16px;
  border: 0; background: var(--rule); transition: background .15s;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--c); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--rule); border-radius: var(--radius-m); overflow: hidden; background: var(--surface-2); }
.stepper button { width: 46px; height: 44px; border: 0; background: transparent; font-size: 22px; }
.stepper input { width: 64px; height: 44px; border: 0; text-align: center; background: transparent; font-size: 17px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: var(--radius-m);
  border: 1px solid var(--rule); background: var(--surface); font-weight: 600; font-size: 16px;
  text-decoration: none; color: inherit;
}
.btn svg { width: 20px; height: 20px; }
.btn.block { display: flex; width: 100%; }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.signal { background: var(--signal); color: var(--on-signal); border-color: var(--signal); }
.btn.danger { color: var(--nc); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn { flex: 1 1 auto; }

/* ---------- Dock de capture ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--rule);
}
.dock-inner { display: flex; gap: 10px; max-width: 680px; margin: 0 auto; }
.dock .btn { flex: 1; min-height: 56px; font-size: 17px; border-radius: 14px; }
.dock .btn.signal { flex: 1.25; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.dock .btn svg { width: 24px; height: 24px; }
body.kb-open .dock { display: none; }

/* ---------- Photos ---------- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-m); overflow: hidden;
  background: var(--surface-2); border: 0; padding: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .tag {
  position: absolute; left: 6px; bottom: 6px; padding: 1px 6px; border-radius: 6px;
  background: rgba(0,0,0,.65); color: #fff; font: 600 13px/1.4 var(--display);
}
.thumb .flag { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--signal); color: var(--on-signal); display: flex; align-items: center; justify-content: center; }
.thumb .flag svg { width: 14px; height: 14px; }
.thumb.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--rule); color: var(--muted); font-size: 13px; font-weight: 600; }
.thumb.add svg { width: 26px; height: 26px; }
.thumb.dim img { opacity: .4; }
.thumb.selected { outline: 3px solid var(--focus); outline-offset: -3px; }

/* ---------- Feuilles (bottom sheets) et boîtes ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(10,12,14,.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .16s ease-out;
}
.sheet {
  width: 100%; max-width: 680px; max-height: calc(100dvh - var(--safe-top) - 24px);
  display: flex; flex-direction: column;
  background: var(--paper); border-radius: 18px 18px 0 0;
  padding-bottom: var(--safe-bottom);
  animation: rise .2s ease-out;
}
.sheet.full { height: calc(100dvh - var(--safe-top) - 12px); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 16px; }
.sheet-head h3 { flex: 1; margin: 0; font: 700 19px/1.2 var(--display); }
.sheet-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 16px; }
.sheet-search { padding: 0 16px 10px; }
.dialog { max-width: 420px; margin: auto; border-radius: 18px; padding: 18px; background: var(--surface); animation: rise .18s ease-out; }
.dialog h3 { margin: 0 0 8px; font: 700 20px/1.2 var(--display); }
.dialog p { margin: 0 0 14px; color: var(--muted); }
.backdrop.center { align-items: center; padding: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .4; } }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--dock-h) + 22px + var(--safe-bottom)); z-index: 90;
  width: fit-content; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--surface); font-size: 15px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  animation: fade .15s ease-out;
}
.toast button { border: 0; background: transparent; color: var(--signal); font-weight: 700; padding: 4px; }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-m); margin-bottom: 12px;
  background: var(--nv-bg); color: var(--ink); font-size: 15px;
}
.banner svg { flex: 0 0 22px; width: 22px; height: 22px; color: var(--nv); }
.banner.info { background: var(--hm-bg); }
.banner.info svg { color: var(--muted); }
.banner.ok { background: var(--c-bg); }
.banner.ok svg { color: var(--c); }
.banner.bad { background: var(--nc-bg); }
.banner.bad svg { color: var(--nc); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h3 { margin: 0 0 6px; color: var(--ink); font: 700 20px/1.2 var(--display); }
.empty p { margin: 0 auto 16px; max-width: 34ch; }

/* ---------- Sélecteur d'EESS ---------- */
.eess-group { margin: 14px 2px 6px; font: 700 14px/1.2 var(--display); color: var(--muted); }
.eess-head { padding: 10px 14px 4px; font: 600 14px/1.25 var(--display); color: var(--faint); }
.eess-row .code { flex: 0 0 auto; min-width: 64px; }
.eess-text { white-space: pre-wrap; font-size: 15px; line-height: 1.45; background: var(--surface); border-radius: var(--radius-m); padding: 12px; margin-top: 8px; }

/* ---------- Grille EESS ---------- */
.grid-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.grid-row + .grid-row { border-top: 1px solid var(--rule); }
.grid-row .code { flex: 0 0 64px; font-size: 16px; }
.grid-row .t { flex: 1; min-width: 0; font-size: 15px; }
.grid-row .avis-pill { flex: 0 0 auto; min-width: 46px; height: 34px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface-2); font-weight: 700; font-size: 14px; }
.avis-pill.nc { background: var(--nc); color: #fff; border-color: var(--nc); }
.avis-pill.nv { background: var(--nv); color: #fff; border-color: var(--nv); }
.avis-pill.c { background: var(--c); color: #fff; border-color: var(--c); }
.avis-pill.hm, .avis-pill.so { background: var(--hm); color: #fff; border-color: var(--hm); }

/* ---------- Essais E/F/ER ---------- */
.essai { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; padding: 6px 0; }
.essai .k { font: 700 18px/1 var(--display); }
.essai .seg button { min-height: 42px; font-size: 14px; }
.essai .seg button.ok[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.essai .seg button.nok[aria-pressed="true"] { background: var(--nc); border-color: var(--nc); color: #fff; }
.essai .seg button.nr[aria-pressed="true"] { background: var(--hm); border-color: var(--hm); color: #fff; }
.preview { white-space: pre-wrap; font-size: 15px; background: var(--surface-2); border: 1px dashed var(--rule); border-radius: var(--radius-m); padding: 10px 12px; }
.preview b { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.preview + .preview { margin-top: 8px; }

/* ---------- Visionneuse et annotation ---------- */
.viewer { position: fixed; inset: 0; z-index: 70; background: #000; color: #fff; display: flex; flex-direction: column; }
.viewer-top, .viewer-bottom { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: rgba(0,0,0,.6); }
.viewer-top { padding-top: calc(var(--safe-top) + 6px); }
.viewer-bottom { padding-bottom: calc(var(--safe-bottom) + 8px); flex-wrap: wrap; justify-content: center; }
.viewer-top .t { flex: 1; font: 700 18px/1.2 var(--display); }
.viewer-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: pan-x pan-y pinch-zoom; }
.viewer-stage img, .viewer-stage canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .vbtn { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; min-height: 52px; padding: 6px 8px; border: 0; border-radius: 10px; background: transparent; color: #fff; font-size: 12px; }
.viewer .vbtn svg { width: 24px; height: 24px; }
.viewer .vbtn[aria-pressed="true"] { background: rgba(255,198,0,.25); color: var(--signal); }
.viewer .vbtn:active { background: rgba(255,255,255,.15); }
.annot-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.annot-stage canvas { touch-action: none; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); }
.swatch[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.35); }

/* ---------- Divers ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.progress { height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; margin: 10px 0; }
.progress > i { display: block; height: 100%; width: 0; background: var(--signal); transition: width .2s; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface); font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.split { display: flex; gap: 12px; }
.split > * { flex: 1; min-width: 0; }
.form > .split + .field, .form > .field + .split, .form > .split + .split { border-top: 1px solid var(--rule); }
.split > .field + .field { border-top: 0; }
.mark { background: color-mix(in srgb, var(--signal) 45%, transparent); border-radius: 3px; padding: 0 2px; }
.lib-item { background: var(--surface); border-radius: var(--radius-m); padding: 12px; margin-bottom: 8px; border: 0; width: 100%; text-align: left; }
.lib-item .t { font-weight: 600; display: block; margin-bottom: 4px; }
.lib-item .x { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.foot-note { font-size: 13px; color: var(--faint); text-align: center; margin: 22px 8px 0; }
.update-bar { position: fixed; top: calc(var(--safe-top) + 58px); left: 12px; right: 12px; z-index: 40; max-width: 656px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--signal); color: var(--on-signal); font-weight: 600; box-shadow: 0 4px 18px rgba(0,0,0,.2); }
.update-bar .btn { min-height: 38px; padding: 6px 12px; background: var(--ink); color: #fff; border-color: var(--ink); }

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

/* ======================================================================
   v2 — assistants de la trame : listes cochables, onglets de rubriques,
   rédaction assistée, aperçus « tel que dans le rapport ».
   ====================================================================== */
.wrap { white-space: normal; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.clamp { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.row .detail.clamp { -webkit-line-clamp: 3; }
h2.section.with-right { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
h2.section.with-right > span:first-child { flex: 1; }
.sub-title { margin: 16px 2px 6px; font: 700 14px/1.2 var(--display); color: var(--muted); letter-spacing: .02em; }
.link-btn { border: 0; background: none; color: var(--focus); font: 600 14px/1.2 var(--body); padding: 4px 2px; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.row.muted { color: var(--muted); font-size: 15px; }
.row.current { background: var(--surface-2); }
.row.current .title { color: var(--ink); }
.btn-row.tight { margin-top: 8px; gap: 8px; }
.btn-row.tight .btn { min-height: 42px; padding: 8px 12px; font-size: 15px; flex: 1 1 auto; }

/* Listes cochables */
.check-list .row { min-height: 48px; }
.check-list.compact .row { min-height: 44px; padding-top: 8px; padding-bottom: 8px; }
.row.check { align-items: flex-start; }
.row.check .box { margin-top: 1px; }
.row.check .title { font-weight: 500; }
.row.check[aria-checked="true"] .title { font-weight: 600; }
.row.check .meta { align-self: center; }
.check-split { padding: 0 6px 0 0; }
.check-split .check-hit { flex: 1; display: flex; align-items: flex-start; gap: 12px; min-width: 0; padding: 10px 0 10px 14px; border: 0; background: none; text-align: left; }
.check-split .check-hit .box { margin-top: 1px; }
.check-split .icon-btn { align-self: center; color: var(--muted); }
.scroll-box { max-height: 46vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.phrase-list .row .title { font-size: 15px; }
.phrase-list .row .detail { font-size: 14px; }

/* Choix de la machine active */
.radio-row { align-items: center; }
.radio-dot { flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--faint); background: var(--surface); position: relative; }
.radio-row.on .radio-dot { border-color: var(--ink); }
.radio-row.on .radio-dot::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--ink); }
.radio-row.on .title { font-weight: 700; }
.row.active-scope { box-shadow: inset 4px 0 0 var(--signal); }
.scope-bar { margin: 0 0 10px; }
.scope-bar .picker { background: var(--surface); }
.scope-bar .val small { display: block; font-size: 12px; color: var(--muted); }
.scope-bar .val { font-weight: 700; }

/* Onglets des rubriques (6.1 … 8.3) */
.tabs { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -16px 12px; padding: 2px 16px 4px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; min-width: 52px; min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--rule); background: var(--surface); font: 700 16px/1 var(--display); color: var(--muted); position: relative; }
.tab.filled { color: var(--ink); }
.tab.filled::after { content: ""; position: absolute; right: 5px; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.tab.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* Pastilles */
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); font-weight: 600; }
.chip.toggle[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip[disabled] { opacity: .4; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll .chip { flex: 0 0 auto; white-space: nowrap; }

/* Liste des champs d'une rubrique */
.row.filled .detail { color: var(--ink); }
.row.empty .detail { color: var(--faint); font-style: italic; }
.row.off .detail { color: var(--nv); }
.row.hidden-field .title { text-decoration: line-through; text-decoration-color: var(--faint); }
.field-help { margin: 2px 2px 10px; font-size: 14px; color: var(--muted); }
.sheet-subtitle { margin: 2px 0 8px; font: 700 18px/1.25 var(--display); }

/* Rédaction assistée */
.assisted-card { background: var(--surface); border-radius: var(--radius-l); padding: 12px 14px; margin-top: 12px; }
.assisted-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.assisted-text { max-height: 260px; overflow: auto; background: var(--surface-2); border-radius: var(--radius-m); padding: 10px 12px; }

/* Zones de saisie : liste et calendrier */
.list-btn { flex: 0 0 46px; border: 1px solid var(--rule); background: var(--surface-2); border-radius: var(--radius-m); color: var(--muted); }
.date-btn { position: relative; flex: 0 0 46px; border: 1px solid var(--rule); background: var(--surface-2); border-radius: var(--radius-m); color: var(--muted); overflow: hidden; }
.date-btn .date-native { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.input-row > .icon-btn { border: 1px solid var(--rule); background: var(--surface-2); }

/* Aperçus « tel que dans le rapport » */
.doc-preview, .obs-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius-m); overflow: hidden; }
.doc-preview .cell, .obs-preview .cell { background: var(--surface); padding: 8px 10px; min-width: 0; }
.obs-preview .cell.wide { grid-column: 1 / -1; }
.doc-preview .label, .obs-preview .label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.doc-preview.absent .pre.red, .doc-preview .red { color: var(--nc); font-weight: 700; }
.obs-machines { display: block; color: #00529b; font-style: italic; font-size: 13px; }
:root[data-theme="dark"] .obs-machines { color: #6aa7ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .obs-machines { color: #6aa7ff; } }
.preview.small { font-size: 14px; }
.preview ul { margin: 6px 0 0; padding-left: 18px; }
.preview li + li { margin-top: 4px; }

/* Criticité */
.seg button.crit1[aria-pressed="true"] { background: #008000; border-color: #008000; color: #fff; }
.seg button.crit2[aria-pressed="true"] { background: #c05000; border-color: #c05000; color: #fff; }
.seg button.crit3[aria-pressed="true"] { background: #c00000; border-color: #c00000; color: #fff; }
.row.bar-vide { box-shadow: inset 4px 0 0 var(--rule); }

/* Exigences */
.eess-row { padding: 2px 6px 2px 0; }
.eess-pick { flex: 1; display: flex; gap: 10px; align-items: baseline; padding: 10px 0 10px 14px; border: 0; background: none; text-align: left; min-width: 0; }
.eess-row.current .eess-pick { font-weight: 700; }

/* Bases du téléphone */
.base-card b { display: block; margin-bottom: 8px; }
.progress > .bar { display: block; height: 100%; width: 0; background: var(--signal); transition: width .2s; }

/* Barre d'actions dans une feuille */
.action-bar.inline { position: sticky; bottom: 0; margin: 12px -16px -16px; padding: 10px 16px calc(10px + var(--safe-bottom)); background: color-mix(in srgb, var(--paper) 92%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--rule); }
.action-bar .action-inner { display: flex; gap: 8px; flex-wrap: wrap; }
.action-bar .btn { flex: 1 1 auto; min-height: 44px; }
.hint { font-size: 13px; color: var(--faint); }
p.hint, div.hint { margin: 6px 2px; }
details.fold { background: var(--surface); border-radius: var(--radius-l); margin-top: 12px; }
details.fold > summary { list-style: none; cursor: pointer; padding: 14px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "▾"; color: var(--faint); }
details.fold[open] > summary::after { content: "▴"; }
details.fold > .fold-body { padding: 0 0 8px; }
details.fold .group { border-radius: 0; }

/* Fonctions de sécurité / ILO */
.big-value { font-size: 22px; font-weight: 700; padding: 4px 0; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.sf-preview div + div { margin-top: 3px; }

/* ---------- Outils de calcul (formulaires transpilés) ----------
   Les cadres des formulaires deviennent des cartes ; la barre de tête porte les onglets et
   l'explication du champ en cours, pour qu'elle reste lisible clavier ouvert. */
.calc-screen .content { padding-top: 12px; }
.calc-tabs { display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; max-width: 680px; margin: 2px auto 0; padding: 0 2px; }
.calc-tabs::-webkit-scrollbar { display: none; }
.calc-tab { flex: 0 0 auto; min-height: 40px; padding: 8px 10px 6px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--bar-muted); font: 700 15px/1.1 var(--display); white-space: nowrap; }
.calc-tab.on { color: var(--bar-ink); border-bottom-color: var(--signal); }
.calc-help { max-width: 680px; margin: 4px auto 0; padding: 6px 8px 2px; font-size: 13px; line-height: 1.35; color: var(--bar-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; border-top: 1px solid color-mix(in srgb, var(--bar-muted) 30%, transparent); }
.calc-help.open { -webkit-line-clamp: unset; display: block; max-height: 40vh; overflow: auto; }
.calc-help[hidden] { display: none; }
.calc-page { display: flex; flex-direction: column; gap: 12px; }
.calc-frame { background: var(--surface); border-radius: var(--radius-l); padding: 12px 14px 10px; }
.calc-frame-title { margin: 0 0 6px; font: 700 15px/1.25 var(--display); color: var(--muted); letter-spacing: .01em; }
.calc-frame-body > * + * { margin-top: 6px; }
.calc-frame .calc-frame { padding: 8px 0 0; border-top: 1px solid var(--rule); border-radius: 0; }
.calc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 5px 0; }
.calc-row.stack { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.calc-row.stack .calc-ctl { justify-content: stretch; }
.calc-row:not(.stack) .calc-in { flex: 0 0 auto; width: 118px; }
.calc-row:not(.stack) .calc-ctl { max-width: 62vw; }
.calc-row + .calc-row { border-top: 1px solid var(--rule); }
.calc-row.free { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.calc-row[hidden], .calc-frame[hidden] { display: none; }
.calc-lbl { font-size: 15px; line-height: 1.3; color: var(--ink); }
.calc-lbl.b { font-weight: 700; }
.calc-ctl { display: flex; align-items: center; gap: 6px; min-width: 0; justify-content: flex-end; }
.calc-ctl > .calc-in, .calc-ctl > .calc-sel { flex: 1 1 auto; }
.calc-in, .calc-sel, .calc-area { min-width: 0; width: 100%; min-height: 40px; padding: 7px 10px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface-2); color: var(--ink); font-size: 16px; line-height: 1.3; -webkit-appearance: none; appearance: none; }
.calc-in { font-variant-numeric: tabular-nums; }
.calc-sel { padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; text-overflow: ellipsis; }
.calc-in:focus, .calc-sel:focus, .calc-area:focus { outline: none; border-color: var(--focus); background-color: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.calc-in[readonly] { background: transparent; border-style: dashed; }
.calc-area { min-height: 84px; resize: vertical; }
.calc-val { display: inline-block; min-width: 64px; padding: 7px 10px; border-radius: var(--radius-s); background: var(--surface-2); font-weight: 700; font-size: 16px; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-unit { flex: 0 0 auto; font-size: 14px; color: var(--muted); min-width: 22px; }
.calc-vd { padding: 7px 10px; border-radius: var(--radius-s); font-size: 14px; font-weight: 600; line-height: 1.35; background: var(--hm-bg); color: var(--hm); }
.calc-vd[data-v="ok"] { background: var(--c-bg); color: var(--c); }
.calc-vd[data-v="ko"] { background: var(--nc-bg); color: var(--nc); }
.calc-vd[data-v="att"] { background: var(--nv-bg); color: var(--nv); }
.calc-vd[hidden] { display: none; }
.calc-note { margin: 2px 0; font-size: 14px; line-height: 1.45; color: var(--muted); white-space: pre-wrap; }
.calc-note.b, .calc-text.b { font-weight: 700; color: var(--ink); }
.calc-note[data-c="ko"], .calc-text[data-c="ko"] { color: var(--nc); }
.calc-note[data-c="ok"], .calc-text[data-c="ok"] { color: var(--c); }
.calc-note[data-c="att"], .calc-text[data-c="att"] { color: var(--nv); }
.calc-note[data-c="title"], .calc-text[data-c="title"] { color: var(--focus); }
.calc-note.boxed, .calc-text.boxed { padding: 6px 8px; border-radius: var(--radius-s); color: #15191d; }
.calc-text { font-size: 15px; white-space: pre-wrap; }
.calc-pave { margin: 4px 0; padding: 10px; max-height: 60vh; overflow: auto; background: var(--surface-2); border-radius: var(--radius-s); font: 12.5px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.note-view { max-height: none; }
.calc-checks { display: grid; gap: 2px 10px; }
.calc-checks.two { grid-template-columns: 1fr 1fr; }
.calc-chk { display: flex; align-items: flex-start; gap: 10px; min-height: 40px; padding: 8px 0; font-size: 15px; line-height: 1.3; }
.calc-chk input { flex: 0 0 auto; width: 22px; height: 22px; margin: 0; accent-color: var(--ink); }
.calc-chk.off { opacity: .5; }
.calc-btns { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0 2px; }
.calc-btn { min-height: 40px; }
.calc-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 0 4px; }
.calc-actions .calc-btn { flex: 1 1 40%; }
.calc-foot { margin-top: 4px; }
.calc-list { margin: 6px 0; border: 1px solid var(--rule); border-radius: var(--radius-s); overflow: hidden; }
.calc-list-tools { padding: 6px; background: var(--surface-2); border-bottom: 1px solid var(--rule); }
.calc-seg button { min-height: 34px; font-size: 13px; }
.calc-seg button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.calc-list-rows { max-height: 52vh; overflow: auto; -webkit-overflow-scrolling: touch; }
.calc-li { display: flex; gap: 10px; align-items: baseline; padding: 9px 10px; font-size: 14px; line-height: 1.3; border-top: 1px solid var(--rule); }
.calc-li:first-child { border-top: 0; }
.calc-li.on { background: color-mix(in srgb, var(--focus) 14%, var(--surface)); }
.calc-li-ck { flex: 0 0 18px; font-weight: 700; color: var(--focus); }
.calc-li-c { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.calc-li-c:first-of-type { flex: 0 1 auto; font-weight: 600; }
.calc-li.empty { color: var(--faint); }
.calc-li.card { align-items: flex-start; }
.calc-li-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
.calc-li-t { font-weight: 600; overflow-wrap: anywhere; }
.calc-li-m { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.calc-li-d { font-size: 13px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.calc-li-v { padding: 1px 6px; border-radius: 5px; background: var(--surface-2); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.calc-li-v[data-v="ok"] { background: var(--c-bg); color: var(--c); font-weight: 600; }
.calc-li-v[data-v="ko"] { background: var(--nc-bg); color: var(--nc); font-weight: 600; }
.calc-li-v[data-v="att"] { background: var(--nv-bg); color: var(--nv); font-weight: 600; }
.calc-li-v[data-v="ne"] { font-weight: 600; }
.calc-img { margin: 6px 0; }
.calc-img img { max-width: 100%; height: auto; border-radius: var(--radius-s); background: #fff; }
.calc-overlay { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--paper); }
.calc-ov-head { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-top) + 6px) 8px 8px 16px; background: var(--bar); color: var(--bar-ink); }
.calc-ov-head h2 { flex: 1; margin: 0; font: 700 18px/1.2 var(--display); }
.calc-ov-head .icon-btn { color: var(--bar-ink); }
.calc-ov-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px calc(24px + var(--safe-bottom)); }
.calc-ov-body .calc { max-width: 680px; margin: 0 auto; }
.calc-ov-body .calc-pave { max-height: none; font: 15px/1.5 var(--body); background: var(--surface); }
.calc-loose > * + * { margin-top: 6px; }
@media (max-width: 380px) { .calc-row { grid-template-columns: 1fr; } .calc-ctl { justify-content: stretch; } .calc-checks.two { grid-template-columns: 1fr; } }
