/* Popups, swatches, layers panel, context menu, zoom bar, toast */
.popup {
  position: fixed;
  background: var(--bar);
  border: 1px solid var(--bar-line);
  border-radius: 16px;
  padding: 8px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  z-index: 40;
  animation: popIn 0.15s ease;
  display: flex;
}
.popup.hidden { display: none; }
.popup.row { gap: 3px; }
.popup.column, #pop-brush { flex-direction: column; gap: 4px; }
.popup.list {
  flex-direction: column;
  padding: 6px;
  min-width: 180px;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.94) translateY(-3px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.popup-drag-handle {
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  color: var(--ink-dim);
  font-size: 9px; letter-spacing: -1px;
  padding: 2px 0 4px;
  border-radius: 8px;
  transition: color 0.15s, background 0.12s;
  touch-action: none;
}
.popup-drag-handle:hover { color: var(--ink); background: rgba(255,255,255,0.06); }
.popup-drag-handle:active { cursor: grabbing; }

#pop-color {
  flex-direction: column;
  padding: 6px;
  gap: 6px;
  width: 200px;
  min-width: 180px;
  max-width: 360px;
  /* Custom resize handle (.pop-resize-handle) instead of the native CSS
     `resize` grip — bigger hit target and works on touch. */
  overflow: hidden;
  position: fixed;   /* already from .popup, restated so the handle anchors here */
}

/* Touch-friendly resize handle, bottom-right corner of resizable popups. */
.pop-resize-handle {
  position: absolute;
  right: 0; bottom: 0;
  width: 24px; height: 24px;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 3;
  /* Diagonal grip lines */
  background:
    linear-gradient(135deg, transparent 0 55%, var(--ink-dim) 55% 62%, transparent 62% 74%, var(--ink-dim) 74% 81%, transparent 81%);
  opacity: 0.6;
  border-bottom-right-radius: 14px;
}
.pop-resize-handle:hover { opacity: 1; }
#color-resize-handle { cursor: ew-resize; }
.color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  justify-items: center;
  column-gap: 4px;
  row-gap: 4px;
  padding: 0;
}
.color-grid .swatch { width: 100%; max-width: 36px; aspect-ratio: 1 / 1; height: auto; }

/* Top bar of the color popup — drag handle on the left, X close on the
   right. The popup is persistent (no auto-close on outside click) so a
   clear close affordance is needed. */
.pop-color-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: -2px -2px 4px;
}
.pop-color-topbar .popup-drag-handle { flex: 1; margin: 0; }

/* Multi-select tabs at the top of the color popup. Each tab toggles its
   pane independently — you can see Paleta + Triângulo + HSL all at once
   or pick any subset. */
.color-tabs {
  display: flex;
  gap: 4px;
  padding: 2px;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
}
.color-tab {
  flex: 1;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.color-tab:hover { color: var(--ink); }
.color-tab.active {
  background: rgba(255,45,110,0.18);
  color: #ff5d8f;
}

/* Tab panes (Paleta / HSV / HSL) — swap on tab click. When two or three
   panes are active simultaneously, a thin divider sits above each one
   that follows another visible pane so the sections read as separate
   without harsh blocks. */
.ct-pane { display: flex; flex-direction: column; gap: 6px; }
.ct-pane.hidden { display: none; }
.ct-pane:not(.hidden) ~ .ct-pane:not(.hidden) {
  border-top: 1px solid var(--div);
  padding-top: 8px;
  margin-top: 2px;
}
.ct-wheel-inline {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  cursor: crosshair;
  touch-action: none;
}
.ct-preview {
  width: 100%; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--bar-line);
}
.ct-slider-row {
  display: flex; align-items: center; gap: 6px;
}
.ct-slider-label {
  width: 14px; font-size: 11px; font-weight: 700;
  color: var(--ink-dim); text-align: center;
}
.ct-slider-val {
  width: 28px; font-size: 10px;
  color: var(--ink-dim); text-align: right;
}
.ct-slider-wrap { flex: 1; }
.ct-slider-wrap input[type=range] {
  width: 100%; height: 12px; margin: 0;
  -webkit-appearance: none; appearance: none;
  border-radius: 6px;
  border: 1px solid var(--bar-line);
  cursor: pointer;
  background-color: rgba(255,255,255,0.04);
}
.ct-slider-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 16px;
  border-radius: 3px;
  background: #fff;
  border: 1px solid #000;
  cursor: pointer;
}
.ct-slider-wrap input[type=range]::-moz-range-thumb {
  width: 12px; height: 16px;
  border-radius: 3px;
  background: #fff;
  border: 1px solid #000;
  cursor: pointer;
}
.ct-strip {
  display: block;
  width: 100%;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--bar-line);
  cursor: pointer;
  touch-action: none;
  image-rendering: pixelated;
}
.ct-shades-row {
  display: grid;
  grid-template-columns: repeat(var(--ct-n, 12), 1fr);
  gap: 2px;
}
.ct-shade {
  width: 100%;
  aspect-ratio: 1 / 2;
  border: 1px solid var(--bar-line);
  border-radius: 3px;
  cursor: pointer;
  transition: transform 0.08s;
}
.ct-shade:hover { transform: scaleY(1.15); }
.ct-shade.active {
  outline: 2px solid var(--pink);
  outline-offset: 1px;
  position: relative;
  z-index: 1;
}
/* Unified strip variant: zero gap, no internal borders so the row reads as
   one continuous bar (per the user's reference). End swatches keep the row
   radius so it looks like a pill. Active swatch lifts via outline to stay
   visible without re-introducing gaps. The strip height is fixed so ±
   doesn't make the row taller/shorter — only the per-swatch width changes. */
