/* ========================================================================== 
   CHUCK NOURRICE — CONFIGURATEUR / CANEVAS
   --------------------------------------------------------------------------
   Feuille dédiée à users/espace_personnel.php.

   Principes :
   - environnement technique sombre autour d'un plan clair ;
   - vert Chuck réservé aux actions, états actifs et repères ;
   - panneaux compacts, lisibles et cohérents ;
   - conservation des IDs/classes utilisés par le JavaScript existant.
   ========================================================================== */

/* ========================================================================== 
   01. TOKENS / IDENTITÉ
   ========================================================================== */
:root {
  /* Marque */
  --brand: #00cf67;
  --brand-hover: #00b85c;
  --brand-active: #009f50;
  --brand-soft: rgba(0, 207, 103, 0.12);
  --brand-ring: rgba(0, 207, 103, 0.24);

  /* Interface sombre */
  --bg-0: #090d0b;
  --bg-1: #0d1210;
  --bg-2: #121914;
  --bg-3: #18211c;
  --bg-4: #202b25;
  --line: #2d3a33;
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #f3f7f4;
  --text-soft: #c5d0c9;
  --muted: #8e9d95;

  /* Zone de dessin */
  --workspace-bg: #e8eeea;
  --workspace-grid: #dde5e0;
  --canvas-bg: #f9fbfa;
  --canvas-line: #aebbb4;

  /* États */
  --danger: #e05a5a;
  --danger-soft: rgba(224, 90, 90, 0.13);
  --info: #62a8ff;
  --warning: #f3c35a;

  /* Layout */
  --sidebar-w: 280px;
  --canvas-w: 1200px;
  --canvas-h: 800px;
  --header-h: 74px;

  /* Formes */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 11px;
  --radius-lg: 15px;

  /* Ombres */
  --shadow-sm: 0 7px 18px rgba(0, 0, 0, 0.16);
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 24px 68px rgba(0, 0, 0, 0.32);

  /* Typo */
  --font-sans: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

/* ========================================================================== 
   02. RESET / BASE
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg-0);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
  background: var(--bg-1);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-ring);
}

::selection {
  color: #07100b;
  background: rgba(0, 207, 103, 0.34);
}

.hidden,
[hidden] {
  display: none !important;
}

/* Scrollbars */
.toolbar,
.workspace,
.shortcuts--inline,
#paletteDock .palette-content {
  scrollbar-width: thin;
  scrollbar-color: #435048 transparent;
}

.toolbar::-webkit-scrollbar,
.workspace::-webkit-scrollbar,
.shortcuts--inline::-webkit-scrollbar,
#paletteDock .palette-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.toolbar::-webkit-scrollbar-thumb,
.workspace::-webkit-scrollbar-thumb,
.shortcuts--inline::-webkit-scrollbar-thumb,
#paletteDock .palette-content::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #435048;
}

/* ========================================================================== 
   03. TYPOGRAPHIE
   ========================================================================== */
h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.15;
}

h1 {
  font-weight: 850;
  letter-spacing: -0.035em;
}

h2 {
  font-weight: 800;
  letter-spacing: -0.025em;
}

h3 {
  font-weight: 750;
}

/* ========================================================================== 
   04. HEADER / NAVIGATION
   ========================================================================== */
.menu {
  position: relative;
  z-index: 900;
  flex: 0 0 auto;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 20px;
  color: #fff;
  background: rgba(9, 13, 11, 0.98);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.menu::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-hover));
}

.menu h1 {
  position: relative;
  flex: 0 1 auto;
  margin: 0;
  padding: 0 0 0 18px;
  color: #fff;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
  text-transform: none;
  white-space: nowrap;
}

.menu h1::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 7px;
  height: 29px;
  border-radius: 999px;
  background: var(--brand);
  transform: translateY(-50%);
  box-shadow: 0 0 20px rgba(0, 207, 103, 0.28);
}

.menu-items {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  min-width: 0;
}

.menu a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.88rem;
  font-weight: 680;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

.menu a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.075);
  transform: translateY(-1px);
}

.hamburger {
  display: none;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.hamburger div {
  width: 20px;
  height: 2px;
  margin: 0;
  border-radius: 99px;
  background: var(--brand);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ========================================================================== 
   05. LAYOUT PRINCIPAL
   ========================================================================== */
.main-container {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--sidebar-w);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  background: var(--workspace-bg);
}

/* ========================================================================== 
   06. BARRES D'OUTILS
   ========================================================================== */
.toolbar {
  min-width: 0;
  height: 100%;
  padding: 15px 13px;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 160px),
    var(--bg-2);
}

