/* base.css: every value a theme can change, then the structure that uses them.
   A theme file redefines custom properties and nothing else. No build step, no
   preprocessor, no imports beyond this one file. See README.md beside it. */

:root {
  /* Surfaces, back to front. */
  --bg: #232323;
  --panel: #2d2d2d;
  --panel2: #353535;
  --raise: #3e3e3e;
  --overlay: rgba(0, 0, 0, 0.6);

  /* Lines. */
  --line: #474747;
  --line-soft: #3a3a3a;

  /* Text. */
  --text: #e6e6e6;
  --dim: #a6a6a6;
  --faint: #787878;
  --on-accent: #101010;

  /* Meaning. Saturated red is spent only on what is going out: the tally, the
     on air frame, the ad pill, the top of a meter. Faults use --bad, which is
     duller on purpose, so a failed source never reads as a live one. */
  --live: #ff2a36;
  --bad: #d9584c;
  --ok: #34d07f;
  --warn: #eea62a;
  --accent: #5590ff;
  --select: #5590ff;
  --select-fill: rgba(85, 144, 255, 0.16);

  /* Default colours per source kind. A tile the operator has not coloured
     takes the colour of its kind, so a tray reads at a glance. */
  --kind-camera: #4f8cff;
  --kind-stream: #b06cff;
  --kind-file: #ff9a3c;
  --kind-page: #2fc4a8;
  --kind-graphic: #f05c8a;
  --kind-other: #7b8494;

  /* Type. */
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --num: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --fs: 13px;
  --fs-sm: 11px;
  --fs-lg: 15px;
  --lh: 1.45;

  /* Geometry. */
  --radius: 8px;
  --radius-sm: 5px;
  --gap: 8px;
  --pad: 10px;
  --tile-w: 168px;
  --header-h: 44px;
  --border: 1px;

  /* Motion. Set --anim to 0s for a still interface. */
  --anim: 0.14s;
  --anim-take: 0.45s;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  :root { --anim: 0s; --anim-take: 0s; }
}

/* ---------------------------------------------------------------- reset */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs)/var(--lh) var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- shell */