.ct-shades-unified { gap: 0; height: 28px; }
.ct-shades-unified .ct-shade {
  border: none;
  border-radius: 0;
  height: 100%;
  aspect-ratio: auto;
}
.ct-shades-unified .ct-shade:first-child { border-radius: 4px 0 0 4px; }
.ct-shades-unified .ct-shade:last-child  { border-radius: 0 4px 4px 0; }
.ct-shades-unified .ct-shade:hover { transform: none; filter: brightness(1.1); }
.ct-shades-unified .ct-shade.active {
  outline: 2px solid var(--pink);
  outline-offset: -2px;
  z-index: 2;
}

/* HSL row layout: small dimension label on the left, the strip in the
   middle, then a tight ± pair to grow/shrink swatch count for that row. */
.ct-hsl-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
}
.ct-hsl-label {
  width: 12px;
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}
.ct-hsl-row .ct-shades-row { flex: 1; min-width: 0; }
.ct-hsl-btn {
  width: 18px;
  padding: 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--bar-line);
  color: var(--ink-dim);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}
.ct-hsl-btn:hover { background: rgba(255,255,255,0.10); color: var(--ink); }
.ct-hsl-btn:active { background: rgba(255,255,255,0.16); }
.ct-hex {
  width: 100%; box-sizing: border-box;
  padding: 4px 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  color: var(--ink);
  font-size: 11px;
  font-family: monospace;
  text-align: center;
  border-radius: 6px;
}

/* Old position-only rules (kept neutral so nothing else stretches) */
.ct-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(255, 45, 110, 0.14);
  border: 1px solid rgba(255, 45, 110, 0.45);
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.ct-trigger:hover {
  background: rgba(255, 45, 110, 0.24);
  border-color: rgba(255, 45, 110, 0.7);
}
.ct-trigger svg { width: 16px; height: 16px; }

.popup-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: transparent;
  border: 1.5px solid transparent;
  color: var(--ink-dim);
  border-radius: 10px;
  transition: all 0.12s;
}
.popup-btn:hover { background: rgba(255,255,255,0.08); color: var(--ink); }
.popup-btn.active {
  background: rgba(255,45,110,0.15);
  color: var(--pink);
  border-color: rgba(255,45,110,0.3);
}
.popup-btn svg { width: 18px; height: 18px; }

.list-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  width: 100%;
  transition: all 0.12s;
}
.list-btn:hover { background: rgba(255,255,255,0.08); color: var(--ink); }
.list-btn.active { background: rgba(255,45,110,0.12); color: var(--pink); }
.list-btn.danger { color: #fca5a5; }
.list-btn.danger:hover { background: rgba(239,68,68,0.15); }
.list-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
/* Inline row (icon + label + input). Matches .list-btn styling so it sits
   flush with the other menu items — same padding, font-weight, hover. */
.list-row {
  cursor: default;
  background: transparent;
  border: none;
}
.list-row:hover { background: rgba(255,255,255,0.06); }
.list-row-label {
  flex: 1;
  text-align: left;
}
.list-row input[type=number] {
  width: 56px;
  padding: 3px 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  color: var(--ink);
  font-size: 12px;
  border-radius: 6px;
  text-align: right;
  font-family: inherit;
}

.swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.12s;
  position: relative;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--pink); }
.swatch.white-bg { border-color: rgba(255,255,255,0.25); }
.swatch.custom {
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* Layers popup */
#pop-layers {
  flex-direction: column;
  padding: 8px;
  min-width: 220px;
  gap: 4px;
  overflow: hidden;          /* so a dragged-down height clips, list scrolls */
  position: fixed;
}
/* When the popup has an explicit height (after resize), the list takes the
   remaining space and scrolls; header + Fundo row stay pinned. */
