/* ============================================================================
   SnapStation UI — socle commun des outils (auth, planning, editor, backoffice)
   ----------------------------------------------------------------------------
   COPIE CONFORME dans chaque outil : css/ss-ui.css. Ne jamais modifier une
   copie seule — modifier, puis recopier dans les quatre dépôts
   (`ops/ui-sync.sh` copie et vérifie). Référence visuelle : le backoffice.

   1. Polices et tokens (palette, surfaces, texte, rayons, ombres, animations)
   2. Base
   3. Primitives : boutons, cartes, badges, champs, pastilles, interrupteurs…
   4. Coquille : barre latérale, barre du haut, page
   5. Couches : fenêtres, palette de recherche, toast
   6. Mobile

   Deux thèmes : sombre (défaut du design system) et `.ss-theme-light`
   (lavande), posé sur <html> par js/ss-ui.js avant le premier rendu. Le choix
   est partagé entre les outils (cookie sur .snapstation.be).

   Typographie :
   - Akira Expanded (--font-display) : titres de page, de fenêtre, chiffres
     clés, nom de l'outil sous le logo. Toujours en capitales, et SANS ACCENTS
     (la police n'en a aucun : SSUI.stripAkiraAccents s'en charge).
   - Space Grotesk (--font-text) : tout le reste.
   ========================================================================== */

