:root {
  /* Canonical chrome: docs/ui-palette.md — channel colors frozen in web/theme.js */
  --bg: #0c1018;
  --panel: #161f30;
  --border: #2d3f5c;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #4a9eff;
  --accent-dim: #2a5a9a;
  --msx-rule: #3b3bff;
  --msx-cyan: #6ec8ff;
  --eq-bg: #080c12;
  /* timeline.js: LABEL_W (118) + TUNER_W (96) */
  --timeline-pad-l: 214px;
  /* Design tokens — shared control sizing */
  --ui-font-family: "Segoe UI", system-ui, sans-serif;
  --ui-font-xs: 0.75rem;
  --ui-font-sm: 0.85rem;
  --ui-font-md: 0.95rem;
  --ui-control-py: 0.35rem;
  --ui-control-px: 0.65rem;
  --ui-control-font: var(--ui-font-sm);
  --ui-control-line: 1.15;
  --ui-radius: 6px;
  --ui-control-h: calc(var(--ui-control-py) * 2 + var(--ui-control-font) * var(--ui-control-line) + 2px);
  --explorer-control-h: var(--ui-control-h);
  /* piano-roll column labels (Channel, BPM, Key) — set from theme.js */
  --ui-kv-label-size: 0.625rem;
  --ui-kv-label-color: #8b9cb3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--ui-font-family);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app-main-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main-column > header {
  flex-shrink: 0;
}

.app-main-column > main {
  flex: 1 1 auto;
}

.app-main-column > footer {
  flex-shrink: 0;
}

header,
.site-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--msx-rule) 35%, transparent);
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.site-header-main {
  flex: 1 1 auto;
  min-width: 0;
}

.help-btn {
  flex-shrink: 0;
  margin-top: 0.15rem;
  min-height: var(--ui-control-h);
  padding: var(--ui-control-py) 0.85rem;
  font-size: var(--ui-control-font);
  line-height: var(--ui-control-line);
  font-weight: 500;
  color: var(--text);
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: var(--ui-radius);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.help-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.help-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.help-dialog:not([open]) {
  display: none;
}

.help-dialog[open] {
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-width: min(58rem, 96vw);
  max-height: min(86vh, 920px);
  width: min(58rem, 96vw);
  height: fit-content;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(26, 35, 50, 0.52);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(45, 58, 79, 0.45);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  color: var(--text);
}

.help-dialog.is-resizing,
.help-dialog.is-resizing * {
  user-select: none;
}

.help-dialog-resize-handle {
  position: absolute;
  z-index: 3;
  touch-action: none;
}

.help-dialog-resize-n,
.help-dialog-resize-s {
  left: 10px;
  right: 10px;
  height: 6px;
}

.help-dialog-resize-n {
  top: 0;
  cursor: ns-resize;
}

.help-dialog-resize-s {
  bottom: 0;
  cursor: ns-resize;
}

.help-dialog-resize-e,
.help-dialog-resize-w {
  top: 10px;
  bottom: 10px;
  width: 6px;
}

.help-dialog-resize-e {
  right: 0;
  cursor: ew-resize;
}

.help-dialog-resize-w {
  left: 0;
  cursor: ew-resize;
}

.help-dialog-resize-ne,
.help-dialog-resize-nw,
.help-dialog-resize-se,
.help-dialog-resize-sw {
  width: 12px;
  height: 12px;
}

.help-dialog-resize-ne {
  top: 0;
  right: 0;
  cursor: nesw-resize;
}

.help-dialog-resize-nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}

.help-dialog-resize-se {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
}

.help-dialog-resize-sw {
  left: 0;
  bottom: 0;
  cursor: nesw-resize;
}

.help-dialog::backdrop {
  background: rgba(8, 12, 18, 0.16);
}

.help-dialog-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: rgba(15, 20, 25, 0.38);
  border-bottom: 1px solid rgba(45, 58, 79, 0.35);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.help-dialog-header.is-dragging {
  cursor: grabbing;
}