#layers-list {
  flex: 1 1 auto;
  min-height: 40px;
  overflow-y: auto;
  overflow-x: hidden;
}
.layers-title {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding: 2px 6px 6px;
}
.layer-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.12s;
}
.layer-item:hover { background: rgba(255,255,255,0.05); }
.layer-item.active {
  background: rgba(255,45,110,0.1);
  border-color: rgba(255,45,110,0.35);
}
.layer-vis {
  width: 26px; height: 26px;
  border: none;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s;
}
.layer-vis:hover { background: rgba(255,255,255,0.08); color: var(--ink); }
.layer-vis.hidden-layer { color: rgba(255,255,255,0.25); }
.layer-vis svg { width: 16px; height: 16px; }
.layer-thumb-wrap {
  width: 40px; height: 53px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  overflow: hidden;
  background: transparent;
  flex-shrink: 0;
}
.layer-thumb { width: 40px; height: 53px; display: block; }
.layer-info { flex: 1; min-width: 0; }
.layer-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}
.layer-blend {
  width: 100%;
  margin-bottom: 5px;
  padding: 2px 4px;
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--ink-dim);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  border-radius: 5px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.layer-blend:hover { color: var(--ink); background: rgba(255,255,255,0.10); }
.layer-blend:focus { border-color: rgba(255,45,110,0.5); }
.layer-blend option { background: #1c1c22; color: var(--ink); }
.layer-opacity {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
}
.layer-opacity::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  cursor: pointer;
}
.layer-opacity::-moz-range-thumb {
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 50%;
  border: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  cursor: pointer;
}

/* Layer drag handle */
.layer-drag-handle {
  cursor: grab;
  color: var(--ink-dim);
  font-size: 11px; letter-spacing: -1px;
  padding: 0 2px;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0.5;
}
.layer-drag-handle:hover { opacity: 1; }
.layer-item.dragging { opacity: 0.5; }
.layer-item.drag-over { border-color: rgba(255,255,255,0.4) !important; background: rgba(255,255,255,0.06) !important; }

/* Background layer special style */
.layer-bg {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 4px;
  padding-top: 10px;
  cursor: pointer;
  opacity: 0.85;
}
.layer-bg:hover { opacity: 1; background: rgba(255,255,255,0.05) !important; }
.layer-bg-swatch {
  width: 40px; height: 53px;
  border-radius: 4px;
  background: #ffffff;
  display: block;
}
.layer-bg-hint {
  font-size: 0.68rem;
  color: var(--ink-dim);
  display: block;
  margin-top: 2px;
}

/* Hold menu — pointer-events intentionally auto so elementFromPoint finds items */
#hold-menu {
  position: fixed;
  background: var(--bar);
  border: 1px solid var(--bar-line);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  z-index: 50;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: popIn 0.12s ease;
}
#hold-menu.hidden { display: none; }
/* Brushes laid out as a 3-column grid so cards line up cleanly instead of
   wrapping unevenly. Colors get their own dedicated grid below. */
.hm-section { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.hm-colors { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; width: 280px; max-width: 90vw; }
.hm-brush-btn {
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-dim);
  transition: all 0.08s;
  cursor: pointer;
  padding: 0;
}
.hm-brush-btn svg { width: 18px; height: 18px; }
.hm-brush-card {
  flex-direction: column;
  padding: 4px 4px 3px;
  gap: 2px;
  width: 100%;
  box-sizing: border-box;
}
.hm-mini-preview {
  width: 100%;
  height: 18px;
  border-radius: 3px;
  background: rgba(255,255,255,0.04);
  display: block;
}
.hm-brush-lbl {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--ink-dim);
  white-space: nowrap;
  text-align: center;
  line-height: 1;
}
/* Final dimensions for hm-color-sq live in the rule below — width: 100%
   so the swatch fills its grid cell exactly instead of jutting past it. */
.hm-brush-btn.hm-active { color: var(--pink); background: rgba(255,45,110,0.08); }
.hm-brush-btn.hm-active .hm-brush-lbl { color: var(--pink); }
.hm-brush-btn.hm-hover {
  border-color: var(--pink);
  background: rgba(255,45,110,0.22);
  color: #fff;
  transform: scale(1.08);
}
.hm-brush-btn.hm-hover .hm-brush-lbl { color: #fff; }
.hm-color-sq {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 4px;
  border: 2px solid transparent;
  box-sizing: border-box;
  transition: transform 0.08s, border-color 0.08s, box-shadow 0.08s;
}
.hm-color-sq.hm-active { border-color: rgba(255,255,255,0.5); }
.hm-color-sq.hm-hover { border-color: #fff; transform: scale(1.10); box-shadow: 0 0 8px rgba(255,255,255,0.4); z-index: 1; position: relative; }
.hm-divider { height: 1px; background: var(--div); }

/* Brush settings panel */
#pop-brush-settings {
  flex-direction: column;
  padding: 10px;
  width: 280px;
  gap: 8px;
  overflow: hidden;          /* so a resized height clips; settings scroll */
  position: fixed;
}
/* When the panel has an explicit height (after resize), the params list
   scrolls; tabs/preview/footer stay pinned. */
#pop-brush-settings .bs-settings {
  flex: 1 1 auto;
  min-height: 60px;
  overflow-y: auto;
  overflow-x: hidden;
}
.bs-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 2px 4px;
}
.bs-footer {
  display: flex; gap: 6px; justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--div);
  margin-top: 4px;
}
.bs-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.bs-reset-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ink-dim);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.bs-reset-btn:hover { background: rgba(255,255,255,0.12); color: var(--ink); }

