/* Copyright (c) 2026 Nenad Micic; SPDX-License-Identifier: Apache-2.0 */
@font-face {
  font-family: "Michroma";
  src: url("fonts/Michroma-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
:root {
  --font-body: system-ui, sans-serif;
  --font-panel: "Michroma", "Eurostile Extended", "Arial Narrow", sans-serif;
  --font-readout: ui-monospace, monospace;
  font: 15px/1.5 var(--font-body);
  color-scheme: dark;
  color: #d3e0e6;
  background: #101a20;
  --display: #101a20;
  --panel: #14212a;
  --raised: #202e35;
  --line: #304650;
  --text: #d3e0e6;
  --muted: #a9c0cc;
  --accent: #ef6b60;
  --focus: #a9d8ff;
  --header-height: 78px;
  --mobile-dock-height: calc(141px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
a { color: inherit; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
input, select { min-width: 0; max-width: 100%; }
button, summary, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 30; padding: 8px 12px; color: var(--display); background: var(--focus); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.app-header { position: sticky; top: env(safe-area-inset-top); z-index: 20; display: flex; align-items: center; gap: 24px; max-width: 1668px; margin: auto; padding: 16px 28px; background: var(--display); border-bottom: 1px solid var(--line); }
/* Paint the top safe-area band so scrolled content never shows above the sticky header. */
.app-header::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: env(safe-area-inset-top); background: var(--display); }
.brand { display: flex; flex-direction: column; gap: 3px; font-family: var(--font-panel); font-size: 18px; font-weight: 400; letter-spacing: .11em; line-height: 1.25; text-decoration: none; text-transform: uppercase; white-space: nowrap; }
.brand span { font-size: 10px; letter-spacing: .16em; font-weight: 400; color: var(--muted); }
.header-note { margin: 0; font-size: 12px; color: var(--muted); }
.resource-nav { display: flex; gap: 20px; margin-left: auto; font-size: 12px; }
.app-shell { display: grid; grid-template-columns: minmax(0, 1fr) 148px; gap: 18px; max-width: 1668px; margin: auto; padding: 18px 28px 24px; }
main { grid-column: 1; grid-row: 1; min-width: 0; }
.agent-entry, .agent-resources { max-width: 1668px; margin: 0 auto; padding: 4px clamp(12px, 2vw, 28px); }
.agent-entry { display: flex; align-items: center; flex-wrap: wrap; column-gap: 14px; font-size: 13px; }
.agent-entry span { color: var(--muted); }
.agent-resources { padding-bottom: 16px; }
.agent-resources p { max-width: 86ch; }
.agent-entry a { display: inline-flex; align-items: center; min-height: 44px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h2 { margin: 0; font-size: 17px; line-height: 1.3; }
h3 { font-size: 15px; }
.section-heading > h2, .panel > summary, #views-heading {
  font-family: var(--font-panel);
  font-weight: 400;
  letter-spacing: .075em;
  text-transform: uppercase;
}
.section-heading > h2 { font-size: 14px; letter-spacing: .04em; }
.panel { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); box-shadow: 0 3px 12px rgb(0 0 0 / 12%); }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 12px; }
.small { font-size: 12px; color: var(--muted); }
button { min-height: 38px; padding: 8px 13px; border: 1px solid #536d7b; border-radius: 5px; color: var(--text); background: var(--raised); font-size: 13px; font-weight: 650; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button:hover:not(:disabled) { background: #36515f; }
button.primary { color: var(--display); background: var(--accent); border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: #ff8d80; border-color: #ff8d80; }
button.quiet { background: transparent; }
input, textarea, select { border: 1px solid #536d7b; border-radius: 5px; padding: 8px 10px; background: var(--display); color: var(--text); }
input:disabled, select:disabled { opacity: .6; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
label { font-size: 12px; }
label[for] { display: block; margin-bottom: 5px; }
input[type="checkbox"], input[type="range"] { accent-color: var(--accent); }
.library-body { padding: 10px 18px 12px; }
#library-summary > span { display: block; margin: 2px 0 0 17px; font-family: var(--font-body); font-weight: 400; letter-spacing: normal; line-height: 1.4; text-transform: none; }
.song-library .section-heading { margin-bottom: 6px; gap: 6px 12px; }
.library-views { display: flex; flex-wrap: wrap; gap: 6px; }
.library-views button { min-height: 30px; padding: 4px 10px; }
.library-views button[aria-pressed="true"] { color: var(--text); background: #365a69; border-color: #90b9c8; }
#library-view-detail { margin: 5px 0 9px; }
.library-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.library-search input { width: 100%; min-height: 38px; font-size: 13px; }
.library-search-filters { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr); align-items: end; gap: 12px; margin-bottom: 10px; }
.library-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 10px; }
.library-filters > div { min-width: 0; }
.library-filters select { width: 100%; height: 38px; min-height: 38px; font-size: 12px; }
#song-discovery { margin: 0 0 9px; }
#song-discovery:empty { display: none; }
.library-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, 180px); align-items: start; gap: 12px; }
.library-controls > div { min-width: 0; }
.library-controls input, .library-controls select { width: 100%; height: 38px; font-size: 13px; }
.song-browser { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
#song-results-label { margin-bottom: 5px; font-size: 12px; }
.library-controls #song-select { width: 100%; min-width: 0; min-inline-size: 0; margin: 0; padding: 3px 0; border: 1px solid #536d7b; border-radius: 5px; background: var(--display); font-size: 13px; line-height: 18px; overflow-y: auto; overscroll-behavior: contain; }
.song-choice { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 24px; padding: 2px 8px; font-size: 13px; line-height: 20px; cursor: pointer; }
.song-choice input[type="radio"] { flex: 0 0 13px; width: 13px; height: 13px; margin: 0; padding: 0; accent-color: #a9d8ff; }
.song-choice-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-choice:has(input:checked) { background: #365a69; color: #fff; }
.song-choice:not(:has(input:checked)):hover { background: var(--raised); }
.song-choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
#song-select:disabled .song-choice { opacity: .6; cursor: default; }
.song-jog { display: flex; flex-direction: column; gap: 4px; height: 124px; padding: 4px 0; border-radius: 8px; background: #0c1419; }
.song-jog button { flex: 0 0 44px; min-height: 44px; width: 44px; padding: 0; border-color: #536d7b; background: linear-gradient(#30434c, #1b2932); font-size: 14px; }
.song-jog button:hover:not(:disabled) { background: #36515f; }
.song-jog-grip { flex: 1; margin: 0 7px; border-radius: 5px; background: repeating-linear-gradient(0deg, #16232c 0 4px, #4a606b 4px 6px, #16232c 6px 10px); box-shadow: inset 5px 0 8px #0c1419, inset -5px 0 8px #0c1419; }
.catalog-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 7px 0; }
.catalog-pagination p { flex: 1 1 240px; margin: 0; }
.song-card { padding: 8px 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 7px; background: var(--display); }
.song-card > p:first-of-type { margin: 6px 0; }
.song-card h3 { margin: 0; font-size: 19px; }
.song-actions button { min-height: 44px; }
.song-card .song-actions { margin-top: 6px; }
.song-actions > .primary { min-width: 100px; }
#song-load-right { margin-left: auto; }
.song-preview-roll { max-height: 250px; overflow: auto; margin-top: 10px; }
.song-preview-roll svg { display: block; width: 100%; }
.song-preview-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 0 4px 8px; font-size: 12px; }
.song-preview-legend span { min-width: 0; max-width: 100%; border-left: 4px solid; padding-left: 6px; overflow-wrap: anywhere; }
.library-research { margin: 12px 0; max-width: 78ch; }
.library-research p { font-size: 13px; }
@media (min-width: 801px) {
  .app-shell { padding-top: 12px; }
  .agent-entry a { min-height: 24px; }
  #library-summary > span { display: inline; margin: 0 0 0 10px; }
  .catalog-pagination button { min-height: 30px; padding: 4px 9px; font-size: 12px; }
}
.loaded-song { margin: 0; font-size: 20px; font-weight: 700; }
#loaded-version { margin: 2px 0 12px; }
.mobile-transport, .dock-sections { display: none; }
#song-detail { margin: 7px 0 9px; }
#song-note:empty { display: none; }
.open-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
#dropzone { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 7px 10px; border: 1px dashed #536d7b; border-radius: 5px; }
#dropzone label { margin: 0; white-space: nowrap; }
#dropzone.drag { background: #36515f; border-color: var(--accent); }
#file { flex: 1; min-width: 130px; max-width: 340px; padding: 0; border: 0; background: transparent; font-size: 12px; }
#file::file-selector-button { margin-right: 8px; padding: 6px 9px; border: 1px solid var(--accent); border-radius: 4px; color: var(--display); background: var(--accent); font: inherit; cursor: pointer; }
.output-panel { padding: 15px 18px 17px; }
.player-heading { justify-content: flex-start; margin-bottom: 10px; }
#player-heading, #views-heading, .panel, #live-views { scroll-margin-top: calc(var(--header-height) + env(safe-area-inset-top) + 12px); }
.player-heading #render { margin-left: auto; min-height: 30px; padding: 4px 10px; }
.badge { padding: 4px 9px; border-radius: 4px; background: var(--raised); color: var(--muted); font-size: 11px; }
.badge.unverified { background: #433b2b; color: #f1d293; }
.badge.valid { background: #203e35; color: #a6e2bd; }
.badge.refused, .badge.mismatch { background: #482c2a; color: #ffb4a8; }
.transport { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
#cancel { position: fixed; z-index: 26; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); min-height: 44px; border-color: var(--accent); box-shadow: 0 3px 16px rgb(0 0 0 / 45%); }
#play, #play-right { min-width: 102px; min-height: 44px; font-size: 15px; }
.check-label { display: inline-flex; align-items: center; gap: 5px; padding: 7px 2px; }
.check-label input { margin: 0; width: 16px; height: 16px; }
#time { margin-left: auto; font: 13px var(--font-readout); white-space: nowrap; }
.position-row { margin-top: 7px; }
#seek { display: block; width: 100%; height: 24px; padding: 0; border: 0; background: transparent; cursor: pointer; }
#seek:disabled { cursor: default; }
.player-status { min-height: 20px; margin: 2px 0 12px; color: var(--muted); font-size: 12px; }
.display-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; padding: 9px 11px; border-radius: 7px 7px 0 0; background: #202e35; }
.display-toolbar .small { color: #b8c7cb; }
.view-controls { display: flex; flex-wrap: wrap; gap: 4px; }
.view-controls button { min-height: 32px; padding: 5px 12px; border-color: #4d636e; color: #c5d5dc; background: transparent; }
.view-controls button:hover:not(:disabled) { background: #334b57; }
.view-controls button[aria-pressed="true"] { border-color: #90b9c8; background: #365a69; color: #fff; }
.display-surface { min-height: 320px; border: 1px solid #202e35; border-top: 0; border-radius: 0 0 7px 7px; background: var(--display); color: #c4d3db; overflow: hidden; }
.timeline { position: relative; min-height: 320px; max-height: 480px; overflow: auto; }
.timeline:focus-visible { outline-offset: -3px; }
.qr-dialog { width: min(420px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-sizing: border-box; overflow: auto; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); }
.qr-dialog::backdrop { background: rgb(4 9 13 / 75%); }
.qr-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qr-dialog-header h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.qr-dialog-header button { flex: none; }
.qr-dialog p, .qr-dialog label { font-size: 14px; }
.qr-image { max-width: 320px; margin: 14px auto; background: white; }
.qr-image svg { display: block; width: 100%; height: auto; }
.qr-dialog label { display: block; margin: 12px 0 6px; font-weight: 600; }
.qr-dialog textarea { width: 100%; min-height: 74px; resize: vertical; box-sizing: border-box; font: 12px/1.4 ui-monospace, monospace; overflow-wrap: anywhere; white-space: pre-wrap; }
.qr-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.qr-status { min-height: 1.5em; margin-bottom: 0; overflow-wrap: anywhere; }
.qr-dialog :focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.timeline > p { margin: 0; padding: 130px 20px; text-align: center; font-size: 13px; }
.timeline > svg { display: block; width: 100%; }
#spectrum-panel { min-height: 320px; }
.spectrum-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; }
#spectrum-status { margin: 0; font-size: 12px; }
#spectrum-cancel { color: #e2eaf0; border-color: #607985; background: transparent; }
#spectrogram { display: block; width: 100%; height: auto; margin: 0; background: var(--display); }
.downloads { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.downloads button { font-size: 12px; min-height: 34px; padding: 6px 10px; }
summary { cursor: pointer; font-size: 13px; font-weight: 650; }
.panel > summary { padding: 13px 18px; background: var(--raised); border-radius: 8px; }
.panel[open] > summary { border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.detail-body { padding: 16px 18px 18px; }
.detail-body > p:first-child { margin-top: 0; }
.detail-body details { margin-top: 14px; }
textarea { display: block; width: 100%; min-height: 250px; resize: vertical; font: 12px/1.6 ui-monospace, monospace; white-space: pre; tab-size: 2; }
.row { display: flex; gap: 10px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.actions { flex-wrap: wrap; margin-top: 10px; }
.actions p { margin: 0; }
#url-form { margin-top: 16px; }
dl { display: grid; grid-template-columns: minmax(100px, 160px) minmax(0, 1fr); gap: 7px 14px; font-size: 12px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, monospace; }
pre { overflow: auto; padding: 12px; border-radius: 5px; background: var(--display); border: 1px solid var(--line); font: 11px/1.6 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.agent-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.agent p { font-size: 13px; }
.agent code { font-size: 12px; }
.reference-links { display: flex; gap: 8px 16px; flex-wrap: wrap; }
#provenance { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
#provenance label { display: flex; flex-direction: column; gap: 5px; }
#provenance input, #provenance select { width: 100%; min-width: 0; font-size: 12px; }
footer { padding: 8px 0 12px; color: var(--muted); font-size: 11px; }
/* One shell surrounds the library, instrument and supporting panels. The rail
   keeps its transport above independently scrolling links. At very short heights
   the entire rail can scroll, so no controls are clipped. Compact windows keep
   the header disclosure and persistent bottom transport. */
.section-nav { grid-column: 2; grid-row: 1; position: sticky; top: calc(var(--header-height) + env(safe-area-inset-top) + 18px); align-self: start; display: flex; flex-direction: column; min-width: 0; max-height: calc(100dvh - var(--header-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 30px); overflow-y: auto; overscroll-behavior: contain; padding: 10px 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.section-nav-heading { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 10px 9px; color: var(--muted); font: 12px var(--font-panel); letter-spacing: .1em; text-transform: uppercase; }
.section-links { min-height: 44px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.rail-transport { flex: none; display: grid; gap: 6px; min-width: 0; margin-bottom: 8px; padding: 8px 6px 10px; border-bottom: 1px solid var(--line); }
.rail-selection { max-height: 8em; overflow-y: auto; overscroll-behavior: contain; }
.rail-selection > * { display: block; }
.rail-selection strong, .rail-selection .small, .rail-loaded-song { overflow-wrap: anywhere; }
.rail-selection strong { font-size: 13px; line-height: 1.3; }
.rail-selection .small { margin-top: 3px; font-size: 12px; line-height: 1.3; }
.rail-label { margin-bottom: 3px; color: var(--muted); font-family: var(--font-panel); font-size: 12px; letter-spacing: .02em; text-transform: uppercase; }
.rail-transport button { width: 100%; min-height: 44px; padding: 8px 5px; }
#rail-load { color: var(--display); background: #72b9ef; border-color: #72b9ef; }
#rail-load:hover:not(:disabled) { background: #a0d2f7; border-color: #a0d2f7; }
.rail-loaded-song, #rail-status { max-height: 4.05em; overflow-y: auto; overscroll-behavior: contain; margin: 0; font-size: 12px; line-height: 1.35; }
.rail-loaded-song { color: var(--text); }
#rail-time { color: var(--muted); font: 12px/1.3 var(--font-readout); white-space: nowrap; }
.section-nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px; border: 1px solid transparent; border-radius: 5px; font-family: var(--font-body); font-size: 12px; font-weight: 600; text-decoration: none; }
.section-nav a span { color: var(--muted); font: 12px ui-monospace, monospace; }
.section-nav a:hover { background: var(--raised); }
.section-nav a[aria-current="location"] { border-color: #90b9c8; background: #365a69; color: #fff; }
.section-nav a[aria-current="location"] span { color: #d3e0e6; }
.auto-move-control { padding: 8px 10px 4px; }
.auto-move-control .check-label { min-height: 44px; font-weight: 600; }
.auto-move-control .small { margin: 0; font-size: 12px; }
#auto-move-off { margin-bottom: 8px; color: var(--text); }
#auto-move-on { display: block; width: 100%; margin-top: 6px; }
.section-toggle { flex: none; min-height: 44px; white-space: nowrap; }
.section-toggle span { padding-left: 5px; }
.live-views { margin-top: 18px; }
#views-heading { margin: 0 0 9px; color: var(--muted); font-size: 11px; }
.view-controls button { padding-inline: 8px; font-size: 12px; }
#file::file-selector-button:hover { background: #ff8d80; }
#file:focus-visible { outline-offset: 4px; }
@media (max-width: 1099px) {
  .app-shell { display: block; }
  .section-nav { position: fixed; z-index: 25; top: calc(var(--header-height) + env(safe-area-inset-top) + 8px); right: max(12px, env(safe-area-inset-right)); width: min(276px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 24px)); max-height: calc(100dvh - var(--header-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px); overflow-y: auto; overscroll-behavior: contain; box-shadow: 0 12px 28px rgb(0 0 0 / 40%); }
  .section-nav-heading { padding: 0 2px 8px 10px; }
  .rail-transport { display: none; }
  .section-links { flex: none; overflow: visible; scrollbar-gutter: auto; }
  .section-nav-heading button { min-height: 44px; }
}
@media (max-width: 480px) {
  .resource-nav { display: none; }
  .section-toggle { margin-left: auto; padding: 8px 10px; }
}

@media (max-width: 1099px) {
  #cancel { bottom: calc(var(--mobile-dock-height) + 8px); }
  html { scroll-padding-bottom: calc(var(--mobile-dock-height) + 12px); }
  body { padding-bottom: var(--mobile-dock-height); }
  main :is(button, input, select, textarea, summary, a, .song-choice) { scroll-margin-top: calc(var(--header-height) + env(safe-area-inset-top) + 12px); scroll-margin-bottom: 8px; }
  .mobile-transport { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 8px; position: fixed; bottom: 0; left: 0; right: 0; z-index: 22; padding: 6px max(12px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: var(--display); box-shadow: 0 -4px 14px rgb(0 0 0 / 24%); }
  .mobile-transport strong, .mobile-transport span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-identity { min-width: 0; }
  .mobile-transport strong { font-size: 12px; line-height: 1.2; }
  .mobile-transport span { line-height: 1.2; }
  .mobile-actions { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .mobile-actions button { min-width: 0; }
  .mobile-transport span, .mobile-transport output { font-size: 11px; color: var(--muted); }
  .mobile-transport button { min-height: 44px; }
  #choose-song[data-action="load"] { color: #101a20; background: #72b9ef; border-color: #72b9ef; }
  #choose-song[data-action="load"]:hover:not(:disabled) { background: #a0d2f7; border-color: #a0d2f7; }
  .mobile-section-nav { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .mobile-section-nav a { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; padding: 6px 4px; border: 1px solid var(--section-color); border-radius: 5px; color: var(--section-color); background: var(--display); font-family: var(--font-body); font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none; }
  .mobile-section-nav a[data-section="library-panel"] { --section-color: #f5ae68; }
  .mobile-section-nav a[data-section="player-panel"] { --section-color: #e9cf70; }
  .mobile-section-nav a[data-section="live-views"] { --section-color: #87d7b3; }
  .mobile-section-nav a[aria-current="location"] { color: var(--display); background: var(--section-color); font-weight: 800; box-shadow: inset 0 0 0 1px var(--section-color); }
  .mobile-section-nav a:hover { box-shadow: inset 0 0 0 1px var(--section-color); }
  #mobile-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
}
@media (max-width: 800px), (max-width: 1099px) and (max-height: 500px) {
  .song-card .actions button, .catalog-pagination button { min-height: 44px; }
  .app-header { padding: 13px 16px; gap: 12px; }
  .header-note { display: none; }
  .app-shell { padding: 12px 12px 20px; }
  .library-controls { grid-template-columns: minmax(0, 1fr); }
  .library-controls .saved-version { width: min(100%, 280px); }
  .library-search-filters { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .song-library .section-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; }
  #library-heading { grid-column: 1; grid-row: 1; }
  .song-library .library-views { grid-column: 1 / -1; grid-row: 2; }
  #library-status { grid-column: 1 / -1; grid-row: 3; }
  .library-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-filters select { height: 44px; min-height: 44px; }
  .library-controls #song-select { height: 200px; max-height: min(200px, max(124px, calc(100dvh - var(--header-height) - var(--mobile-dock-height) - env(safe-area-inset-top) - 32px))); }
  .song-choice { min-height: 24px; padding: 2px 7px; gap: 7px; font-size: 14px; line-height: 1.4; }
  .song-choice input[type="radio"] { flex-basis: 16px; width: 16px; height: 16px; }
  .song-jog { align-self: stretch; height: 100%; min-height: 124px; }
  .song-jog button { color: #142a1b; border-color: #b7e4bf; background: linear-gradient(#b7e4bf, #8dcea0); }
  .song-jog button:hover:not(:disabled) { border-color: #c8efcf; background: #c8efcf; }
  .library-body, .output-panel { padding: 13px; }
  #drop-hint { display: none; }
  .agent-grid { grid-template-columns: 1fr; gap: 24px; }
  .display-surface, .timeline, #spectrum-panel { min-height: 280px; }
  .timeline { max-height: 420px; }
  .timeline > p { padding: 110px 14px; }
}
@media (max-width: 480px) {
  .brand { font-size: 16px; }
  .brand span { font-size: 10px; }
  .section-heading > h2 { font-size: 13px; }
  .resource-nav { gap: 12px; }
  .song-library .section-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; }
  #library-heading { grid-column: 1; grid-row: 1; }
  #library-status { grid-column: 1 / -1; grid-row: 3; }
  .library-views { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .library-views button { min-width: 0; padding: 5px 4px; font-size: 12px; line-height: 1.25; }
  .library-search { gap: 8px; }
  .library-search button { padding: 8px; font-size: 12px; }
  .library-filters { gap: 8px; }
  .song-browser { gap: 5px; }
  .song-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr); gap: 6px; }
  .song-actions button, .song-actions > .primary { min-width: 0; width: 100%; padding: 8px 5px; font-size: 12px; }
  #song-load { grid-column: 1; grid-row: 1; }
  #song-preview { grid-column: 2; grid-row: 1; }
  #song-load-right { grid-column: 3; grid-row: 1; margin: 0; }
  #song-preview-cancel { grid-column: 1 / -1; grid-row: 2; }
  .open-row { align-items: stretch; }
  #dropzone { flex-basis: 100%; flex-wrap: wrap; }
  #file { width: 100%; max-width: none; }
  #example { min-height: 30px; padding: 4px 8px; }
  .display-toolbar > .small { display: none; }
  .transport { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #play, #play-right { min-width: 0; width: 100%; padding: 8px 5px; font-size: 14px; grid-row: 1; }
  #play { grid-column: 1; }
  #stop { grid-column: 2; grid-row: 1; }
  #play-right { grid-column: 3; }
  .transport .check-label { grid-column: 1; grid-row: 2; }
  #time { grid-column: 2 / -1; grid-row: 2; justify-self: end; margin-left: 0; font-size: 12px; }
  #cancel { margin-left: auto; }
  .panel > summary { padding: 12px 13px; }
  .detail-body { padding: 13px; }
  #provenance { grid-template-columns: 1fr; }
  dl { grid-template-columns: 95px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

.profile-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 9px 16px; margin-top: 12px; }
.profile-controls > div { flex: 1; min-width: 180px; max-width: 340px; }
.profile-controls select { width: 100%; height: 38px; min-height: 38px; }
.profile-controls .check-label { min-height: 38px; margin: 0; }
#profile-detail { margin: 7px 0; }
.profile-help { margin: 0 0 13px; font-size: 12px; }
.profile-help p { margin: 8px 0; max-width: 95ch; }
.instrument { padding: 14px 16px 16px; color: #d3e0e6; }
.instrument-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 14px; }
#instrument-route { font-size: 13px; }
#instrument-clock { color: #a9c0cc; font: 12px var(--font-readout); }
.instrument h3 { margin: 6px 0 9px; color: #d3e0e6; font-family: var(--font-panel); font-size: 10px; font-weight: 400; letter-spacing: .065em; text-transform: uppercase; }
.instrument-header strong, .instrument-meter label,
#instrument-spectrum-panel label {
  font-family: var(--font-panel);
  font-weight: 400;
  letter-spacing: .035em;
  text-transform: uppercase;
}
.instrument-caption { margin: 7px 0 10px; color: #a9c0cc; font-size: 11px; }
.instrument-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr); gap: 14px; }
.instrument-grid > section { min-width: 0; }
.instrument-audio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; margin: 10px 0 14px; }
.instrument-audio-grid > section { min-width: 0; }
.instrument-panel-controls { display: flex; flex-wrap: wrap; gap: 16px; padding-top: 10px; }
.instrument-panel-controls label { display: flex; align-items: center; gap: 6px; margin: 0; min-height: 32px; color: #d3e0e6; font-size: 12px; }
.instrument-panel-controls input { width: auto; }
.instrument-roll { padding: 10px 12px; border: 1px solid #304650; border-radius: 5px; background: #101a20; }
.instrument-roll-chart { display: grid; grid-template-columns: 36px minmax(0, 1fr); height: 214px; }
.instrument-pitch-axis { position: relative; color: #a9c0cc; font: 10px var(--font-readout); }
.instrument-pitch-axis span { position: absolute; right: 5px; transform: translateY(-50%); }
#instrument-roll-plot { width: 100%; height: 214px; overflow: hidden; }
.instrument-roll-times { display: flex; justify-content: space-between; margin: 4px 0 0 36px; color: #a9c0cc; font: 10px var(--font-readout); }
.instrument-roll-legend { display: flex; flex-wrap: wrap; gap: 5px 12px; margin: 8px 0; font-size: 11px; }
.instrument-roll-legend span { border-left: 4px solid var(--stream-color, #657c88); padding-left: 5px; overflow-wrap: anywhere; }
.instrument-spectrum-chart { display: grid; grid-template-columns: 28px minmax(0, 1fr); height: 140px; }
#instrument-spectrum-panel { display: flex; flex-direction: column; }
.instrument-spectrum-footer { margin-top: auto; }
.instrument-db-axis { display: flex; flex-direction: column; justify-content: space-between; color: #a9c0cc; font: 10px var(--font-readout); }
#instrument-spectrum { width: 100%; height: 140px; background: #101a20; }
.instrument-spectrum-axis { display: flex; justify-content: space-between; gap: 4px; margin: 5px 0 0 28px; color: #a9c0cc; font: 10px var(--font-readout); }
#instrument-spectrum-panel label { display: flex; gap: 7px; align-items: center; color: #d3e0e6; font-size: 11px; }
#instrument-spectrum-channel { min-width: 0; width: 100%; color: #d3e0e6; background: #202e35; padding: 3px; }
.instrument-spectrum-controls { display: flex; gap: 5px; flex-wrap: wrap; }
.instrument-spectrum-controls button { flex: 1; min-width: 58px; min-height: 44px; padding: 5px 8px; font-size: 12px; }
.instrument-spectrum-controls button[aria-pressed="true"] { background: #365a69; border-color: #90b9c8; box-shadow: 0 0 0 1px #90b9c8 inset; }
#instrument-spectrum-left { border-bottom: 3px solid #eabf6c; }
#instrument-spectrum-right { border-bottom: 3px dashed #87d7b3; }
.display-off { margin: 0; padding: 16px; color: #a9c0cc; }
.display-surface[data-view="off"] { min-height: 0; }
.instrument-audio, .instrument-spatial { padding: 10px 12px; border: 1px solid #304650; border-radius: 5px; background: #14212a; }
#instrument-scope { display: block; width: 100%; height: 140px; background: #101a20; border-radius: 3px; }
#instrument-meters { display: grid; gap: 5px; max-height: 164px; overflow: auto; margin: 12px 0 8px; }
.instrument-meter { display: grid; grid-template-columns: minmax(36px, auto) minmax(30px, 1fr) 78px; align-items: center; gap: 7px; }
.instrument-meter label { margin: 0; color: #c1d2da; font-size: 11px; }
.instrument-meter span { color: #a9c0cc; text-align: right; font: 11px var(--font-readout); }
.instrument-meter meter { width: 100%; height: 11px; accent-color: #87d7b3; }
#instrument-space { display: block; width: 100%; height: 320px; border-radius: 4px; background: #101a20; }
.instrument-space-controls { display: flex; gap: 6px; margin: 7px 0; }
.instrument-space-controls button { min-height: 44px; min-width: 64px; }
.instrument-space-controls button[aria-pressed="true"] { background: #365a69; border-color: #90b9c8; }
#instrument-space-summary { color: #d3e0e6; }
.instrument-navigation { display: flex; gap: 7px; flex-wrap: wrap; }
.instrument button { color: #d3e0e6; background: #202e35; border-color: #536d7b; }
.instrument button:hover:not(:disabled) { background: #36515f; }
.instrument-navigation button { padding: 5px 9px; font-size: 11px; min-height: 32px; }
#instrument-voices { display: flex; flex-wrap: wrap; gap: 5px; max-height: 116px; overflow: auto; padding: 3px; margin: 0 -3px; }
#instrument-voices button { min-width: 38px; min-height: 34px; padding: 5px 9px; font: 12px ui-monospace, monospace; }
#instrument-voices button[data-gate="open"] { color: #101a20; background: var(--voice-color); border-color: var(--voice-color); }
#instrument-voices button[aria-pressed="true"] { box-shadow: 0 0 0 2px #e6f0f4 inset; text-decoration: underline; text-underline-offset: 3px; }
.instrument-detail { min-height: 36px; margin: 10px 0; color: #c6d8e1; font-size: 12px; }
#instrument-keyboard { position: relative; display: flex; align-items: flex-start; height: 64px; max-width: 600px; }
.instrument-key { position: relative; flex: 1; display: flex; align-items: flex-end; justify-content: center; height: 64px; padding-bottom: 4px; background: #d4dce0; color: #273c47; border: 1px solid #101a20; border-radius: 0 0 3px 3px; font-size: 11px; }
.instrument-key.black { z-index: 1; flex: 0 0 8%; width: 8%; height: 41px; margin-left: -4%; margin-right: -4%; color: #c6d8e1; background: #273c47; }
.instrument-key[data-gate="open"] { background: #87d7b3; color: #101a20; }
.instrument-key[data-selected="true"] { box-shadow: 0 -4px 0 #eabf6c inset; }
.instrument :focus-visible { outline-color: #a9d8ff; }
@media (max-width: 700px) {
  .instrument-grid { grid-template-columns: minmax(0, 1fr); }
  .instrument { padding: 11px; }
  .instrument-audio, .instrument-spatial { padding: 8px 10px; }
  #instrument-scope { height: 100px; }
  #instrument-space { height: 280px; }
  .profile-controls { gap: 8px; }
  .profile-controls > div { flex-basis: 100%; max-width: none; }
  .profile-controls .check-label { flex: 1; }
}
@media (max-width: 480px) {
  .instrument h3 { font-family: var(--font-body); font-size: 12px; font-weight: 600; letter-spacing: normal; text-transform: none; }
}
@media (max-width: 359px) {
  .view-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
}

/* Touch controls remain usable in short landscape windows and installed PWAs.
   Editable fields use 16px to avoid iPhone focus zoom; browser zoom stays enabled. */
@media (pointer: coarse), (max-width: 800px), (max-width: 1099px) and (max-height: 500px) {
  body button, #play, #example, .player-heading #render,
  .library-views button, .view-controls button, .downloads button,
  .profile-controls .check-label, .instrument-navigation button,
  body summary, body .check-label, body .instrument-panel-controls label,
  body input:not([type="checkbox"]):not([type="radio"]), body select { min-height: 44px; }
  body button { min-width: 44px; }
  body input:not([type="checkbox"]):not([type="radio"]), body select, body textarea,
  body .library-controls select, body .library-filters select, body .qr-dialog textarea,
  #file, #provenance input, #provenance select { font-size: 16px; }
  body .library-controls input:not([type="radio"]), body .library-controls select,
  body .library-filters select, body .profile-controls select { height: 44px; }
  #seek { height: 44px; }
  #file::file-selector-button { min-height: 44px; }
  .resource-nav { gap: 8px; }
  .resource-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 4px; }
  .profile-help summary, .detail-body summary { padding: 10px 0; }
  .instrument-panel-controls { gap: 4px 16px; }
  .instrument-panel-controls input, .check-label input { width: 20px; height: 20px; }
  #instrument-voices button { min-width: 44px; min-height: 44px; }
  .qr-dialog { max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px); }
}

/* Short windows keep their fixed transport while the header scrolls away;
   the dock's Sections button keeps the section menu reachable. */
@media (max-width: 1099px) and (max-height: 500px) {
  .app-header { position: static; }
  .mobile-transport { column-gap: 8px; }
  .mobile-identity { grid-column: 1; grid-row: 1; }
  .mobile-actions { grid-column: 2; grid-row: 1; min-width: 230px; }
  .mobile-section-nav { grid-row: 2; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dock-sections { display: block; min-width: 0; padding: 6px 4px; font-size: 12px; line-height: 1.2; }
  #mobile-time, #mobile-version { display: none; }
}

.diagnostics .row { flex-wrap: wrap; }
.diagnostics .row > label { flex: 1 1 150px; min-width: 0; }
.diagnostics .row > label input:not([type="checkbox"]) { width: 100%; }

.guide-manual { display: inline-flex; align-items: center; min-height: 44px; padding: 4px 8px; }

/* Phone type scale: body copy 14px and secondary text, labels and readouts at
   least 13px. The brand lockup, chart axis ticks and keyboard key letters keep
   their small sizes. Song rows stay 24px, so eight remain visible. */
@media (max-width: 480px) {
  .agent-entry, .agent p, .library-research p, .profile-help, .timeline > p, .mobile-transport strong { font-size: 14px; }
  .small, label, dl, pre, footer, .badge, #views-heading, #song-results-label, .player-status, #spectrum-status,
  .song-preview-legend, .agent code, #time, .mobile-transport span, .mobile-transport output, .mobile-section-nav a,
  .library-views button, .library-search button, .song-actions button, .song-actions > .primary, .downloads button,
  .view-controls button, .section-nav-heading, .section-nav a, .section-nav a span, .auto-move-control .small,
  .instrument h3, .instrument-caption, .instrument-detail, .instrument-roll-legend, #instrument-clock,
  .instrument-panel-controls label, #instrument-spectrum-panel label, .instrument-spectrum-controls button,
  .instrument-meter label, .instrument-meter span, .instrument-navigation button, #instrument-voices button { font-size: 13px; }
  .instrument-meter { grid-template-columns: minmax(36px, auto) minmax(30px, 1fr) 90px; }
}