.help-dialog-body {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: min(52vh, 520px);
  min-width: 0;
  overflow: hidden;
}

.help-dialog-aside {
  position: relative;
  flex: 0 0 clamp(11rem, 40%, 24rem);
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid rgba(45, 58, 79, 0.35);
  background: rgba(8, 12, 18, 0.25);
  cursor: grab;
  touch-action: none;
}

.help-dialog-aside.is-panning {
  cursor: grabbing;
}

.help-dialog-aside::before {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 42%;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    270deg,
    rgba(15, 20, 25, 0.72) 0%,
    rgba(15, 20, 25, 0.2) 55%,
    transparent 100%
  );
}

.help-dialog-aside img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 0.92;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.help-content {
  flex: 1 1 auto;
  min-width: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem 1.15rem 1.2rem;
  color: var(--text);
  background: rgba(15, 20, 25, 0.28);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

@media (max-width: 720px) {
  .help-dialog[open] {
    max-width: min(42rem, 96vw);
    width: min(42rem, 96vw);
  }

  .help-dialog-resize-handle {
    display: none;
  }

  .help-dialog-body {
    flex-direction: column;
    min-height: min(40vh, 420px);
  }

  .help-dialog-aside {
    flex: 0 0 auto;
    height: clamp(9rem, 28vw, 12rem);
    border-right: none;
    border-bottom: 1px solid rgba(45, 58, 79, 0.35);
  }

  .help-dialog-aside::before {
    inset: auto 0 0 0;
    width: 100%;
    height: 45%;
    background: linear-gradient(
      0deg,
      transparent 0%,
      rgba(15, 20, 25, 0.35) 100%
    );
  }

  .help-dialog-aside img {
    object-position: center 22%;
  }
}

.help-dialog-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.help-dialog-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  touch-action: auto;
}

.help-dialog-close:hover {
  color: var(--text);
  background: rgba(61, 139, 253, 0.15);
  border-color: var(--border);
}

.help-dialog-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.help-content .help-article {
  /* Open .vgm/.vgz capture is 138×28 px at ui-control-h — widest control column */
  --help-control-col-w: calc(var(--ui-control-h) * 138 / 28 + 0.5rem);
}

.help-content .help-article > :first-child {
  margin-top: 0;
}

.help-content .help-article > :last-child {
  margin-bottom: 0;
}

.help-content .help-article table {
  table-layout: fixed;
  width: 100%;
  margin-bottom: 1.4rem;
}

.help-content .help-article table + p,
.help-content .help-article table + ul,
.help-content .help-article table + ol {
  margin-top: 0.65rem;
}

.help-content .help-article col.help-control-col {
  width: var(--help-control-col-w);
}

.help-content .help-article table img {
  display: inline-block;
  height: var(--ui-control-h);
  width: auto;
  max-width: 100%;
  vertical-align: middle;
  margin: 0;
  padding: 0;
  border: none;
  box-shadow: none;
  outline: none;
  background: transparent;
}

/* Large control shots — border matches player UI (pills, reset, open, export). */
.help-content .help-article table img[src*="help-pill-"],
.help-content .help-article table img[src*="help-btn-reset"],
.help-content .help-article table img[src*="help-btn-open"] {
  border: 1px solid var(--accent-dim);
  border-radius: var(--ui-radius);
}

.help-content .help-article table img[src*="help-btn-export"] {
  border: 1px solid #5eb3ff;
  border-radius: var(--ui-radius);
}

.help-content .help-article table img[src*="help-btn-play"] {
  border: 1px solid #2ecc71;
  border-radius: var(--ui-radius);
}

.help-content .help-article table img[src*="help-btn-stop"] {
  border: 1px solid #e74c3c;
  border-radius: var(--ui-radius);
}

.help-content .help-article table img[src*="help-field-"] {
  height: var(--ui-control-h);
  width: auto;
  max-height: none;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius);
}