.bs-tabs {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 4px 0;
  border-bottom: 1px solid var(--div);
}
.bs-tab {
  width: auto; height: 24px;
  padding: 2px 4px;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-dim);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s;
}
.bs-tab svg { width: 16px; height: 16px; }
.bs-tab-preview {
  width: 48px;
  height: 18px;
  display: block;
  border-radius: 3px;
  background: rgba(255,255,255,0.04);
}
.bs-tab:hover { background: rgba(255,255,255,0.06); color: var(--ink); }
.bs-tab.active {
  background: rgba(255,45,110,0.12);
  color: var(--pink);
  border-color: rgba(255,45,110,0.3);
}

/* Brush stroke preview in settings panel */
.bs-preview-canvas {
  display: block;
  width: 260px;
  height: 48px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.bs-settings { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.bs-row {
  display: grid;
  grid-template-columns: 96px 1fr 54px;
  align-items: center;
  gap: 8px;
}
.bs-row-toggle {
  display: flex;
  justify-content: space-between;
  padding-top: 4px;
}
.bs-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--pink);
  cursor: pointer;
  flex: 0 0 auto;
}
.bs-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-dim);
}
/* The stabilizer is an input-FEEL control, not a brush-shape one — give it a
   distinct accent card with a small wave icon so it reads as "different". */
.bs-row-feel {
  grid-template-columns: auto 1fr 54px;
  background: rgba(255,45,110,0.08);
  border: 1px solid rgba(255,45,110,0.20);
  border-radius: 9px;
  padding: 8px 10px;
  margin: 4px 0 2px;
}
.bs-row-feel .bs-label {
  color: #ff7da6;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.bs-row-feel .bs-label svg { flex-shrink: 0; opacity: 0.9; }
.bs-slider {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
}
.bs-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px; height: 12px;
  background: var(--pink);
  border-radius: 50%;
  cursor: pointer;
}
.bs-slider::-moz-range-thumb {
  width: 12px; height: 12px;
  background: var(--pink);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}
.bs-value {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  text-align: right;
}
/* Editable value: click-to-type number + "%" unit. */
.bs-value-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1px;
}
.bs-value-input {
  width: 34px;
  padding: 2px 2px;
  text-align: right;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255,255,255,0.06);
  border: 1px solid transparent;
  border-radius: 5px;
  -moz-appearance: textfield;
  appearance: textfield;
}
.bs-value-input::-webkit-outer-spin-button,
.bs-value-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bs-value-input:hover { background: rgba(255,255,255,0.10); }
.bs-value-input:focus { outline: none; border-color: var(--pink, #ff2d6e); background: rgba(255,255,255,0.12); }
.bs-value-unit { font-size: 0.7rem; font-weight: 700; color: var(--ink-dim); }

.brush-config-btn {
  border-left: 1px solid var(--div);
  margin-left: 2px;
  padding-left: 4px;
}

/* Procreate-style brush list — item styling (container styled below near #brush-list) */
.brush-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.brush-list-item:hover { background: rgba(255,255,255,0.05); }
.brush-list-item:hover .brush-item-actions { opacity: 1; }
.brush-list-item.active {
  border-color: var(--pink);
  background: rgba(255,45,110,0.08);
}
.brush-list-item.dragging { opacity: 0.55; }
.brush-list-item.drag-over { background: rgba(255,45,110,0.18); }

.brush-drag-grip {
  width: 16px; flex-shrink: 0;
  cursor: grab; color: var(--ink-dim);
  display: flex; align-items: center; justify-content: center;
  opacity: 0.4;
  transition: opacity 0.12s, color 0.12s;
}
.brush-drag-grip:hover { opacity: 1; color: var(--ink); }
.brush-drag-grip:active { cursor: grabbing; }

.brush-preview-canvas {
  width: 110px; height: 42px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  flex-shrink: 0;
  display: block;
}
.brush-list-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brush-item-actions {
  display: flex; gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}
.brush-item-btn {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  color: var(--ink-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}
.brush-item-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }
.brush-item-btn.brush-item-delete:hover { background: rgba(220,38,38,0.32); color: #fff; }
/* Armed (first click) delete = red, awaiting confirm click. */
.brush-item-btn.brush-item-delete.armed { background: rgba(220,38,38,0.85); color: #fff; }
.brush-gear-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--div);
  margin-top: 4px;
  padding-top: 6px;
}
.brush-create-btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255,45,110,0.14);
  color: #ff5d8f;
  border: 1px solid rgba(255,45,110,0.32);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.brush-create-btn:hover {
  background: rgba(255,45,110,0.24);
  color: #fff;
}
/* Restore default brushes — subtle ghost button under the create/gear row;
   turns red/armed on first click awaiting confirmation. */
.brush-restore-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-dim);
  border: 1px dashed var(--bar-line);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.brush-restore-btn svg { flex-shrink: 0; }
