/* ==========================================================================
   Studio Bourgade — Gestionnaire
   Systeme de design MAISON (aucun framework, aucun CDN).
   Contrat visuel canonique : tous les ecrans reutilisent ces tokens/classes.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Polices — self-host optionnel.
   Par defaut on s'appuie sur la stack systeme (voir --font-sans / --font-mono).
   Pour activer les vraies polices, deposez les .woff2 dans public/fonts/ et
   decommentez les @font-face ci-dessous.
   --------------------------------------------------------------------------
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
   -------------------------------------------------------------------------- */

/* ==========================================================================
   1. TOKENS (variables CSS)
   ========================================================================== */

:root {
  /* ---- Couleurs : surfaces & fond ---- */
  --background: #faf8ff;              /* canvas de l'application */
  --surface: #ffffff;                /* surfaces elevees (listes, panneaux) */
  --surface-dim: #d9d9e5;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f3f3fe;
  --surface-container: #ededf9;      /* entetes de tableau, zones sobres */
  --surface-container-high: #e7e7f3;
  --surface-container-highest: #e1e2ed;
  --surface-variant: #e1e2ed;
  --inverse-surface: #2e3039;        /* fond sombre (apercu code) */
  --inverse-on-surface: #f0f0fb;

  /* ---- Couleurs : texte ---- */
  --text: #191b23;                   /* texte principal / titres */
  --text-variant: #434655;           /* metadonnees, texte secondaire */
  --text-disabled: #737686;

  /* ---- Couleurs : accent primaire (bleu, accent UNIQUE) ---- */
  --primary: #2563eb;                /* boutons primaires, selection, focus, progression */
  --primary-strong: #004ac6;         /* survol / actif du primaire */
  --on-primary: #ffffff;
  --primary-container: #dbe1ff;
  --on-primary-container: #00174b;
  --primary-tint-10: rgba(37, 99, 235, 0.10);   /* fond de ligne selectionnee */
  --primary-tint-06: rgba(37, 99, 235, 0.06);   /* survol subtil teinte primaire */

  /* ---- Couleurs : secondaire ---- */
  --secondary: #495c95;
  --on-secondary: #ffffff;
  --secondary-container: #dbe1ff;
  --on-secondary-container: #394c84;

  /* ---- Couleurs : tertiaire (brun-orange — JAMAIS un succes) ---- */
  --tertiary: #943700;
  --on-tertiary: #ffffff;
  --tertiary-container: #ffdbcd;
  --on-tertiary-container: #7d2d00;

  /* ---- Couleurs : erreur ---- */
  --error: #ba1a1a;
  --on-error: #ffffff;
  --error-container: #ffdad6;
  --on-error-container: #93000a;

  /* ---- Couleurs : succes (VERT — ajoute au systeme, absent de la maquette) ---- */
  --success: #0f7a52;
  --on-success: #ffffff;
  --success-container: #d7f5e6;
  --on-success-container: #0b5a3c;

  /* ---- Couleurs : bordures & contours ---- */
  --outline: #737686;                /* contour marque (icones, focus secondaire) */
  --border: #c3c6d7;                 /* separateur principal 1px (IDE-style) */
  --border-subtle: #e1e2ed;          /* separateur tres leger (lignes de tableau) */

  /* ---- Typographie ---- */
  --font-sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Echelle typographique (taille / hauteur de ligne / graisse / interlettrage) */
  --fs-headline-lg: 20px;  --lh-headline-lg: 28px;  --ls-headline-lg: -0.02em;
  --fs-headline-md: 16px;  --lh-headline-md: 24px;  --ls-headline-md: -0.01em;
  --fs-body-md: 14px;      --lh-body-md: 20px;      --ls-body-md: -0.01em;
  --fs-body-sm: 13px;      --lh-body-sm: 18px;      --ls-body-sm: 0em;
  --fs-label-md: 12px;     --lh-label-md: 16px;     --ls-label-md: 0em;
  --fs-label-xs: 11px;     --lh-label-xs: 14px;     --ls-label-xs: 0.02em;

  /* ---- Rayons ---- */
  --r-sm: 2px;
  --r: 4px;                /* rayon par defaut : boutons, inputs, cards, checkbox */
  --r-md: 6px;
  --r-lg: 8px;
  --r-full: 9999px;

  /* ---- Espacement (base 4px) ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* ---- Dimensions structurelles ---- */
  --row-height: 34px;             /* hauteur d'une ligne de fichier */
  --table-head-height: 32px;      /* hauteur de l'entete de tableau sticky */
  --topbar-height: 52px;
  --toolbar-height: 52px;
  --statusbar-height: 32px;
  --sidebar-width: 256px;
  --inspector-width: 300px;

  /* ---- Ombres (uniquement modales / menus flottants) ---- */
  --shadow-modal: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-menu: 0 4px 12px rgba(0, 0, 0, 0.12);

  /* ---- Anneau de focus ---- */
  --focus-ring: 0 0 0 1px var(--primary);

  /* ---- Transitions ---- */
  --transition: 120ms ease;
}

