:root {
  color-scheme: dark light;
  --bg: #0b0b0d;
  --surface: rgb(28 28 32 / 0.72);
  --surface-solid: #1c1c20;
  --line: rgb(255 255 255 / 0.1);
  --text: #f5f5f7;
  --muted: #a1a1aa;
  --accent: #667eea;
  --on-accent: #fff;
  --ambient-opacity: 0.38;
  --radius: 22px;
  --gutter: clamp(16px, 4vw, 40px);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f5f2;
    --surface: rgb(255 255 255 / 0.78);
    --surface-solid: #fff;
    --line: rgb(0 0 0 / 0.1);
    --text: #17171a;
    --muted: #5d5d66;
    --ambient-opacity: 0.3;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI",
    "Hiragino Sans", "Apple SD Gothic Neo", "Noto Sans CJK JP", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ul { margin: 0; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 7vw, 4.6rem); font-weight: 800; }
h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 750; }
h3 { font-size: 1.25rem; font-weight: 700; }
a { color: inherit; }
code, pre { font-family: var(--mono); }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ---------- ambient color ---------- */

.ambient {
  position: fixed;
  inset: -12%;
  width: 124%;
  height: 124%;
  z-index: -1;
  opacity: var(--ambient-opacity);
  filter: blur(60px) saturate(1.2);
  pointer-events: none;
}

/* ---------- chrome ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px var(--gutter);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; }
.brand img { border-radius: 9px; }
.top-nav { display: flex; gap: 20px; margin-left: auto; }
.top-nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.top-nav a:hover { color: var(--text); }
.top > .button { margin-left: 0; }
.top:not(:has(.top-nav)) { justify-content: space-between; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.button:hover { transform: translateY(-1px); opacity: 0.9; }
.button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.button.small { padding: 8px 16px; font-size: 0.9rem; }
.button:has(:focus-visible) { outline: 2px solid var(--text); outline-offset: 3px; }

.fine { color: var(--muted); font-size: 0.85rem; }
.center { text-align: center; }

main { display: grid; gap: clamp(72px, 12vw, 140px); padding: 0 var(--gutter) 96px; }
section, .legal { width: 100%; max-width: 1120px; margin: 0 auto; }

/* ---------- hero ---------- */

.hero {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding-top: clamp(48px, 10vw, 110px);
  text-align: center;
}
.hero-icon { border-radius: 22px; box-shadow: 0 18px 50px rgb(0 0 0 / 0.35); }
.eyebrow { color: var(--muted); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.8rem; }
.lead { max-width: 44rem; font-size: clamp(1.05rem, 2.2vw, 1.3rem); color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 10px; }

.section-head { display: grid; gap: 12px; max-width: 46rem; margin: 0 auto 32px; text-align: center; }
.section-head p { color: var(--muted); }

/* ---------- demo ---------- */

.panel, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
.panel { display: grid; gap: 16px; padding: 20px; align-content: start; min-width: 0; }

.demo-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); margin-bottom: 20px; }
.side { display: grid; gap: 20px; align-content: start; min-width: 0; }

.stage {
  position: relative;
  aspect-ratio: var(--ratio, 3 / 4);
  max-height: 62vh;
  margin: 0 auto;
  touch-action: none;
}
.stage canvas#photo { display: block; width: 100%; height: 100%; border-radius: 16px; }
.dots { position: absolute; inset: 0; }

.dot {
  position: absolute;
  width: 30px;
  height: 30px;
  padding: 0;
  translate: -50% -50%;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.45), 0 4px 12px rgb(0 0 0 / 0.4);
  cursor: grab;
  touch-action: none;
  transition: scale 0.15s ease;
}
.dot::after { content: ""; position: absolute; inset: -10px; } /* a comfortable touch target */
.dot.selected { scale: 1.25; z-index: 1; }
.dot:active { cursor: grabbing; }

.loupe {
  position: absolute;
  width: 132px;
  height: 132px;
  translate: -50% calc(-100% - 28px);
  border: 5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.5);
  pointer-events: none;
  z-index: 2;
}
.loupe.below { translate: -50% 28px; }

.status { color: var(--muted); font-size: 0.85rem; text-align: center; min-height: 1.4em; }

.swatches { display: flex; height: 54px; border-radius: 14px; overflow: hidden; }
.swatch { flex: 1; border: 0; padding: 0; cursor: pointer; transition: flex 0.2s ease; }
.swatch[aria-selected="true"] { flex: 1.8; }
.swatch:focus-visible { outline-offset: -4px; }

.controls, .sources { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.segmented {
  display: flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text) 9%, transparent);
  max-width: 100%;
}
.segmented button {
  flex: 1;
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface-solid); box-shadow: 0 1px 4px rgb(0 0 0 / 0.25); }
.counts button { padding-inline: 10px; }