.help-content .help-article table img[src*="help-btn-zoom"],
.help-content .help-article table img[src*="help-btn-pan"],
.help-content .help-article table img[src*="help-btn-follow"],
.help-content .help-article table img[src*="help-btn-layout"] {
  height: 1.45rem;
  width: 1.45rem;
}

.help-content .help-article table img[src*="help-btn-mute"],
.help-content .help-article table img[src*="help-btn-solo"] {
  height: 16px;
  width: 16px;
}

.help-content .help-article table img[src*="help-tuner-monitor"] {
  height: auto;
  width: 96px;
  max-width: 100%;
}

.help-content .help-article table img[src*="help-scc-waveform"] {
  height: auto;
  width: 111px;
  max-width: 100%;
}

.help-content .help-article table img[src*="help-range-marker"] {
  height: auto;
  width: 72px;
  max-width: 100%;
}

.help-content .help-article table td:first-child,
.help-content .help-article table th:first-child {
  width: var(--help-control-col-w);
  min-width: var(--help-control-col-w);
  max-width: var(--help-control-col-w);
  box-sizing: border-box;
  white-space: nowrap;
  vertical-align: middle;
  padding: 0.4rem 0.25rem;
  overflow: hidden;
}

.help-content .help-article table td:first-child img {
  max-width: none;
}

.help-content .help-article thead th {
  background: color-mix(in srgb, var(--panel) 82%, var(--bg));
  color: var(--muted);
  font-weight: 600;
  vertical-align: middle;
}

.help-content .help-article li img {
  display: inline-block;
  height: var(--ui-control-h);
  width: auto;
  max-width: none;
  margin: 0 0.2rem 0 0;
  padding: 0;
  vertical-align: middle;
  border-radius: var(--ui-radius);
  box-shadow: none;
  outline: none;
  background: transparent;
}

.help-content .help-article li img[src*="help-btn-open"] {
  border: 1px solid var(--accent-dim);
}

.help-content .help-article li img[src*="help-btn-play"] {
  border: 1px solid #2ecc71;
}

.help-content .help-article li img[src*="help-btn-stop"] {
  border: 1px solid #e74c3c;
}

.help-capture-refs {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
}

.help-capture-mixer-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  font: bold 9px "Segoe UI", system-ui, sans-serif;
  color: #9aa8bc;
  background: #2d3644;
  border: 1px solid #4a5668;
  padding: 0;
  line-height: 1;
}

.help-capture-mixer-btn--mute.is-active {
  color: #1a1208;
  background: #e67e22;
  border-color: #e67e22;
}

.help-capture-mixer-btn--solo.is-active {
  color: #1a1208;
  background: #f1c40f;
  border-color: #f1c40f;
}

.help-capture-mixer-btn--mute-hw.is-active {
  color: #1a1208;
  background: #b8c4d0;
  border-color: #b8c4d0;
}

.help-capture-tuner {
  display: block;
  width: 96px;
  height: 96px;
}