@font-face {
  font-family: "Akira Expanded";
  src: url("../assets/fonts/Akira-Expanded.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("../assets/fonts/SpaceGrotesk-Variable.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* ============================================================================
   1. TOKENS
   ========================================================================== */

:root {
  /* Palette de marque — les seules couleurs de la suite. */
  --purple-950: #1B0F3D;
  --purple-900: #2A1657;
  --purple-800: #371F6D;
  --purple-700: #45317E;
  --purple-600: #553F96;
  --purple-500: #6B4FB8;
  --purple-400: #9161FF;
  --magenta-600: #DA58FF;
  --magenta-500: #EB55FF;
  --magenta-400: #F27DFF;
  --blue-600: #4A5BE8;
  --blue-500: #5B6EF5;
  --blue-400: #7E8DFF;
  --lavender-50: #F4F0FF;
  --lavender-100: #E5DCFF;
  --lavender-200: #D3C6F5;
  --lavender-300: #B6A6E0;
  --white: #FFFFFF;
  --black: #0E0823;

  /* États */
  --success: #34D9A0;
  --warning: #FFC24B;
  --danger: #FF5C7A;
  --success-ink: #1E9E72;
  --warning-ink: #C98A0B;
  --danger-ink: #E0324F;

  --gradient-brand: linear-gradient(150deg, #DA58FF 0%, #9161FF 48%, #5B6EF5 100%);
  --gradient-canvas: linear-gradient(160deg, #371F6D 0%, #2A1657 60%, #1B0F3D 100%);

  /* Surfaces et texte — thème sombre */
  --surface-base: var(--purple-900);
  --surface-raised: var(--purple-800);
  --surface-sunken: var(--purple-950);
  --surface-card: var(--purple-800);
  --text-strong: var(--white);
  --text-body: var(--lavender-100);
  --text-muted: var(--lavender-300);
  --text-on-accent: var(--purple-950);
  --text-link: var(--magenta-500);
  --border-subtle: rgba(229, 220, 255, 0.14);
  --border-strong: rgba(229, 220, 255, 0.28);
  --focus-ring: var(--magenta-400);

  /* Aplats (survol, fonds de champ, pistes) */
  --fill-faint: rgba(255, 255, 255, 0.03);
  --fill-soft: rgba(255, 255, 255, 0.06);
  --fill-hover: rgba(255, 255, 255, 0.10);
  --field-bg: rgba(255, 255, 255, 0.04);
  --placeholder: rgba(229, 220, 255, 0.42);
  --tint: rgba(145, 97, 255, 0.07);
  --tint-2: rgba(145, 97, 255, 0.12);
  --scrim: rgba(14, 8, 35, 0.68);

  /* Barre latérale : sombre dans les deux thèmes */
  --sidebar-w: 244px;
  --sidebar-bg: var(--purple-950);
  --sidebar-text: var(--lavender-300);
  --sidebar-icon: #9C8BD0;
  --sidebar-strong: var(--white);
  --sidebar-line: rgba(229, 220, 255, 0.08);

  /* Formes et mouvement */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(27, 15, 61, 0.16);
  --shadow-md: 0 8px 24px rgba(27, 15, 61, 0.22);
  --shadow-lg: 0 20px 48px rgba(27, 15, 61, 0.32);
  --shadow-glow-magenta: 0 10px 36px rgba(235, 85, 255, 0.40);
  --shadow-glow-blue: 0 10px 36px rgba(91, 110, 245, 0.38);

  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --font-display: "Akira Expanded", "Arial Narrow", system-ui, sans-serif;
  --font-text: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;

  color-scheme: dark;
}

.ss-theme-light {
  --surface-base: var(--lavender-100);
  --surface-raised: var(--white);
  --surface-sunken: var(--lavender-200);
  --surface-card: var(--white);
  --text-strong: var(--purple-900);
  --text-body: var(--purple-800);
  --text-muted: var(--purple-600);
  --text-on-accent: var(--purple-950);
  --text-link: var(--magenta-600);
  --border-subtle: rgba(42, 22, 87, 0.12);
  --border-strong: rgba(42, 22, 87, 0.22);

  --fill-faint: rgba(42, 22, 87, 0.025);
  --fill-soft: rgba(42, 22, 87, 0.05);
  --fill-hover: rgba(42, 22, 87, 0.08);
  --field-bg: var(--white);
  --placeholder: rgba(42, 22, 87, 0.42);
  color-scheme: light;
}

/* ============================================================================
   2. BASE
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-body);
  background: var(--surface-base);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: var(--font-text); font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--text-link); text-decoration: none; }
a:hover { color: var(--magenta-600); text-decoration: underline; }
img { max-width: 100%; display: block; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
select option { background: var(--surface-raised); color: var(--text-strong); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
::selection { background: var(--magenta-500); color: var(--purple-950); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(145, 97, 255, 0.28);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
/* Zones arrondies qui défilent (fenêtres, recherche) : le rail s'arrête
   avant les arrondis, sinon la barre déborde sur les coins.
   `scrollbar-width`/`scrollbar-color` seulement là où ::-webkit-scrollbar
   n'existe pas (Firefox) : Chrome, dès qu'ils sont posés, ignore les
   ::-webkit-scrollbar — marge du rail comprise, et la barre repart sur les
   coins. */
@supports not selector(::-webkit-scrollbar) {
  .modal, .palette__list { scrollbar-width: thin; scrollbar-color: rgba(145, 97, 255, 0.35) transparent; }
}
.modal::-webkit-scrollbar-track { margin: 22px 0; background: transparent; }
.palette__list::-webkit-scrollbar-track { margin: 10px 0; background: transparent; }
[hidden] { display: none !important; }
body.is-locked { overflow: hidden; }

@keyframes ssFadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ssSlideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ssSheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ssSpin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.icon { display: inline-block; flex: none; vertical-align: middle; }
.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;
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.kbd {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}
.mark {
  background: var(--magenta-500);
  color: var(--purple-950);
  padding: 0.04em 0.32em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ============================================================================
   3. PRIMITIVES
   ========================================================================== */

/* ---- Boutons ----
   primary : l'action principale de l'écran (une seule visible à la fois).
   secondary : les autres. ghost : actions discrètes (Annuler, Retour).
   danger : suppression. gradient : réservé aux moments de marque. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.01em;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  transition:
    transform 120ms var(--ease-out),
    background 220ms var(--ease-standard),
    box-shadow 220ms var(--ease-standard),
    border-color 220ms var(--ease-standard);
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn--sm { font-size: 13px; padding: 8px 14px; gap: 6px; }
.btn--lg { font-size: 17px; padding: 16px 30px; gap: 10px; }
.btn--full { display: flex; width: 100%; }
.btn--primary { background: var(--magenta-500); color: var(--purple-950); box-shadow: var(--shadow-glow-magenta); }
.btn--primary:hover { background: var(--magenta-600); color: var(--purple-950); }
.btn--gradient { background: var(--gradient-brand); color: #fff; box-shadow: var(--shadow-glow-blue); }
.btn--gradient:hover { color: #fff; }
.btn--secondary { background: transparent; color: var(--text-strong); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--magenta-500); color: var(--text-strong); }
.btn--ghost { background: transparent; color: var(--text-link); }
.btn--ghost:hover { background: rgba(235, 85, 255, 0.12); color: var(--text-link); }
.btn--danger { background: transparent; color: var(--danger); border-color: rgba(255, 92, 122, 0.4); }
.btn--danger:hover { background: rgba(255, 92, 122, 0.1); color: var(--danger); border-color: var(--danger); }
.ss-theme-light .btn--danger, .ss-theme-light .btn--danger:hover { color: var(--danger-ink); }
.btn:disabled, .btn.is-disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.is-busy { pointer-events: none; opacity: 0.7; }

/* ---- Boutons icône ----
   défaut : bordé (barres d'outils). plain : sans cadre (listes, en-têtes).
   tint : fond teinté (fermer une fenêtre). danger : suppression. */
.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1.5px solid var(--border-subtle);
  background: transparent;
  color: var(--text-strong);
  text-decoration: none;
  transition: border-color 160ms var(--ease-standard), background 160ms var(--ease-standard), color 160ms var(--ease-standard);
}
.icon-btn:hover { border-color: var(--magenta-500); color: var(--text-strong); text-decoration: none; }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; border-color: var(--border-subtle); }
.icon-btn--sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn--xs { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn--plain { border: 0; background: transparent; color: var(--text-muted); width: 32px; height: 32px; border-radius: 9px; }
.icon-btn--plain:hover { background: var(--tint-2); color: var(--text-strong); }
.icon-btn--tint { border: 0; background: rgba(145, 97, 255, 0.1); }
.icon-btn--tint:hover { background: rgba(145, 97, 255, 0.18); }
.icon-btn--danger:hover { background: rgba(255, 92, 122, 0.14); color: var(--danger); border-color: rgba(255, 92, 122, 0.4); }
.icon-btn.is-on { background: var(--magenta-500); border-color: var(--magenta-500); color: var(--purple-950); }

.link-btn { border: 0; background: transparent; padding: 0; color: inherit; text-align: left; font: inherit; }
.link-btn:hover { color: var(--text-strong); }

/* ---- Cartes ---- */
.card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 22px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  color: var(--text-body);
}
.card--flat { box-shadow: var(--shadow-sm); }
.card--p0 { padding: 0; }
.card--sm { padding: 18px 20px; }
.card--gradient {
  border: 2px solid transparent;
  background-image: linear-gradient(var(--surface-card), var(--surface-card)), var(--gradient-brand);
  background-origin: border-box;
  background-clip: padding-box, border-box;
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.card__title {
  font-family: var(--font-text);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.2;
  margin: 0;
  color: var(--text-strong);
  text-transform: none;
  letter-spacing: 0;
}
.card__sub { margin: 4px 0 0; font-size: 13.5px; color: var(--text-muted); }
.panel {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ---- Lignes de liste, dans un .panel : séparées par un filet ---- */
.lrow {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 20px;
  border: 0;
  border-top: 1px solid var(--border-subtle);
  background: transparent;
  text-align: left;
  color: inherit;
  font: inherit;
}
.lrow:first-child { border-top-color: transparent; }
button.lrow:hover, a.lrow:hover, .lrow.is-on { background: rgba(145, 97, 255, 0.06); text-decoration: none; }
.lrow.is-muted .lrow__main { opacity: 0.55; }
.lrow__main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.lrow__text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lrow__title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-strong);
}
.lrow__sub {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lrow__side { flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.lrow__meta { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.lrow__side .select, .lrow__side .input { width: auto; max-width: 240px; }

/* ---- Badges : statuts et étiquettes ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.badge--sm { font-size: 11px; padding: 3px 8px; gap: 5px; }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: currentColor; }
.badge--sm .badge__dot { width: 5px; height: 5px; }
.badge--magenta { background: var(--magenta-500); color: var(--purple-950); }
.badge--gradient { background: var(--gradient-brand); color: #fff; }
.badge--soft { background: rgba(235, 85, 255, 0.16); color: var(--magenta-400); }
.ss-theme-light .badge--soft { color: #B03CCB; }
.badge--blue { background: rgba(91, 110, 245, 0.18); color: var(--blue-400); }
.ss-theme-light .badge--blue { color: var(--blue-600); }
.badge--violet { background: rgba(145, 97, 255, 0.18); color: #B69CFF; }
.ss-theme-light .badge--violet { color: var(--purple-500); }
.badge--outline { background: transparent; color: var(--text-body); box-shadow: inset 0 0 0 1px var(--border-strong); }
.badge--outline .badge__dot { background: var(--magenta-500); }
.badge--neutral { background: var(--purple-700); color: var(--lavender-100); }
.ss-theme-light .badge--neutral { background: var(--lavender-200); color: var(--purple-800); }
.badge--success { background: rgba(52, 217, 160, 0.16); color: var(--success); }
.ss-theme-light .badge--success { color: var(--success-ink); }
.badge--danger { background: rgba(255, 92, 122, 0.16); color: var(--danger); }
.ss-theme-light .badge--danger { color: var(--danger-ink); }
.badge--warning { background: rgba(255, 194, 75, 0.2); color: var(--warning); }
.ss-theme-light .badge--warning { color: var(--warning-ink); }

.count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(145, 97, 255, 0.16);
  color: var(--text-body);
}
.count--hot { background: var(--magenta-500); color: var(--purple-950); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }

/* ---- Avatars (initiales sur la couleur du compte : SSUI.avatar) ---- */
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-brand);
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1;
  overflow: hidden;
}
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--md { width: 30px; height: 30px; font-size: 12px; }
.avatar--lg { width: 46px; height: 46px; font-size: 16px; }

/* ---- Champs ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field__label { font-size: 13px; font-weight: 600; color: var(--text-body); }
.field__hint { font-size: 12px; color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  font-size: 15px;
  color: var(--text-strong);
  background: var(--field-bg);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  outline: 0;
  transition: border-color 220ms var(--ease-standard), box-shadow 220ms var(--ease-standard);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--magenta-500);
  box-shadow: 0 0 0 3px rgba(235, 85, 255, 0.18);
}
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; cursor: not-allowed; }
.input--sm, .select--sm { padding: 7px 10px; font-size: 13.5px; border-radius: 10px; }
.select--sm { padding-right: 30px; background-position: right 9px center; }
.textarea { resize: vertical; line-height: 1.55; font-size: 14px; }
.select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239161FF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.input[type="date"], .input[type="time"], .input[type="datetime-local"] { font-size: 14.5px; }
/* Champ avec icône : <label class="input-box"><svg…/><input></label> */
.input-box {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--field-bg);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 14px;
  color: var(--text-muted);
  transition: border-color 220ms var(--ease-standard), box-shadow 220ms var(--ease-standard);
}
.input-box:focus-within { border-color: var(--magenta-500); box-shadow: 0 0 0 3px rgba(235, 85, 255, 0.18); }
.input-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 11px 0;
  font-size: 15px;
  color: var(--text-strong);
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-muted);
  min-width: 240px;
}
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; color: var(--text-strong); }
.search:focus-within { border-color: var(--magenta-500); }

