/* ═══════════════════════════════════════════════
   TOKENS & CSS OPTIMISÉ
   - Regroupement des sélecteurs similaires
   - Réduction de la duplication de code
   - Utilisation de variables CSS cohérentes
═══════════════════════════════════════════════ */
:root {
  --bg: #0b0d11;
  --surface: #13161e;
  --surface2: #1a1e2a;
  --border: #232738;
  --border2: #2d3348;
  --accent: #d4903a;
  --accent-rgb: 212, 144, 58;
  --red: #e05555;
  --text: #dde2ed;
  --text2: #8a93ad;
  --mono: 'DM Mono', monospace;
  --sans: 'DM Sans', sans-serif;
  --serif: 'Fraunces', serif;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.18s ease;
  --link: #5b9cf6;
  --link-hover: #91bcff;
  --tag-accent: #d4903a;
  --tag-accent-rgb: 212, 144, 58;
}

/* Palettes de couleurs — source unique via custom properties.
   Pour ajouter une couleur : ajouter UNE ligne à COLOR_PALETTE en haut du JS
   et un trio (--pal-<name>, --pal-<name>-rgb) ci-dessous. */
:root {
  --pal-amber:      #d4903a; --pal-amber-rgb:       212,144,58;
  --pal-blue:       #82C8E5; --pal-blue-rgb:        130,200,229;
  --pal-pink:       #FC8EAC; --pal-pink-rgb:        252,142,172;
  --pal-kaki:       #D5C58A; --pal-kaki-rgb:        213,197,138;
  --pal-citrouille: #FF7518; --pal-citrouille-rgb:  255,117,24;
  --pal-champagne:  #F7E6CA; --pal-champagne-rgb:   247,230,202;
  --pal-silver:     #8a9bb5; --pal-silver-rgb:      138,155,181;
  --pal-pistache:   #84B067; --pal-pistache-rgb:    132,176,103;
}
.palette-amber      { --accent:var(--pal-amber);      --accent-rgb:var(--pal-amber-rgb); }
.palette-blue       { --accent:var(--pal-blue);       --accent-rgb:var(--pal-blue-rgb); }
.palette-pink       { --accent:var(--pal-pink);       --accent-rgb:var(--pal-pink-rgb); }
.palette-kaki       { --accent:var(--pal-kaki);       --accent-rgb:var(--pal-kaki-rgb); }
.palette-citrouille { --accent:var(--pal-citrouille); --accent-rgb:var(--pal-citrouille-rgb); }
.palette-champagne  { --accent:var(--pal-champagne);  --accent-rgb:var(--pal-champagne-rgb); }
.palette-silver     { --accent:var(--pal-silver);     --accent-rgb:var(--pal-silver-rgb); }
.palette-pistache   { --accent:var(--pal-pistache);   --accent-rgb:var(--pal-pistache-rgb); }

/* ─── Mode clair ──────────────────────────────────────────────────────────────
   Override des tokens de surface/texte/lien quand .theme-light est appliqué
   sur <html>. Les couleurs d'accent (palettes) restent identiques pour
   préserver l'identité visuelle. La preview du tag suit le thème via les
   mêmes tokens, ce qui donne un tag clair cohérent avec l'éditeur.
   ─────────────────────────────────────────────────────────────────────────── */
:root.theme-light {
  --bg:       #f5f6f9;
  --surface:  #ffffff;
  --surface2: #eef0f5;
  --border:   #d8dde6;
  --border2:  #c2c8d4;
  --text:     #1a1d24;
  --text2:    #5a6275;
  --link:     #2563d4;
  --link-hover: #1e4dab;
}

/* ─── Phase 1 — Polices personnalisables du tag ──────────────────────────────
   - --tag-font-body   : corps (valeurs, notes, contenu courant) du preview
   - --tag-font-display: titres principaux (nom, header, titles serif italic)
   Les LABELS/MRZ/codes restent en var(--mono) — c'est leur identité visuelle.
   Pour ajouter une police : importer la fonte au <head>, ajouter un trio
   --tag-fnt-<name> (body/display si différents) et une classe .tag-font-<name>.
   ─────────────────────────────────────────────────────────────────────────── */
:root {
  --tag-fnt-mono-body:     'DM Mono', monospace;
  --tag-fnt-mono-display:  'DM Mono', monospace;
  --tag-fnt-sans-body:     'DM Sans', sans-serif;
  --tag-fnt-sans-display:  'DM Sans', sans-serif;
  --tag-fnt-serif-body:    'Fraunces', serif;
  --tag-fnt-serif-display: 'Fraunces', serif;
  --tag-fnt-rounded-body:    'Quicksand', sans-serif;
  --tag-fnt-rounded-display: 'Quicksand', sans-serif;
  --tag-fnt-display-body:    'DM Sans', sans-serif;
  --tag-fnt-display-display: 'Playfair Display', serif;
  /* Défauts (= sans, identique à l'ancien comportement) */
  --tag-font-body:    var(--tag-fnt-sans-body);
  --tag-font-display: var(--tag-fnt-sans-display);
}
.tag-font-mono    { --tag-font-body: var(--tag-fnt-mono-body);    --tag-font-display: var(--tag-fnt-mono-display); }
.tag-font-sans    { --tag-font-body: var(--tag-fnt-sans-body);    --tag-font-display: var(--tag-fnt-sans-display); }
.tag-font-serif   { --tag-font-body: var(--tag-fnt-serif-body);   --tag-font-display: var(--tag-fnt-serif-display); }
.tag-font-rounded { --tag-font-body: var(--tag-fnt-rounded-body); --tag-font-display: var(--tag-fnt-rounded-display); }
.tag-font-display { --tag-font-body: var(--tag-fnt-display-body); --tag-font-display: var(--tag-fnt-display-display); }

.tag-palette-amber      { --tag-accent:var(--pal-amber);      --tag-accent-rgb:var(--pal-amber-rgb); }
.tag-palette-blue       { --tag-accent:var(--pal-blue);       --tag-accent-rgb:var(--pal-blue-rgb); }
.tag-palette-pink       { --tag-accent:var(--pal-pink);       --tag-accent-rgb:var(--pal-pink-rgb); }
.tag-palette-kaki       { --tag-accent:var(--pal-kaki);       --tag-accent-rgb:var(--pal-kaki-rgb); }
.tag-palette-citrouille { --tag-accent:var(--pal-citrouille); --tag-accent-rgb:var(--pal-citrouille-rgb); }
.tag-palette-champagne  { --tag-accent:var(--pal-champagne);  --tag-accent-rgb:var(--pal-champagne-rgb); }
.tag-palette-silver     { --tag-accent:var(--pal-silver);     --tag-accent-rgb:var(--pal-silver-rgb); }
.tag-palette-pistache   { --tag-accent:var(--pal-pistache);   --tag-accent-rgb:var(--pal-pistache-rgb); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

a { color: var(--text2); text-decoration: none; }

/* Opt 21 — X5 : focus ring unifié pour les contrôles de formulaire.
   Ajoute un halo accent subtil en plus des règles existantes, sans les remplacer.
   Cible spécifiquement les inputs textuels / textareas / selects pour ne pas
   polluer les boutons qui gèrent déjà leur propre outline. */
.field-group input:focus-visible,
.field-group textarea:focus-visible,
.field-group select:focus-visible,
.login-box input:focus-visible,
.custom-field-row input:focus-visible,
.phone-row input:focus-visible,
.preset-search:focus-visible,
.flag-search:focus-visible,
.phone-flag-popup-search:focus-visible,
.pref-select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.22);
  border-color: var(--accent);
}

/* Opt 21 — (3) VALEURS saisies en DM Sans pour lisibilité.
   Chaque règle ci-dessous (login, field-group, custom-field-row, phone-row,
   preset-search, flag-search, phone-flag-popup-search, pref-select, acc-item-label)
   a été basculée de var(--mono) à var(--sans) directement. Les labels, boutons,
   status, onglets, séparateurs, tpl-option-label et éléments structurels restent
   en var(--mono) pour préserver l'identité visuelle.
   Grep « TEXT-SANS » pour retrouver tous les points basculés. */

