@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/vendor/space-grotesk-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/vendor/space-grotesk-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/vendor/space-grotesk-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/vendor/space-grotesk-700.woff2') format('woff2');
}

:root {
  color-scheme: dark;
  --bg-0: #08131d;
  --bg-1: #0e2231;
  --bg-2: #12334a;
  --panel: rgba(7, 22, 31, 0.82);
  --panel-solid: #102635;
  --line: #28536b;
  --line-soft: #2d5f77;
  --text: #eaf5ff;
  --muted: #8fb1c8;
  --ok: #68d39c;
  --warn: #ff9d82;
  --accent: #7fd1ff;
  --accent-2: #b9ff96;
  --select: #ffd090;
  --danger: #ff7f6a;
  --control-bg: #142e3e;
  --control-border: #42667d;
  --surface: linear-gradient(135deg, #132b3a, #0b1c28);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

.system-history { width: 100%; color: var(--muted); font-size: 12px; }
.history-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; }
.history-legend span:nth-child(1) { color: #ff9d82; }
.history-legend span:nth-child(2) { color: #7fd1ff; }
.history-legend span:nth-child(3) { color: #b9ff96; }
.tab-btn[data-unsaved]::after { content: ' *'; color: var(--warn); }
#system-hardware-health[data-warning="true"] { border-color: var(--warn); }

@media (forced-colors: none) {
  * {
    scrollbar-color: var(--muted) var(--bg-0);
  }

  @supports selector(::-webkit-scrollbar) {
    * {
      scrollbar-color: auto;
    }

    ::-webkit-scrollbar {
      width: 12px;
      height: 12px;
    }

    ::-webkit-scrollbar-track,
    ::-webkit-scrollbar-corner {
      background: var(--bg-0);
    }

    ::-webkit-scrollbar-thumb {
      border: 2px solid var(--bg-0);
      border-radius: 999px;
      background: var(--muted);
    }

    ::-webkit-scrollbar-thumb:hover {
      background: var(--accent);
    }

    ::-webkit-scrollbar-thumb:active {
      background: var(--accent-2);
    }
  }
}

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

body {
  font-family: "Space Grotesk", "IBM Plex Sans", "DejaVu Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(980px 480px at 12% -5%, rgba(56, 132, 180, 0.38), transparent 62%),
    radial-gradient(780px 560px at 100% 100%, rgba(42, 94, 68, 0.32), transparent 58%),
    linear-gradient(140deg, var(--bg-0), var(--bg-1) 48%, #0c1a26);
}

.app {
  width: 95%;
  margin: 12px auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(5px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12, 31, 44, 0.93), rgba(10, 28, 40, 0.78));
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-img {
  width: 120px;
  max-width: 45vw;
  height: auto;
  display: block;
}

.brand-meta {
  display: grid;
  gap: 2px;
}

.brand-title {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.version {
  font-size: 12px;
  color: var(--muted);
}

.docs-link {
  color: var(--accent);
  font-size: 12px;
  padding: 6px 0;
  text-underline-offset: 3px;
}

.docs-link:hover {
  color: var(--text);
}

.docs-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.tab-btn {
  border: 1px solid #335f79;
  border-radius: var(--radius);
  background: #112b3c;
  color: var(--text);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.tab-btn.active {
  border-color: #7fb2ce;
  background: linear-gradient(180deg, #1f4a62, #193f53);
  box-shadow: 0 0 0 1px rgba(127, 178, 206, 0.28) inset;
}

.page {
  display: none;
  padding: 14px;
  animation: page-in 220ms ease;
}

.page.active {
  display: block;
}

body:has([data-page="routing"].active) .app {
  height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
}

.app-header { flex-shrink: 0; }

.page[data-page="routing"].active {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 10px;
  animation: none;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #1d3b4e, var(--control-bg));
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

button:hover {
  border-color: #6d98b4;
}

button:active:not(:disabled) {
  box-shadow: inset 0 2px 4px #0006;
}

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

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  border-color: #5f965f;
  background: #21432a;
  color: #dcffe8;
}

button.warn {
  border-color: #8a574a;
  background: #442922;
  color: #ffd8ce;
}

button.flat {
  background: #102b3b;
}

input[type="number"],
input[type="text"],
input[type="file"],
select,
textarea {
  width: 100%;
  border: 1px solid #385f75;
  border-radius: var(--radius);
  background: var(--bg-0);
  color: var(--text);
  padding: 8px;
  font-size: 13px;
}

input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input[type="file"] { min-width: 0; font-size: 12px; }
input[type="file"]::file-selector-button {
  font: inherit;
  padding: 5px 8px;
  margin-right: 8px;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: var(--control-bg);
  color: var(--text);
  cursor: pointer;
}
textarea { resize: vertical; line-height: 1.6; min-height: 200px; }
.lua-editor { position: relative; min-width: 0; }
.lua-editor textarea,
.lua-editor pre {
  margin: 0;
  padding: 8px;
  border: 1px solid #385f75;
  border-radius: var(--radius);
  font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  text-align: left;
  letter-spacing: normal;
}
.lua-editor pre {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--bg-0);
  color: var(--text);
  pointer-events: none;
}
.lua-editor textarea { display: block; position: relative; width: 100%; min-width: 0; }
.lua-highlighted pre { display: block; }
.lua-highlighted textarea {
  background: transparent;
  color: transparent;
  caret-color: var(--text);
}
.lua-highlighted textarea::selection { background: #38678d; color: #fff; }
.lua-keyword { color: #d7a9ff; }
.lua-builtin { color: #83d8f5; }
.lua-string { color: #b7df98; }
.lua-comment { color: #93a6b5; }
.lua-number { color: #ffce8b; }
.lua-operator { color: #f0b4ce; }
@media (forced-colors: active) {
  .lua-highlighted pre { display: none; }
  .lua-highlighted textarea { color: CanvasText; caret-color: CanvasText; }
}
pre { max-width: 100%; overflow-x: auto; }
a { color: var(--accent); text-underline-offset: 3px; }
.page label { line-height: 1.5; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}

.routing-grid {
  display: flex;
  gap: 12px;
  align-items: stretch;
  min-width: 0;
  width: 100%;
  min-height: 0;
  position: relative;
}

.graph-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(rgba(127, 209, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(127, 209, 255, 0.08) 1px, transparent 1px),
    #0d1e2a;
  background-size: 32px 32px;
}

.graph-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px;
  border-bottom: 1px solid #24475d;
  background: rgba(11, 29, 41, 0.92);
}

.graph-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
}

.zoom-controls {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.routing-mode-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.routing-mode-toggle input { width: auto; margin: 0; accent-color: var(--accent); }

.graph-hint {
  color: var(--muted);
  font-size: 12px;
}

.graph-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  background: #0d1e2a;
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#graph-wrap .litegraph.litecontextmenu {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
}

.node {
  position: absolute;
  width: 264px;
  border: 1px solid #3b6982;
  border-radius: 12px;
  background: linear-gradient(180deg, #123044, #0c2332);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.3);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.node.related {
  border-color: #6e97ae;
}

.node.selected {
  border-color: var(--select);
  box-shadow: 0 0 0 1px rgba(255, 208, 144, 0.45), 0 12px 24px rgba(0, 0, 0, 0.34);
}

.node .headbar {
  padding: 8px 10px;
  border-bottom: 1px solid #2d4f63;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: move;
  user-select: none;
}

.node .headbar strong {
  font-size: 13px;
}

.kind {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.ports {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
}

.col {
  display: grid;
  gap: 5px;
}

.port {
  border: 1px solid #345b72;
  border-radius: 7px;
  background: #132939;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.port.in {
  border-color: #326785;
}

.port.out {
  border-color: #5d7f3c;
}

.port.connected {
  box-shadow: 0 0 0 1px rgba(127, 209, 255, 0.38) inset;
}

.port.active {
  border-color: var(--select);
  box-shadow: 0 0 0 1px rgba(255, 208, 144, 0.38) inset;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot.in {
  background: #7ec4ff;
}

.dot.out {
  background: #ace17f;
}

.edge-line {
  stroke: #79c8ff;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  pointer-events: none;
}

.edge-line.related {
  stroke: #afdfff;
}

.edge-line.selected {
  stroke: #ffd090;
  filter: drop-shadow(0 0 6px rgba(255, 208, 144, 0.85));
}

.edge-line.hot {
  stroke: #ffbe84;
  filter: drop-shadow(0 0 5px rgba(255, 190, 132, 0.95));
}

.edge-del-btn {
  fill: #4d2924;
  stroke: #ffccbf;
  stroke-width: 1.2;
  cursor: pointer;
}

.edge-del-label {
  fill: #ffd8ce;
  font-size: 11px;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.graph-shell:fullscreen,
.graph-shell.expanded {
  width: 100%;
  height: 100dvh;
  border-radius: 0;
  background: var(--bg-0);
}

.graph-shell.expanded {
  position: fixed;
  inset: 0;
  z-index: 900;
}

.app:has(.graph-shell.expanded) { backdrop-filter: none; }

.bluetooth-layout {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.bluetooth-header,
.bluetooth-device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.bluetooth-header p { margin: 8px 0 0; }
.bluetooth-header button { flex-shrink: 0; }
.bluetooth-filter { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; cursor: pointer; }
.bluetooth-filter input { width: auto; margin: 0; accent-color: var(--accent); }
.bluetooth-groups { display: grid; gap: 20px; }
.bluetooth-group h2 { margin: 0 0 10px; color: var(--muted); }
.bluetooth-device-list { display: grid; gap: 8px; }
.bluetooth-device { padding: 16px; }
.bluetooth-device.connected { border-color: var(--ok); }
.bluetooth-device-info { flex: 1; min-width: 0; display: grid; gap: 5px; }
.bluetooth-device-info strong { overflow-wrap: anywhere; font-size: 14px; }
.bluetooth-device-state { font-size: 12px; color: var(--muted); }
.connected .bluetooth-device-state { color: var(--ok); }
.bluetooth-device-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bluetooth-auto-connect { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.bluetooth-auto-connect input { width: auto; margin: 0; accent-color: var(--accent); }
.bluetooth-device-address { font-size: 11px; color: var(--muted); }
.bluetooth-empty { padding: 20px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 13px; }
.sb-grid.can-reorder .sb-card-name { cursor: grab; user-select: none; touch-action: none; }
.sb-grid.can-reorder .sb-card-name::after {
  content: "drag";
  float: right;
  color: var(--muted);
  font-size: 10px;
  font-weight: normal;
}
.soundboard-layout:not(.play-mode) .sb-card.dragging {
  opacity: 0.6;
  outline: 2px solid var(--accent-2);
}
.sb-card-name:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  border: 1px solid #355b72;
  border-radius: 8px;
  padding: 6px;
  background: #0d222f;
  min-width: 0;
}

.metric .label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.metric .value {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.small {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: break-word;
  line-height: 1.55;
}

.cfg-wrap {
  max-width: 760px;
}

.config-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
}

.loading-dialog {
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 20px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin 900ms linear infinite;
}

@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

.cfg-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.cfg-row label {
  color: var(--muted);
  font-size: 13px;
}

.actions-3 {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stack {
  display: grid;
  gap: 10px;
}

.stack > p { margin: 0; }
.stack > *, .config-layout > *, .system-layout > *, .grid-2 > * { min-width: 0; }
.reference-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--bg-0);
}
.reference-panel > summary { font-size: 12px; color: var(--muted); }
.reference-panel > p, .reference-panel > pre { margin: 12px 0 0; }
.reference-panel > .grid-2 { margin-top: 12px; }

#macro-midi-binding[hidden],
#system-audio-stress[hidden],
#chord-script-editor[hidden] {
  display: none;
}

#chord-script:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.notifications {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  pointer-events: none;
}

.notification {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 16px;
  background: var(--panel-solid);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  animation: page-in 180ms ease;
}

.notification.ok { border-left-color: var(--ok); }
.notification.warn { border-left-color: var(--warn); }
.notification strong { font-size: 13px; color: var(--accent); }
.notification.ok strong { color: var(--ok); }
.notification.warn strong { color: var(--warn); }

.notification p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.notification-dismiss {
  flex-shrink: 0;
  font-size: 11px;
  padding: 5px 8px;
}

.confirm-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.confirm-dialog::backdrop {
  background: rgba(3, 12, 20, 0.78);
  backdrop-filter: blur(4px);
}

.dialog-heading {
  color: var(--warn);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}

.confirm-dialog h2 {
  font-size: 22px;
  text-transform: none;
  letter-spacing: -0.02em;
}

.confirm-dialog p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  margin: 16px 0 24px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.effects-layout {
  display: grid;
  gap: 10px;
}

.effects-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr));
  gap: 10px;
  align-items: start;
}

.fx-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
}

.fx-name-row, .fx-param-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.fx-name-row input, .fx-param-inputs input[type="range"] {
  flex: 1;
  min-width: 0;
}

.fx-name-row input { padding: 7px 9px; }
.fx-name-row button { padding: 7px 9px; font-size: 12px; }

.fx-param-inputs input[type="number"] {
  width: 90px;
  min-width: 0;
}

.fx-parameter {
  border-top: 1px solid #2d5065;
  padding-top: 10px;
}

.fx-band-heading {
  margin: 14px 0 0;
  font-size: 13px;
}

.fx-param-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
}

.fx-param-info { position: relative; }
.fx-param-info > summary {
  display: grid;
  place-items: center;
  justify-content: center;
  gap: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-family: Georgia, serif;
  font-style: italic;
}
.fx-param-info > summary::after { display: none; }
.fx-param-info[open] > summary { color: var(--accent); border-color: var(--accent); }
.fx-param-help {
  position: absolute;
  z-index: 10;
  right: 0;
  width: min(270px, 65vw);
  margin: 6px 0 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-0);
  box-shadow: 0 8px 24px #0008;
  font-weight: 400;
  line-height: 1.5;
}

.fx-param-inputs { gap: 6px; }
.fx-param-inputs select { flex: 1; padding: 6px 8px; }
.fx-param-inputs input[type="number"] { width: 80px; padding: 6px 8px; }
.fx-param-inputs button { padding: 6px 8px; font-size: 11px; }
.fx-param-inputs input[type="range"] {
  appearance: none;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.fx-param-inputs input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  background: var(--bg-0);
  border-radius: 3px;
  box-shadow: 0 1px #365063;
}
.fx-param-inputs input[type="range"]::-moz-range-track {
  height: 5px;
  background: var(--bg-0);
  border-radius: 3px;
  box-shadow: 0 1px #365063;
}
.fx-param-inputs input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  margin-top: -6px;
  width: 24px;
  height: 17px;
  border: 1px solid #07121b;
  border-radius: 4px;
  background: linear-gradient(90deg, #97afbf, #d2e0e8 44%, #244255 45% 55%, #97afbf 56%);
  box-shadow: 0 2px 4px #0008;
}
.fx-param-inputs input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 17px;
  border: 1px solid #07121b;
  border-radius: 4px;
  background: linear-gradient(90deg, #97afbf, #d2e0e8 44%, #244255 45% 55%, #97afbf 56%);
  box-shadow: 0 2px 4px #0008;
}
.fx-card { background: linear-gradient(135deg, var(--panel-solid), var(--bg-0)); }
.fx-card > .small { margin: 0; }
.fx-midi-details, .fx-advanced {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.fx-midi-details .fx-map-row { margin-top: 8px; }
.fx-card summary { cursor: pointer; }
.fx-card-head, .fx-map-meta { overflow-wrap: anywhere; }
.fx-midi-details .fx-map-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.fx-midi-details .fx-map-meta { grid-column: 1 / -1; }

.fx-card-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.fx-map-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #2d5065;
  border-radius: 8px;
  background: #0d2230;
  padding: 7px;
}

.fx-map-meta {
  font-size: 12px;
  color: var(--text);
}

.fx-map-badge {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ddffe9;
  border: 1px solid #3b6f55;
  border-radius: 999px;
  background: #163629;
  padding: 4px 8px;
}

.fx-map-badge.unset {
  color: var(--muted);
  border-color: #3a5e73;
  background: #0f2a3a;
}

.soundboard-layout {
  display: grid;
  gap: 12px;
}

.sb-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.sb-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.mode-switch { display: flex; gap: 4px; }
.sb-edit-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  align-items: start;
  gap: 12px;
}

.sb-setup-panel > summary,
.sb-tile-settings > summary {
  cursor: pointer;
  font-weight: 600;
}

details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  cursor: pointer;
  border-radius: 5px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::marker { content: ''; }
details > summary::after {
  content: '';
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}
details[open] > summary::after { transform: rotate(225deg); }
details > summary:hover { color: var(--accent); }
details > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.sb-setup-panel {
  background: linear-gradient(135deg, var(--panel-solid), var(--bg-0));
}
.sb-setup-panel[open] { border-color: var(--line-soft); }

.sb-panel-content { margin-top: 14px; }
.sb-tile-settings { grid-column: 1 / -1; }
.sb-tile-settings > summary {
  padding: 8px 4px;
  font-size: 12px;
  color: var(--accent);
}

.sb-tile-controls {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.sb-tile-controls label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.soundboard-layout:not(.play-mode) .sb-card { min-height: 0; }
.soundboard-layout:not(.play-mode) .sb-card-actions { grid-template-columns: 1fr; }
.soundboard-layout:not(.play-mode) .sb-card-actions > .sb-play { min-height: 40px; }
.play-mode .sb-edit-only { display: none; }
.play-mode .sb-card { min-height: 140px; }
.play-mode .sb-card-actions { grid-template-columns: 1fr; }
.play-mode .sb-card-actions .sb-play { min-height: 64px; font-size: 18px; }
.sb-play:active { background: #32623c; border-color: var(--ok); }
.play-mode .sb-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

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

.sb-grid.grid-mode {
  grid-template-columns: repeat(var(--sb-columns), minmax(112px, 1fr));
  gap: 6px;
  overflow-x: auto;
}

.sb-grid.grid-mode .sb-card {
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 6px;
  gap: 5px;
}

.sb-grid.grid-mode .sb-card-name,
.sb-grid.grid-mode .sb-card-midi {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-grid.grid-mode .sb-card-actions {
  grid-template-columns: 1fr;
}

.sb-grid.grid-mode .sb-play {
  min-height: 48px;
}

.sb-grid-empty {
  min-height: 80px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.sb-grid-cell-select {
  font-size: 11px;
}

.soundboard-layout:not(.play-mode) .grid-mode .sb-card-name,
.soundboard-layout:not(.play-mode) #sb-unassigned .sb-card-name {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.grid-drop-target {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

#sb-unassigned {
  min-height: 140px;
}

.sb-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-solid);
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 174px;
}

.sb-card.assign-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(127, 209, 255, 0.35) inset;
}

.sb-card-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-card-midi {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sb-card-midi.mapped {
  color: var(--accent-2);
}

.sb-midi-clear {
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  padding: 0 3px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  min-width: 0;
}

.sb-midi-clear:hover {
  color: var(--warn);
  border-color: transparent;
  background: transparent;
}

.sb-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.sb-card-actions > * {
  min-width: 0;
}

.sb-card-actions button,
.sb-card-actions select {
  width: 100%;
}

.sb-card-actions button {
  font-size: 12px;
  padding: 5px 6px;
}

.system-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  align-items: start;
}

.system-info { grid-column: 1; grid-row: 1 / span 2; }
#update-card { grid-column: 2; grid-row: 2; }
.system-advanced { grid-column: 1 / -1; grid-row: 3; }
.system-advanced > summary, .scenes-menu > summary { cursor: pointer; font-weight: 600; }
.system-health-layout { display: grid; gap: 24px; padding-top: 20px; }
.system-health-layout > section { border-top: 1px solid var(--line); padding-top: 16px; }
.resource-meter {
  position: relative;
  width: 100%;
  height: 8px;
  margin-top: 7px;
  overflow: hidden;
  border: 1px solid rgba(143, 177, 200, 0.18);
  border-radius: 999px;
  background: linear-gradient(180deg, #07141d, #0b1c28);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.48), 0 1px 0 rgba(255, 255, 255, 0.025);
}
.resource-meter[hidden] { display: none; }
.resource-meter::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--meter-level, 0%);
  border-radius: inherit;
  content: '';
  transition: width 350ms ease, background 350ms ease, box-shadow 350ms ease;
  background: linear-gradient(180deg, var(--meter-color-soft, #78d99a), var(--meter-color, #32b99b));
  box-shadow: 0 0 8px var(--meter-glow, rgba(70, 207, 151, 0.28));
}
.resource-meter[data-state="warning"]::after { box-shadow: 0 0 8px var(--meter-glow); }
.resource-meter[data-state="critical"]::after { box-shadow: 0 0 10px var(--meter-glow); }
.metric-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.metric-action { flex: 0 0 auto; padding: 3px 7px; font-size: 11px; }
.system-actions { grid-column: 2; grid-row: 1; }

.fan-dialog {
  width: min(1120px, calc(100vw - 32px));
  height: min(880px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  padding: clamp(18px, 3vw, 34px);
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  color: var(--text);
  background:
    radial-gradient(800px 460px at 85% 0%, rgba(35, 91, 112, 0.22), transparent 68%),
    var(--panel-solid);
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.68);
}
.fan-dialog::backdrop {
  background: rgba(3, 12, 20, 0.84);
  backdrop-filter: blur(7px);
}
.fan-dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.fan-dialog-header .dialog-heading { color: var(--accent); margin-bottom: 4px; }
.fan-dialog-header h2 { margin: 0; font-size: clamp(24px, 3vw, 34px); }
.fan-dialog-description { color: var(--muted); margin: 12px 0 20px; line-height: 1.6; }
.fan-warning {
  border: 1px solid #9a6342;
  border-radius: 10px;
  background: linear-gradient(110deg, rgba(106, 59, 31, 0.68), rgba(71, 37, 31, 0.72));
  color: #ffddb1;
  padding: 12px 15px;
  margin-bottom: 16px;
  line-height: 1.55;
}
.fan-warning[hidden] { display: none; }
.fan-dialog-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(220px, 0.8fr); gap: 18px; align-items: start; }
.fan-graph-card {
  min-width: 0;
  border: 1px solid rgba(112, 160, 185, 0.2);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(155deg, rgba(7, 22, 32, 0.94), rgba(12, 35, 48, 0.9));
}
.fan-graph { display: block; width: 100%; height: auto; overflow: visible; touch-action: none; }
.fan-graph text { font-family: inherit; fill: #8fb1c8; font-size: 13px; }
.fan-graph .fan-gridline { stroke: rgba(143, 177, 200, 0.14); stroke-width: 1; }
.fan-graph .fan-axis { stroke: rgba(143, 177, 200, 0.52); stroke-width: 1.5; }
.fan-graph .fan-area { fill: url(#fan-area-gradient); }
.fan-graph .fan-line { fill: none; stroke: url(#fan-line-gradient); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.fan-graph .fan-point { cursor: grab; outline: none; }
.fan-graph .fan-point:active { cursor: grabbing; }
.fan-graph.is-disabled { opacity: 0.62; }
.fan-graph .fan-point:focus .fan-point-ring { stroke: #fff; stroke-width: 4; }
.fan-graph .fan-point-halo { fill: rgba(127, 209, 255, 0.16); }
.fan-graph .fan-point-ring { fill: #153448; stroke: #c4eeff; stroke-width: 2; }
.fan-graph .fan-point-core { fill: #7fd1ff; }
.fan-graph .fan-point-label { fill: #eaf5ff; font-size: 12px; font-weight: 600; pointer-events: none; }
.fan-graph-legend { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.fan-controls { display: grid; gap: 18px; }
.fan-enable { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: rgba(15, 40, 54, 0.62); }
.fan-hysteresis-control { display: grid; gap: 9px; }
.fan-hysteresis-control > label { display: flex; justify-content: space-between; font-weight: 600; }
.fan-hysteresis-control output { color: var(--accent); font-variant-numeric: tabular-nums; }
.fan-hysteresis-control input { width: 100%; accent-color: var(--accent); }
.fan-curve-summary { display: grid; gap: 6px; }
.fan-curve-summary-row { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.fan-curve-summary-row strong { color: var(--text); font-weight: 500; }
.fan-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 20px; margin-top: 18px; border-top: 1px solid rgba(143, 177, 200, 0.18); }
.fan-dialog-actions button:disabled { opacity: 0.48; cursor: not-allowed; }
.fan-controls .small { line-height: 1.55; }

.spectrum-dialog { height: auto; }
.spectrum-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.spectrum-controls select { min-width: 0; flex: 0 1 360px; }
.spectrum-option { display: flex; align-items: center; gap: 8px; }
.spectrum-graph-card {
  border: 1px solid rgba(112, 160, 185, 0.2);
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(155deg, rgba(7, 22, 32, 0.94), rgba(12, 35, 48, 0.9));
}
.spectrum-canvas { display: block; width: 100%; height: min(460px, 55dvh); }
#spectrum-status { min-height: 1.4em; margin: 10px 0 0; }

.update-progress {
  width: 100%;
}

.boot-failure-banner {
  flex-basis: 100%;
  order: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  border: 1px solid #8a574a;
  border-radius: 10px;
  background: #3a221d;
  color: #ffd8ce;
  padding: 10px 12px;
}

.boot-failure-banner[hidden],
.boot-failure-banner pre[hidden] {
  display: none;
}

.boot-failure-text span {
  color: var(--warn);
  margin-left: 6px;
}

.boot-failure-actions {
  display: flex;
  gap: 8px;
}

.boot-failure-banner pre {
  flex-basis: 100%;
  white-space: pre-wrap;
}

.update-banner {
  flex-basis: 100%;
  order: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--panel-solid);
  color: var(--accent);
  padding: 10px 12px;
}

.update-banner[hidden] {
  display: none;
}

.update-banner-actions {
  display: flex;
  gap: 8px;
}

.logs-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.logs-filter-row {
  grid-template-columns: 96px minmax(0, 1fr);
  margin-top: 4px;
}

.logs-view {
  margin: 0;
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid #355b72;
  border-radius: 8px;
  background: #0b1b26;
  padding: 8px;
  font-family: "IBM Plex Mono", "DejaVu Sans Mono", monospace;
  font-size: 12px;
  line-height: 1.38;
  color: #d8e8f2;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-word;
}

.log-src {
  color: #7fd1ff;
}

.log-level-error {
  color: #ff8f7a;
}

.log-level-warn {
  color: #ffcd83;
}

.log-level-info {
  color: #8be3b7;
}

.log-level-debug {
  color: #9bb7c8;
}

/* Volume page */
.vol-layout {
  display: grid;
  gap: 12px;
}

.vol-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.vol-header-left {
  min-width: 0;
  flex: 1 1 300px;
}

.vol-header-left h2 { margin: 0; }
.vol-header-left p { margin: 6px 0; }

.vol-effect-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.vol-effect-filter input {
  width: auto;
  accent-color: var(--accent);
}

#vol-effect-summary { margin: 0; }

.vol-layout > * {
  min-width: 0;
}

.vol-grid {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  align-items: flex-start;
  scrollbar-gutter: stable;
}

.vol-channel-controls {
  display: flex;
  gap: 2px;
  min-width: 0;
  height: 260px;
}

.vol-meters {
  position: relative;
  display: flex;
  min-width: 0;
  flex: 1;
  justify-content: center;
}

.vol-meter-bars {
  display: flex;
  width: 100%;
  justify-content: safe center;
  gap: 2px;
  max-width: 100%;
  height: 236px;
  padding: 1px;
  overflow-x: auto;
  overflow-y: hidden;
}

.vol-meter-row {
  position: relative;
  flex: 0 0 6px;
  height: 220px;
  text-align: center;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.vol-meter-row meter {
  position: absolute;
  width: 6px;
  height: 220px;
  top: 0;
  left: 0;
  opacity: 0;
}

.vol-meter-row::before,
.vol-meter-row::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 220px;
  top: 0;
  left: 0;
  box-sizing: border-box;
  border-radius: 2px;
  pointer-events: none;
}

.vol-meter-row::before {
  border: 1px solid #060e15;
  background: #060e15;
  box-shadow: 0 0 0 1px #284354;
}

.vol-meter-row::after {
  background: repeating-linear-gradient(to top, transparent 0 6px, #08131d 6px 8px),
    linear-gradient(to top, #48be91, #a6e877 80%, #ffd077 94%, #ff806c);
  clip-path: inset(calc(100% - var(--meter-level, 0%)) 0 0);
}

.vol-meter-reading {
  position: absolute;
  inset: auto 0 0;
  min-height: 20px;
  color: var(--muted);
  text-align: center;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.vol-card {
  flex: 0 0 156px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: linear-gradient(90deg, #10212e, #162e3e 50%, #10212e);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.vol-card.cc-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(127, 209, 255, 0.35) inset;
}

.vol-card-name {
  height: 34px;
  line-height: 17px;
  font-size: 12px;
  text-align: center;
  font-weight: 600;
  overflow-wrap: anywhere;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.vol-card-id {
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
  margin-top: -6px;
}

.vol-slider-row {
  position: relative;
  flex: 0 0 72px;
  height: 260px;
}

.vol-slider-row input[type="range"] {
  position: absolute;
  top: 0;
  left: 28px;
  width: 44px;
  height: 220px;
  writing-mode: vertical-lr;
  direction: rtl;
  appearance: none;
  accent-color: var(--accent);
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  cursor: ns-resize;
}

.vol-slider-row input[type="range"]::-webkit-slider-runnable-track {
  width: 5px;
  height: 100%;
  border-radius: 3px;
  background: #060e15;
  box-shadow: 1px 0 #365063;
}

.vol-slider-row input[type="range"]::-moz-range-track {
  width: 5px;
  height: 100%;
  border-radius: 3px;
  background: #060e15;
  box-shadow: 1px 0 #365063;
}

.vol-slider-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 28px;
  height: 16px;
  margin-left: -12px;
  border: 1px solid #07121b;
  border-radius: 3px;
  background: linear-gradient(to bottom, #b5c7d2, #6e8b9e 43%, #142b3a 44% 56%, #9ab0be 57%, #526f84);
  box-shadow: 0 2px 4px #0009;
}

.vol-slider-row input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 16px;
  border: 1px solid #07121b;
  border-radius: 3px;
  background: linear-gradient(to bottom, #b5c7d2, #6e8b9e 43%, #142b3a 44% 56%, #9ab0be 57%, #526f84);
  box-shadow: 0 2px 4px #0009;
}

.vol-slider-row input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.vol-fader-scale {
  position: absolute;
  inset: 0 auto 40px 0;
  width: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  pointer-events: none;
}

.vol-pct {
  position: absolute;
  inset: auto 0 0;
  min-height: 20px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--accent);
}

.vol-unity { width: 100%; }

.vol-cc-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-height: 66px;
}

.vol-cc-row button,
.vol-unity {
  padding: 6px 8px;
  font-size: 11px;
}

.vol-cc-badge {
  font-size: 11px;
  color: var(--accent-2);
}

.vol-cc-badge.unset {
  color: var(--muted);
}

/* MIDI page */
.midi-layout {
  display: grid;
  gap: 12px;
}

.midi-action-row {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.midi-action-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.midi-action-label {
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 1200px) {
  .brand-title { display: none; }
  .brand { gap: 8px; }
  .tabs { gap: 5px; }
  .tab-btn { padding: 7px 9px; }
}

@media (max-width: 1000px) {
  .app-header { flex-wrap: nowrap; }
  .brand { flex-direction: column; align-items: flex-start; gap: 2px; flex-shrink: 0; }
  .logo-img { width: 88px; }
  .version { font-size: 10px; }
  .tabs { min-width: 0; flex-wrap: nowrap; overflow-x: auto; }
  .tab-btn { flex-shrink: 0; }

}

@media (max-width: 760px) {
  .app {
    width: 100%;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  body:has([data-page="routing"].active) .app { height: 100dvh; }

  .app-header {
    padding: 8px;
  }

  .notifications {
    right: 16px;
    bottom: 16px;
  }

  .tabs {
    width: auto;
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-left: 0;
    gap: 5px;
  }

  .tab-btn { padding: 6px 9px; flex-shrink: 0; }
  .brand-title { display: none; }
  .logo-img { width: 88px; }
  .graph-toolbar { padding: 6px; gap: 6px; }
  .graph-actions { gap: 4px; }
  .graph-actions button { padding: 6px 8px; font-size: 12px; }
  .zoom-controls { margin-left: 0; padding-left: 6px; }
  .bluetooth-device { flex-wrap: wrap; }
  .bluetooth-device-actions { width: 100%; }
  .cfg-row {
    grid-template-columns: 1fr;
  }

  .actions-3,
  .grid-2,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .system-layout,
  .config-layout {
    grid-template-columns: 1fr;
  }

  .system-info,
  .system-actions,
  .system-advanced,
  #update-card {
    grid-column: auto;
    grid-row: auto;
  }

  .fan-dialog {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
    padding: 18px 14px;
    border-radius: 14px;
  }
  .fan-dialog-body { grid-template-columns: 1fr; gap: 14px; }
  .fan-graph-card { padding: 7px; }
  .spectrum-graph-card { padding: 6px; }
  .spectrum-canvas { height: min(320px, 50dvh); }
  .fan-dialog-description { margin-bottom: 14px; }

  .node {
    width: 236px;
  }

  @media (prefers-reduced-motion: reduce) {
    .page,
    .notification {
      animation: none;
    }

    .loading-spinner {
      animation-duration: 3s;
    }
  }

  .midi-action-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
.macros-layout {
  max-width: 1200px;
  margin: 0 auto;
}

.macro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#chord-list > div {
  overflow-wrap: anywhere;
}

.script-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.script-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}

.script-control input:not([type="checkbox"]),
.script-control select {
  width: 12rem;
  max-width: 100%;
  min-width: 0;
}

@media (min-width: 1100px) {
  .midi-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .midi-layout > :last-child { grid-column: 1 / -1; }
}

@media (pointer: coarse) {
  button, select, details > summary, input[type="file"]::file-selector-button {
    min-height: 40px;
  }
  .fx-param-info > summary { min-height: 32px; width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .page, .notification { animation: none; }
}

.plugin-manager { display: grid; gap: 8px; }
.plugin-warning, .fx-plugin-warning, .fx-plugin-error, .fx-plugin-status.fault,
.fx-plugin-status.unavailable, .fx-plugin-status.unknown { color: var(--warn); }
.fx-plugin-status.ready { color: var(--accent); }
.plugin-install {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.plugin-list { display: grid; gap: 8px; }
.plugin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #2d5065;
  border-radius: 8px;
  background: #0d2230;
  padding: 7px;
}
.plugin-meta { min-width: 0; overflow-wrap: anywhere; }
.fx-plugin-ui {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.fx-plugin-ui > button { justify-self: start; }
.fx-plugin-frame {
  width: 100%;
  min-height: 320px;
  border: 1px solid #2d5065;
  border-radius: 8px;
  background: #fff;
}
.fx-plugin-error { overflow-wrap: anywhere; }
