:root {
  --palette-title-height: 2rem;
  font-family: system-ui, sans-serif;
  color: #264653;
  background: #f4f1de;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
}

main {
  width: 100%;
}

.scheme-name {
  position: fixed;
  z-index: 1;
  top: var(--palette-title-top, 1.5rem);
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 9rem);
  display: grid;
  align-items: center;
  height: var(--palette-title-height);
  line-height: 1rem;
  overflow: hidden;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  background: #102b33;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.scheme-name:empty {
  visibility: hidden;
}

.search-status {
  position: fixed;
  top: 4.75rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: #102b33;
  color: #ffffff;
  font-size: 0.875rem;
  text-align: center;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(var(--column-count, 5), minmax(4.5rem, 1fr));
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: pan-x pan-y pinch-zoom;
  overflow-x: auto;
}

.palette-nav {
  position: fixed;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.625rem;
  border: 0;
  border-radius: 50%;
  background: #102b33;
  color: #ffffff;
  cursor: pointer;
}

.palette-previous {
  left: 0.75rem;
}

.palette-next {
  right: 0.75rem;
}

.palette-nav svg {
  width: 1.5rem;
  height: 1.5rem;
}

.palette-nav:hover {
  background: #264653;
}

.palette-nav:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.resource-menu-toggle {
  position: fixed;
  z-index: 3;
  top: 1.5rem;
  right: 0.75rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0.4375rem;
  border: 0;
  border-radius: 0.375rem;
  background: #102b33;
  color: #ffffff;
  cursor: pointer;
}

.resource-menu-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
}

.resource-menu-toggle:hover {
  background: #264653;
}

.resource-menu-toggle:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.agent-resources {
  position: fixed;
  inset: 4rem 0.75rem auto auto;
  min-width: 8rem;
  max-width: calc(100% - 1.5rem);
  margin: 0;
  padding: 0.25rem;
  border: 0;
  border-radius: 0.5rem;
  background: #102b33;
  color: #ffffff;
  box-shadow: 0 0.5rem 1.5rem #00000033;
  font-size: 0.75rem;
  white-space: nowrap;
}

.agent-resources a {
  display: flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  color: inherit;
  text-underline-offset: 0.2em;
}

.agent-resources a:hover {
  background: #264653;
}

.agent-resources a:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.swatch {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-rows: repeat(3, 2.75rem) 2rem 3rem;
  align-content: end;
  justify-items: center;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 0.25rem 3.75rem;
  color: var(--text-color, #ffffff);
  text-align: center;
}

.column-controls {
  position: absolute;
  z-index: 2;
  top: calc(var(--palette-title-top, 1.5rem) + var(--palette-title-height, 2.25rem) + 0.75rem);
  right: 0;
  left: 0;
  height: 2.75rem;
  pointer-events: none;
}

.color-resize {
  position: absolute;
  top: 0.375rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0.4375rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}

.color-resize svg {
  width: 1.125rem;
  height: 1.125rem;
}

.color-remove {
  left: 50%;
  width: min(2rem, calc(100% - 2rem));
  padding: 0.125rem;
  transform: translateX(-50%);
}

.color-add {
  right: 0;
  transform: translateX(50%);
  border-radius: 50%;
  background: #102b33;
  color: #ffffff;
}

.swatch:hover .color-resize,
.swatch:has(+ .swatch:hover) .color-add,
.color-resize:focus-visible {
  opacity: var(--control-opacity, 1);
  pointer-events: auto;
}

.color-add:hover:not(:disabled) {
  background: #264653;
}

.color-resize:disabled {
  --control-opacity: 0.3;
  cursor: default;
}

.color-resize:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}


.color-lock {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.625rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0;
}

.swatch:hover .color-lock,
.color-lock[aria-pressed="true"],
.color-lock:focus-visible {
  opacity: 1;
}

.color-lock svg {
  width: 1.5rem;
  height: 1.5rem;
}

.color-lock:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.color-chooser {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.625rem;
  cursor: pointer;
  opacity: 0;
}

.color-chooser svg {
  width: 1.5rem;
  height: 1.5rem;
}

.color-chooser input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.swatch:hover .color-chooser,
.color-chooser:focus-within {
  opacity: 1;
}

.color-chooser:has(:focus-visible) {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.color-drag {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.625rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: grab;
  touch-action: none;
  opacity: 0;
}

.color-drag svg {
  width: 1.5rem;
  height: 1.5rem;
}

.swatch:hover .color-drag,
.color-drag:focus-visible,
.dragging .color-drag {
  opacity: 1;
}

.color-drag:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.swatch {
  transition: transform 160ms ease;
}

.dragging {
  z-index: 1;
  transition: none;
}

.dragging .color-drag {
  cursor: grabbing;
}


.hex {
  font-size: clamp(0.75rem, 2.1vw, 2rem);
  font-weight: 600;
}

.hex-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
}

.color-copy {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.color-copy svg {
  width: 1rem;
  height: 1.25rem;
  opacity: 0;
}

/* The code and icon share one copy target; only the icon fades in. */
.swatch:hover .color-copy svg,
.color-copy:focus-visible svg {
  opacity: 1;
}

.color-copy:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.copy-feedback {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  width: max-content;
  max-width: 300%;
  overflow-wrap: anywhere;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  background: #102b33;
  color: #ffffff;
  font-size: 0.75rem;
  pointer-events: none;
}

.swatch:first-child .copy-feedback {
  left: 0;
  transform: none;
}

.swatch:last-child .copy-feedback {
  right: 0;
  left: auto;
  transform: none;
}

.name {
  font-size: clamp(0.625rem, 0.8vw, 0.75rem);
  align-self: start;
  max-width: 100%;
  line-height: 1.3;
  overflow-wrap: anywhere;
  font-weight: 600;
  letter-spacing: 0.04em;
}

@media (max-width: 30rem) {
  .swatch {
    grid-template-rows: repeat(3, 2.75rem) 3.5rem 3rem;
  }

  .color-copy {
    display: grid;
    grid-template-rows: 1.5rem 2rem;
    gap: 0;
    justify-items: center;
  }
}

.swatch:nth-child(1) { background: #264653; }
.swatch:nth-child(2) { background: #e76f51; }
.swatch:nth-child(3) { background: #2a9d8f; }
.swatch:nth-child(4) { background: #e9c46a; }
.swatch:nth-child(5) { background: #a8dadc; }
@media (max-width: 700px) {
  .search-status {
    top: 4rem;
  }
}
