/* ====================================================================
   Le Greffier — assistant global (bouton flottant + panneau)
   Monté sur <body> : présent sur toutes les routes. z-index 45 (au-dessus du
   contenu, SOUS les overlays focus 50 et les toasts 60). Safe-area iPhone.
   ==================================================================== */
.greffier-fab {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 45; width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--hairline);
  background: var(--a-surface); color: var(--a-on); box-shadow: var(--shadow); cursor: pointer;
  display: grid; place-items: center; transition: transform .15s ease, box-shadow .15s ease;
}
.greffier-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.greffier-fab svg { width: 24px; height: 24px; }
.greffier-fab-badge {
  position: absolute; top: -3px; right: -3px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 10px; background: var(--danger); color: #fff; font: 600 11px/19px var(--sans);
  text-align: center; box-shadow: 0 0 0 2px var(--paper);
}
/* L'attribut [hidden] doit l'emporter sur display:flex — sinon le panneau (et les
   blocs internes) ne se masquent jamais : la croix « fermer » resterait sans effet. */
.greffier-panel[hidden], .greffier-ops[hidden], .greffier-apercu[hidden], .greffier-image-jointe[hidden],
.greffier-journal[hidden] { display: none !important; }   /* B66 : le journal replié doit VRAIMENT disparaître (display:flex l'emportait sur [hidden]) */
.greffier-panel {
  position: fixed; z-index: 46; right: max(16px, env(safe-area-inset-right));
  bottom: calc(84px + env(safe-area-inset-bottom)); width: min(420px, calc(100vw - 32px));
  max-height: min(72vh, 720px); display: flex; flex-direction: column;
  background: var(--card); color: var(--ink); border: 1px solid var(--hairline);
  border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.28); overflow: hidden;
}
/* D3 (CDC Greffe) : l'overlay « plein écran » a disparu — le ⛶ mène au Greffe. */
.greffier-plein-btn { font-size: 14px; }
.greffier-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px; border-bottom: 1px solid var(--hairline); }
.greffier-h-t { display: flex; align-items: center; gap: 7px; flex: 1 1 auto; min-width: 0; }
.greffier-h-t b { font-family: var(--sans); font-size: 15px; }
.greffier-mark { font-size: 16px; }
.greffier-modele { font-size: 11px; }
.greffier-x { font-size: 20px; line-height: 1; }
.greffier-ctx { margin: 0; padding: 8px 14px; font-family: var(--sans); font-size: var(--t-small); border-bottom: 1px solid var(--hairline); background: var(--paper-2, var(--paper)); }
.greffier-corps { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }
.greffier-fil { padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; }
.greffier-vide p { margin: 0 0 8px; font-family: var(--sans); font-size: 13px; line-height: 1.5; }
.greffier-msg { max-width: 86%; padding: 9px 12px; border-radius: 13px; font-family: var(--sans); font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.greffier-msg-user { align-self: flex-end; background: var(--a-surface); color: var(--a-on); border-bottom-right-radius: 4px; }
.greffier-msg-bot { align-self: flex-start; background: var(--paper); border: 1px solid var(--hairline); border-bottom-left-radius: 4px; }
.greffier-busy { opacity: .7; font-style: italic; }
.greffier-undo { align-self: flex-start; font-family: var(--sans); font-size: 12.5px; }
.greffier-sugg { padding: 0 14px; display: flex; flex-direction: column; gap: 8px; }
.greffier-sugg:empty { display: none; }
.greffier-pro { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; }
.greffier-pro-l { font-family: var(--sans); font-size: var(--t-caption); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.greffier-starter { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0; }
.greffier-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: var(--t-ui); text-align: left; padding: 7px 11px; border-radius: 16px;
  border: 1px solid var(--hairline); background: var(--paper); color: var(--ink); cursor: pointer; line-height: 1.35;
}
.greffier-chip:hover { border-color: var(--c-a); }
.greffier-chip-haute { border-left: 3px solid var(--danger); }
.greffier-chip-moyenne { border-left: 3px solid var(--gold); }
.greffier-chip-compagnon { border-style: dashed; }
.greffier-chip-orch { border-left: 3px solid var(--c-e); }
.greffier-op-orch { border-left-color: var(--c-e); }
.greffier-ops { padding: 0 14px 4px; display: flex; flex-direction: column; gap: 6px; }
.greffier-ops-t { margin: 6px 0 2px; font-family: var(--sans); font-size: 12.5px; font-weight: 600; }
.greffier-op { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border: 1px solid var(--hairline); border-left: 3px solid var(--c-c); border-radius: 8px; cursor: pointer; }
.greffier-op input { margin-top: 2px; width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--c-c); }
.greffier-op-b { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.greffier-op-d { font-family: var(--sans); font-size: 13px; font-weight: 600; }
.greffier-op-r { font-size: var(--t-small); line-height: 1.45; }
.greffier-ops-ign { font-size: 11.5px; }
.greffier-ops-a { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.greffier-f { border-top: 1px solid var(--hairline); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
.greffier-image-jointe { display: flex; align-items: center; gap: 6px; font-family: var(--sans); }
.greffier-img-x { border: none; background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 16px; line-height: 1; }
.greffier-img-x:hover { color: var(--danger); }
.greffier-apercu { display: flex; }
.greffier-apercu-b { font-family: var(--sans); font-size: 12.5px; padding: 6px 10px; border-radius: 8px; border: 1px dashed var(--c-a); background: transparent; color: var(--c-a); cursor: pointer; width: 100%; text-align: left; }
.greffier-barre { display: flex; align-items: flex-end; gap: 6px; }
.greffier-input { flex: 1 1 auto; resize: none; min-height: 38px; max-height: 120px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--hairline); background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 13.5px; line-height: 1.4; }
.greffier-input:focus { outline: 2px solid var(--c-a); outline-offset: -1px; }
.greffier-mic.on { background: var(--danger-surface); color: var(--danger-on); }
.greffier-send { padding: 0 12px; height: 38px; }
.greffier-send svg { width: 18px; height: 18px; }
.greffier-note { margin: 0; font-size: var(--t-caption); line-height: 1.4; }
@media (max-width: 560px) {
  .greffier-panel { right: 8px; left: 8px; width: auto; bottom: calc(78px + env(safe-area-inset-bottom)); max-height: 76vh; }
  .greffier-fab { width: 52px; height: 52px; }
}
/* Impression : la bulle disparaît ; au Greffe, le FIL s'imprime (la coquille,
   la saisie et le rail se retirent — il reste la conversation, datée par le titre). */
@media print {
  .greffier-fab, .greffier-panel:not(.greffier-page) { display: none !important; }
  .greffe-rail, .greffier-page .greffier-h, .greffier-page .greffier-ctx,
  .greffier-page .greffier-f, .greffier-page .greffier-sugg { display: none !important; }
  .greffier-page, .greffe, .greffe-corps, .greffier-page .greffier-corps { display: block; height: auto; max-height: none; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) { .greffier-fab { transition: none; } }
/* B66 · journal du Greffier (dans le panneau) */
.greffier-journal { display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.greffier-jrn-h { margin: 4px 0; }
.greffier-jrn-i { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--hairline); border-radius: 10px; }
.greffier-jrn-b { flex: 1 1 auto; min-width: 0; }
.greffier-jrn-t { margin: 0; }
.greffier-jrn-m { margin: 2px 0 0; font-size: .8rem; }
.greffier-jrn-undo { flex: 0 0 auto; }
.greffier-jrn[aria-pressed='true'] { background: color-mix(in srgb, var(--gold) 20%, transparent); }
/* B107 · « ce qui part » (Greffier) + B108 transparence (réglages) */
.greffier-cqp { margin: 4px 0 0; }
.greffier-cqp summary { cursor: pointer; font-size: .8rem; }
.greffier-cqp-pre { max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-size: .72rem; background: color-mix(in srgb, var(--ink) 4%, transparent); border-radius: 8px; padding: 8px; margin: 6px 0 0; }

/* Lot 4 : sur mobile, l'onglet CENTRAL de la barre basse remplace le FAB
   (le Greffier gagne la place d'honneur permanente — jamais marginalisé). */
@media (max-width: 860px) {
  .greffier-fab { display: none; }
  .greffier-panel { bottom: calc(76px + env(safe-area-inset-bottom)); }
}


/* ===== Lot 12 : le Greffier magnifié ===== */
.greffier-chip svg { width: 14px; height: 14px; flex: 0 0 auto; color: var(--ink-soft); }
.greffier-chip:hover svg { color: var(--a-text); }
/* Le panneau MONTE (320 ms) — l'assistant arrive, il n'apparaît pas sec */
.greffier-panel:not([hidden]) { animation: greffier-monte var(--dur-3) var(--ease); }
@keyframes greffier-monte { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) { .greffier-panel:not([hidden]) { animation: none; } }
/* Le journal s'annule au pouce (44 px) */
.greffier-jrn-undo { min-height: 40px; min-width: 44px; }
/* « Ce qui part » : la console de confiance se lit */
.greffier-cqp summary { font-size: var(--t-small); color: var(--ink-soft); }
.greffier-cqp summary:hover { color: var(--ink); }
.greffier-cqp-pre { font-size: 11.5px; line-height: 1.5; }
/* Mobile : une vraie sheet pleine largeur au-dessus de la barre basse */
@media (max-width: 560px) {
  .greffier-panel { left: 0; right: 0; border-radius: 16px 16px 0 0; max-height: 78vh; }
}

.greffier-cqp-ic { width: 13px; height: 13px; vertical-align: -2px; }

/* ==================================================================== */
/*  Le Greffe — l'onglet pleine page (le panneau ADOPTÉ par la vue)     */
/*  CDC-onglet-greffier.md · lot 1. La page ne scrolle pas : le FIL     */
/*  (.greffier-corps) reste l'unique scroller, comme dans la bulle.     */
/* ==================================================================== */
body.greffier-en-page { overflow: hidden; }
body.greffier-en-page .wrap { height: 100dvh; }
body.greffier-en-page .main-col { min-height: 0; }
body.greffier-en-page .view { min-height: 0; display: flex; flex-direction: column; padding-bottom: var(--sp-5); }
body.greffier-en-page .greffier-fab { display: none; }   /* on ne sonne pas quelqu'un qui est déjà là */

.greffe { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--sp-3); width: 100%; max-width: var(--gab-atelier); margin: 0 auto; }
.greffe-tete { display: flex; align-items: baseline; gap: var(--sp-4); flex-wrap: wrap; }
.greffe-tete .view-title { margin: 0; }
.greffe-corps { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-5); align-items: stretch; }
.greffe-conv { min-width: 0; min-height: 0; display: flex; }

/* Le panneau adopté : plus flottant, plus borné — il habite la colonne. */
.greffier-panel.greffier-page {
  position: static; flex: 1 1 auto; width: auto; max-width: none; height: auto; max-height: none;
  min-height: 0; border-radius: var(--r-l); box-shadow: var(--elev-1);
}
.greffier-panel.greffier-page:not([hidden]) { animation: none; }   /* l'entrée de vue est déjà la View Transition */
.greffier-page .greffier-x { display: none; }            /* une page ne se ferme pas */
.greffier-page .greffier-plein-btn { display: none; }    /* on y est déjà */
/* La lecture respire : corps de texte, bulles à l'aise, marges amples. */
.greffier-page .greffier-msg { font-size: var(--t-body); max-width: 72ch; }
.greffier-page .greffier-fil { padding: var(--sp-4) var(--sp-5); gap: 10px; }
.greffier-page .greffier-sugg, .greffier-page .greffier-ops, .greffier-page .greffier-journal { padding-inline: var(--sp-5); }
.greffier-page .greffier-f { padding-inline: var(--sp-5); }
.greffier-page .greffier-input { font-size: var(--t-body); }

/* Le rail : les organes du Greffe, en périphérie de l'objet central. */
.greffe-rail { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-5); padding-bottom: var(--sp-2); }
/* Chaque organe du rail est un <details> : à demeure sur bureau (ouvert),
   replié sur mobile — le summary EST l'en-tête de section. */