.brush-restore-btn:hover { background: rgba(255,255,255,0.06); color: var(--ink); border-color: rgba(255,255,255,0.18); }
.brush-restore-btn.armed {
  background: rgba(220,38,38,0.2);
  border: 1px solid rgba(220,38,38,0.7);
  color: #fca5a5;
}
/* Brush settings delete button armed state. */
.bs-action-btn.bs-del:hover { color: #f87171; background: rgba(239,68,68,0.15); }
.bs-action-btn.bs-del.armed { background: rgba(220,38,38,0.85); color: #fff; }

/* ─────────── Brush creator modal ─────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  /* No backdrop-filter: blurring the full screen forces a costly recomposite
     on every canvas paint, which made the draw pad feel laggy. A plain dark
     overlay reads the same and keeps drawing buttery. */
  background: rgba(0,0,0,0.62);
}
.modal-panel {
  position: relative;
  background: var(--bar-bg, #1d1f24);
  border: 1px solid var(--bar-line, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 16px;
  max-width: 92vw;
  max-height: 92vh;
  overflow: auto;
  box-shadow: 0 10px 32px rgba(0,0,0,0.6);
}
.bc-panel { width: 340px; }
.bc-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--div, rgba(255,255,255,0.08));
}
.bc-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.bc-close {
  width: 26px; height: 26px;
  background: none; border: none; color: var(--ink-dim);
  font-size: 16px; cursor: pointer; border-radius: 6px;
}
.bc-close:hover { background: rgba(255,255,255,0.10); color: #fff; }
.bc-body { padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.bc-tabs { display: flex; gap: 4px; }
.bc-tab {
  flex: 1; padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--bar-line);
  color: var(--ink-dim);
  font-size: 12px; cursor: pointer;
  font-family: inherit;
}
.bc-tab.active {
  background: rgba(255,45,110,0.18);
  color: #ff5d8f;
  border-color: rgba(255,45,110,0.32);
}
.bc-tab-panel.hidden { display: none; }
.bc-help {
  font-size: 11px; line-height: 1.45;
  color: var(--ink-dim); margin: 4px 0 8px;
}
/* Shape presets — quick starting silhouettes for the brush pad. */
.bc-shapes {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center;
  margin-bottom: 4px;
}
.bc-shape {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--bar-line);
  color: var(--ink-dim);
  cursor: pointer;
  transition: transform 0.06s ease;
}
.bc-shape:hover {
  background: rgba(255,45,110,0.16);
  border-color: rgba(255,45,110,0.32);
  color: #ff5d8f;
}
.bc-shape:active { transform: scale(0.93); }
.bc-canvas-wrap, .bc-upload-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#bc-canvas, #bc-preview {
  width: 256px; height: 256px;
  background: #fff;
  border: 1px solid var(--bar-line);
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
}
#bc-preview { background: #222; cursor: default; }
.bc-tools {
  display: flex; gap: 8px; align-items: center; flex-wrap: nowrap;
  margin-top: 8px;
  justify-content: center;
}
.bc-tools input[type=range] { flex: 1; max-width: 160px; }
.bc-action {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  color: var(--ink-dim);
  cursor: pointer;
  font-family: inherit;
}
.bc-action:hover { background: rgba(255,255,255,0.12); color: #fff; }
.bc-action.active {
  background: rgba(255,45,110,0.18);
  color: #ff5d8f;
  border-color: rgba(255,45,110,0.32);
}
#bc-file {
  font-size: 11px;
  color: var(--ink-dim);
  padding: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
}
.bc-footer {
  display: flex; gap: 8px; align-items: center;
  border-top: 1px solid var(--div);
  padding-top: 10px;
  margin-top: 4px;
}
.bc-footer #bc-name {
  flex: 1;
  padding: 5px 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  color: var(--ink);
  font-size: 12px;
  border-radius: 6px;
}
.bc-save {
  padding: 6px 14px;
  border-radius: 6px;
  background: #ff2d6e;
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.bc-save:hover { background: #ff4583; }

/* Brush settings header buttons (X, ✓, +, ↺) */
.bs-header-btns { display: flex; gap: 4px; }
.bs-action-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
  transition: all 0.12s;
}
.bs-action-btn:hover { background: rgba(255,255,255,0.14); color: var(--ink); }
.bs-action-btn.bs-save { color: #4ade80; }
.bs-action-btn.bs-save:hover { background: rgba(74,222,128,0.15); }
.bs-action-btn.bs-add  { color: var(--pink); }
.bs-action-btn.bs-add:hover { background: rgba(255,45,110,0.15); }
.bs-action-btn.bs-cls:hover { color: #f87171; background: rgba(239,68,68,0.15); }

/* Layers header (+ Camada button) */
.layers-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 6px 6px;
}
#btn-add-layer {
  width: 26px; height: 26px;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 50%;
  background: rgba(255,45,110,0.12);
  color: var(--pink);
  border: 1px solid rgba(255,45,110,0.35);
  cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
#btn-add-layer:hover { background: rgba(255,45,110,0.2); }

/* Layer remove button — trash icon */
.layer-remove-btn {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: 0.55;
  transition: all 0.12s;
}
.layer-remove-btn svg { width: 14px; height: 14px; }
.layer-remove-btn:hover { opacity: 1; color: #f87171; background: rgba(239,68,68,0.15); }

/* Background color picker popup */
#pop-bg-color {
  flex-direction: column;
  padding: 6px;
  z-index: 48;
}
.bg-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 1px;
}

/* Pixel grid styles live in canvas.css */

/* Shortcuts panel */
#pop-shortcuts {
  flex-direction: column;
  padding: 14px;
  width: 480px;
  max-width: 92vw;
  max-height: 80vh;
  gap: 10px;
}
/* Shortcuts panel: grouped by category, each row pairs a "combo" of
   chip-styled key labels with its description. Combo notation is
   inspired by fighting-game move lists — keys read as a sequence of
   chunky chips joined by "+" / "/" connectors — but tones down the flair
   to fit the site's minimal dark theme. Vertical-only scroll; chips wrap
   to a new line within the combo cell if the row is narrow, so the panel
   never needs horizontal scrolling. */
