:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --sunken: #eceef3;
  --text: #15171c;
  --muted: #596170;
  --line: #dde1e8;
  --ink: #15171c;
  --on-ink: #ffffff;
  --focus: #3d6df2;
  --danger: #b42318;
  --ok: #157347;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d0f13;
  --surface: #171a20;
  --sunken: #0f1217;
  --text: #eceef2;
  --muted: #a1a9b7;
  --line: #2a2f39;
  --ink: #eceef2;
  --on-ink: #0d0f13;
  --focus: #7c9dff;
  --danger: #ff8f86;
  --ok: #63d297;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: clip;
  transition: background-color .25s, color .25s;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p, dl { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(100% - 2rem, 72rem); margin-inline: auto; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 30;
  padding: .6rem 1rem; border-radius: .625rem;
  background: var(--ink); color: var(--on-ink);
}
.skip:focus { top: 1rem; }

.bar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar-in {
  display: grid; align-items: center; gap: 1rem; min-height: 4rem;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "b t c";
}
.brand { grid-area: b; display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.0625rem; letter-spacing: -.01em; }
.tabs { grid-area: t; justify-self: start; display: flex; gap: .25rem; padding: .25rem; background: var(--sunken); border: 1px solid var(--line); border-radius: .75rem; }
.ctrl { grid-area: c; display: flex; align-items: center; gap: .5rem; }