/* ═══════════════════════════════════════════════
   COMPOSANTS RÉUTILISABLES
═══════════════════════════════════════════════ */
button {
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-full {
  width: 100%;
  padding: 13px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-primary, .btn-secondary, .btn-add {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text2);
}

.btn-primary {
  font-size: 12px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-primary:hover, .btn-secondary:hover, .btn-add:hover,
.icon-btn:hover, .icon-btn-info:hover, .icon-btn-left:hover, .icon-btn-left_1:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-add {
  font-size: 13px;
  font-weight: 900;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Boutons icônes */
.info-group-dev label {
  display: block;
  font-size: 14px;
  font-family: var(--mono);
  color: var(--red);
}

.info-group label {
  display: block;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text2);
}

.icon-btn, .icon-btn-info, .icon-btn-left, .icon-btn-left_1 {
  height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.icon-btn, .icon-btn-left, .icon-btn-left_1 { width: 30px; }
.icon-btn-info { width: 120px; }

.icon-btn:hover, .icon-btn-left:hover, .icon-btn-left_1:hover { transform: scale(1.08); }

.icon-btn svg, .icon-btn-info svg,
.icon-btn-left svg, .icon-btn-left_1 svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Opt 21 — U2 : état disabled + spinner de chargement sur .icon-btn.
   Utilisé par le bouton Save pendant le fetch vers save.php.
   Le spinner réutilise le pseudo-élément ::after (la tooltip est neutralisée via ::before). */
.icon-btn:disabled,
.icon-btn-info:disabled,
.icon-btn-left:disabled,
.icon-btn-left_1:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.icon-btn.btn-loading {
  pointer-events: none;
  position: relative;
}
.icon-btn.btn-loading svg { visibility: hidden; }
/* Neutralise la flèche de tooltip pendant le chargement. */
.icon-btn.btn-loading::before { display: none; }
/* Le spinner : anneau CSS centré, animé via rotate sur un wrapper pour ne pas
   interférer avec un éventuel translate dans transform. */
.icon-btn.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: transparent;
  border: 2px solid rgba(var(--accent-rgb), 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: 1;
  transform: none;
  animation: btn-spin 0.7s linear infinite;
  /* On annule la décoration de tooltip héritée. */
  white-space: normal;
  padding: 0;
  color: transparent;
  pointer-events: none;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* Tooltips unifiés */
[class*="icon-btn"]::after {
  content: attr(data-tip);
  position: absolute;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 6px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 100;
}

.icon-btn::after, .icon-btn-info::after {
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
}

.icon-btn-left::after, .icon-btn-left_1::after {
  right: calc(100% + 5px);
  top: 50%;
  transform: translateY(-50%);
}

[class*="icon-btn"]::before {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--surface2);
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 99;
}

.icon-btn::before, .icon-btn-info::before {
  bottom: calc(100% + 3px);
  left: 50%;
  border-left: 1px solid var(--border2);
  border-top: 1px solid var(--border2);
  transform: translateX(-50%) rotate(45deg);
}

.icon-btn-left::before, .icon-btn-left_1::before {
  right: calc(100% + 2px);
  top: 50%;
  border-right: 1px solid var(--border2);
  border-top: 1px solid var(--border2);
  transform: translateY(-50%) rotate(45deg);
}

[class*="icon-btn"]:hover::after,
[class*="icon-btn"]:hover::before { opacity: 1; }

/* ═══════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════ */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  /* display: none par défaut → évite le flash d'overlay au refresh quand
     une session est restaurée depuis sessionStorage. Le JS de boot affiche
     l'overlay (display: flex) seulement si aucune session n'est disponible. */
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 52px 44px;
  width: 380px;
  text-align: center;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6);
  position: relative;
}

.login-box::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.login-logo {
  font-family: var(--serif);
  font-style: italic;
  font-weight: bold;
  font-size: 28px;
  letter-spacing: 3px;
  color: var(--accent);
  font-variant: small-caps;
  margin-bottom: 6px;
}

.login-box p {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 32px;
}

.login-box input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans); /* TEXT-SANS */
  font-size: 16px;
  padding: 13px 16px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  letter-spacing: 1px;
  text-align: center;
}

#username {
  letter-spacing: 1px;
  text-transform: lowercase;
}

.login-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

#pwd:-webkit-autofill,
#pwd:-webkit-autofill:hover,
#pwd:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
  -webkit-text-fill-color: var(--text2) !important;
  caret-color: var(--text);
  border-color: var(--accent);
}

.login-error {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--red);
  margin-top: 10px;
  min-height: 16px;
}

/* ═══════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════ */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 32px;
  width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5);
}

.modal-title-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 3px;
  margin-bottom: 24px;
  color: var(--accent);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ═══ Custom confirm dialog ═══
   Remplace le confirm() natif (préfixe d'origine "www.hanot.fr says:" non
   stylable). Z-index 250 pour passer au-dessus de #modal-overlay (200) si
   jamais les deux étaient ouverts. */
#confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 250;
}

#confirm-overlay.open { display: flex; }

.modal-confirm {
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 24px;
}

.modal-confirm .modal-title {
  margin-bottom: 14px;
}

.confirm-message {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 8px;
  white-space: pre-line;
}

.radio-group {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  padding: 8px 14px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  color: var(--text2);
}

.radio-item:hover { border-color: var(--accent); color: var(--text); }
.radio-item.selected { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.06); }
.radio-item input { display: none; }

/* Flag picker */
.flag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  max-height: 110px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.flag-opt {
  font-size: 22px;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 5px;
  border: 2px solid transparent;
  transition: 0.12s;
}

.flag-opt:hover { background: var(--border2); }
.flag-opt.selected { border-color: var(--accent); }

/* Preset search */
.preset-search, .flag-search {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans); /* TEXT-SANS */
  font-style: italic;
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  margin-bottom: 6px;
  transition: border-color var(--transition);
}

.preset-search:focus, .flag-search:focus { border-color: var(--accent); }

.preset-list {
  max-height: 160px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.preset-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-bottom: 1px solid var(--border);
}

.preset-list-item:last-child { border-bottom: none; }
.preset-list-item:hover { background: var(--surface2); color: var(--text); }
.preset-list-item.selected { background: rgba(var(--accent-rgb), 0.08); color: var(--accent); }
.preset-list-item .preset-flag { font-size: 16px; flex-shrink: 0; }

.preset-list-empty {
  padding: 12px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
  text-align: center;
  font-style: italic;
}

/* ═══════════════════════════════════════════════
   PREFERENCES MENU
═══════════════════════════════════════════════ */
.pref-wrap { position: relative; display: flex; align-items: center; gap: 10px; }

.pref-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px 18px;
  width: 230px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65);
  display: none;
  z-index: 60;
}

.pref-dropdown.open { display: block; }

.pref-section { margin-bottom: 14px; }
.pref-section:last-child { margin-bottom: 0; }


.pref-section-title{
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  gap: 8px;
}

.pref-section-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.7px;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 4px;
}

.pref-divider {
  height: 1px;
  background: var(--border);
  margin: 5px 0;
}

.pref-color-swatches {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 2px 0;
}

.pref-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.pref-color-swatch:hover { transform: scale(1.2); }
.pref-color-swatch.active { border-color: var(--text); transform: scale(1.15); }

.pref-tag-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.pref-tag-color-swatch:hover { transform: scale(1.2); }
.pref-tag-color-swatch.active { border-color: var(--text); transform: scale(1.15); }

/* Switch thème clair / sombre */
.pref-theme-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.pref-theme-btn {
  width: 28px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border: none;
  background: transparent;
  color: var(--text2);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  padding: 0;
  line-height: 1;
}
.pref-theme-btn:hover { color: var(--text); }
.pref-theme-btn.active {
  background: var(--accent);
  color: var(--bg);
}
.pref-theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Phase 1 — Échantillons de polices "Aa" sous Préférences > Tag font.
   Les 5 échantillons restent sur UNE seule ligne (flex-wrap: nowrap)
   et partagent l'espace disponible à parts égales (flex: 1 1 0). */
