@property --ground { syntax: "<color>"; inherits: true; initial-value: #f4f4f1; }
@property --figure-1 { syntax: "<color>"; inherits: true; initial-value: #1b1b1d; }
@property --figure-2 { syntax: "<color>"; inherits: true; initial-value: #6a6a70; }
@property --accent-1 { syntax: "<color>"; inherits: true; initial-value: #1b1b1d; }
@property --accent-2 { syntax: "<color>"; inherits: true; initial-value: #6a6a70; }
@property --accent-3 { syntax: "<color>"; inherits: true; initial-value: #1b1b1d; }
@property --on-accent-1 { syntax: "<color>"; inherits: true; initial-value: #f4f4f1; }
@property --on-accent-3 { syntax: "<color>"; inherits: true; initial-value: #f4f4f1; }

:root {
  --ground: #f4f4f1;
  --figure-1: #1b1b1d;
  --figure-2: #6a6a70;
  --accent-1: #1b1b1d;
  --accent-2: #6a6a70;
  --accent-3: #1b1b1d;
  --on-accent-1: #f4f4f1;
  --on-accent-3: #f4f4f1;

  --faint: color-mix(in srgb, var(--figure-1) 13%, transparent);
  --faint-strong: color-mix(in srgb, var(--figure-1) 26%, transparent);
  --motion: 380ms cubic-bezier(0.4, 0, 0.2, 1);
  --gutter: 32px;
  --font: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-code: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  transition:
    --ground var(--motion), --figure-1 var(--motion), --figure-2 var(--motion),
    --accent-1 var(--motion), --accent-2 var(--motion), --accent-3 var(--motion),
    --on-accent-1 var(--motion), --on-accent-3 var(--motion);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #161618;
    --figure-1: #f1f1f3;
    --figure-2: #9b9ba2;
    --accent-1: #f1f1f3;
    --accent-2: #9b9ba2;
    --accent-3: #f1f1f3;
    --on-accent-1: #161618;
    --on-accent-3: #161618;
  }
}

@media (max-width: 699px) {
  :root { --gutter: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  :root, *, *::before, *::after { transition: none !important; }
}

html[data-still], html[data-still] *, html[data-dragging], html[data-dragging] * { transition: none !important; }
html[data-dragging], html[data-dragging] * { cursor: none !important; }
html[data-busy] { cursor: progress; }

*, *::before, *::after { box-sizing: border-box; }

html, body { overflow-x: clip; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--figure-1);
  font: 14px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }

button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

html:not([data-state="empty"]) [data-when="empty"],
html:not([data-state="picture"]) [data-when="picture"] { display: none; }

.masthead {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(100%, calc(var(--workspace-width, 100%) + 2 * var(--gutter)));
  margin: 0 auto;
  padding: 18px var(--gutter) 16px;
}

.title {
  margin-right: auto;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.schemes {
  display: flex;
  margin: 0 8px 0 0;
  padding: 2px;
  border: 1px solid var(--faint);
  border-radius: 999px;
}

.scheme { position: relative; display: flex; }

.scheme input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.scheme span {
  padding: 3px 11px;
  border-radius: 999px;
  color: var(--figure-2);
  font-size: 13px;
}

.scheme input:checked + span {
  background: var(--accent-3);
  color: var(--on-accent-3);
  font-weight: 560;
}

.scheme input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.scheme:has(input:not(:checked)):hover span { color: var(--figure-1); }

.actions { display: flex; gap: 6px; }

.button {
  padding: 4px 12px;
  border: 1px solid color-mix(in srgb, var(--accent-1) 55%, transparent);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.button:hover { background: color-mix(in srgb, var(--accent-1) 12%, transparent); }

.button.filled {
  border-color: var(--accent-1);
  background: var(--accent-1);
  color: var(--on-accent-1);
  font-weight: 560;
}

.button.filled:hover { background: color-mix(in srgb, var(--accent-1) 86%, var(--ground)); }

#copy-css { display: inline-grid; }
#copy-css > span { grid-area: 1 / 1; text-align: center; }
#copy-css .copied-label, #copy-css[data-copied] .copy-label { visibility: hidden; }
#copy-css[data-copied] .copied-label { visibility: visible; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px var(--gutter) 24px;
}

.invitation { flex: 1; display: flex; }

.drop-target {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 320px;
  border: 1px dashed var(--faint-strong);
  border-radius: 16px;
}

.invitation-heading {
  font-size: 20px;
  font-weight: 560;
  letter-spacing: -0.01em;
}

.workspace {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--strip-gap);
  width: max-content;
  margin: 0 auto;
}

.frame {
  flex: none;
  width: var(--picture-width);
  height: var(--picture-height);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 1px var(--faint);
}

.picture {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.picture.small { image-rendering: pixelated; }

.strip-column {
  position: relative;
  flex: none;
  width: var(--strip-width);
}

.strip {
  position: relative;
  height: var(--strip-height);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--faint);
  transition: height var(--motion);
}

.band {
  position: absolute;
  left: 0;
  width: 100%;
  background: var(--fill);
  color: var(--ink);
  transition: top var(--motion), height var(--motion), left var(--motion), width var(--motion), background-color var(--motion), color var(--motion), opacity var(--motion);
}

@starting-style {
  .band { opacity: 0; }
}

.band-copy {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: copy;
}

.band-copy:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }

.band-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 5px 9px 4px;
  pointer-events: none;
}

.band-line {
  display: flex;
  align-items: center;
  gap: 4px;
}

.band-hex {
  display: inline-grid;
  font: 12px/14px var(--font-code);
  letter-spacing: 0.02em;
}

.band-hex > span { grid-area: 1 / 1; }
.band-copied, .band[data-copied] .band-hex-value { visibility: hidden; }
.band[data-copied] .band-copied { visibility: visible; }

.band-edit {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: -3px 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  opacity: 0.35;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 120ms ease-out;
}

.band:hover .band-edit, .band:focus-within .band-edit { opacity: 0.8; }
.band .band-edit:hover, .band .band-edit:focus-visible { opacity: 1; }
.band-edit:focus-visible { outline: 2px solid var(--ink); outline-offset: -1px; }

@media (hover: none) {
  .band-edit { opacity: 0.8; }
}

.band-edit svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.band-share {
  margin-left: auto;
  font-size: 11px;
  line-height: 14px;
  font-variant-numeric: tabular-nums;
  opacity: 0.78;
}

.band-roles {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  line-height: 14px;
  opacity: 0.86;
}

.band-how { opacity: 0.7; }

.colour-choice {
  position: absolute;
  left: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.add {
  display: block;
  width: 100%;
  height: 30px;
  margin-top: 8px;
  padding: 0;
  border: 1px solid var(--faint-strong);
  border-radius: 6px;
  background: none;
  color: var(--figure-1);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.add:hover { background: var(--faint); }

.wires {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.wire {
  fill: none;
  stroke-linecap: butt;
  transition: opacity var(--motion);
}

@starting-style {
  .wire { opacity: 0; }
}

.wire-halo {
  stroke: var(--ink);
  stroke-opacity: 0.35;
  stroke-width: 3.5;
  transition: stroke var(--motion);
}

.wire-line {
  stroke: var(--fill);
  stroke-width: 1.5;
  transition: stroke var(--motion);
}

.wire[data-dashed] path { stroke-dasharray: 4 4; }

.markers {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  width: var(--picture-width);
  height: var(--picture-height);
  pointer-events: none;
}

.marker {
  --size: 18px;
  position: absolute;
  left: calc(var(--x) * 100%);
  top: calc(var(--y) * 100%);
  width: var(--size);
  height: var(--size);
  margin: 0;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--fill);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
  translate: -50% -50%;
  cursor: crosshair;
  pointer-events: auto;
  touch-action: none;
  transition:
    left var(--motion), top var(--motion), width var(--motion), height var(--motion),
    border-radius var(--motion), background-color var(--motion), border-color var(--motion), scale var(--motion);
}

@starting-style {
  .marker { scale: 0; }
}

.marker::before {
  content: "";
  position: absolute;
  inset: -8px;
}

.marker[data-shape="square"] { --size: 13px; border-radius: 4px; }
.marker[data-ground] { --size: 28px; }
.marker[data-ground][data-shape="square"] { --size: 21px; border-radius: 6px; }
.marker:focus-visible { z-index: 1; }
.marker[data-dragged] { visibility: hidden; }

.magnifier {
  position: absolute;
  left: calc(var(--x) * var(--picture-width));
  top: calc(var(--y) * var(--picture-height));
  z-index: 3;
  width: 132px;
  height: 132px;
  overflow: hidden;
  border: 9px solid var(--sampled);
  border-radius: 50%;
  background: var(--ground);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.55), 0 10px 28px rgb(0 0 0 / 0.32);
  translate: -50% -50%;
  pointer-events: none;
}

.magnifier canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.magnifier-centre {
  position: absolute;
  left: calc(100% * 7 / 15);
  top: calc(100% * 7 / 15);
  width: calc(100% / 15);
  height: calc(100% / 15);
  outline: 1.5px solid var(--ink);
}

.drop-veil {
  position: fixed;
  inset: 12px;
  z-index: 10;
  border: 2px dashed var(--accent-1);
  border-radius: 20px;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease-out;
}

html[data-dropping] .drop-veil { opacity: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 11;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--figure-1);
  color: var(--ground);
  font-size: 13px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}

.toast.shown { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 699px) {
  .masthead { gap: 4px; padding: 12px var(--gutter) 10px; }
  .title { font-size: 14px; }
  .schemes { margin-right: 2px; }
  .scheme span { padding: 2px 5px; font-size: 12px; }
  .actions { gap: 3px; }
  .button { padding: 3px 6px; font-size: 12px; }
}

[data-demo] .picture { cursor: pointer; }

[data-arrangement="below"] .workspace, [data-arrangement="row"] .workspace { flex-direction: column; }
[data-arrangement="row"] .band-label { padding: 6px 7px; }
[data-arrangement="row"] .band-line { flex-wrap: wrap; row-gap: 0; }
[data-arrangement="row"] .band-share { margin-left: 0; }

html { visibility: visible; }

.band[data-highlighted]::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 2px var(--ink);
  pointer-events: none;
}
.marker[data-highlighted] { scale: 1.4; z-index: 3; }
[data-highlighting] .wire:not([data-highlighted]) { opacity: 0.25; }
.wire[data-highlighted] .wire-line { stroke-width: 2.5; }
.wire[data-highlighted] .wire-halo { stroke-width: 5; }