/* ---- Pastilles de filtre ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border-subtle);
  background: transparent;
  color: var(--text-body);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}
.pill:hover { border-color: var(--border-strong); }
.pill.is-on { background: var(--text-strong); color: var(--surface-base); border-color: var(--text-strong); }
.pill__count { font-size: 12px; opacity: 0.75; }
.pill--sm { padding: 6px 12px; font-size: 12.5px; }

/* ---- Sélecteur à segments (changer de vue) ---- */
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(145, 97, 255, 0.1); }
.seg__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}
.seg__btn:hover { color: var(--text-strong); }
.seg__btn.is-on { background: var(--surface-card); color: var(--text-strong); box-shadow: var(--shadow-sm); }
.seg--sm .seg__btn { padding: 6px 12px; font-size: 13px; }
/* Variante formulaire : <span class="seg__opt"><input type="radio"><label class="seg__btn"></span> */
.seg--wrap { flex-wrap: wrap; }
.seg__opt { display: inline-flex; }
.seg__opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg__opt input:checked + .seg__btn { background: var(--surface-card); color: var(--text-strong); box-shadow: var(--shadow-sm); }
.seg__opt input:focus-visible + .seg__btn { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---- Interrupteur ---- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: var(--text-body);
  font-size: 13.5px;
}
.switch__track {
  width: 36px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  flex: none;
  transition: background 160ms;
}
.switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: left 160ms var(--ease-out);
}
.switch.is-on .switch__track { background: var(--magenta-500); }
.switch.is-on .switch__knob { left: 17px; }
/* Même interrupteur sur une vraie case à cocher : <input type="checkbox" class="toggle"> */
.toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  flex: none;
  cursor: pointer;
  transition: background 160ms;
}
.toggle::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: left 160ms var(--ease-out);
}
.toggle:checked { background: var(--magenta-500); }
.toggle:checked::before { left: 17px; }
.toggle-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; cursor: pointer; }
.toggle-row + .toggle-row { border-top: 1px solid var(--border-subtle); }
.toggle-row .toggle { margin-top: 1px; }
.toggle-row__text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toggle-row__text b { font-size: 14px; font-weight: 600; color: var(--text-strong); }
.toggle-row__text span { font-size: 12.5px; color: var(--text-muted); }