.pref-font-swatches {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 4px;
}
.pref-tag-font-swatch {
  flex: 1 1 0;
  min-width: 0;
  height: 32px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  user-select: none;
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
  /* La classe .tag-font-* applique le tag-font-display à elle-même via spec ci-dessous */
}
.pref-tag-font-swatch:hover { transform: scale(1.08); border-color: var(--accent); }
.pref-tag-font-swatch.active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  transform: scale(1.05);
}
.pref-tag-font-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Chaque échantillon utilise sa propre police pour montrer le rendu */
.pref-tag-font-swatch.tag-font-mono    { font-family: var(--tag-fnt-mono-display); }
.pref-tag-font-swatch.tag-font-sans    { font-family: var(--tag-fnt-sans-display); font-weight: 500; }
.pref-tag-font-swatch.tag-font-serif   { font-family: var(--tag-fnt-serif-display); font-style: italic; font-weight: 600; }
.pref-tag-font-swatch.tag-font-rounded { font-family: var(--tag-fnt-rounded-display); font-weight: 600; }
.pref-tag-font-swatch.tag-font-display { font-family: var(--tag-fnt-display-display); font-style: italic; font-weight: 700; }

.pref-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans); /* TEXT-SANS */
  font-size: 12px;
  padding: 7px 7px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.pref-select:focus { border-color: var(--accent); }

/* ═══════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════ */
.app-shell {
  display: grid;
  grid-template-columns: 1fr 380px;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Top bar */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 17, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
}

.topbar-brand-name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--accent);
  font-variant: small-caps;
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 20px;
  padding: 8px 8px;
  background: rgba(var(--accent-rgb), 0.06);
}

.topbar-saved-at {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  padding: 6px 0 8px;
}

/* Chip "tag actif" : positionné en haut à droite du topbar, opposé au titre
   "Luggage Tag Editor", aligné verticalement sur le milieu du titre.
   Couleur basée sur --accent (couleur d'interface de l'éditeur en cours).
   Note : .topbar a déjà position: sticky (ligne 851) qui établit un
   positioning context — pas besoin de la repasser en relative. */

.topbar-tag {
  position: absolute;
  /* Alignement vertical : milieu du topbar-brand. Le brand a padding-top: 8px,
     font-size 20px et padding 8/8. Son centre est à ~24 px du haut. */
  top: 24px;
  transform: translateY(-50%);
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.40);
  border-radius: 14px;
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.4px;
  white-space: nowrap;
  max-width: 200px;
  z-index: 10;
}
.topbar-tag-icon {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  line-height: 1;
}
.topbar-tag-icon svg { display: block; width: 1em; height: 1em; }
.topbar-tag-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Séparateur vertical entre message de statut et timestamp */
.topbar-saved-at .status:not(:empty) {
  border-right: 1px solid var(--border2);
  margin-right: 10px;
  padding-right: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 6px 0 8px;
}

.status {
  font-family: var(--mono);
  font-size: 10px;
  min-height: 16px;
  transition: color 0.3s;
  color: transparent;
}

.status.ok { color: var(--accent); }
.status.err { color: var(--red); }

.saved-at {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0.85;
  text-align: right;
}

/* Tooltip USERID sur user-label */
.saved-at[data-tip] {
  position: relative;
  cursor: default;
}
.saved-at[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text2);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 6px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  z-index: 100;
}
.saved-at[data-tip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════
   MAIN COLUMN
═══════════════════════════════════════════════ */
.main-col {
  padding: 28px 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ═══════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════ */
.sidebar {
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow-y: auto;
}

.sidebar-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text2);
}

.preview-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 16px;
}

/* ═══════════════════════════════════════════════
   CARDS / SECTIONS
═══════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header, .card-header1 {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* Hauteur uniforme : 52 px = padding 28 + bouton 24 (réduit ci-dessous).
     Les headers sans bouton (Données personnelles) sont bumpés au même 52 px
     par min-height. Tous les card-header ont donc exactement la même hauteur. */
  min-height: 52px;
  box-sizing: border-box;
}

.card-header1 { padding: 8px 20px; }

/* Bouton + dans les card-header : ramené de 30×30 à 24×24 pour matcher la
   min-height. Visible mais moins encombrant. */
.card-header .icon-btn-left,
.card-header .icon-btn-left_1 { width: 24px; height: 24px; }

.card-title {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}



.card-title-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.card-body { padding: 20px; }

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

/* ═══════════════════════════════════════════════
   FORM FIELDS
═══════════════════════════════════════════════ */
.field-group { margin-bottom: 14px; }
.field-group:last-child { margin-bottom: 0; }

.field-group label {
  display: block;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.field-group input,
.field-group textarea,
.field-group select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans); /* TEXT-SANS */
  font-size: 15px;
  letter-spacing: 0.2px;
  /*font-variant-caps: small-caps;*/
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}


.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus { /*roro*/
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

/* ─── Neutralisation de l'autofill Chrome/Safari (fond jaune/blanc forcé) ───
   On ré-applique le fond sombre via un box-shadow interne (qui prime sur
   le background jaune imposé par le navigateur) et on force la couleur du
   texte en variable --text. La transition très longue est un fallback
   classique pour éviter le clignotement à l'autofill. */
.field-group input:-webkit-autofill,
.field-group input:-webkit-autofill:hover,
.field-group input:-webkit-autofill:focus,
.field-group input:-webkit-autofill:active,
.field-group textarea:-webkit-autofill,
.field-group textarea:-webkit-autofill:hover,
.field-group textarea:-webkit-autofill:focus,
.field-group select:-webkit-autofill,
.phone-row input:-webkit-autofill,
.phone-row input:-webkit-autofill:hover,
.phone-row input:-webkit-autofill:focus,
.phone-row input:-webkit-autofill:active,
.custom-field-row input:-webkit-autofill,
.custom-field-row input:-webkit-autofill:hover,
.custom-field-row input:-webkit-autofill:focus,
.custom-field-row input:-webkit-autofill:active,
.login-box input:-webkit-autofill,
.login-box input:-webkit-autofill:hover,
.login-box input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
  box-shadow: 0 0 0 1000px var(--bg) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}

/* Préserver le halo de focus quand le champ est aussi autofilled */
.field-group input:-webkit-autofill:focus,
.field-group textarea:-webkit-autofill:focus,
.phone-row input:-webkit-autofill:focus,
.custom-field-row input:-webkit-autofill:focus {
  -webkit-box-shadow:
    0 0 0 1000px var(--bg) inset,
    0 0 0 3px rgba(var(--accent-rgb), 0.1) !important;
  box-shadow:
    0 0 0 1000px var(--bg) inset,
    0 0 0 3px rgba(var(--accent-rgb), 0.1) !important;
  border-color: var(--accent);
}

/* Section separator */
.sep {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 20px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sep::before {
  content: '';
  width: 16px;
  height: 1px;
  background: var(--accent);
  opacity: 0.5;
}

.sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Bouton "+" générique (utilisé dans les sep ou à côté d'un label) */
.sep-add-btn {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  font-family: var(--mono);
  transition: all var(--transition);
  flex-shrink: 0;
}
.sep-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}
/* Variante : titre de section .sep avec bouton à droite (le bouton passe après le filet) */
.sep.sep-with-action::after { order: 1; }
.sep.sep-with-action > .sep-add-btn { order: 2; }

/* Label de field-group avec bouton d'action à droite (ex. "Téléphone +") */
.label-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.label-with-action > label {
  margin: 0;
}

/* ═══════════════════════════════════════════════
   LANGUAGE TOGGLES
═══════════════════════════════════════════════ */
.lang-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
}