/* The color detail sits on the color itself, like in the app. */
.detail {
  background: var(--swatch, var(--surface));
  color: var(--on-swatch, var(--text));
  transition: background 0.25s ease;
}
.detail-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; min-height: 3.6rem; }
.detail-name { font-size: 1.5rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; }
.detail-hex { font-family: var(--mono); opacity: 0.8; }
.detail .segmented { background: color-mix(in srgb, var(--on-swatch) 14%, transparent); }
.detail .segmented button[aria-pressed="true"] { background: var(--on-swatch); color: var(--swatch); }
.detail .fine { color: inherit; opacity: 0.75; }
.detail .fine:empty { display: none; }

.chip {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--on-swatch, var(--text));
  color: var(--swatch, var(--bg));
  font-size: 0.8rem;
  font-weight: 650;
}

.rows { display: grid; gap: 6px; min-height: 17.5rem; align-content: start; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--on-swatch) 10%, transparent);
  color: inherit;
  font: inherit;
  text-align: start;
}
button.row { cursor: copy; }
button.row:hover { background: color-mix(in srgb, var(--on-swatch) 18%, transparent); }
.row-label { flex: 0 0 4.2rem; font-size: 0.75rem; opacity: 0.75; }
.row code { font-size: 0.85rem; overflow-wrap: anywhere; min-width: 0; }
.aa { flex: none; padding: 4px 10px; border-radius: 8px; font-weight: 700; border: 1px solid color-mix(in srgb, var(--on-swatch) 35%, transparent); }
.level { margin-left: auto; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.level-pass { background: var(--on-swatch); color: var(--swatch); }
.level-fail { border: 1px solid currentColor; opacity: 0.8; }

.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.code {
  margin: 0;
  padding: 16px;
  min-height: 12.5rem;
  border-radius: 14px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
}

/* ---------- features ---------- */

.cards { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { display: grid; gap: 14px; padding: clamp(22px, 3vw, 32px); align-content: start; min-width: 0; }
.card.wide { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.card.wide:not(:has(> :nth-child(2))) { grid-template-columns: 1fr; }
.card-text { display: grid; gap: 14px; }
.card p, .card li { color: var(--muted); }
.card ul { display: grid; gap: 10px; padding: 0; list-style: none; }
.card li { position: relative; padding-left: 20px; }
.card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--line); /* stays visible when the picked color is close to the card */
}

.viewfinder {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--on-accent);
  transition: background 0.3s ease;
}
.reticle { width: 64px; height: 64px; border: 3px solid currentColor; border-radius: 50%; position: relative; }
.reticle::after { content: ""; position: absolute; inset: 24px; border: 2px solid currentColor; border-radius: 50%; }
.reading {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  line-height: 1.3;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.reading-swatch { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--accent); border: 1px solid rgb(255 255 255 / 0.4); }

.harmonies { display: grid; gap: 8px; }
.harmony { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; color: var(--muted); }
.strip { display: flex; flex: 0 0 45%; height: 26px; border-radius: 8px; overflow: hidden; }
.strip i { flex: 1; transition: background 0.3s ease; }

.mesh { width: 100%; height: 260px; border-radius: 18px; display: block; }

/* ---------- pro, footer, legal ---------- */

.faq-list { display: grid; gap: 16px; max-width: 46rem; margin: 0 auto; }

.pro { display: grid; justify-items: center; gap: 18px; max-width: 46rem; text-align: center; }
.pro p { color: var(--muted); }

.bottom {
  display: grid;
  gap: 18px;
  justify-items: center;
  padding: 36px var(--gutter) calc(36px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  text-align: center;
}
.bottom nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; }
.bottom a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.bottom a:hover, .bottom a[aria-current] { color: var(--text); }

.legal { max-width: 46rem; padding-top: 48px; display: grid; gap: 14px; }
.legal h1 { font-size: 2.2rem; }
.legal h2 { font-size: 1.35rem; margin-top: 22px; }
.legal h3 { font-size: 1.05rem; margin-top: 8px; }
.legal p, .legal li { color: var(--muted); }
.legal ul { display: grid; gap: 6px; padding-left: 22px; }
.legal a { color: var(--text); }
.legal hr { width: 100%; border: 0; border-top: 1px solid var(--line); }

/* ---------- small screens, motion ---------- */

@media (max-width: 860px) {
  .demo-grid, .cards, .card.wide { grid-template-columns: minmax(0, 1fr); }
  .top-nav { display: none; }
  .top { justify-content: space-between; }
  .rows, .code { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