/* ---- Onglets ---- */
/* Le trait du bas est une ombre, pas une bordure : le soulignement de l'onglet
   actif le recouvre sans dépasser du conteneur. Une marge négative le faisait
   déborder d'un pixel, et overflow-x: auto (qui force overflow-y) affichait
   alors une barre de défilement verticale. */
.tabs { display: flex; gap: 4px; box-shadow: inset 0 -1px 0 var(--border-subtle); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 2.5px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
}
.tab:hover { color: var(--text-strong); }
.tab.is-on { color: var(--text-strong); border-bottom-color: var(--magenta-500); }

/* ---- Encadrés, vides, chargement ---- */
.callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  background: rgba(145, 97, 255, 0.08);
  color: var(--text-body);
}
.callout .icon { color: var(--purple-400); margin-top: 1px; }
.callout--warn { background: rgba(255, 194, 75, 0.16); color: var(--text-strong); }
.callout--warn .icon { color: var(--warning-ink); }
.callout--danger { background: rgba(255, 92, 122, 0.12); color: var(--text-strong); }
.callout--danger .icon { color: var(--danger); }
.callout--success { background: rgba(52, 217, 160, 0.14); color: var(--text-strong); }
.callout--success .icon { color: var(--success-ink); }
.empty {
  padding: 44px;
  text-align: center;
  color: var(--text-muted);
  border: 1.5px dashed var(--border-strong);
  border-radius: 20px;
  font-size: 14px;
}
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--magenta-500);
  animation: ssSpin 0.8s linear infinite;
}