.toggle-item:hover { border-color: var(--accent); color: var(--text); }
.toggle-item.enabled { border-color: var(--accent); color: var(--text); }
.toggle-item.dragging { opacity: 0.4; border-style: dashed; }
.toggle-item.drag-over { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

.toggle-switch {
  width: 28px;
  height: 14px;
  background: var(--border2);
  border-radius: 7px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-item.enabled .toggle-switch { background: var(--accent); }

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
}

.toggle-item.enabled .toggle-switch::after { transform: translateX(14px); }

.toggle-flag { font-size: 15px; }

.toggle-drag, .toggle-remove, .toggle-edit {
  font-size: 12px;
  opacity: 0.7;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  position: relative;
  height: 20px;
  display: inline-flex;
  align-items: center;
}

.toggle-drag { cursor: grab; }
.toggle-drag:active { cursor: grabbing; }
.toggle-drag:hover, .toggle-remove:hover, .toggle-edit:hover { opacity: 1; }
.toggle-remove:hover { color: var(--red); }
.toggle-edit:hover { color: var(--accent); }

.toggle-item.lang-locked { cursor: default; }
.toggle-item.lang-locked .toggle-switch { opacity: 0.7; pointer-events: none; }
.toggle-item.lang-locked::after {
  content: '🔒';
  font-size: 10px;
  margin-left: 2px;
  opacity: 0.3;
}

.toggle-note {
  font-size: 10px;
  color: var(--red);
  font-family: var(--mono);
  margin-top: 8px;
  display: none;
}

.toggle-note.visible { display: block; }

.toggle-label-text {
  transition: opacity 0.15s, max-width 0.2s;
  max-width: 120px;
  overflow: hidden;
  white-space: nowrap;
}

.hide-lang-names .toggle-label-text {
  opacity: 0;
  max-width: 0;
}

/* Pref toggle */
.pref-lang-names-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  width: fit-content;
  padding: 2px 0;
}

.pref-lang-names-toggle .toggle-switch { flex-shrink: 0; }
.pref-lang-names-toggle.enabled .toggle-switch { background: var(--accent); }
.pref-lang-names-toggle.enabled .toggle-switch::after { transform: translateX(14px); }

/* ═══════════════════════════════════════════════
   PHONE ROWS
═══════════════════════════════════════════════ */
.phone-row-wrap { position: relative; }

.phone-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  position: relative; /* pour héberger le popup drapeau */
}

.phone-row input { flex: 1; min-width: 0; }

/* Bouton ✕ de suppression d'une ligne téléphone (caché s'il n'y en a qu'une) */
.phone-remove-btn {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all var(--transition);
  padding: 0;
  font-family: var(--mono);
  line-height: 1;
}
.phone-remove-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

/* Opt 21 — (2) : règle d'erreur consolidée + halo 3px aligné sur le focus-ring X5.
   Couvre téléphone, email, URL. Les 3 règles individuelles restent pour la
   spécificité mais pointent toutes vers le même rendu. */
.phone-row input.phone-invalid,
.phone-row input.phone-invalid:focus,
.field-group input.email-invalid,
.field-group input.email-invalid:focus,
.field-group input.web-invalid,
.field-group input.web-invalid:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(224, 85, 85, 0.20);
}
/*.phone-row input.phone-valid {
  border-color: var(--border);
  box-shadow: 0 0 0 2px rgba(var(--border-rgb), 0.1);
}
*/
.phone-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.1);
}

/* Animation shake bouton Save en cas d'erreur de validation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(3px); }
}
.btn-shake { animation: shake 0.38s ease; }

/* État intermédiaire pendant la vérification DNS/MX de l'email (halo 3px aligné). */
.field-group input.email-checking,
.field-group input.email-checking:focus {
  border-color: var(--text2);
  box-shadow: 0 0 0 3px rgba(138, 147, 173, 0.18);
}
/* Pas de surlignage persistant quand l'URL est valide (cohérence avec email-valid)
.field-group input.web-valid,
.field-group input.web-valid:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.12);
}*/

/* Wrapper champ web + bouton lien */
.web-input-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}
.web-input-wrap input {
  flex: 1;
  min-width: 0;
}
.web-open-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  transition: border-color var(--transition), color var(--transition), opacity var(--transition);
  opacity: 0;
  pointer-events: none;
  text-decoration: none;
  line-height: 1;
}
.web-open-btn.visible {
  opacity: 1;
  pointer-events: all;
}
.web-open-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.phone-row .app-btns {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.phone-flag-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  transition: all var(--transition);
  padding: 0;
}

.phone-flag-btn:hover { border-color: var(--accent); }

.phone-flag-popup {
  position: absolute;
  z-index: 50;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  width: 260px;
}

.phone-flag-popup-search {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans); /* TEXT-SANS */
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  margin-bottom: 8px;
}

.phone-flag-popup-search:focus { border-color: var(--accent); }

.phone-flag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-height: 130px;
  overflow-y: auto;
}

/* Opt 22 — accepte aussi <button role="option"> pour l'a11y clavier. */
.phone-flag-grid span,
.phone-flag-grid button[role="option"] {
  font-size: 19px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 5px;
  border: 2px solid transparent;
  background: transparent;
  color: inherit;
  font-family: inherit;
  line-height: 1;
}

.phone-flag-grid span:hover,
.phone-flag-grid button[role="option"]:hover { background: var(--border2); }
.phone-flag-grid span.selected,
.phone-flag-grid button[role="option"].selected,
.phone-flag-grid button[role="option"][aria-selected="true"] { border-color: var(--accent); }
.phone-flag-grid button[role="option"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.30);
}

.phone-flag-clear {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text2);
  cursor: pointer;
  margin-top: 8px;
  display: block;
  text-align: right;
  background: transparent;
  border: 0;
  padding: 0;
  width: 100%;
}

.phone-flag-clear:hover { color: var(--red); }

.app-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg) center/17px no-repeat;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
  font-size: 0;
}

.app-btn:hover { transform: scale(1.08); }
.app-btn.inactive { opacity: 0.2; filter: grayscale(1); }

/* App icons - URLs inchangées */
.app-btn[data-app="whatsapp"] { background-image: url("data:image/svg+xml,%3Csvg%20role%3D%22img%22%20viewBox%3D%220%200%2024%2024%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cpath%20fill%3D%22%23fff%22%20d%3D%22M17.472%2014.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94%201.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198%200-.52.074-.792.372-.272.297-1.04%201.016-1.04%202.479%200%201.462%201.065%202.875%201.213%203.074.149.198%202.096%203.2%205.077%204.487.709.306%201.262.489%201.694.625.712.227%201.36.195%201.871.118.571-.085%201.758-.719%202.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421%207.403h-.004a9.87%209.87%200%2001-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86%209.86%200%2001-1.51-5.26c.001-5.45%204.436-9.884%209.888-9.884%202.64%200%205.122%201.03%206.988%202.898a9.825%209.825%200%20012.893%206.994c-.003%205.45-4.437%209.884-9.885%209.884m8.413-18.297A11.815%2011.815%200%200012.05%200C5.495%200%20.16%205.335.157%2011.892c0%202.096.547%204.142%201.588%205.945L.057%2024l6.305-1.654a11.882%2011.882%200%20005.683%201.448h.005c6.554%200%2011.89-5.335%2011.893-11.893a11.821%2011.821%200%2000-3.48-8.413Z%22/%3E%3C/svg%3E"); background-size: 17px; }
.app-btn[data-app="wechat"] { background-image: url("data:image/svg+xml,%3Csvg%20role%3D%22img%22%20viewBox%3D%220%200%2024%2024%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cpath%20fill%3D%22%23fff%22%20d%3D%22M8.691%202.188C3.891%202.188%200%205.476%200%209.53c0%202.212%201.17%204.203%203.002%205.55a.59.59%200%200%201%20.213.665l-.39%201.48c-.019.07-.048.141-.048.213%200%20.163.13.295.295.295a.326.326%200%200%200%20.167-.054l1.903-1.114a.864.864%200%200%201%20.717-.098%2010.16%2010.16%200%200%200%202.837.403c.276%200%20.543-.027.811-.05-.857-2.578.157-4.972%201.932-6.446%201.703-1.415%203.882-1.98%205.853-1.838-.576-3.583-3.895-6.348-7.601-6.348zM5.785%205.991c.642%200%201.162.529%201.162%201.18a1.17%201.17%200%200%201-1.162%201.178A1.17%201.17%200%200%201%204.623%207.17c0-.651.52-1.18%201.162-1.18zm4.843%200c.641%200%201.162.529%201.162%201.18a1.17%201.17%200%200%201-1.162%201.178%201.17%201.17%200%200%201-1.162-1.178c0-.651.52-1.18%201.162-1.18zm8.55%202.511c-4.553-.288-8.367%203.165-8.367%207.054%200%203.747%203.655%206.778%208.163%206.778.739%200%201.456-.095%202.14-.267a.752.752%200%200%201%20.625.083l1.662.973a.28.28%200%200%200%20.146.047.257.257%200%200%200%20.257-.257c0-.063-.026-.12-.042-.179l-.34-1.29a.514.514%200%200%201%20.186-.581%206.545%206.545%200%200%200%202.623-5.14c0-3.61-3.066-6.875-7.053-7.221zm-2.562%203.628c.559%200%201.012.462%201.012%201.031%200%20.57-.453%201.031-1.012%201.031a1.022%201.022%200%200%201-1.013-1.031c0-.569.454-1.031%201.013-1.031zm5.123%200c.559%200%201.012.462%201.012%201.031%200%20.57-.453%201.031-1.012%201.031a1.022%201.022%200%200%201-1.013-1.031c0-.569.453-1.031%201.013-1.031z%22/%3E%3C/svg%3E"); background-size: 17px; }
.app-btn[data-app="line"] { background-image: url("data:image/svg+xml,%3Csvg%20role%3D%22img%22%20viewBox%3D%220%200%2024%2024%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cpath%20fill%3D%22%23fff%22%20d%3D%22M19.365%209.863c.349%200%20.63.285.63.631%200%20.345-.281.63-.63.63H17.61v1.125h1.755c.349%200%20.63.283.63.63%200%20.344-.281.629-.63.629h-2.386c-.345%200-.627-.285-.627-.629V8.108c0-.345.282-.63.627-.63h2.386c.349%200%20.63.285.63.63%200%20.349-.281.63-.63.63H17.61v1.125h1.755zm-3.855%203.016c0%20.27-.174.51-.432.596-.064.021-.133.031-.199.031-.211%200-.391-.09-.51-.25l-2.443-3.317v2.94c0%20.344-.279.629-.631.629-.346%200-.626-.285-.626-.629V8.108c0-.27.173-.51.43-.595.06-.023.136-.033.194-.033.195%200%20.375.104.495.254l2.462%203.33V8.108c0-.345.282-.63.63-.63.345%200%20.63.285.63.63v4.771zm-5.741%200c0%20.344-.282.629-.631.629-.345%200-.627-.285-.627-.629V8.108c0-.345.282-.63.627-.63.349%200%20.631.285.631.63v4.771zm-2.466.629H4.917c-.345%200-.63-.285-.63-.629V8.108c0-.345.285-.63.63-.63.348%200%20.63.285.63.63v4.141h1.756c.348%200%20.629.283.629.63%200%20.344-.281.629-.629.629M24%2010.314C24%204.943%2018.615.572%2012%20.572S0%204.943%200%2010.314c0%204.811%204.27%208.842%2010.035%209.608.391.082.923.258%201.058.59.12.301.079.766.038%201.08l-.164%201.02c-.045.301-.24%201.186%201.049.645%201.291-.539%206.916-4.07%209.436-6.975C23.176%2014.393%2024%2012.458%2024%2010.314%22/%3E%3C/svg%3E"); background-size: 17px; }

