/* ── 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 color 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" color: 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; }

/* Symmetry buttons (phones: in the brush / shape settings; desktop moves them into the options bar) */
#sym-ctl { display: flex; align-items: center; gap: 10px; }
#sym-ctl .seg .btn { width: 40px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: 0; background: #1e1e1e; color: #aaa; }
#sym-ctl .seg .btn + .btn { border-left: 1px solid #3a3a3a; }
#sym-ctl .seg .btn.active { background: #4a7fcb; color: #fff; }
#ts-shape #sym-ctl { margin-top: 2px; }
#sym-angle-field[hidden] { display: none; }
#sym-ctl .num-field input {
  width: 34px !important; padding: 0 2px 0 6px !important; border: none !important; background: transparent !important;
  font-size: inherit !important; text-align: right !important; -moz-appearance: textfield;
}
#ts-shape-checks { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 10px; }
/* Shape button: press and hold it for the shapes (no long-press callout on phones) */
#btn-shape { -webkit-touch-callout: none; user-select: none; }
/* the shapes in one row, icons only (names in the tooltips) */
#shape-flyout { min-width: 0; z-index: 1200; flex-direction: row; gap: 2px; }
#shape-flyout button { width: 34px; height: 34px; padding: 0; justify-content: center; }
.tool-flyout button.active { background: #1a3558; }
.tool-flyout button.active svg { color: #fff; }
.tool-flyout button:not(.active):hover { background: #ffffff1c; }
/* Fill settings */
#ts-fill-opts { display: flex; flex-direction: column; gap: 10px; margin: 2px 0 6px; }
#ts-fill-opts .co-sub { padding-left: 0; border-left: none; }
#fill-tol-row .num-field input, #co-fill .num-field input { width: 30px; }
#draw-flyout, #fill-flyout { min-width: 0; z-index: 1200; flex-direction: row; gap: 2px; }
#draw-flyout button, #fill-flyout button { width: 34px; height: 34px; padding: 0; justify-content: center; }
#btn-draw, #btn-fill { -webkit-touch-callout: none; user-select: none; }
#pixel-perfect-label[hidden], #brush-outline-label[hidden] { display: none !important; }
/* Dither: Intensity */
#dither-ctl { display: flex; align-items: center; gap: 8px; }
#dither-ctl[hidden] { display: none !important; }
#dither-preview { width: 26px; height: 26px; flex: none; border: 1px solid #3a3a3a; border-radius: 4px; background: #1a1a1a; image-rendering: pixelated; }
#dither-ctl .num-field input { width: 30px; }
#ins-draw-body #dither-ctl { padding-left: 0; border-left: none; flex-wrap: wrap; }
#ins-draw-body #dither-ctl .ts-label { width: 100%; }
#ins-draw-body #dither-slider { flex: 1; accent-color: #4a7fcb; }
#blend-ctl[hidden] { display: none !important; }
#ins-draw-body #blend-ctl { padding-left: 0; border-left: none; }
/* Select settings: the magic wand's options */
/* (the Mode and action icons are for the options bar; the window keeps the words) */
#tool-settings #ts-sel-mode svg, #tool-settings #ts-sel-actions svg { display: none; }
#ts-wand-opts { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 6px; }
#ts-wand-opts[hidden] { display: none; }
.wand-tol-row { display: flex; align-items: center; gap: 8px; }
#wand-tol { width: 30px; }
/* Fill › Outline: Outside / Inside and Pixel perfect show while it's on */
#fill-outline-row { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#fill-outline-place { display: inline-flex; border: 1px solid #3a3a3a; border-radius: 6px; overflow: hidden; }
#fill-outline-place .btn { border: none; border-radius: 0; padding: 4px 9px; background: #1e1e1e; color: #bbb; font-size: 0.72rem; }
#fill-outline-place .btn + .btn { border-left: 1px solid #3a3a3a; }
#fill-outline-place .btn.active { background: #4a7fcb; color: #fff; }
#fill-outline-place[hidden], #fill-outline-pp-label[hidden], #fill-tol-row[hidden] { display: none; }
#canvas-options #fill-outline-place .btn { width: auto; padding: 0 9px !important; font-size: 0.72rem !important; } /* (words, not icons)
#co-fill #fill-outline-row { gap: 12px; }
/* Gradient: Linear / Radial (words), Dither */
#grad-row { display: inline-flex; align-items: center; gap: 12px; }
#grad-row[hidden], #fill-outline-row[hidden] { display: none; }
#grad-shapes { display: inline-flex; border: 1px solid #3a3a3a; border-radius: 6px; overflow: hidden; }
#grad-shapes .btn { border: none; border-radius: 0; padding: 4px 9px; background: #1e1e1e; color: #bbb; font-size: 0.72rem; }
#grad-shapes .btn + .btn { border-left: 1px solid #3a3a3a; }
#grad-shapes .btn.active { background: #4a7fcb; color: #fff; }
#canvas-options #grad-shapes .btn { width: auto; padding: 0 9px !important; font-size: 0.72rem !important; }
