/* ============================================================================
   Yggdralore - Base CSS (variables, reset léger, typo, composants génériques)
   Mobile-first. Toutes les classes sont préfixées ygg-.
   ============================================================================ */

:root {
  /* Palette */
  --ygg-bg:           #FAFAF7;
  --ygg-surface:      #FFFFFF;
  --ygg-text:         #1F2937;
  --ygg-text-muted:   #6B7280;
  --ygg-border:       #E5E7EB;
  --ygg-border-soft:  #F3F4F6;
  --ygg-primary:      #1E3A5F;
  --ygg-primary-hover:#2C5282;

  /* Accents par type d'item */
  --ygg-evenement:   #D97706;
  --ygg-univers:     #7C3AED;
  --ygg-stand:       #059669;
  --ygg-personnage:  #BE123C;
  --ygg-monument:    #475569;

  /* Statuts */
  --ygg-statut-idee:     #9CA3AF;
  --ygg-statut-encours:  #2563EB;
  --ygg-statut-valide:   #059669;
  --ygg-statut-archive:  #111827;

  /* Feedback */
  --ygg-success:     #059669;
  --ygg-warning:     #D97706;
  --ygg-error:       #BE123C;
  --ygg-info:        #2563EB;

  /* Dimensions */
  --ygg-radius:        8px;
  --ygg-radius-sm:     6px;
  --ygg-radius-lg:     12px;
  --ygg-shadow:        0 1px 3px rgba(0,0,0,0.08);
  --ygg-shadow-lg:     0 4px 16px rgba(0,0,0,0.10);

  --ygg-sidebar-w:     240px;
  --ygg-bottom-nav-h:  60px;
  --ygg-header-h:      56px;

  /* Typo */
  --ygg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --ygg-fs-xs:   0.75rem;
  --ygg-fs-sm:   0.85rem;
  --ygg-fs-base: 1rem;
  --ygg-fs-lg:   1.15rem;
  --ygg-fs-xl:   1.4rem;
  --ygg-fs-xxl:  1.8rem;
}

/* Mode sombre auto, override manuel via [data-theme="dark"] */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ygg-bg:           #0F172A;
    --ygg-surface:      #1E293B;
    --ygg-text:         #F1F5F9;
    --ygg-text-muted:   #94A3B8;
    --ygg-border:       #334155;
    --ygg-border-soft:  #1E293B;
  }
}
[data-theme="dark"] {
  --ygg-bg:           #0F172A;
  --ygg-surface:      #1E293B;
  --ygg-text:         #F1F5F9;
  --ygg-text-muted:   #94A3B8;
  --ygg-border:       #334155;
  --ygg-border-soft:  #1E293B;
}

/* ============================================================================
   Thème PRODUCTION : palette vert bouteille (chic, plus traditionnel).
   Surcharge appliquée quand <html data-env="production">.
   ============================================================================ */
[data-env="production"] {
  --ygg-primary:       #0F4C3A;   /* vert bouteille profond */
  --ygg-primary-hover: #1B5C45;   /* vert bouteille un peu plus clair au survol */
}
/* Mode clair production : ambiance papier teintée légèrement vert */
[data-env="production"]:not([data-theme="dark"]) {
  --ygg-bg:           #F5F8F4;    /* blanc cassé très légèrement vert */
  --ygg-surface:      #FFFFFF;
  --ygg-text:         #0F2E25;
  --ygg-text-muted:   #4A6357;
  --ygg-border:       #CFDCD3;
  --ygg-border-soft:  #E6EEE9;
}
/* Mode sombre production : vert bouteille profond, riche, mat */
@media (prefers-color-scheme: dark) {
  [data-env="production"]:not([data-theme="light"]) {
    --ygg-bg:          #0A2A21;   /* vert bouteille très sombre, presque noir */
    --ygg-surface:     #0F3D2E;   /* vert bouteille foncé pour les cartes */
    --ygg-text:        #E5EFE7;
    --ygg-text-muted:  #7DA993;
    --ygg-border:      #1B5C45;
    --ygg-border-soft: #103729;
    --ygg-primary:       #1F7050;   /* boutons plus lumineux pour ressortir */
    --ygg-primary-hover: #268362;
  }
}
/* Mode sombre production : override manuel */
[data-env="production"][data-theme="dark"] {
  --ygg-bg:          #0A2A21;
  --ygg-surface:     #0F3D2E;
  --ygg-text:        #E5EFE7;
  --ygg-text-muted:  #7DA993;
  --ygg-border:      #1B5C45;
  --ygg-border-soft: #103729;
  --ygg-primary:       #1F7050;
  --ygg-primary-hover: #268362;
}