.app-btn.active-wa { border-color: #25d366; background-color: #25d366; }
.app-btn.active-wc { border-color: #07c160; background-color: #07c160; }
.app-btn.active-li { border-color: #00b900; background-color: #00b900; }

/* ═══════════════════════════════════════════════
   LANG TABS
═══════════════════════════════════════════════ */
.lang-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.lang-tab {
  padding: 4px 11px;
  border-radius: 5px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all var(--transition);
}

.lang-tab:hover { border-color: var(--accent); color: var(--text); }
.lang-tab.active { background: var(--bg); color: var(--accent); border-color: var(--accent); }

/* ═══════════════════════════════════════════════
   PREVIEW TAG
═══════════════════════════════════════════════ */
.tag-preview-shell { text-align: center; width: 100%; }

.tag-flags {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tag-flag-btn {
  font-size: 22px;
  cursor: pointer;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--surface);
  transition: all var(--transition);
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.tag-flag-btn:hover { background: var(--border2); transform: translateY(-1px); }
.tag-flag-btn.active { border-color: var(--tag-accent); box-shadow: 0 0 0 3px rgba(var(--tag-accent-rgb), 0.15); }

.tag-flag-btn-name {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text2);
  line-height: 1;
  white-space: nowrap;
}

.tag-wrap {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tag-header {
  background: var(--surface);
  color: var(--tag-accent);
  padding: 10px 10px;
  font-family: var(--tag-font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 35px;
  letter-spacing: 2px;
  font-variant: small-caps;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: pre-line;
}

.tag-content {
  padding: 0 20px 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  /* Isolation : le preview est entièrement redessiné à chaque frappe.
     `contain` empêche le reflow de remonter à la page entière. */
  contain: layout paint;
  will-change: contents;
}

.tag-field { margin-top: 13px; }

.tag-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--tag-accent);
  margin-bottom: 4px;
  font-weight: 500;
  /* Opt 23 — guards texte long : empêche un label sans espace de défoncer la mise en page */
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tag-value {
  padding: 5px 0 7px;
  border-bottom: 1px solid var(--border);
  white-space: pre-line;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  font-family: var(--tag-font-body);
  /* Opt 23 — guards texte long sur valeurs (URLs/IBAN/etc.) */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.tag-value a { color: var(--link); font-weight: 500; }
.tag-value a:hover { color: var(--link-hover); }

.tag-phone-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
}

.tag-phone-line a { color: var(--link); font-weight: 500; }

.tag-app-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
}

.tag-app-wa { background: #25d366; }
.tag-app-wc { background: #07c160; }
.tag-app-li { background: #00b900; }

.tag-addr { margin-top: 13px !important; }
.tag-addr .tag-value {
  line-height: 1.45;
  padding-top: 5px;
  padding-bottom: 7px;
}

.tag-addr-line { 
  margin-bottom: 2px;
}

.tag-note {
  margin-top: 6px;
  padding: 2px 12px;
  font-size: 13px;
  font-style: italic;
  text-align: center;
  line-height: 1.5;
  font-weight: 700;
  color: var(--tag-accent);
  font-family: var(--tag-font-display);
  font-variant-caps: small-caps;
  letter-spacing: 0.5px;
}

.tag-ec-reveal-btn {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: opacity var(--transition);
  padding: 2px 0;
  /* Opt 22 — extraction des styles inline JS dans la classe. */
  color: #ff0000;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
}

.tag-ec-reveal-btn:hover { opacity: 0.75; }

.tag-ec-chevron {
  font-size: 10px;
  display: inline-block;
  transition: transform 0.28s ease;
  color: var(--text2);
}

.tag-ec-reveal-btn.open .tag-ec-chevron { transform: rotate(90deg); }

.tag-ec-body { display: none; }

.tag-ec-body.open {
  display: block;
  animation: tag-ec-unfold 0.22s ease forwards;
}

/* Opt 22 — extraction des styles inline du preview EC vers des classes. */
.tag-ec-content {
  padding: 4px 0;
  font-size: 15px;
  line-height: 1.15;
  color: var(--text);
}
.tag-ec-content > div { margin-bottom: 0; }
.tag-ec-content .tag-ec-email-link {
  color: var(--link);
  font-weight: 500;
  text-decoration: underline;
}
.tag-ec-section { margin-top: 6px; }
.tag-flag-badge { font-size: 16px; line-height: 1; }
.tag-flag-badge-sm { font-size: 14px; line-height: 1; margin-left: 3px; }
.tag-flag-badge-mid { font-size: 15px; line-height: 1; margin-left: 3px; }
.tag-flag-badge-md { font-size: 16px; line-height: 1; margin-left: 4px; }
.tag-section-hr { border: none; border-top: 1px solid #2e3245; margin: 10px 0 0; }
/* Phones lines à l'intérieur de la section EC : pas de margin-bottom (compact) */
.tag-ec-content .tag-phone-line { margin-bottom: 0; }

@keyframes tag-ec-unfold {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══ TEMPLATE PICKER ═══ */
.tpl-picker { position: relative; }
.tpl-picker-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--mono);
  font-size: 12px; cursor: pointer; transition: border-color var(--transition);
}
.tpl-picker-btn:focus { outline: none; border-color: var(--accent); }
.tpl-picker-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; flex-shrink: 0; }
.tpl-picker-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 8px; z-index: 200;
  box-shadow: 0 16px 40px rgba(0,0,0,.6); flex-direction: column; gap: 6px;
}
.tpl-picker-dropdown.open { display: flex; }
.tpl-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; transition: all var(--transition); background: var(--bg);
}
.tpl-option:hover { border-color: var(--border2); }
.tpl-option.active { border-color: var(--accent); background: rgba(var(--accent-rgb),.06); }
.tpl-thumb {
  width: 52px; height: 38px; flex-shrink: 0; border-radius: 4px;
  overflow: hidden; background: var(--surface); border: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.tpl-thumb-classic-header { height: 12px; background: var(--surface); display: flex; align-items: center; justify-content: center; }
.tpl-thumb-classic-header span { font-size: 5px; color: var(--tag-accent); font-style: italic; font-family: serif; }
.tpl-thumb-classic-row { height: 5px; margin: 2px 4px; background: var(--border); border-radius: 1px; }
.tpl-thumb-classic-row:first-of-type { background: rgba(var(--tag-accent-rgb),.4); width: 60%; }
.tpl-thumb-pp-header { height: 13px; background: #0f1e48; display: flex; align-items: center; gap: 3px; padding: 0 4px; }
.tpl-thumb-pp-dot { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--tag-accent); flex-shrink: 0; }
.tpl-thumb-pp-title { font-size: 5px; color: var(--tag-accent); font-style: italic; font-family: serif; }
.tpl-thumb-pp-row { height: 4px; margin: 2px 4px; background: var(--border); border-radius: 1px; }
.tpl-thumb-pp-mrz { height: 6px; background: #080f22; margin-top: auto; }
.tpl-thumb-bp-top { height: 13px; background: var(--surface); display: flex; align-items: flex-end; padding: 0 4px 2px; border-bottom: 1px dashed rgba(var(--tag-accent-rgb),.4); }
.tpl-thumb-bp-name { font-size: 6px; color: var(--tag-accent); font-style: italic; font-family: serif; }
.tpl-thumb-bp-row { height: 4px; margin: 2px 4px; background: var(--border); border-radius: 1px; }
.tpl-thumb-bp-strip { height: 3px; background: repeating-linear-gradient(90deg,var(--tag-accent) 0,var(--tag-accent) 3px,transparent 3px,transparent 6px); opacity:.5; margin-top: auto; }
.tpl-thumb-ac-head { height: 14px; background: var(--surface); border-bottom: 2px solid var(--tag-accent); display: flex; align-items: flex-end; padding: 0 4px 2px; }
.tpl-thumb-ac-title { font-size: 6px; color: var(--tag-accent); font-style: italic; font-family: serif; }
.tpl-thumb-ac-row { display: flex; align-items: stretch; border-bottom: 0.5px solid var(--border); }
.tpl-thumb-ac-key { width: 14px; background: var(--surface); border-right: 0.5px solid var(--border); height: 7px; flex-shrink: 0; }
.tpl-thumb-ac-val { flex: 1; height: 7px; background: var(--bg); }
.tpl-thumb-ss-wrap { display: flex; flex: 1; }
.tpl-thumb-ss-stripe { width: 8px; background: var(--tag-accent); flex-shrink: 0; }
.tpl-thumb-ss-body { flex: 1; padding: 2px 3px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); }
.tpl-thumb-ss-name { height: 6px; background: rgba(var(--tag-accent-rgb),.4); border-radius: 1px; margin-bottom: 2px; }
.tpl-thumb-ss-row { height: 4px; background: var(--border); border-radius: 1px; }
.tpl-option-label { font-family: var(--mono); font-size: 11px; color: var(--text2); }
.tpl-option.active .tpl-option-label { color: var(--accent); }

/* ═══ TEMPLATE PASSPORT — preview ═══ */
.tpl-passport .tag-header { display: none; }
.tpl-passport .tag-content { padding: 0; }
.pp-header-bar { background: #0f1e48; display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-radius: var(--radius) var(--radius) 0 0; }
.pp-emblem { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--tag-accent); display: flex; align-items: center; justify-content: center; color: var(--tag-accent); font-size: 16px; flex-shrink: 0; }
.pp-header-text { flex: 1; }
.pp-doc-type { font-family: var(--mono); font-size: 8px; letter-spacing: 2px; text-transform: uppercase; color: #6a7faf; margin-bottom: 3px; }
.pp-title { font-family: var(--tag-font-display); font-style: italic; font-size: 20px; font-weight: 600; letter-spacing: 1px; color: var(--tag-accent); font-variant: small-caps; line-height: 1; }
.pp-body { padding: 16px 20px 12px; display: flex; flex-direction: column; }
.pp-grid { display: flex; flex-direction: column; }
.pp-field { padding: 8px 0; border-bottom: 1px solid var(--border); }
.pp-field:last-child { border-bottom: none; }
.pp-label { font-family: var(--mono); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--tag-accent); margin-bottom: 4px; opacity: 0.85; }
.pp-value { font-family: var(--tag-font-body); font-size: 15px; color: var(--text); line-height: 1.4; }
.pp-value a { color: var(--link); text-decoration: none; font-weight: 500; }
.pp-value-name { font-family: var(--mono); font-size: 15px; font-weight: 500; letter-spacing: 1px; color: #e0e8ff; }
.pp-phone-line { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.pp-note { margin-top: 10px; padding: 8px 12px; text-align: center; font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--tag-accent); border: 1px solid rgba(var(--tag-accent-rgb), 0.25); border-radius: var(--radius-sm); line-height: 1.6; }
.pp-mrz { background: #080f22; border-top: 2px solid #1a2744; padding: 8px 20px; border-radius: 0 0 var(--radius) var(--radius); font-family: 'Courier New', Courier, monospace; font-size: 9px; letter-spacing: 2px; color: #1e3a6a; line-height: 1.6; overflow: hidden; white-space: nowrap; user-select: none; }
.pp-mrz-line { overflow: hidden; text-overflow: clip; }

/* ═══ TEMPLATE BOARDING PASS — preview ═══ */
.tpl-boarding-pass .tag-header { display: none; }
.tpl-boarding-pass .tag-content { padding: 0; }

/* ═══ TEMPLATE ACCORDION — preview ═══ */
.tpl-accordion .tag-header { display: none; }
.tpl-accordion .tag-content { padding: 0; }
.ac-wrap { display: flex; flex-direction: column; }
.ac-head { padding: 16px 20px 12px; border-bottom: 2px solid var(--tag-accent); }
.ac-label { font-family: var(--mono); font-size: 8px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--text2); margin-bottom: 4px; }
.ac-title { font-family: var(--tag-font-display); font-style: italic; font-size: 26px; font-weight: 600; color: var(--tag-accent); font-variant: small-caps; letter-spacing: 1px; line-height: 1.1; }
.ac-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.ac-row:last-of-type { border-bottom: none; }
.ac-key { width: 80px; flex-shrink: 0; padding: 10px 14px; font-family: var(--mono); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--tag-accent); border-right: 1px solid var(--border); display: flex; align-items: center; }
.ac-val { flex: 1; padding: 10px 14px; font-family: var(--tag-font-body); font-size: 14px; color: var(--text); line-height: 1.4; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.ac-val a { color: var(--link); text-decoration: none; font-weight: 500; }
.ac-note { padding: 10px 20px; font-family: var(--tag-font-display); font-style: italic; font-size: 13px; font-weight: 700; color: var(--tag-accent); text-align: center; line-height: 1.5; border-top: 1px solid var(--border); font-variant-caps: small-caps; letter-spacing: 0.5px; }

/* ═══ TEMPLATE SIDE STRIPE — preview ═══ */
.tpl-side-stripe .tag-header { display: none; }
.tpl-side-stripe .tag-content { padding: 0; }
.ss-wrap { display: flex; flex-direction: row; min-height: 200px; }
.ss-stripe { width: 32px; background: var(--tag-accent); flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 0; }
.ss-stripe-title { font-family: var(--tag-font-display); font-style: italic; font-size: 11px; font-weight: 600; color: var(--bg); writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; letter-spacing: 1px; font-variant: small-caps; }
.ss-body { flex: 1; padding: 16px 18px 14px; display: flex; flex-direction: column; min-width: 0; }
.ss-name { font-family: var(--tag-font-display); font-style: italic; font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: 0.5px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); font-variant: small-caps; }
.ss-list { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ss-item { display: flex; gap: 10px; align-items: flex-start; }
.ss-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--tag-accent); flex-shrink: 0; margin-top: 5px; }
.ss-item-body { flex: 1; min-width: 0; }
.ss-item-label { font-family: var(--mono); font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text2); margin-bottom: 2px; }
.ss-item-val { font-family: var(--tag-font-body); font-size: 13px; color: var(--text); line-height: 1.4; }
.ss-item-val a { color: var(--link); text-decoration: none; font-weight: 500; }
.ss-phone-line { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.ss-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-family: var(--mono); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--tag-accent); line-height: 1.6; }
.bp-wrap { display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; }
.bp-top { padding: 14px 20px 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 2px dashed rgba(var(--tag-accent-rgb), 0.35); }
.bp-top-left { flex: 1; min-width: 0; }
.bp-airline { font-family: var(--mono); font-size: 8px; letter-spacing: 3px; text-transform: uppercase; color: var(--text2); margin-bottom: 5px; }
.bp-name { font-family: var(--tag-font-display); font-style: italic; font-size: 24px; font-weight: 600; color: var(--tag-accent); font-variant: small-caps; letter-spacing: 1px; line-height: 1.1; word-break: break-word; }
.bp-top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.bp-seq-label { font-family: var(--mono); font-size: 7px; letter-spacing: 2px; text-transform: uppercase; color: var(--text2); }
.bp-seq { font-family: var(--mono); font-size: 28px; font-weight: 500; color: rgba(var(--tag-accent-rgb), 0.18); line-height: 1; letter-spacing: -1px; }
.bp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.bp-cell { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--border); }
.bp-cell:nth-last-child(-n+2) { border-bottom: none; }
.bp-cell-full { grid-column: 1 / -1; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--border); }
.bp-cell-full:last-child { border-bottom: none; }
.bp-label { font-family: var(--mono); font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--tag-accent); margin-bottom: 3px; opacity: 0.8; }
.bp-value { font-family: var(--tag-font-body); font-size: 13px; color: var(--text); line-height: 1.4; }
.bp-value a { color: var(--link); text-decoration: none; font-weight: 500; }
.bp-phone-line { display: flex; align-items: center; gap: 5px; margin-bottom: 2px; }
.bp-strip { height: 4px; background: repeating-linear-gradient(90deg, var(--tag-accent) 0px, var(--tag-accent) 6px, transparent 6px, transparent 12px); opacity: 0.5; }
.bp-note { padding: 8px 20px; font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text2); text-align: center; line-height: 1.6; }