.help-capture-no-border,
.help-capture-no-border span,
button.help-capture-no-border,
label.help-capture-no-border,
label.help-capture-no-border span,
label.file-btn.help-capture-no-border {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.help-content h1,
.help-content h2,
.help-content h3 {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

.help-content p,
.help-content li,
.help-content td,
.help-content th {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.help-content h1 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.help-content h2 {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.help-content h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.help-content p {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

.help-content ul,
.help-content ol {
  margin: 0 0 0.75rem;
  padding-left: 1.35rem;
  font-size: 0.9rem;
}

.help-content li {
  margin-bottom: 0.35rem;
}

.help-content table {
  width: 100%;
  margin: 0 0 0.85rem;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.help-content th,
.help-content td {
  padding: 0.4rem 0.55rem;
  border: 1px solid rgba(45, 58, 79, 0.55);
  text-align: left;
  vertical-align: top;
}

.help-content th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(15, 20, 25, 0.32);
}

.help-content code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(15, 20, 25, 0.42);
  border: 1px solid rgba(45, 58, 79, 0.4);
}

.help-content kbd,
.help-content strong {
  color: #fff;
  font-weight: 600;
}

.help-content a {
  color: var(--accent);
}

.help-content a:hover {
  text-decoration: underline;
}

.help-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.5rem 0 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.help-content pre {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  overflow-x: auto;
  font-size: 0.82rem;
  border-radius: 6px;
  background: rgba(15, 20, 25, 0.42);
  border: 1px solid rgba(45, 58, 79, 0.4);
}

.help-load-error {
  color: #e8b060;
}

.site-title {
  margin: 0 0 0.35rem;
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  font-weight: 600;
  line-height: 1.3;
  max-width: 72rem;
}

.header-info {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.45;
}

.header-chips {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.1rem 0.45rem;
  font: 600 0.72rem ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--msx-cyan);
  background: color-mix(in srgb, var(--msx-cyan) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--msx-cyan) 28%, var(--border));
  border-radius: 3px;
}

.header-warn {
  color: #e8b060;
}

main {
  width: 100%;
  max-width: min(75rem, 100%);
  margin: 0 auto;
  padding: 1rem 1.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-sizing: border-box;
}

main.layout-full {
  max-width: none;
  padding: 1rem clamp(1rem, 2vw, 2rem) 0.5rem;
}

.timeline-panel {
  padding-bottom: 0.75rem;
}

.timeline-toolbar {
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem;
}

.timeline-nav-control {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.timeline-nav-control button {
  min-width: 1.45rem;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 600;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.timeline-nav-control button.layout-width-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  font-size: 0.72rem;
  font-weight: 600;
}

.timeline-nav-control button.layout-width-toggle .layout-bracket {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
}

.timeline-nav-control button.layout-width-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.timeline-nav-control button.follow-playhead-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.timeline-stage {
  position: relative;
}

.timeline-marker-density {
  position: absolute;
  z-index: 2;
  left: 1px;
  top: 1px;
  width: calc(var(--timeline-label-w, 118px) + var(--timeline-tuner-w, 96px));
  height: var(--timeline-ruler-top-h, 28px);
  box-sizing: border-box;
  padding: 0 4px;
  display: grid;
  grid-template-columns: var(--timeline-label-w, 118px) var(--timeline-tuner-w, 96px);
  align-items: center;
  column-gap: 0;
  pointer-events: auto;
}

.timeline-marker-density[hidden] {
  display: none !important;
}

.timeline-marker-density label {
  font: 10px "Segoe UI", system-ui, sans-serif;
  color: var(--muted);
  text-align: right;
  padding-right: 6px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

.timeline-marker-density input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: calc(100% - 8px);
  height: 4px;
  margin: 0 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.timeline-marker-density input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.timeline-marker-density input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px;
  height: 12px;
  margin-top: -4px;
  border: none;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(61, 139, 253, 0.5);
}

.timeline-marker-density input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  border: none;
}

.timeline-marker-density input[type="range"]::-moz-range-thumb {
  width: 3px;
  height: 12px;
  border: none;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(61, 139, 253, 0.5);
}

.timeline-marker-density input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 2px rgba(61, 139, 253, 0.35), 0 0 8px rgba(61, 139, 253, 0.5);
}

.timeline-marker-density input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 2px rgba(61, 139, 253, 0.35), 0 0 8px rgba(61, 139, 253, 0.5);
}

.timeline-host {
  width: 100%;
  min-height: 546px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--timeline-host-bg, #121a24);
}

.hit-timeline-canvas {
  display: block;
  cursor: crosshair;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--msx-rule) 10%, transparent);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: var(--ui-font-md);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel-section-label {
  margin: 0 0 0.5rem;
  font: 600 0.65rem var(--ui-font-family);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--msx-cyan);
}