/* ==========================================================================
   2. RESET LEGER & BASE
   ========================================================================== */

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body-md);
  line-height: var(--lh-body-md);
  letter-spacing: var(--ls-body-md);
  color: var(--text);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

img { max-width: 100%; display: block; }

::selection { background: var(--primary-tint-10); }

/* ==========================================================================
   3. UTILITAIRES TYPOGRAPHIQUES
   ========================================================================== */

.headline-lg { font-size: var(--fs-headline-lg); line-height: var(--lh-headline-lg); letter-spacing: var(--ls-headline-lg); font-weight: 600; }
.headline-md { font-size: var(--fs-headline-md); line-height: var(--lh-headline-md); letter-spacing: var(--ls-headline-md); font-weight: 600; }
.body-md { font-size: var(--fs-body-md); line-height: var(--lh-body-md); }
.body-sm { font-size: var(--fs-body-sm); line-height: var(--lh-body-sm); color: var(--text-variant); }

/* Donnees techniques : TOUJOURS en mono (tailles, dates, chemins, permissions, codes) */
.mono { font-family: var(--font-mono); }
.label-md { font-family: var(--font-mono); font-size: var(--fs-label-md); line-height: var(--lh-label-md); font-weight: 500; }
.label-xs { font-family: var(--font-mono); font-size: var(--fs-label-xs); line-height: var(--lh-label-xs); letter-spacing: var(--ls-label-xs); }

/* Label d'entete en MAJUSCULES (mono) */
.label-head {
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-variant);
}

.text-variant { color: var(--text-variant); }
.text-muted { color: var(--text-disabled); }

/* Icone generique (herite de la couleur du texte) */
.icon { display: inline-block; vertical-align: middle; flex: none; color: currentColor; }
.icon svg { display: block; }

/* ==========================================================================
   4. LAYOUT — SHELL APPLICATION
   ========================================================================== */

/* Grille principale : topbar (haut) / corps (sidebar + main + inspecteur) / status (bas) */
.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-height) 1fr var(--statusbar-height);
  grid-template-columns: var(--sidebar-width) 1fr var(--inspector-width);
  grid-template-areas:
    "topbar    topbar    topbar"
    "sidebar   main      inspector"
    "statusbar statusbar statusbar";
  height: 100vh;
  overflow: hidden;
}

.app-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.app-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;               /* autorise le retrecissement du contenu fluide */
  background: var(--background);
  overflow: hidden;
}

.app-inspector {
  grid-area: inspector;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

/* Barre d'etat basse */
.status-bar {
  grid-area: statusbar;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-4);
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--fs-label-xs);
  letter-spacing: var(--ls-label-xs);
  color: var(--text-variant);
}
.status-bar__sep { color: var(--border); }
.status-bar__spacer { margin-left: auto; }
.status-bar__dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: var(--r-full);
  background: var(--success);
  margin-right: var(--sp-1);
}

/* ==========================================================================
   5. LAYOUT — SHELL AUTHENTIFICATION
   ========================================================================== */

.auth-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-6);
  background: var(--background);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-8);
  box-shadow: var(--shadow-modal);
}

.auth-card__logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  color: var(--primary);
}
.auth-card__title { margin: 0 0 var(--sp-2); }
.auth-card__subtitle { margin: 0 0 var(--sp-6); color: var(--text-variant); font-size: var(--fs-body-sm); }

.auth-footer {
  margin-top: var(--sp-6);
  display: flex;
  gap: var(--sp-4);
  justify-content: center;
  font-size: var(--fs-body-sm);
  color: var(--text-variant);
}