/* ============================================================================
   4. COQUILLE — identique dans tous les outils (SSUI.sidebar, SSUI.topbar)
   ========================================================================== */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--surface-base);
}

/* ---- Barre latérale ----
   De haut en bas : logo + nom de l'outil, navigation principale, espace,
   navigation secondaire (réglages), compte connecté avec sa déconnexion. */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: auto;
  background: var(--sidebar-bg);
  color: var(--lavender-100);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--sidebar-line);
}
.sidebar__fill { flex: 1; }

/* Logo empilé sans la mention PHOTOBOOTH ; le nom de l'outil prend sa
   place, dans la même écriture (Akira, lettres étalées sur toute la largeur). */
.brandmark {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 152px;
  margin: 2px 10px 0;
  text-decoration: none;
}
.brandmark:hover { text-decoration: none; }
.brandmark img { width: 100%; height: auto; }
.brandmark__tool {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 9px;
  line-height: 1;
  color: var(--lavender-100);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  text-decoration: none;
  transition: background 160ms var(--ease-standard);
}
.nav__item .icon { color: var(--sidebar-icon); }
.nav__item:hover { background: rgba(229, 220, 255, 0.07); color: var(--sidebar-strong); text-decoration: none; }
.nav__item.is-on { background: rgba(235, 85, 255, 0.14); color: var(--sidebar-strong); font-weight: 600; }
.nav__item.is-on .icon { color: var(--magenta-500); }
.nav__label { flex: 1; min-width: 0; }
.nav__count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--magenta-500);
  color: var(--purple-950);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav__ext { color: var(--sidebar-icon); opacity: 0.7; }

