:root {
  --bg: #e8eaed;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #d1d5db;
  --text: #1f2937;
  --text-muted: #6b7280;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --dark: #111827;
  --danger: #dc2626;
  --gap: 6px;
  --pad: 8px;
  --radius: 4px;
  --library-w: 220px;
  --props-w: 220px;
  --topbar-h: 48px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* —— Accueil —— */
body.is-home .workspace {
  display: none;
}

body:not(.is-home) .screen-home {
  display: none;
}

.screen-home {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: linear-gradient(160deg, #a6b5c5 0%, #fff 48%, #fff 100%);
  overflow: auto;
  font-family: Manrope, "Segoe UI", system-ui, sans-serif;
}

.home-pattern {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.home-pattern::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 65% 50% at 50% 40%, rgba(248, 250, 252, 0.94) 0%, rgba(248, 250, 252, 0.62) 42%, transparent 72%);
  z-index: 1;
}

.home-pattern__cell {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  animation: home-float var(--float-dur, 14s) ease-in-out var(--float-delay, 0s) infinite;
  will-change: transform;
}

.home-pattern__cell svg {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes home-float {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) translateY(0);
  }
  50% {
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) translateY(-10px);
  }
}

@keyframes home-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-pattern__cell {
    animation: none;
  }

  .home-intro,
  .home-cta {
    animation: none;
  }
}

.home-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  min-height: 0;
}

