/* Color Tool — cosmic dark, match homepage / qr */

:root {
  --bg:         #03040f;
  --bg2:        #080a1c;
  --bg3:        #0d1030;
  --purple:     #8b5cf6;
  --purple-dim: #5b21b6;
  --cyan:       #22d3ee;
  --gold:       #fbbf24;
  --gold-deep:  #f59e0b;
  --gold-light: #fde68a;
  --rose:       #f472b6;
  --text:       #e2e8f0;
  --muted:      #94a3b8;
  --border:     rgba(139,92,246,0.18);
  --card:       rgba(10,12,35,0.85);
  --nav-h:      64px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100%;
}

button, a, input { font-family: inherit; }
button { touch-action: manipulation; }

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.nebula {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.nebula::before,
.nebula::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}
.nebula::before {
  width: 60vw; height: 60vw;
  top: -20vw; left: -10vw;
  background: radial-gradient(ellipse, rgba(139,92,246,0.12) 0%, transparent 70%);
  animation: nebulaDrift 30s ease-in-out infinite alternate;
}
.nebula::after {
  width: 50vw; height: 50vw;
  bottom: -10vw; right: -5vw;
  background: radial-gradient(ellipse, rgba(34,211,238,0.09) 0%, transparent 70%);
  animation: nebulaDrift 40s ease-in-out infinite alternate-reverse;
}
@keyframes nebulaDrift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(3vw, 4vh) scale(1.08); }
}

.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: var(--nav-h);
  background: rgba(3,4,15,0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-logo {
  font-family: Cinzel, serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-logo:focus-visible,
.site-nav nav a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
.logo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 8px var(--purple);
  display: inline-block;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.7); }
}
.site-nav nav a {
  font-family: Cinzel, serif;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.1em;
}

main.page {
  position: relative;
  z-index: 2;
  padding: calc(var(--nav-h) + 1.5rem) 1.25rem 2.5rem;
  max-width: 1240px;
  margin: 0 auto;
}

.hero { margin-bottom: 1.1rem; }
.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--purple);
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.hero h1 {
  font-family: Cinzel, serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.08;
  background: linear-gradient(135deg, #fff 0%, var(--purple) 50%, var(--cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.lede {
  font-family: "Playfair Display", serif;
  font-style: italic;
  color: var(--muted);
  font-size: 1.02rem;
  margin-top: 0.35rem;
}

.tool {
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr) minmax(220px, 270px);
  grid-template-areas:
    "rgb picks hsl"
    "hex image cmyk";
  gap: 0.7rem;
  padding: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(91,33,182,0.14);
}

.model {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0.65rem 0.7rem 0.55rem;
  border: 1px solid rgba(139,92,246,0.22);
  border-radius: 8px;
  background: rgba(8,10,28,0.78);
}
.model.is-standard {
  border-color: rgba(251,191,36,0.55);
  box-shadow: 0 0 18px rgba(251,191,36,0.12);
}
#model-rgb { grid-area: rgb; }
#model-hex { grid-area: hex; }
#model-hsl { grid-area: hsl; }
#model-cmyk { grid-area: cmyk; }

.model h2 {
  font-family: Cinzel, serif;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.hex-expr {
  display: block;
  width: 100%;
  margin-bottom: 0.55rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chans { display: flex; flex-direction: column; gap: 0.38rem; }

.chan {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr) 3.15rem;
  gap: 0.4rem;
  align-items: center;
}
.chan label {
  font-family: Cinzel, serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold-light);
}
.chan input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 0.22rem 0.2rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]:focus-visible { outline-offset: 2px; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1e2238, var(--purple) 55%, var(--cyan));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: #f8fafc;
  border: 2px solid #c4b5fd;
  box-shadow: 0 0 8px rgba(139,92,246,0.55);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1e2238, var(--purple) 55%, var(--cyan));
  border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f8fafc;
  border: 2px solid #c4b5fd;
}

.model-foot {
  display: flex;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.55rem;
}
.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: rgba(139,92,246,0.12);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { border-color: rgba(139,92,246,0.5); background: rgba(139,92,246,0.22); }
.icon-btn.is-on {
  color: var(--gold);
  border-color: rgba(251,191,36,0.7);
  box-shadow: 0 0 12px rgba(251,191,36,0.28);
}
.icon-btn.copied {
  color: var(--cyan);
  border-color: var(--cyan);
}

.picks {
  grid-area: picks;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: stretch;
  min-width: 0;
}
.wheel-wrap,
.grad-wrap {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  height: 220px;
}
.grad-wrap { flex: 1 1 260px; min-width: 200px; }
.picker {
  display: block;
  touch-action: none;
  cursor: crosshair;
  border-radius: 2px;
}
#luma {
  width: 16px;
  height: 100%;
  cursor: ns-resize;
  border-radius: 2px;
}
#wheel {
  width: 220px;
  height: 100%;
  cursor: crosshair;
}
#grad {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
}
#strip {
  width: 14px;
  height: 100%;
  flex: 0 0 14px;
  cursor: ns-resize;
}