.toolbar-left {
  border-right: 1px solid var(--line);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
}

.toolbar-right {
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
}

.toolbar > h2 {
  position: sticky;
  top: -15px;
  z-index: 4;
  margin: -15px -13px 12px;
  padding: 16px 14px 13px;
  color: #fff;
  background: rgba(18, 25, 20, 0.96);
  border-bottom: 1px solid var(--line);
  font-size: 1.05rem;
  backdrop-filter: blur(10px);
}

.toolbar > h2::after {
  content: "";
  display: block;
  width: 32px;
  height: 3px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--brand);
}

.tool-group {
  margin-bottom: 11px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.tool-group h3 {
  margin: 0 0 9px;
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tool-row button {
  flex: 1 1 calc(50% - 4px);
  min-width: 100px;
}

.toolbar button,
.legend button {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #35443b;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: var(--bg-3);
  box-shadow: none;
  font-weight: 690;
  font-size: 0.79rem;
  line-height: 1.15;
  cursor: pointer;
  transition:
    color 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.toolbar button:hover,
.legend button:hover {
  color: #fff;
  border-color: rgba(0, 207, 103, 0.48);
  background: #1f2c25;
  box-shadow: inset 3px 0 0 var(--brand);
  transform: translateY(-1px);
}

.toolbar button:active,
.legend button:active {
  background: #17211c;
  transform: translateY(0);
}

button.active,
.toolbar button.active {
  color: #06110b;
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 207, 103, 0.12);
}

.toolbar img {
  display: none;
}

.icons-row {
  gap: 9px;
}

/* ========================================================================== 
   07. RECHERCHE / MODE RÉEL-SCHÉMA / COMPOSANTS
   ========================================================================== */
.component-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
}

.component-search input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  min-height: 38px;
  padding: 8px 9px;
  border: 1px solid #38473f;
  border-radius: 8px;
  color: #f5f7f6;
  background: #0e1511;
  outline: none;
  font-size: 0.78rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.component-search input[type="search"]::placeholder {
  color: #708078;
}

.component-search input[type="search"]:focus {
  border-color: var(--brand-hover);
  box-shadow: 0 0 0 3px rgba(0, 207, 103, 0.11);
}

.component-search button#clearComponentSearch {
  flex: 0 0 36px;
  min-width: 36px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: #38473f;
  color: var(--muted);
  background: #151e19;
  font-size: 0.84rem;
}

.component-search button#clearComponentSearch:hover {
  color: #fff;
  border-color: rgba(0, 207, 103, 0.45);
  background: #1b2821;
  box-shadow: none;
}

.components-empty {
  margin-top: 8px;
  padding: 10px;
  border: 1px dashed #39473f;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.78rem;
  text-align: center;
}

.components-mode--mini {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0 0 10px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0e1511;
}

.mode-txt {
  color: #74837b;
  font-size: 0.72rem;
  font-weight: 700;
  user-select: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.mode-txt.is-active {
  color: #fff;
}

.switch-mini {
  position: relative;
  width: 40px;
  height: 22px;
  display: inline-block;
  flex: 0 0 40px;
  cursor: pointer;
  user-select: none;
}

.switch-mini input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.switch-mini .track {
  position: absolute;
  inset: 0;
  border: 1px solid #48564f;
  border-radius: 999px;
  background: #202b25;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.switch-mini .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #d7dfda;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.switch-mini input:checked ~ .track {
  border-color: var(--brand-hover);
  background: rgba(0, 207, 103, 0.18);
}

.switch-mini input:checked ~ .thumb {
  background: var(--brand);
  transform: translateX(18px);
}

/* Grille des composants */
.tool-row.components-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 7px;
}

.btn-component--thumb,
.toolbar .btn-component--thumb {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 64px;
  padding: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #d8e1dc;
  border-radius: 10px;
  color: #101612;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    background-color 0.12s ease;
}

.btn-component--thumb::after,
.toolbar .btn-component--thumb::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.btn-component--thumb:hover,
.toolbar .btn-component--thumb:hover {
  border-color: var(--brand-hover);
  background: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
  transform: translateY(-2px);
}