.home-intro {
  max-width: min(640px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  backdrop-filter: none;
  animation: home-rise 0.55s ease-out both;
}

.home-logo {
  width: clamp(96px, 18vw, 140px);
  height: clamp(96px, 18vw, 140px);
  object-fit: contain;
  display: block;
  margin-bottom: 2px;
}

.home-brand {
  margin: 0;
  font-family: Syne, Manrope, sans-serif;
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 400;
  color: var(--dark);
  letter-spacing: -0.02em;
  line-height: 0.95;
}

.home-title {
  margin: 0;
  font-family: Syne, Manrope, sans-serif;
  font-size: clamp(20px, 3.4vw, 30px);
  font-weight: 400;
  color: #1e293b;
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: 16em;
}

.home-lead {
  margin: 0;
  font-size: clamp(14px, 1.6vw, 16px);
  font-weight: 400;
  line-height: 1.55;
  color: #64748b;
  max-width: 34em;
}

.home-tag {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.4;
  color: #94a3b8;
  max-width: 32em;
}

.home-cta {
  min-width: 180px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  animation: home-rise 0.55s ease-out 0.12s both;
}

.home-cta-secondary {
  margin-top: 4px;
}

.home-motifs {
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid rgba(209, 213, 219, 0.7);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
}

.home-motifs[hidden] {
  display: none;
}

.home-motifs__title {
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: center;
}

.home-motifs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.home-motif {
  display: flex;
  align-items: center;
  gap: 4px;
}

.home-motif__open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.home-motif__open:hover {
  border-color: var(--blue);
}

.home-motif__thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.home-motif__thumb.is-empty {
  background: repeating-linear-gradient(
    -45deg,
    #f3f4f6,
    #f3f4f6 4px,
    #e5e7eb 4px,
    #e5e7eb 8px
  );
}

.home-motif__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.home-motif__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.home-motif__name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-motif__date {
  font-size: 10px;
  color: var(--text-muted);
}

.home-motif__del {
  flex-shrink: 0;
  padding: 4px 6px;
  font-size: 11px;
}

/* —— Barre supérieure —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 var(--pad);
  gap: 8px;
  background: var(--dark);
  color: #fff;
  flex-shrink: 0;
}

.topbar__left,
.topbar__right,
.topbar__center,
.topbar__account {
  display: flex;
  align-items: center;
  gap: var(--gap);
  min-width: 0;
}

.topbar__left {
  flex: 0 1 auto;
  gap: 8px;
}

.topbar__center {
  flex: 1 1 auto;
  justify-content: center;
  gap: 8px;
}

.topbar__right {
  flex: 0 1 auto;
  justify-content: flex-end;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
  font: inherit;
  flex-shrink: 0;
}

.topbar__brand:hover .topbar__brand-text {
  color: #e5e7eb;
}

.topbar__logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.topbar__brand-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.topbar__search {
  display: flex;
  align-items: center;
  flex: 0 1 180px;
  max-width: 200px;
}

.topbar__search input {
  width: 100%;
  height: 28px;
  padding: 2px 8px;
  border: 1px solid #4b5563;
  border-radius: var(--radius);
  background: #1f2937;
  color: #f3f4f6;
  font-size: 12px;
}

.topbar__search input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.topbar__search input::placeholder {
  color: #9ca3af;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.view-mode {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* —— Boutons —— */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1.3;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.btn--ghost {
  background: transparent;
  border-color: #4b5563;
  color: #e5e7eb;
  padding: 4px 8px;
}

.btn--ghost:hover:not(:disabled) {
  background: #374151;
}

.btn--danger {
  color: var(--danger);
  border-color: #fca5a5;
}

/* Boutons topbar (Nouveau, etc.) — gris */
.topbar .btn:not(.btn--ghost):not(.btn--primary):not(.motif-toggle) {
  background: #374151;
  border-color: #4b5563;
  color: #f3f4f6;
}

.topbar .btn:not(.btn--ghost):not(.btn--primary):not(.motif-toggle):hover:not(:disabled) {
  background: #4b5563;
}

/* Motif répété — gris inactif, bleu actif (après .btn pour ne pas être écrasé) */
.topbar .btn.motif-toggle {
  background: #374151;
  border-color: #4b5563;
  color: #f3f4f6;
  font-size: 12px;
}

.topbar .btn.motif-toggle:hover:not(:disabled):not(.is-active) {
  background: #4b5563;
}

.topbar .btn.motif-toggle.is-active,
.topbar .btn.motif-toggle.is-active:hover:not(:disabled) {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* —— Workspace —— */
.workspace {
  display: grid;
  grid-template-columns: var(--library-w) 8px minmax(0, 1fr) 8px var(--props-w);
  gap: 0;
  flex: 1;
  min-height: 0;
  padding: var(--gap);
  min-width: 0;
}

body.has-pattern-props .workspace {
  grid-template-columns: var(--library-w) 8px minmax(0, 1fr) 8px var(--props-w) var(--gap) var(--props-w);
}

body.has-forme-props .workspace {
  grid-template-columns: var(--library-w) 8px minmax(0, 1fr) 8px var(--props-w) var(--gap) var(--props-w);
}

body.pattern-props-collapsed .workspace {
  grid-template-columns: var(--library-w) 8px minmax(0, 1fr) 8px var(--props-w) var(--gap) 36px;
}

.col-gap {
  min-width: 0;
  pointer-events: none;
}

.col-gap[hidden] {
  display: none !important;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

/* Poignées dans l’interstice (pas sur les panneaux) */
.col-resize {
  width: 8px;
  min-width: 8px;
  min-height: 0;
  z-index: 5;
  cursor: col-resize;
  background: transparent;
  align-self: stretch;
  position: relative;
}

.col-resize::after {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: transparent;
  border-radius: 1px;
  pointer-events: none;
  transition: background 0.12s ease;
}

.col-resize:hover::after,
.col-resize.is-dragging::after {
  background: #9ca3af;
}

body.is-col-resizing {
  cursor: col-resize;
  user-select: none;
}

body.is-col-resizing iframe,
body.is-col-resizing img {
  pointer-events: none;
}

.panel__title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: var(--pad);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.panel__title--tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.panel-tools {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

.icon-btn[hidden] {
  display: none;
}

.panel--props {
  position: relative;
}

.panel--props-pattern[hidden] {
  display: none !important;
}

#panel-props-forme[hidden] {
  display: none !important;
}

/* Calque Shape interactif — dans #canvas-stage, même repère que les items */
.shape-items-layer {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  width: 8000px;
  height: 8000px;
  overflow: visible;
  pointer-events: none;
  z-index: 20;
}

.shape-item {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  outline: none;
  pointer-events: auto;
}

.shape-item:active {
  cursor: grabbing;
}

.shape-item.is-selected {
  outline: none;
}

.shape-item__body {
  position: relative;
  transform-origin: center center;
  pointer-events: auto;
  cursor: grab;
}

.shape-item__body:active {
  cursor: grabbing;
}

.shape-item__svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
}

.shape-item__svg svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.shape-handles-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 90;
}

.shape-handles-layer .item-handles {
  pointer-events: none;
}

.shape-handles-layer .item-handle {
  pointer-events: auto;
}

/* Aperçu Shape au centre (comme la vue motif répété) */
.shape-stage {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #fff;
}

.shape-stage[hidden] {
  display: none !important;
}

.shape-stage > svg,
.shape-stage .shape-stage__svg {
  display: block;
  flex: 0 0 auto;
  max-width: min(92%, 640px);
  max-height: 92%;
  background: transparent;
}

.shape-stage .empty {
  color: var(--text-muted);
  font-size: 13px;
}

/* Mode Shape : espace de travail sur le canvas (silhouettes interactives) */
body.is-forme .shape-stage {
  display: none !important;
}

body.is-forme .motif-viewport {
  visibility: visible;
  pointer-events: auto;
}

body.is-forme .canvas .canvas-item,
body.is-forme .canvas #item-handles-layer,
body.is-forme .canvas .align-guides {
  display: none !important;
  pointer-events: none !important;
}

body.is-forme .shape-items-layer {
  display: block !important;
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
  z-index: 20;
}

body.is-forme .shape-handles-layer,
body.is-forme .shape-handles-layer .item-handles {
  display: block !important;
  visibility: visible;
  opacity: 1;
  pointer-events: none;
}

body.is-forme .shape-handles-layer .item-handle {
  display: block !important;
  pointer-events: auto;
}

body.is-forme .shape-world-layer {
  display: none !important;
}

body.is-forme .canvas__hint {
  display: none;
}

.props-forme .props__actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.props-forme .radio:has(input:disabled) {
  opacity: 0.45;
}

.panel--props-pattern.is-collapsed {
  cursor: pointer;
  overflow: hidden;
}

.panel--props-pattern.is-collapsed .props-motif {
  display: none;
}

.panel--props-pattern.is-collapsed .panel__title--tools {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  height: 100%;
  padding: 8px 4px;
  border-bottom: none;
  writing-mode: horizontal-tb;
}

.panel--props-pattern.is-collapsed .panel__title-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.panel--props-pattern.is-collapsed .panel-tools {
  flex-direction: column;
}

.panel--props-pattern.is-floating {
  position: fixed;
  width: 220px;
  max-height: min(70vh, 520px);
  overflow: auto;
  z-index: 40;
  box-shadow: 0 4px 16px rgba(17, 24, 39, 0.18);
}

.panel--props-pattern.is-floating .panel__title--tools {
  cursor: grab;
  user-select: none;
}

.panel--props-pattern.is-floating .panel__title--tools:active {
  cursor: grabbing;
}

.empty {
  color: var(--text-muted);
  font-size: 12px;
  padding: var(--pad);
  line-height: 1.4;
}

/* —— Bibliothèque —— */
.library__collections {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px 4px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.collection {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.collection:hover:not(:disabled) {
  border-color: #9ca3af;
}

.collection.is-active {
  background: #1f2937;
  border-color: #1f2937;
  color: #fff;
}

.collection.is-soon,
.collection:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.library__cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.library__cats[hidden] {
  display: none !important;
}

.cat {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 3px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
}

.cat:hover {
  border-color: #9ca3af;
}

.cat.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.library__grid {
  flex: 1;
  overflow-y: auto;
  padding: var(--pad);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-content: start;
}

.library__grid .empty {
  grid-column: 1 / -1;
}

.lib-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 6px;
  cursor: pointer;
  text-align: center;
  color: var(--text);
}

.lib-item:hover {
  border-color: var(--blue);
  background: #eff6ff;
}

.lib-item__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
}

.lib-item__preview img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.lib-item__name {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* —— Toile —— */
.panel--canvas {
  background: var(--bg);
  border: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.canvas-mode-title {
  flex-shrink: 0;
  margin: 0;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  --cam-inv-zoom: 1;
}

/* —— Multi-vues : Création = plein écran ; Pattern/Shape = Original | dérivation —— */
.views-board {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  gap: 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.views-board.is-split {
  grid-template-columns: minmax(160px, 0.9fr) minmax(0, 1.4fr);
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
}

.view-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

.view-pane--original[hidden] {
  display: none !important;
}

.views-board.is-split .view-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.view-pane__label {
  flex-shrink: 0;
  margin: 0;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.view-pane__label[hidden] {
  display: none !important;
}

.view-pane__body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.view-pane__body .motif-viewport {
  flex: 1;
  width: 100%;
  height: 100%;
}

.original-preview {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 8px;
  border: none;
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  background-color: #fff;
  cursor: pointer;
  box-sizing: border-box;
}

.original-preview:hover {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.original-preview__svg,
.original-preview > svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
}

.original-preview__empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

/* Barre création — bas de la toile : modes puis outils contextuels */
.createbar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.creation-modes {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.creation-modes__btn {
  appearance: none;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  align-self: stretch;
}

.creation-modes__btn:hover:not(:disabled):not(.is-active) {
  color: var(--text);
  background: #e5e7eb;
}

.creation-modes__btn.is-active {
  color: var(--blue-dark);
  border-bottom-color: var(--blue);
  background: var(--surface);
}

.creation-modes__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.creation-modes__btn[hidden] {
  display: none;
}

.creation-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 4px 8px;
}

.creation-tools__project,
.creation-tools__view {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.creation-tools__project {
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.creation-tools__view {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.creation-tools__name {
  width: min(140px, 22vw);
  height: 28px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
}

.creation-tools__name:focus {
  outline: none;
  border-color: var(--blue);
}

.creation-tools .btn {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
}

.creation-tools .btn:hover:not(:disabled) {
  background: #e5e7eb;
}

.creation-tools .btn--primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.creation-tools .btn--primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

#btn-save.is-dirty {
  border-color: var(--blue);
  color: var(--blue);
}

#btn-save.is-saved {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.creation-tools .canvas-zoom {
  background: var(--surface-2);
  border-color: var(--border);
}

.creation-tools .canvas-zoom__btn {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.creation-tools .canvas-zoom__btn:hover {
  background: #e5e7eb;
}

.creation-tools .canvas-zoom__pct {
  color: var(--text);
}

.creation-tools .canvas-zoom__pct:hover {
  border-color: var(--border);
  background: var(--surface);
}

.creation-tools .canvas-zoom__sep {
  background: var(--border);
}

/* —— Aperçu export (centre) —— */
.export-preview {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: #e5e7eb;
}

.export-preview[hidden] {
  display: none;
}

.export-preview__label {
  margin: 0;
  flex-shrink: 0;
  font-size: 12px;
  color: #4b5563;
}

.export-preview__frame {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid var(--border);
  overflow: hidden;
}

.export-preview__frame--checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.export-preview__frame svg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

body.is-export .motif-viewport {
  visibility: hidden;
  pointer-events: none;
}

.motif-viewport {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background: var(--surface);
}

.motif-viewport[data-bg="default"] {
  background: var(--surface);
}

.motif-viewport[data-bg="white"] {
  background: #ffffff;
}

.motif-viewport[data-bg="paper"] {
  background: #e8eaed;
}

.motif-viewport[data-bg="dark"] {
  background: #1f2937;
}

.motif-viewport[data-bg="custom"] {
  background: var(--motif-bg-custom, #ffffff);
}

.motif-world {
  width: 100%;
  height: 100%;
  position: relative;
}

.motif-previews {
  display: none;
}

.canvas {
  flex: none;
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  touch-action: none;
}

.canvas-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

/* Composition = toile infinie (même caméra pan/zoom) */
body:not(.is-pattern) .motif-viewport {
  cursor: grab;
}

body:not(.is-pattern) .motif-viewport.is-panning {
  cursor: grabbing;
}

body:not(.is-pattern) .motif-world {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}

body:not(.is-pattern) .canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 8000px;
  height: 8000px;
  flex: none;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  box-shadow: none;
}

/* Motif répété = tuile + caméra + copies */
body.is-pattern .panel--canvas {
  background: var(--surface-2);
}

body.is-pattern .motif-viewport {
  cursor: default;
}

body.is-pattern .motif-viewport.is-panning {
  cursor: default;
}

body.is-pattern .motif-world {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}

body.is-pattern .motif-previews {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: auto;
  /* Au-dessus du canvas : sinon le rectangle tuile masque les voisins (fond transparent). */
  z-index: 3;
}

/* Sélection active : remonte la tuile pour que les poignées hors cadre
   restent au-dessus des copies (les voisins restent cliquables). */
body.is-pattern.is-editing-item .canvas {
  z-index: 5;
}

body.is-pattern .motif-preview {
  position: absolute;
  overflow: visible;
  background: transparent;
  border: none;
  pointer-events: auto;
  cursor: pointer;
  box-sizing: border-box;
}

body.is-pattern .motif-preview__content {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  pointer-events: none;
}

body.is-pattern .motif-preview .is-preview-clone {
  pointer-events: none;
  outline: none;
}

body.is-pattern .motif-preview svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* Contours tuile / grille — au-dessus du canvas */
body.is-pattern .motif-bounds-layer {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 4;
}

.motif-bounds-layer {
  display: none;
}

.motif-bound-cell {
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
  background: transparent;
}

/* Contour de la tuile active (édition) — épaisseur adaptée au zoom */
.motif-bound-cell.is-tile {
  border: none;
  outline: var(--tile-stroke, 1.5px) solid #9ca3af;
  outline-offset: calc(var(--tile-stroke, 1.5px) / -2);
}

/* Grille des copies (option limites) — plus clair */
.motif-bound-cell.is-grid {
  border: none;
  outline: var(--grid-stroke, 1px) dashed #d1d5db;
  outline-offset: calc(var(--grid-stroke, 1px) / -2);
}

body.is-pattern .canvas {
  position: absolute;
  left: calc(var(--tile-w, 200px) / -2);
  top: calc(var(--tile-h, 200px) / -2);
  width: var(--tile-w, 200px);
  height: var(--tile-h, 200px);
  z-index: 2;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  /* Laisse dépasser vers les voisins (demi-brique / goutte) */
  overflow: visible;
  cursor: default;
  /* Zone vide cliquable vers les copies ; seuls les motifs restent interactifs. */
  pointer-events: none;
}

body.is-pattern .canvas .canvas-item:not(.is-wrap) {
  pointer-events: auto;
}

body.is-pattern .canvas .item-handles,
body.is-pattern .canvas .item-handles *,
body.is-pattern .item-handles-layer .item-handle {
  pointer-events: auto;
}

body.is-pattern .canvas__hint {
  display: none;
}

.props-motif,
.props-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tile-preview {
  width: 100%;
  min-height: 120px;
  height: 140px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  background-color: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 6px;
}

.tile-preview > svg,
.tile-preview__svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: visible;
}

.tile-preview__empty {
  margin: 0;
  padding: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

#props-canvas-bg {
  margin-top: 0;
  margin-bottom: 8px;
}

#motif-bg-color-wrap {
  margin-top: 4px;
}

#motif-bg-color-wrap .color-pair {
  width: auto;
}

#motif-bg-color-wrap .color-swatch {
  flex: 0 0 28px;
}

.props-canvas-bg-slot {
  margin-top: 8px;
}

.props-canvas-bg-slot[hidden] {
  display: none !important;
}

.props-side[hidden],
#props-element[hidden] {
  display: none;
}

.props-motif select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 6px;
  background: var(--surface);
  color: var(--text);
}

.props-motif .btn {
  align-self: stretch;
}

.props-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.props-subtitle:first-child {
  margin-top: 0;
}

/* Zoom / caméra — dans la barre création */
.canvas-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: var(--radius);
}

