/* picofasthtml — tokens projet + mapping Pico + composants de la librairie.
 * Chargé APRÈS pico.min.css. Ne jamais éditer Pico directement.
 *
 * Palette reprise de workflowy-replicate (valeurs relevées sur workflowy.com).
 */

:root {
  /* -- tokens projet -------------------------------------------------- */
  --u-text:   #2a3135;
  --u-muted:  #868c90;
  --u-line:   #eceef0;
  --u-halo:   #dce0e2;
  --u-dot:    #4b5155;
  --u-accent: #3d8bfd;
  --u-accent-hover: #2f7de8;
  --u-bg:     #ffffff;
  --u-surface: #ffffff;

  --u-bar-h: 3.25rem;              /* hauteur de la topbar */
  --pfx-drawer-w: 17rem;           /* largeur du menu latéral (bureau) —
                                      réécrite par picofasthtml.js au drag */
}

/* Mapping vers les variables Pico. Le sélecteur reprend EXACTEMENT celui de
 * Pico (`:root:not([data-theme=dark])`) : à spécificité égale, c'est la
 * feuille chargée en dernier qui gagne — donc il faut cette forme, un simple
 * `:root` serait battu par Pico. L'app est verrouillée en thème clair
 * (voir <meta name=color-scheme content=light> dans assets.py). */
:root:not([data-theme="dark"]) {
  --pico-primary:                 var(--u-accent);
  --pico-primary-background:       var(--u-accent);
  --pico-primary-border:           var(--u-accent);
  --pico-primary-hover:            var(--u-accent-hover);
  --pico-primary-hover-background: var(--u-accent-hover);
  --pico-primary-hover-border:     var(--u-accent-hover);
  --pico-primary-focus:           rgba(61, 139, 253, 0.25);
  --pico-primary-underline:       rgba(61, 139, 253, 0.5);
  --pico-color:                    var(--u-text);
  --pico-background-color:         var(--u-bg);
  --pico-muted-color:              var(--u-muted);
  --pico-muted-border-color:       var(--u-line);
  --pico-border-color:             var(--u-line);
  --pico-border-radius:            6px;
  --pico-font-family: -apple-system, "system-ui", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Pico applique son fond sur <body> ; on garde la même teinte que wfreplicate. */
body { background: var(--u-bg); }

/* ====================================================================
 * pfx-bar — topbar horizontale collée en haut
 * ==================================================================== */
.pfx-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: var(--u-bar-h);
  /* même gouttière horizontale que le .container Pico, pour aligner
     la marque sur le <h1> du contenu */
  padding-inline: var(--pico-spacing, 1rem);
  background: var(--u-surface);
  margin: 0;
}
.pfx-bar > * { margin: 0; }
/* `overflow` reste visible : le menu de page (.pfx-pop__panel) déborde la
   barre sur bureau. Le scroll horizontal de page est bloqué plus haut, sur
   .pfx-shell (overflow-x: clip). */

.pfx-bar--top {
  position: sticky;
  top: 0;
  /* le menu de page (.pfx-pop__panel, fixed) est peint dans le contexte
     d'empilement de la topbar ; il doit passer au-dessus de la barre d'actions. */
  z-index: 20;
  border-bottom: 1px solid var(--u-line);
  padding-top: env(safe-area-inset-top);
}

/* marque / titre à gauche */
.pfx-bar__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--u-text);
  text-decoration: none;
  white-space: nowrap;
}
.pfx-bar__brand:hover { color: var(--u-text); }
.pfx-bar__brand { flex-shrink: 0; }

/* pousse ce qui suit vers la droite */
.pfx-bar__spacer { flex: 1 1 auto; min-width: 0.5rem; }

/* groupe d'actions (nav) à droite ; scroll horizontal si trop étroit.
   Mobile-first : masqué par défaut, repassé en `flex` à partir de 768px (voir
   le @media plus bas). Les propriétés flex ci-dessous ne servent donc qu'à
   partir de ce palier. */
