/* Control tab layout: fixed bars top and bottom, three columns between. */

.control-body {
  display: grid;
  grid-template-rows: 42px 1fr 44px;
  height: 100dvh;
}

/* ------------------------------------------------------------------ */
/* App bar                                                             */
/* ------------------------------------------------------------------ */

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
}

.app-bar-left,
.app-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.logo {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.project-name {
  width: 200px;
  background: transparent;
  border-color: transparent;
  font-weight: 600;
  font-size: 13px;
}

.project-name:hover { border-color: var(--line); }

.save-state {
  color: var(--text-faint);
  font-size: 11px;
  min-width: 60px;
}

.save-state.dirty { color: var(--warn); }

/* ------------------------------------------------------------------ */
/* Workspace                                                           */
/* ------------------------------------------------------------------ */

.workspace {
  display: grid;
  grid-template-columns: 268px 1fr 288px;
  min-height: 0;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  min-height: 0;
  overflow: hidden;
}

.panel-left { border-right: 1px solid var(--line); }
.panel-right { border-left: 1px solid var(--line); }

.panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  padding: 5px 5px 0;
  border-bottom: 1px solid var(--line);
}

.panel-tab {
  appearance: none;
  border: none;
  background: none;
  color: var(--text-faint);
  font: inherit;
  font-size: 11.5px;
  padding: 4px 7px;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
}

.panel-tab:hover { color: var(--text); background: var(--bg-raised); }

.panel-tab.active {
  color: var(--accent);
  background: var(--bg-raised);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px;
  min-height: 0;
}

.panel-page { display: none; }
.panel-page.active { display: block; }

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
  align-items: center;
}

.panel-heading {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 10.5px;
  margin: 14px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.panel-heading:first-child { margin-top: 0; }

.filter-row { margin-bottom: 8px; }

/* ------------------------------------------------------------------ */
/* Stage                                                               */
/* ------------------------------------------------------------------ */

.stage {
  display: grid;
  grid-template-rows: 36px 1fr 24px;
  min-width: 0;
  min-height: 0;
  background: #07080b;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tool-group.right { margin-left: auto; }

.tool {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text-dim);
  font: inherit;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.tool:hover { background: var(--bg-hover); color: var(--text); }

.tool.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #17110a;
  font-weight: 600;
}

.stage-hint {
  color: var(--text-faint);
  font-size: 11.5px;
  white-space: nowrap;
}

.stage-canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}

#stage {
  display: block;
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
  background: #000;
  touch-action: none;
}

#stage.tool-select { cursor: default; }
#stage.dragging { cursor: grabbing; }

.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 40px;
  background: rgba(7, 8, 11, 0.92);
  pointer-events: none;
}

.stage-empty p { max-width: 46ch; color: var(--text-dim); }

/* The overlay ignores pointer events so it can never swallow a stray click on
   the canvas; the buttons have to opt back in. */
.stage-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 14px;
  pointer-events: auto;
}

.stage-status .warn { color: var(--warn); }

.stage-status {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 10px;
  background: var(--bg-panel);
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 11px;
  font-family: var(--mono);
  overflow: hidden;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Transport                                                           */
/* ------------------------------------------------------------------ */

.transport {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--line);
  overflow-x: auto;
}

.transport-btn {
  width: 32px;
  padding: 4px 0;
  text-align: center;
  font-size: 13px;
}

.transport .time {
  font-family: var(--mono);
  font-size: 13px;
  min-width: 72px;
  color: var(--text-dim);
}

.transport #bpm { width: 56px; }
.transport .field.grow { max-width: 220px; }

.scene-buttons {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
}

.scene-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  color: var(--text-dim);
  font: inherit;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: var(--radius);
  cursor: pointer;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-btn.active {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #06141c;
  font-weight: 600;
}

.scene-btn .hot {
  color: var(--text-faint);
  font-family: var(--mono);
  margin-right: 5px;
}