.me { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.me__text { flex: 1; min-width: 0; }
.me__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-strong);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me__role { font-size: 11.5px; color: var(--sidebar-text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me form { margin: 0; display: contents; }
.me .icon-btn--plain { color: var(--sidebar-text); }
.me .icon-btn--plain:hover { color: var(--sidebar-strong); background: rgba(229, 220, 255, 0.08); }

/* ---- Zone principale et barre du haut ----
   Barre du haut, de gauche à droite : menu (mobile), recherche de l'outil
   s'il en a une, espace, actions de l'outil, thème, action principale. */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 68px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-base);
}
.topbar__menu { display: none; }
.topbar__fill { flex: 1 1 0; min-width: 0; }
.topbar__search {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-muted);
  font-size: 14px;
  text-align: left;
}
.topbar__search:hover { border-color: var(--border-strong); }
.topbar__search:focus-within { border-color: var(--magenta-500); }
.topbar__search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
  color: var(--text-strong);
  padding: 0;
}
.topbar__search .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__brand { display: none; }
/* Une seule hauteur pour tout ce qui vit dans la barre : recherche, boutons
   icône et action principale s'alignent au pixel. */
.topbar .icon-btn { width: 42px; height: 42px; }
.topbar .btn { height: 42px; padding: 0 18px; font-size: 14.5px; }

.page {
  padding: 32px 40px 72px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.page--wide { max-width: 1400px; padding-top: 24px; gap: 20px; }
.page--mid { max-width: 1180px; }
.page--narrow { max-width: 1080px; }

/* En-tête de page : titre (+ sous-titre) à gauche, actions de la page à droite. */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 20px; flex-wrap: wrap; }
.page-head__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 30px;
  line-height: 0.94;
  color: var(--text-strong);
  margin: 0;
  letter-spacing: -0.01em;
}
.page-title--xl { font-size: 34px; }
.page-sub { margin: 8px 0 0; font-size: 15px; color: var(--text-muted); }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-strong); margin: 0; }

/* ============================================================================
   5. COUCHES
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.overlay--top { align-items: flex-start; padding-top: 12vh; z-index: 70; }

/* Fenêtre : titre en Akira à gauche, fermeture à droite ; pied avec les
   actions alignées à droite (Annuler/Retour puis l'action principale), une
   éventuelle suppression seule à gauche (.modal__foot-start). */
.modal {
  width: min(640px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--surface-base);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: ssFadeUp 220ms var(--ease-out);
}
.modal--sm { width: min(560px, 100%); }
.modal--lg { width: min(860px, 100%); }
.modal--xl { width: min(1040px, 100%); }
/* Couche déjà affichée au rendu précédent (SSUI.settleLayers) : elle ne
   rejoue pas son apparition à chaque mise à jour de son contenu. Tout enfant
   direct, et prioritaire : la feuille mobile (ssSheetUp, plus bas) et les
   fenêtres propres à un outil (assistant du backoffice) sont couvertes aussi
   — sans quoi chaque clic dans la fenêtre la refaisait apparaître. */
.overlay.is-shown > * { animation: none !important; }
.modal__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-base);
}
.modal__title {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 17px;
  color: var(--text-strong);
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}
.modal__lead { margin: 6px 0 0; font-size: 13.5px; color: var(--text-muted); }
.modal__body { padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal__foot {
  /* Comme l'en-tête, le pied reste visible quand la fenêtre défile : les
     actions ne sortent jamais de l'écran. */
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--surface-base);
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.modal__foot-start { margin-right: auto; }

/* Pas de tiroir latéral dans la suite : toute édition se fait dans une
   fenêtre (.modal), fermée par la croix, Échap ou un clic à côté. */

/* Palette de recherche (⌘K) */
.palette {
  width: min(620px, 92vw);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: ssFadeUp 220ms var(--ease-out);
}
.palette__input { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); }
.palette__input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 17px; color: var(--text-strong); min-width: 0; }
.palette__list { padding: 8px; max-height: 420px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.palette__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  color: var(--text-body);
  width: 100%;
}
.palette__item:hover, .palette__item.is-on { background: rgba(235, 85, 255, 0.1); }
.palette__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(145, 97, 255, 0.14);
  color: var(--purple-400);
  flex: none;
}
.palette__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.palette__title { font-size: 14.5px; font-weight: 600; color: var(--text-strong); }
.palette__sub { font-size: 13px; color: var(--text-muted); }
.palette__empty { padding: 28px; text-align: center; font-size: 14px; color: var(--text-muted); }

