:root {
  color-scheme: dark;
  --page: #101112;
  --bezel: #1b1d20;
  --black: #111416;
  --pane: #191c1f;
  --tile: #252a2e;
  --line: #4a5359;
  --ink: #f3f6f7;
  --muted: #bac3c8;
  --active: #79dcf3;
  --active-ink: #081719;
  --touch-min: 48px;
  font: 100%/1.4 system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--page);
}
* { box-sizing: border-box; }
body, p, h1, h2, h3 { margin: 0; }
body { display: flow-root; }
a { color: inherit; text-underline-offset: .28em; }
button, a { touch-action: manipulation; }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--active); outline-offset: 3px; }
.skip { position: fixed; left: 1rem; top: 1rem; z-index: 1; padding: .8rem; background: var(--pane); }
.skip:not(:focus) { clip-path: inset(50%); }
.site-header {
  width: min(100% - 2rem, 80rem);
  margin-inline: auto;
  min-height: 3.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-header a { color: var(--muted); font-size: .9rem; padding-block: .75rem; }
.site-header img { display: block; width: 6.5rem; height: auto; filter: brightness(0) invert(1); }
.panel {
  width: min(100% - 1.75rem, 80rem);
  margin: .2rem auto .75rem;
  padding: .75rem;
  border-radius: 1.25rem;
  background: var(--bezel);
  border: 1px solid #3d4245;
  box-shadow: 0 .7rem 2.5rem #050607a3, inset 0 1px #363b3f;
}
#editor-form {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border: 1px solid #0d0f10;
  border-radius: .68rem;
  background: var(--black);
}
.panel-header, .region-header, .preview-header, .preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
}
.panel-header { padding: .95rem 1.25rem; border-bottom: 1px solid var(--line); }
.panel-header h1 { font-size: clamp(1.35rem, 2.6vw, 2rem); letter-spacing: -.035em; line-height: 1.05; }
.panel-header p { color: var(--muted); font-size: .86rem; margin-top: .35rem; }
.toolbar { display: flex; justify-content: flex-end; align-items: center; gap: .55rem; }
.toolbar button { white-space: nowrap; }
.toolbar #save-status { margin: 0 .3rem 0 0; text-align: right; max-width: 17rem; }
button {
  min-height: var(--touch-min);
  padding: .55rem 1rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--tile);
  color: var(--ink);
  font-weight: 700;
}
button:hover { background: #323a3f; }
button:active:not(:disabled) { background: #192e35; border-color: var(--active); box-shadow: inset 0 2px 0 #080c0e; }
button:disabled { cursor: default; opacity: .42; }
.primary { background: var(--active); border-color: var(--active); color: var(--active-ink); }
.primary:hover, .primary:active:not(:disabled) { background: #a1ebf9; }
#save-status[data-state="dirty"] { color: var(--ink); }
#save-status[data-state="invalid"] { color: #edc2bd; }
#save-status[data-state="saved"] { color: #9ce1b2; }
.cue-bank { padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); }
.cue-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; }
.cue, .step-select {
  width: 100%;
  min-height: 60px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: .7rem;
  text-align: left;
}
.cue > span:last-child, .step-select > span:last-child { min-width: 0; }
.cue-title, .step-title { display: block; overflow-wrap: anywhere; line-height: 1.18; }
.cue small, .step-select small { display: block; color: var(--muted); font-size: .79rem; font-weight: 550; margin-top: .22rem; }
.cue-number, .step-number, .eyebrow, .region-note, .preview-time {
  font: 650 .75rem/1.4 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .055em;
}
.cue-number, .step-number, .region-note { color: var(--muted); }
.cue[aria-current="true"], .step-select[aria-current="true"] {
  background: #1c2b31;
  border-color: #629eab;
  box-shadow: inset 3px 0 var(--active);
}
[aria-current="true"] .cue-number, [aria-current="true"] .step-number, .cue[data-dirty="true"] small { color: var(--active); }
.eyebrow { color: var(--muted); }
.eyebrow { text-transform: uppercase; }
.workspace { display: grid; grid-template-columns: .96fr 1.04fr; min-height: 0; }
.sequence, .detail { min-width: 0; min-height: 0; padding: 1rem 1.25rem 1.15rem; background: var(--pane); }
.sequence { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.detail { overflow: auto; }
.region-header { margin-bottom: .85rem; }
.region-header h2, dialog h2 { font-size: 1.4rem; letter-spacing: -.025em; line-height: 1.15; }
.region-header h2 { margin-top: .15rem; }
.region-note { text-align: right; }
label { display: block; min-width: 0; color: var(--muted); font-size: .86rem; font-weight: 650; }
label > span { display: block; margin-bottom: .35rem; }
input, select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--touch-min);
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--black);
  color: var(--ink);
  font-size: 1.04rem;
}
select { padding-right: .7rem; }
select:invalid { color: var(--active); }
input[type="number"] { appearance: textfield; text-align: center; }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { appearance: none; }