.canvas-zoom[hidden] {
  display: none;
}

.canvas-zoom__btn {
  border: 1px solid #4b5563;
  background: #374151;
  color: #f3f4f6;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 2px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.canvas-zoom__btn:hover {
  background: #4b5563;
}

.canvas-zoom__btn--text {
  font-size: 11px;
  min-width: auto;
  padding: 0 8px;
}

.canvas-zoom__pct {
  border: 1px solid transparent;
  background: transparent;
  color: #e5e7eb;
  min-width: 40px;
  height: 26px;
  padding: 0 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.canvas-zoom__pct:hover {
  border-color: #4b5563;
  background: #374151;
  border-radius: 2px;
}

.canvas-zoom__sep {
  width: 1px;
  height: 16px;
  background: #4b5563;
  margin: 0 2px;
}

.settings-about {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}

.settings-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.canvas__hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
  user-select: none;
}

.canvas__hint[hidden] {
  display: none;
}

.canvas-item {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  outline: none;
  /* z-index géré en inline par syncItemZOrder (ordre d’empilement) */
}

.canvas-item:active {
  cursor: grabbing;
}

.canvas-item.is-selected {
  outline: none;
}

.canvas-item__body {
  position: relative;
  transform-origin: center center;
  pointer-events: auto;
  cursor: grab;
}

