/* ─── Palette sidebar ─────────────────────────────────────────────────────── */
.palette-sidebar {
  width: 138px;
  flex-shrink: 0;
  background: linear-gradient(to bottom, #fff 0%, #f4f6fb 100%);
  border-left: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 10px 8px;
  overflow-y: auto;
}

.palette-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  list-style: none;
}

.color-swatch {
  aspect-ratio: 1;
  width: 100%;
  border-radius: 7px;
  background: var(--c, #ccc);
  border: 2.5px solid rgba(255,255,255,.9);
  box-shadow: 0 2px 6px rgba(0,0,0,.18), inset 0 -2px 0 rgba(0,0,0,.1);
  cursor: pointer;
  padding: 0;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), box-shadow .15s;
  display: block;
}
.color-swatch:hover {
  transform: scale(1.18) translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,.22), inset 0 -2px 0 rgba(0,0,0,.1);
  z-index: 2;
}
.color-swatch.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2.5px #fff, 0 0 0 5px var(--c, #aaa), 0 6px 16px rgba(0,0,0,.22);
  z-index: 3;
}

/* Tool items (erase, picker) span full width */
.legend-tool-item {
  grid-column: 1 / -1;
  list-style: none;
}

.tool-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 9px;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: var(--ff-brand);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: transform .12s ease, box-shadow .12s ease, border-color .15s, background .15s;
}
.tool-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 14px rgba(0,0,0,.16); }
.tool-btn svg { flex-shrink: 0; pointer-events: none; }

.erase-btn { background: #f5f5f5; color: #c62828; border-color: #e5e5e5; }
.erase-btn:hover { background: #fff0ee; border-color: #ffb3a0; }
.erase-btn.active { background: #fde8e4; border-color: #e57373; box-shadow: 0 0 0 3px rgba(229,115,115,.18); transform: none; }

.picker-btn {
  background: linear-gradient(120deg, color-mix(in srgb, var(--c, #e91e63) 18%, #fff) 0%, color-mix(in srgb, var(--c, #e91e63) 8%, #fff) 100%);
  color: rgba(0,0,0,.7);
  border-color: color-mix(in srgb, var(--c, #e91e63) 30%, transparent);
  overflow: hidden;
}
.picker-btn:hover { border-color: color-mix(in srgb, var(--c, #e91e63) 55%, transparent); }
.picker-btn.active { border-color: var(--c, #e91e63); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, #e91e63) 22%, transparent); transform: none; }
.picker-label { flex: 1; text-align: left; pointer-events: none; }
.picker-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); box-shadow: 0 1px 4px rgba(0,0,0,.22); flex-shrink: 0; pointer-events: none; }
.color-input-hidden { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: none; padding: 0; z-index: 2; }

.legend-sep {
  grid-column: 1 / -1;
  height: 1px;
  margin: 4px 2px;
  background: linear-gradient(to right, transparent, rgba(0,0,0,.13), transparent);
  list-style: none;
  pointer-events: none;
}

/* Mobile: horizontal strip */
@media (max-width: 560px) {
  .canvas-body { flex-direction: column; }
  .palette-sidebar { width: 100%; flex-direction: row; border-left: none; border-top: 1.5px solid var(--border); overflow-x: auto; overflow-y: visible; padding: 8px 10px; }
  .palette-strip { display: flex; flex-direction: row; align-items: center; gap: 5px; }
  .color-swatch { width: 36px; height: 36px; aspect-ratio: 1; }
  .legend-tool-item { grid-column: auto; }
  .tool-btn { padding: 5px 8px; gap: 5px; font-size: .64rem; border-radius: 7px; white-space: nowrap; }
  .picker-dot { width: 11px; height: 11px; }
  .legend-sep { width: 1px; height: 30px; margin: 0 3px; background: linear-gradient(to bottom, transparent, rgba(0,0,0,.13), transparent); flex-shrink: 0; }
}