/* ==========================================================================
   6. TOPBAR — MARQUE, ONGLETS, ACTIONS
   ========================================================================== */

.app-topbar__brand {
  font-size: var(--fs-headline-md);
  font-weight: 600;
  letter-spacing: var(--ls-headline-md);
  white-space: nowrap;
}

.app-topbar__spacer { margin-left: auto; }

.app-topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

/* Onglets de navigation (style souligne) */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  height: 100%;
}
.nav-tab {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 var(--sp-3);
  border: none;
  background: none;
  color: var(--text-variant);
  font-size: var(--fs-body-md);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.nav-tab:hover { color: var(--text); }
.nav-tab--active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

/* ==========================================================================
   7. SIDEBAR — ESPACE DE TRAVAIL, NAVIGATION, STOCKAGE
   ========================================================================== */

.app-sidebar__workspace {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
}
.app-sidebar__workspace-icon { color: var(--primary); flex: none; }
.app-sidebar__workspace-name { font-weight: 600; font-size: var(--fs-body-md); }
.app-sidebar__workspace-sub { color: var(--text-variant); font-size: var(--fs-body-sm); }

.app-sidebar__nav { padding: var(--sp-2); flex: 1 1 auto; }
.app-sidebar__footer {
  padding: var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* Navigation laterale (elements plats, coins nets) */
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--row-height);
  padding: 0 var(--sp-3);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--text-variant);
  font-size: var(--fs-body-md);
  cursor: pointer;
  border-radius: var(--r);
  border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition);
}
.side-nav__item:hover { background: var(--surface-container-low); color: var(--text); }
.side-nav__item--active {
  background: var(--primary-tint-10);
  color: var(--primary);
  font-weight: 500;
  border-left-color: var(--primary);
  border-radius: 0 var(--r) var(--r) 0;
}
.side-nav__item .icon { flex: none; }

/* ==========================================================================
   8. FIL D'ARIANE (BREADCRUMB)
   ========================================================================== */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  height: var(--toolbar-height);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  color: var(--text-variant);
  overflow-x: auto;
  white-space: nowrap;
}
.breadcrumb__item {
  color: var(--text-variant);
  padding: 2px var(--sp-1);
  border-radius: var(--r-sm);
}
a.breadcrumb__item:hover { color: var(--primary); text-decoration: none; background: var(--surface-container-low); }
.breadcrumb__item--current { color: var(--text); font-weight: 500; }
.breadcrumb__sep { color: var(--border); flex: none; }

/* ==========================================================================
   9. BARRE D'OUTILS (TOOLBAR)
   ========================================================================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--toolbar-height);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
}
.toolbar__group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.toolbar__spacer { margin-left: auto; }
.toolbar__sep {
  width: 1px;
  align-self: stretch;
  margin: var(--sp-2) 0;
  background: var(--border);
}

/* ==========================================================================
   10. BOUTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 36px;
  padding: 0 var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--r);
  background: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body-md);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn .icon { flex: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
.btn--primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }

.btn--secondary {
  background: var(--surface);
  color: var(--text-variant);
  border-color: var(--border);
}
.btn--secondary:hover { background: var(--surface-container-low); color: var(--text); }

.btn--ghost {
  background: none;
  color: var(--text-variant);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--surface-container); color: var(--text); }

.btn--danger {
  background: var(--error-container);
  color: var(--on-error-container);
  border-color: transparent;
}
.btn--danger:hover { background: var(--error); color: var(--on-error); }

/* Bouton icone carre (barre d'outils) */
.btn--icon { width: 36px; padding: 0; }

.btn--sm { height: 30px; padding: 0 var(--sp-2); font-size: var(--fs-body-sm); }
.btn--sm.btn--icon { width: 30px; }

.btn--block { width: 100%; }

/* ==========================================================================
   11. CHAMPS DE SAISIE & RECHERCHE
   ========================================================================== */