.btn-component--thumb:hover::after,
.toolbar .btn-component--thumb:hover::after {
  opacity: 1;
}

.btn-component--thumb:active,
.toolbar .btn-component--thumb:active {
  background: #f8fbf9;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(0);
}

.btn-component--thumb .thumb,
.toolbar .btn-component--thumb .thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.tool-row.components-grid .btn-component--thumb {
  flex: none;
  min-width: 0;
}

/* ========================================================================== 
   08. WORKSPACE / CANEVAS
   ========================================================================== */
.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: block;
  overflow: auto;
  padding: 26px;
  background:
    linear-gradient(90deg, rgba(89, 107, 97, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(89, 107, 97, 0.055) 1px, transparent 1px),
    var(--workspace-bg);
  background-size: 28px 28px;
}

.canvas-frame {
  position: relative;
  width: max-content;
  margin: auto;
  padding: 14px;
  border: 1px solid #b9c5be;
  border-radius: 15px;
  background: #d5ddd8;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.8) inset,
    0 18px 44px rgba(42, 56, 48, 0.16);
}

.canvas-frame::before {
  content: "PLAN DE CONCEPTION";
  position: absolute;
  top: -20px;
  left: 6px;
  padding: 3px 7px;
  border-radius: 5px;
  color: #6f7d75;
  background: rgba(232, 238, 234, 0.9);
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.11em;
}

#nourriceCanvas {
  display: block;
  width: var(--canvas-w) !important;
  height: var(--canvas-h) !important;
  max-width: none !important;
  max-height: none !important;
  border: 1px solid var(--canvas-line);
  border-radius: 3px;
  background: var(--canvas-bg);
  box-shadow: 0 8px 24px rgba(42, 56, 48, 0.13);
}

#nourriceCanvasContainer {
  width: 100%;
  height: auto;
}

#nourriceCanvas g.is-selected {
  filter: drop-shadow(0 0 5px rgba(0, 207, 103, 0.95));
}

/* ========================================================================== 
   09. INFOS PROJET / CHAMPS
   ========================================================================== */
.form-grid {
  display: grid;
  gap: 9px;
}

.form-grid label {
  display: grid;
  gap: 5px;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 730;
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 9px;
  border: 1px solid #38473f;
  border-radius: 8px;
  color: #f3f6f4;
  background: #0e1511;
  outline: none;
  font-size: 0.79rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-grid textarea {
  min-height: 68px;
  resize: vertical;
}

.form-grid input:focus,
.form-grid textarea:focus {
  border-color: var(--brand-hover);
  box-shadow: 0 0 0 3px rgba(0, 207, 103, 0.1);
}

/* ========================================================================== 
   10. NOTIFICATION
   ========================================================================== */
.notification {
  position: fixed;
  z-index: 2000;
  top: 18px;
  left: 50%;
  max-width: min(560px, calc(100% - 30px));
  padding: 11px 16px;
  border: 1px solid rgba(0, 207, 103, 0.24);
  border-radius: 10px;
  color: #fff;
  background: rgba(11, 15, 13, 0.95);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(12px);
}

.notification.visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

/* ========================================================================== 
   11. MENU CONTEXTUEL
   ========================================================================== */
.context-menu {
  position: absolute;
  z-index: 1800;
  display: none;
  width: 225px;
  overflow: hidden;
  padding: 6px;
  border: 1px solid #cdd8d1;
  border-radius: 11px;
  color: #18201b;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 48px rgba(11, 15, 13, 0.24);
  backdrop-filter: blur(12px);
}

.context-menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.context-menu ul li,
.context-menu li {
  padding: 8px 10px;
  border-radius: 7px;
  color: #2d3832;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.14s ease, background-color 0.14s ease, opacity 0.14s ease;
}

.context-menu ul li:hover,
.context-menu li:hover {
  color: #08110c;
  background: #e8f9f0;
}

.context-menu .sep,
.context-menu li.sep {
  height: 1px;
  margin: 5px 4px;
  padding: 0;
  background: #e1e7e3;
  pointer-events: none;
}

#ctx-delete:hover {
  color: #9b2d2d;
  background: #fff0f0;
}

/* ========================================================================== 
   12. ÉTATS COPIER / COLLER
   ========================================================================== */
@keyframes chuckFlash {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.18);
  }
}

#ctx-copy.state-copied,
.toolbar-right .btn-copy.state-copied {
  color: #5c4300;
  border-color: rgba(243, 195, 90, 0.55);
  background: #fff4c8;
  animation: chuckFlash 0.75s ease 1;
}