.canvas-item__body:active {
  cursor: grabbing;
}

.canvas-item__body .canvas-item__svg {
  pointer-events: none;
}

/* Zone cliquable = boîte de base (avant scale) */
.canvas-item {
  width: 96px;
  height: 96px;
}

/* Poignées au-dessus de tous les motifs (pas dans le z-index du motif). */
.item-handles-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 80;
}

/* Poignées de transformation — taille adaptée au zoom caméra (--cam-inv-zoom) */
.item-handles {
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  border: calc(1.5px * var(--cam-inv-zoom, 1)) solid var(--blue);
  pointer-events: none;
  z-index: 3;
}

.item-handles-layer .item-handles {
  pointer-events: none;
}

.item-handle {
  position: absolute;
  width: calc(8px * var(--cam-inv-zoom, 1));
  height: calc(8px * var(--cam-inv-zoom, 1));
  padding: 0;
  border: calc(1.5px * var(--cam-inv-zoom, 1)) solid var(--blue);
  background: #fff;
  border-radius: 1px;
  pointer-events: auto;
  cursor: nwse-resize;
  box-sizing: border-box;
}

.item-handle--nw {
  left: calc(-5px * var(--cam-inv-zoom, 1));
  top: calc(-5px * var(--cam-inv-zoom, 1));
  cursor: nwse-resize;
}