.input {
  height: 36px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body-md);
  width: 100%;
}
.input::placeholder { color: var(--text-disabled); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field__label {
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  font-weight: 500;
  color: var(--text-variant);
}

/* Recherche : icone incrustee a gauche */
.search { position: relative; display: inline-flex; align-items: center; }
.search__icon {
  position: absolute;
  left: var(--sp-2);
  color: var(--text-disabled);
  pointer-events: none;
  display: inline-flex;
}
.search .input { padding-left: 30px; }

/* ==========================================================================
   12. FILTRES (CHIPS)
   ========================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: 30px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-variant);
  font-size: var(--fs-body-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip:hover { background: var(--surface-container-low); color: var(--text); }
.chip--active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

/* ==========================================================================
   13. TABLEAU DE FICHIERS
   ========================================================================== */

.file-list {
  flex: 1 1 auto;
  overflow: auto;
  background: var(--surface);
}

/* Grille de colonnes partagee par l'entete et les lignes.
   [checkbox] [nom fluide] [taille] [date] [actions] */
.file-list__head,
.file-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 110px 200px 44px;
  align-items: center;
}

.file-list__head {
  position: sticky;
  top: 0;
  z-index: 2;
  height: var(--table-head-height);
  background: var(--surface-container);
  border-bottom: 1px solid var(--border);
}
.file-list__head .file-cell { color: var(--text-variant); }

.file-row {
  height: var(--row-height);
  border-bottom: 1px solid var(--border-subtle);
  border-left: 2px solid transparent;
  cursor: default;
  transition: background var(--transition);
}
.file-row:hover { background: var(--surface-container-low); }
.file-row--selected {
  background: var(--primary-tint-10);
  border-left-color: var(--primary);
}
.file-row--selected:hover { background: var(--primary-tint-10); }

.file-cell {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Colonnes nommees */
.col-check { justify-content: center; padding: 0; }
.col-name { gap: var(--sp-2); }
.col-name__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-size,
.col-date,
.col-type {
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  color: var(--text-variant);
}
.col-size { justify-content: flex-end; text-align: right; }
.col-actions { justify-content: center; padding: 0; }

/* Icone de type de fichier dans la colonne nom */
.file-icon { flex: none; color: var(--text-variant); }
.file-icon--folder { color: var(--primary); }

/* Entete : labels MAJUSCULES mono */
.file-list__head .col-name,
.file-list__head .col-size,
.file-list__head .col-date,
.file-list__head .col-type {
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-variant);
}

/* --- Vue GRILLE (bascule liste/grille) --- */
.file-grid {
  flex: 1 1 auto;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface);
  align-content: start;
}
.file-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: default;
  transition: background var(--transition), border-color var(--transition);
}
.file-card:hover { background: var(--surface-container-low); border-color: var(--border); }
.file-card--selected { background: var(--primary-tint-10); border-color: var(--primary); }
.file-card__name {
  font-size: var(--fs-body-sm);
  text-align: center;
  word-break: break-word;
}
.file-card__meta { font-family: var(--font-mono); font-size: var(--fs-label-xs); color: var(--text-variant); }

/* ==========================================================================
   14. CASE A COCHER
   ========================================================================== */

.checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1px solid var(--outline);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  position: relative;
  flex: none;
  transition: background var(--transition), border-color var(--transition);
}
.checkbox:hover { border-color: var(--primary); }
.checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 3px; height: 7px;
  border: solid var(--on-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.checkbox:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ==========================================================================
   15. BADGES / PASTILLES
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-label-xs);
  font-weight: 500;
  letter-spacing: var(--ls-label-xs);
}
.badge--success { background: var(--success-container); color: var(--on-success-container); }
.badge--error { background: var(--error-container); color: var(--on-error-container); }
.badge--neutral { background: var(--surface-container-high); color: var(--text-variant); }

/* ==========================================================================
   16. MENU CONTEXTUEL (CLIC DROIT)
   ========================================================================== */

.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  padding: var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-menu);
}
.context-menu[hidden] { display: none; }
.context-menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  height: 32px;
  padding: 0 var(--sp-2);
  border: none;
  background: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body-sm);
  text-align: left;
  cursor: pointer;
  border-radius: var(--r);
}
.context-menu__item:hover { background: var(--surface-container-low); }
.context-menu__item .icon { flex: none; color: var(--text-variant); }
.context-menu__item--danger { color: var(--error); }
.context-menu__item--danger .icon { color: var(--error); }
.context-menu__item--danger:hover { background: var(--error-container); }
.context-menu__item:disabled { opacity: 0.45; cursor: not-allowed; }
.context-menu__shortcut {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-label-xs);
  color: var(--text-disabled);
}
.context-menu__sep {
  height: 1px;
  margin: var(--sp-1) 0;
  background: var(--border-subtle);
}