#ctx-paste.state-pasted,
.toolbar-right .btn-paste.state-pasted {
  color: #164c89;
  border-color: rgba(98, 168, 255, 0.5);
  background: #dbeaff;
  animation: chuckFlash 0.75s ease 1;
}

#ctx-paste.state-hasclip,
.toolbar-right .btn-paste.state-hasclip {
  color: #075e38;
  border-color: rgba(0, 184, 92, 0.45);
  background: #dcf8ea;
}

#ctx-paste.is-disabled,
.toolbar-right .btn-paste.is-disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

/* ========================================================================== 
   13. PALETTES FLOTTANTES
   ========================================================================== */
#paletteDock {
  position: fixed;
  z-index: 1200;
  right: calc(var(--sidebar-w) + 18px);
  bottom: 86px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
  pointer-events: none;
}

#paletteDock .floating-palette {
  position: relative !important;
  right: auto !important;
  bottom: auto !important;
  z-index: auto !important;
  pointer-events: auto;
  user-select: none;
}

/* Fallback avant déplacement par le JS */
.canvas-frame > .floating-palette {
  position: absolute;
  z-index: 20;
  right: 22px;
  bottom: 22px;
}

.canvas-frame > #toolsPalette {
  bottom: 74px;
}

#paletteDock .palette-toggle,
.canvas-frame > .floating-palette .palette-toggle {
  min-width: 44px;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid #35443b;
  border-radius: 11px;
  color: #fff;
  background: rgba(13, 18, 16, 0.93);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-weight: 800;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

#paletteDock .palette-toggle:hover,
.canvas-frame > .floating-palette .palette-toggle:hover {
  border-color: rgba(0, 207, 103, 0.52);
  background: #162019;
  transform: translateY(-1px);
}

#paletteDock .floating-palette .palette-panel {
  display: none;
  width: min(350px, 92vw);
  overflow: hidden;
  border: 1px solid #35443b;
  border-radius: 13px;
  color: #fff;
  background: rgba(13, 18, 16, 0.96);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
}

#paletteDock .floating-palette.is-open .palette-panel {
  display: block;
}

/* Certaines versions du JS ouvrent directement .palette-content sans wrapper. */
#paletteDock .floating-palette .palette-content,
.canvas-frame > .floating-palette .palette-content {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  width: min(340px, 90vw);
  max-height: min(58vh, 520px);
  margin-bottom: 6px;
  padding: 9px;
  overflow: auto;
  border: 1px solid #35443b;
  border-radius: 12px;
  background: rgba(13, 18, 16, 0.97);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
}

#paletteDock .floating-palette.is-open .palette-content,
#paletteDock .floating-palette:not(.collapsed) .palette-content,
.canvas-frame > .floating-palette:not(.collapsed) .palette-content {
  display: grid;
}

#paletteDock .floating-palette .palette-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 18, 16, 0.98);
}

#paletteDock .floating-palette .palette-title {
  color: #fff;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.02em;
}

#paletteDock .floating-palette .palette-close {
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid #3b4942;
  border-radius: 8px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