/* Badge "PROD" dans le header : on le passe aussi en vert bouteille pour cohérence */
[data-env="production"] .ygg-env-badge.ygg-env-production {
  background: #0F4C3A;
}

/* ===== Badge d'environnement dans le header ===== */
.ygg-env-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.ygg-env-badge.ygg-env-local {
  background: #FBBF24;     /* jaune ambre pour bien attirer l'oeil en local */
  color: #78350F;
}
.ygg-env-badge.ygg-env-production {
  background: #15803D;
  color: white;
}

/* ----- Reset léger ----- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--ygg-font);
  font-size: var(--ygg-fs-base);
  line-height: 1.5;
  color: var(--ygg-text);
  background: var(--ygg-bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 0.5em; color: var(--ygg-text); font-weight: 700; line-height: 1.2; }
h1 { font-size: var(--ygg-fs-xxl); }
h2 { font-size: var(--ygg-fs-xl); }
h3 { font-size: var(--ygg-fs-lg); }
p  { margin: 0 0 1rem; }
a  { color: var(--ygg-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; height: auto; }

/* Focus visible accessible */
:focus-visible {
  outline: 2px solid var(--ygg-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ----- Utilitaires ----- */
.ygg-muted { color: var(--ygg-text-muted); }
.ygg-center { text-align: center; }
.ygg-hidden { display: none !important; }
.ygg-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
@media (min-width: 768px) {
  .ygg-mobile-only { display: none !important; }
}
@media (max-width: 767.98px) {
  .ygg-desktop-only { display: none !important; }
}

/* ----- Formulaires ----- */
label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 500;
  font-size: var(--ygg-fs-sm);
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="url"], input[type="date"],
select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--ygg-border);
  border-radius: var(--ygg-radius-sm);
  font-size: var(--ygg-fs-base);
  font-family: inherit;
  background: var(--ygg-surface);
  color: var(--ygg-text);
  margin-bottom: 1rem;
}
textarea { resize: vertical; min-height: 100px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--ygg-primary);
  outline-offset: 1px;
  border-color: var(--ygg-primary);
}

/* ----- Boutons ----- */
.ygg-btn,
.ygg-btn-primary,
.ygg-btn-secondary,
.ygg-btn-danger {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: 1px solid transparent;
  border-radius: var(--ygg-radius-sm);
  font-size: var(--ygg-fs-base);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background-color .15s ease, border-color .15s ease;
  font-family: inherit;
}
.ygg-btn-primary { background: var(--ygg-primary); color: white; }
.ygg-btn-primary:hover { background: var(--ygg-primary-hover); }
.ygg-btn-secondary {
  background: transparent; color: var(--ygg-primary); border-color: var(--ygg-primary);
}
.ygg-btn-secondary:hover { background: var(--ygg-primary); color: white; }
.ygg-btn-danger { background: var(--ygg-error); color: white; }
.ygg-btn-block { display: block; width: 100%; }

/* Mode sombre : les boutons secondaires en bleu nuit se confondent avec le fond.
   On éclaircit le texte et la bordure pour qu'ils restent lisibles. */
[data-theme="dark"] .ygg-btn-secondary {
  color: #93C5FD;
  border-color: #475569;
  background: rgba(255,255,255,0.03);
}
[data-theme="dark"] .ygg-btn-secondary:hover {
  background: #93C5FD;
  color: #0F172A;
  border-color: #93C5FD;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ygg-btn-secondary {
    color: #93C5FD;
    border-color: #475569;
    background: rgba(255,255,255,0.03);
  }
  :root:not([data-theme="light"]) .ygg-btn-secondary:hover {
    background: #93C5FD;
    color: #0F172A;
    border-color: #93C5FD;
  }
}