.dots { display: flex; }
.dots i { width: .95rem; height: .95rem; margin-left: -.3rem; border-radius: 50%; border: 2px solid var(--bg); }
.dots i:first-child { margin-left: 0; background: #ef4444; }
.dots i:nth-child(2) { background: #22c55e; }
.dots i:nth-child(3) { background: #3b82f6; }

.tab, .seg button {
  min-height: 2.5rem; padding: 0 1rem; border: 0; border-radius: .55rem;
  background: transparent; color: var(--muted); font-weight: 600;
  transition: background-color .2s, color .2s;
}
.tab:hover, .seg button:hover { color: var(--text); }
.tab[aria-current="page"], .seg [aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.seg { display: inline-flex; gap: .15rem; padding: .2rem; background: var(--sunken); border: 1px solid var(--line); border-radius: .75rem; }
.seg button { min-height: 2.25rem; padding: 0 .65rem; font-size: .875rem; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; min-height: 2.75rem; padding: 0 .25rem; }

.icon-btn {
  display: grid; place-items: center; width: 2.5rem; height: 2.5rem;
  border: 1px solid var(--line); border-radius: .75rem; background: var(--sunken);
  transition: border-color .2s;
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .moon, :root:not([data-theme="dark"]) .sun { display: none; }

.panel { padding-block: 2rem 1rem; animation: rise .4s ease both; }
.head { margin-bottom: 1.5rem; }
.head h1 { margin-bottom: .5rem; font-size: clamp(1.75rem, 4.5vw, 2.5rem); line-height: 1.1; letter-spacing: -.025em; }
.head p { max-width: 60ch; color: var(--muted); }

.mix-grid, .find-grid { display: grid; gap: 1.5rem; align-items: start; grid-template-columns: minmax(0, 1fr) 22rem; }
.find-grid { grid-template-columns: 22rem minmax(0, 1fr); }
.result, .target { position: sticky; top: 5.5rem; display: grid; gap: 1rem; }

.card { padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); }
.row-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.row-head h2 { font-size: 1.125rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.5rem; padding: 0 1rem;
  border: 1px solid var(--line); border-radius: .625rem;
  background: var(--surface); color: var(--text); font-weight: 600;
  transition: transform .12s, border-color .2s, opacity .2s, background-color .2s, color .2s;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover:not(:disabled) { opacity: .88; border-color: var(--ink); }
.btn.done { background: var(--surface); border-color: var(--ok); color: var(--ok); }
.btn.sm { min-height: 2.25rem; padding: 0 .75rem; font-size: .875rem; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: .875rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr)); }
.cc { display: grid; gap: .75rem; padding: .75rem; }
.cc-body { display: grid; gap: .35rem; }
.cc-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

.pick {
  position: relative; display: grid; place-items: center; height: 5.5rem;
  border: 1px solid rgba(127, 127, 127, .35); border-radius: .75rem; background: var(--sunken);
  cursor: pointer; font: 700 1.5rem/1 var(--mono);
  transition: background-color .35s ease, color .35s ease;
}
.pick input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.pick:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.tpick { height: 8rem; }

.hex, .field input {
  width: 100%; min-height: 2.75rem; padding: 0 .75rem;
  border: 1px solid var(--line); border-radius: .625rem;
  background: var(--sunken); color: var(--text);
}
.hex { font-family: var(--mono); text-transform: uppercase; }
.field input { font-weight: 500; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.err { color: var(--danger); font-size: .8125rem; font-weight: 600; }
.rgb { color: var(--muted); font: .8125rem var(--mono); overflow-wrap: anywhere; }

.enter { animation: pop .3s ease both; }

.swatch {
  display: grid; place-items: center; height: 13rem; padding: 1rem;
  border: 1px solid rgba(127, 127, 127, .35); border-radius: .875rem; background: var(--sunken);
  font: 700 clamp(1.5rem, 5vw, 2.25rem)/1.1 var(--mono); text-align: center; overflow-wrap: anywhere;
  transition: background-color .5s ease, color .5s ease;
}
.facts { display: grid; gap: .5rem; }
.facts div { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem .75rem; border-radius: .625rem; background: var(--sunken); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font: 600 .9375rem var(--mono); text-align: right; overflow-wrap: anywhere; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.acts .wide { grid-column: 1 / -1; }

.empty {
  display: grid; justify-items: center; gap: .6rem; padding: 2.5rem 1rem; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 1rem; color: var(--muted);
}
.empty strong { color: var(--text); font-size: 1.0625rem; }

.field { display: grid; gap: .3rem; color: var(--muted); font-size: .875rem; font-weight: 600; }
.rgb3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.group { display: grid; gap: .4rem; color: var(--muted); font-size: .875rem; font-weight: 600; }

.status { display: flex; align-items: center; gap: .6rem; min-height: 1.5rem; margin-bottom: 1rem; color: var(--muted); }
.status.busy::before {
  content: ""; flex: none; width: 1rem; height: 1rem;
  border: 2px solid var(--line); border-top-color: var(--text); border-radius: 50%;
  animation: turn .7s linear infinite;
}

.combos { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); transition: opacity .2s; }
.combos.dim { opacity: .45; pointer-events: none; }
.combo { display: grid; gap: .75rem; }
.combo.enter { animation: rise .35s ease both; animation-delay: calc(var(--i, 0) * 50ms); }
.strip { display: flex; height: 4.5rem; overflow: hidden; border: 1px solid rgba(127, 127, 127, .35); border-radius: .75rem; }
.strip span { flex: 1; }
.parts { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; font: .8125rem var(--mono); }
.parts li { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
.parts i, .mini { flex: none; width: 1rem; height: 1rem; border: 1px solid rgba(127, 127, 127, .4); border-radius: .25rem; }
.parts span { color: var(--muted); }
.out { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: .625rem; background: var(--sunken); font-size: .875rem; }
.out b { font-family: var(--mono); }
.mini { width: 2.25rem; height: 2.25rem; border-radius: .5rem; }
.match { color: var(--muted); font-size: .8125rem; }

.about { margin-top: 3rem; padding-block: 2.5rem; border-top: 1px solid var(--line); }
.about h2 { margin-bottom: .5rem; font-size: 1.375rem; letter-spacing: -.01em; }
.about > p { max-width: 62ch; margin-bottom: 1.5rem; color: var(--muted); }
.about-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.about-grid div { padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; }
.about h3 { margin-bottom: .35rem; font-size: 1rem; }
.about-grid p { color: var(--muted); font-size: .9375rem; }

.foot { padding-block: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.foot-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; }
.foot strong { color: var(--text); }
.foot small { font-size: inherit; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
@keyframes turn { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .mix-grid, .find-grid { grid-template-columns: minmax(0, 1fr); }
  .result, .target { position: static; }
  .result { order: -1; }
}

@media (max-width: 640px) {
  .bar-in { grid-template-columns: 1fr auto; grid-template-areas: "b c" "t t"; gap: .5rem; padding-block: .6rem; }
  .tabs { justify-self: stretch; }
  .tab { flex: 1; padding: 0 .5rem; }
  .swatch { height: 10.5rem; }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (pointer: coarse) {
  .btn, .btn.sm, .tab, .seg button, .icon-btn { min-height: 2.75rem; }
  .icon-btn { width: 2.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}