#paletteDock .floating-palette .palette-content button,
.canvas-frame > .floating-palette .palette-content button {
  min-height: 38px;
  padding: 8px 9px;
  border: 1px solid #344239;
  border-radius: 8px;
  color: var(--text-soft);
  background: #18211c;
  text-align: left;
  font-size: 0.76rem;
  font-weight: 670;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

#paletteDock .floating-palette .palette-content button:hover,
.canvas-frame > .floating-palette .palette-content button:hover {
  color: #fff;
  border-color: rgba(0, 207, 103, 0.48);
  background: #203027;
}

#paletteDock .palette--shapes .palette-content,
.canvas-frame > .palette--shapes .palette-content {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#paletteDock .palette--shapes .palette-content button,
.canvas-frame > .palette--shapes .palette-content button {
  min-height: 48px;
  text-align: center;
  font-size: 1rem;
}

/* ========================================================================== 
   14. FOOTER / LÉGENDE DU CONFIGURATEUR
   ========================================================================== */
.legend {
  position: relative;
  z-index: 700;
  flex: 0 0 auto;
  padding: 10px 14px;
  color: var(--text-soft);
  background:
    linear-gradient(90deg, #0b100d 0%, #111813 48%, #0b100d 100%);
  border-top: 1px solid rgba(0, 207, 103, 0.28);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.22);
  transition: padding 0.2s ease, box-shadow 0.2s ease;
}

.legend.legend--compact {
  padding: 9px 13px;
}

.legend__row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 46px;
}

.project-title--slim {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
}

.project-label {
  color: var(--brand);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.project-name {
  max-width: 300px;
  overflow: hidden;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shortcuts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.shortcuts--inline {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  overflow-x: auto;
  padding: 0 4px 2px;
  white-space: nowrap;
}

.shortcuts--inline li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  color: #9caaa2;
  font-size: 0.7rem;
}

.shortcuts--inline li + li {
  border-left: 1px solid rgba(255, 255, 255, 0.075);
}

.shortcuts--inline li:hover {
  color: #dce4df;
}

kbd {
  padding: 3px 5px;
  border: 1px solid #39483f;
  border-bottom-color: #2d3932;
  border-radius: 5px;
  color: #eaf0ec;
  background: #1a231e;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  font-family: var(--font-mono);
  font-size: 0.9em;
  line-height: 1;
}

.toolbar-actions--tight {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-actions--tight button,
.legend .toggle-footer {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #344239;
  border-radius: 8px;
  color: #dce5df;
  background: #19221d;
  box-shadow: none;
  font-size: 0.74rem;
  font-weight: 720;
}

.toolbar-actions--tight button:hover,
.legend .toggle-footer:hover {
  color: #fff;
  border-color: rgba(0, 207, 103, 0.52);
  background: #203027;
  box-shadow: inset 3px 0 0 var(--brand);
}

.legend .toggle-footer {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.88rem;
}

/* États de réduction : les deux noms sont conservés car le JS a connu
   plusieurs versions (.collapsed et .is-collapsed). */
.legend.collapsed,
.legend.is-collapsed {
  padding-top: 5px !important;
  padding-bottom: 5px !important;
  box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.18);
}

.legend.collapsed .project-title,
.legend.collapsed .shortcuts--inline,
.legend.is-collapsed .shortcuts {
  display: none;
}

.legend.collapsed .toolbar-actions--tight {
  margin-left: auto;
}

.legend.collapsed .toggle-footer {
  transform: rotate(180deg);
}

.legend.is-collapsed .legend__row {
  min-height: 36px;
  gap: 8px;
}

.legend.is-collapsed .project-title {
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.touchOnly {
  display: none;
}

@media (pointer: coarse) {
  .touchOnly {
    display: inline-flex;
  }
}

/* ========================================================================== 
   15. COOKIES — SI LA BANNIÈRE EST PRÉSENTE DANS L'ÉDITEUR
   ========================================================================== */
.cookie-banner,
#cookie-banner {
  position: fixed !important;
  z-index: 2200 !important;
  right: 16px !important;
  bottom: 16px !important;
  left: auto !important;
  width: min(430px, calc(100% - 32px)) !important;
  padding: 16px !important;
  border: 1px solid #344239 !important;
  border-radius: 12px !important;
  color: #fff !important;
  background: rgba(9, 13, 11, 0.97) !important;
  box-shadow: var(--shadow-lg) !important;
  text-align: left !important;
}

.cookie-banner p,
#cookie-banner p {
  margin: 0 0 10px;
  color: var(--text-soft);
}

.cookie-banner a,
#cookie-banner a {
  color: var(--brand) !important;
}

.cookie-banner button,
#cookie-banner button {
  min-height: 34px;
  margin: 0 5px 0 0 !important;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #06110b;
  background: var(--brand);
  font-weight: 760;
  cursor: pointer;
}

#decline-cookies {
  color: #fff !important;
  border-color: #38473f !important;
  background: #17201b !important;
}

/* ========================================================================== 
   16. RESPONSIVE DESKTOP / TABLETTE
   ========================================================================== */
@media (max-width: 1380px) {
  :root {
    --sidebar-w: 250px;
  }

  .toolbar {
    padding-inline: 11px;
  }

  .toolbar > h2 {
    margin-inline: -11px;
    padding-inline: 12px;
  }

  .tool-row button {
    min-width: 92px;
    font-size: 0.75rem;
  }

  .project-name {
    max-width: 230px;
  }
}

