/* Color Palette Generator from Image — image and picker on the left, swatches on the right,
   exports below. Colours come from the shared tokens; swatch colours are set inline from the image. */
.cpg {
  display: grid;
  gap: 1.2rem;
  padding: clamp(16px, 2.4vw, 32px);
  text-align: left;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--shade);
}
.cpg *, .cpg *::before, .cpg *::after { box-sizing: border-box; }
.cpg [hidden] { display: none !important; }
.cpg h2 { margin: 0 0 .35rem; font-size: 1.45rem; letter-spacing: -.02em; }
.cpg h3 { margin: 0 0 .6rem; font-size: 1.1rem; }
.cpg p { margin: 0; color: var(--ink-soft); }
.cpg-head p { max-width: 76ch; }
.cpg label { display: grid; gap: .3rem; min-width: 0; font-size: .85rem; font-weight: 650; }
.cpg input:not([type]), .cpg input[type="text"], .cpg select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: .5rem .6rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
}
.cpg :is(input, select, button, canvas, .cpg-add):focus-visible, .cpg .cpg-add:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.cpg button, .cpg .cpg-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .5rem .95rem;
  font: inherit;
  font-weight: 650;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.cpg .cpg-primary, .cpg .cpg-add { color: var(--on-action); background: var(--action); box-shadow: 3px 3px 0 var(--shade); }
.cpg .cpg-primary:hover, .cpg .cpg-add:hover { background: var(--primary-dark); }
.cpg .cpg-add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.cpg-row { display: flex; flex-wrap: wrap; align-items: end; gap: .7rem 1rem; }
.cpg-row > label { flex: 1 1 12rem; }

.cpg-drop { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding: 1.6rem 1.2rem; background: var(--blue-tint); border: 2px dashed var(--line); border-radius: 10px; }
.cpg-drop p { flex: 1 1 22rem; font-size: .92rem; color: var(--ink); }
.cpg-drop.cpg-over { background: var(--action-tint); border-style: solid; }
.cpg-drop.cpg-drop-small { padding: .8rem 1rem; }

.cpg-work { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 860px) { .cpg-work { grid-template-columns: 1fr; } }
.cpg-image { display: grid; gap: .6rem; }
.cpg-image canvas { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; background: var(--paper-3); border: 1.5px solid var(--border-soft); border-radius: 8px; cursor: crosshair; }
.cpg-hint { font-size: .85rem; }
.cpg-picked { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; padding: .5rem .6rem; background: var(--paper-3); border: 1.5px solid var(--border-soft); border-radius: 8px; }
.cpg-chip { width: 2.2rem; height: 2.2rem; border: 2px solid var(--line); border-radius: 6px; }
.cpg-picked code { flex: 1 1 10rem; font: 600 .95rem var(--font-mono); }
.cpg-tools { align-items: end; }
.cpg-tools .cpg-hexadd { flex: 1 1 9rem; }

.cpg-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem 1rem; margin: 0 0 .9rem; padding: .9rem 1rem; border: 2px solid var(--line); border-radius: 10px; background: var(--paper-3); }
.cpg-settings legend { padding: 0 .4rem; font-weight: 700; }
.cpg-settings input[type="range"] { width: 100%; accent-color: var(--action); }
.cpg-settings output { font-family: var(--font-mono); }
.cpg .cpg-check { display: flex; align-items: center; gap: .55rem; min-height: 42px; font-size: .92rem; font-weight: 500; }
.cpg .cpg-check input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--action); }

.cpg-strip { display: flex; height: 44px; margin-bottom: .9rem; overflow: hidden; border: 2px solid var(--line); border-radius: 8px; }
.cpg-strip span { flex-basis: 0; min-width: 6px; }
.cpg-swatches { display: grid; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.cpg-swatch { position: relative; display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: .75rem; padding: .5rem; background: var(--bg-2); border: 1.5px solid var(--border-soft); border-radius: 8px; }
.cpg .cpg-color { min-height: 92px; padding: .4rem; font: 700 .9rem var(--font-mono); border: 2px solid var(--line); border-radius: 6px; box-shadow: none; }
.cpg-info dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .15rem .7rem; margin: 0; padding-right: 1.6rem; font-size: .82rem; }
.cpg-info dt { font-weight: 650; color: var(--ink-soft); }
.cpg-info dd { margin: 0; font-family: var(--font-mono); overflow-wrap: anywhere; }
.cpg-info dd[data-copy] { cursor: copy; text-decoration: underline dotted var(--border-soft); text-underline-offset: 3px; }
.cpg .cpg-remove { position: absolute; top: .35rem; right: .35rem; min-height: 28px; width: 28px; padding: 0; font-size: 1.1rem; line-height: 1; border-width: 1.5px; border-color: var(--border-soft); }

.cpg-export { padding: 1rem; background: var(--paper-3); border: 2px solid var(--line); border-radius: 10px; }
.cpg-code { max-height: 18rem; margin: .8rem 0 0; padding: .8rem 1rem; overflow: auto; font: .85rem/1.55 var(--font-mono); background: var(--bg-2); border: 1.5px solid var(--border-soft); border-radius: 6px; }
.cpg-status { min-height: 1.4em; font-weight: 600; color: var(--ink) !important; }
.cpg-status[data-error="true"] { padding: .5rem .75rem; background: var(--error-soft); border-left: 4px solid var(--error); border-radius: 6px; }
.cpg-note { font-size: .85rem; }
@media (max-width: 480px) { .cpg-swatch { grid-template-columns: 5.5rem minmax(0, 1fr); } }

/* Space the page holds for this view until it mounts (see .tool-view-placeholder in _workspace.css).
   Each height is a little under the space the view takes at that width, measured as how far the
   content below moves when the view replaces the placeholder, so nothing below it moves. Re-measure
   after changing the view's layout: node scripts/measure-tool-views.js --apply color-palette-from-image. */
.tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 350px; }
@media (max-width: 1312px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 364px; } }
@media (max-width: 996px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 399px; } }
@media (max-width: 660px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 442px; } }
@media (max-width: 604px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 521px; } }
@media (max-width: 476px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 567px; } }
@media (max-width: 436px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 617px; } }
@media (max-width: 416px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 673px; } }
@media (max-width: 372px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 719px; } }
@media (max-width: 344px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 767px; } }
@media (max-width: 328px) { .tool-view-placeholder[data-tool="color-palette-from-image"] { min-height: 814px; } }
