/* ═══════════════════════════════════════════════════════════════
   Fenêtre modale
   ═══════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 200;
  display: none;
}
.modal-overlay.open { display: block; }

.modal {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--bdr);
  border-radius: 12px;
  padding: 20px 24px;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
}

.modal h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--tx);
  margin-bottom: 14px;
}

.modal input[type=text] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg0);
  border: 1px solid var(--bdr);
  border-radius: 6px;
  color: var(--tx);
  outline: none;
  font-family: inherit;
}
.modal input[type=text]:focus { border-color: var(--acc); }

/* Ligne de saisie (texte + bouton couleur) */
.modal-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Actions */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-btn {
  padding: 8px 18px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  border: 1px solid var(--bdr);
  background: var(--bg3);
  color: var(--tx);
  transition: all .15s;
}
.modal-btn:hover { background: var(--bg4); }
.modal-btn.primary { background: var(--acc); color: #fff; border-color: var(--acc); }
.modal-btn.primary:hover { opacity: .85; }

/* Noms prédéfinis */
.modal-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* Sélecteur de type (Section / Boucle) */
.modal-section-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.modal-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--tx);
  cursor: pointer;
  user-select: none;
}
.modal-section-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--acc);
  cursor: pointer;
}

/* Bouton pastille de couleur dans la ligne de saisie */
.modal-color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--bdr);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  box-shadow: 0 0 4px rgba(255, 255, 255, .1);
  transition: border-color .15s, box-shadow .15s;
}
.modal-color-dot:hover {
  border-color: var(--acc);
  box-shadow: 0 0 8px rgba(255, 255, 255, .2);
}

/* Modale de confirmation */
.modal-confirm p {
  font-size: 14px;
  color: var(--tx2);
  line-height: 1.5;
  margin-bottom: 4px;
}

/* Popup flottante du sélecteur de couleur */
.cpk-popup {
  position: fixed;
  background: var(--bg2);
  border: 1px solid var(--bdr);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, .55);
  z-index: 800;
  display: none;
}
.cpk-popup.open { display: block; }

.modal-preset {
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 500;
  border: 1px solid var(--bdr);
  background: var(--bg3);
  color: var(--tx);
  transition: all .15s;
}
.modal-preset:hover {
  background: var(--acc);
  color: #fff;
  border-color: var(--acc);
}

.modal-preset-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   Sélecteur de fichier média (dossier)
   ═══════════════════════════════════════════════════════════════ */

.mp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mp-fade-in .15s ease;
}

@keyframes mp-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.mp-box {
  background: var(--bg1);
  border: 1px solid var(--bdr);
  border-radius: 14px;
  min-width: 380px;
  max-width: 520px;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .05) inset;
  animation: mp-slide-in .2s ease;
  overflow: hidden;
}

@keyframes mp-slide-in {
  from { transform: translateY(16px) scale(.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ─── En-tête ─── */
.mp-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--bdr);
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg1) 100%);
}

.mp-header-icon {
  font-size: 28px;
  flex-shrink: 0;
  filter: var(--icon-filter);
}
.mp-header-icon svg { filter: none; }

.mp-header-text { flex: 1; }

.mp-title {
  font-size: 15px;
  color: var(--tx);
  margin: 0;
  font-weight: 700;
}

.mp-subtitle {
  font-size: 12px;
  color: var(--tx3);
  margin: 3px 0 0;
}

.mp-help {
  font-size: 11px;
  color: var(--tx3);
  margin: 6px 0 0;
  font-style: italic;
}

/* ─── Liste de fichiers ─── */
.mp-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
}

.mp-item {
  background: var(--bg2);
  border: 1px solid transparent;
  color: var(--tx);
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all .12s ease;
}
.mp-item:hover {
  background: var(--acc2);
  border-color: var(--acc);
}
.mp-item:active {
  transform: scale(.98);
}

.mp-item-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.mp-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.mp-item-ext {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--tx3);
  background: var(--bg3);
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ─── Pied de page ─── */
.mp-footer {
  display: flex;
  justify-content: flex-end;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--bdr);
}

.mp-cancel {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--tx2);
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .12s ease;
}
.mp-cancel:hover { background: var(--bg4); color: var(--tx); border-color: var(--tx3); }

/* ─── Ligne dossier ─── */
.mp-dir-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.mp-dir-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.mp-dir-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--tx);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mp-dir-change {
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--tx2);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s ease;
}
.mp-dir-change:hover {
  background: var(--bg4);
  color: var(--tx);
  border-color: var(--tx3);
}

/* ─── État vide ─── */
.mp-empty {
  color: var(--tx3);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   Fenêtre À propos
   ═══════════════════════════════════════════════════════════════ */

.about-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 700;
  opacity: 0;
  transition: opacity .2s;
}
.about-overlay.visible { opacity: 1; }

.about-dialog {
  background: var(--bg2);
  border: 1px solid var(--bdr);
  border-radius: 12px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  max-width: 360px;
}

.about-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
}

.about-dialog h2 {
  color: var(--tx);
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
}

.about-dialog p {
  color: var(--tx2);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 24px;
}

.about-close {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--tx);
  font-size: 13px;
  padding: 6px 24px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
}
.about-close:hover { background: var(--bg4); }

/* ═══════════════════════════════════════════════════════════════
   Fenêtre Préférences
   ═══════════════════════════════════════════════════════════════ */

.pref-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 700;
  opacity: 0;
  transition: opacity .2s;
}
.pref-overlay.visible { opacity: 1; }

.pref-dialog {
  background: var(--bg2);
  border: 1px solid var(--bdr);
  border-radius: 12px;
  padding: 24px 32px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  min-width: 280px;
}

.pref-dialog h2 {
  color: var(--tx);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
}

.pref-subtitle {
  color: var(--tx2);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 0 0 10px;
}

.pref-colors {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.pref-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .12s;
}
.pref-color-row:hover {
  background: var(--bg3);
}

.pref-color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--bdr);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .12s;
}
.pref-color-dot:hover {
  border-color: var(--tx2);
}

.pref-color-label {
  color: var(--tx);
  font-size: 14px;
}

.pref-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pref-btn {
  background: var(--bg3);
  border: 1px solid var(--bdr);
  color: var(--tx);
  font-size: 13px;
  padding: 6px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
}
.pref-btn:hover { background: var(--bg4); }
