.schemes {
  margin-bottom: 18px;
}

@media (min-width: 761px) {
  .schemes {
    flex-wrap: nowrap;
  }
}

.schemes .pill-btn {
  min-height: 44px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 28px 36px;
  align-items: center;
}

.wheel-col {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.wheel {
  --marker-reach: 40.6;
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 1;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.wheel:focus {
  outline: none;
}

.wheel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  border-radius: 50%;
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  -webkit-mask: radial-gradient(circle closest-side, transparent 61%, #000 62.5%);
  mask: radial-gradient(circle closest-side, transparent 61%, #000 62.5%);
}

.hub {
  position: absolute;
  width: 46%;
  height: 46%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.marker {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-secondary);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, -50%);
}

.marker.main {
  width: 22px;
  height: 22px;
  border-width: 3px;
  z-index: 1;
}

.controls {
  display: grid;
  gap: 16px;
  min-width: 0;
  container-type: inline-size;
}

.note,
.readout {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.6;
}

.note {
  color: var(--text-muted);
  /* 配色によって説明の行数が変わっても、色相環が上下にずれないようにする */
  min-height: 2lh;
}

.readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, 1.6em);
  align-items: center;
  column-gap: 12px;
  height: calc(3 * 1.6em + 22px);
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

.readout-item {
  min-width: 0;
  white-space: nowrap;
}

/* 説明がどの配色でも1行に収まる幅では、余白の行を残さない */
@container (min-width: 26rem) {
  .note {
    min-height: 1lh;
  }
}

/* 6色ぶんの枠を最初から確保する。角度や配色が変わっても行数は動かない */
@container (min-width: 34rem) {
  .readout {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, 1.6em);
    height: calc(2 * 1.6em + 22px);
  }
}

.hex-field label {
  font-size: 13px;
}

.hex-field .text-input {
  min-height: 44px;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.swatch-frame {
  container-type: inline-size;
  margin-top: 22px;
}

.swatches {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 枚数で割り切れる列数だけ使う。1枚だけ次の行に残さない。
   hsl() が1行で読める幅になるまで列を増やさない。 */
@container (min-width: 300px) {
  .swatches[data-count="2"],
  .swatches[data-count="4"],
  .swatches[data-count="6"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (min-width: 520px) {
  .swatches[data-count="3"],
  .swatches[data-count="6"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container (min-width: 680px) {
  .swatches[data-count="4"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@container (min-width: 860px) {
  .swatches[data-count="5"] {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@container (min-width: 1000px) {
  .swatches[data-count="6"] {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.swatch {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  container-type: inline-size;
}

.swatch:hover {
  border-color: var(--accent);
}

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

.swatch.copied {
  border-color: var(--accent);
}

.swatch-chip {
  display: block;
  height: 88px;
}

.swatch-body {
  display: grid;
  gap: 3px;
  padding: 10px 12px 12px;
}

.role,
.deg,
.hsl,
.code {
  white-space: nowrap;
  overflow: hidden;
}

.role {
  font-size: min(0.8rem, calc((100cqi - 26px) / 14));
  line-height: 1.4;
  height: 1.4em;
}

.deg,
.hsl {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.deg {
  font-size: 0.75rem;
  line-height: 1.4;
  height: 1.4em;
}

/* いちばん長い hsl(359.9, 100%, 100%) が、どのカード幅でも1行に収まる。
   行の高さは固定して、文字の中身でカードの高さが変わらないようにする。 */
.hsl {
  font-size: min(0.75rem, calc((100cqi - 26px) / 14));
  line-height: 1.4;
  height: 1.4em;
}

.code {
  font-size: min(1rem, calc((100cqi - 26px) / 8));
  letter-spacing: 0.03em;
  line-height: 1.25;
  height: 1.25em;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .wheel {
    width: min(100%, 420px);
  }

  .swatch-chip {
    height: 72px;
  }
}