.scene-btn.active .hot { color: #06141c; }

/**
 * The live scene, changed since it was saved.
 *
 * A dot rather than a word: the buttons are already as wide as they are going
 * to get, and the thing being said is "there is something here", which a dot
 * says at a glance from across a dark garden.
 */
.scene-btn.edited { border-color: var(--warn, #ffb347); }

.scene-btn .edited-dot {
  color: var(--warn, #ffb347);
  margin-left: 5px;
  font-size: 14px;
  line-height: 0;
  vertical-align: middle;
}

.scene-btn.active .edited-dot { color: #06141c; }

/**
 * The save button, which is only ever on screen when pressing it would do
 * something. It sits ahead of the scene buttons, so the thing you are about to
 * lose is next to the button that would lose it.
 */
.scene-save {
  margin-left: auto;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* With the save button up it owns the gap, so the scenes sit beside it. */
.scene-save:not([hidden]) + .scene-buttons { margin-left: 8px; }

/* ------------------------------------------------------------------ */
/* Inspector                                                           */
/* ------------------------------------------------------------------ */

.inspector-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.inspector-title input { font-weight: 600; }

.param-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.param-row > label {
  color: var(--text-dim);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.param-control {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.param-value {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  min-width: 42px;
  text-align: right;
}

.bind-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text-faint);
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--mono);
  padding: 2px 4px;
  cursor: pointer;
  line-height: 1.3;
}

.bind-btn.bound {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.binding-editor {
  grid-column: 1 / -1;
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--accent-2);
  border-radius: var(--radius);
  padding: 8px;
  margin: 2px 0 8px;
  background: var(--bg-raised);
}

.binding-editor .field > span { flex-basis: 78px; }

.binding-expr {
  width: 100%;
  font-family: var(--mono);
  font-size: 11.5px;
  min-height: 46px;
  resize: vertical;
}

.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.tag-toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text-faint);
  border-radius: 99px;
  font: inherit;
  font-size: 10.5px;
  padding: 1px 8px;
  cursor: pointer;
}

.tag-toggle.on {
  border-color: var(--accent);
  color: var(--accent);
  background: #241a11;
}

.target-list {
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px;
  margin-bottom: 8px;
}

.calib-progress {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 8px;
  background: var(--bg-raised);
}

.calib-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.calib-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.2s;
}

/* ------------------------------------------------------------------ */
/* Code editor                                                         */
/* ------------------------------------------------------------------ */

.code-wrap {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-input);
  overflow: hidden;
  height: clamp(240px, 42vh, 560px);
  margin-bottom: 6px;
}

.code-gutter {
  flex: 0 0 auto;
  padding: 8px 6px 8px 8px;
  background: #161a22;
  border-right: 1px solid var(--line);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  text-align: right;
  user-select: none;
  overflow: hidden;
  white-space: pre;
}

.code-editor {
  flex: 1 1 auto;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  resize: none;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}

.code-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 6px;
  min-height: 16px;
  white-space: pre-wrap;
}

.code-status.bad { color: var(--bad); }
.code-status.good { color: var(--good); }

/* ------------------------------------------------------------------ */
/* Help                                                                */
/* ------------------------------------------------------------------ */

.dialog-body h2 { margin-top: 20px; }
.dialog-body h2:first-child { margin-top: 0; }
.dialog-body h3 { font-size: 13px; margin-top: 14px; color: var(--accent); }
.dialog-body ul { padding-left: 20px; margin: 0 0 10px; }
.dialog-body li { margin-bottom: 4px; }
.dialog-body table { border-collapse: collapse; width: 100%; margin-bottom: 12px; font-size: 12px; }
.dialog-body th,
.dialog-body td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dialog-body th { color: var(--text-faint); font-weight: 600; }
.dialog-body td code { white-space: nowrap; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 236px 1fr 250px; }
}

/* ------------------------------------------------------------------ *
 * Setup walkthrough
 *
 * A checklist rather than a page of instructions. Only the step you are on is
 * expanded; the ones above collapse to a tick, and the ones below stay dim so
 * the eye lands on the one that matters.
 * ------------------------------------------------------------------ */

.setup-guide {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* The demo offer, above the checklist: it changes what the checklist means. */
.setup-demo {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 4px;
  background: linear-gradient(180deg, rgba(255, 122, 24, 0.12), rgba(255, 122, 24, 0.03));
}

.setup-demo h3 {
  margin: 0 0 4px;
  font-size: 13px;
}

.setup-demo p {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.45;
}

.setup-progress .setup-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-input);
  overflow: hidden;
}

.setup-progress .setup-bar span {
  display: block;
  height: 100%;
  background: var(--good);
  transition: width 220ms ease;
}

.setup-progress .panel-note {
  margin: 6px 0 2px;
}

.setup-step {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--bg-panel);
}

/* Done but not current: dim, compact, and clickable to go back to it. */
.setup-step.done {
  opacity: 0.62;
  cursor: pointer;
}

.setup-step.done:hover {
  opacity: 1;
  background: var(--bg-hover);
}

.setup-step.current {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.setup-step.warn {
  border-color: var(--warn);
}

.setup-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.setup-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.setup-mark {
  flex: 0 0 18px;
  margin-top: 1px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-dim);
}

.setup-step.done .setup-mark {
  background: var(--good);
  color: #08120c;
}

.setup-step.current .setup-mark {
  background: var(--accent);
  color: #1a0d02;
}

.setup-title {
  font-size: 13px;
  line-height: 1.3;
  color: var(--text);
}

.setup-status {
  font-size: 11px;
  color: var(--text-faint);
}

.setup-step.warn .setup-status {
  color: var(--warn);
}

.setup-why {
  margin: 6px 0 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
}

/* ------------------------------------------------------------------ *
 * Name-and-tag prompt, over the stage
 * ------------------------------------------------------------------ */

