/* Barre de formatage globale (en haut) */
.toolbar-global-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow: hidden;
  padding: 10px 8px 10px 8px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  background: #f8fafc;
  position: relative;
  z-index: 10;
}
.toolbar-global-bar button,
.toolbar-global-bar select,
.toolbar-global-bar input[type="color"],
.toolbar-global-bar input[type="number"] {
  flex: 0 0 auto;
  height: 32px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}
.toolbar-global-bar select {
  width: auto;
  min-width: 82px;
  max-width: 110px;
  padding-right: 22px;
}
.toolbar-global-bar input[type="number"] {
  width: 96px;
}
.icon-btn {
  width: 32px;
  min-width: 32px !important;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none !important;
}
.toolbar-icon {
  position: relative;
  width: 14px;
  height: 12px;
  display: inline-block;
}
.toolbar-icon::after {
  content: '';
  position: absolute;
  left: 0;
  top: 1px;
  width: 14px;
  height: 10px;
  background-repeat: no-repeat;
  background-size: 14px 2px, 11px 2px, 13px 2px, 9px 2px;
  background-position: 0 0, 0 3px, 0 6px, 0 9px;
  background-image:
    linear-gradient(#334155, #334155),
    linear-gradient(#334155, #334155),
    linear-gradient(#334155, #334155),
    linear-gradient(#334155, #334155);
}
.toolbar-icon.align-left::after {
  background-position: 0 0, 0 3px, 0 6px, 0 9px;
}
.toolbar-icon.align-center::after {
  background-position: 0 0, 1.5px 3px, 0.5px 6px, 2.5px 9px;
}
.toolbar-icon.align-right::after {
  background-position: 0 0, 3px 3px, 1px 6px, 5px 9px;
}
.toolbar-icon.align-justify::after {
  background-size: 14px 2px, 14px 2px, 14px 2px, 14px 2px;
  background-position: 0 0, 0 3px, 0 6px, 0 9px;
}
.toolbar-global-bar input[type="color"] {
  width: 38px;
  padding: 2px;
}
/* Barre de formatage éditeur (gauche) */
.editor-toolbar-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  flex-wrap: nowrap;
  overflow: hidden;
  padding: 6px 8px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  margin-bottom: 8px;
}
.editor-toolbar-bar button,
.editor-toolbar-bar select {
  flex: 0 0 auto;
  height: 30px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
}
.editor-toolbar-bar select {
  width: auto;
  min-width: 82px;
  max-width: 110px;
  padding-right: 22px;
}
:root {
      --bg: #f3f6fb;
      --card: #ffffff;
      --line: #d9e2ec;
      --text: #1f2937;
      --muted: #64748b;
      --primary: #1d4ed8;
      --primary-dark: #163ea9;
      --danger: #dc2626;
      --success: #0f766e;
      --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
      --radius: 16px;
      --a4-width: 794px;
      --a4-height: 1123px;
    }

    * { box-sizing: border-box; }

    html, body {
      margin: 0;
      height: 100%;
      font-family: Arial, sans-serif;
      background: var(--bg);
      color: var(--text);
      overflow: hidden;
    }

    body { min-height: 100dvh; }
    body.is-loading { overflow: hidden; }

    .app {
      height: 100dvh;
      max-width: 1800px;
      margin: 0 auto;
      padding: 16px;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .topbar {
      flex: 0 0 auto;
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      align-items: center;
      justify-content: space-between;
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 14px 18px;
    }

    .title-block h1 { margin: 0; font-size: 24px; }

    .toolbar-main {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
    }

    .file-picker-wrap {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .file-help {
      font-size: 12px;
      color: #64748b;
      font-weight: 600;
    }

    .layout {
      flex: 1 1 auto;
      min-height: 0;
      display: grid;
      grid-template-columns: minmax(520px, 760px) minmax(500px, 1fr);
      gap: 18px;
      overflow: hidden;
    }

    .panel {
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow: hidden;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }

    .panel-header {
      flex: 0 0 auto;
      padding: 14px 18px;
      border-bottom: 1px solid var(--line);
      background: #fbfdff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .panel-header h2 { margin: 0; font-size: 18px; }

    .panel-body {
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
      overflow-x: hidden;
      padding: 18px;
      overscroll-behavior: contain;
    }

    .stack { display: grid; gap: 16px; }

    .grid-2 {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
    }

    .grid-3 {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 12px;
    }

    .section-card {
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fff;
      overflow: hidden;
    }

    .section-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 12px 14px;
      border-bottom: 1px solid var(--line);
      background: #f8fbff;
    }

    .section-head-left {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
      flex: 1;
    }

    .section-content {
      padding: 14px;
      display: grid;
      gap: 14px;
    }

    .item-card {
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      background: #fafcff;
      overflow: hidden;
    }

    .item-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 10px 12px;
      border-bottom: 1px solid #e5e7eb;
      background: #f8fafc;
    }

    .item-head.is-collapsed {
      background: #f3f7fc;
      cursor: grab;
    }

    .item-body {
      padding: 12px;
      display: grid;
      gap: 12px;
    }

    label {
      display: grid;
      gap: 6px;
      font-size: 13px;
      font-weight: 700;
      color: #334155;
    }

    input, select {
      width: 100%;
      border: 1px solid #cbd5e1;
      border-radius: 10px;
      padding: 10px 12px;
      font: inherit;
      color: var(--text);
      background: #fff;
    }

    button {
      border: 0;
      border-radius: 10px;
      padding: 10px 14px;
      font: inherit;
      cursor: pointer;
      font-weight: 700;
      transition: 0.15s ease;
    }

    button:disabled,
    input:disabled,
    select:disabled { opacity: 0.6; cursor: not-allowed; }

    .btn-primary { background: var(--primary); color: #fff; }
    .btn-primary:hover { background: var(--primary-dark); }
    .btn-secondary { background: #e8eefb; color: #183b8a; }
    .btn-danger { background: #fee2e2; color: #991b1b; }
    .btn-ghost { background: #edf2f7; color: #334155; }

    .row-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }

    .status {
      margin-bottom: 12px;
      padding: 12px 14px;
      border-radius: 12px;
      background: #eff6ff;
      color: #1d4ed8;
      white-space: pre-wrap;
      font-size: 14px;
    }

    .hidden { display: none !important; }

    .preview-shell {
      height: 100%;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }

    .preview-topbar {
      flex: 0 0 auto;
      border-bottom: 1px solid var(--line);
      background: #f8fafc;
      position: relative;
      z-index: 5;
    }

    .preview-editor-bar {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 4px;
      flex-wrap: nowrap;
      overflow: hidden;
      padding: 6px 8px;
      border-bottom: 1px solid #e2e8f0;
      white-space: nowrap;
    }

    .preview-editor-bar button,
.preview-editor-bar select,
.preview-editor-bar input[type="color"] {
      flex: 0 0 auto;
      height: 30px;
      min-width: 0;
      padding: 0 8px;
      border: 1px solid #cbd5e1;
      border-radius: 7px;
      background: #fff;
      font-size: 11px;
      font-weight: 700;
      color: #334155;
    }

    .preview-editor-bar select {
      width: auto;
      min-width: 82px;
      max-width: 110px;
      padding-right: 22px;
    }
.preview-editor-bar input[type="color"] {
  width: 34px;
  padding: 2px;
}

    .preview-meta-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 5px 8px;
      font-size: 11px;
      color: var(--muted);
      min-height: 30px;
    }

    .preview-meta-left {
      font-weight: 700;
      color: #334155;
      white-space: nowrap;
    }

    .preview-meta-right {
      white-space: nowrap;
      margin-left: auto;
    }

    .preview-scroll {
      flex: 1 1 auto;
      min-height: 0;
      overflow: auto;
      background: #e9eef5;
      padding: 24px;
      overscroll-behavior: contain;
    }

    .preview-stage {
      width: 100%;
      min-height: 100%;
      display: flex;
      justify-content: center;
      align-items: flex-start;
      position: relative;
    }

    .preview-paper {
      width: var(--a4-width);
      min-height: var(--a4-height);
      background: #fff;
      border-radius: 8px;
      overflow: visible;
      box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
      transform-origin: top center;
      flex: 0 0 auto;
    }

    .preview-frame {
      width: 100%;
      min-height: var(--a4-height);
      border: 0;
      background: #fff;
      display: block;
      overflow: hidden;
    }

    .compact-rich-editor {
      display: block;
      border: 1px solid #cbd5e1;
      border-radius: 10px;
      background: #fff;
      overflow: hidden;
    }

    .compact-toolbar {
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 6px 8px;
      background: #f8fafc;
      border-bottom: 1px solid #e2e8f0;
      white-space: nowrap;
      overflow-x: auto;
    }

    .compact-toolbar button,
.compact-toolbar select,
.compact-toolbar input[type="color"] {
      flex: 0 0 auto;
      height: 24px;
      padding: 0 6px;
      border: 1px solid #cbd5e1;
      border-radius: 4px;
      background: #fff;
      font-size: 10px;
      font-weight: 600;
      color: #334155;
      min-width: 0;
    }

    .compact-toolbar select {
      min-width: 50px;
      max-width: 70px;
      padding-right: 16px;
    }
.compact-toolbar .icon-btn {
  width: 24px;
  min-width: 24px !important;
}
.compact-toolbar .toolbar-icon {
  width: 12px;
  height: 10px;
}
.compact-toolbar .toolbar-icon::after {
  width: 12px;
  height: 9px;
  background-size: 12px 1.5px, 9px 1.5px, 11px 1.5px, 7px 1.5px;
  background-position: 0 0, 0 2.5px, 0 5px, 0 7.5px;
}
.compact-toolbar .toolbar-icon.align-center::after {
  background-position: 0 0, 1.5px 2.5px, 0.5px 5px, 2.5px 7.5px;
}
.compact-toolbar .toolbar-icon.align-right::after {
  background-position: 0 0, 3px 2.5px, 1px 5px, 5px 7.5px;
}
.compact-toolbar .toolbar-icon.align-justify::after {
  background-size: 12px 1.5px, 12px 1.5px, 12px 1.5px, 12px 1.5px;
}
.compact-toolbar input[type="color"] {
  width: 26px;
  padding: 1px;
}

    .compact-text-area {
      min-height: 60px;
      padding: 8px;
      background: #fff;
      border: none;
      outline: none;
      font-size: 12px;
      line-height: 1.4;
      resize: vertical;
    }

    .compact-text-area:focus { background: #fafafa; }

    .drop-zone-top {
      height: 10px;
      border-radius: 8px;
      background: transparent;
      transition: 0.15s ease;
    }

    .drop-zone-top.active {
      background: #bfdbfe;
      height: 14px;
    }

    .drag-handle {
      cursor: grab;
      user-select: none;
      font-size: 18px;
      color: #64748b;
      padding: 6px 8px;
      border-radius: 8px;
      background: #eef2f7;
      flex: 0 0 auto;
    }

    .drag-handle:active { cursor: grabbing; }

    .collapse-btn {
      border: 1px solid #cbd5e1;
      background: #fff;
      color: #334155;
      border-radius: 8px;
      width: 34px;
      height: 34px;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      font-weight: 700;
      cursor: pointer;
      flex: 0 0 auto;
    }

    .collapse-btn:hover { background: #f1f5f9; }

    .section-content.is-collapsed,
    .item-body.is-collapsed {
      display: none !important;
    }

    .compact-title {
      font-weight: 700;
      color: #1f2937;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      min-width: 0;
      flex: 1;
    }

    .compact-title.muted {
      color: #64748b;
      font-weight: 600;
    }

    .language-chips-field {
      display: grid;
      gap: 8px;
    }

    .language-chips-list {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .language-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 8px 10px;
      border-radius: 999px;
      background: #e8eefb;
      color: #183b8a;
      font-size: 12px;
      font-weight: 700;
      line-height: 1;
    }

    .language-chip-remove {
      border: 0;
      background: transparent;
      color: #183b8a;
      padding: 0;
      width: 18px;
      height: 18px;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
    }

    .language-chip-remove:hover {
      background: rgba(24, 59, 138, 0.12);
    }

    .language-chip-add {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 8px;
      align-items: center;
    }

    .language-chip-add .btn-secondary {
      padding: 10px 12px;
      min-width: 44px;
    }

    .loading-overlay {
      position: fixed;
      inset: 0;
      z-index: 9999;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(15, 23, 42, 0.46);
      backdrop-filter: blur(5px);
      -webkit-backdrop-filter: blur(5px);
    }

    .loading-card {
      min-width: 320px;
      max-width: 90vw;
      background: #ffffff;
      border-radius: 24px;
      padding: 30px 34px;
      box-shadow: 0 30px 70px rgba(15, 23, 42, 0.25);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 20px;
      text-align: center;
    }

    .spinner-ring {
      width: 82px;
      height: 82px;
      border-radius: 50%;
      border: 8px solid #dbeafe;
      border-top-color: #1d4ed8;
      animation: spinLoading 0.9s linear infinite;
    }

    .loading-text {
      font-size: 22px;
      font-weight: 800;
      color: #1f2937;
      line-height: 1.2;
      min-height: 32px;
    }

    .loading-dots {
      display: inline-flex;
      width: 30px;
      justify-content: flex-start;
    }

    .loading-dots span {
      opacity: 0;
      animation: blinkDot 1.4s infinite;
    }

    .loading-dots span:nth-child(1) { animation-delay: 0s; }
    .loading-dots span:nth-child(2) { animation-delay: 0.2s; }
    .loading-dots span:nth-child(3) { animation-delay: 0.4s; }

    .loading-subtext {
      font-size: 14px;
      color: #64748b;
      font-weight: 600;
    }

    .preview-languages-sub-block {
      margin-top: 6px;
      padding-left: 10px;
    }

 


#globalAlignCenterBtn {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='[http://www.w3.org/2000/svg'](http://www.w3.org/2000/svg') viewBox='0 0 24 24' fill='%23a8a8a8'%3E%3Cpath d='M12 5c2.761 0 5 2.239 5 5 0 2.761-2.239 5-5 5a5 5 0 0 1-5-5 5 5 0 0 1 5-5zm0 6c2.761 0 5 2.239 5 5 0 2.761-2.239 5-5 5-2.761 0-5-2.239-5-5 0-2.761 2.239-5 5-5zm0 6c2.761 0 5 2.239 5 5 0 2.761-2.239 5-5 5-2.761 0-5-2.239-5-5 0-2.761 2.239-5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

#gglobalAlignRightBtn {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23a8a8a8'%3E%3Cpath d='M21 6h-12v2h12V6zm-7 5H6v2h12v-2zM6 13v2h12V13H6zm7-5h12v2H9v-2zm0 5h12v2H9v-2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}


    @keyframes spinLoading { to { transform: rotate(360deg); } }

    @keyframes blinkDot {
      0%, 20% { opacity: 0; }
      40%, 100% { opacity: 1; }
    }

    @media (max-width: 1200px) {
      html, body { overflow: auto; }
      .app { height: auto; min-height: 100vh; }
      .layout { grid-template-columns: 1fr; overflow: visible; }
      .panel { min-height: 700px; }
    }

    @media (max-width: 720px) {
      .grid-2, .grid-3 { grid-template-columns: 1fr; }
      .toolbar-main { width: 100%; }
      .toolbar-main > * { width: 100%; }
      .preview-scroll { padding: 12px; }
      .loading-card {
        min-width: 0;
        width: calc(100vw - 32px);
        padding: 24px 22px;
      }
      .loading-text { font-size: 19px; }
    }