.pfx-bar__actions {
  display: none;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  padding: 0;
  margin: 0;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pfx-bar__actions::-webkit-scrollbar { display: none; }
.pfx-bar__actions li { list-style: none; flex-shrink: 0; }
.pfx-bar__actions a {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  color: var(--u-muted);
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
}
.pfx-bar__actions a:hover { background: var(--u-halo); color: var(--u-text); }
.pfx-bar__actions a[aria-current] { color: var(--u-text); font-weight: 600; }

/* ====================================================================
 * pfx-iconbtn — bouton icône ≥ 44px (cible tactile iOS)
 * ==================================================================== */
.pfx-iconbtn {
  --pico-background-color: transparent;
  --pico-border-color: transparent;
  --pico-color: var(--u-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--u-text);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.pfx-iconbtn:hover { background: var(--u-halo); }
/* glyphe = SVG inline (`currentColor`) plutôt qu'un caractère : rendu net et
   identique sur toutes plateformes, voir ux/picofasthtml/icons.py. */
.pfx-iconbtn svg { width: 24px; height: 24px; display: block; pointer-events: none; }

/* ====================================================================
 * Shell applicatif — topbar + contenu + barre d'actions en colonne plein écran
 * ==================================================================== */
.pfx-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  /* bloque tout débordement horizontal (barre d'actions, panneaux) sans
     créer de conteneur de défilement — `clip` (≠ `hidden`) ne casse pas le
     `position: sticky` des barres. */
  overflow-x: clip;
}
.pfx-shell__main {
  flex: 1 1 auto;
  width: 100%;
}
/* padding vertical du contenu (le .container Pico gère l'horizontal) */
.pfx-shell__main > .container { padding-block: 1.5rem 2.5rem; }

/* Inputs : 16px minimum pour éviter le zoom auto de Safari iOS au focus. */
@media (max-width: 480px) {
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; }
}

/* ====================================================================
 * Menu coulissant (drawer) façon appli mobile — voir drawer.py
 * Mécanique CSS pure : .pfx-menu-toggle (checkbox cachée) pilote l'état.
 * ==================================================================== */
.pfx-menu-toggle,
.pfx-menu-pin { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Bouton hamburger : visible en mobile uniquement. */
.pfx-burger { display: inline-flex; }

.pfx-drawer-root { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }

.pfx-drawer__scrim {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 28, 0.38);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  cursor: pointer;
}

.pfx-drawer {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: min(86vw, 20rem);
  display: flex;
  flex-direction: column;
  background: var(--u-surface);
  border-right: 1px solid var(--u-line);
  transform: translateX(-100%);
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  /* le défilement est porté par __body : l'en-tête et le pied restent fixes,
     et la poignée de resize (enfant absolu) ne défile pas avec le contenu. */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

/* état ouvert. L'ombre ne vit QUE ici (pas sur `.pfx-drawer` de base) : tiroir
   fermé, `translateX(-100%)` amène son bord droit pile sur le bord gauche du
   viewport (x=0) — un box-shadow présent en permanence baverait donc sur
   ~40px de flou par-dessus le contenu visible. Le tiroir vit en plus dans
   `.pfx-drawer-root` (position: fixed), qui échappe au clip de `.pfx-shell`
   (overflow-x: clip), donc rien ne rognerait ce débordement. */
.pfx-menu-toggle:checked ~ .pfx-drawer-root { pointer-events: auto; }
.pfx-menu-toggle:checked ~ .pfx-drawer-root .pfx-drawer__scrim { opacity: 1; pointer-events: auto; }
.pfx-menu-toggle:checked ~ .pfx-drawer-root .pfx-drawer {
  transform: none;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.16);
}

/* poignée de redimensionnement, sur le bord droit (bureau — voir picofasthtml.js) */
.pfx-drawer__resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 11px;
  height: 100%;
  cursor: ew-resize;
  touch-action: none;
  z-index: 3;
}
.pfx-drawer__resize::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background: transparent;
  transition: background 0.15s ease;
}
.pfx-drawer__resize:hover::after,
.pfx-drawer-resizing .pfx-drawer__resize::after { background: var(--u-accent); }
.pfx-drawer-resizing, .pfx-drawer-resizing * { user-select: none !important; cursor: ew-resize !important; }
.pfx-drawer-resizing .pfx-drawer { transition: none; }
@media (max-width: 767px) { .pfx-drawer__resize { display: none; } }