.controls-spectrum-band {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.controls-spectrum-eq {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.controls-spectrum-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.load-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.file-group {
  gap: 0.5rem;
  padding: 0.4rem 0.6rem 0.5rem;
}

.file-btn {
  display: inline-block;
  padding: var(--ui-control-py) 1rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--ui-radius);
  cursor: pointer;
  font-size: var(--ui-control-font);
  line-height: var(--ui-control-line);
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}

.file-btn.secondary {
  background: var(--accent-dim);
}

.file-btn input {
  display: none;
}

/* Match load-panel action buttons to the play-window button height. */
.load-panel button {
  padding: var(--ui-control-py) 0.9rem;
  font-size: var(--ui-control-font);
  line-height: var(--ui-control-line);
}

.transport-panel {
  display: block;
}

.transport-panel-controls {
  min-width: 0;
}

.transport-spectrum-host {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 5rem;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--msx-cyan) 25%, var(--border));
  border-radius: var(--ui-radius);
  background: var(--eq-bg);
}

.spectrum-monitor-heading {
  position: absolute;
  top: 0.35rem;
  left: 0.5rem;
  z-index: 1;
  font: 600 0.62rem var(--ui-font-family);
  letter-spacing: 0.14em;
  color: var(--msx-cyan);
  pointer-events: none;
  user-select: none;
}

.transport-spectrum-host canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.transport-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  /* Align Play button with the Play selection pill (option-group border + padding). */
  padding-left: calc(0.5rem + 1px);
}

.transport-row label {
  font: 0.85rem "Segoe UI", system-ui, sans-serif;
  color: var(--text);
}

/* Align Start/End label text and inputs on the same centerline as Play/Stop. */
.transport-row label:has(input[type="number"]) {
  display: inline-flex;
  align-items: center;
}

.transport-row label:has(input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}

.transport-row label:has(input[type="checkbox"]) input {
  cursor: pointer;
}

.transport-row button {
  font-size: var(--ui-control-font);
  line-height: var(--ui-control-line);
  padding: var(--ui-control-py) var(--ui-control-px);
}

.transport-row input[type="number"] {
  width: 5.5rem;
  min-height: var(--ui-control-h);
  margin-left: 0.35rem;
  padding: var(--ui-control-py) calc(var(--ui-control-py) - 0.05rem);
  font-size: var(--ui-control-font);
  line-height: var(--ui-control-line);
  border: 1px solid var(--border);
  border-radius: var(--ui-radius);
  background: var(--bg);
  color: var(--text);
}

#btnPlay,
#btnStop {
  min-width: 3.25rem;
  padding: var(--ui-control-py) 0.75rem;
}

/* Playing status: state dot + song name + position */
.transport-status {
  display: flex;
  align-items: center;
  gap: 0.4rem 0.55rem;
  margin-bottom: 0.5rem;
  min-width: 0;
  font: 0.78rem "Segoe UI", system-ui, sans-serif;
  /* Match the transport row inset so the status lines up with Play. */
  padding-left: calc(0.5rem + 1px);
}

.transport-status-state {
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--muted);
}

.transport-status.is-playing .transport-status-state {
  color: var(--text);
}

.transport-status-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.transport-status-pos {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.transport-status-sel {
  flex: 0 0 auto;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--msx-cyan);
  letter-spacing: 0.02em;
}

.transport-status-sel[hidden] {
  display: none;
}

/* Grouped playback / PSG / interface option pills */
.option-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
  align-items: stretch;
  margin-bottom: 0;
  min-width: 0;
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0.3rem 0.5rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
}

.option-group-title {
  padding: 0 0.25rem;
  font: 600 0.65rem var(--ui-font-family);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.toggle-pill input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-pill span {
  display: inline-block;
  padding: var(--ui-control-py) var(--ui-control-px);
  font: var(--ui-control-font) / var(--ui-control-line) var(--ui-font-family);
  color: var(--text);
  background: #243044;
  border: 1px solid var(--accent-dim);
  border-radius: var(--ui-radius);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.toggle-pill:hover span {
  border-color: var(--accent);
  background: #2d3a4f;
}

.toggle-pill input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.toggle-pill input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.toggle-pill:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
}

.toggle-pill:has(input:disabled) span {
  cursor: not-allowed;
}

input[type="number"] {
  width: 5.5rem;
  margin-left: 0.35rem;
  padding: var(--ui-control-py) 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius);
  background: var(--bg);
  color: var(--text);
  font-size: var(--ui-control-font);
  line-height: var(--ui-control-line);
}