/* Opt 23 — guards texte long applicables à TOUS les templates de preview.
   Évite qu'une URL/IBAN/etc. sans espaces ne défonce la mise en page. */
.pp-label, .pp-value,
.bp-label, .bp-value,
.ac-key,   .ac-val,
.ss-item-label, .ss-item-val {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.acc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.acc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: default;
  transition: border-color var(--transition);
}

.acc-item.editing { border-color: var(--accent); background: var(--surface2); }
.acc-item.active-tag .acc-active-dot { color: var(--accent); }

.acc-active-dot {
  font-size: 14px;
  color: var(--text2);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  transition: color var(--transition);
  user-select: none;
  padding: 2px 4px;
  border-radius: 4px;
}

.acc-active-dot:hover { color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }

.acc-item-label {
  flex: 1;
  font-family: var(--sans); /* TEXT-SANS */
  font-size: 13px;
  letter-spacing: 0.2px;
  color: var(--text2);
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  border-radius: 3px;
  padding: 1px 4px;
  margin: -1px -4px;
  min-width: 40px;
  transition: background var(--transition), color var(--transition);
}

.acc-item-label:hover { color: var(--text); }

.acc-item-label:focus {
  background: var(--surface2);
  color: var(--text);
  text-overflow: clip;
}

.acc-item-label:empty::before {
  content: attr(data-placeholder);
  color: var(--text2);
  pointer-events: none;
}

