/* ── Tools Sidebar (floats next to canvas) ── */
#editor-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

#tools-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.3rem;
  gap: 0.2rem;
  background: #161616;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.tool-btn {
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-size: 0.52rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tool-btn:hover { background: #2a2a2a; border-color: #3a3a3a; color: #e0e0e0; }
.tool-btn.active { background: #1a3558; border-color: #4a7fcb; color: #fff; }
.tool-btn svg { display: block; flex-shrink: 0; }

.sidebar-sep { width: 28px; height: 1px; background: #2e2e2e; margin: 0.3rem 0; }

/* foreground / background colour squares under the tools */
#fg-bg { position: relative; width: 40px; height: 40px; margin: 2px 0 4px; flex-shrink: 0; }
.color-sq {
  position: absolute; width: 22px; height: 22px; padding: 0;
  border: 2px solid #d8d8d8; border-radius: 3px; cursor: pointer;
  box-shadow: 0 0 0 1px #000;
  transition: transform 0.1s, border-color 0.1s;
}
.color-sq.fg { left: 2px; top: 2px; z-index: 2; }
.color-sq.bg { right: 2px; bottom: 2px; z-index: 1; }
.color-sq:hover { border-color: #fff; transform: scale(1.08); }
#fgbg-swap {
  position: absolute; right: 0; top: 0; z-index: 3;
  width: 14px; height: 14px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: #999; cursor: pointer;
}
#fgbg-swap:hover { color: #fff; }
#fgbg-reset {
  position: absolute; left: 0; bottom: 0; z-index: 3;
  width: 14px; height: 14px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; opacity: 0.75;
}
#fgbg-reset:hover { opacity: 1; }
#fgbg-swap svg { transform: scaleX(-1); }
/* "transparent" colour: shown as a checkerboard (painting with it clears pixels) */
.color-sq.is-transparent, .swatch.transparent-swatch, #color-input.is-transparent, .cp-transparent, .cp-current.is-transparent {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #bbb 25%, transparent 25%), linear-gradient(-45deg, #bbb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #bbb 75%), linear-gradient(-45deg, transparent 75%, #bbb 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tool-group label {
  font-size: 0.75rem;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

select {
  background: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn {
  padding: 0.35rem 0.85rem;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  background: #2a2a2a;
  color: #e0e0e0;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover { background: #383838; border-color: #555; }

/* ── Sliders: thin dark track, filled up to the value (--fill, kept in sync by JS), small light knob ── */
input[type=range] {
  -webkit-appearance: none; appearance: none; background: transparent;
  height: 16px; margin: 0; padding: 0; cursor: pointer; accent-color: auto;
}
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, #4a7fcb var(--fill, 0%), #333 var(--fill, 0%));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%;
  background: #d0d0d0; border: 2px solid #1a1a1a; box-shadow: 0 0 0 1px #4a4a4a;
  transition: background 0.1s, box-shadow 0.1s;
}
input[type=range]:hover::-webkit-slider-thumb { background: #fff; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px #4a7fcb; }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: #333; }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: #4a7fcb; }
input[type=range]::-moz-range-thumb {
  width: 8px; height: 8px; border-radius: 50%; background: #d0d0d0; border: 2px solid #1a1a1a; box-shadow: 0 0 0 1px #4a4a4a;
}
input[type=range]:hover::-moz-range-thumb { background: #fff; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.btn.active {
  background: #4a7fcb;
  border-color: #5a8fdb;
  color: #fff;
}

#color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#color-input {
  width: 36px; height: 28px;
  border: 1px solid #3a3a3a; border-radius: 4px;
  cursor: pointer;
  padding: 0;
}
#color-input:hover { border-color: #777; }