/* ==========================================================================
   17. MODALES
   ========================================================================== */

.modal[hidden] { display: none; }
.modal__overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(25, 27, 35, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}
.modal__panel {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.modal__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.modal__title { margin: 0; font-size: var(--fs-headline-md); font-weight: 600; }
.modal__close {
  margin-left: auto;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: none; color: var(--text-variant);
  border-radius: var(--r); cursor: pointer;
}
.modal__close:hover { background: var(--surface-container); color: var(--text); }
.modal__body {
  padding: var(--sp-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   18. BARRE DE PROGRESSION
   ========================================================================== */

.progress {
  width: 100%;
  height: 6px;
  background: var(--surface-container-high);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: var(--r-full);
  transition: width var(--transition);
}
.progress__bar--success { background: var(--success); }
.progress__bar--error { background: var(--error); }

/* Ligne d'upload (nom + progression + etat) */
.upload-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
}
.upload-item__meta {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}
.upload-item__name { font-size: var(--fs-body-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item__status { font-family: var(--font-mono); font-size: var(--fs-label-xs); color: var(--text-variant); }

/* ==========================================================================
   19. DROPZONE (GLISSER-DEPOSER)
   ========================================================================== */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-4);
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-container-low);
  color: var(--text-variant);
  text-align: center;
  transition: background var(--transition), border-color var(--transition);
}
.dropzone__icon { color: var(--text-disabled); }
.dropzone--over {
  border-color: var(--primary);
  background: var(--primary-tint-06);
  color: var(--primary);
}
.dropzone--over .dropzone__icon { color: var(--primary); }

/* ==========================================================================
   20. SQUELETTE DE CHARGEMENT (SKELETON)
   ========================================================================== */

.skeleton {
  background: var(--surface-container);
  border-radius: var(--r);
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: skeleton-shimmer 1.4s infinite;
}
.skeleton--text { height: 12px; }
@keyframes skeleton-shimmer {
  100% { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
}

/* ==========================================================================
   21. ETAT VIDE
   ========================================================================== */

.empty-state {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-8);
  text-align: center;
  color: var(--text-variant);
}
.empty-state__icon {
  color: var(--text-disabled);
  margin-bottom: var(--sp-2);
}
.empty-state__title { font-size: var(--fs-headline-md); font-weight: 600; color: var(--text); }
.empty-state__text { font-size: var(--fs-body-sm); max-width: 320px; }

/* ==========================================================================
   22. INSPECTEUR (PANNEAU DROIT)
   ========================================================================== */

.inspector__header {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
}
.inspector__title { margin: 0; font-size: var(--fs-headline-md); font-weight: 600; }
.inspector__subtitle { margin: var(--sp-1) 0 0; font-size: var(--fs-body-sm); color: var(--text-variant); }

.inspector__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.inspector__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  background: var(--surface-container-low);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--text-disabled);
}
.inspector__preview img { max-height: 200px; border-radius: var(--r); }
.inspector__preview-name {
  padding: var(--sp-2);
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  color: var(--text-variant);
  border-top: 1px solid var(--border-subtle);
}

.inspector__section-label {
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-variant);
  margin-bottom: var(--sp-2);
}

/* Ligne propriete : libelle a gauche, valeur a droite */
.inspector__prop {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-1) 0;
  font-size: var(--fs-body-sm);
}
.inspector__prop-key { color: var(--text-variant); }
.inspector__prop-value { color: var(--text); text-align: right; }
.inspector__prop-value--mono { font-family: var(--font-mono); font-size: var(--fs-label-md); }

