/* Layout: the design fills the stage; up to three visuals sit as tabs under it; the rack holds the selected visual's
   own sliders, then music, then personalities. Grayscale steel UI; only the visuals carry color. */
:root {
  color-scheme: dark;
  --bg: #08080a;
  --panel: #111114;
  --panel-hi: #19191d;
  --well: #040405;
  --line: rgba(232, 232, 242, .08);
  --line-hi: rgba(232, 232, 242, .18);
  --fg: #d8d8de;
  --muted: #8f8f98;
  --dim: #5c5c64;
  --silver: #f2f2f6;
  --font-ui: "Jost", "Futura", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font-family: var(--font-ui); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1px solid var(--silver); outline-offset: 2px; }
a { color: var(--fg); }
.wrap { max-width: 1400px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); padding-block: env(safe-area-inset-top, 0px) calc(32px + env(safe-area-inset-bottom, 0px)); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px; border-bottom: 1px solid var(--line); }
.mark { font-weight: 300; font-size: 20px; letter-spacing: .42em; color: var(--silver); }

.main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; padding-top: 14px; }
.stage-col { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 8px); display: grid; gap: 10px; min-width: 0; }
.stage { position: relative; aspect-ratio: 16 / 10; max-width: 100%; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line);
  background-color: var(--well); background-image: radial-gradient(rgba(232,232,242,.06) 1px, transparent 1.2px); background-size: 28px 28px; background-position: 14px 14px; }
#stage { width: 100%; height: 100%; display: block; }
.beat { position: absolute; right: 12px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--silver); opacity: .18; pointer-events: none; }

.layers { display: flex; gap: 8px; flex-wrap: wrap; }
.layer-tab { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; color: var(--muted); }
.layer-tab i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, #888); }
.layer-tab[aria-pressed="true"] { color: var(--silver); border-color: var(--line-hi); background: var(--panel-hi); }
.layer-tab.off { opacity: .5; }
.add-tab { border-style: dashed; }