.greffe-sec { display: flex; flex-direction: column; gap: var(--sp-2); }
.greffe-sec-t { margin: 0 0 2px; font-family: var(--sans); font-size: var(--t-caption); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); cursor: pointer; }
.greffe-sec-t:hover { color: var(--ink); }
.greffe-geste {
  display: flex; align-items: center; gap: 9px; min-height: 44px; padding: 8px 12px; text-align: left;
  font-family: var(--sans); font-size: var(--t-ui); color: var(--ink); cursor: pointer;
  border: 1px solid var(--hairline); border-radius: var(--r-m); background: var(--card);
}
.greffe-geste:hover { border-color: var(--a-line); background: var(--a-tint); }
.greffe-geste:active { transform: translateY(1px); }
.greffe-geste-ic { width: 16px; height: 16px; flex: 0 0 auto; color: var(--ink-soft); }
.greffe-geste:hover .greffe-geste-ic { color: var(--a-text); }

/* D'un coup d'œil : 4 tuiles cliquables — le chiffre en serif, l'unité dite. */
.greffe-tuiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.greffe-tuile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 10px 12px; text-align: left; border: 1px solid var(--hairline); border-radius: var(--r-m); background: var(--card); cursor: pointer; }
.greffe-tuile:hover { border-color: var(--a-line); background: var(--a-tint); }
.greffe-tuile:active { transform: translateY(1px); }
.greffe-tuile-v { font-family: var(--serif); font-size: var(--t-h2); font-weight: 600; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.greffe-tuile-l { font-family: var(--sans); font-size: var(--t-small); color: var(--ink-soft); line-height: 1.35; }
/* Attente : blocs statiques aux dimensions finales (CLS = 0, DIRECTION-UX §5). */
.greffe-tuile-attente { min-height: 64px; border: 1px solid var(--hairline); border-radius: var(--r-m); background: var(--card); animation: attente-pulse 1.2s var(--ease) infinite alternate; }
@media (prefers-reduced-motion: reduce) { .greffe-tuile-attente { animation: none; opacity: .7; } }

/* Le journal à demeure : l'organe B66, 8 dernières écritures, ↶ au pouce. */
.greffe-jrn-i { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--hairline); border-radius: var(--r-m); background: var(--card); }
.greffe-jrn-b { flex: 1 1 auto; min-width: 0; }
.greffe-jrn-t { margin: 0; font-family: var(--sans); font-size: var(--t-small); line-height: 1.4; }
.greffe-jrn-m { margin: 2px 0 0; font-size: var(--t-caption); }
.greffe-jrn-undo { flex: 0 0 auto; min-height: 44px; min-width: 44px; }
.greffe-rail-vide { margin: 0; font-size: var(--t-small); line-height: 1.5; }

/* Mobile : une colonne — le rail se REPLIE au-dessus du fil (details fermés),
   il ne disparaît plus ; le fil garde la part du lion. */
@media (max-width: 860px) {
  .greffe-corps { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .greffe-rail { order: -1; max-height: 38dvh; gap: 0; }
  .greffe-tete .view-sub { display: none; }             /* le fil garde la part du lion */
  .greffe-sec-t { padding: 12px 0; }                    /* zone de frappe ≥ 44 px au pouce */
  .greffe-sec[open] { padding-bottom: var(--sp-3); }
  body.greffier-en-page .view { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}