/* Bloc de code (apercu) sur fond sombre */
.inspector__code {
  background: var(--inverse-surface);
  color: var(--inverse-on-surface);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

.inspector__footer {
  padding: var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* ==========================================================================
   23. EDITEUR DE FICHIER TEXTE
   ========================================================================== */

.editor {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--surface);
}
.editor__tabbar {
  display: flex;
  align-items: center;
  height: var(--table-head-height);
  background: var(--surface-container);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--sp-2);
  gap: var(--sp-1);
}
.editor__tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 26px;
  padding: 0 var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r) var(--r) 0 0;
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  color: var(--text);
}
.editor__body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  line-height: 1.6;
}
/* Gouttiere de numeros de ligne */
.editor__gutter {
  flex: none;
  padding: var(--sp-3) var(--sp-2);
  text-align: right;
  color: var(--text-disabled);
  background: var(--surface-container-low);
  border-right: 1px solid var(--border-subtle);
  user-select: none;
}
.editor__line-no { display: block; }
.editor__code {
  flex: 1 1 auto;
  padding: var(--sp-3);
  white-space: pre;
  color: var(--text);
  tab-size: 4;
}
.editor__statusbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  height: var(--statusbar-height);
  padding: 0 var(--sp-4);
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--fs-label-xs);
  color: var(--text-variant);
}

/* Coloration syntaxique basique (jetons neutres, purement decoratifs) */
.tok-key { color: var(--primary); }
.tok-str { color: var(--success); }
.tok-num { color: var(--tertiary); }
.tok-com { color: var(--text-disabled); font-style: italic; }
.tok-fn  { color: var(--secondary); }

/* ==========================================================================
   24. WIDGET DE STOCKAGE
   ========================================================================== */

.storage-widget { display: flex; flex-direction: column; gap: var(--sp-2); }
.storage-widget__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
}
.storage-widget__label {
  font-family: var(--font-mono);
  font-size: var(--fs-label-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-variant);
}
.storage-widget__value {
  font-family: var(--font-mono);
  font-size: var(--fs-label-md);
  font-weight: 500;
  color: var(--text);
}
.storage-widget__bar {
  height: 6px;
  background: var(--surface-container-high);
  border-radius: var(--r-full);
  overflow: hidden;
}
.storage-widget__bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
}
.storage-widget__caption {
  font-family: var(--font-mono);
  font-size: var(--fs-label-xs);
  color: var(--text-variant);
}

/* ==========================================================================
   25. AVATAR
   ========================================================================== */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-size: var(--fs-label-xs);
  font-weight: 600;
  flex: none;
  border: 1px solid var(--surface);
}
.avatar-group { display: inline-flex; }
.avatar-group .avatar:not(:first-child) { margin-left: -8px; }

/* ==========================================================================
   26. DRAWER MOBILE (SIDEBAR HORS-CANVAS) & BOTTOM NAV
   ========================================================================== */

/* Voile affiche derriere la sidebar en mode drawer */
.app-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(25, 27, 35, 0.32);
}

/* Barre d'onglets basse (mobile) : masquee par defaut */
.app-bottombar { display: none; }

/* ==========================================================================
   27. RESPONSIVE
   ========================================================================== */

/* Sous ~1100px : l'inspecteur se replie. */
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas:
      "topbar    topbar"
      "sidebar   main"
      "statusbar statusbar";
  }
  .app-inspector { display: none; }
  /* Fable5/UI : l'inspecteur peut etre reaffiche en superposition si besoin. */
}

/* Sous ~760px : la sidebar devient un drawer hors-canvas + barre d'onglets basse. */
@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr auto var(--statusbar-height);
    grid-template-areas:
      "topbar"
      "main"
      "bottombar"
      "statusbar";
  }

  .app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    max-width: 84vw;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-modal);
  }
  .app-sidebar--open { transform: translateX(0); }
  .app-sidebar--open ~ .app-scrim,
  .app-scrim.app-scrim--visible { display: block; }

  /* Barre d'onglets basse visible en mobile */
  .app-bottombar {
    grid-area: bottombar;
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 52px;
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  .app-bottombar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border: none;
    background: none;
    color: var(--text-variant);
    font-size: var(--fs-label-xs);
    cursor: pointer;
    padding: var(--sp-1);
  }
  .app-bottombar__item--active { color: var(--primary); }

  /* Bouton d'ouverture du drawer visible dans la topbar */
  .app-topbar__menu-btn { display: inline-flex; }

  /* Onglets centraux masques sur mobile (repris dans la barre basse) */
  .nav-tabs { display: none; }
}

/* Le bouton menu (hamburger) n'est visible qu'en mobile */
.app-topbar__menu-btn { display: none; }
@media (max-width: 760px) {
  .app-topbar__menu-btn { display: inline-flex; }
}
