/* ── Custom color picker (replaces the browser's) ── */
#color-pop {
  position: fixed; z-index: 2600; /* above dialogs (Export, confirmations) */
  width: 260px; padding: 10px; /* width is recalculated in JS to fit the grid exactly */
  background: #161616; border: 1px solid #2e2e2e; border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  font-size: 0.75rem; color: #e0e0e0;
}
.cp-top { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.cp-current { width: 28px; height: 28px; border-radius: 4px; border: 1px solid #3a3a3a; flex-shrink: 0; }
#cp-hex {
  flex: 1; min-width: 0; height: 28px; padding: 0 8px;
  background: #1e1e1e; border: 1px solid #3a3a3a; border-radius: 4px;
  color: #e0e0e0; font: inherit; font-family: ui-monospace, Consolas, monospace; outline: none;
}
#cp-hex:focus { border-color: #4a7fcb; }
#cp-hex.invalid { border-color: #e5484d; }
.cp-transparent { width: 28px; height: 28px; border-radius: 4px; border: 1px solid #3a3a3a; cursor: pointer; flex-shrink: 0; padding: 0; }
.cp-transparent:hover { border-color: #fff; }
/* eyedropper toggle (color picker and Palette window) */
.cp-eyedrop {
  width: 28px; height: 28px; flex-shrink: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #1e1e1e; border: 1px solid #3a3a3a; border-radius: 4px; color: #ccc; cursor: pointer;
}
.cp-eyedrop:hover { border-color: #fff; color: #fff; }
.cp-eyedrop.active { background: #4a7fcb; border-color: #4a7fcb; color: #fff; }
/* while sampling: pipette cursor (tip = hotspot) over the canvas area */
#grid-container.eyedropping, #grid-container.eyedropping *, #tile-area.eyedropping, #tile-area.eyedropping * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='%23000' stroke-width='4'%3E%3Cpath d='m2 22 1-1h3l9-9'/%3E%3Cpath d='M3 21v-3l9-9'/%3E%3Cpath d='m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z'/%3E%3C/g%3E%3Cg stroke='%23fff' stroke-width='2'%3E%3Cpath d='m2 22 1-1h3l9-9'/%3E%3Cpath d='M3 21v-3l9-9'/%3E%3Cpath d='m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z'/%3E%3C/g%3E%3C/svg%3E") 2 22, crosshair !important;
}
#toast {
  position: fixed; left: 16px; bottom: 60px; z-index: 2700; /* messages show over dialogs too — at the left, clear of the text at the bottom */
  max-width: min(420px, calc(100vw - 32px));
  padding: 7px 14px; border-radius: 6px; background: #000c; border: 1px solid #3a3a3a;
  color: #e0e0e0; font-size: 0.78rem; pointer-events: none; transition: opacity 0.3s;
}
#toast.fade { opacity: 0; }
#eyedrop-chip {
  position: fixed; z-index: 1500; width: 22px; height: 22px; pointer-events: none;
  border: 2px solid #fff; border-radius: 4px; box-shadow: 0 0 0 1px #000, 0 2px 8px #0008;
}
#eyedrop-chip.is-transparent { background: repeating-conic-gradient(#bbb 0% 25%, #fff 0% 50%) 0 0 / 8px 8px; }
.cp-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.07em; opacity: 0.5; margin: 0 0 5px; }
.cp-canvas { display: block; cursor: pointer; image-rendering: pixelated; }
#cp-grid { margin-bottom: 10px; }

.palette {
  display: flex;
  gap: 4px;
}

.swatch {
  width: 22px; height: 22px;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.1s, transform 0.1s;
}

.swatch:hover { transform: scale(1.15); }
.swatch.selected { border-color: #fff; }

/* ── The color chooser for any color (src/hsv-picker.js): adding / changing a palette's colors ── */
#hsv-pop {
  position: fixed; z-index: 2650; width: 224px; padding: 10px; display: flex; flex-direction: column; gap: 8px;
  background: #161616; border: 1px solid #2e2e2e; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  font-size: 0.75rem; color: #e0e0e0;
}
#hsv-pop[hidden] { display: none; }
.hsv-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.hsv-x { width: 22px; height: 22px; padding: 0; display: flex; align-items: center; justify-content: center; background: none; border: none; border-radius: 4px; color: #888; cursor: pointer; }
.hsv-x:hover { background: #262626; color: #e0e0e0; }
.hsv-sv { position: relative; height: 140px; border-radius: 5px; cursor: crosshair; touch-action: none; box-shadow: inset 0 0 0 1px #0006; }
.hsv-hue {
  position: relative; height: 12px; border-radius: 6px; cursor: ew-resize; touch-action: none;
  background: linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00);
}
.hsv-knob {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; pointer-events: none;
  border: 2px solid #fff; box-shadow: 0 0 0 1px #000a, 0 1px 3px #0008;
}
.hsv-hue .hsv-knob { top: 50%; }
.hsv-row { display: flex; align-items: center; gap: 6px; }
.hsv-preview { display: flex; width: 44px; height: 26px; flex-shrink: 0; border-radius: 5px; overflow: hidden; box-shadow: 0 0 0 1px #3a3a3a; }
.hsv-preview i { flex: 1; }
.hsv-hex, .hsv-rgb input {
  min-width: 0; height: 26px; padding: 0 6px; background: #121212; border: 1px solid #3a3a3a; border-radius: 5px;
  color: #e0e0e0; font: inherit; font-family: ui-monospace, Consolas, monospace; outline: none;
}
.hsv-hex { flex: 1; }
.hsv-hex:focus, .hsv-rgb input:focus { border-color: #4a7fcb; }
.hsv-hex.invalid { border-color: #c04040; }
.hsv-rgb label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; color: #8a8a8a; }
.hsv-rgb input { width: 100%; -moz-appearance: textfield; }
.hsv-rgb input::-webkit-inner-spin-button { display: none; }
.hsv-buttons button { flex: 1; height: 28px; border-radius: 5px; font: inherit; cursor: pointer; }
.hsv-random { background: #232323; border: 1px solid #333; color: #ddd; }
.hsv-random:hover { background: #2c2c2c; }
.hsv-ok { background: #4a7fcb; border: 1px solid #4a7fcb; color: #fff; font-weight: 600; }
.hsv-ok:hover { background: #5b8fdb; }

#color-pop .cp-label[hidden], #cp-recent[hidden] { display: none; } /* (Document colors: none yet) */

/* the color picker on another palette than the Palette window's: a note under its dropdown (amber while locked) */
.cp-pal-note { margin: -2px 0 6px; font-size: 0.7rem; line-height: 1.4; color: #9a9a9a; }
.cp-pal-note[hidden] { display: none; }
.cp-pal-note.warn { color: #e0b960; }

/* the picker's header (drag it to move the picker), its rail (Palette | Spectrum) and the Spectrum view */
#color-pop { padding-top: 0; }
.cp-head { display: flex; align-items: center; gap: 8px; margin: 0 -10px 10px; padding: 7px 8px 7px 12px; border-bottom: 1px solid #2a2a2a; cursor: grab; user-select: none; touch-action: none; border-radius: 8px 8px 0 0; }
.cp-head:hover { background: #1c1c1c; }
#color-pop.moving .cp-head { cursor: grabbing; }
.cp-title { flex: 1; min-width: 0; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #9a9a9a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-x { width: 22px; height: 22px; padding: 0; display: flex; align-items: center; justify-content: center; background: none; border: 1px solid transparent; border-radius: 4px; color: #999; cursor: pointer; }
.cp-x:hover { background: #ffffff10; color: #fff; }
.cp-tabs { display: flex; gap: 2px; padding: 2px; margin-bottom: 14px; background: #222; border-radius: 7px; }
.cp-tab { flex: 1; height: 24px; border: none; border-radius: 5px; background: none; color: #aaa; font: inherit; font-size: 0.74rem; font-weight: 600; cursor: pointer; }
.cp-tab:hover { color: #e0e0e0; }
.cp-tab[aria-selected="true"] { background: #3a3a3a; color: #fff; }
.cp-view[hidden] { display: none; }
#cp-view-spectrum { display: flex; flex-direction: column; gap: 8px; }
#cp-view-spectrum[hidden] { display: none; }
.cp-sv { position: relative; width: 100%; height: 150px; border-radius: 4px; cursor: crosshair; touch-action: none; }
.cp-hue { position: relative; width: 100%; height: 14px; border-radius: 7px; cursor: pointer; touch-action: none; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.cp-rgb { display: flex; gap: 6px; }
.cp-rgb label { flex: 1; display: flex; align-items: center; gap: 4px; color: #9a9a9a; font-size: 0.72rem; }
.cp-rgb input { width: 100%; min-width: 0; height: 24px; padding: 0 4px; background: #1e1e1e; border: 1px solid #3a3a3a; border-radius: 4px; color: #e0e0e0; font: inherit; text-align: center; -moz-appearance: textfield; outline: none; }
.cp-rgb input::-webkit-inner-spin-button, .cp-rgb input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cp-rgb input:focus { border-color: #4a7fcb; }
.cp-use { height: 28px; }
#cp-use-pal { width: 100%; margin-top: 12px; }
#cp-use-pal[hidden] { display: none; }