.rack { display: grid; gap: 12px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 12px; min-width: 0; }
.card h3, .grp h3 { margin: 0; font-size: 11.5px; font-weight: 400; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h3 span, .grp h3 span { letter-spacing: .04em; text-transform: none; color: var(--dim); font-size: 12px; }
.grp { display: grid; gap: 10px; }
.ctls { display: grid; gap: 12px; }
.ctl { display: grid; gap: 5px; }
.ctl-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ctl label { font-size: 13.5px; }
.ctl output { font-family: var(--font-data); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ctl-hint { font-size: 12px; color: var(--dim); line-height: 1.35; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; margin: 0; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--silver) var(--p), #2a2a30 var(--p)); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--silver) var(--p), #2a2a30 var(--p)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7.5px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fafafc, #9a9aa3 70%); border: 1px solid #2a2a30; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fafafc, #9a9aa3 70%); border: 1px solid #2a2a30; }
.sel { appearance: none; -webkit-appearance: none; width: 100%; background-color: var(--panel-hi); border: 1px solid var(--line-hi); border-radius: 7px; padding: 8px 28px 8px 10px; font-size: 13.5px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 11px) 52%; background-size: 4px 4px; background-repeat: no-repeat; }
textarea { width: 100%; resize: vertical; background: var(--well); border: 1px solid var(--line-hi); border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.4; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel-hi); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; color: var(--muted); font-size: 13px; }
.chip[aria-pressed="true"] { color: #0b0b0d; background: var(--silver); border-color: var(--silver); }
.btn { background: var(--panel); border: 1px solid var(--line-hi); border-radius: 8px; padding: 7px 12px; color: var(--fg); font-size: 13px; }
.btn:hover { background: var(--panel-hi); }
.btn[aria-pressed="true"] { background: var(--silver); color: #0b0b0d; border-color: var(--silver); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.transport { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.transport[hidden] { display: none; }
.transport #t-play { min-width: 64px; }
.transport input[type=range] { flex: 1; min-width: 0; }
.t-time { font-family: var(--font-data); font-size: 12px; color: var(--muted); white-space: nowrap; }
.now { font-family: var(--font-data); font-size: 12px; color: var(--muted); }
.desc { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary h3::after { content: "+"; font-family: var(--font-data); }
details[open] > summary h3::after { content: "−"; }
.danger { color: #d6a9a9; }
.foot { font-size: 12px; color: var(--dim); margin: 4px 2px; }
.capture { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.cap-head { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.meter { height: 3px; border-radius: 2px; background: #1d1d22; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--silver); transition: width .08s linear; }

/* full-screen play: only the design */
body.playing .top, body.playing .rack, body.playing .layers { display: none; }
body.playing .wrap { padding: 0; max-width: none; }
body.playing .main { display: block; padding: 0; }
body.playing .stage-col { position: fixed; inset: 0; z-index: 10; }
body.playing .stage { aspect-ratio: auto; width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0; }
.exit-play { position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: rgba(17,17,20,.7); border: 1px solid var(--line-hi); color: var(--muted); border-radius: 999px; padding: 6px 14px; font-size: 12px; transition: opacity .6s; }
.exit-play.fade { opacity: 0; }

@media (max-width: 860px) {
  .main { grid-template-columns: minmax(0, 1fr); }
  .stage-col { top: env(safe-area-inset-top, 0px); z-index: 2; background: var(--bg); padding-block: 6px; }
  .stage { aspect-ratio: 4 / 3; max-height: 40vh; width: 100%; }
}

/* saved designs */
#save-form { flex-wrap: nowrap; }
.name-in { flex: 1; min-width: 0; background: var(--well); border: 1px solid var(--line-hi); border-radius: 8px; padding: 7px 10px; font-size: 13.5px; }
.design { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-hi); overflow: hidden; }
.design button { background: none; border: 0; color: var(--fg); font-size: 13px; padding: 6px 4px 6px 12px; }
.design .x { color: var(--dim); padding: 6px 10px 6px 6px; }
.design .x.armed { color: #d6a9a9; padding-left: 8px; }

.cycle-name { position: absolute; left: 16px; top: calc(14px + env(safe-area-inset-top, 0px)); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--silver); opacity: 0; transition: opacity .8s; pointer-events: none; text-shadow: 0 1px 8px rgba(0,0,0,.8); }
.cycle-name.show { opacity: .85; }
.sync { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.sync-form { display: grid; gap: 8px; }
.sync-form .name-in { width: 100%; }
@media (max-width: 860px) { .top .row .btn { padding: 7px 10px; } }

/* Tap to sync: covers the stage so the design can't give away the beat */
.cal { position: absolute; inset: 0; z-index: 5; background: var(--well); display: grid; place-content: center; justify-items: center; gap: 12px; padding: 20px; text-align: center; touch-action: manipulation; user-select: none; -webkit-user-select: none; cursor: pointer; }
.cal-x { position: absolute; right: 10px; top: 8px; background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; padding: 6px 10px; }
.cal-step { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); }
.cal-say { font-size: 14px; color: var(--fg); max-width: 30ch; line-height: 1.4; }
.cal-dot { width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line-hi); background: transparent; }
.cal-dot.flash { background: var(--silver); box-shadow: 0 0 28px rgba(242,242,246,.55); }
.cal-dot.fade { transition: background .25s, box-shadow .25s; }
.cal-dot.tap { border-color: var(--silver); }
.cal-pips { display: flex; gap: 6px; }
.cal-pips i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-hi); }
.cal-pips i.on { background: var(--silver); }
.cal-btns { justify-content: center; }
.offset-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.seg { gap: 6px; }
.chips.seg .chip { padding: 5px 10px; font-size: 12px; }
/* Color fold: the only color in the interface is the color you're choosing */
input[type=range].hue::-webkit-slider-runnable-track { height: 6px; background: linear-gradient(90deg, hsl(0 90% 55%), hsl(60 90% 55%), hsl(120 90% 55%), hsl(180 90% 55%), hsl(240 90% 55%), hsl(300 90% 55%), hsl(360 90% 55%)); }
input[type=range].hue::-moz-range-track { height: 6px; background: linear-gradient(90deg, hsl(0 90% 55%), hsl(60 90% 55%), hsl(120 90% 55%), hsl(180 90% 55%), hsl(240 90% 55%), hsl(300 90% 55%), hsl(360 90% 55%)); }
input[type=range].hue::-webkit-slider-thumb { margin-top: -6px; }
.pal-chip { display: inline-flex; align-items: center; gap: 7px; }
.pal-chip .sw { width: 30px; height: 10px; border-radius: 5px; display: inline-block; }
.pal-edit { display: grid; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.sw-live { height: 14px; border-radius: 7px; }
.x-btn { background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 4px 0 10px; }
.x-btn:hover { color: var(--silver); }
/* automation: the wave button beside a slider, the Low–High band on its track, and the panel beneath it */
.ctl-r { display: flex; align-items: center; gap: 8px; }
.auto-btn { width: 24px; height: 20px; padding: 0; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--dim); font-size: 14px; line-height: 1; }
.auto-btn:hover { color: var(--muted); border-color: var(--line-hi); }
.auto-btn[aria-pressed="true"] { color: var(--silver); border-color: var(--line-hi); background: var(--panel-hi); }
.ctl.auto > input[type=range] { pointer-events: none; }
.ctl.auto > input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(90deg, #2a2a30 var(--lo), rgba(242, 242, 246, .42) var(--lo), rgba(242, 242, 246, .42) var(--hi), #2a2a30 var(--hi)); }
.ctl.auto > input[type=range]::-moz-range-track { background: linear-gradient(90deg, #2a2a30 var(--lo), rgba(242, 242, 246, .42) var(--lo), rgba(242, 242, 246, .42) var(--hi), #2a2a30 var(--hi)); }
.auto-panel { display: grid; gap: 10px; margin-top: 4px; padding: 10px 10px 12px; border: 1px solid var(--line); border-left: 2px solid var(--line-hi); border-radius: 8px; background: rgba(0, 0, 0, .25); }
.auto-line { display: grid; gap: 6px; }
.auto-line > span { font-size: 12px; color: var(--muted); }