.item-handle--ne {
  right: calc(-5px * var(--cam-inv-zoom, 1));
  top: calc(-5px * var(--cam-inv-zoom, 1));
  cursor: nesw-resize;
}

.item-handle--sw {
  left: calc(-5px * var(--cam-inv-zoom, 1));
  bottom: calc(-5px * var(--cam-inv-zoom, 1));
  cursor: nesw-resize;
}

.item-handle--se {
  right: calc(-5px * var(--cam-inv-zoom, 1));
  bottom: calc(-5px * var(--cam-inv-zoom, 1));
  cursor: nwse-resize;
}

.item-handle--rotate {
  left: 50%;
  top: calc(-28px * var(--cam-inv-zoom, 1));
  width: calc(12px * var(--cam-inv-zoom, 1));
  height: calc(12px * var(--cam-inv-zoom, 1));
  margin-left: calc(-6px * var(--cam-inv-zoom, 1));
  border-radius: 50%;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23334155' stroke-width='1.75' stroke-linecap='round' d='M5 12a7 7 0 0 1 11.3-5.5'/%3E%3Cpath fill='%23334155' d='M16.8 3.8l.2 3.8-3.4-1.6z'/%3E%3Cpath fill='none' stroke='%23334155' stroke-width='1.75' stroke-linecap='round' d='M19 12a7 7 0 0 1-11.3 5.5'/%3E%3Cpath fill='%23334155' d='M7.2 20.2l-.2-3.8 3.4 1.6z'/%3E%3C/svg%3E") 12 12, crosshair;
  background: var(--blue);
  border-color: #fff;
}