.shortcuts-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 2px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 68vh;
}
.sc-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sc-section-title {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,93,143,0.85);
  padding: 0 2px 4px;
  border-bottom: 1px solid var(--div);
}
.sc-section-grid {
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr;
  column-gap: 14px;
  row-gap: 4px;
  align-items: center;
}
.sc-row {
  display: contents;
}
.shortcut-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  min-width: 0;
}
/* Keycap chip — slight inset shadow + 1px lift to read tactile. The
   monospace face keeps multi-letter labels like "Ctrl" / "Shift" aligned
   with single-letter ones. */
.sc-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', 'Courier New', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.16);
  border-bottom-color: rgba(0,0,0,0.45);
  border-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.10),
    0 1px 0 rgba(0,0,0,0.35);
  white-space: nowrap;
}
.sc-plus,
.sc-or {
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-dim);
  padding: 0 1px;
  user-select: none;
}
.sc-or {
  color: rgba(255,255,255,0.28);
  margin: 0 3px;
}
.sc-hint {
  font-size: 0.68rem;
  color: var(--ink-dim);
  font-style: italic;
  margin-left: 4px;
}
.sc-desc {
  font-size: 0.78rem;
  color: var(--ink-dim);
  line-height: 1.3;
}
.sc-remap-hint {
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink-dim);
  margin: 0 2px 4px;
}
/* Clickable key chip = remappable. Looks like a keycap but invites a click. */
.sc-key-btn {
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}
.sc-key-btn:hover { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.3); }
.sc-key-btn.remapped { color: #ffd; border-color: rgba(255,200,80,0.5); }
.sc-key-btn.capturing {
  color: #fff;
  background: rgba(255,45,110,0.30);
  border-color: var(--pink, #ff2d6e);
  animation: kmPulse 0.9s ease-in-out infinite;
}
@keyframes kmPulse { 50% { opacity: 0.55; } }
.sc-key-clear {
  margin-left: 4px;
  width: 18px; height: 18px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
}
.sc-key-clear:hover { background: rgba(239,68,68,0.18); color: #fca5a5; }

/* ─────────── Keybinding remap panel ─────────── */
#pop-keymap {
  flex-direction: column;
  padding: 14px;
  width: 360px;
  max-width: 92vw;
  max-height: 80vh;
  gap: 8px;
}
.km-help {
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink-dim);
  margin: 0 2px 2px;
}
.km-help b { color: var(--ink); }
.keymap-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 2px;
}
.km-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px;
  border-radius: 6px;
}
.km-row:hover { background: rgba(255,255,255,0.04); }
.km-label {
  flex: 1;
  font-size: 0.8rem;
  color: var(--ink);
  min-width: 0;
}
.km-key {
  min-width: 92px;
  padding: 5px 10px;
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.16);
  border-bottom-color: rgba(0,0,0,0.45);
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s, border-color 0.12s;
}
.km-key:hover { background: rgba(255,255,255,0.14); }
.km-key.capturing {
  color: #fff;
  background: rgba(255,45,110,0.28);
  border-color: var(--pink, #ff2d6e);
  animation: kmPulse 0.9s ease-in-out infinite;
}
@keyframes kmPulse { 50% { opacity: 0.6; } }
.km-clear {
  width: 24px; height: 24px;
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 0.8rem;
}
.km-clear:hover:not(:disabled) { background: rgba(239,68,68,0.18); color: #fca5a5; }
.km-clear:disabled { opacity: 0.25; cursor: default; }

/* Palette slot editor popover (long-press / right-click a swatch) */
#palette-edit-popover {
  position: fixed;
  z-index: 60;
  min-width: 150px;
  background: var(--bar);
  border: 1px solid var(--bar-line);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-lg, 0 12px 40px rgba(0,0,0,0.6));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: popIn 0.12s ease;
}
#palette-edit-popover.hidden { display: none; }
.pal-edit-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.pal-edit-item:hover { background: rgba(255,255,255,0.08); }