.acc-item.editing .acc-item-label { color: var(--text); }

.acc-active-badge {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.acc-delete {
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.acc-delete:hover { color: var(--red); background: rgba(224, 85, 85, 0.1); }

.acc-drag {
  font-size: 12px;
  opacity: 0.2;
  cursor: grab;
  flex-shrink: 0;
  line-height: 1;
  padding: 2px 3px;
  user-select: none;
  transition: opacity var(--transition);
}

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

.acc-item:hover .acc-drag { opacity: 0.5; }
.acc-item.dragging { opacity: 0.4; border-style: dashed; }
.acc-item.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2); }

.acc-editor {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 2px;
}

.acc-editor-title {
  font-family: var(--mono);
  font-size: 0;
  letter-spacing: 2px;
  color: var(--text2);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.acc-empty {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
  text-align: center;
  padding: 24px;
}

/* ═══════════════════════════════════════════════
   CHAMPS PERSONNALISÉS
═══════════════════════════════════════════════ */
.custom-field-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
}
/* Poignée de drag-and-drop des custom fields */
.cf-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text2);
  font-size: 14px;
  line-height: 1;
  cursor: grab;
  user-select: none;
  letter-spacing: -2px;
  transition: color var(--transition);
}
.cf-drag-handle:hover { color: var(--accent); }
.cf-drag-handle:active { cursor: grabbing; }
.custom-field-row.dragging { opacity: 0.4; border-style: dashed; border-color: var(--border2); }
.custom-field-row.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2); }
.custom-field-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans); /* TEXT-SANS */
  font-size: 14px;
  letter-spacing: 0.2px;
  padding: 8px 10px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-width: 0;
}
.custom-field-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}
.custom-field-row .cf-label { flex: 2; }
.custom-field-row .cf-value { flex: 3; }
.custom-field-delete {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all var(--transition);
  padding: 0;
  font-family: var(--mono);
  line-height: 1;
}
.custom-field-delete:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }
.custom-field-header {
  display: flex;
  gap: 6px;
  margin-bottom: 5px;
  /* padding-left = largeur de la poignée (16px) + gap (6px) pour aligner les colonnes du header sur les inputs */
  padding: 0 32px 0 22px;
}
.custom-field-header span {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text2);
  font-family: var(--mono);
}
.custom-field-header .cf-lh { flex: 2; }
.custom-field-header .cf-vh { flex: 3; }

/* ─── Popover de presets de champs personnalisés ─────────────────────────────
   Attaché à .cf-sep (position: relative). S'ouvre sous les boutons d'action.
   Items "blocked" = preset déjà inséré dans le tag (cf._presetKey égal).
   ─────────────────────────────────────────────────────────────────────────── */
.cf-sep { position: relative; }
.cf-preset-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 200px;
  max-width: 260px;
  /* Sécurité hauteur : ne dépasse jamais le viewport, scroll interne sinon.
     dvh = dynamic viewport height (correct sur iOS Safari quand la barre
     d'URL est visible/masquée), avec fallback vh pour les navigateurs plus
     anciens. */
  max-height: min(380px, calc(100vh - 100px));
  max-height: min(380px, calc(100dvh - 100px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 3px;
  display: none;
  font-family: var(--sans, var(--text-fnt, sans-serif));
  line-height: 1.2;
}
/* Variante : popover ouvert vers le HAUT (quand pas assez de place dessous).
   Activée par JS via classlist .flip-up dans openCfPresetPopover. */
.cf-preset-popover.flip-up {
  top: auto;
  bottom: calc(100% + 6px);
}

/* Backdrop modal pour mobile : assombrit l'arrière-plan, tap pour fermer.
   Sur mobile, sert aussi de wrapper flex pour centrer le popover de manière
   fiable (translate(-50%) avait des soucis sur iOS Safari). */
.cf-preset-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 49;
  -webkit-tap-highlight-color: transparent;
}
.cf-preset-backdrop.open { display: block; }