.item-handle--rotate::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: calc(1px * var(--cam-inv-zoom, 1));
  height: calc(16px * var(--cam-inv-zoom, 1));
  background: var(--blue);
  transform: translateX(-50%);
  pointer-events: none;
}

/* Zone de clic un peu plus large que le pastille visible */
.item-handle--rotate::after {
  content: "";
  position: absolute;
  inset: calc(-7px * var(--cam-inv-zoom, 1));
  border-radius: 50%;
}

.item-handle--rotate:active {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23334155' stroke-width='1.75' stroke-linecap='round' d='M5 12a7 7 0 0 1 11.3-5.5'/%3E%3Cpath fill='%23334155' d='M16.8 3.8l.2 3.8-3.4-1.6z'/%3E%3Cpath fill='none' stroke='%23334155' stroke-width='1.75' stroke-linecap='round' d='M19 12a7 7 0 0 1-11.3 5.5'/%3E%3Cpath fill='%23334155' d='M7.2 20.2l-.2-3.8 3.4 1.6z'/%3E%3C/svg%3E") 12 12, crosshair;
}

/* Raccords : copies d’affichage (non interactives) */
.canvas-item.is-wrap {
  pointer-events: none;
  outline: none;
  z-index: 0;
}

.canvas-item.is-wrap .item-handles {
  display: none;
}

.canvas-item img,
.canvas-item svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.canvas-item__svg {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.canvas-item__svg svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: visible;
}

/* —— Propriétés —— */
.props {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--pad);
}

.props__fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.props__fields[hidden],
#props-element .props__actions[hidden] {
  display: none;
}

.props-selected-name {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.props-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.field-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.field--grow {
  flex: 1 1 0;
  min-width: 0;
}

.field--grow input[type="number"] {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.props-tab-panel .btn {
  width: 100%;
}

.transform-flips {
  width: 100%;
}

.transform-flips .btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

.transform-flips .btn.is-active {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: #eff6ff;
}

.transform-aligns {
  width: 100%;
  margin-top: 4px;
}

.transform-aligns .btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  padding: 4px 2px;
  font-size: 14px;
  line-height: 1;
}

.transform-aligns .btn--align {
  font-family: inherit;
}

.align-guides {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 50;
}

.align-guides[hidden] {
  display: none !important;
}

.align-guides__frame {
  position: absolute;
  box-sizing: border-box;
  border: calc(1.5px * var(--cam-inv-zoom, 1)) dashed rgba(59, 130, 246, 0.85);
  background: rgba(59, 130, 246, 0.04);
}

.align-guides__cross-h,
.align-guides__cross-v {
  position: absolute;
  background: rgba(59, 130, 246, 0.55);
}

.align-guides__cross-h {
  height: calc(1px * var(--cam-inv-zoom, 1));
  transform: translateY(-50%);
}

.align-guides__cross-v {
  width: calc(1px * var(--cam-inv-zoom, 1));
  transform: translateX(-50%);
}

.align-guides__label {
  position: absolute;
  padding: 2px 6px;
  font-size: calc(10px * var(--cam-inv-zoom, 1));
  line-height: 1.2;
  color: #1e3a5f;
  background: rgba(239, 246, 255, 0.92);
  border: calc(1px * var(--cam-inv-zoom, 1)) solid rgba(59, 130, 246, 0.45);
  border-radius: 2px;
  white-space: nowrap;
}

.props-tabs__btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 4px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
}

