/* Document Lab — chrome éditeur + barre thème premium */

/* Entrée douce : évite le flash « chrome brut » au premier paint */
.fmt-doc-lab.fmt-ed-shell {
  animation: fmt-doc-lab-in 0.22s ease-out both;
}
@keyframes fmt-doc-lab-in {
  from { opacity: 0.55; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .fmt-doc-lab.fmt-ed-shell { animation: none; }
}

/* Annule le fond plat .fmt-theme-dark/light + largeur 720px du canvas formation */
.fmt-doc-lab .fmt-ed-canvas.fmt-doc-premium-root.fmt-theme-dark,
.fmt-doc-lab .fmt-ed-canvas.fmt-doc-premium-root.fmt-theme-light,
.fmt-doc-lab .fmt-ed-canvas.fmt-doc-premium-root {
  width: min(1120px, 100%);
  max-width: 100%;
  background: linear-gradient(180deg, var(--bg-a), var(--bg-b) 46%, var(--bg-a));
  color: var(--text);
  border-color: var(--border);
  transition: background 0.28s ease, color 0.2s ease;
}

.fmt-doc-lab .fmt-ed-add-strip {
  width: min(1120px, 100%);
}

.fmt-doc-lab .fmt-ed-stage,
.fmt-doc-lab.fmt-ed-preview-mode .fmt-ed-preview-stage {
  background:
    radial-gradient(42% 36% at 12% 0%, rgba(249, 115, 22, 0.08), transparent 55%),
    radial-gradient(38% 30% at 90% 20%, rgba(139, 92, 246, 0.06), transparent 58%),
    var(--surface-2, #070910);
}

.fmt-doc-lab .fmt-ed-canvas.fmt-doc-canvas,
.fmt-doc-lab .fmt-ed-preview-canvas-wrap .fmt-ed-canvas.fmt-doc-canvas {
  padding: 0;
  min-height: min(82vh, 960px);
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--border, #fff) 40%, transparent),
    0 24px 56px -28px rgba(0, 0, 0, 0.75);
}

.fmt-doc-lab .fmt-ed-canvas.fmt-doc-canvas[data-has-toc="1"] {
  overflow: visible;
  width: min(1200px, 100%);
}

.fmt-doc-lab .fmt-ed-canvas.fmt-doc-canvas .shell.has-toc {
  max-width: none;
  width: 100%;
  padding: 0 clamp(12px, 2vw, 28px);
  box-sizing: border-box;
}

.fmt-doc-lab .fmt-ed-canvas.fmt-doc-canvas .shell.has-toc > .fmt-canvas-inner.fmt-doc-premium-inner {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.fmt-doc-lab .fmt-ed-canvas-wrap {
  border-radius: 16px;
}

/* Aperçu / player : pleine largeur (comme Tester), pas de carte 1200px flottante. */
.fmt-doc-lab.fmt-doc-preview-full .fmt-ed-preview-canvas-wrap,
.fmt-player-shell.fmt-doc-player .fmt-ed-preview-canvas-wrap,
.fmt-ed-preview-canvas-wrap:has(> .fmt-doc-premium-root) {
  display: block !important;
  max-width: none;
  width: 100%;
  margin: 0;
  max-height: none;
  overflow: auto;
  border-radius: 0;
  padding: 0;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  align-self: stretch;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.fmt-doc-lab.fmt-doc-preview-full .fmt-doc-premium-root,
.fmt-player-shell.fmt-doc-player .fmt-doc-premium-root,
.fmt-ed-preview-canvas-wrap > .fmt-doc-premium-root {
  display: block;
  width: 100% !important;
  max-width: none;
  min-width: 0;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 100%;
  border-radius: 0;
  overflow: visible;
  box-sizing: border-box;
  box-shadow: none;
}

.fmt-doc-lab.fmt-doc-preview-full .fmt-doc-premium-inner,
.fmt-doc-lab.fmt-doc-preview-full .fmt-premium-doc {
  width: 100%;
  max-width: var(--maxw, 1120px);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.fmt-toc-hint {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted, #8b93a7);
}
.fmt-toc-hint strong {
  color: var(--text, inherit);
  font-weight: 600;
}

.fmt-doc-lab .fmt-ed-canvas.fmt-doc-canvas.fmt-doc-premium-root {
  display: block;
  position: relative;
  isolation: isolate;
}

.fmt-doc-lab .fmt-ed-canvas.fmt-doc-canvas .fmt-canvas-inner.fmt-doc-premium-inner {
  max-width: var(--maxw, 1120px);
  width: 100%;
  margin: 0 auto;
  min-height: min(82vh, 960px);
  padding: clamp(28px, 5vw, 56px) var(--pad, clamp(22px, 4.5vw, 48px)) clamp(40px, 6vw, 72px);
  box-shadow: none;
  border-radius: 0;
  background: transparent;
  gap: 0;
}

.fmt-doc-lab.fmt-ed-preview-mode .fmt-ed-preview-canvas-wrap {
  max-width: none;
  padding: 0;
}

.fmt-doc-lab.fmt-ed-preview-mode .fmt-ed-preview-canvas-wrap .fmt-ed-canvas {
  width: 100%;
  max-width: none;
}

/* Player participant — document premium pleine largeur (comme aperçu / Tester) */
.fmt-player-shell.fmt-doc-player .fmt-ed-preview-canvas-wrap {
  padding: 0;
  max-height: none;
}
.fmt-player-shell.fmt-doc-player .fmt-doc-premium-root {
  /* Remplit le stage flex (pas 100vh) pour éviter la bande noire sous le contenu. */
  min-height: 100%;
}
.fmt-doc-lab.fmt-ed-preview-mode.fmt-doc-preview-full {
  background: var(--fmt-chrome-bg, #070910);
}
.fmt-doc-lab.fmt-ed-preview-mode.fmt-doc-preview-full[data-fmt-chrome-theme="light"] {
  background: var(--fmt-chrome-bg, #eef1f8);
}
.fmt-doc-lab.fmt-ed-preview-mode.fmt-doc-preview-full .fmt-ed-preview-stage {
  background: transparent;
  padding: 0;
  gap: 0;
}
.fmt-doc-lab.fmt-ed-preview-mode.fmt-doc-preview-full .fmt-ed-preview-nav {
  margin-top: 0;
  background: color-mix(in srgb, var(--fmt-chrome-bg, #0a0d15) 94%, transparent);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.fmt-player-shell.fmt-doc-player .fmt-doc-premium-inner {
  width: 100%;
  max-width: var(--maxw, 1120px);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}
.fmt-player-shell.fmt-doc-player .fmt-ed-preview-nav {
  display: none;
}
.fmt-player-shell.fmt-doc-player.fmt-doc-paged .fmt-ed-preview-nav {
  display: block;
}

/* ——— Public document : header + footer type Intro IA ——— */
.fmt-player-shell.fmt-doc-player.fmt-public-mode {
  --fmt-doc-chrome-w: min(1120px, calc(100% - 24px));
  background: #070910;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-ed-preview-stage {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 0;
  box-sizing: border-box;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-ed-preview-canvas-wrap {
  flex: 1 1 auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 8px clamp(10px, 2.5vw, 28px) 12px;
  border-radius: 0;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-ed-page-tabs-bar--preview {
  display: none !important;
}

.fmt-doc-pub-head {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, #070910 92%, transparent);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  border-bottom: 1px solid color-mix(in srgb, #f97316 22%, rgba(255, 255, 255, 0.08));
}
.fmt-doc-pub-head-in {
  width: var(--fmt-doc-chrome-w, min(1120px, 100%));
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-sizing: border-box;
}
.fmt-doc-pub-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.fmt-doc-pub-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #f97316, #facc15);
  box-shadow: 0 8px 18px -10px rgba(249, 115, 22, 0.8);
  position: relative;
}
.fmt-doc-pub-mark::before,
.fmt-doc-pub-mark::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  top: 11px;
}
.fmt-doc-pub-mark::before { left: 7px; }
.fmt-doc-pub-mark::after { right: 7px; }
.fmt-doc-pub-title {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fmt-doc-pub-title b {
  color: #f97316;
  font-weight: 700;
}
.fmt-doc-pub-pages {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.fmt-doc-pub-pages::-webkit-scrollbar { display: none; }
.fmt-doc-pub-page {
  flex: 0 0 auto;
  max-width: 11rem;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.62);
  font: 600 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.fmt-doc-pub-page:hover {
  color: #fff;
  border-color: color-mix(in srgb, #f97316 45%, transparent);
}
.fmt-doc-pub-page.is-on {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(100deg, #f97316, #facc15);
  box-shadow: 0 8px 18px -12px rgba(249, 115, 22, 0.75);
}

.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-ed-preview-nav.fmt-doc-page-nav,
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-ed-preview-nav.fmt-player-nav-public {
  display: flex !important;
  position: sticky;
  bottom: 0;
  z-index: 30;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  background: #0a0d15 !important;
  border-top: 1px solid color-mix(in srgb, #f97316 28%, rgba(255, 255, 255, 0.1)) !important;
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.45);
  padding: 12px clamp(12px, 3vw, 20px) max(12px, env(safe-area-inset-bottom, 0px)) !important;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-player-nav-in {
  width: var(--fmt-doc-chrome-w, min(1120px, 100%));
  max-width: 1120px;
  margin: 0 auto;
  gap: 14px;
  align-items: center;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-ed-preview-nav-btn {
  min-height: 44px;
  padding: 0 1.15rem;
  border-radius: 999px !important;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: rgba(255, 255, 255, 0.9) !important;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-ed-preview-nav-btn:disabled {
  opacity: 0.32;
  color: rgba(255, 255, 255, 0.4) !important;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-player-nav-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff !important;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-player-nav-index {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45) !important;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-ed-preview-dots {
  margin-top: 2px;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-ed-preview-dot {
  background: rgba(255, 255, 255, 0.16);
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-ed-preview-dot.active {
  width: 22px;
  background: linear-gradient(100deg, #f97316, #facc15);
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-player-nav-next:not(.is-finish) {
  background: linear-gradient(100deg, #f97316, #facc15) !important;
  border-color: transparent !important;
  color: #111 !important;
  box-shadow: 0 10px 24px -12px rgba(249, 115, 22, 0.75) !important;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-player-nav-next.is-finish,
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-ed-preview-nav-finish.is-finish {
  width: 52px;
  min-width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0 !important;
  border-radius: 999px !important;
  background: linear-gradient(135deg, #f97316, #facc15) !important;
  border-color: transparent !important;
  color: #111 !important;
  font-weight: 800;
  box-shadow: 0 12px 28px -10px rgba(249, 115, 22, 0.8) !important;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-player-nav-next.is-finish .fmt-nav-lbl-full {
  display: none;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode .fmt-doc-page-nav .fmt-player-nav-next.is-finish .fmt-nav-lbl-short {
  display: inline !important;
}

/* Empêche le thème clair Magic d’écraser le chrome public document */
.fmt-player-shell.fmt-doc-player.fmt-public-mode[data-fmt-chrome-theme="light"] .fmt-ed-preview-nav.fmt-player-nav-public,
.fmt-player-shell.fmt-doc-player.fmt-public-mode[data-fmt-chrome-theme="light"] .fmt-ed-preview-nav.fmt-doc-page-nav {
  background: #0a0d15 !important;
  border-top-color: color-mix(in srgb, #f97316 28%, rgba(255, 255, 255, 0.1)) !important;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode[data-fmt-chrome-theme="light"] .fmt-doc-page-nav .fmt-ed-preview-nav-btn {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
  color: rgba(255, 255, 255, 0.9) !important;
}
.fmt-player-shell.fmt-doc-player.fmt-public-mode[data-fmt-chrome-theme="light"] .fmt-doc-page-nav .fmt-player-nav-title {
  color: #fff !important;
}

.fmt-doc-lab.fmt-ed-preview-mode .fmt-ed-preview-topbar .fmt-doc-theme-bar {
  flex: 1;
  justify-content: center;
  min-width: 0;
}
.fmt-doc-lab.fmt-ed-preview-mode > .fmt-ed-topbar.fmt-ed-preview-topbar {
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}
.fmt-doc-lab.fmt-ed-preview-mode > .fmt-ed-topbar .fmt-ed-top-title {
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(40vw, 280px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Topbar édition : titre + actions stables, thème centré sans casser la ligne */
.fmt-doc-lab > .fmt-ed-topbar {
  flex-wrap: nowrap;
  gap: 8px;
}
.fmt-doc-lab > .fmt-ed-topbar .fmt-ed-top-title {
  flex: 0 1 160px;
  max-width: 22vw;
}
.fmt-doc-lab > .fmt-ed-topbar .fmt-ed-sidebar-toggle {
  flex: 0 0 auto;
}
.fmt-doc-theme-bar {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  min-width: 0;
  margin: 0 4px;
  overflow: visible;
}
.fmt-doc-theme-bar .mcp-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill, 999px);
  background: transparent;
  backdrop-filter: blur(12px);
  max-width: 100%;
  overflow: visible;
}
.fmt-doc-lab > .fmt-ed-topbar .fmt-ed-preview-btn,
.fmt-doc-lab > .fmt-ed-topbar .fmt-doc-print-top,
.fmt-doc-lab > .fmt-ed-topbar [data-ed-save] {
  flex: 0 0 auto;
}
.fmt-doc-colors-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(34, 211, 238, 0.45);
  background: linear-gradient(135deg, #0891b2, #2563eb) !important;
  color: #fff !important;
  font-size: 0;
  cursor: pointer;
  box-shadow: 0 4px 12px -6px rgba(34, 211, 238, 0.55);
}
.fmt-doc-colors-top svg {
  width: 15px;
  height: 15px;
  stroke: #fff !important;
  color: #fff !important;
}
.fmt-doc-colors-top span {
  display: none;
}
.fmt-doc-colors-top:hover {
  filter: brightness(1.08);
}
.fmt-doc-print-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fmt-doc-panel .fmt-doc-hint {
  margin-top: 0;
}

.fmt-doc-print-btn,
.fmt-doc-record-btn,
.fmt-doc-capture-btn {
  width: 100%;
  justify-content: center;
  margin-top: var(--space-1);
}

@media (max-width: 1100px) {
  .fmt-doc-lab > .fmt-ed-topbar,
  .fmt-doc-lab.fmt-ed-preview-mode > .fmt-ed-topbar.fmt-ed-preview-topbar {
    flex-wrap: wrap;
  }
  .fmt-doc-lab > .fmt-ed-topbar .fmt-ed-top-title,
  .fmt-doc-lab.fmt-ed-preview-mode > .fmt-ed-topbar .fmt-ed-top-title {
    flex: 1 1 auto;
    max-width: none;
    min-width: 0;
  }
  .fmt-doc-theme-bar,
  .fmt-doc-lab.fmt-ed-preview-mode .fmt-ed-preview-topbar .fmt-doc-theme-bar {
    order: 5;
    flex: 1 1 100%;
    margin: 4px 0 0;
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .fmt-doc-theme-bar .mcp-mode-seg .mcp-mode-btn .mcp-mode-lbl {
    display: none;
  }
}

/* ——— Mobile : chrome compact (édition + aperçu) ——— */
@media (max-width: 768px) {
  /* Masque le header app « Formation » pendant l’éditeur — comme CRM / notes. */
  #content:has(#page-formation:not(.hidden) .fmt-ed-shell) .content-mobile-head {
    display: none !important;
  }

  .fmt-doc-lab > .fmt-ed-topbar,
  .fmt-ed-preview-mode > .fmt-ed-topbar.fmt-ed-preview-topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
    min-height: 44px;
    align-items: center;
  }
  /* Une seule rangée d’actions — le titre cède la place, pas Enregistrer. */
  .fmt-doc-lab > .fmt-ed-topbar > :not(.fmt-doc-theme-bar) {
    flex-shrink: 0;
  }
  .fmt-doc-lab > .fmt-ed-topbar .fmt-ed-top-title,
  .fmt-ed-preview-mode > .fmt-ed-topbar .fmt-ed-top-title {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    font-size: 13px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .fmt-doc-lab > .fmt-ed-topbar .fmt-btn,
  .fmt-doc-lab > .fmt-ed-topbar .fmt-ed-preview-btn,
  .fmt-ed-preview-mode > .fmt-ed-topbar .fmt-btn,
  .fmt-ed-preview-mode > .fmt-ed-topbar .fmt-ed-preview-btn {
    min-height: 34px;
    min-width: 34px;
    padding: 0 8px;
    font-size: 12px;
  }
  /* Retour compact */
  .fmt-doc-lab > .fmt-ed-topbar [data-ed-back] {
    font-size: 0;
    padding: 0 10px;
    letter-spacing: 0;
  }
  .fmt-doc-lab > .fmt-ed-topbar [data-ed-back]::before {
    content: "←";
    font-size: 16px;
    line-height: 1;
  }
  .fmt-ed-toggle-full,
  .fmt-ed-save-full {
    display: none;
  }
  .fmt-ed-toggle-short,
  .fmt-ed-save-short {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
  }
  .fmt-ed-sidebar-toggle .fmt-ed-toggle-short svg {
    display: block;
  }
  .fmt-doc-lab > .fmt-ed-topbar .fmt-ed-preview-label,
  .fmt-ed-preview-mode > .fmt-ed-topbar .fmt-ed-preview-label,
  .fmt-doc-print-top span:not(:first-child) {
    display: none;
  }
  .fmt-doc-print-top {
    padding: 0 8px;
    gap: 0;
  }
  .fmt-doc-print-top svg {
    width: 15px;
    height: 15px;
  }

  /* Palette : 2ᵉ rangée unique, scrollable */
  .fmt-doc-theme-bar {
    order: 8;
    flex: 1 1 100%;
    margin: 0;
    padding: 0 0 2px;
    justify-content: flex-start;
    max-width: 100%;
  }
  .fmt-doc-lab.fmt-ed-preview-mode .fmt-ed-preview-topbar .fmt-doc-theme-bar {
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .fmt-doc-theme-bar .mcp-toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    padding: 3px 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .fmt-doc-theme-bar .mcp-toolbar::-webkit-scrollbar {
    display: none;
  }
  .fmt-doc-theme-bar .mcp-mode-seg {
    flex-shrink: 0;
    padding: 2px;
  }
  .fmt-doc-theme-bar .mcp-mode-btn {
    padding: 4px 8px;
    font-size: 11px;
    gap: 3px;
  }
  .fmt-doc-theme-bar .mcp-style-bubbles {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    flex-shrink: 0;
  }
  .fmt-doc-theme-bar .mcp-style-bubble,
  .fmt-doc-theme-bar .paldot,
  .fmt-doc-theme-bar .mcp-style-bubbles-host .paldot {
    width: 26px !important;
    height: 26px !important;
    flex-shrink: 0;
  }
  .fmt-doc-theme-bar .mcp-palette-open {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px;
    padding: 0 !important;
    border-radius: 8px;
    flex-shrink: 0;
    font-size: 0;
  }
  .fmt-doc-theme-bar .mcp-palette-open svg {
    width: 14px;
    height: 14px;
  }
  .fmt-doc-theme-bar .mcp-mode-lbl {
    display: none;
  }
  /* Aperçu : titre + Édition sur L1, thèmes scrollables sur L2 */
  .fmt-doc-lab.fmt-ed-preview-mode > .fmt-ed-topbar.fmt-ed-preview-topbar {
    row-gap: 6px;
  }
  .fmt-doc-lab.fmt-ed-preview-mode .fmt-ed-preview-topbar .fmt-doc-theme-bar {
    order: 8;
    margin: 0;
  }

  /* Masquer le toggle sidebar détail en aperçu mobile */
  .fmt-ed-preview-mode .fmt-ed-sidebar-toggle {
    display: none !important;
  }

  /* Toolbar section collée sous le chrome */
  .fmt-doc-lab .fmt-sec-toolbar {
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 6px 16px -12px rgba(0, 0, 0, 0.45);
  }

  /* Outils de bloc : visibles seulement à la sélection / focus (pas de clutter) */
  .fmt-doc-lab .fmt-live-block .fmt-live-tools,
  .fmt-doc-lab .fmt-live-block .fmt-sec-grip,
  .fmt-doc-lab .fmt-live-block .fmt-sec-col-pick,
  .fmt-doc-lab .fmt-live-block .fmt-media-size,
  .fmt-doc-lab .fmt-live-block .fmt-live-lvl {
    display: none;
  }
  .fmt-doc-lab .fmt-live-block.is-selected .fmt-live-tools,
  .fmt-doc-lab .fmt-live-block.is-selected .fmt-sec-grip,
  .fmt-doc-lab .fmt-live-block.is-selected .fmt-sec-col-pick,
  .fmt-doc-lab .fmt-live-block.is-selected .fmt-media-size,
  .fmt-doc-lab .fmt-live-block.is-selected .fmt-live-lvl,
  .fmt-doc-lab .fmt-live-block:focus-within .fmt-live-tools,
  .fmt-doc-lab .fmt-live-block:focus-within .fmt-sec-grip,
  .fmt-doc-lab .fmt-live-block:focus-within .fmt-sec-col-pick,
  .fmt-doc-lab .fmt-live-block:focus-within .fmt-media-size,
  .fmt-doc-lab .fmt-live-block:focus-within .fmt-live-lvl {
    display: flex;
  }
  .fmt-doc-lab .fmt-live-block.is-selected .fmt-sec-col-pick,
  .fmt-doc-lab .fmt-live-block.is-selected .fmt-media-size,
  .fmt-doc-lab .fmt-live-block.is-selected .fmt-live-lvl,
  .fmt-doc-lab .fmt-live-block:focus-within .fmt-sec-col-pick,
  .fmt-doc-lab .fmt-live-block:focus-within .fmt-media-size,
  .fmt-doc-lab .fmt-live-block:focus-within .fmt-live-lvl {
    display: inline-flex;
  }
  .fmt-doc-lab .fmt-live-head {
    opacity: 1;
    min-height: 22px;
    margin-bottom: 4px;
  }
  .fmt-doc-lab .fmt-live-block:not(.is-selected):not(:focus-within) .fmt-live-type {
    font-size: 9px;
    opacity: 0.7;
  }

  /* Canvas : place pour FAB / safe-area en focus édition */
  .fmt-doc-lab .fmt-ed-canvas-wrap {
    padding-bottom: max(88px, calc(56px + env(safe-area-inset-bottom, 0px)));
  }

  /* Feuille image : safe-area */
  .fmt-media-pick-panel {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  /* Insert chips : icône + label court, scroll horizontal */
  .fmt-sec-toolbar-add .fmt-sec-tool-btn span {
    max-width: 7.5em;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (min-width: 769px) {
  .fmt-ed-toggle-short,
  .fmt-ed-save-short {
    display: none;
  }
}

@media (max-width: 480px) {
  .fmt-doc-lab > .fmt-ed-topbar,
  .fmt-ed-preview-mode > .fmt-ed-topbar.fmt-ed-preview-topbar {
    padding: 4px 6px;
    gap: 4px;
    min-height: 40px;
  }
  .fmt-doc-theme-bar .mcp-mode-lbl {
    display: none;
  }
  .fmt-doc-theme-bar .mcp-style-bubble,
  .fmt-doc-theme-bar .paldot {
    width: 24px !important;
    height: 24px !important;
  }
  .fmt-doc-theme-bar .mcp-palette-open {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px;
    padding: 0 !important;
  }
  /* Chips insert : icônes seules sur très petit écran */
  .fmt-sec-toolbar-add .fmt-sec-tool-btn span {
    display: none;
  }
  .fmt-sec-toolbar-add .fmt-sec-tool-btn {
    padding: 6px 8px;
    min-width: 36px;
    justify-content: center;
  }
}

/* Sidebar collapsable */
.fmt-doc-lab .fmt-ed-layout.fmt-ed-layout-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}
.fmt-doc-lab .fmt-ed-sidebar-meta.is-collapsed {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.fmt-ed-sidebar-toggle {
  flex-shrink: 0;
  min-width: 36px;
  min-height: 36px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.fmt-ed-sidebar-toggle .fmt-ed-toggle-short {
  display: none;
  line-height: 0;
}
.fmt-ed-sidebar-toggle .fmt-ed-toggle-short svg {
  display: block;
}
.fmt-ed-sidebar-toggle[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}
@media (max-width: 768px) {
  .fmt-doc-lab > .fmt-ed-topbar .fmt-ed-sidebar-toggle .fmt-ed-toggle-full {
    display: none;
  }
  .fmt-doc-lab > .fmt-ed-topbar .fmt-ed-sidebar-toggle .fmt-ed-toggle-short {
    display: inline-flex;
  }
  .fmt-doc-lab > .fmt-ed-topbar .fmt-ed-sidebar-toggle {
    order: 2;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
  }
}

@media (max-width: 900px) {
  .fmt-doc-lab .fmt-ed-layout.fmt-ed-layout-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }
  .fmt-doc-lab .fmt-ed-sidebar-meta.is-collapsed {
    display: none;
  }
  /* Vue détails : panneau plein écran (médias, paramètres, pages) — pas de split 45/55 */
  .fmt-doc-lab .fmt-ed-layout:not(.fmt-ed-layout-collapsed) {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }
  .fmt-doc-lab .fmt-ed-layout:not(.fmt-ed-layout-collapsed) > .fmt-ed-stage {
    display: none;
  }
  .fmt-doc-lab .fmt-ed-layout:not(.fmt-ed-layout-collapsed) > .fmt-ed-sidebar-meta {
    max-height: none;
    border-bottom: 0;
    min-height: 0;
  }
}

/* Theme bar : 4 presets + bouton palette (picker avancé) */
.fmt-doc-theme-bar .mcp-style-bubble,
.fmt-doc-theme-bar .mcp-palette-open {
  display: inline-flex;
  flex-shrink: 0;
}
.fmt-doc-theme-bar .mcp-style-bubble,
.fmt-doc-theme-bar .paldot,
.fmt-doc-theme-bar .mcp-style-bubbles-host .paldot {
  width: 24px;
  height: 24px;
}
.fmt-doc-theme-bar .mcp-palette-open {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #0891b2, #2563eb);
  color: #fff;
  border: 0;
}
.fmt-doc-theme-bar .mcp-mode-btn {
  padding: 3px 8px;
  font-size: 11px;
}

/* Image pick sheet (mobile + desktop compact) */
.fmt-live-media-pickable {
  position: relative;
  cursor: pointer;
}
.fmt-live-media-pick-hint {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--accent, #f97316) 92%, #000);
  color: #fff;
  opacity: 0.92;
  pointer-events: none;
}
.fmt-media-pick-sheet {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.fmt-media-pick-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.fmt-media-pick-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
  max-height: min(78dvh, 560px);
  display: flex;
  flex-direction: column;
  border-radius: 16px 16px 0 0;
  background: var(--surface, #12151c);
  border: 1px solid var(--border);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.fmt-media-pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.fmt-media-pick-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  align-items: center;
}
.fmt-media-pick-search {
  flex: 1;
  min-width: 0;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2, #1a1f26);
  color: var(--text);
  padding: 0 10px;
  font-size: 14px;
}
.fmt-media-pick-grid {
  flex: 1;
  overflow: auto;
  padding: 8px 12px 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.fmt-media-pick-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2, #1a1f26);
  color: var(--text);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
}
.fmt-media-pick-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #0a0d15;
}
.fmt-media-pick-item span {
  font-size: 10px;
  padding: 0 6px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dim, #94a3b8);
}
.fmt-media-pick-empty {
  grid-column: 1 / -1;
  margin: 12px 0;
  text-align: center;
  color: var(--text-dim, #94a3b8);
  font-size: 13px;
}

/* Toolbar section WYSIWYG */
.fmt-sec-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
}
.fmt-sec-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.fmt-sec-toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim, #64748b);
  margin-right: 4px;
}
.fmt-sec-toolbar-add .fmt-sec-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.fmt-sec-toolbar-add .fmt-sec-tool-btn svg {
  width: 14px;
  height: 14px;
}
.fmt-sec-toolbar-add .fmt-sec-tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.fmt-sec-toolbar-add .fmt-sec-tool-btn:hover:not(:disabled) {
  border-color: var(--accent, #f97316);
  color: var(--accent, #f97316);
}
.fmt-sec-toolbar-row-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.fmt-sec-seg {
  display: inline-flex;
  align-items: center;
  gap: 0;
  height: 30px;
  padding: 2px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface, #111) 88%, transparent);
}
.fmt-sec-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  min-width: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim, #94a3b8);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
}
.fmt-sec-chip.is-on {
  background: color-mix(in srgb, var(--accent, #f97316) 22%, transparent);
  color: var(--text, #fff);
}
.fmt-sec-chip-n {
  min-width: 26px;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}

/* Section live */
.fmt-sec {
  margin-bottom: 18px;
  contain: layout style;
}
.fmt-sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 12px;
  min-height: 36px;
  padding: 4px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border, #334155) 55%, transparent);
}
.fmt-sec-select {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 2px 4px 2px 0;
  text-align: left;
  color: inherit;
  min-width: 0;
  flex: 1 1 120px;
}
.fmt-sec-meta {
  font-size: 11px;
  color: var(--text-dim, #64748b);
  text-transform: lowercase;
}
.fmt-sec-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 8px;
  margin-left: auto;
}
.fmt-sec-controls .fmt-live-tools {
  margin-left: 2px;
}
.fmt-sec-grip {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--text-dim);
  cursor: grab;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid transparent;
}
.fmt-sec-grip:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
}
.fmt-sec-col-pick {
  width: auto !important;
  min-width: 42px !important;
  max-width: 52px;
  min-height: 26px !important;
  height: 26px !important;
  padding: 0 1.1rem 0 0.35rem !important;
  font-size: 11px !important;
}
.fmt-live-block.fmt-sec-child .fmt-live-head,
.fmt-live-block.fmt-sec .fmt-sec-head {
  opacity: 1;
}
.fmt-sec-ai-mic.is-recording {
  color: var(--danger, #e11d48);
  border-color: color-mix(in srgb, var(--danger, #e11d48) 45%, var(--border));
  background: color-mix(in srgb, var(--danger, #e11d48) 12%, var(--surface));
  animation: fmt-mic-pulse 1.2s ease-in-out infinite;
}
.fmt-sec-ai-mic.is-transcribing {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  pointer-events: none;
  opacity: 0.75;
}
@keyframes fmt-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger, #e11d48) 35%, transparent); }
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger, #e11d48) 0%, transparent); }
}
.fmt-sec-ai-agent:hover:not(:disabled) {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

/* Agent modal (texte / HTML) — style Notes compact */
.fmt-ai-modal {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.fmt-ai-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: color-mix(in srgb, var(--bg, #0b0f14) 10%, #000 60%);
  backdrop-filter: blur(3px);
  cursor: pointer;
}
.fmt-ai-panel {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 20px));
  max-height: min(88vh, 640px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  background: var(--surface, #12151a);
  box-shadow: 0 16px 48px color-mix(in srgb, #000 32%, transparent);
}
.fmt-ai-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  flex-shrink: 0;
}
.fmt-ai-head-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.fmt-ai-head-ico {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}
.fmt-ai-head-ico svg {
  width: 18px;
  height: 18px;
}
.fmt-ai-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}
.fmt-ai-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}
.fmt-ai-x {
  width: 28px;
  height: 28px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.fmt-ai-x:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}
.fmt-ai-skill-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.fmt-ai-skill-btn svg {
  width: 15px;
  height: 15px;
}
.fmt-ai-skill-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.fmt-ai-panel-skill {
  width: min(560px, calc(100vw - 20px));
  max-height: min(92vh, 760px);
}
.fmt-ai-skill-ta {
  min-height: min(52vh, 420px);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
}
.fmt-ai-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fmt-ai-lbl {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.fmt-ai-agent-select {
  width: 100% !important;
  min-height: 36px !important;
  font-size: 13px !important;
}
.fmt-ai-block .ui-select {
  width: 100%;
}
.fmt-ai-block .ui-select-trigger {
  min-height: 36px;
  width: 100%;
}
.fmt-ai-field {
  display: block;
}
.fmt-ai-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 56px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: var(--bg, #0b0f14);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  resize: vertical;
}
.fmt-ai-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.fmt-ai-empty {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}
.fmt-ai-chat-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  background: color-mix(in srgb, var(--bg) 40%, transparent);
}
.fmt-ai-msg {
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.fmt-ai-msg-user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  max-width: 92%;
}
.fmt-ai-msg-assistant {
  align-self: flex-start;
  background: color-mix(in srgb, var(--surface-2, #1a1f26) 80%, transparent);
  max-width: 92%;
}
.fmt-ai-chat-compose {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fmt-ai-compose-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.fmt-ai-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--surface-2, #1a1f26) 35%, var(--surface));
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .fmt-sec-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 6px 8px;
  }
  .fmt-sec-toolbar-label {
    display: none;
  }
  .fmt-sec-toolbar-styles {
    flex-wrap: nowrap;
  }
  .fmt-sec-toolbar-row-main {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .fmt-sec-toolbar-row-main::-webkit-scrollbar {
    display: none;
  }
  .fmt-sec-toolbar-add-primary,
  .fmt-sec-toolbar-add-secondary {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .fmt-sec-toolbar-add-primary::-webkit-scrollbar,
  .fmt-sec-toolbar-add-secondary::-webkit-scrollbar {
    display: none;
  }
  .fmt-sec-toolbar-add .fmt-sec-tool-btn {
    flex: 0 0 auto;
    padding: 5px 8px;
    font-size: 11px;
    white-space: nowrap;
  }
  .fmt-sec-controls {
    width: 100%;
    justify-content: flex-start;
  }
  .fmt-ai-panel {
    width: min(100%, calc(100vw - 12px));
    max-height: min(92dvh, 720px);
  }
  .fmt-live-row-media-url {
    display: none;
  }
}
.fmt-sec-grid {
  display: grid;
  grid-template-columns: repeat(var(--fmt-sec-cols, 1), minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.fmt-sec-col {
  min-width: 0;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fmt-doc-lab .fmt-sec-col > .fmt-live-block,
.fmt-doc-lab .fmt-sec-drop {
  min-width: 0;
  width: 100%;
}
/* Même logique que .mediabox aperçu : ratio 16:9 stable, pas d’aplatissement */
.fmt-doc-lab .fmt-live-media,
.fmt-doc-lab .fmt-live-media-sm {
  --media-w: 100%;
  display: block;
  position: relative;
  width: var(--media-w);
  max-width: 100%;
  margin-inline: auto;
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: none;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  background: #0a0a0a;
  box-sizing: border-box;
}
.fmt-doc-lab .fmt-live-media img,
.fmt-doc-lab .fmt-live-media video,
.fmt-doc-lab .fmt-live-media-sm img,
.fmt-doc-lab .fmt-live-media-sm video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  display: block;
  background: #0a0a0a;
  border: 0;
}
.fmt-doc-lab .fmt-live-media-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  margin: 0;
  height: auto;
}
.fmt-media-size {
  max-width: 88px;
  font-size: 11px !important;
  padding: 2px 4px !important;
}
.fmt-sec-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
}
.fmt-sec-col-label {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent, #f97316);
  white-space: nowrap;
}
.fmt-sec-insert {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  padding: 2px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface, #111) 88%, transparent);
}
.fmt-sec-ins {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim, #94a3b8);
  cursor: grab;
}
.fmt-sec-ins svg {
  width: 13px;
  height: 13px;
}
.fmt-sec-ins:hover {
  background: color-mix(in srgb, var(--accent, #f97316) 16%, transparent);
  color: var(--accent, #f97316);
}
.fmt-sec-drop {
  flex: 1;
  min-height: 72px;
  border-radius: 12px;
  border: 1px dashed transparent;
  padding: 2px;
  transition: border-color 0.15s, background 0.15s;
}
.fmt-sec-drop.is-drop-target {
  border-color: color-mix(in srgb, var(--accent, #f97316) 55%, transparent);
  background: color-mix(in srgb, var(--accent, #f97316) 8%, transparent);
}
.fmt-sec-col-empty {
  padding: 22px 12px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-dim, #64748b);
  font-size: 12px;
  pointer-events: none;
}
.fmt-sec.is-selected {
  outline: 2px solid color-mix(in srgb, var(--accent, #f97316) 55%, transparent);
  outline-offset: 4px;
  border-radius: 14px;
}
.fmt-sec-child.is-selected {
  outline: 1px solid color-mix(in srgb, var(--accent, #f97316) 70%, transparent);
  outline-offset: 1px;
}
.fmt-sec-child.is-dragging {
  opacity: 0.45;
}
.fmt-sec-child.is-drop-target {
  outline: 2px dashed color-mix(in srgb, var(--accent, #f97316) 60%, transparent);
  outline-offset: 2px;
}
.fmt-sec-grip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  cursor: grab;
  color: var(--text-dim, #94a3b8);
  border-radius: 6px;
}
.fmt-sec-grip:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}
.fmt-sec-grip svg {
  width: 12px;
  height: 12px;
}
.fmt-sec-quiz-answers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.fmt-sec-quiz-ans {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fmt-sec-quiz-ans .fmt-live-input {
  flex: 1;
}
.fmt-toc-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 10px;
}
.fmt-toc-lvl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--mono, ui-monospace, monospace);
  color: var(--muted, #8b93a7);
  cursor: pointer;
  user-select: none;
}
.fmt-toc-lvl input {
  accent-color: var(--acc, #f97316);
}
.fmt-toc-eyebrow {
  margin: 0 0 4px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint, #6b7280);
}
.fmt-toc-empty {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted, #8b93a7);
}
.fmt-sec-col-pick {
  max-width: 48px;
  font-size: 11px !important;
  padding: 2px 4px !important;
}

/* Style section: frame / flat / hero (édition) */
.fmt-doc-lab .fmt-sec[data-style="frame"] {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.fmt-doc-lab .fmt-sec[data-style="flat"] {
  border: 0;
  background: transparent;
  padding: 4px 0;
  box-shadow: none;
}
.fmt-doc-lab .fmt-sec[data-style="flat"].fmt-live-block,
.fmt-doc-lab .fmt-sec[data-style="flat"] .fmt-sec-child.fmt-live-block {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}
.fmt-doc-lab .fmt-sec[data-style="hero"] {
  border: 0;
  border-radius: 18px;
  padding: clamp(22px, 4vw, 40px) clamp(16px, 3vw, 28px);
  background: color-mix(in srgb, var(--accent, #f97316) 12%, transparent);
}
.fmt-doc-lab .fmt-sec[data-style="hero"] .fmt-live-title.h1 {
  font-size: clamp(2rem, 5vw, 3rem);
}

/* Document Lab — media library sidebar */
.fmt-doc-media-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.fmt-doc-media-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-2, color-mix(in srgb, var(--surface) 80%, #000));
  border: var(--border-width) solid var(--border);
}
.fmt-doc-media-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.fmt-doc-media-tab.is-on {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--text);
}
.fmt-doc-media-hint {
  margin: 0;
  font-size: 11px;
}
.fmt-doc-media-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(220px, 28vh);
  overflow: auto;
  min-height: 0;
  padding-right: 2px;
}
.fmt-doc-media-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px;
  align-items: stretch;
  min-width: 0;
}
.fmt-doc-media-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 4px;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: grab;
  font: inherit;
}
.fmt-doc-media-item:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.fmt-doc-media-item.is-dragging {
  opacity: 0.45;
}
.fmt-doc-media-acts {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.14s ease;
}
.fmt-doc-media-row:hover .fmt-doc-media-acts,
.fmt-doc-media-row:focus-within .fmt-doc-media-acts {
  opacity: 1;
}
.fmt-doc-media-act {
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  border: var(--border-width) solid color-mix(in srgb, var(--border) 88%, transparent);
  border-radius: 6px;
  background: var(--surface-2, color-mix(in srgb, var(--surface) 85%, #000));
  color: var(--text-dim);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.fmt-doc-media-act:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.fmt-doc-media-act--danger:hover {
  color: var(--danger, #ef4444);
  border-color: color-mix(in srgb, var(--danger, #ef4444) 45%, var(--border));
  background: color-mix(in srgb, var(--danger, #ef4444) 12%, var(--surface));
}
.fmt-doc-media-act--danger.is-armed {
  color: #fff;
  border-color: var(--danger, #ef4444);
  background: var(--danger, #ef4444);
  opacity: 1;
}
.fmt-doc-media-act:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
@media (hover: none) {
  .fmt-doc-media-acts {
    opacity: 1;
  }
}
.fmt-doc-media-thumb {
  width: 44px;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fmt-doc-media-thumb img,
.fmt-doc-media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.fmt-doc-media-name {
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.fmt-doc-media-empty {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}
.fmt-doc-media-more {
  width: 100%;
  justify-content: center;
  margin-top: 6px;
  height: 28px;
  font-size: 11px;
}

@media (max-width: 720px) {
  .fmt-sec-grid {
    grid-template-columns: 1fr !important;
  }
  .fmt-doc-media-list {
    max-height: min(180px, 32vh);
  }
}

/* ——— Contraste thème clair (boutons / champs lisibles) ——— */
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-live-btn,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-live-tool,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-live-input,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-live-text,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-sec-chip,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-sec-ins,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-ui-select,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .ui-select-trigger,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] select,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] textarea,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] [contenteditable="true"],
.fmt-doc-premium-root[data-theme="light"] .fmt-live-btn,
.fmt-doc-premium-root[data-theme="light"] .fmt-live-tool,
.fmt-doc-premium-root[data-theme="light"] .fmt-live-input,
.fmt-doc-premium-root[data-theme="light"] .fmt-live-text,
.fmt-doc-premium-root[data-theme="light"] .fmt-media-size,
.fmt-doc-premium-root[data-theme="light"] .fmt-sec-col-pick,
.fmt-doc-premium-root[data-theme="light"] .ui-select-trigger,
.fmt-doc-premium-root[data-theme="light"] select,
.fmt-doc-premium-root[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
.fmt-doc-premium-root[data-theme="light"] textarea,
.fmt-doc-premium-root[data-theme="light"] [contenteditable="true"] {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid rgba(15, 23, 42, 0.28) !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  color-scheme: light;
}
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-live-input::placeholder,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-live-text::placeholder,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] input::placeholder,
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] textarea::placeholder,
.fmt-doc-premium-root[data-theme="light"] .fmt-live-input::placeholder,
.fmt-doc-premium-root[data-theme="light"] input::placeholder,
.fmt-doc-premium-root[data-theme="light"] textarea::placeholder {
  color: #64748b !important;
  opacity: 0.9;
}
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .ui-select-menu,
.fmt-doc-premium-root[data-theme="light"] .ui-select-menu {
  background: #fff !important;
  color: #0f172a !important;
  border-color: rgba(15, 23, 42, 0.18) !important;
}
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .ui-select-opt,
.fmt-doc-premium-root[data-theme="light"] .ui-select-opt {
  color: #0f172a !important;
}
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .ui-select-opt:hover,
.fmt-doc-premium-root[data-theme="light"] .ui-select-opt:hover {
  background: #f1f5f9 !important;
}
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] select option,
.fmt-doc-premium-root[data-theme="light"] select option {
  background: #fff;
  color: #0f172a;
}
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-live-btn,
.fmt-doc-premium-root[data-theme="light"] .fmt-live-btn {
  font-weight: 600 !important;
}
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-live-tool svg,
.fmt-doc-premium-root[data-theme="light"] .fmt-live-tool svg {
  stroke: #0f172a;
  color: #0f172a;
}
.fmt-doc-lab .fmt-ed-canvas[data-theme="light"] .fmt-live-tool:hover,
.fmt-doc-premium-root[data-theme="light"] .fmt-live-btn:hover {
  border-color: var(--acc, #f97316) !important;
  color: var(--acc, #c2410c) !important;
}
html[data-theme="light"] .fmt-doc-lab .fmt-doc-panel .fmt-ed-field input,
html[data-theme="light"] .fmt-doc-lab .fmt-doc-panel .fmt-ed-field textarea,
html[data-theme="light"] .fmt-doc-lab .fmt-doc-panel .fmt-ed-field select,
html[data-theme="light"] .fmt-doc-lab .fmt-doc-panel .fmt-ed-block-input,
html[data-theme="light"] .fmt-doc-lab .fmt-doc-panel .ui-select-trigger {
  background: #fff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.22);
  color-scheme: light;
}
html[data-theme="light"] .fmt-doc-lab .fmt-doc-panel .ui-select-menu {
  background: #fff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.16);
}
html[data-theme="light"] .fmt-doc-lab .fmt-doc-panel .ui-select-opt {
  color: #0f172a;
}
html[data-theme="light"] .fmt-doc-lab .fmt-sec-toolbar .fmt-sec-chip,
html[data-theme="light"] .fmt-doc-lab .fmt-sec-toolbar .fmt-sec-tool-btn,
html[data-theme="light"] .fmt-doc-lab .fmt-ed-add-chip {
  background: #fff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.22);
}
html[data-theme="light"] .fmt-doc-lab .fmt-sec-toolbar .fmt-sec-chip.is-on,
html[data-theme="light"] .fmt-doc-lab .fmt-sec-toolbar .fmt-sec-tool-btn:hover {
  background: color-mix(in srgb, var(--accent) 16%, #fff);
  border-color: color-mix(in srgb, var(--accent) 45%, #cbd5e1);
  color: #0f172a;
}
.fmt-doc-lab .fmt-ed-canvas-wrap {
  padding-bottom: 72px;
}