button {
  padding: var(--ui-control-py) 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: var(--ui-control-font);
  line-height: var(--ui-control-line);
  transition: border-color 0.12s, background 0.12s;
}

button:focus-visible,
.file-btn:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

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

#btnReset,
#btnReanalyze {
  background: #243044;
  border-color: var(--accent-dim);
  color: #dce8f8;
}

#btnReset:hover:not(:disabled),
#btnReanalyze:hover:not(:disabled) {
  background: #2d3a4f;
  border-color: var(--accent);
}

/* Default: Play sits at a light green (hover-like); Stop is highlighted red. */
#btnPlay {
  background: #20844a;
  border-color: #2ecc71;
  color: #ecfdf3;
}

#btnPlay:hover:not(:disabled) {
  background: #25a05a;
  border-color: #4be08a;
}

#btnStop {
  background: #962f2f;
  border-color: #e74c3c;
  color: #fceaea;
}

#btnStop:hover:not(:disabled) {
  background: #a83232;
  border-color: #ff6b6b;
}

/* While playing: Play stays green; Stop dims to a muted grey-red. */
.transport-panel-controls.is-playing #btnStop {
  background: #231616;
  border-color: #5a2e2e;
  color: #c8a9a9;
}

.transport-panel-controls.is-playing #btnStop:hover:not(:disabled) {
  background: #331c1c;
  border-color: #905a5a;
}

#btnExportWav,
#btnExportVgm {
  background: #1a3d5c;
  border-color: #5eb3ff;
  color: #e8f4ff;
}

#btnExportWav:hover:not(:disabled),
#btnExportVgm:hover:not(:disabled) {
  background: #245a82;
  border-color: #7ec8ff;
}

.mute-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.mute-grid label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.hint-key {
  color: #fff;
  text-transform: lowercase;
}

footer {
  text-align: center;
  padding: 0.35rem 1rem 8rem;
  font-size: 0.55rem;
  color: var(--muted);
  line-height: 1.35;
}

footer p {
  margin: 0 auto;
  max-width: min(98vw, 68rem);
}

.footer-disclaimer,
.footer-extra {
  display: block;
  margin-top: 0.45rem;
}

footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

footer a:hover {
  color: var(--text);
}

footer code {
  background: var(--panel);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.file-hunter-panel {
  --fh-folder: #e8b060;
  --fh-folder-active: #f0c878;
  --fh-file: var(--accent);
  --fh-row-hover: #243044;
  --fh-row-selected: rgba(61, 139, 253, 0.12);
}

.vgm-explorer-section {
  padding: 1rem 1.25rem;
}

.explorer-heading {
  margin: 0 0 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
}

.explorer-heading-title {
  font: 600 var(--ui-font-md) var(--ui-font-family);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.explorer-heading-credit {
  font: 0.75rem var(--ui-font-family);
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
}

.explorer-heading-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.explorer-heading-credit a:hover {
  color: var(--text);
}

.vgm-explorer-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.vgm-explorer-col {
  min-width: 0;
}

.vgm-explorer-col h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.vgm-info-host {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  --vgi-cover-outer-w: calc(min(38vh, 280px) * 2 / 3);
}

.vgm-info-headings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--vgi-cover-outer-w);
  gap: 1rem;
  align-items: end;
  margin-bottom: 0;
}

.vgm-info-headings h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.vgi-cover-heading {
  text-align: left;
  white-space: nowrap;
}

.vgm-info-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--vgi-cover-outer-w);
  gap: 1rem;
  align-items: stretch;
  height: min(38vh, 280px);
  min-height: min(38vh, 280px);
  max-height: min(38vh, 280px);
}

.vgi-meta-panel {
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--panel);
}

.vgi-cover-wrap {
  height: 100%;
  width: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0;
}

