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

:root {
  --room: #f2f2f1;
  --panel: #fbfbfa;
  --ink: #171715;
  --gray: #8a8a86;
  --line: #e3e3e1;
  --blue: #2547f4;           /* the single accent; pigment is the only other color */
  --sans: -apple-system, "SF Pro Text", "Helvetica Neue", Inter, sans-serif;
}

html, body { height: 100%; }
body {
  background: var(--room);
  color: var(--ink);
  font: 11px/1.5 var(--sans);
  letter-spacing: .01em;
  overflow: hidden;
}
::selection { background: var(--blue); color: #fff; }

main { display: flex; height: 100vh; }

/* ---------- stage ---------- */
#stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  background: var(--room);
  transition: background .6s ease;
}
body.backlit #stage { background: #0b0b0b; }

#sheet { position: relative; }
#sheet::after { /* crisp edge, then air */
  content: "";
  position: absolute; inset: 0;
  box-shadow: 0 0 0 1px rgba(23,23,21,.07), 0 24px 80px rgba(23,23,21,.14);
  pointer-events: none;
  transition: box-shadow .6s ease;
}
body.backlit #sheet::after {
  box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 0 120px rgba(255,244,214,.25);
}
#paper { display: block; width: 100%; height: 100%; cursor: none; touch-action: none; }
#cursor {
  position: absolute;
  border: 1px solid rgba(23,23,21,.6);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
}
body.backlit #cursor { border-color: rgba(255,255,255,.65); }
.glfail { color: var(--gray); text-align: center; }

/* ---------- rail ---------- */
#rail {
  width: 264px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 20px 18px 12px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: none;
}
#rail::-webkit-scrollbar { display: none; }

#brand { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
#brand h1 { font-size: 11px; font-weight: 600; letter-spacing: .34em; }
#brand span { font-size: 8.5px; color: var(--gray); letter-spacing: .06em; }

.block { border-top: 1px solid var(--line); padding: 12px 0 10px; }
h2 {
  font-size: 8.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .24em;
  color: var(--gray);
  margin-bottom: 8px;
}
.blockhead { display: flex; justify-content: space-between; align-items: baseline; }
.blockhead.sub { margin-top: 12px; }
#libname { font-size: 9.5px; color: var(--gray); }

.mini {
  background: none; border: none; cursor: pointer;
  font: 8.5px var(--sans);
  text-transform: uppercase; letter-spacing: .18em;
  color: var(--gray);
  padding: 0;
}
.mini:hover { color: var(--blue); }

/* pigment */
#mixrow { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
#wellprev { width: 44px; height: 44px; border-radius: 50%; flex: none; }
#mixname { font-size: 10.5px; }
#mixinfo .mini { margin-top: 3px; }

#wells { display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; margin-bottom: 8px; }
.well { aspect-ratio: 1; border-radius: 50%; border: none; cursor: pointer; }
.well.empty { background: none; border: 1px dashed var(--line); cursor: default; }
.well.sel { outline: 1.5px solid var(--blue); outline-offset: 2px; }

#chips { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.chip { display: flex; align-items: center; gap: 7px; font-size: 9.5px; }
.chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.chip input[type="range"] { width: 64px; }

#library { display: grid; grid-template-columns: repeat(13, 1fr); gap: 5px; }
.dot { aspect-ratio: 1; border-radius: 50%; border: none; cursor: pointer; }
.dot:hover { transform: scale(1.3); }

/* params */
.param { display: grid; grid-template-columns: 44px 1fr 30px; align-items: center; gap: 10px; margin-bottom: 8px; }
.param h2 { margin: 0; }
.param output {
  font-size: 15px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1px;
  background: #cfcfcc;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 9px; height: 9px;
  border-radius: 0;
  background: var(--ink);
  cursor: ew-resize;
}
input[type="range"]::-moz-range-thumb {
  width: 9px; height: 9px;
  border: none; border-radius: 0;
  background: var(--ink);
  cursor: ew-resize;
}

/* buttons: quiet text instruments */
#tools, #papers, #alive, #actions { display: flex; gap: 4px; flex-wrap: wrap; }
#tools button, #papers button, #alive button, #actions button, .wide {
  background: none;
  border: 1px solid var(--line);
  padding: 5px 9px;
  font: 9px var(--sans);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--ink);
  cursor: pointer;
  border-radius: 2px;
}
#tools button:hover, #papers button:hover, #alive button:hover,
#actions button:hover, .wide:hover { border-color: var(--ink); }
#tools button.sel, #papers button.sel, #alive button.sel, .wide.sel {
  border-color: var(--blue);
  color: var(--blue);
}
.wide { width: 100%; text-align: center; }

footer {
  margin-top: auto;
  padding-top: 14px;
  font-size: 8.5px;
  letter-spacing: .06em;
  color: var(--gray);
}

/* phones and tablets: stack, keep the sheet generous */
@media (max-width: 900px) {
  body { overflow: auto; }
  main { flex-direction: column; height: auto; }
  #stage { min-height: 66vh; padding: 18px 0; }
  #rail {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
    overflow: visible;
  }
}

/* fat fingers deserve fat controls */
@media (pointer: coarse) {
  #cursor { display: none; }
  input[type="range"] { height: 2px; }
  input[type="range"]::-webkit-slider-thumb { width: 18px; height: 18px; border-radius: 50%; }
  input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; }
  #tools button, #papers button, #alive button, #actions button, .wide { padding: 9px 13px; font-size: 10px; }
  #wells { gap: 9px; }
  #library { grid-template-columns: repeat(10, 1fr); gap: 8px; }
  .chip input[type="range"] { width: 90px; }
}

/* toast */
#toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(6px);
  background: var(--ink);
  color: #fff;
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