.swatches {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.65fr) minmax(0, 1.65fr);
  gap: 0.45rem;
  align-items: stretch;
}
.swatch-group {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
}
.swatch-heading {
  font-family: Cinzel, serif;
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--gold);
  line-height: 1.2;
}
.swatch-frame {
  flex: 1;
  display: flex;
  min-height: 58px;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(3,4,15,0.35);
}
.swatch-frame.swatch-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255,255,255,0.28);
}
.swatch-cell {
  position: relative;
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
}
.swatch {
  flex: 1;
  width: 100%;
  min-height: 58px;
  margin: 0;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.45rem 0.35rem 0.35rem;
  text-align: center;
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  word-break: break-word;
}
.swatch-readout {
  flex: 1;
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.35rem 0 0.3rem;
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: 0.12em;
  line-height: 1;
  user-select: none;
}
.swatch:hover { filter: brightness(1.08); }
.swatch:focus-visible,
.swatch-copy:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.swatch-copy {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(3,4,15,0.62);
  color: #f8fafc;
  cursor: pointer;
}
.swatch-copy:hover { border-color: var(--cyan); color: var(--cyan); }
.swatch-copy.copied { color: var(--cyan); border-color: var(--cyan); }
.swatch-copy svg { display: block; }

.imagebox {
  grid-area: image;
  min-width: 0;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(139,92,246,0.22);
  border-radius: 8px;
  background: rgba(3,4,15,0.55);
  overflow: hidden;
}
.viewport {
  position: relative;
  flex: 1;
  min-height: 210px;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(ellipse at center, rgba(139,92,246,0.08), transparent 70%);
}
.viewport.is-panning { cursor: grabbing; }
.viewport.is-dropper { cursor: crosshair; }
#world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}
#world img,
#world video {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}
.empty-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: "Playfair Display", serif;
  font-style: italic;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  color: rgba(148,163,184,0.45);
  letter-spacing: 0.04em;
}
.viewport.has-media .empty-label { display: none; }

.zoom-controls {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  display: flex;
  gap: 0.25rem;
  z-index: 2;
}
.zoom-controls button,
.nav-arrow,
.upload-btn,
.dropper-btn {
  border: 1px solid var(--border);
  background: rgba(8,10,28,0.88);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
}
.zoom-controls button {
  width: 28px;
  height: 28px;
  font-size: 1rem;
  line-height: 1;
}
.zoom-controls button:hover,
.nav-arrow:hover,
.upload-btn:hover,
.dropper-btn:hover {
  border-color: rgba(34,211,238,0.55);
}

.image-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.5rem;
  border-top: 1px solid var(--border);
  background: rgba(8,10,28,0.92);
  min-width: 0;
}
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.65rem;
  font-family: Cinzel, serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold-light);
  white-space: nowrap;
}
.upload-btn .up { font-size: 0.85rem; line-height: 1; }
.dropper-btn {
  width: 34px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.dropper-btn[aria-pressed="true"] {
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(34,211,238,0.35);
}
.nav-arrow {
  width: 26px;
  height: 32px;
  flex: 0 0 auto;
  font-size: 1.15rem;
  line-height: 1;
}
.ribbon {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  flex: 1 1 auto;
  min-width: 0;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.ribbon button {
  width: 44px;
  height: 36px;
  padding: 0;
  flex: 0 0 auto;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #000;
  overflow: hidden;
  cursor: pointer;
}
.ribbon button.is-current { border-color: var(--gold); box-shadow: 0 0 8px rgba(251,191,36,0.35); }
.ribbon img { width: 100%; height: 100%; object-fit: cover; display: block; }

.img-note {
  padding: 0 0.6rem 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(8,10,28,0.92);
}
.img-note:empty { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .tool {
    grid-template-columns: 1fr;
    grid-template-areas:
      "rgb"
      "hex"
      "hsl"
      "cmyk"
      "picks"
      "image";
  }
  .imagebox { min-height: 280px; }
}

@media (max-width: 560px) {
  .site-nav { padding: 0 1rem; }
  .swatches { grid-template-columns: 1fr 1fr; }
  .swatch-readout { font-size: 1.2rem; }
  .wheel-wrap, .grad-wrap { height: 200px; }
  #wheel { width: min(200px, 70vw); }
}

@media (prefers-reduced-motion: reduce) {
  .nebula::before, .nebula::after, .logo-dot { animation: none; }
  .ribbon { scroll-behavior: auto; }
}