.pfx-drawer__header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--u-line);
}
.pfx-drawer__controls { display: inline-flex; gap: 0.1rem; margin-left: auto; flex-shrink: 0; }
.pfx-drawer__controls .pfx-iconbtn { width: 2.5rem; height: 2.5rem; font-size: 0.95rem; }
.pfx-drawer__controls .pfx-iconbtn svg { width: 24px; height: 24px; }
.pfx-drawer__pin { display: none; }   /* épinglage : bureau large uniquement */

.pfx-drawer__account { display: flex; align-items: center; gap: 0.6rem; min-width: 0; flex: 1; }
.pfx-drawer__avatar {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--u-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}
.pfx-drawer__account-text { display: flex; flex-direction: column; min-width: 0; }
.pfx-drawer__account-name {
  font-weight: 600;
  color: var(--u-text);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pfx-drawer__account-role { color: var(--u-muted); font-size: 0.75rem; text-transform: capitalize; }

/* Sélecteur d'arbre (admin) : liste déroulante Pico dans l'en-tête du tiroir. */
.pfx-drawer__switch { flex: 1; min-width: 0; margin: 0; }
.pfx-drawer__switch > summary {
  display: block;
  width: 100%;
  height: auto;
  padding: 0.15rem 1.4rem 0.15rem 0;
  border: 0;
  background: none;
  line-height: 1.2;
  overflow: hidden;
}
.pfx-drawer__switch > summary::after { top: 0.35rem; }
.pfx-drawer__switch > summary .pfx-drawer__account-name,
.pfx-drawer__switch > summary .pfx-drawer__account-role {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pfx-drawer__switch > summary .pfx-drawer__account-role { text-transform: none; }
.pfx-drawer__switch > ul {
  max-height: min(60vh, 22rem);
  overflow-y: auto;
  z-index: 5;
}
.pfx-drawer__switch-item {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pfx-drawer__switch-item[aria-current] { background: var(--u-halo); font-weight: 600; }
.pfx-drawer__switch-item--self { color: var(--u-accent); }
.pfx-drawer__switch-item svg { width: 13px; height: 13px; vertical-align: -2px; }

/* Bandeau permanent « vous consultez l'arbre de … ». */
.pfx-impersonate {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.9rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  background: #fff4d6;
  border: 1px solid #e8cf8a;
  color: #6b5010;
  font-size: 0.85rem;
}
.pfx-impersonate__exit { font-weight: 600; white-space: nowrap; }

/* Champ « lien magique » de la page d'invitation : large, monospace, sélectionnable. */
.pfx-invite-link {
  width: 100%;
  font-family: var(--pico-font-family-monospace, monospace);
  font-size: 0.85rem;
}

/* --- Tableau d'administration des utilisateurs --- */
.pfx-users { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pfx-users__table { width: 100%; min-width: 640px; font-size: 0.9rem; }
.pfx-users__table th { white-space: nowrap; }
.pfx-users__table td { vertical-align: middle; }
.pfx-users__email { font-weight: 600; }
.pfx-users__when { color: var(--u-muted); white-space: nowrap; }
.pfx-users__count { text-align: right; font-variant-numeric: tabular-nums; }
.pfx-users__off td { opacity: 0.55; }
.pfx-users__magic {
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  background: #fff4d6;
  border: 1px solid #e8cf8a;
}
.pfx-users__magic p { margin: 0 0 0.4rem; font-size: 0.85rem; }

.pfx-users__acts { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pfx-users__act { margin: 0; }
.pfx-btn-sm {
  margin: 0;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.pfx-utag {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: 1px;
}
/* Ces badges sont en 0.7rem : du texte normal au sens WCAG, donc 4.5:1 exigé.
   `--u-muted` sur `--u-halo` ne donnait que 2.56:1 — les teintes sont conservées,
   seule la luminosité descend. `--superadmin` passait déjà (4.67:1). */
.pfx-utag--user { background: var(--u-halo); color: #565b5e; }
.pfx-utag--admin { background: #e7f0ff; color: #1864ab; }
.pfx-utag--superadmin { background: #ffe3e3; color: #c2255c; }
.pfx-utag--off { background: #f1f3f5; color: #5f666d; }

.pfx-drawer__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.5rem 0.5rem 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.pfx-drawer__search { margin: 0.5rem 0.25rem 0.75rem; }
.pfx-drawer__search input { width: 100%; margin: 0; }

.pfx-drawer__section { margin-top: 0.75rem; }
.pfx-drawer__section:first-child { margin-top: 0; }
.pfx-drawer__section-label {
  padding: 0.25rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--u-muted);
}
.pfx-drawer__list { display: flex; flex-direction: column; }

.pfx-drawer__item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  color: var(--u-text);
  text-decoration: none;
  font-size: 0.95rem;
}
.pfx-drawer__item:hover { background: var(--u-halo); }
.pfx-drawer__item[aria-current] { background: var(--u-halo); font-weight: 600; }
.pfx-drawer__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--u-muted);
}
.pfx-drawer__icon svg { width: 24px; height: 24px; display: block; }
.pfx-drawer__item:hover .pfx-drawer__icon,
.pfx-drawer__item[aria-current] .pfx-drawer__icon { color: var(--u-text); }
.pfx-drawer__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pfx-drawer__footer {
  padding: 0.75rem;
  border-top: 1px solid var(--u-line);
  color: var(--u-muted);
  font-size: 0.75rem;
}
.pfx-drawer__storage { margin-top: 0.5rem; }
.pfx-drawer__storage-label { display: block; margin-bottom: 0.25rem; }
.pfx-drawer__storage-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--u-line);
  overflow: hidden;
}
.pfx-drawer__storage-fill {
  height: 100%;
  background: var(--u-accent, #3d8bfd);
}

/* --------------------------------------------------------------------
 * Bureau : largeur pilotée par --pfx-drawer-w (redimensionnable), et
 * possibilité d'épingler le tiroir (≥ 1024px) — il pousse le contenu.
 * ------------------------------------------------------------------ */
@media (min-width: 768px) {
  .pfx-drawer { width: var(--pfx-drawer-w); max-width: 90vw; }
}

@media (min-width: 1024px) {
  .pfx-drawer__pin { display: inline-flex; }

  /* tiroir épinglé : plus de superposition, il occupe sa colonne */
  .pfx-menu-pin:checked ~ .pfx-drawer-root { pointer-events: none; }
  .pfx-menu-pin:checked ~ .pfx-drawer-root .pfx-drawer { pointer-events: auto; }
  .pfx-menu-pin:checked ~ .pfx-drawer-root .pfx-drawer__scrim { display: none; }
  .pfx-menu-pin:checked ~ .pfx-drawer-root .pfx-drawer {
    transform: none;
    box-shadow: none;
  }
  .pfx-menu-pin:checked ~ .pfx-drawer-root .pfx-drawer__close { display: none; }
  .pfx-menu-pin:checked ~ .pfx-drawer-root .pfx-drawer__pin { color: var(--u-accent); }

  /* le contenu se décale de la largeur du tiroir */
  .pfx-menu-pin:checked ~ .pfx-bar--top,
  .pfx-menu-pin:checked ~ .pfx-shell__main,
  .pfx-menu-pin:checked ~ .pfx-actionbar-wrap {
    padding-left: calc(var(--pfx-drawer-w) + 0.75rem);
  }
  .pfx-menu-pin:checked ~ .pfx-bar--top .pfx-burger { display: none; }
}

/* ====================================================================
 * Menu de page « ••• » (pop-menu) — voir popmenu.py
 * mobile : feuille qui remonte du bas (bottom sheet) + voile
 * bureau : liste déroulante ancrée sous le bouton
 * ==================================================================== */
.pfx-pop { position: relative; display: inline-flex; flex-shrink: 0; }
.pfx-pop-toggle { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* défense : rebat le `display` que Pico impose via `[type=checkbox] ~ label`
   (voir popmenu.py) si le déclencheur repassait après la case. */
.pfx-pop .pfx-pop__trigger { display: inline-flex; }

/* 3 points dessinés en CSS : parfaitement centrés dans le bouton, quelle que
   soit la police (un glyphe « ••• » ou « ⋯ » se décale verticalement). */
.pfx-dots, .pfx-dots::before, .pfx-dots::after {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}
.pfx-dots {
  position: relative;
  display: block;
  color: inherit;  /* les points prennent la couleur du bouton porteur */
}
.pfx-dots::before, .pfx-dots::after { content: ""; position: absolute; top: 0; }
.pfx-dots::before { left: -7px; }
.pfx-dots::after { left: 7px; }

.pfx-pop__scrim {
  position: fixed;
  inset: 0;
  z-index: 1090;
  background: rgba(20, 24, 28, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

.pfx-pop__panel {
  position: fixed;
  z-index: 1100;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--u-surface);
  border-top: 1px solid var(--u-line);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
  padding: 0.25rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  max-height: 80vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* état ouvert */
.pfx-pop-toggle:checked ~ .pfx-pop__scrim { opacity: 1; pointer-events: auto; }
.pfx-pop-toggle:checked ~ .pfx-pop__panel { transform: none; }

.pfx-pop__grip {
  width: 2.25rem;
  height: 0.25rem;
  border-radius: 999px;
  background: var(--u-halo);
  margin: 0.25rem auto 0.35rem;
}
.pfx-pop__title {
  padding: 0.1rem 0.7rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--u-muted);
}
.pfx-pop__list { display: flex; flex-direction: column; }
.pfx-pop__sep { height: 1px; background: var(--u-line); margin: 0.2rem 0.5rem; }

.pfx-pop__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.3rem 0.7rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--u-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.pfx-pop__item:hover { background: var(--u-halo); }
.pfx-pop__item--danger { color: #c0392b; }
.pfx-pop__item--danger:hover { background: rgba(192, 57, 43, 0.1); }
.pfx-pop__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--u-muted);
}
.pfx-pop__icon svg { width: 24px; height: 24px; display: block; }
.pfx-pop__item--danger .pfx-pop__icon { color: inherit; }
.pfx-pop__label { flex: 1; min-width: 0; }

/* --- couleur du nœud, en tête de menu (voir pagemenu._color_row) --- */
.pfx-pop__colors {
  gap: 0.5rem;
  cursor: default;
  min-height: 0;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}
.pfx-pop__colors:hover { background: transparent; }

/* sélecteur de couleur natif : Pico met les inputs à width:100% + hauteur de
   form-element + margin-bottom -> on rétablit une pastille compacte. */
.pfx-pop__colors .pfx-colorpick {
  flex: 1;
  width: auto;
  height: 2.1rem;
  min-width: 0;
  max-width: 9rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--u-line);
  border-radius: 6px;
  background: var(--u-surface);
  cursor: pointer;
}
.pfx-colorpick::-webkit-color-swatch-wrapper { padding: 3px; }
.pfx-colorpick::-webkit-color-swatch { border: none; border-radius: 3px; }
.pfx-colorpick::-moz-color-swatch { border: none; border-radius: 3px; }

.pfx-pop__colors .pfx-colorpick__reset {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--u-line);
  border-radius: 6px;
  background: var(--u-surface);
  color: var(--u-muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}
.pfx-pop__colors .pfx-colorpick__reset:hover { color: var(--u-text); background: var(--u-halo); }

/* ====================================================================
 * Bascule mobile / bureau — 768px
 * mobile  : hamburger + drawer, menu de page en bottom sheet
 * bureau  : hamburger + drawer AUSSI (comme Workflowy) + liens texte dans la
 *           topbar, menu de page en liste déroulante
 * ==================================================================== */
@media (min-width: 768px) {
  /* le `display: none` de base est posé avec le reste de `.pfx-bar__actions` */
  .pfx-bar__actions { display: flex; }

  /* menu de page : dropdown ancré sous le bouton, plus de feuille ni de voile */
  .pfx-pop__scrim {
    position: fixed;
    background: transparent;
    z-index: 1090;
  }
  .pfx-pop__panel {
    position: absolute;
    left: auto;
    right: 0;
    top: calc(100% + 0.35rem);
    bottom: auto;
    width: max-content;
    min-width: 13rem;
    max-width: min(20rem, 90vw);
    max-height: min(70vh, 30rem);
    border: 1px solid var(--u-line);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
    padding: 0.2rem;
    transform: translateY(-0.4rem);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
  }
  .pfx-pop-toggle:checked ~ .pfx-pop__panel { transform: none; opacity: 1; visibility: visible; }
  .pfx-pop__grip, .pfx-pop__title { display: none; }

  /* un pop-menu déclenché depuis la barre d'actions (bas d'écran, voir
     actionbar.py) doit s'ouvrir vers le HAUT : ancré sous le bouton comme
     ci-dessus, le panneau déborderait sous la fenêtre et agrandirait la
     page (scroll fantôme sous la barre d'actions). */
  .pfx-actionbar .pfx-pop__panel {
    top: auto;
    bottom: calc(100% + 0.35rem);
    transform: translateY(0.4rem);
  }
}

/* ====================================================================
 * Barre d'actions (« mobile-action-bar-wrap ») — voir actionbar.py
 * Rangée de raccourcis collée en bas. Visible à toutes les tailles ;
 * (à toutes les tailles).
 * ==================================================================== */
.pfx-actionbar-wrap {
  position: sticky;
  bottom: 0;
  z-index: 15;
  background: var(--u-surface);
  border-top: 1px solid var(--u-line);
  padding-bottom: env(safe-area-inset-bottom);
  /* [data-kbd-bar] : le maintien au-dessus du clavier virtuel (transform +
     classe `.is-kbd`, dont `padding-bottom: 0`) est géré par kbd-bar.js /
     kbd-bar.css — composant autonome. */
}

/* Mobile : l'EditActionBar (collée en bas, tenue au-dessus du clavier par
   kbd-bar.js) est remplacée par la SelActionBar en pilule flottante — ancrée
   au texte, elle suit le clavier nativement (position: absolute + coordonnées
   page) sans dépendre du `.is-kbd` piloté par JS, pas fiable sur iOS (barre
   qui restait partiellement masquée par le clavier pendant le scroll). Sur
   bureau, pas de clavier virtuel à traquer : gabarit normal de l'ActionBar. */
@media (max-width: 767px) {
  /* Scopé à `.pfx-shell` (la vraie app) : un id nu masquerait aussi la démo
     de ce composant dans l'atelier (`/components`, rendue hors `.pfx-shell`,
     voir `ux/components/framework.py:_canvas`) dès qu'on la consulte sous
     768px de large — précisément le cas d'usage pour vérifier ce composant. */
  .pfx-shell #pfx-edit-actionbar { display: none !important; }
}
.pfx-actionbar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 0.25rem;
  min-height: 3.25rem;
  padding: 0.2rem 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.pfx-actionbar::-webkit-scrollbar { display: none; }

.pfx-actionbar__btn {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 3rem;
  min-height: 2.75rem;
  margin: 0;              /* Pico met `margin-bottom` sur <button> -> décale
                            le contenu vers le haut dans la barre. */
  padding: 0.2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--u-muted);
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
}
.pfx-actionbar__btn:hover { background: var(--u-halo); color: var(--u-text); }
.pfx-actionbar__btn[aria-current] { color: var(--u-accent); }
.pfx-actionbar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.4rem;
  font-size: 1.2rem;
  line-height: 1;
}
.pfx-actionbar__icon svg { width: 1.4rem; height: 1.4rem; display: block; }
.pfx-actionbar__label { font-size: 0.65rem; white-space: nowrap; }

/* bouton « + » mis en avant : pastille pleine, sans libellé */
.pfx-actionbar__btn--primary { color: #fff; }
.pfx-actionbar__btn--primary .pfx-actionbar__icon {
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--u-accent);
  border-radius: 50%;
  font-size: 1.4rem;
}
.pfx-actionbar__btn--primary .pfx-actionbar__icon svg { width: 1.5rem; height: 1.5rem; }
.pfx-actionbar__btn--primary:hover { background: transparent; }
.pfx-actionbar__btn--primary:hover .pfx-actionbar__icon { background: var(--u-accent-hover); }
.pfx-actionbar__btn--primary .pfx-actionbar__label { display: none; }

/* sur bureau : rangée resserrée et centrée plutôt qu'étalée sur toute la
   largeur, avec les libellés bien lisibles */
@media (min-width: 768px) {
  .pfx-actionbar {
    justify-content: center;
    gap: 1.5rem;
    max-width: 44rem;
    margin: 0 auto;
    overflow-x: visible;
  }
  .pfx-actionbar__btn { flex: 0 0 auto; min-width: 4rem; }
  .pfx-actionbar__label { font-size: 0.7rem; }
}

/* --- barres d'édition contextuelles (ux/components/editbar.py) ---------- */

/* EditActionBar : remplace la barre d'actions quand une ligne est en
   édition. Même gabarit que .pfx-actionbar, filet d'accent pour signaler le
   mode. Toggle du hidden par wf-edit.js sur focusin / focusout d'un champ. */
.pfx-actionbar-wrap--edit .pfx-actionbar__btn:hover {
  color: var(--u-accent);
}

/* SelActionBar : pilule flottante quand une ligne est en édition. Positionnée
   par wf-edit.js (ancrée à la sélection / au curseur) ; statique dans
   l'atelier. `position: absolute` (coordonnées page, comme les autres
   popups) : le scroll l'emporte nativement avec le texte, sans recalcul JS —
   un `position: fixed` recalculé au `scroll` se détache visuellement de la
   sélection pendant l'inertie du scroll sur iOS Safari.
   Deux groupes de boutons (`.pfx-selbar__group--format` /  `--structure`),
   un seul affiché à la fois (`wf-edit.js`, selon présence d'une sélection) —
   sur mobile la pilule fait aussi office d'`EditActionBar` (indenter, tag…) :
   ancrée au texte, elle échappe au bug de la barre collée en bas à traquer
   au-dessus du clavier virtuel iOS (voir `#pfx-edit-actionbar` plus bas,
   masquée sur mobile). */
.pfx-selbar {
  position: absolute;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--u-surface);
  border: 1px solid var(--u-line);
  box-shadow: 0 6px 22px -6px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
.pfx-selbar__group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.pfx-selbar__group[hidden] { display: none; }
.pfx-selbar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  margin: 0;              /* Pico met margin-bottom sur button ET label —
                            différent selon l'élément -> désalignait
                            `align-items:center` (couleur/surlignage bas). */
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--u-text);
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
}
.pfx-selbar__btn:hover { background: var(--u-halo); }
.pfx-selbar__btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--u-accent) 16%, transparent);
  color: var(--u-accent);
}