@media (max-width: 1160px) {
  :root {
    --sidebar-w: 218px;
  }

  .menu a {
    padding-inline: 7px;
    font-size: 0.82rem;
  }

  .toolbar {
    padding: 11px 9px;
  }

  .toolbar > h2 {
    top: -11px;
    margin: -11px -9px 10px;
    padding: 13px 10px 11px;
  }

  .tool-group {
    padding: 8px;
  }

  .tool-row {
    gap: 5px;
  }

  .tool-row button {
    flex-basis: 100%;
    min-width: 0;
  }

  .tool-row.components-grid {
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  }

  .btn-component--thumb,
  .toolbar .btn-component--thumb {
    height: 58px;
  }

  .shortcuts--inline li {
    padding-inline: 7px;
  }
}

@media (max-width: 940px) {
  :root {
    --sidebar-w: 190px;
  }

  .menu {
    min-height: 68px;
    flex-wrap: wrap;
    padding: 9px 12px;
  }

  .menu h1 {
    max-width: calc(100% - 56px);
    overflow: hidden;
    font-size: 0.98rem;
    text-overflow: ellipsis;
  }

  .hamburger {
    display: flex;
    margin-left: auto;
  }

  .menu-items {
    display: none;
    flex: 0 0 100%;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--line-soft);
  }

  .menu.active .menu-items {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    background: transparent;
  }

  .menu.active .hamburger div:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .menu.active .hamburger div:nth-child(2) {
    opacity: 0;
  }

  .menu.active .hamburger div:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .menu-items a {
    width: 100%;
    justify-content: flex-start;
  }

  .project-label {
    display: none;
  }

  .project-name {
    max-width: 170px;
  }

  #paletteDock {
    right: calc(var(--sidebar-w) + 12px);
  }
}

/* ========================================================================== 
   17. RESPONSIVE MOBILE — MODE DÉGRADÉ ASSUMÉ
   --------------------------------------------------------------------------
   L'éditeur reste prioritairement conçu pour ordinateur. Sur petit écran,
   on conserve la palette composants + le plan et on masque le panneau droit.
   ========================================================================== */
@media (max-width: 780px) {
  :root {
    --sidebar-w: 82px;
  }

  .main-container {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .toolbar-left {
    padding: 8px 6px;
  }

  .toolbar-right {
    display: none;
  }

  .toolbar-left > h2,
  .toolbar-left .tool-group > h3,
  .components-mode--mini,
  .component-search {
    display: none;
  }

  .toolbar-left .tool-group {
    margin: 0;
    padding: 6px;
    border: 0;
    background: transparent;
  }

  .tool-row.components-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .btn-component--thumb,
  .toolbar .btn-component--thumb {
    width: 58px;
    height: 58px;
    margin-inline: auto;
  }

  .workspace {
    padding: 20px 14px;
  }

  .canvas-frame {
    margin: 0;
  }

  #paletteDock {
    right: 12px;
    bottom: 70px;
  }

  .project-title--slim {
    display: none;
  }

  .legend__row {
    gap: 7px;
  }

  .shortcuts--inline {
    display: none;
  }

  .toolbar-actions--tight {
    width: 100%;
    justify-content: flex-end;
  }

  .toolbar-actions--tight button {
    padding-inline: 8px;
    font-size: 0.7rem;
  }
}

@media (max-width: 520px) {
  :root {
    --sidebar-w: 70px;
  }

  .menu.active .menu-items {
    grid-template-columns: 1fr 1fr;
  }

  .menu h1 {
    max-width: calc(100% - 54px);
    padding-left: 14px;
    font-size: 0.88rem;
  }

  .menu h1::before {
    width: 5px;
    height: 24px;
  }

  .toolbar-left {
    padding-inline: 3px;
  }

  .btn-component--thumb,
  .toolbar .btn-component--thumb {
    width: 54px;
    height: 54px;
  }

  .legend {
    padding-inline: 7px;
  }

  .toolbar-actions--tight button:nth-child(1) {
    display: none;
  }

  .cookie-banner,
  #cookie-banner {
    right: 8px !important;
    bottom: 8px !important;
    width: calc(100% - 16px) !important;
  }
}

/* Compatibilité avec une ancienne sidebar générique éventuellement injectée. */
.sidebar {
  width: var(--sidebar-w);
  min-width: 0;
  color: var(--text);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
}

.sidebar ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar li {
  margin-bottom: 6px;
}

/* ========================================================================== 
   18. ACCESSIBILITÉ / MOUVEMENT
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