/* Selection tool flyout (anchored under #btn-select) */
.sel-flyout {
  position: fixed;
  z-index: 60;
  min-width: 150px;
  background: var(--bar);
  border: 1px solid var(--bar-line);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-lg, 0 12px 40px rgba(0,0,0,0.6));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: popIn 0.12s ease;
}
.sel-flyout.hidden { display: none; }
.sel-flyout-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; text-align: left; width: 100%;
}
.sel-flyout-item:hover { background: rgba(255,255,255,0.08); color: var(--ink); }
.sel-flyout-item.active { color: var(--pink); }
.sel-flyout-item svg { flex-shrink: 0; }
.sel-flyout-item span { flex: 1; }
.sel-flyout-item kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 0.7rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--bar-line);
  border-radius: 4px; padding: 1px 6px;
  color: var(--ink-dim);
}

/* Eyedropper active state on toolbar button */
.icon-btn#btn-eyedropper.active {
  background: rgba(74,222,128,0.15);
  color: #4ade80;
}

/* Brush popup scrollable list (max 7 visible) */
#pop-brush {
  flex-direction: column;
  min-width: 230px;
  padding: 6px;
}
#pop-brush .popup-drag-handle {
  width: 100%;
  text-align: center;
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--bar-line);
  margin-bottom: 4px;
}
.brush-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 420px;       /* ~7 items × ~58px */
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-dim) transparent;
}
.brush-list::-webkit-scrollbar { width: 6px; }
.brush-list::-webkit-scrollbar-track { background: transparent; }
.brush-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}
.brush-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* Recent colors row */
.recent-colors {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  padding: 2px 0 6px;
  border-bottom: 1px solid var(--bar-line);
  margin-bottom: 2px;
  width: 100%;
  box-sizing: border-box;
}
.recent-colors .swatch { width: 18px; height: 18px; border-width: 1.5px; }
.recent-colors.hidden { display: none; }

/* Modal overlay — blocks pointer events behind dialogs */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 59;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: all;
}
#modal-overlay.hidden { display: none; }

/* Canvas size dialog */
#pop-canvas-size {
  flex-direction: column;
  padding: 12px;
  width: 340px;
  gap: 10px;
  z-index: 60;
}
#cs-presets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  max-height: 50vh;
  overflow-y: auto;
}
.cs-preset {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.1s;
}
.cs-preset:hover { background: rgba(255,255,255,0.05); }
.cs-preset.selected {
  border-color: var(--pink);
  background: rgba(255,45,110,0.08);
}
.cs-thumb {
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}
.cs-thumb-custom {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1.5px dashed rgba(255,255,255,0.4);
  color: var(--ink-dim);
  font-size: 18px; font-weight: 800;
}
.cs-meta { flex: 1; min-width: 0; }
.cs-name { font-size: 0.85rem; font-weight: 700; color: var(--ink); }
.cs-dim { font-size: 0.7rem; color: var(--ink-dim); margin-top: 2px; }

#cs-name-wrap { display: flex; flex-direction: column; gap: 4px; }
#cs-name-wrap.hidden { display: none; }
#cs-name-wrap label { font-size: 0.7rem; color: var(--ink-dim); }
#cs-proj-name {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  border-radius: 6px;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.9rem;
  font-family: inherit;
}
#cs-proj-name:focus { outline: none; border-color: var(--pink); }

#cs-custom {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  padding: 6px 0;
}
#cs-custom.hidden { display: none; }
#cs-custom label {
  display: flex; flex-direction: column;
  font-size: 0.7rem; color: var(--ink-dim);
  gap: 2px;
}
#cs-custom input {
  width: 80px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  border-radius: 6px;
  color: var(--ink);
  padding: 4px 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
}
.cs-actions {
  display: flex; gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--bar-line);
}
.cs-btn {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--bar-line);
  background: rgba(255,255,255,0.06);
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.cs-btn:hover { background: rgba(255,255,255,0.12); color: var(--ink); }
.cs-btn-primary {
  background: rgba(255,45,110,0.18);
  border-color: rgba(255,45,110,0.5);
  color: var(--pink);
}
.cs-btn-primary:hover { background: rgba(255,45,110,0.28); }