#steps, #preview-steps { list-style: none; padding: 0; margin: .75rem 0; display: grid; gap: .5rem; }
#steps { padding: .25rem; margin-inline: -.25rem; overflow: auto; flex: 0 1 auto; }
.step-select { min-height: 56px; }
.step-select small { overflow-wrap: anywhere; }
#add-step { align-self: flex-start; }
.step-controls { display: flex; gap: .45rem; }
.step-controls[hidden] { display: none; }
.step-controls button:not(.remove), .adjust { width: var(--touch-min); padding: 0; font-size: 1.2rem; }
.command-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.timing { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-top: 1rem; }
.timing-control { min-width: 0; padding: .7rem; background: var(--black); border: 1px solid var(--line); border-radius: .55rem; }
.timing-control label { margin-bottom: .35rem; }
.timing-control input { background: var(--pane); }
.timing-control p { margin-top: .5rem; color: var(--muted); font-size: .78rem; }
.adjustment { display: grid; grid-template-columns: var(--touch-min) minmax(2.35rem, 1fr) var(--touch-min); gap: .35rem; }
.dmx-value label { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; }
.unit-range { font: 650 .75rem/1 ui-monospace, Consolas, monospace; white-space: nowrap; }
.dmx-value p { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.level-presets p { margin: 0 0 .35rem; color: var(--muted); font-size: .86rem; font-weight: 650; }
.shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.shortcuts button { font: 650 .85rem/1.2 ui-monospace, Consolas, monospace; padding: .45rem; }
.dmx-note { color: var(--muted); margin-top: .55rem; font-size: .82rem; }
.timing-diagram { display: flex; gap: 3px; margin-top: .75rem; font: 650 .76rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
.timing-diagram span { padding: .43rem .65rem; flex-basis: 7.5rem; border: 1px solid var(--line); overflow-wrap: anywhere; }
.timing-wait { background: #292e32; color: var(--muted); border-radius: .35rem 0 0 .35rem; }
.timing-fade { color: var(--active); background: #1c2b31; border-radius: 0 .35rem .35rem 0; }
.remove { color: #edc2bd; padding-inline: .75rem; }
.empty, .notice { border: 1px dashed var(--line); border-radius: .5rem; padding: 1rem; color: var(--muted); }
.embedded .site-header, .capture .site-header { display: none; }
.capture .panel { width: 100%; max-width: none; min-height: 100dvh; margin: 0; border-radius: 0; display: grid; }
dialog {
  width: min(100% - 1.5rem, 42rem);
  max-height: calc(100% - 1.5rem);
  padding: 1.2rem;
  color: var(--ink);
  background: var(--pane);
  border: 1px solid var(--line);
  border-radius: .85rem;
}
dialog::backdrop { background: #090b0de8; }
.preview-header { align-items: start; }
.preview-header h2 { margin-top: .25rem; overflow-wrap: anywhere; }
.preview-note { margin-block: .75rem 1rem; color: var(--muted); font-size: .92rem; }
.preview-row { display: grid; align-items: center; grid-template-columns: 4rem minmax(0, 1fr) auto; gap: .6rem; padding: .7rem; border: 1px solid var(--line); border-radius: .4rem; }
.preview-time, .preview-row[data-state="waiting"] .preview-state, .preview-row[data-state="running"] .preview-state { color: var(--active); }
.preview-row[data-state="waiting"], .preview-row[data-state="running"] { border-color: var(--active); }
.preview-row[data-state="done"] .preview-state { color: #9ce1b2; }
.preview-state, #preview-status, .preview-row small { color: var(--muted); font-size: .8rem; }
.preview-row strong, .preview-row small { display: block; overflow-wrap: anywhere; }
#stop-preview { white-space: nowrap; }
@media (min-width: 800px) {
  body:not(.embedded):not(.capture) #editor-form { height: min(735px, calc(100dvh - 5.75rem)); min-height: 29.9rem; }
  .capture #editor-form { height: calc(100dvh - 1.625rem); min-height: 29.9rem; }
}
@media (min-width: 1050px) and (min-height: 700px) {
  :root { --touch-min: 56px; }
  .panel-header, .cue-bank { padding-inline: 1.45rem; }
  .panel-header { padding-block: 1.15rem; }
  .cue-bank { padding-block: 1rem; }
  .cue { min-height: 71px; }
  .sequence, .detail { padding: 1.3rem 1.45rem; }
  .region-header { margin-bottom: 1.1rem; }
  .step-select { min-height: 62px; }
  .timing { margin-top: 1.2rem; }
  .timing-control { padding: .9rem; }
}
@media (max-height: 680px) and (min-width: 850px) {
  .panel-header, .cue-bank { padding-block: .65rem; }
  .cue { min-height: 54px; }
  .sequence, .detail { padding-block: .7rem; }
  .region-header { margin-bottom: .65rem; }
  .timing { margin-top: .65rem; gap: .55rem; }
  .timing-control { padding: .55rem; }
}
@media (max-width: 850px) {
  .toolbar #save-status { max-width: 12rem; }
  .panel-header, .cue-bank, .sequence, .detail { padding-inline: .8rem; }
  .timing { grid-template-columns: minmax(0, 1fr); gap: .55rem; }
  .command-fields { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .panel { width: calc(100% - .75rem); padding: .4rem; border-radius: .85rem; }
  .site-header { width: calc(100% - 1.5rem); }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .toolbar { flex-wrap: wrap; justify-content: flex-start; }
  .toolbar #save-status { order: 1; width: 100%; max-width: none; text-align: left; }
  .cue-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cue, .step-select { padding-inline: .65rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sequence { border-right: 0; border-bottom: 1px solid var(--line); }
  .timing, .command-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 430px) {
  .timing, .command-fields { grid-template-columns: minmax(0, 1fr); }
  .preview-row { grid-template-columns: 3.1rem minmax(0, 1fr); }
  .preview-state { grid-column: 2; }
  .preview-footer { align-items: start; flex-direction: column; }
}

[data-keypad] { cursor: pointer; }
#keypad { width: min(100% - 1.5rem, 25rem); }
#keypad .preview-note { margin-block: .45rem .65rem; }
#keypad-value {
  display: block;
  min-height: 3rem;
  padding: .35rem .65rem;
  margin-bottom: .65rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--black);
  color: var(--ink);
  font: 650 1.65rem/1.25 ui-monospace, Consolas, monospace;
  text-align: right;
}
.keypad-keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .38rem; }
.keypad-keys button { font-size: 1.2rem; min-height: max(48px, var(--touch-min)); padding: .4rem; }
#keypad-clear { font-size: .9rem; }
#keypad-status { min-height: 1.4em; margin: .4rem 0; color: #edc2bd; font-size: .84rem; }
.keypad-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