.props-tabs__btn:hover {
  color: var(--text);
  background: #f3f4f6;
}

.props-tabs__btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.props-tabs__btn:disabled:hover {
  color: var(--text-muted);
  background: transparent;
}

.props-tabs__btn.is-active {
  color: var(--blue-dark, #1e3a5f);
  background: #eef3f8;
  font-weight: 600;
}

.props-tab-panels {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.props-tab-panel[hidden] {
  display: none !important;
}

.props-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 88px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}

.props-preview svg {
  max-width: 100%;
  max-height: 76px;
  width: 100%;
  height: 76px;
}

.layer-vis-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text);
}

.layer-vis-row.is-locked {
  opacity: 0.85;
}

.layer-vis-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

.layer-vis-row__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-vis-row__ops {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0.35;
}

.layer-vis-row:hover .layer-vis-row__ops,
.layer-vis-row.is-locked .layer-vis-row__ops {
  opacity: 1;
}

.layer-vis-row__ops .btn {
  width: auto;
  min-width: 24px;
  padding: 2px 4px;
  font-size: 10px;
}

.layer-vis-row__ops .btn--icon-lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  min-width: 24px;
  padding: 2px;
}

.layer-vis-row__ops .lock-icon {
  width: 12px;
  height: 12px;
  display: block;
}

.layer-vis-row__ops .btn.is-active {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: #eff6ff;
}