.vgi-cover-panel {
  box-sizing: border-box;
  aspect-ratio: 2 / 3;
  height: 100%;
  width: 100%;
  max-height: 100%;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.vgi-cover-slot {
  box-sizing: border-box;
  position: relative;
  flex: 1 1 0;
  align-self: stretch;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.vgi-cover-placeholder {
  box-sizing: border-box;
  position: absolute;
  inset: 0;
  border: 1px dashed var(--border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font: 0.75rem "Segoe UI", system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(0, 0, 0, 0.15);
}

.vgi-cover-img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.15);
}

.vgi-cover-img--missing {
  object-fit: cover;
  object-position: right center;
}

.vgi-cover-slot--multi .vgi-cover-img {
  cursor: pointer;
}

.vgm-info-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--vgi-cover-outer-w);
  gap: 1rem;
  align-items: center;
}

.vgm-info-toolbar-spacer {
  min-width: 0;
}

.vgi-cover-zoom {
  flex: 0 0 auto;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--explorer-control-h);
  height: var(--explorer-control-h);
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  line-height: 0;
}

.vgi-cover-zoom:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg);
}

.vgi-cover-zoom:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.vgi-cover-zoom[hidden] {
  display: none;
}

.cover-lightbox:not([open]) {
  display: none;
}

.cover-lightbox[open] {
  margin: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-width: min(92vw, 56rem);
  max-height: min(92vh, 900px);
  width: min(92vw, 56rem);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  color: var(--text);
}

.cover-lightbox::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.cover-lightbox-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.cover-lightbox-header.is-dragging {
  cursor: grabbing;
}

.cover-lightbox-header h2 {
  margin: 0;
  flex: 1 1 auto;
  font: 600 0.95rem "Segoe UI", system-ui, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cover-lightbox-close {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.15rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.cover-lightbox-close:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel);
}

.cover-lightbox-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 12px;
  background: var(--panel);
  overflow: hidden;
}

.cover-lightbox-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  min-height: min(80vh, 820px);
  min-width: 0;
}

.cover-lightbox-viewport {
  position: relative;
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  cursor: grab;
  touch-action: none;
}

.cover-lightbox-viewport.is-panning {
  cursor: grabbing;
}

.cover-lightbox-nav {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: 600 1.25rem/1 "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}

.cover-lightbox-nav:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--panel);
}

.cover-lightbox-nav:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cover-lightbox-nav[hidden] {
  display: none;
}

