/* Shared reset, tokens and controls.
   Dark by default and permanently so: this app is used at night, standing
   outside, next to a projector. A light theme would be actively unhelpful. */

:root {
  color-scheme: dark;

  --bg: #0c0e13;
  --bg-raised: #14171f;
  --bg-panel: #11141b;
  --bg-input: #1b1f29;
  --bg-hover: #222735;
  --line: #262c3a;
  --line-strong: #384156;

  --text: #e7eaf2;
  --text-dim: #98a0b4;
  --text-faint: #6b7488;

  --accent: #ff7a18;
  --accent-dim: #b8560f;
  --accent-2: #4cc2ff;
  --good: #35d07f;
  --warn: #ffc14d;
  --bad: #ff4d6a;

  --radius: 6px;
  --radius-lg: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "SF Mono", "Cascadia Mono", ui-monospace, Consolas, "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

/* Several overlays below set `display: grid`, which outranks the user-agent
   rule for [hidden]. Without this they can never actually be hidden. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
}

h1, h2, h3 {
  margin: 0 0 0.5em;
  font-weight: 600;
  line-height: 1.2;
}

h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 12px; }

p { margin: 0 0 0.75em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-2); }

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-input);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--bg-input);
  padding: 1px 4px;
  border-radius: 3px;
}

pre {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: #4a5468;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.btn.primary:hover:not(:disabled) { background: #ff8c35; border-color: #ff8c35; }

.btn.danger { color: var(--bad); border-color: #4a2b34; }
.btn.danger:hover:not(:disabled) { background: #2a161c; }

.btn.small { padding: 3px 8px; font-size: 11.5px; }

.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #17110a;
}

/* ------------------------------------------------------------------ */
/* Form controls                                                       */
/* ------------------------------------------------------------------ */

input[type="text"],
input[type="search"],
input[type="number"],
select,
textarea {
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  font: inherit;
  font-size: 12px;
  padding: 4px 7px;
  width: 100%;
  min-width: 0;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

select {
  padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 12px) 52%, calc(100% - 7px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

input[type="color"] {
  appearance: none;
  width: 34px;
  height: 24px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-input);
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 18px;
  background: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-input);
  border: 1px solid var(--line);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-input);
  border: 1px solid var(--line);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  margin: 0;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.field > span {
  flex: 0 0 92px;
  color: var(--text-dim);
  font-size: 11.5px;
}

.field.inline { margin-bottom: 0; }
.field.inline > span { flex: 0 0 auto; }
.field.grow { flex: 1 1 auto; min-width: 120px; }

.inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.select-full { margin-bottom: 8px; }

/* A select that sits in a row of buttons and matches their height. */
.select-inline {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 6px;
  font-size: 12px;
}

/* ------------------------------------------------------------------ */
/* Lists                                                               */
/* ------------------------------------------------------------------ */

.list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  background: var(--bg-raised);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 30px;
}

.list-item:hover { background: var(--bg-hover); }

.list-item.selected {
  border-color: var(--accent);
  background: #241a11;
}

.list-item .item-title {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item .item-sub {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
}

.list.compact .list-item { padding: 3px 7px; min-height: 24px; }

.chip {
  display: inline-block;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 10.5px;
  line-height: 16px;
}

.chip.on { border-color: var(--accent); color: var(--accent); }
.chip.good { border-color: var(--good); color: var(--good); }
.chip.warn { border-color: var(--warn); color: var(--warn); }
.chip.bad { border-color: var(--bad); color: var(--bad); }

.icon-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
}

.icon-btn:hover { color: var(--text); background: var(--bg-input); }
.icon-btn.on { color: var(--accent); }

/* ------------------------------------------------------------------ */
/* Dialog + toast                                                      */
/* ------------------------------------------------------------------ */

.dialog {
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 18px;
  max-width: min(820px, 92vw);
  max-height: 86vh;
  overflow: auto;
}

.dialog::backdrop { background: rgba(0, 0, 0, 0.65); }

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 8px 14px;
  max-width: 60vw;
  z-index: 100;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.toast.bad { border-left-color: var(--bad); }
.toast.good { border-left-color: var(--good); }

.panel-note {
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.5;
  margin: 6px 0 10px;
}

.panel-note.inline { margin: 0; align-self: center; }

.muted { color: var(--text-faint); }

.meter {
  height: 6px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

/*
 * Driven by transform, not width.
 *
 * The microphone updates this thirty times a second, and animating `width`
 * makes each of those a layout of the whole panel. `scaleX` is handled by the
 * compositor and touches neither layout nor paint — the same bar, for none of
 * the cost, on the one screen you are most likely to be watching while you set
 * an audio-reactive effect up.
 */
.meter > span {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--good), var(--warn), var(--bad));
  transition: transform 0.06s linear;
  will-change: transform;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b3242; border-radius: 5px; border: 2px solid var(--bg-panel); }
::-webkit-scrollbar-thumb:hover { background: #3a4356; }

/* A status chip in a list row must not push the row into two lines. */
.list-item .chip { flex: none; white-space: nowrap; }