.shape-namer {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  width: min(420px, calc(100% - 32px));
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.shape-namer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shape-namer-label {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-dim);
}

.shape-namer-row .input {
  flex: 1 1 auto;
  min-width: 0;
}

.shape-namer .tag-picker {
  margin-top: 8px;
}

.shape-namer .panel-note {
  margin: 8px 0 0;
}

/* ------------------------------------------------------------------ *
 * Effect browser
 * ------------------------------------------------------------------ */

.dialog-wide {
  width: min(1080px, 94vw);
  max-width: none;
}

.effect-search {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 10px;
  background: var(--bg-panel);
}

.effect-search .input {
  width: 100%;
}

.effect-group {
  margin: 14px 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.effect-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.effect-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  cursor: pointer;
}

.effect-card:hover {
  border-color: var(--accent-2);
}

.effect-card.current {
  border-color: var(--accent);
}

.effect-thumb {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 3px;
  background: #000;
}

.effect-name {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

.effect-card:hover .effect-name {
  color: var(--text);
}

/* ------------------------------------------------------------------ *
 * Command palette
 *
 * Anchored near the top rather than centred: the list grows downwards from a
 * fixed point, so the first result never moves as you type. A palette whose
 * top result slides up and down under the cursor is unusable at speed.
 * ------------------------------------------------------------------ */

.palette {
  width: min(620px, 92vw);
  padding: 0;
  overflow: hidden;
  margin-top: 12vh;
}

.palette-input {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.palette-input::placeholder { color: var(--text-faint); }

.palette-list {
  max-height: min(52vh, 440px);
  overflow-y: auto;
  padding: 6px;
}

.palette-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}

.palette-row.active { background: var(--accent); color: #140b03; }

.palette-group {
  flex: none;
  width: 78px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.palette-row.active .palette-group,
.palette-row.active .palette-detail { color: #140b03; opacity: 0.72; }

.palette-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-detail {
  flex: none;
  font-size: 11.5px;
  color: var(--text-faint);
}

.palette-foot {
  margin: 0;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-faint);
}

.palette-foot kbd { margin-right: 3px; }

.kbd-hint {
  margin-left: 5px;
  font-size: 10px;
  opacity: 0.75;
}

/* ------------------------------------------------------------------ *
 * "Why can't I see it?" notes
 * ------------------------------------------------------------------ */

.panel-note.issue {
  border-left: 2px solid var(--line-strong);
  padding-left: 8px;
  margin: 6px 0;
}

.panel-note.issue.warn { border-left-color: var(--warn); color: var(--warn); }
.panel-note.issue.bad { border-left-color: var(--bad); color: var(--bad); }
.panel-note.issue.info { border-left-color: var(--accent-2); }

/* ------------------------------------------------------------------ *
 * Help dialog
 *
 * A tab strip and one scrolling pane, rather than one very long column. The
 * strip is the same control as the left panel's so it needs no explaining, and
 * only the pane scrolls — the tabs stay put, which is the whole point of having
 * them.
 * ------------------------------------------------------------------ */

.dialog-wide .help-tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-panel);
  margin: -18px -18px 12px;
  padding: 14px 18px 0;
  border-bottom: 1px solid var(--line);
}

.help-pane {
  max-height: 64vh;
  overflow-y: auto;
  padding: 4px 6px 0 0;
}

.help-pane > h2:first-child { margin-top: 0; }

/* ------------------------------------------------------------------ *
 * The link indicator
 *
 * A pill in the app bar rather than a panel, because the answer it carries is
 * one word — is anything else on this show — and because on a machine with no
 * link server it should read as a piece of status and not as a broken feature.
 * ------------------------------------------------------------------ */

.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-dim);
}

.link-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.link-pill[data-link='linked'] { color: var(--text); }
.link-pill[data-link='linked'] .link-dot {
  background: var(--good);
  /* Faint halo: at a glance across a dark room this is the difference between
     "a dot" and "a lit dot". */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent);
}
.link-pill[data-link='connecting'] .link-dot { background: var(--warn); animation: link-pulse 1.4s ease-in-out infinite; }
.link-pill[data-link='checking'] .link-dot { background: var(--text-faint); animation: link-pulse 1.4s ease-in-out infinite; }

@keyframes link-pulse {
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .link-pill .link-dot { animation: none; }
}

.link-body { max-width: 46em; }
.link-body h3 { margin-top: 16px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }

.link-command {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent-2);
}

.link-urls { display: grid; gap: 8px; }

.link-url {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.link-url-what { color: var(--text-faint); font-size: 11px; }

.link-url code {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--accent);
  /* Long enough to wrap on a narrow dialog, and worth wrapping rather than
     truncating — it is meant to be read out loud and typed into a phone. */
  overflow-wrap: anywhere;
  user-select: all;
}

.link-peers { margin-top: 6px; }