/* ─── Mode mobile : popover en feuille modale centrée ──────────────────────
   En dessous de 600px de large, le popover est porté DANS le backdrop par
   le JS (openCfPresetPopover), et le backdrop devient un wrapper flex
   centrant le popover. Approche plus robuste qu'un position:fixed +
   translate sur iOS Safari (où la barre d'URL et les conteneurs
   transformés cassent le centrage).
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .cf-preset-backdrop.open {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
  }
  .cf-preset-popover {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
    width: 100%;
    max-width: 360px;
    min-width: 0;
    max-height: 75vh;
    max-height: 75dvh;
    z-index: 60;
    margin: 0;
  }
  .cf-preset-popover.flip-up {
    top: auto;
    bottom: auto;
    transform: none;
  }
}
.cf-preset-popover.open { display: block; }
.cf-preset-popover[hidden] { display: none; }
.cf-preset-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text2);
  padding: 2px 8px 3px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1px;
  line-height: 1.2;
}
.cf-preset-cat {
  font-size: 9px;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 8px 1px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.2;
}
.cf-preset-cat:first-of-type { padding-top: 2px; }
.cf-preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.2;
  /* Lignes compactes pour desktop ; surchargé sur mobile pour respect
     des cibles tactiles iOS (44px). */
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.cf-preset-item:hover:not(.blocked):not([disabled]) {
  background: rgba(var(--accent-rgb), 0.10);
  border-color: rgba(var(--accent-rgb), 0.35);
  color: var(--text);
}
.cf-preset-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.cf-preset-item.blocked,
.cf-preset-item[disabled] {
  color: var(--text2);
  cursor: not-allowed;
  opacity: 0.55;
  background: transparent;
}
.cf-preset-item.blocked:hover {
  background: transparent;
  border-color: transparent;
}
.cf-preset-check {
  color: var(--accent);
  font-size: 12px;
  margin-left: 8px;
  flex-shrink: 0;
}

/* Onglets de langue pour les champs personnalisés */
.cf-lang-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.cf-lang-tab {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition);
}
.cf-lang-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.cf-lang-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.10);
}
.cf-lang-tab .cf-lang-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text2);
  opacity: 0.5;
}
.cf-lang-tab.has-content .cf-lang-dot {
  background: var(--accent);
  opacity: 1;
}
.custom-fields-empty {
  /* Opt 21 — X7 : empty state plus lisible + visuellement intégré. */
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
  line-height: 1.4;
  background: rgba(var(--accent-rgb), 0.03);
  margin: 4px 0 8px;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .modal { width: 95vw; padding: 20px; }
}

@media (max-width: 640px) {
  /* Par défaut .grid-2 bascule en colonne unique sur iPhone. */
  .grid-2 { grid-template-columns: 1fr; }
  /* Variante "compact" : reste en 2 colonnes même sur iPhone (utile pour
     Tags + Langues qui ont du contenu compact en chips). */
  .grid-2.grid-2-compact { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Uniformise la hauteur des headers de carte sur iPhone.
     Sans cette règle, les headers avec bouton + (Tags, Langues, Hébergements)
     sont plus hauts que ceux sans bouton (Données personnelles) à cause de la
     hauteur native du .icon-btn-left (30 px). On réduit le bouton à 24 px et
     on fixe une min-height commune pour aligner visuellement les 4. */
  .card-header { padding: 10px 16px; min-height: 44px; box-sizing: border-box; }
  .card-header .icon-btn-left,
  .card-header .icon-btn-left_1 { width: 24px; height: 24px; }
  .topbar { padding: 0 16px; }
  .main-col { padding: 20px 16px; }
  .phone-flag-popup {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: calc(100vw - 32px) !important;
    max-width: 320px;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 200 !important;
  }

  /* Opt 21 — R1 : tap targets ≥ 40px (WCAG AA+ / proche du seuil iOS 44px).
     S'applique uniquement en mobile pour ne pas dégrader le desktop. */
  .icon-btn,
  .icon-btn-left,
  .icon-btn-left_1,
  .icon-btn-info {
    min-width: 40px;
    min-height: 40px;
  }
  .phone-flag-btn {
    min-width: 40px;
    min-height: 40px;
  }
  .web-open-btn {
    min-width: 40px;
    min-height: 40px;
  }
  .phone-remove-btn,
  .custom-field-delete,
  .sep-add-btn {
    min-width: 32px;
    min-height: 32px;
  }
  .app-btn {
    min-height: 40px;
    padding: 8px 14px;
  }
  .tpl-picker-btn {
    min-height: 40px;
  }

  /* Opt 21 — R2 : empêche le zoom automatique de Safari iOS lors du focus
     sur les inputs en passant tous les champs à 16px en mobile. */
  .field-group input,
  .field-group textarea,
  .field-group select,
  .login-box input,
  .preset-search,
  .flag-search,
  .phone-flag-popup-search,
  .pref-select,
  .custom-field-row input,
  .phone-row input,
  .phone-row select {
    font-size: 16px;
  }
}

/* Opt 21 — R4 : très petit mobile (≤460px) — compacter topbar et marges
   pour récupérer de l'espace sans sacrifier les tap targets. */
@media (max-width: 460px) {
  .topbar { padding: 0 12px; height: auto; min-height: 52px; flex-wrap: wrap; row-gap: 6px; }
  .topbar-brand { gap: 8px; }
  .topbar-brand-name { font-size: 13px; }
  .topbar-saved-at { font-size: 11px; gap: 6px; flex-wrap: wrap; }
  .main-col { padding: 16px 12px; }
  .sidebar { padding: 16px 12px; }
  .modal {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px);
    padding: 16px;
    border-radius: 12px;
  }
  .field-group { margin-bottom: 14px; }
  .section-title { font-size: 13px; }
  h1 { font-size: 18px; }
  h2 { font-size: 15px; }
}

/* ═════════════════════════════════════════════════════════════════════════
   MULTI-TAG : barre de toggles tags + modal tag + modal tri-état
   ═══════════════════════════════════════════════════════════════════════ */

/* Barre de toggles tags : même pattern que .lang-toggles mais plus compact. */
.tag-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-toggle-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 7px 10px 7px 9px;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
  position: relative;
}

.tag-toggle-item:hover { border-color: var(--accent); color: var(--text); }

/* Tag actif : fond + bordure accent, label plus contrasté. */
.tag-toggle-item.active {
  background: rgba(var(--accent-rgb), 0.10);
  border-color: var(--accent);
  color: var(--text);
}

.tag-toggle-icon {
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.tag-toggle-icon svg {
  display: block;
  width: 1em;
  height: 1em;
}
.tag-icon-pick svg {
  display: block;
  width: 1em;
  height: 1em;
}

.tag-toggle-label {
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-toggle-edit {
  margin-left: 4px;
  padding: 0 4px;
  font-size: 11px;
  color: var(--text3, #6b7589);
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
}
.tag-toggle-edit:hover {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.10);
}

/* Modal tag (create/edit) — réutilise .modal mais conteneur dédié. */
#tag-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 240;
}
#tag-modal-overlay.open { display: flex; }

.modal-tag {
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 24px;
}

/* Picker emoji dans le modal tag : grille de chips. */
.tag-icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tag-icon-pick {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 26px;       /* SVG hérite de 1em → 26×26 dans le picker */
  line-height: 1;
  color: var(--text);    /* couleur explicite : SVG stroke=currentColor → bien visible */
  transition: all var(--transition);
  padding: 0;
}
.tag-icon-pick:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.tag-icon-pick.active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
}

/* Modal tri-état : même style que confirm-overlay mais 3 boutons. */
#confirm-tri-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 260;
}
#confirm-tri-overlay.open { display: flex; }

/* ═════════════════════════════════════════════════════════════════════════
   PHOTO DE PROFIL DU TAG (avatar circulaire dans l'éditeur)
   ═══════════════════════════════════════════════════════════════════════ */

.profile-block {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
}

.profile-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg);
  border: 2px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-placeholder {
  color: var(--text3, #6b7589);
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-placeholder svg { display: block; }

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

.btn-secondary.btn-sm {
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.btn-secondary.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

.profile-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
}
.profile-status.err { color: var(--red, #e05555); }

/* Avatar dans la preview (sidebar). Plus petit que l'éditeur, suit la couleur
   d'accent du tag pour la bordure. Centré sous le titre du tag. */
.preview-profile {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
}
.preview-profile img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--tag-accent);
  background: var(--surface);
  display: block;
}