/* ----- Alertes ----- */
.ygg-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--ygg-radius-sm);
  margin-bottom: 1rem;
  border-left: 4px solid;
  font-size: var(--ygg-fs-sm);
}
.ygg-alert-error    { background: #FEE2E2; color: #7F1D1D; border-color: var(--ygg-error); }
.ygg-alert-success  { background: #D1FAE5; color: #064E3B; border-color: var(--ygg-success); }
.ygg-alert-warning  { background: #FEF3C7; color: #78350F; border-color: var(--ygg-warning); }
.ygg-alert-info     { background: #DBEAFE; color: #1E3A8A; border-color: var(--ygg-info); }

/* ----- Cartes ----- */
.ygg-card {
  background: var(--ygg-surface);
  border-radius: var(--ygg-radius);
  border: 1px solid var(--ygg-border);
  padding: 1.25rem;
  box-shadow: var(--ygg-shadow);
}

/* ----- Badges / pastilles statut ----- */
.ygg-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: var(--ygg-fs-xs);
  font-weight: 600;
  color: white;
}
.ygg-badge-idee     { background: var(--ygg-statut-idee); }
.ygg-badge-en_cours { background: var(--ygg-statut-encours); }
.ygg-badge-valide   { background: var(--ygg-statut-valide); }
.ygg-badge-archive  { background: var(--ygg-statut-archive); }
.ygg-badge-ia,
.ygg-badge-import   { background: linear-gradient(135deg, #8B5CF6, #6366F1); color: white; }

/* Pastille de couleur unie pour le statut "import" (anciennement "ia") */
:root {
  --ygg-statut-ia: #8B5CF6;
  --ygg-statut-import: #8B5CF6;
}

/* ===== Gros bouton "Saisir avec l'IA" (dashboard) ===== */
.ygg-saisir-ia-cta {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 50%, #3B82F6 100%);
  color: white;
  border-radius: 12px;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  margin-bottom: 1.5rem;
}
.ygg-saisir-ia-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
  text-decoration: none;
  color: white;
}
.ygg-saisir-ia-cta .ygg-cta-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ygg-saisir-ia-cta .ygg-cta-text strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}
.ygg-saisir-ia-cta .ygg-cta-text small {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* Badge type d'item */
.ygg-type-evenement  { background: var(--ygg-evenement); color: white; }
.ygg-type-univers    { background: var(--ygg-univers); color: white; }
.ygg-type-stand      { background: var(--ygg-stand); color: white; }
.ygg-type-personnage { background: var(--ygg-personnage); color: white; }
.ygg-type-monument   { background: var(--ygg-monument); color: white; }

/* ============================================================================
   Quill : contention de largeur + adaptation mode sombre
   ============================================================================ */
.ygg-card { overflow: hidden; }              /* aucune carte ne déborde */
.ygg-card > * { max-width: 100%; }

.ygg-quill,
.ygg-quill-chap {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 120px;
}

/* Container et toolbar Quill : forcer 100% et box-sizing */
.ql-toolbar.ql-snow,
.ql-container.ql-snow {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  border-color: var(--ygg-border) !important;
  font-family: inherit !important;
}
.ql-toolbar.ql-snow {
  border-radius: var(--ygg-radius-sm) var(--ygg-radius-sm) 0 0;
  background: var(--ygg-border-soft);
}
.ql-container.ql-snow {
  border-radius: 0 0 var(--ygg-radius-sm) var(--ygg-radius-sm);
  min-height: 120px;
  background: var(--ygg-surface);
  color: var(--ygg-text);
}
.ql-editor {
  min-height: 100px;
  max-height: 50vh;
  overflow-y: auto;
  color: var(--ygg-text);
  background: var(--ygg-surface);
}
.ql-editor.ql-blank::before {
  color: var(--ygg-text-muted) !important;
  font-style: normal;
}

/* Mode sombre : toolbar et icônes Quill mieux contrastés
   Ce bloc s'applique soit via [data-theme="dark"] explicite,
   soit via la préférence système quand l'utilisateur n'a pas overridé. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ql-toolbar.ql-snow {
    background: #111827;
    border: 1px solid #334155 !important;
    border-bottom: none !important;
  }
  :root:not([data-theme="light"]) .ql-container.ql-snow {
    border: 1px solid #334155 !important;
    background: #0F172A;
    border-radius: 0 0 var(--ygg-radius-sm) var(--ygg-radius-sm);
  }
  :root:not([data-theme="light"]) .ql-editor {
    color: #F1F5F9;
    background: #0F172A;
    border-radius: 0 0 var(--ygg-radius-sm) var(--ygg-radius-sm);
  }
  :root:not([data-theme="light"]) .ql-snow .ql-stroke { stroke: #CBD5E1 !important; }
  :root:not([data-theme="light"]) .ql-snow .ql-fill   { fill:   #CBD5E1 !important; }
  :root:not([data-theme="light"]) .ql-snow .ql-picker-label { color: #CBD5E1 !important; }
  :root:not([data-theme="light"]) .ql-snow .ql-picker-label .ql-stroke { stroke: #CBD5E1 !important; }
  :root:not([data-theme="light"]) .ql-snow .ql-picker-options { background: #1E293B; color: #F1F5F9; }
  :root:not([data-theme="light"]) .ql-snow .ql-active .ql-stroke,
  :root:not([data-theme="light"]) .ql-snow button:hover .ql-stroke { stroke: #FFFFFF !important; }
  :root:not([data-theme="light"]) .ql-snow .ql-active .ql-fill,
  :root:not([data-theme="light"]) .ql-snow button:hover .ql-fill   { fill:   #FFFFFF !important; }
  :root:not([data-theme="light"]) .ql-snow button:hover { background: rgba(255,255,255,0.05); border-radius: 4px; }
}
/* Override manuel "dark" : on choisit un fond éditeur PLUS sombre que la carte
   pour que le bloc ressorte visuellement et "se termine" clairement. */
[data-theme="dark"] .ql-toolbar.ql-snow {
  background: #111827;
  border: 1px solid #334155 !important;
  border-bottom: none !important;
}
[data-theme="dark"] .ql-container.ql-snow {
  border: 1px solid #334155 !important;
  background: #0F172A;
  border-radius: 0 0 var(--ygg-radius-sm) var(--ygg-radius-sm);
}
[data-theme="dark"] .ql-editor {
  color: #F1F5F9;
  background: #0F172A;
  border-radius: 0 0 var(--ygg-radius-sm) var(--ygg-radius-sm);
}
[data-theme="dark"] .ql-snow .ql-stroke { stroke: #CBD5E1 !important; }
[data-theme="dark"] .ql-snow .ql-fill   { fill:   #CBD5E1 !important; }
[data-theme="dark"] .ql-snow .ql-picker-label { color: #CBD5E1 !important; }
[data-theme="dark"] .ql-snow .ql-picker-label .ql-stroke { stroke: #CBD5E1 !important; }
[data-theme="dark"] .ql-snow .ql-picker-options { background: #1E293B; color: #F1F5F9; }
[data-theme="dark"] .ql-snow .ql-active .ql-stroke,
[data-theme="dark"] .ql-snow button:hover .ql-stroke { stroke: #FFFFFF !important; }
[data-theme="dark"] .ql-snow .ql-active .ql-fill,
[data-theme="dark"] .ql-snow button:hover .ql-fill   { fill:   #FFFFFF !important; }
[data-theme="dark"] .ql-snow button:hover { background: rgba(255,255,255,0.05); border-radius: 4px; }
[data-theme="dark"] .ql-tooltip { background: #1E293B !important; border-color: #334155 !important; color: #F1F5F9 !important; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
[data-theme="dark"] .ql-tooltip input { background: #0F172A !important; color: #F1F5F9 !important; border-color: #334155 !important; }

/* ===== Mention = lien wiki-style (simple et safe) =====
   On neutralise le fond/padding par défaut de quill-mention.css (qui est chargé
   APRÈS base.css), mais on NE TOUCHE PAS à la structure interne (pas de
   display:none, pas de color:inherit sur les enfants, ce qui cassait le rendu
   du texte dans certaines versions). */
.ql-editor .mention,
.ygg-rich .mention {
  background-color: transparent !important;
  padding: 0 !important;
  margin-right: 1px !important;
  border-radius: 0 !important;
  color: #2563EB !important;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.ql-editor .mention:hover,
.ygg-rich .mention:hover { text-decoration: underline; }

/* Le @ : conservé mais discret (petite taille, opacité réduite) */
.ql-editor .mention .ql-mention-denotation-char,
.ygg-rich .mention .ql-mention-denotation-char {
  opacity: 0.55;
  font-size: 0.85em;
  margin-right: 1px;
}

/* En mode dark : bleu plus clair pour la lisibilité */
[data-theme="dark"] .ql-editor .mention,
[data-theme="dark"] .ygg-rich .mention { color: #93C5FD !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ql-editor .mention,
  :root:not([data-theme="light"]) .ygg-rich .mention { color: #93C5FD !important; }
}

/* Mode aperçu : helper PHP émet des <a class="mention"> qui hérite des mêmes styles. */
.ygg-rich a.mention { display: inline; }

/* ===== Image principale ===== */
.ygg-image-principale { position: relative; }
.ygg-image-principale img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--ygg-radius-sm);
  display: block;
  background: var(--ygg-border-soft);
}
.ygg-img-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.4rem;
}

/* ===== Drop zone (image principale + galerie) ===== */
.ygg-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed var(--ygg-border);
  border-radius: var(--ygg-radius-sm);
  padding: 2rem 1rem;
  cursor: pointer;
  color: var(--ygg-text-muted);
  background: var(--ygg-bg);
  transition: border-color .15s, background .15s;
}
.ygg-dropzone:hover { border-color: var(--ygg-primary); color: var(--ygg-primary); }
.ygg-dropzone.dragging {
  border-color: var(--ygg-primary);
  background: rgba(30,58,95,0.05);
}
.ygg-dropzone-small {
  padding: 0.5rem;
  font-size: 0.85rem;
  aspect-ratio: 1;
  min-width: 110px;
}

/* ===== Bouton IA dans la toolbar Quill ===== */
.ql-toolbar.ql-snow button.ql-ygg-ai {
  width: auto !important;
  padding: 0 8px !important;
  color: var(--ygg-primary);
}
[data-theme="dark"] .ql-toolbar.ql-snow button.ql-ygg-ai { color: #CBD5E1; }
.ql-toolbar.ql-snow button.ql-ygg-ai:hover { color: #DC2626; }
.ql-toolbar.ql-snow button.ql-ygg-ai svg { vertical-align: middle; }

/* ===== Modale popup "Améliorer avec l'IA" (Quill) ===== */
#yggQuillAiModal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#yggQuillAiModal .ygg-qai-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}
#yggQuillAiModal .ygg-qai-box {
  position: relative;
  background: var(--ygg-surface);
  border-radius: 12px;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
#yggQuillAiModal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
#yggQuillAiModal header h3 { margin: 0; font-size: 1.1rem; }
#yggQuillAiModal .ygg-qai-close {
  background: transparent;
  border: 0;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--ygg-text-muted);
  line-height: 1;
}
#yggQuillAiModal .ygg-qai-hint {
  color: var(--ygg-text-muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}
#yggQuillAiModal .ygg-qai-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
#yggQuillAiModal .ygg-qai-action {
  padding: 0.5rem 0.75rem;
  background: var(--ygg-bg);
  border: 1px solid var(--ygg-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ygg-text);
  text-align: left;
  font-family: inherit;
}
#yggQuillAiModal .ygg-qai-action:hover { border-color: var(--ygg-primary); }
#yggQuillAiModal .ygg-qai-action.active {
  background: var(--ygg-primary);
  color: white;
  border-color: var(--ygg-primary);
}
#yggQuillAiModal .ygg-qai-custom {
  width: 100%;
  margin: 0 0 0.75rem;
  padding: 0.6rem;
  border: 1px solid var(--ygg-border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--ygg-bg);
  color: var(--ygg-text);
  resize: vertical;
}
#yggQuillAiModal .ygg-qai-bar,
#yggQuillAiModal .ygg-qai-result-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
#yggQuillAiModal .ygg-qai-result {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}
@media (max-width: 640px) {
  #yggQuillAiModal .ygg-qai-result { grid-template-columns: 1fr; }
}
#yggQuillAiModal .ygg-qai-source,
#yggQuillAiModal .ygg-qai-target {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
#yggQuillAiModal .ygg-qai-source strong,
#yggQuillAiModal .ygg-qai-target strong {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--ygg-text-muted);
  letter-spacing: 0.05em;
}
#yggQuillAiModal .ygg-qai-before,
#yggQuillAiModal .ygg-qai-after {
  background: var(--ygg-bg);
  border: 1px solid var(--ygg-border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 280px;
  overflow-y: auto;
  min-height: 100px;
}
#yggQuillAiModal .ygg-qai-after { border-color: var(--ygg-primary); }

/* ===== Galerie ===== */
.ygg-galerie {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
}
.ygg-galerie-item {
  position: relative;
  border-radius: var(--ygg-radius-sm);
  overflow: hidden;
  background: var(--ygg-border-soft);
  aspect-ratio: 1;
}
.ygg-galerie-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ygg-galerie-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: 0;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.ygg-galerie-remove:hover { background: var(--ygg-error); }

/* ===== Lightbox global ===== */
#yggLightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#yggLightbox.open { display: flex; animation: yggLbFade 0.15s ease; }
@keyframes yggLbFade { from { opacity: 0; } to { opacity: 1; } }
#yggLightbox .ygg-lb-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.88);
  cursor: zoom-out;
}
#yggLightbox .ygg-lb-content {
  position: relative;
  z-index: 1;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
#yggLightbox .ygg-lb-img {
  max-width: 95vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  background: #111;
}
#yggLightbox .ygg-lb-close {
  position: absolute;
  top: -2rem;
  right: -2rem;
  width: 44px; height: 44px;
  background: white;
  border: 0;
  border-radius: 50%;
  font-size: 1.6rem;
  cursor: pointer;
  color: #111;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
@media (max-width: 768px) {
  #yggLightbox .ygg-lb-close { top: 0.5rem; right: 0.5rem; }
}
#yggLightbox .ygg-lb-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: white;
  font-size: 0.85rem;
  background: rgba(0,0,0,0.5);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  max-width: 95vw;
}
#yggLightbox .ygg-lb-caption { opacity: 0.85; }
#yggLightbox .ygg-lb-dl {
  color: white;
  text-decoration: underline;
  font-weight: 600;
}
#yggLightbox .ygg-lb-dl:hover { color: #93C5FD; }

/* Curseur loupe sur les images cliquables */
.ygg-galerie-item img,
.ygg-medias-grid img,
.ygg-ia-img-card img,
.ygg-image-principale img,
img.ygg-zoomable { cursor: zoom-in; }

/* Bouton "voir/télécharger" sur les vignettes (concept art) */
.ygg-galerie-dl {
  position: absolute;
  top: 4px; left: 4px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  text-decoration: none;
  font-weight: 700;
}
.ygg-galerie-dl:hover { background: var(--ygg-primary); color: white; text-decoration: none; }

/* ===== Inspiration visuelle (IA) ===== */
.ygg-inspiration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}
.ygg-inspiration-item {
  position: relative;
  background: var(--ygg-bg);
  border: 1px solid var(--ygg-border);
  border-radius: var(--ygg-radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ygg-inspiration-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.ygg-inspiration-legende {
  margin: 0 !important;
  padding: 0.35rem 0.5rem !important;
  border: 0 !important;
  border-top: 1px solid var(--ygg-border) !important;
  border-radius: 0 !important;
  font-size: 0.75rem !important;
  font-style: italic;
  background: var(--ygg-surface);
}
.ygg-inspiration-legende:focus {
  background: var(--ygg-border-soft);
  outline: 2px solid var(--ygg-primary);
  outline-offset: -2px;
}
.ygg-inspiration-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: 0;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.ygg-inspiration-remove:hover { background: var(--ygg-error); }

/* ===== Mode d'emploi (Stand) ===== */
.ygg-mode-emploi-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--ygg-bg);
  border: 1px solid var(--ygg-border);
  border-radius: var(--ygg-radius-sm);
}
.ygg-me-icon {
  width: 48px; height: 48px;
  background: var(--ygg-primary);
  color: white;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.ygg-me-info { flex: 1; min-width: 0; }
.ygg-me-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ygg-me-info small { font-size: 0.8rem; }
.ygg-me-actions { display: flex; gap: 0.3rem; }

/* ===== Liste personnel du stand ===== */
.ygg-personnel-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ygg-personnel-list li {
  background: var(--ygg-bg);
  border: 1px solid var(--ygg-border);
  border-radius: var(--ygg-radius-sm);
  padding: 0.75rem;
}
.ygg-personnel-head {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.ygg-personnel-nom { font-weight: 600; flex: 1; margin: 0 !important; }
.ygg-personnel-role { flex: 1; margin: 0 !important; }
.ygg-personnel-del {
  background: transparent;
  border: 1px solid var(--ygg-border);
  border-radius: 6px;
  color: var(--ygg-error);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.ygg-personnel-del:hover { background: var(--ygg-error); color: white; border-color: var(--ygg-error); }
.ygg-personnel-list textarea {
  width: 100%;
  resize: vertical;
  margin: 0 0 0.5rem !important;
  font-family: inherit;
  font-size: 0.9rem;
}
.ygg-personnel-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  position: relative;
}
.ygg-personnel-link label { margin: 0; white-space: nowrap; color: var(--ygg-text-muted); }
.ygg-personnel-link input { flex: 1; margin: 0 !important; padding: 0.35rem 0.5rem !important; font-size: 0.85rem !important; }
.ygg-personnel-link-go {
  text-decoration: none;
  background: var(--ygg-primary);
  color: white !important;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}
/* Suggestions autocomplete personnage */
.ygg-personnel-link .ygg-autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
}

/* ===== Dropdown des suggestions @ (quill-mention) ===== */
.ql-mention-list-container {
  background: var(--ygg-surface) !important;
  border: 1px solid var(--ygg-border) !important;
  border-radius: var(--ygg-radius-sm);
  box-shadow: var(--ygg-shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 9999;
}
.ql-mention-list { list-style: none; margin: 0; padding: 0.25rem 0; }
.ql-mention-list-item {
  padding: 0.45rem 0.75rem !important;
  font-size: 0.9rem;
  color: var(--ygg-text) !important;
  cursor: pointer;
  line-height: 1.3;
}
.ql-mention-list-item.selected,
.ql-mention-list-item:hover {
  background: var(--ygg-primary) !important;
  color: white !important;
}
.ygg-mention-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.ygg-mention-type {
  font-size: 0.75rem;
  color: var(--ygg-text-muted);
  text-transform: capitalize;
  font-weight: 400;
}
.ql-mention-list-item.selected .ygg-mention-type,
.ql-mention-list-item:hover .ygg-mention-type {
  color: rgba(255,255,255,0.85);
}

/* Forçage explicite mode dark (toggle manuel) */
[data-theme="dark"] .ql-mention-list-container {
  background: #1E293B !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .ql-mention-list-item { color: #F1F5F9 !important; }
[data-theme="dark"] .ql-mention-list-item.selected,
[data-theme="dark"] .ql-mention-list-item:hover { background: #2C5282 !important; color: #FFFFFF !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ql-mention-list-container {
    background: #1E293B !important;
    border-color: #334155 !important;
  }
  :root:not([data-theme="light"]) .ql-mention-list-item { color: #F1F5F9 !important; }
  :root:not([data-theme="light"]) .ql-mention-list-item.selected,
  :root:not([data-theme="light"]) .ql-mention-list-item:hover {
    background: #2C5282 !important; color: #FFFFFF !important;
  }
}

/* Le span ".mention" inséré dans le texte : adaptation dark */
[data-theme="dark"] .ql-editor .mention {
  background: rgba(59,130,246,0.15);
  color: #93C5FD;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ql-editor .mention {
    background: rgba(59,130,246,0.15);
    color: #93C5FD;
  }
}

/* Inputs aussi en mode sombre */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--ygg-surface);
  color: var(--ygg-text);
  border-color: var(--ygg-border);
}
