:root {
  --ink: #171714;
  --muted: #6f6b63;
  --paper: #f4f0e8;
  --paper-deep: #e8e1d4;
  --line: rgb(23 23 20 / 18%);
  --acid: #d6ed47;
  --radius: 22px;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 82% 4%, rgb(255 255 255 / 72%), transparent 29rem),
    var(--paper);
}

button,
input { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

.control-label {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.17em;
}

.page-main {
  width: min(1460px, calc(100% - 64px));
  margin: 0 auto;
}

.hero {
  display: grid;
  place-items: center;
  min-height: 650px;
  padding: 36px 0 30px;
}

.wheel-column {
  display: grid;
  place-items: center;
  min-width: 0;
}

.wheel-shell {
  position: relative;
  width: min(610px, 54vw);
  aspect-ratio: 1;
}

#color-wheel {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#color-wheel:active { cursor: grabbing; }

#wheel-center {
  position: absolute;
  inset: 30%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
}

#wheel-center:active { cursor: grabbing; }

.wheel-action-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.17em;
}

#hue-readout {
  margin: 6px 0 3px;
  font-family: "Instrument Serif", serif;
  font-size: clamp(38px, 4.4vw, 66px);
  font-weight: 400;
  line-height: 1;
}

#hue-range-name {
  color: var(--muted);
  font-size: 11px;
}

.wheel-label {
  position: absolute;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-size: 9px;
  font-weight: 600;
  pointer-events: none;
}

.label-yellow { top: 62%; right: -1%; }
.label-cyan { bottom: -1%; left: 35%; }
.label-magenta { top: 7%; left: 20%; }

.control-panel {
  position: relative;
  z-index: 3;
  margin: 0 0 82px;
  background: rgb(255 255 255 / 42%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgb(45 39 29 / 6%);
  backdrop-filter: blur(16px);
}

.controls-inner {
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
}

.control-block {
  min-width: 0;
  padding: 24px 30px;
}

.control-block + .control-block { border-left: 1px solid var(--line); }
.control-label { color: var(--muted); }
.control-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#strictness-value { font-size: 13px; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap: 5px;
  margin-top: 14px;
  padding: 4px;
  background: var(--paper-deep);
  border-radius: 13px;
}

.selection-option {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}

.selection-option.active {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 2px 8px rgb(30 27 20 / 8%);
}

.fraction-mark {
  font-family: "Instrument Serif", serif;
  font-size: 22px;
}

.custom-option { font-size: 12px; }

#color-wheel.custom-mode { cursor: pointer; }
#color-wheel.custom-mode:active { cursor: pointer; }

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 23px 0 4px;
  accent-color: var(--ink);
  cursor: ew-resize;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

.source-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.source-toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}

.source-toggle:has(input:checked) { background: #fbf9f4; }
.source-toggle input { width: 15px; height: 15px; accent-color: var(--ink); }
.source-name { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.source-count { color: var(--muted); font-size: 10px; }

.results-section {
  min-height: 460px;
  padding-bottom: 110px;
  transition: opacity 130ms ease;
}

.results-section.is-loading { opacity: 0.46; }

.results-heading {
  margin-bottom: 28px;
  padding-bottom: 19px;
  border-bottom: 1px solid var(--line);
}

.results-title {
  margin: 0;
  font-family: "Instrument Serif", serif;
  font-size: clamp(36px, 4vw, 58px);
  font-weight: 400;
  line-height: 1;
}

.result-count { color: var(--muted); font-style: italic; }
.art-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 34px 18px;
}

.art-card {
  display: block;
  min-width: 0;
  text-decoration: none;
}

.art-image-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1.17 / 1;
  background: var(--paper-deep);
  border-radius: 13px;
}

.art-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms cubic-bezier(.2,.8,.2,1);
}

.art-card:hover .art-image-wrap img { transform: scale(1.035); }

.card-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.source-badge,
.match-badge {
  padding: 5px 8px;
  background: rgb(244 240 232 / 90%);
  border-radius: 999px;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.source-magic { background: rgb(214 237 71 / 92%); }
.match-badge { margin-left: auto; }

.dominant-dot {
  position: absolute;
  right: 11px;
  bottom: 11px;
  width: 13px;
  height: 13px;
  background: oklch(70% 0.18 var(--dominant-hue));
  border: 2px solid var(--paper);
  border-radius: 50%;
  box-shadow: 0 1px 5px rgb(0 0 0 / 24%);
}

.art-card-copy { padding: 12px 3px 0; }
.art-card-copy h2 {
  overflow: hidden;
  margin: 0 0 4px;
  font-family: "Instrument Serif", serif;
  font-size: 23px;
  font-weight: 400;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artist-line { overflow: hidden; margin: 0 0 3px; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.art-card-copy small { color: var(--muted); font-size: 9px; }

.empty-state {
  display: grid;
  place-items: center;
  min-height: 350px;
  padding: 48px;
  text-align: center;
  background: rgb(255 255 255 / 28%);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty-title {
  margin: 0;
  font-family: "Instrument Serif", serif;
  font-size: 40px;
}

.empty-copy { max-width: 560px; margin: -110px 0 0; color: var(--muted); line-height: 1.5; }

.site-footer {
  width: min(1460px, calc(100% - 64px));
  margin: 0 auto;
  padding: 35px 0 44px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.site-footer p { margin: 3px 0; }
.legal-copy { max-width: 760px; line-height: 1.5; }

@media (max-width: 1000px) {
  .hero { min-height: 580px; }
  .wheel-shell { width: min(540px, 68vw); }
  .controls-inner { grid-template-columns: 1fr 1fr; }
  .control-block:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; }
  .art-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .page-main,
  .site-footer { width: min(100% - 30px, 1460px); }
  .hero { min-height: 0; padding: 34px 0 28px; }
  .wheel-column { width: 100%; }
  .wheel-shell { width: min(92vw, 470px); }
  #hue-readout { font-size: 48px; }
  .control-panel { margin-bottom: 64px; }
  .controls-inner { display: block; }
  .control-block + .control-block { border-top: 1px solid var(--line); border-left: 0; }
  .art-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 10px; }
  .art-card-copy h2 { font-size: 20px; }
  .source-badge { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .match-badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
