/* Charte Grist Factory : gris neutres, un seul bleu d'accent, rouge pour les erreurs et les
   actions destructrices, ambre pour l'attente. Police du système. Contrastes de 4,5:1 au moins
   en clair comme en sombre. Thème : système, ou choix des Réglages (attribut data-theme). */
:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-sunken: #eef1f6;
  --border: #dde2ea; --border-strong: #c3cad6;
  --text: #1b2430; --text-muted: #5f6b7e;
  --accent: #2f6fed; --accent-solid: #2f6fed; --accent-solid-hover: #2558c4;
  --accent-soft: #e8f0fe; --accent-ink: #2558c4;
  --good: #146c48; --good-soft: #e5f6ee;
  --warn: #8a5300; --warn-soft: #fdf3e1;
  --danger: #d84343; --danger-ink: #c53030; --danger-soft: #fbe9e9;
  --danger-solid: #c53030; /* fond des boutons rouges : texte blanc lisible dans les deux thèmes */
  --scrim: rgba(15, 23, 42, .45);
  --radius: 7px; --radius-frame: 8px;
  --shadow-float: 0 8px 28px rgba(15, 23, 42, .18);
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171b23; --surface: #1e2430; --surface-sunken: #262e3c;
    --border: #323b4b; --border-strong: #465166;
    --text: #e7ecf5; --text-muted: #9aa6bb;
    --accent: #5b91f5;
    --accent-soft: #24324b; --accent-ink: #74a3f7;
    --good: #6fd3a3; --good-soft: #163326;
    --warn: #f2c36b; --warn-soft: #3a2f1a;
    --danger: #f08a8a; --danger-ink: #f08a8a; --danger-soft: #3a2426;
    --scrim: rgba(3, 6, 12, .62);
    --shadow-float: 0 8px 28px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171b23; --surface: #1e2430; --surface-sunken: #262e3c;
  --border: #323b4b; --border-strong: #465166;
  --text: #e7ecf5; --text-muted: #9aa6bb;
  --accent: #5b91f5;
  --accent-soft: #24324b; --accent-ink: #74a3f7;
  --good: #6fd3a3; --good-soft: #163326;
  --warn: #f2c36b; --warn-soft: #3a2f1a;
  --danger: #f08a8a; --danger-ink: #f08a8a; --danger-soft: #3a2426;
  --scrim: rgba(3, 6, 12, .62);
  --shadow-float: 0 8px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font-ui); }