gmx-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-columns: 1fr auto;
  grid-template-areas: "header header" "monitor sidebar" "main sidebar" "strip strip" "footer footer";
  height: 100%;
}
.slot-header { grid-area: header; border-bottom: var(--border) solid var(--line); background: var(--panel); }
.slot-main { grid-area: main; overflow: auto; min-width: 0; min-height: 0; }
.slot-strip { grid-area: strip; }
.slot-strip:empty { display: none; }
.slot-sidebar {
  grid-area: sidebar; width: 340px; max-width: 90vw; overflow: auto;
  border-left: var(--border) solid var(--line); background: var(--panel);
}
.slot-sidebar:empty { display: none; }
.slot-footer { max-height: 22vh; overflow: auto; grid-area: footer; border-top: var(--border) solid var(--line); background: var(--panel); }
.slot-modal { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.slot-modal > * { pointer-events: auto; }
.slot-modal:empty { display: none; }

@media (max-width: 760px) {
  gmx-shell { grid-template-columns: 1fr; grid-template-areas: "header" "monitor" "main" "strip" "footer"; }
  .slot-sidebar {
    position: fixed; right: 0; top: var(--header-h); bottom: 0; z-index: 30;
    width: min(340px, 92vw); box-shadow: var(--shadow);
  }
}

/* ---------------------------------------------------------------- bits */

.row { display: flex; align-items: center; gap: var(--gap); }
.col { display: flex; flex-direction: column; gap: var(--gap); }
.grow { flex: 1 1 auto; min-width: 0; }
.pad { padding: var(--pad); }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.sm { font-size: var(--fs-sm); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.btn {
  background: var(--raise); color: var(--text); border: var(--border) solid var(--line);
  border-radius: var(--radius-sm); padding: 5px 10px; line-height: 1.2;
  transition: background var(--anim), border-color var(--anim); white-space: nowrap; }
.btn:hover { background: var(--panel2); border-color: var(--dim); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.icon { padding: 4px 7px; }

input[type=text], input[type=search], input[type=password], input[type=number], input[type=url], select, textarea {
  background: var(--bg); border: var(--border) solid var(--line);
  border-radius: var(--radius-sm); padding: 5px 8px; width: 100%;
}
input::placeholder { color: var(--faint); }
label { display: block; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.live { background: var(--ok); }
.dot.connecting { background: var(--warn); }
.dot.stalled { background: var(--warn); }
.dot.failed, .dot.error { background: var(--bad); }

.pill {
  border-radius: 999px; padding: 2px 8px; font-size: var(--fs-sm);
  border: var(--border) solid var(--line); background: var(--panel2);
}
.pill.live { background: var(--live); border-color: var(--live); color: #fff; }
/* A destination that is failing: a fault, so --bad, and an outline rather
   than a fill, because a filled red pill in the header means on air. */
.pill.failed { border-color: var(--bad); color: var(--bad); }

/* ---------------------------------------------------------------- header */

/* The wordmark: Godwin in a moving blue gradient, Mix in white. The sweep is
   slow, runs three times when the page opens, and stops for anyone who asked
   for less motion. It used to run for ever, and a background moving under
   clipped text is painted on the page's main thread every screen refresh: on
   a laptop with a busy GPU that halved the rate the page could put monitor
   frames on screen (43 refreshes a second with it, 77 without). */
.wordmark { font-size: 18px; font-weight: 800; letter-spacing: 0.01em; white-space: nowrap; }
.wm-godwin {
  background: linear-gradient(100deg, #1a5cff, #38a4ff 35%, #c8ecff 50%, #38a4ff 65%, #1a5cff);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: wm-sweep 4s ease-in-out 3;
}
.wm-mix { color: #fff; }
:root[data-theme="light"] .wm-mix { color: var(--text); }
@keyframes wm-sweep { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .wm-godwin { animation: none; } }

.header {
  display: flex; align-items: center; gap: var(--gap);
  height: var(--header-h); padding: 0 var(--pad);
}
.tally {
  display: flex; align-items: center; gap: 6px; font-weight: 600;
  padding: 3px 10px; border-radius: var(--radius-sm);
  background: var(--panel2); border: var(--border) solid var(--line);
}
.tally.on { background: var(--live); border-color: var(--live); color: #fff; }

/* ---------------------------------------------------------------- meters */

.meter { display: flex; gap: 2px; height: 100%; align-items: flex-end; }
.meter .ch { flex: 1; background: var(--line-soft); border-radius: 1px; position: relative; overflow: hidden; }
.meter .fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to top, var(--ok) 0%, var(--ok) 62%, var(--warn) 82%, var(--live) 100%);
}
.meter.h { flex-direction: column; align-items: stretch; }
/* The fill spans the whole channel and clip-path cuts it to the level. With
   `right: auto` and no width it was zero pixels wide, so every horizontal
   meter (the header's programme bar, the Audio panel) drew nothing at all
   while its number moved. */
.meter.h .fill { top: 0; right: 0; background: linear-gradient(to right, var(--ok) 0%, var(--ok) 62%, var(--warn) 82%, var(--live) 100%); }

/* A scroll bar that belongs to the theme: thin, and the colour of a line,
   so a panel that does scroll does not grow a bright grey gutter. */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ---------------------------------------------------------------- gallery */

.gallery {
  display: grid; gap: var(--gap); padding: var(--pad);
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-w), 1fr));
  position: relative; align-content: start; min-height: 120px;
}
.gallery.mode-icon, .gallery.mode-label { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

.tile {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--panel2); border: 2px solid var(--line-soft);
  user-select: none; touch-action: manipulation;
  transition: border-color var(--anim), transform var(--anim);
}
.tile:hover { border-color: var(--dim); }
.tile.selected { border-color: var(--select); background: var(--select-fill); }
/* `display` is here because `.program` further down is the programme monitor's
   rule, a centred grid, and a tile on air carries the same class name: its face
   shrank to the size of the number in it, 9 by 22 px, the moment it was taken.
   `place-items` as well: a browser that aligns block children honours it. */
.tile.program { border-color: var(--live); display: block; place-items: normal; }
.tile.program.took { animation: took var(--anim-take) ease-out; }
.tile.armed { border-color: var(--warn); }
.tile.dragging { opacity: 0.5; }
.tile.drop-into { outline: 2px dashed var(--accent); outline-offset: -4px; }
@keyframes took {
  from { box-shadow: 0 0 0 0 var(--live); }
  to { box-shadow: 0 0 0 12px rgba(255, 42, 54, 0); }
}

.tile .pic { aspect-ratio: 16 / 9; background: #000; display: block; width: 100%; object-fit: contain; }
/* The plain background comes first so a WebKitGTK older than 2.38, which has no
   color-mix, still gets a readable tile rather than a transparent one. */
.tile .kindbox {
  aspect-ratio: 16 / 9; display: grid; place-items: center;
  background: var(--panel2);
  background: color-mix(in srgb, var(--tile-color, var(--kind-other)) 22%, var(--panel2));
}
.tile .kindbox svg { width: 34%; max-width: 46px; opacity: 0.9; color: var(--tile-color, var(--kind-other)); }
.tile .bar {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  border-top: var(--border) solid var(--line-soft); background: var(--panel);
  border-left: 3px solid var(--tile-color, var(--kind-other));
}
.tile .name { font-size: var(--fs-sm); }
.tile .name[contenteditable] { background: var(--bg); outline: 1px solid var(--accent); border-radius: 2px; }
.tile .gear { opacity: 0; background: none; border: 0; color: var(--dim); padding: 0 2px; }
.tile:hover .gear, .tile.selected .gear { opacity: 1; }
.tile .badge {
  position: absolute; top: 5px; left: 5px; font-size: var(--fs-sm);
  background: var(--overlay); border-radius: 3px; padding: 0 5px;
}
/* Every tile has a line under its name ("Clip", "Continuous live source"),
   and the hover strip has to clear it as well as the name, or it sits on
   the name's buttons and they cannot be pressed. */
.tile { --under-bar: calc(6px + var(--lh) * var(--fs-sm)); }
.tile .strip {
  position: absolute; left: 0; right: 0; bottom: calc(26px + var(--under-bar)); padding: 4px 6px;
  background: var(--overlay); opacity: 0; transition: opacity var(--anim);
  display: flex; align-items: center; gap: 6px;
}
.tile:hover .strip, .tile:focus-within .strip { opacity: 1; }
/* The level is never behind a hover: a slim bar between the picture and the
   name, in every gallery mode, so a glance says which inputs are making a
   sound. The hover strip moves up by the bar's height to stay clear of it. */
.tile .meter.level { height: 6px; padding: 1px 6px; gap: 1px; background: var(--panel); }
.tile.metered .strip { bottom: calc(32px + var(--under-bar)); }
/* A source with sound and no picture shows that, not a black box that reads as
   a camera that failed, and its level is the widest thing on it. */
.tile .soundface {
  aspect-ratio: 16 / 9; display: grid; place-items: center; align-content: center; gap: 6px;
  background: var(--panel2);
  background: color-mix(in srgb, var(--tile-color, var(--kind-other)) 14%, var(--panel2));
}
.tile .soundface svg { width: 30%; max-width: 40px; color: var(--tile-color, var(--kind-other)); }
.tile .soundface .row { display: flex; gap: 8px; align-items: baseline; }
.tile.sound .meter.level { height: 14px; }
.tile.sound.metered .strip { bottom: calc(40px + var(--under-bar)); }
.tile.mode-label .soundface { display: none; }
.tile input[type=range] { width: 100%; accent-color: var(--accent); }

.marquee {
  position: absolute; border: 1px solid var(--select);
  background: var(--select-fill); pointer-events: none; z-index: 5;
}

/* ---------------------------------------------------------------- program */

.program { background: #000; display: grid; place-items: center; position: relative; }
.program img { max-width: 100%; max-height: 100%; display: block; }
.program.on { box-shadow: inset 0 0 0 2px var(--live); }

/* ---------------------------------------------------------------- modal */

.scrim { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; padding: var(--pad); }
.dialog {
  background: var(--panel); border: var(--border) solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); max-width: min(860px, 96vw); max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden; width: 100%;
}
.dialog > header { display: flex; align-items: center; gap: var(--gap); padding: var(--pad); border-bottom: var(--border) solid var(--line); }
.dialog > .body { padding: var(--pad); overflow: auto; }
.dialog > footer { display: flex; justify-content: flex-end; gap: var(--gap); padding: var(--pad); border-top: var(--border) solid var(--line); }
.dialog h2 { margin: 0; font-size: var(--fs-lg); }

.tabs { display: flex; gap: 2px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px; color: var(--dim); white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* The scene strip: tabs that choose, and one button that takes. */
.scene-tabs { flex-wrap: wrap; align-items: center; gap: 4px; padding: 0 var(--pad) var(--pad); }
.scene-tabs button:not(.btn) {
  display: flex; align-items: center; gap: 6px; max-width: 18ch;
  border: var(--border) solid var(--line); border-bottom-width: 2px; border-radius: var(--radius-sm);
}
.scene-tabs button:not(.btn).on { background: var(--panel2); color: var(--text); border-color: var(--accent); }
.scene-tabs button.program { color: var(--text); border-bottom-color: var(--live); }
.scene-tabs button.armed { border-bottom-color: var(--warn); }
.scene-tabs .btn { margin-left: auto; color: var(--text); background: var(--panel2); border: var(--border) solid var(--line); border-radius: var(--radius-sm); }

/* ---------------------------------------------------------------- picker */

.picker-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.picker-grid.list { grid-template-columns: 1fr; }
.kindtile {
  display: flex; gap: var(--gap); align-items: flex-start; text-align: left;
  background: var(--panel2); border: var(--border) solid var(--line);
  border-radius: var(--radius); padding: var(--pad);
}
.kindtile:hover, .kindtile.on { border-color: var(--accent); }
.kindtile svg { width: 26px; height: 26px; flex: none; color: var(--accent); }
.kindtile .who { color: var(--faint); font-size: var(--fs-sm); }
.group-title { color: var(--dim); font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.06em; margin: var(--pad) 0 4px; }

/* The source picker: what to add on the left, what there is on the right. */
.picker { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: var(--gap); min-height: 400px; }
.picker-rail { display: flex; flex-direction: column; gap: 2px; padding-right: var(--gap); border-right: var(--border) solid var(--line); }
.picker-rail button {
  display: flex; align-items: center; gap: var(--gap); text-align: left;
  background: none; border: 0; border-radius: var(--radius-sm); padding: 7px 9px; color: var(--dim);
}
.picker-rail button svg { width: 18px; height: 18px; flex: none; }
.picker-rail button:hover { background: var(--panel2); color: var(--text); }
.picker-rail button.on { background: var(--raise); color: var(--text); }
.picker-main { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.picker-head input { width: 100%; }
.picker-panel { display: flex; flex-direction: column; gap: 6px; overflow: auto; max-height: min(56vh, 520px); }
.picker-panel .picker-grid { margin-bottom: var(--pad); }
.picker-row {
  display: flex; align-items: center; gap: var(--gap); padding: 7px var(--pad);
  background: var(--panel2); border: var(--border) solid var(--line); border-radius: var(--radius-sm);
}
.picker-row svg { width: 20px; height: 20px; flex: none; }
.picker-row .grow { min-width: 0; }
.picker-row .btn { flex: none; }

/* A narrow window puts the rail across the top, where the tabs already live. */
@media (max-width: 720px) {
  .picker { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .picker-rail { flex-direction: row; overflow-x: auto; padding: 0 0 var(--gap); border-right: 0; border-bottom: var(--border) solid var(--line); }
  .picker-rail button { white-space: nowrap; }
}
/* ---------------------------------------------------------------- outputs */

/* Two lines per destination: the name and what it is doing on the first,
   where it goes and how it is coping on the second. The actions sit on the
   first line because the state is what an operator is reading when they reach
   for one of them. */
.output-row { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.output-row + .output-row { border-top: var(--border) solid var(--line); }
.output-detail { color: var(--faint); }
/* A destination still carrying a preset's placeholder is a fault, not a
   warning: nothing is arriving anywhere and nothing will until somebody
   pastes a key. */
.needs-key { color: var(--bad); }
/* And so is an address nothing ever answered at, which is the same fault
   wearing different clothes. */
.output-advice { color: var(--bad); }
.dot.reconnecting { background: var(--warn); }
/* The add flow's tiles are one line of platform and one of where to find the
   key, with no icon, so they read as a list of choices rather than a gallery. */
.picker-grid.destinations .kindtile { align-items: center; }
.form .field .replace-key { align-self: flex-start; }

/* ---------------------------------------------------------------- forms */

.form { display: flex; flex-direction: column; gap: var(--gap); }
.form .field { display: flex; flex-direction: column; gap: 3px; }
.form .field > .lbl { color: var(--dim); font-size: var(--fs-sm); }
.form .field .hint { color: var(--faint); font-size: var(--fs-sm); }
.form .field.bad input, .form .field.bad select { border-color: var(--bad); }
.form .err { color: var(--bad); font-size: var(--fs-sm); }
.form fieldset { border: var(--border) solid var(--line); border-radius: var(--radius-sm); padding: var(--pad); margin: 0; }
.form legend { color: var(--dim); font-size: var(--fs-sm); padding: 0 4px; }
.form .unit { color: var(--faint); font-size: var(--fs-sm); margin-left: 4px; }
.form .inline { display: flex; align-items: center; gap: 6px; }
/* Mixer settings and the folder picker. A status line says when a change
   takes effect, and is not there at all until there is something to say. */
.form .field .field-status { color: var(--dim); }
.form .field .field-status:empty { display: none; }
.mixer-banner { border-left: 3px solid var(--warn); padding: 6px 10px; margin: 0; }
.row.wrap { flex-wrap: wrap; }
.folder-list .btn.folder { justify-content: flex-start; text-align: left; }

/* ---------------------------------------------------------------- toast */

.toasts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast {
  background: var(--raise); border: var(--border) solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px 12px; display: flex; align-items: center; gap: var(--gap);
  max-width: min(560px, 94vw);
}
.toast.error { border-color: var(--bad); }
.toast.warning { border-color: var(--warn); }

/* ---------------------------------------------------------------- palette */

.palette { position: fixed; inset: 0; background: var(--overlay); z-index: 50; display: flex; justify-content: center; padding-top: 12vh; }
.palette .box { width: min(620px, 94vw); height: fit-content; max-height: 70vh; background: var(--panel); border: var(--border) solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.palette input { border: 0; border-bottom: var(--border) solid var(--line); border-radius: 0; padding: 10px 12px; }
.palette ul { list-style: none; margin: 0; padding: 4px; overflow: auto; }
.palette li { padding: 6px 8px; border-radius: var(--radius-sm); display: flex; gap: var(--gap); align-items: baseline; }
.palette li.on { background: var(--raise); }
.palette li .id { font-family: var(--num); font-size: var(--fs-sm); color: var(--dim); }

/* ---------------------------------------------------------------- menu */

.menu {
  position: fixed; z-index: 70; min-width: 190px; padding: 4px;
  background: var(--raise); border: var(--border) solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.menu button { display: flex; width: 100%; gap: var(--gap); justify-content: space-between; background: none; border: 0; text-align: left; padding: 5px 8px; border-radius: 3px; }
.menu button:hover { background: var(--panel2); }
.menu button[disabled] { opacity: 0.4; }
.menu hr { border: 0; border-top: var(--border) solid var(--line); margin: 4px 0; }
.menu .key { color: var(--faint); font-size: var(--fs-sm); }
.menu .swatches { display: flex; gap: 4px; padding: 5px 8px; }
.menu .swatches button { width: 18px; height: 18px; border-radius: 50%; padding: 0; border: var(--border) solid var(--line); }

/* ---------------------------------------------------------------- menu bar */

.menubar-wrap { display: flex; align-items: center; flex: none; }
.menubar { display: flex; align-items: center; }
.menubar-title { background: none; border: 0; color: var(--text); padding: 4px 8px; border-radius: var(--radius-sm); }
.menubar-title:hover, .menubar-title:focus-visible, .menubar-title[aria-expanded="true"] { background: var(--panel2); outline: none; }
.menubar-all { display: none; }
.menubar-drop { min-width: 240px; max-height: calc(100vh - 56px); overflow: auto; }
.menubar-drop button { justify-content: flex-start; align-items: center; }
.menubar-drop button:focus { background: var(--panel2); outline: none; }
.menubar-tick { width: 1em; flex: none; color: var(--accent); }
.menubar-heading { padding: 6px 8px 2px; color: var(--faint); font-size: var(--fs-sm); }
[data-native-menu] .menubar-wrap { display: none; }
/* Show tabs, after the menu bar. One show reads as a plain name. */
.header > .pill, .header > .tally { flex-shrink: 0; white-space: nowrap; }
/* REC is a button: pressing it stops the recording, after one question. */
.hdr-rec, .hdr-dest { cursor: pointer; font-family: inherit; color: inherit; font-variant-numeric: tabular-nums; }
.shows { display: flex; align-items: center; min-width: 60px; padding-left: 6px; border-left: var(--border) solid var(--line-soft); }
.showtabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.showtab, .shows-add { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--dim); white-space: nowrap; }
.showtab { min-width: 0; flex: 0 1 auto; }
.showtab[aria-selected="true"], .shows-add, .showtab .dot { flex-shrink: 0; }
.showtab-name { min-width: 0; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.header > .ellipsis { flex-shrink: 4; min-width: 0; }
/* Several shows on a laptop screen: their own row under the controls. */
@media (min-width: 761px) and (max-width: 1800px) {
  .header:has(.shows:not(.one):not([hidden])) { flex-wrap: wrap; height: auto; padding: 6px var(--pad) 2px; }
  .header > .shows:not(.one) { order: 9; flex-basis: 100%; border: 0; padding: 0; margin-top: -4px; }
}
.showtab:hover, .shows-add:hover, .showtab:focus-visible, .shows-add:focus-visible { background: var(--panel2); color: var(--text); outline: none; }
.showtab[aria-selected="true"] { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px var(--accent); }
.shows.one .showtab[aria-selected="true"] { background: none; box-shadow: none; }
.showtab .dot { background: var(--live); }
/* The state's word is for screen readers; a mark shows it. */
.showtab-state { font-size: 0; color: var(--faint); }
.showtab-state::before { content: "○"; font-size: var(--fs-sm); }
.showtab-state.starting::before { content: "◌"; color: var(--warn); }
.showtab-state.failed::before { content: "!"; color: var(--bad); font-weight: 700; }
.showtab:has(.showtab-state) .showtab-name { color: var(--faint); }
/* Close, as on a browser's tab: shown on the chosen tab and under the pointer. */
.showtab-x { visibility: hidden; width: 18px; margin-right: -6px; text-align: center; border-radius: var(--radius-sm); color: var(--faint); }
.shows:not(.one) [aria-selected="true"] .showtab-x, .showtab:hover .showtab-x, .showtab:focus-visible .showtab-x { visibility: visible; }
.showtab-x:hover { background: var(--line); color: var(--text); }
.project-counts { align-self: flex-start; border-collapse: collapse; }
.project-counts th, .project-counts td { text-align: left; padding: 2px 24px 2px 0; }
@media (max-width: 760px) {
  .menubar { display: none; }
  .menubar-all { display: inline-block; }
  .menubar-every { right: 8px; }
  .shows { border: 0; padding: 0; }
  .showtab { flex-shrink: 0; }
  .showtab .showtab-x { visibility: visible; }
}

/* ---------------------------------------------------------------- empty */

.empty { display: grid; place-items: center; padding: 40px var(--pad); text-align: center; color: var(--dim); }
.empty h2 { margin: 0 0 6px; color: var(--text); font-size: var(--fs-lg); }
.empty ol { text-align: left; margin: var(--pad) auto; max-width: 44ch; padding-left: 20px; }

/* ---------------------------------------------------------------- drop */

body.dropping::after {
  content: "Drop to add"; position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; background: var(--overlay);
  outline: 3px dashed var(--accent); outline-offset: -12px; font-size: var(--fs-lg);
}

/* Safari before 15 and WebKitGTK before 2.34 have no aspect-ratio. The padding
   trick keeps the 16:9 box there, and the modern rule above wins where it is
   supported. Only the two elements that need a fixed box are covered. */
@supports not (aspect-ratio: 16 / 9) {
  .tile .pic, .tile .kindbox {
    height: 0;
    padding-top: 56.25%;
    position: relative;
  }
  .tile .kindbox > svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}

/* ---------------------------------------------------------------- panel iframe */

iframe.panel { width: 100%; border: 0; background: var(--panel); display: block; }

/* --- the welcome tiles (panels/welcome) --------------------------------- */

.welcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--pad, 12px);
}

.welcome-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  text-align: left;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius, 8px);
  cursor: pointer;
  font: inherit;
}

.welcome-tile:hover:not(:disabled),
.welcome-tile:focus-visible {
  border-color: var(--select);
  background: var(--panel2);
}

.welcome-tile:disabled {
  opacity: 0.55;
  cursor: progress;
}

.welcome-art {
  display: block;
  line-height: 0;
  border-radius: calc(var(--radius, 8px) - 2px);
  overflow: hidden;
}

.welcome-steps {
  margin: 0 0 8px;
  padding-left: 1.3em;
  line-height: 1.6;
}

/* What did not start, under the checklist: one tight list, not a paragraph each. */
.welcome-notes { margin: 8px 0 0; padding-left: 1.2em; line-height: 1.5; }
.welcome-notes li { margin: 2px 0; }

.checklist { padding-left: 0; list-style: none; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.checklist li:not(.step) { padding-left: 26px; }
.checklist .step-tick {
  flex: 0 0 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--line); text-align: center; line-height: 16px; font-size: 12px;
}
.checklist li.done .step-tick { background: var(--ok); border-color: transparent; color: var(--on-accent); }
.checklist li.done > .grow { color: var(--dim); }

/* Under dialogs and the palette, which must not open with their title behind
   it, and in its own room above the shell: the page does not scroll, so a bar
   that pushed the shell down hid the bottom of it, a phone's take bar included. */
body:has(> .restart-bar:not([hidden])) { display: flex; flex-direction: column; }
body:has(> .restart-bar:not([hidden])) > gmx-shell { flex: 1 1 auto; min-height: 0; height: auto; }
.restart-bar {
  position: sticky; top: 0; z-index: 35;
  display: flex; align-items: center; gap: var(--gap, 8px);
  padding: 6px var(--pad, 12px);
  background: var(--panel2); border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm, 13px);
}
.restart-bar[hidden] { display: none; }

.obs-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 28px 16px; border: 2px dashed var(--line); border-radius: var(--radius, 8px);
  cursor: pointer; text-align: center;
}
.obs-drop.over, .obs-drop:focus-visible { border-color: var(--accent, #4a8); background: var(--panel2); }
.obs-drop.busy { opacity: 0.6; pointer-events: none; }
.obs-skipped { margin: 0; padding-left: 1.3em; }

[data-panel].flash, [data-dock-panel].flash { outline: 2px solid var(--accent, #4a8); outline-offset: 2px; }

.welcome-code {
  margin: 0;
  padding: 8px 10px;
  background: var(--panel2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius, 8px);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Keep the monitor and source tray visible together on a laptop. */
gmx-program .program { flex: 1 1 0; background: #000; }
gmx-program canvas, gmx-program img {
  height: min(34vh, 320px); object-fit: contain;
}
.tile .playback { padding: 3px 6px; font-size: var(--fs-sm); color: var(--dim); }

.slot-monitor { grid-area: monitor; min-width: 0; overflow: hidden; border-bottom: 1px solid var(--line); }
.slot-main { padding: var(--pad); }
.panel-section { display: block; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.panel-section > summary { cursor: pointer; padding: 10px; font-weight: 600; }
.panel-section[open] > summary { border-bottom: 1px solid var(--line); }
.panel-section > :not(summary) { display: block; }
.panel-section:not([open]) > :not(summary) { display: none; }
.panel-section > :not(summary) > .row.pad:first-child > strong:first-child { display: none; }
gmx-program canvas, gmx-program img { height: min(32vh, 300px); }

/* The studio panes fit their dock, with preview before programme. */
gmx-program { min-width: 0; container-type: inline-size; }
.monitor-stage { display: flex; min-width: 0; gap: 8px; padding: 8px; }
gmx-program .monitor-pane { display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; background: #000; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.monitor-label { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 10px; flex: 0 0 auto; background: var(--panel2); font-size: var(--fs-sm); }
.monitor-label strong { font-size: 10px; letter-spacing: 0.1em; }
.program .monitor-label strong { color: var(--live); }
.preview-pane .monitor-label strong { color: var(--ok); }
/* Each monitor's frame rate menu, at the right end of its title bar. */
.monitor-label .monitor-rate { margin-left: auto; flex: 0 0 auto; width: auto; height: 22px; min-height: 0; padding: 0 4px; font-size: var(--fs-sm); color: var(--dim); }
.monitor-label .monitor-rate:hover, .monitor-label .monitor-rate:focus-visible { color: inherit; }
gmx-program .monitor-pane canvas, gmx-program .monitor-pane img { width: 100%; height: auto; max-height: 45vh; aspect-ratio: 16 / 9; object-fit: contain; }
.monitor-controls { flex-wrap: wrap; border-top: 1px solid var(--line); }
.monitor-controls [aria-pressed="true"] { color: var(--accent); background: var(--select-fill); }
.monitor-controls select { max-width: 80px; }
@container (max-width: 500px) { .monitor-stage { flex-direction: column; } .monitor-controls > .grow { flex-basis: 100%; } }
.recording-row { border-left: 2px solid var(--live); padding-left: 10px; }
gmx-program .monitor-pane { align-items: stretch; justify-content: flex-start; }
gmx-program .monitor-pane canvas { flex: 0 0 auto; }
@container (max-width: 500px) {
  gmx-program .monitor-pane { flex: 0 0 auto; width: 100%; }
}

.audio-master { display: grid; grid-template-columns: auto minmax(50px, 1fr) auto auto; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); }
.audio-master .meter, .audio-channel .meter { width: 100%; height: 12px; }
.audio-channels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.audio-channel { min-width: 0; display: flex; flex-direction: column; gap: 9px; padding: 12px; border-bottom: 1px solid var(--line-soft); }
.audio-channel input { width: 100%; accent-color: var(--accent); }
.audio-channel.muted .meter { opacity: .4; }
.audio-channel [aria-pressed="true"] { color: var(--warn); }
/* Keep studio controls reachable when the monitor dock is resized. */
@media (min-width: 761px) {
  .dock-frame[data-dock-panel="core/program"] .dock-content { overflow: hidden; }
  .dock-content > gmx-program { display: flex !important; flex-direction: column; height: 100%; min-height: 0; }
  .dock-content > gmx-program .monitor-stage { flex: 1 1 auto; min-height: 0; overflow: auto; }
  .dock-content > gmx-program .monitor-pane { min-height: 120px; flex: 1 1 0; }
  .dock-content > gmx-program .monitor-pane canvas { flex: 1 1 auto; min-height: 0; height: 100%; max-height: none; }
  .dock-content > gmx-program .monitor-controls { flex: 0 0 auto; }
}

/* The Outputs panel's tabs, and the planner's line under a row. */
.out-head { flex-wrap: wrap; }
.out-tabs { flex: none; white-space: nowrap; display: inline-flex; border: var(--border) solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.out-tabs button { background: none; border: 0; color: var(--dim); padding: 4px 10px; font: inherit; }
.out-tabs [aria-selected=true] { background: var(--raise); color: var(--text); }
.output-plan { color: var(--dim); font-size: 11.5px; }
.output-plan:empty { display: none; }