/* Toast : confirmation brève, en bas au centre. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border-radius: 999px;
  background: var(--purple-950);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(14, 8, 35, 0.4);
  animation: ssFadeUp 220ms var(--ease-out);
  max-width: calc(100vw - 32px);
}
/* Même message qu'au rendu précédent : il reste en place (SSUI.settleLayers). */
.toast.is-shown { animation: none; }
.toast__icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--success);
  color: var(--purple-950);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.toast--error .toast__icon { background: var(--danger); color: #fff; }
.toast--info .toast__icon { background: var(--blue-400); color: #fff; }
.toast.is-leaving { opacity: 0; transform: translate(-50%, 8px); transition: opacity 250ms var(--ease-standard), transform 250ms var(--ease-standard); }
/* Plusieurs toasts à la fois : empilés au même endroit. */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast-stack .toast { position: static; transform: none; pointer-events: auto; }
.toast-stack .toast.is-leaving { transform: translateY(8px); }

/* Chargement et erreur plein écran, identiques dans toute la suite : fond
   dégradé de la marque, logo complet et anneau magenta (ceux du chargeur de
   l'editor). Toujours sombre, quel que soit le thème. */
.state-msg {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 32px;
  background: var(--gradient-canvas);
  color: var(--lavender-100);
}
.state-msg strong { font-size: 20px; color: #fff; }
.state-msg__logo { width: auto; height: auto; max-height: 72px; max-width: 58%; opacity: 0.95; margin-bottom: 16px; }
.state-msg .spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid rgba(229, 220, 255, 0.16);
  border-top-color: var(--magenta-500);
  animation-duration: 0.75s;
}

/* ============================================================================
   6. MOBILE — la barre latérale devient un tiroir ouvert par le bouton menu
   ========================================================================== */

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 264px;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 220ms var(--ease-out);
  }
  .shell.is-menu .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell.is-menu::after { content: ""; position: fixed; inset: 0; background: rgba(14, 8, 35, 0.45); z-index: 79; }
  .topbar { padding: 0 16px; gap: 10px; height: 60px; }
  .topbar__menu { display: inline-flex; }
  .topbar__brand { display: inline-flex; align-items: center; gap: 8px; min-width: 0; text-decoration: none; }
  .topbar__brand img { height: 30px; width: auto; }
  .topbar__search .kbd, .topbar__label { display: none; }
  /* En mobile l'action principale se réduit à son icône : un carré de la
     même taille que les autres boutons de la barre. */
  .topbar .btn { width: 42px; padding: 0; flex: none; }
  /* La recherche prend toute la largeur libre : sans ça, l'espace flexible
     qui la suit creuse un écart plus grand à sa droite qu'à sa gauche. */
  .topbar__search { max-width: none; }
  .topbar__search + .topbar__fill { display: none; }
  .page, .page--wide { padding: 20px 16px 64px; gap: 18px; }
  .page-title { font-size: 24px; }
  .page-title--xl { font-size: 26px; }
  .search { min-width: 0; flex: 1; }
}

@media (max-width: 700px) {
  .lrow { flex-wrap: wrap; padding: 14px 16px; }
  .lrow__side { width: 100%; justify-content: flex-start; }
  .panel__head { padding: 14px 16px; }
}

@media (max-width: 560px) {
  /* Les fenêtres deviennent des feuilles ancrées en bas de l'écran. */
  .overlay:not(.overlay--top) { align-items: flex-end; padding: 0; }
  .overlay:not(.overlay--top) > .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    animation: ssSheetUp 260ms var(--ease-out);
  }
  .modal__head, .modal__body, .modal__foot { padding-left: 18px; padding-right: 18px; }
  .modal__foot .btn { flex: 1 1 auto; }
  .modal__foot-start { flex-basis: 100%; order: 2; }
  .toast { bottom: 20px; }
}