/* glyphe = boîte carrée qui centre son contenu, que ce soit une lettre
   (B/I/U/S/A, empattements) ou un <svg> — même gabarit pour tout le monde. */
.pfx-selbar__glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 1.05rem;
  height: 1.05rem;
  font-size: 0.95rem;
  line-height: 1;
  font-family: Georgia, "Times New Roman", serif;
}
.pfx-selbar__glyph svg { display: block; width: 1rem; height: 1rem; }
.pfx-selbar__btn.is-bold      .pfx-selbar__glyph { font-weight: 700; }
.pfx-selbar__btn.is-italic    .pfx-selbar__glyph { font-style: italic; }
.pfx-selbar__btn.is-underline .pfx-selbar__glyph { text-decoration: underline; }
.pfx-selbar__btn.is-strike    .pfx-selbar__glyph { text-decoration: line-through; }

/* séparateur avant le bouton « effacer la mise en forme » */
.pfx-selbar__sep {
  flex: 0 0 auto;
  width: 1px;
  height: 1.25rem;
  margin: 0 3px;
  background: var(--u-line);
}

/* sélecteurs de couleur (texte « A » + surlignage) : <input type=color> natif
   masqué sous le glyphe. Le trait de couleur courante est le ::after — la
   réserve `padding-bottom` le loge DANS la boîte, donc le glyphe reste centré
   verticalement comme B/I/U/S (pas de décalage vers le bas). */
.pfx-selbar__btn--pick { position: relative; overflow: hidden; }
.pfx-selbar__glyph--swatch { position: relative; }
.pfx-selbar__glyph--color { font-weight: 600; }
.pfx-selbar__glyph--swatch::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;               /* dans la boîte : n'agrandit pas l'empreinte */
  height: 3px;
  border-radius: 2px;
  background: var(--sel-color, var(--u-accent));
}
.pfx-selbar__pick {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
}