input, select, textarea, button { font-family: var(--font-ui); font-size: 14px; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.text-danger { color: var(--danger-ink); }
h1, h2, h3 { margin: 0; font-weight: 600; }

/* Barre du haut */
.topbar { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 8px 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { font-size: inherit; font-weight: 700; }
#brand-logo { width: 20px; height: 20px; border-radius: 50%; opacity: .85; flex: none; }
.tabs { display: flex; gap: 2px; flex: 1; }
.tabs button { border: 0; background: none; padding: 9px 10px; border-bottom: 2px solid transparent; cursor: pointer; color: var(--text-muted); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button[aria-selected="true"]:hover { color: var(--accent-ink); }
/* Panneau étroit (380 px) : la barre du haut tenait sur 381 px en français ; elle se resserre au lieu de déborder. */
@media (max-width: 420px) {
  .topbar { gap: 6px; padding: 0 6px 0 8px; }
  .tabs button { padding: 9px 6px; }
}
.icon-button { border: 0; background: none; width: 30px; height: 30px; border-radius: var(--radius); cursor: pointer; display: grid; place-items: center; color: var(--text-muted); }
.icon-button:hover { background: var(--surface-sunken); color: var(--text); }

main { padding: 12px; max-width: 760px; margin: 0 auto; }
/* Avis d'une invitation arrivée d'un autre onglet (tab-link-ui.js) : au-dessus de l'écran, à sa largeur. */
#offer { max-width: 760px; margin: 0 auto; padding: 12px 12px 0; }
#offer:empty { display: none; }
.tab-link { display: grid; gap: 4px; }
.tab-link > p { margin: 0; }

/* Accueil */
.home-title { font-size: 16px; margin: 8px 0 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.tile { text-align: left; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-frame); background: var(--surface); cursor: pointer; display: grid; gap: 4px; }
.tile:hover { border-color: var(--accent); }
.tile-title { font-weight: 600; color: var(--accent); }
.tile-desc { color: var(--text-muted); }

/* Boutons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent-solid); border-color: var(--accent-solid); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-solid-hover); color: #fff; }
.btn-danger { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn-danger:hover:not(:disabled) { color: #fff; filter: brightness(.92); }
.btn-danger-text { color: var(--danger-ink); }
.btn-danger-text:hover:not(:disabled) { border-color: var(--danger); color: var(--danger-ink); }
.btn-small { padding: 3px 8px; font-size: 12.5px; min-height: 24px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

/* Cartes */
.cards { display: grid; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-frame); padding: 10px 12px; }
.card p { margin: 4px 0 0; overflow-wrap: anywhere; }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill { border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--good-soft); color: var(--good); }
.pill-pending { background: var(--warn-soft); color: var(--warn); }
.pill-err { background: var(--danger-soft); color: var(--danger-ink); }
.pill-off { background: var(--surface-sunken); color: var(--text-muted); }
/* Destinataires d'un export, table proposée à la CIBLE */
.people { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.person { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; background: var(--surface-sunken); }
.stray-list { list-style: none; margin: 0; padding: 6px 8px; display: grid; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-sunken); font-size: 13px; }
.formula-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.formula-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; background: var(--surface-sunken); }
.formula-code { resize: none; margin: 4px 0; padding: 6px 8px; white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.formulas-box { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.formulas-panel { margin-top: 8px; }
.person-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.person-who { font-weight: 600; overflow-wrap: anywhere; }
.person-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.offer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; margin-top: 6px;
  padding: 6px 8px; border-radius: var(--radius); background: var(--accent-soft); }

/* Messages */
.msg { margin: 6px 0; padding: 7px 10px; border-radius: var(--radius); border-left: 3px solid; }
.notice-title { display: block; }
.notice > p { margin: 3px 0 0; }
.notice > .card-actions { margin-top: 8px; }
.fold { margin-top: 6px; }
.fold > summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; }
.msg-info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.msg-ok { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.msg-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.msg-err { background: var(--danger-soft); border-color: var(--danger); color: var(--danger-ink); }
/* Avancement d'un envoi sur la carte d'un export (js/source/flow.js). */
.flow progress { display: block; width: 100%; height: 8px; margin: -4px 0 8px; accent-color: var(--accent); }
.suspect p { margin: 4px 0 0; }
.suspect .card-actions { margin-top: 8px; }

/* Formulaires */
.form { display: grid; gap: 6px; }
.form p { margin: 0; }
.form label, .form h3, .field-title { font-weight: 600; font-size: 13px; margin-top: 4px; }
.input, .code, .search-input { width: 100%; padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; resize: vertical; word-break: break-all; }
.copy-field { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: start; }
.radios { display: flex; gap: 14px; }
.radios label { font-weight: 400; display: flex; gap: 5px; align-items: center; }
.dest-row { display: grid; grid-template-columns: auto 1fr; gap: 6px; align-items: center; }
.rules-grid { display: grid; grid-template-columns: max-content minmax(0, 260px); gap: 6px 12px; align-items: center; }
.dest-grid { display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: 8px 12px; align-items: start; margin: 4px 0 8px; }
.dest-grid .dest-head { font-size: 12px; color: var(--text-muted); }
.dest-grid .dest-from { padding-top: 7px; font-weight: 600; }
.dest-grid .dest-pick { display: grid; gap: 4px; }
/* Une table de l'export : un résumé, deux boutons pour préciser colonnes et lignes */
.table-block { border: 1px solid var(--border); border-radius: var(--radius-frame); padding: 10px 12px; }
.table-block h3 { margin: 0; }
.table-block .block-actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* Étape « Contenu » : sections par question, Références rangées dans la fiche de leur table (export-links.js), panneau de la table ajoutée sous le choix cliqué */
.step-intro { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: baseline; margin: 0 0 10px; }
.step-intro p { margin: 0; flex: 1 1 240px; }
.linkish { color: var(--accent-ink); font-size: 13px; white-space: nowrap; text-decoration: underline; text-underline-offset: 2px; background: none; border: 0; padding: 0; cursor: pointer; }
details.guide.tuto-step.linked > summary { display: none; }
details.guide.tuto-step.linked:not([open]) { display: none; }
.sec { display: grid; gap: 8px; margin-top: 10px; }
.sec .sec-title { font-size: 14px; font-weight: 600; margin: 0; }
.sec .sec-sub { margin: 1px 0 0; color: var(--text-muted); font-size: 12.5px; }
.table-added { background: var(--surface-sunken); }
.added-head { display: flex; gap: 8px; align-items: center; }
.pull-modes { flex-direction: column; gap: 4px; align-items: flex-start; }
.ref-slot:empty { display: none; }
.ref-slot > .ref-item { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.ref-item .col { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ref-item .col strong { font-size: 14px; }
.choices { display: grid; gap: 8px; margin-top: 6px; }
.choice, .form label.choice { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-weight: 400; margin-top: 0; }
.choice input { margin: 3px 0 0; }
.choice .what { font-weight: 600; }
.choice .why { grid-column: 2; font-size: 12.5px; font-weight: 400; color: var(--text-muted); margin-top: 1px; }
.ref-panel > .table-added { margin: 8px 0 2px 24px; }
.opts { display: grid; gap: 4px; }
.opts .has-help { display: block; }
.opts .help-row { align-items: center; }
.opts .formulas-box { margin: 0; padding: 0; border: 0; }
.badge { margin-left: 6px; }
.table-block .summary { padding-top: 6px; border-top: 1px solid var(--border); font-weight: 600; }
.fiche { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 6px 0; }
.fiche dt { color: var(--text-muted); }
.fiche dd { margin: 0; overflow-wrap: anywhere; }
.fiche a { color: var(--accent-ink); }
/* Lien vers un document Grist : nouvel onglet, icône qui le dit (une icône, une fonction), et le même texte pour les lecteurs d'écran. */
.doc-link { color: var(--accent-ink); text-underline-offset: 2px; overflow-wrap: anywhere; }
.doc-link .icon { width: 12px; height: 12px; margin-left: 3px; vertical-align: -1px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Liste avec recherche */
.check-list { display: flex; flex-direction: column; gap: 2px; max-height: 140px; overflow: auto; margin-top: 4px; padding: 4px 6px;
  border: 1px solid var(--border); border-radius: var(--radius); }
/* Longue liste : haute de son contenu jusqu'à 45 % de la fenêtre (fitHeight), étirable au coin ;
   sur plusieurs colonnes quand la place le permet (colonnes d'une table) */
.check-long { max-height: 45vh; min-height: 96px; resize: vertical; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-content: start; column-gap: 14px; }
.check-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.check-tools .search-input { flex: 1 1 160px; min-width: 0; }
.check-count { white-space: nowrap; }
.check-list .check-label { min-width: 0; }
.pick-field { position: relative; min-width: 0; }
.pick-button { width: 100%; justify-content: space-between; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-button::after { content: ""; flex: none; width: 12px; height: 12px; margin-left: 6px; background: var(--text-muted);
  -webkit-mask: var(--chevron) center / contain no-repeat; mask: var(--chevron) center / contain no-repeat; }
.pick-panel { margin-top: 4px; }
.pick-option { text-align: left; padding: 3px 6px; border: 0; border-radius: var(--radius); background: none; color: var(--text); cursor: pointer; }
.pick-option:hover, .pick-option[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.check-list label, label.check { font-weight: 400; display: flex; gap: 6px; align-items: center; }
.check-list .hint { margin-left: auto; padding-left: 8px; color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.filter-field { display: grid; gap: 6px; margin-top: 8px; }
/* Filtre des lignes : une condition par bloc (colonne, opérateur, retirer), ses valeurs dessous */
.filter-conds { display: grid; gap: 8px; }
.filter-cond { display: grid; gap: 4px; padding-left: 10px; border-left: 2px solid var(--border); }
.filter-cond-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; align-items: start; }
.filter-values { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-values .input { flex: 1 1 140px; min-width: 0; }
.filter-mode { display: flex; gap: 4px 12px; flex-wrap: wrap; align-items: center; }
.filter-mode:empty { display: none; }
.filter-field > .btn { justify-self: start; }

/* Fenêtres : titre et boutons fixes, contenu qui défile ; tiennent dans un panneau de 700×400 */
.scrim { position: fixed; inset: 0; background: var(--scrim); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; z-index: 2000; padding: 12px; }
.modal { background: var(--surface); border-radius: var(--radius-frame); box-shadow: var(--shadow-float); width: 100%;
  max-height: calc(100vh - 24px); display: flex; flex-direction: column; }
.modal-400 { max-width: 400px; }
.modal-480 { max-width: 480px; }
/* Assistants : 720 px de large, agrandissables par le coin (jusqu'à la taille du panneau) */
.modal-720 { width: 720px; max-width: 100%; min-width: min(400px, 100%); min-height: 220px; resize: both; overflow: hidden; }
/* Un assistant s'ancre en haut : sa hauteur change d'une étape à l'autre, ses boutons Retour et Continuer ne doivent pas
   sauter sous la souris (centré, le haut de la fenêtre montait et descendait de plus de 100 px). */
.scrim:has(> .modal-720) { --top: clamp(12px, 4vh, 32px); align-items: start; padding-top: var(--top); }
.scrim:has(> .modal-720) > .modal-720 { max-height: calc(100vh - var(--top) - 12px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.modal-title { font-size: 15px; padding: 12px 14px 8px; flex: 1 1 auto; min-width: 0; }
/* Croix de fermeture : Échap fait la même chose (ui.js, openModal) */
.modal-x { flex: none; width: 28px; height: 28px; margin: 8px 10px 0 0; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-muted); font-size: 20px; line-height: 1; cursor: pointer; }
.modal-x:hover { background: var(--surface-sunken); color: var(--text); }
.modal-body { flex: 1 1 auto; min-height: 0; padding: 0 14px 8px; overflow: auto; overflow-wrap: anywhere; }
.steps { display: flex; gap: 4px; margin: 0 0 10px; padding: 0; list-style: none; font-size: 12px; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 4px; color: var(--text-muted); }
.steps li + li::before { content: ""; width: 10px; height: 1px; background: var(--border-strong); margin-right: 2px; }
.steps .step-num { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-strong); font-size: 11px; }
.steps .step-num .icon { width: 11px; height: 11px; }
.steps .current { color: var(--text); font-weight: 600; }
.steps .current .step-num { background: var(--accent-solid); border-color: var(--accent-solid); color: #fff; }
.steps .done .step-num { border-color: var(--good); color: var(--good); }
.modal-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.modal-footer .btn-back { margin-right: auto; }
/* Explication d'une option : « ? » à côté du libellé, texte dessous à la demande (ui.js : helpButton, withHelp) */
.help-row { display: flex; align-items: flex-start; gap: 8px; }
.help-row > :first-child { flex: 1 1 auto; min-width: 0; }
.help-btn { flex: none; width: 24px; height: 24px; padding: 0; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface);
  color: var(--accent-ink); font-size: 13px; font-weight: 700; line-height: 1; cursor: pointer; }
.help-btn:hover { border-color: var(--accent); }
.help-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.help-panel { margin: 2px 0 8px; padding: 6px 10px; border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--surface-sunken);
  font-size: 12.5px; }
.help-panel p { margin: 0; }
.help-panel p + p { margin-top: 4px; }
/* Aides d'une étape : discrètes, en bas, repliées */
.modal-body .guide { border: 0; background: none; padding: 0; margin-top: 10px; }
.modal-body .guide summary { font-weight: 400; font-size: 13px; }
.modal-body .guide + .guide { margin-top: 4px; }
.modal-body .guide[open] { border-left: 2px solid var(--border); padding-left: 10px; }

/* Icônes : tracés SVG en masque, couleur du texte du bouton */
.icon { width: 16px; height: 16px; display: inline-block; flex: none; background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.icon-settings { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z'/%3E%3C/svg%3E"); width: 18px; height: 18px; }
.icon-column { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Cpath d='M9 4v16M15 4v16'/%3E%3C/svg%3E"); }
.icon-plus { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.icon-paste { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3Crect x='8' y='2' width='8' height='4' rx='1'/%3E%3C/svg%3E"); }
.icon-copy { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E"); }
.icon-refresh { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-2.6-6.4L21 8M21 3v5h-5'/%3E%3C/svg%3E"); }
.icon-trash { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6'/%3E%3C/svg%3E"); }
.icon-send { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 2 11 13M22 2l-7 20-4-9-9-4z'/%3E%3C/svg%3E"); }
.icon-pause { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 5v14M15 5v14'/%3E%3C/svg%3E"); }
.icon-play { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M7 4l13 8-13 8z'/%3E%3C/svg%3E"); }
.icon-unblock { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 9.9-1'/%3E%3C/svg%3E"); }
.icon-check { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }
.icon-key { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7.5' cy='15.5' r='4.5'/%3E%3Cpath d='m10.7 12.3 9.8-9.8M17 6l3 3M14 9l2 2'/%3E%3C/svg%3E"); }
.icon-link { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7'/%3E%3C/svg%3E"); }
.icon-external { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpath d='M15 3h6v6M10 14 21 3'/%3E%3C/svg%3E"); }
.icon-unlink { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 0 1 3.5 8.5M8 12h3M3 3l18 18'/%3E%3C/svg%3E"); }
.icon-revoke { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 11h-6'/%3E%3C/svg%3E"); }
.icon-stop { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m5.6 5.6 12.8 12.8'/%3E%3C/svg%3E"); }
:root { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }

/* Aide en images dans l'assistant */
.help-figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.help-figure img { max-width: 100%; max-height: 120px; object-fit: contain; align-self: flex-start; border: 1px solid var(--border); border-radius: var(--radius); }
/* Réglage d'accès montré quand le widget n'a pas l'accès complet : la page entière, assez grande pour voir où est le panneau. */
.access-help { margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.access-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.access-shots .help-figure { min-width: 0; }
.access-shots .tuto-shot { width: 100%; }
.access-shots .tuto-shot img { width: 100%; height: auto; max-height: none; }

/* Qui fait quoi : étapes des deux documents, étape en cours soulignée. */
.guide { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius-frame); background: var(--surface); padding: 8px 12px; }
.guide p { margin: 0; }
.guide summary { cursor: pointer; font-weight: 600; color: var(--accent); }
/* Cibles tactiles : 24 px de haut au moins (WCAG 2.5.8), volets repliés compris. */
summary { min-height: 24px; box-sizing: border-box; }
.guide summary { padding: 3px 0; }
.guide > * + * { margin-top: 8px; }
.guide-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.guide-steps li { padding: 2px 4px; border-radius: var(--radius); }
.guide-steps li.current { background: var(--accent-soft); }
.role-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; margin-right: 6px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-muted); white-space: nowrap; }
.role-badge.role-source { color: var(--accent-ink); border-color: var(--accent); }
.handoff { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.choice-help { margin: -4px 0 4px 24px; }

/* Tutoriel : sections numérotées, captures cliquables (agrandies dans une fenêtre). */
.tuto { display: grid; gap: 12px; max-width: 900px; }
.tuto > h2, .tuto > p { margin: 0; }
.tuto-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.tuto-filter button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.tuto-section { border: 1px solid var(--border); border-radius: var(--radius-frame); background: var(--surface); padding: 10px 14px; }
.tuto-section h2 { font-size: 14px; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tuto-section p { margin: 4px 0; }
.tuto-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; }
.tuto-shot { padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-sunken); cursor: zoom-in; display: block; overflow: hidden; }
.tuto-shot:hover { border-color: var(--accent); }
.tuto-shot img { display: block; width: 100%; height: 140px; object-fit: contain; }
.tuto-step .tuto-section { border: 0; padding: 0; margin-top: 8px; }
.modal-full { max-width: min(960px, 96vw); }
.tuto-steps { margin: 0 0 8px; padding-left: 22px; display: grid; gap: 4px; }
.tuto-more { margin: 8px 0; }
.tuto-full { display: block; max-width: 100%; height: auto; }

/* Historique de la CIBLE : par table, compteurs et lignes marquées par état (vert ajout, bleu
   d'accent modification, rouge suppression ; le mot accompagne toujours la couleur). */
.history { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.history > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; list-style: none; }
.history > summary::-webkit-details-marker { display: none; }
.history > summary::before { content: ""; width: 6px; height: 6px; border: solid var(--text-muted); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
.history[open] > summary::before { transform: rotate(45deg); }
.history-title { font-weight: 600; font-size: 12.5px; }
.history-counts { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chg { display: inline-flex; align-items: center; gap: 3px; border-radius: 999px; padding: 1px 8px 1px 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chg .icon, .chg-dot .icon { width: 12px; height: 12px; }
.chg-ajout { --chg: var(--good); --chg-soft: var(--good-soft); }
.chg-modif { --chg: var(--accent-ink); --chg-soft: var(--accent-soft); }
.chg-suppression { --chg: var(--danger-ink); --chg-soft: var(--danger-soft); }
.chg-colonne { --chg: var(--good); --chg-soft: var(--good-soft); }
.chg-refus { --chg: var(--warn); --chg-soft: var(--warn-soft); }
.chg { color: var(--chg); background: var(--chg-soft); }
.history-table { margin-top: 8px; }
.history-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-bottom: 4px; }
.history-rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chg-item + .chg-item { border-top: 1px solid var(--border); }
.chg-row { display: grid; grid-template-columns: 2.4em auto 1fr auto auto 8px; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; font-size: 12.5px; }
summary.chg-row { cursor: pointer; list-style: none; }
summary.chg-row::-webkit-details-marker { display: none; }
summary.chg-row::after { content: ""; width: 5px; height: 5px; border: solid var(--text-muted); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); transition: transform .15s; }
details[open] > summary.chg-row::after { transform: rotate(45deg); }
summary.chg-row:hover { background: var(--surface-sunken); }
.chg-n { color: var(--text-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; text-align: right; }
.chg-dot { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: var(--chg); background: var(--chg-soft); }
.chg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chg-suppression .chg-label { text-decoration: line-through; color: var(--text-muted); }
.chg-state { color: var(--chg); font-size: 12px; }
.chg-time { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.send-event { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 4px 8px; font-size: 12.5px; }
.send-event + .send-event { border-top: 1px solid var(--border); }
/* Dernier envoi ordinaire (d'après Grist, voir last-send.js) : en tête de l'historique, sans être un événement de la note ; caché quand Grist n'en dit aucun. */
.send-event[hidden] { display: none; }
.send-event[hidden] + .send-event { border-top: 0; }
.send-last { background: var(--surface-sunken); }
.history > .small { margin: 6px 0; }

/* Petit tableau de valeurs (avant/après de l'historique, valeurs retouchées), comme une vue Grist. */
.mini-grid-wrap { overflow-x: auto; }
.chg-item .mini-grid-wrap { padding: 2px 8px 8px calc(2.4em + 12px); }
.mini-grid { border-collapse: collapse; font-size: 12px; color: var(--text); background: var(--surface); }
.mini-grid th, .mini-grid td { border: 1px solid var(--border); padding: 2px 8px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.mini-grid thead th, .mini-grid tbody th { background: var(--surface-sunken); color: var(--text-muted); font-weight: 600; }
.mg-before td { background: var(--danger-soft); }
.mg-after td { background: var(--good-soft); }
.mg-blank { color: var(--text-muted); font-style: italic; }
.mg-n { color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.mg-here { font-weight: 600; }
.drift p { margin: 4px 0 0; }
.drift .mini-grid-wrap { margin-top: 6px; }
/* Changements d'un participant à valider (Échange administré ici). */
.review p { margin: 4px 0 0; }
.review-rows { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); color: var(--text); }
.review-item + .review-item { border-top: 1px solid var(--border); }
.review-head { display: grid; grid-template-columns: 2.4em auto 1fr auto auto; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; font-size: 12.5px; }
.review-actions { display: inline-flex; gap: 4px; }
.review-item .mini-grid-wrap { padding: 0 8px 8px calc(2.4em + 12px); }
.review .card-actions { margin-top: 8px; }
.btn-link { border: 0; background: none; color: var(--accent); padding: 4px 0; margin-top: 4px; }
.btn-link:hover:not(:disabled) { color: var(--accent-ink); text-decoration: underline; }
.icon-edit { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E"); }
/* Refuser (un changement reçu), Corriger (remettre la valeur de la SOURCE), Ignorer (une alerte) :
   une icône par fonction. */
.icon-refuse { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E"); }
.icon-undo { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 14 4 9l5-5'/%3E%3Cpath d='M4 9h10.5a5.5 5.5 0 0 1 0 11H11'/%3E%3C/svg%3E"); }
.icon-ignore { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.9 4.2A10 10 0 0 1 12 4c6.5 0 10 8 10 8a17 17 0 0 1-2.2 3.2M6.6 6.6A17 17 0 0 0 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20'/%3E%3C/svg%3E"); }
.icon-minus { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E"); }