/* Color triangle panel */
#pop-color-triangle {
  flex-direction: column;
  padding: 12px;
  width: 304px;
  gap: 10px;
  z-index: 55;
}
#ct-wheel {
  display: block;
  cursor: crosshair;
  touch-action: none;
  background: var(--bar);
  border-radius: 4px;
  width: 280px;
  height: 280px;
}
.ct-swatches {
  position: relative;
  height: 48px;
  display: block;
}
.ct-fg, .ct-bg {
  position: absolute;
  width: 32px; height: 32px;
  border-radius: 4px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #000, 0 2px 6px rgba(0,0,0,0.4);
  cursor: pointer;
  display: block;
}
.ct-fg { top: 0; left: 4px; z-index: 2; }
.ct-bg { top: 14px; left: 22px; z-index: 1; }
.ct-fg > span, .ct-bg > span { display: block; width: 100%; height: 100%; border-radius: 2px; }
#ct-swap {
  position: absolute;
  right: 4px; top: 10px;
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  border-radius: 6px;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
#ct-swap:hover { background: rgba(255,255,255,0.14); color: var(--ink); }
.ct-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.6fr;
  gap: 4px;
  align-items: end;
}
.ct-inputs label {
  display: flex; flex-direction: column;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  text-transform: uppercase;
  gap: 2px;
}
.ct-inputs input {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bar-line);
  border-radius: 4px;
  color: var(--ink);
  padding: 4px 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  width: 100%;
  box-sizing: border-box;
}

/* Eyedropper magnifier — floats with cursor while sampling */
#eyedrop-magnifier {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 18px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(0,0,0,0.5);
  z-index: 70;
  background: var(--bar);
}
#eyedrop-magnifier.hidden { display: none; }

/* Context menu */
#ctx-menu {
  position: fixed;
  background: var(--bar);
  border: 1px solid var(--bar-line);
  border-radius: 18px;
  padding: 14px;
  width: 260px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  z-index: 45;
  animation: popIn 0.18s ease;
}
#ctx-menu.hidden { display: none; }
.ctx-divider { height: 1px; background: var(--div); margin: 10px 0; }
.ctx-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.ctx-brushes-row { display: flex; flex-wrap: wrap; gap: 3px; }
.ctx-colors-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}
.ctx-colors-grid .swatch { width: 18px; height: 18px; border-width: 1.5px; }
.ctx-colors-grid .swatch:hover { transform: scale(1.2); }
.ctx-size-row { display: flex; align-items: center; gap: 8px; }
.ctx-size-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--ink);
  font-size: 1.2rem; font-weight: 900; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s;
}
.ctx-size-btn:hover { background: rgba(255,255,255,0.18); }
#ctx-size-value {
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}
.ctx-divider-vert {
  width: 1px;
  background: var(--div);
  height: 24px;
  flex-shrink: 0;
}
#ctx-eraser-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
#ctx-eraser-btn:hover { background: rgba(255,255,255,0.18); color: var(--ink); }
#ctx-eraser-btn.active { background: rgba(255,45,110,0.15); color: var(--pink); }
#ctx-eraser-btn svg { width: 15px; height: 15px; }

/* Zoom bar */
#zoom-bar {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  background: var(--bar);
  border: 1px solid var(--bar-line);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.75rem; font-weight: 700;
  color: var(--ink-dim);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex; align-items: center; gap: 8px;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
#zoom-bar.visible { opacity: 1; pointer-events: auto; }
#zoom-bar button {
  background: none; border: none;
  color: var(--pink); cursor: pointer;
  font-weight: 800; font-size: 0.7rem;
  padding: 0;
}

/* Rotation indicator + reset (mirrors #zoom-bar, stacked just above it) */
#rot-bar {
  position: absolute;
  bottom: 56px; left: 50%;
  transform: translateX(-50%);
  background: var(--bar);
  border: 1px solid var(--bar-line);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.75rem; font-weight: 700;
  color: var(--ink-dim);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex; align-items: center; gap: 8px;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
#rot-bar.visible { opacity: 1; pointer-events: auto; }
#rot-bar button {
  background: none; border: none;
  color: var(--pink); cursor: pointer;
  font-weight: 800; font-size: 0.7rem;
  padding: 0;
}

/* Toast */
#toast {
  position: fixed;
  top: 16px; left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: var(--bar);
  border: 1px solid var(--bar-line);
  color: var(--ink);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  white-space: nowrap;
}
#toast.visible { transform: translateX(-50%) translateY(0); }