.layer-row--color.is-locked {
  opacity: 0.65;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.stack-list[hidden] {
  display: none;
}

.stack-list__title {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.stack-list__hint {
  display: none;
}

.stack-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 6px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

.stack-row:hover {
  background: #f3f4f6;
}

.stack-row.is-selected {
  background: #eef3f8;
}

.stack-row.is-selected .stack-row__name {
  color: var(--blue-dark, #1e3a5f);
  font-weight: 600;
}

.stack-row__name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
}

.stack-row__ops {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0.35;
}

.stack-row:hover .stack-row__ops,
.stack-row.is-selected .stack-row__ops {
  opacity: 1;
}

.stack-row__ops .btn {
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  border-color: transparent;
  background: transparent;
}

.stack-row__ops .btn:hover:not(:disabled) {
  background: #e5e7eb;
}

.stack-row__ops .btn:disabled {
  opacity: 0.25;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-list__motif-name {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.layer-list__title {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.layer-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-row__name {
  font-size: 12px;
  color: var(--text-muted);
}

.layer-row__controls {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.layer-row__controls .color-pair {
  flex: 1 1 auto;
  min-width: 0;
}

.layer-row__controls .color-hex,
.color-hex {
  flex: 1.4 1 0;
  width: auto;
  min-width: 64px;
  height: 28px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
}

.color-pair {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.color-swatch {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--swatch, #fff);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.color-swatch:hover {
  border-color: var(--blue);
}

.color-pair .color-hex {
  flex: 1 1 auto;
  width: auto;
  min-width: 64px;
}

.layer-row__controls input[type="checkbox"] {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  accent-color: var(--blue);
  cursor: pointer;
}

.layer-colors {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.field input[type="range"] {
  width: 100%;
}

.field-val {
  float: right;
  font-style: normal;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.field input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.field input[type="text"]:focus {
  outline: none;
  border-color: var(--blue);
}

/* Sélecteur custom (doc 09) */
.layer-row--color {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius);
  cursor: pointer;
}

.layer-row--color:hover {
  background: #f3f4f6;
}

.layer-row--color.is-editing {
  background: #eef3f8;
}

.layer-row--color .layer-row__name {
  flex: 1;
  min-width: 0;
}

.layer-row--color .layer-row__controls {
  width: auto;
  flex: 0 0 auto;
}

.layer-row--color .color-pair {
  width: auto;
}

.color-picker-host {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  min-height: 24px;
}

.color-picker-host__hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.color-picker-host__hint[hidden] {
  display: none !important;
}

.color-picker {
  z-index: 4000;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface, #fff);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-picker--float {
  position: fixed;
  width: 240px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.color-picker--inline {
  position: static;
  width: 100%;
  box-shadow: none;
  border: none;
  padding: 0;
  background: transparent;
}

.color-picker[hidden] {
  display: none !important;
}

.color-picker__editing {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.color-picker__editing[hidden] {
  display: none !important;
}

.color-picker__actions {
  display: flex;
  gap: 6px;
}

.color-picker__actions .btn {
  width: auto;
  flex: 1;
  font-size: 11px;
  padding: 4px 8px;
}

.color-picker__actions .btn.is-active {
  border-color: var(--blue);
  color: var(--blue-dark, #1e3a5f);
  background: #eef3f8;
}

body.is-picking-color,
body.is-picking-color * {
  cursor: crosshair !important;
}

/* Pendant la pipette : les formes SVG doivent être ciblables (sinon pointer-events:none). */
body.is-picking-color .canvas-item__svg,
body.is-picking-color .canvas-item__svg svg,
body.is-picking-color .canvas-item__svg *,
body.is-picking-color .canvas-item svg,
body.is-picking-color .canvas-item svg * {
  pointer-events: auto !important;
}

body.is-picking-color .item-handles,
body.is-picking-color .item-handles * {
  pointer-events: none !important;
}

.color-pipette-preview {
  position: fixed;
  z-index: 5000;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
  pointer-events: none;
}

.color-pipette-preview[hidden] {
  display: none !important;
}

.color-pipette-preview__swatch {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
  flex-shrink: 0;
}

.color-pipette-preview__swatch.is-empty {
  background-image: repeating-conic-gradient(#d1d5db 0% 25%, #fff 0% 50%);
  background-size: 8px 8px;
}

.color-pipette-preview__hex {
  font-size: 11px;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text);
  min-width: 3.6em;
}

.color-picker__preview {
  display: flex;
  gap: 6px;
  height: 28px;
}

.color-picker__chip {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-image: repeating-conic-gradient(#d1d5db 0% 25%, #fff 0% 50%);
  background-size: 8px 8px;
  padding: 0;
  cursor: pointer;
}

.color-picker__chip:hover {
  border-color: var(--blue);
}

.color-picker__sv {
  position: relative;
  height: 140px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: crosshair;
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, var(--picker-hue, #f00));
  touch-action: none;
}

.color-picker__sv-cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-picker__row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.color-picker__row em {
  font-style: normal;
  color: var(--text);
  float: right;
}

.color-picker__opacity-row[hidden] {
  display: none !important;
}

.color-picker__hue,
.color-picker__opacity {
  width: 100%;
  height: 14px;
  appearance: none;
  border-radius: 4px;
}

.color-picker__hue {
  background: linear-gradient(
    to right,
    #f00,
    #ff0,
    #0f0,
    #0ff,
    #00f,
    #f0f,
    #f00
  );
}

.color-picker__opacity {
  background: linear-gradient(to right, transparent, #334155);
  border: 1px solid var(--border);
}

.color-picker__hue::-webkit-slider-thumb,
.color-picker__opacity::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #64748b;
  cursor: pointer;
}

.color-picker__hue::-moz-range-thumb,
.color-picker__opacity::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #64748b;
  cursor: pointer;
}

.color-picker__fields {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 4px;
}

.color-picker__field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--text-muted);
}

.color-picker__field input {
  width: 100%;
  min-width: 0;
  height: 26px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg, #f8fafc);
  color: var(--text);
  font-size: 11px;
  font-family: ui-monospace, Consolas, monospace;
}

.color-picker__swatches {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.color-picker__label {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.color-picker__hint {
  font-weight: 400;
  opacity: 0.75;
}

.color-picker__swatch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 18px;
}

.color-picker__dot {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--swatch, #ccc);
  cursor: pointer;
}

.color-picker__dot:hover {
  border-color: var(--blue);
}

.color-picker__empty {
  font-size: 11px;
  color: var(--text-muted);
}

.props__actions {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  margin-top: 4px;
}

.props__actions .btn {
  width: 100%;
}

/* —— Formulaires panneau —— */
.field-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* display:flex ci-dessus écrasait sinon l’attribut HTML hidden */
.field-group[hidden] {
  display: none !important;
}

.field-group legend {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0 4px;
}

.radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.pattern-preview-wrap .panel__title {
  border: none;
  background: transparent;
  padding: 0 0 4px;
}

.pattern-preview {
  height: 280px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.pattern-preview svg {
  width: 100%;
  height: 100%;
  display: block;
}

.pattern-preview[data-bg="white"] {
  background: #ffffff;
}

.pattern-preview[data-bg="paper"] {
  background: #e8eaed;
}

.pattern-preview[data-bg="dark"] {
  background: #1f2937;
}

.field--inline {
  margin-top: 4px;
}

.field--inline[hidden] {
  display: none;
}

/* —— Mobile —— */
@media (max-width: 780px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .panel--library,
  .panel--props,
  .panel--props-pattern:not(.is-floating) {
    max-height: 140px;
  }

  body.has-pattern-props .workspace {
    grid-template-columns: 1fr;
  }

  .col-resize {
    display: none;
  }

  .topbar__name {
    display: none;
  }
}