.cover-lightbox-img {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

.vgi-placeholder {
  margin: 0;
  font: var(--ui-kv-label-size) "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.35;
  color: var(--ui-kv-label-color);
}

.vgi-dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.vgi-row {
  display: grid;
  grid-template-columns: minmax(4.75rem, 6.5rem) 1fr;
  gap: 0.35rem;
  align-items: baseline;
  font: var(--ui-kv-label-size) "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.35;
}

.vgi-row dt {
  margin: 0;
  color: var(--ui-kv-label-color);
  font-weight: 400;
  font-size: var(--ui-kv-label-size);
}

.vgi-row dd {
  margin: 0;
  color: var(--ui-kv-label-color);
  font-size: var(--ui-kv-label-size);
  word-break: break-word;
}

.vgi-row dd a {
  color: var(--link, #6eb5ff);
}

@media (max-width: 960px) {
  .controls-spectrum-band {
    grid-template-columns: 1fr;
  }

  .transport-spectrum-host {
    min-height: 4.5rem;
  }

  .vgm-explorer-row {
    grid-template-columns: 1fr;
  }
}

.file-hunter-panel h2 a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.file-hunter-panel h2 a:hover {
  color: var(--text);
}

.file-hunter-host {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.fh-explorer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0;
}

.fh-search {
  flex: 1 1 10rem;
  min-width: 8rem;
  box-sizing: border-box;
  min-height: var(--explorer-control-h);
  font: var(--ui-control-font) var(--ui-font-family);
  line-height: var(--ui-control-line);
  padding: var(--ui-control-py) 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--ui-radius);
  background: var(--bg);
  color: var(--text);
}

.fh-reload-btn {
  min-height: var(--ui-control-h);
  font: var(--ui-control-font) var(--ui-font-family);
  line-height: var(--ui-control-line);
  padding: var(--ui-control-py) var(--ui-control-px);
  border: 1px solid var(--border);
  border-radius: var(--ui-radius);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.fh-reload-btn:hover {
  background: var(--btn-reset-bg, #243044);
}

.fh-index-status {
  flex: 1 1 100%;
  font: var(--ui-font-xs) var(--ui-font-family);
  color: var(--muted);
  line-height: 1.3;
}

.fh-index-status-loading {
  color: var(--msx-cyan);
}

.fh-index-status-warn {
  color: #e8a060;
}

.fh-loading {
  padding: 0.75rem;
  color: var(--muted);
  font: 0.875rem "Segoe UI", system-ui, sans-serif;
}

.fh-chip-filters {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.fh-chip-pill {
  box-sizing: border-box;
  min-width: 16px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid #4a5668;
  border-radius: 0;
  background: #242d3a;
  color: #9aa8bc;
  font: bold 8px var(--ui-font-family);
  line-height: 16px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.fh-chip-pill:hover:not(.fh-chip-pill-active) {
  border-color: #5a6470;
  background: #2d3644;
}

.fh-chip-pill-psg.fh-chip-pill-active {
  background: linear-gradient(
    to bottom,
    #4696e0 0%,
    #4696e0 33.34%,
    #4bc48a 33.34%,
    #4bc48a 66.67%,
    #d99448 66.67%,
    #d99448 100%
  );
  border-color: #4bc48a;
  color: #101820;
}

.fh-chip-pill-scc.fh-chip-pill-active {
  background: #c070b8;
  border-color: #c070b8;
  color: #101820;
}

.fh-chip-pill-scc-plus.fh-chip-pill-active {
  background: #5070d0;
  border-color: #5070d0;
  color: #101820;
}

.fh-explorer {
  display: grid;
  grid-template-columns: minmax(11rem, 38%) 1fr;
  grid-template-rows: minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  height: min(38vh, 280px);
  min-height: min(38vh, 280px);
  max-height: min(38vh, 280px);
}

.fh-pane {
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--panel);
}

.fh-pane::-webkit-scrollbar {
  width: 10px;
}

.fh-pane::-webkit-scrollbar-track {
  background: var(--panel);
}

.fh-pane::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 2px solid var(--panel);
  border-radius: 6px;
}

.fh-pane::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.fh-pane-folders {
  border-right: 1px solid var(--border);
}

.fh-explorer-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
}

.fh-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  min-height: 1.75rem;
  padding: 0.25rem 0.5rem;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text);
  font: 0.875rem "Segoe UI", system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}

.fh-row:hover {
  background: var(--fh-row-hover);
}

.fh-row-selected {
  background: var(--fh-row-selected);
  border-left-color: var(--accent);
}

.fh-row-folder .fh-icon-folder {
  color: var(--fh-folder);
  flex-shrink: 0;
}

.fh-row-folder:hover .fh-icon-folder,
.fh-row-folder.fh-row-selected .fh-icon-folder {
  color: var(--fh-folder-active);
}

.fh-row-file .fh-icon-file {
  color: var(--fh-file);
  flex-shrink: 0;
}

.fh-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fh-files-placeholder,
.fh-files-status,
.fh-empty,
.fh-error {
  padding: 0.85rem 0.65rem;
  font: var(--ui-font-sm) var(--ui-font-family);
  color: var(--muted);
  text-align: center;
  border: 1px dashed color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: var(--ui-radius);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}

.fh-files-error {
  padding: 0.75rem 0.5rem;
  font: 0.875rem "Segoe UI", system-ui, sans-serif;
  color: #e8b060;
}

.fh-files-error a {
  color: var(--accent);
}

.fh-row:disabled {
  opacity: 0.6;
  cursor: wait;
}

.fh-row-loading .fh-label::after {
  content: ' …';
  color: var(--muted);
}
