:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1e23;
  --muted: #6a7280;
  --line: #dfe3e8;
  --accent: #2f6df6;
  --accent-soft: #e6edfe;
  --good: #17935a;
  --bad: #cf3b3b;
  --wave: #9aa5b4;
  --wave-sel: #2f6df6;
  --topbar-bg: #1b1e23;
  --topbar-ink: #f3f5f8;
  --topbar-dim: #a6adb9;
  --radius: 10px;
  --mono: ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", monospace;
}

/* Three states, not two. No attribute means "whatever this computer is set to",
   which is the default and the one that keeps following the system when it
   switches at dusk. The :not() is what lets an explicit choice of light win
   against a system set to dark — without it the media query would override it
   and the toggle would only work in one direction.

   The dark values appear twice on purpose: a media query and a plain selector
   cannot be combined into one rule. docs.css carries the same three blocks, and
   a test compares them, which is what keeps the two from drifting. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14171c;
    --panel: #1c2027;
    --ink: #e8ebef;
    --muted: #939caa;
    --line: #2c323b;
    --accent: #5b8cff;
    --accent-soft: #23304d;
    --good: #35c07f;
    --bad: #ef6b6b;
    --wave: #5b6572;
    --wave-sel: #5b8cff;
    --topbar-bg: #0e1116;
    --topbar-ink: #eef1f5;
    --topbar-dim: #98a1ae;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c;
  --panel: #1c2027;
  --ink: #e8ebef;
  --muted: #939caa;
  --line: #2c323b;
  --accent: #5b8cff;
  --accent-soft: #23304d;
  --good: #35c07f;
  --bad: #ef6b6b;
  --wave: #5b6572;
  --wave-sel: #5b8cff;
  --topbar-bg: #0e1116;
  --topbar-ink: #eef1f5;
  --topbar-dim: #98a1ae;
}

* {
  box-sizing: border-box;
}

/* Every focusable thing shows where the keyboard is. Only .help-btn used to,
   so everywhere else fell back to the UA default, which is close to invisible
   against the dark panel. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    15px/1.5 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

h1 {
  font-size: 17px;
  margin: 0;
}
h2 {
  font-size: 13px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}
.hidden {
  display: none !important;
}

/* ---- unsupported browser / no JavaScript ---- */
.blocker {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}
.blocker-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  max-width: 440px;
}
.blocker-card h2 {
  font-size: 17px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  margin-bottom: 10px;
}
.blocker-card p {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
}
.blocker-card p:last-child {
  margin-bottom: 0;
}

/* ---- small-screen advisory ---- */
.advisory {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  font-size: 13px;
  background: var(--accent-soft);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.advisory button {
  flex: 0 0 auto;
  margin-left: auto;
}

/* ---- header ---- */
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 220px;
}
.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
/* A visible box, so it reads as a field you can type in rather than a caption. */
#programName {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  width: 260px;
}
#programName:hover {
  border-color: var(--muted);
}
#programName:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--bg);
}

.budget {
  flex: 1 1 380px;
  min-width: 260px;
  max-width: 560px;
}
.budget-time {
  font: 600 30px/1.1 var(--mono);
  font-variant-numeric: tabular-nums;
}
.budget-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}
/* The readout never wraps, so the select is what gives way when the header is
   tight: a truncated level name is still readable, a readout broken across two
   lines mid-phrase is not. */
.budget-meta > select {
  min-width: 0;
  flex: 0 1 auto;
}
.budget-meta > .delta {
  flex: 0 0 auto;
}
.delta {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.delta.ok {
  color: var(--good);
}
.delta.bad {
  color: var(--bad);
}
.budget-bar {
  position: relative;
  height: 8px;
  margin-top: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.budget-ok {
  position: absolute;
  height: 100%;
  background: var(--accent-soft);
}
.budget-fill {
  position: absolute;
  height: 100%;
  background: var(--muted);
  transition: width 0.12s linear;
}
.budget-fill.ok {
  background: var(--good);
}
.budget-fill.bad {
  background: var(--bad);
}

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

/* ---- buttons ---- */
button {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) {
  border-color: var(--muted);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}
button.small {
  padding: 4px 10px;
  font-size: 13px;
}
button.danger {
  color: var(--bad);
}
button.danger:hover:not(:disabled) {
  border-color: var(--bad);
}
/* Filled red only on the confirmation itself, so the destructive step is the
   one that looks destructive — not the button that opens the dialog. */
button.danger-solid {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
button.danger-solid:hover:not(:disabled) {
  filter: brightness(1.08);
}
button.play {
  min-width: 76px;
}

select,
input[type="text"] {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
}

/* ---- layout ---- */
main {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  padding: 16px 20px 40px;
  align-items: start;
}
/* Collapsed, the sidebar hands its whole column back to the workspace and
   keeps only the button that brings it out again — put anywhere else, that
   button would be a control for a panel with nothing on screen to attach it
   to. Below the breakpoint there is one column anyway and nothing to reclaim,
   so the collapsed rule has to be overridden rather than merely outranked:
   main.library-collapsed is the more specific selector. */
main.library-collapsed {
  grid-template-columns: auto 1fr;
}
/* The same padding as the expanded panel, so the toggle keeps the exact spot it
   was in rather than sliding as the sidebar goes. */
main.library-collapsed #library {
  padding: 14px;
}
main.library-collapsed #library > :not(.panel-head) {
  display: none;
}
main.library-collapsed #library .panel-head {
  margin-bottom: 0;
}
main.library-collapsed #library .panel-head > :not(.lib-toggle) {
  display: none;
}
/* ---- help menu ---- */

.menu-wrap {
  position: relative;
}
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  width: 200px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
.menu hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 4px 0;
}

/* One control, three states, and the chosen one is obvious without reading —
   which a cycling button never manages, because it can only ever show you where
   you are and not what else there is. */
.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.seg > button {
  flex: 1;
  border: 0;
  border-radius: 0;
  padding: 6px 4px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
}
.seg > button + button {
  border-left: 1px solid var(--line);
}
.seg > button:hover:not([aria-checked="true"]) {
  color: var(--ink);
  background: var(--bg);
}
.seg > button[aria-checked="true"] {
  color: #fff;
  background: var(--accent);
}

/* The panel-with-a-chevron mark, which is what editors and browsers use for
   "show or hide the side panel". A bare arrow was the first attempt and says
   nothing about what it acts on; this draws the panel itself, with the bar down
   the side standing for the sidebar and the chevron pointing the way it is
   about to go. */
.lib-toggle .ico-show {
  display: none;
}
main.library-collapsed .lib-toggle .ico-hide {
  display: none;
}
main.library-collapsed .lib-toggle .ico-show {
  display: block;
}

/* The toggle comes first in the row and the heading takes the slack, so the
   button sits at the far left whether the panel is open or shut. Collapsed it
   is the only thing left, and a control that moves when you use it is a control
   you have to go looking for the second time. */
#library .panel-head > h2 {
  margin-right: auto;
}
.lib-toggle {
  display: grid;
  place-items: center;
  /* Matches a full-size button, which is what sets the height of this row while
     the panel is open. Without it the row shrinks to the icon when everything
     else is hidden and the toggle rises by several pixels as you collapse —
     small, and exactly the kind of movement that makes you hunt for a control
     you just used. A browser check pins the position in both states. */
  min-height: 39px;
  padding: 4px 6px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}
.lib-toggle:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--line);
}

@media (max-width: 860px) {
  main,
  main.library-collapsed {
    grid-template-columns: 1fr;
  }
}

aside,
section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  /* Grid items default to min-width:auto, so one long unbreakable clip name
     would widen the whole column and push the buttons off-screen. */
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  /* The controls beside the heading refuse to shrink, so on a narrow window
     they have to be allowed onto a second line instead — without this, adding
     one more button to the row pushes the rest off the side of the page. */
  flex-wrap: wrap;
}
/* The heading yields; the controls beside it never shrink. When there are too
   many of them to fit, they take a second line rather than being squashed. */
.panel-head > h2 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.panel-head > :not(h2) {
  flex: 0 0 auto;
}

/* ---- library ---- */
#libraryList {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
#libraryList li {
  position: relative; /* for the corner × */
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
}
#libraryList .lib-title {
  font-size: 13px;
  word-break: break-word;
}
/* Room for the corner × beside the name. */
#libraryList li:has(.lib-remove:not(.hidden)) .lib-title {
  padding-right: 26px;
}
/* In the red of every other removal, softened until it is pointed at: it is
   the one thing on the card that takes something away, not the thing to
   look at first. */
#libraryList .lib-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--bad);
  opacity: 0.6;
  font-size: 18px;
  line-height: 1;
}
#libraryList .lib-remove:hover,
#libraryList .lib-remove:focus-visible {
  opacity: 1;
  background: var(--bg);
}
/* What the song is on the left, what to do with it on the right. The facts
   give way first, and the row wraps rather than pushing a button out. */
#libraryList .lib-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
#libraryList .lib-facts {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
#libraryList .lib-row .badge,
#libraryList .lib-row button {
  flex: 0 0 auto;
}
/* The waveform is the play control, with the mark that says so at its left. */
#libraryList .lib-play {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
#libraryList .lib-play:hover canvas {
  opacity: 0.75;
}
#libraryList .lib-play-icon {
  position: relative;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
}
/* A triangle while it would play, a square while it would stop. */
#libraryList .lib-play-icon::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 8px;
  border-left: 8px solid #fff;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
#libraryList .lib-play[aria-pressed="true"] .lib-play-icon::after {
  top: 7px;
  left: 7px;
  width: 8px;
  height: 8px;
  border: 0;
  background: #fff;
}
#libraryList .lib-play canvas {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---- song player ---- */
/* A song from the music list, in a dialog of its own in the middle of the
   dimmed page — the modal card does the placing. */
/* Darker than the other dialogs: this one is for listening, and the page
   behind it is not what anyone is looking at. */
#songPlayer.modal {
  background: rgba(0, 0, 0, 0.72);
}
.modal-card.song-player {
  gap: 16px;
  width: min(720px, 94vw);
  padding: 24px 28px 28px;
}
.song-player-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* The song's own name, as written — not the small capitals of a section
   heading. */
.song-player-head h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}
.song-player-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}
.song-player-close:hover {
  color: var(--ink);
  background: var(--bg);
}
/* The waveform is where to click or drag to move through the song. */
.song-player-wave {
  position: relative;
  cursor: pointer;
  touch-action: none;
}
.song-player-wave canvas {
  display: block;
  width: 100%;
  height: 120px;
}
/* The part already heard, tinted, with a line where the music is now. */
.song-player-progress {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-right: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  pointer-events: none;
}
#songSeek {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}
.song-player-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.song-player-row button {
  min-width: 96px;
  padding: 9px 18px;
  font-size: 15px;
}
.song-time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 16px;
  color: var(--muted);
}
#libraryList .lib-dur {
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
/* In the program: plain words in the accent, not a badge, so it does not read
   as a verdict on the song the way Good / Fair / Low do. */
#libraryList .lib-used {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
#libraryList canvas {
  width: 100%;
  height: 28px;
  display: block;
}
#libraryList li.loading {
  opacity: 0.55;
}

.badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.good {
  color: var(--good);
  border-color: var(--good);
}
.badge.unknown {
  color: var(--muted);
  border-color: var(--line);
}
/* 5.56:1 on the panel — 10px bold needs at least 4.5:1, and the old #b4770e
   only reached 3.76:1. The dark-mode value below is already well clear. */
.badge.caution {
  color: #8f5e0b;
  border-color: #8f5e0b;
}
.badge.poor {
  color: var(--bad);
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
}
@media (prefers-color-scheme: dark) {
  .badge.caution {
    color: #e0a33c;
    border-color: #e0a33c;
  }
}

/* The list of checks in the replace dialog. A colored rule down the left rather
   than a colored panel: five of these stacked as panels is a traffic light, and
   what matters is which one is not green, not that the dialog is decorated. */
.checks {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checks .check {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0 6px 10px;
  border-left: 3px solid var(--line);
}
.checks .check-head {
  font-size: 13px;
  font-weight: 600;
}
.checks .check .hint {
  font-size: 12px;
}
/* `is-` prefixed, because `.warn` is already a filled red panel elsewhere in
   this app and a bare `.check.warn` inherits all of it — border, background and
   padding — turning the rule into a box. Found in a screenshot, which is the
   only place a cascade collision shows up. */
.checks .check.is-good {
  border-left-color: var(--good);
}
.checks .check.is-note {
  border-left-color: var(--muted);
}
.checks .check.is-warn {
  border-left-color: var(--bad);
}
.checks .check.is-warn .check-head {
  color: var(--bad);
}

.warn {
  border: 1px solid var(--bad);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: color-mix(in srgb, var(--bad) 8%, transparent);
}
.warn-head {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.warn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  word-break: break-word;
}
.missing-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.warn .hint {
  font-size: 12px;
}

.dropzone {
  margin-top: 10px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.dropzone.over {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
/* Music can be dropped anywhere on the page, so while one is over it both
   places that mean something light up: the list it will join, and the timeline,
   which also puts it straight into the program. */
body.dropping .dropzone {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
body.dropping #timelineWrap .timeline,
body.dropping #timelineWrap[data-mode="start"] .empty {
  border-color: var(--accent);
  background: var(--accent-soft);
}
/* And a third place, once there is one file over one song the program plays:
   dropping there puts that file underneath the song instead of adding it
   alongside. Only the row being pointed at lights up — every swappable row
   glowing at once would say the list is the target, which is the meaning the
   dropzone already has. */
#libraryList li.swap-target {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---- timeline ---- */
.transport {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Sits with the transport rather than stranded mid-row, but as its own flex
   item so it can take a second line on a narrow window instead of pushing
   Play and Stop off the edge. */
#btnEvenOut {
  margin-left: auto;
}
.undo-buttons,
.zoom-buttons {
  display: flex;
  gap: 6px;
}
.zoom-buttons button {
  min-width: 2.2em;
}
#timelineWrap {
  position: relative;
}
.timeline {
  display: flex;
  gap: 4px;
  align-items: stretch;
  min-height: 96px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}
.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  /* The panel behind this is a drop target, so the overlay lets everything
     through; the buttons inside take their clicks back. */
  pointer-events: none;
  padding: 12px;
}
/* One grid item, not several. Grid blockifies each run of text, so a bare
   sentence with a <b> in it comes out as three stacked lines — including the
   full stop on a line of its own. */
.empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.empty-lead {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.empty-sub {
  margin: 0;
  max-width: 46ch;
}
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 2px;
  pointer-events: auto;
}
.empty-card .hint {
  margin: 0;
}
/* Whichever state is not current is not there at all, so nothing reads it out
   to a screen reader either. */
#timelineWrap[data-mode="start"] [data-when="pick"],
#timelineWrap:not([data-mode="start"]) [data-when="start"] {
  display: none;
}
/* With nothing added there is no strip to overlay, so the card stands in the
   slot and the wrapper takes its height from it — an absolutely positioned
   overlay contributes none, and the card is taller than an empty strip. */
#timelineWrap[data-mode="start"] .timeline {
  display: none;
}
#timelineWrap[data-mode="start"] .empty {
  position: static;
  padding: 26px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.tl-clip {
  position: relative;
  flex: 1 1 0; /* grow factor is set per clip from its duration */
  min-width: 52px; /* a very short clip stays clickable */
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 6px;
  cursor: grab;
  overflow: hidden;
}
.tl-clip.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.tl-clip.dragging {
  opacity: 0.4;
}
.tl-clip .tl-name {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.tl-clip .tl-dur {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.tl-clip canvas {
  width: 100%;
  height: 44px;
  display: block;
}
.tl-clip.missing {
  border-color: var(--bad);
}
.tl-xf {
  align-self: center;
  flex: 0 0 auto; /* the overlap markers keep their size; clips absorb the rest */
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  writing-mode: vertical-rl;
  padding: 2px;
}
#scrubber {
  width: 100%;
  height: 62px;
  display: block;
  margin-top: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
}
.scrub-help {
  margin: 5px 2px 0;
}

/* ---- clip editor ---- */
.editor {
  margin-top: 16px;
}
.clip-wrap {
  position: relative;
}
.closeup {
  position: absolute;
  top: 8px;
  width: min(360px, 60%);
  height: 64px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  pointer-events: none; /* the drag underneath must keep every event */
}
#clipCanvas {
  width: 100%;
  height: 180px;
  display: block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
}
.scrub-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 6px 2px 14px;
  font-size: 12px;
}
/* Reads as the label it used to be until it is pointed at or typed into. */
.time-entry {
  width: 8ch;
  flex: 0 0 auto;
  font: inherit;
  font-family: var(--mono);
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 4px;
}
.time-entry.end {
  text-align: right;
}
.time-entry:hover {
  border-color: var(--line);
}
.time-entry:focus {
  background: var(--bg);
  border-color: var(--accent);
}
/* Four buttons now, so they take a second line on a narrow window rather than
   running off the side of the panel. */
.editor-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
}
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
.controls label b {
  color: var(--ink);
  font-family: var(--mono);
}
.controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
/* The blend slider and the button that sets it share one cell, so they stay
   together however the grid wraps. min-width: 0 or a long button label widens
   the column and pushes the other controls off. */
.join-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  min-width: 0;
}
.join-cell label {
  width: 100%;
}
.join-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
}

/* ---- help ---- */
/* Help lives behind header buttons rather than on the page. The buttons are
   always visible so the topics are discoverable; the reading is opt-in. */
/* The app bar. Dark in both themes so it reads as chrome — a fixed frame around
   the tool — rather than as another row of controls acting on your work. */
.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 20px;
  min-height: 46px;
  background: var(--topbar-bg);
  color: var(--topbar-ink);
}
.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 20px 0 0;
  color: var(--topbar-ink);
}
/* Logo and title travel together; without this they can be split by the wrap
   that the rest of the bar depends on at narrow widths. */
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}
/* Help, the colors and GitHub, at the far end of the bar. Six help entries
   used to sit here in a row and wrapped onto a second line on a phone, above
   the app; one menu keeps the bar to one line. */
.topbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}
.topbar-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--topbar-dim);
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-link:hover {
  color: var(--topbar-ink);
  background: rgba(255, 255, 255, 0.11);
}
.topbar-link svg {
  display: block;
}
/* The Help button wears the link styling, so it has to shed the button
   defaults first. */
button.topbar-link {
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
/* The colors on the bar's dark background, rather than the panel's. */
.topbar-seg {
  border-color: rgba(255, 255, 255, 0.18);
}
.topbar-seg > button {
  padding: 4px 9px;
  font-size: 12px;
  color: var(--topbar-dim);
}
.topbar-seg > button + button {
  border-left-color: rgba(255, 255, 255, 0.18);
}
.topbar-seg > button:hover:not([aria-checked="true"]) {
  color: var(--topbar-ink);
  background: rgba(255, 255, 255, 0.11);
}
/* The help menu: a list, not a row of buttons. */
.help-nav {
  display: flex;
  flex-direction: column;
}
.help-btn,
.menu-link {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
.help-btn:hover,
.menu-link:hover {
  background: var(--bg);
  border-color: transparent;
}
.help-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---- start dialog ---- */
.start-card {
  width: min(430px, 94vw);
}
.start-card h2 {
  font-size: 16px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
}
.start-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.start-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.start-field input,
.start-field select {
  width: 100%;
}
button.wide {
  width: 100%;
  padding: 9px 14px;
}
/* A rule with the word sitting in the gap, separating the routes. */
.start-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.start-or::before,
.start-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
/* The one thing worth knowing before you hand over your files, and the only
   place in the app that still says it since the topbar note went. Set apart
   from the hint above it, which is housekeeping rather than reassurance. */
.start-privacy {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.start-privacy b {
  color: var(--ink);
}

.help-card {
  width: min(600px, 94vw);
  max-height: 84vh;
  overflow-y: auto;
}
.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.help-head h2 {
  text-transform: none;
  letter-spacing: 0;
  font-size: 16px;
  color: var(--ink);
}
.help-head button {
  flex: 0 0 auto;
}

#helpBody ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.65;
}
#helpBody li {
  margin-bottom: 11px;
}
#helpBody li:last-child {
  margin-bottom: 0;
}
#helpBody .hint {
  margin-top: 14px;
  line-height: 1.6;
}
#helpBody .hint + .hint {
  margin-top: 10px;
}

.badge-key {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px 12px;
  margin: 0;
  align-items: baseline;
  font-size: 13.5px;
}
.badge-key dt {
  justify-self: start;
}
.badge-key dd {
  margin: 0;
}

/* Shortcuts read as keys, not as a paragraph — the shape is what makes them
   scannable, so they stay expanded rather than hiding behind a disclosure. */
kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  padding: 2px 6px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  white-space: nowrap;
}
/* Inline hints sit quietly on the control they belong to, so the shortcut is
   learned at the moment you reach for the mouse. */
button > kbd {
  margin-left: 7px;
  padding: 1px 5px;
  font-size: 10px;
  border-bottom-width: 1px;
  opacity: 0.6;
  background: transparent;
  pointer-events: none;
}
button.primary > kbd {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}
.hint kbd {
  margin: 0 1px;
}
.keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px 14px;
  margin: 0;
  align-items: baseline;
  font-size: 13.5px;
}
.keys dt {
  justify-self: start;
  white-space: nowrap;
}
.keys dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

/* ---- modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  z-index: 20;
}
.modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-card .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
/* A checkbox and its explanation, which is a different shape from the label-
   and-control rows above: the two sit together on the left rather than being
   pushed to opposite edges, and the explanation runs under the label. */
.modal-card .row.check {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  cursor: pointer;
}
.modal-card .row.check input {
  margin-top: 3px;
  flex: 0 0 auto;
}
.modal-card .row.check > span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.modal-card .row.check .hint {
  font-size: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
/* Starting over, taken further: at the far end from Cancel, so it is not the
   button a hurried click finds. */
.start-forget {
  margin-right: auto;
}
.progress {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* Both width transitions above are feedback rather than decoration, but the
   system setting is a request to stop things moving and nothing is lost by
   honoring it — the bars still land where they were going to. */
@media (prefers-reduced-motion: reduce) {
  .budget-fill,
  .progress > div {
    transition: none;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 30;
}

/* ---- notes ---- */

/* Quiet when closed: one line that does not compete with the program above it,
   and no card of its own until there is something in it to read. */
.notes {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
/* Nothing to separate from when it is shut and empty, so no rule either. */
.notes:not([open]) {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 8px;
}
.notes > summary {
  cursor: pointer;
  width: fit-content;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 6px;
}
.notes > summary:hover {
  color: var(--ink);
}
.notes > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.notes[open] > summary {
  color: var(--ink);
  margin-bottom: 8px;
}
#programNotes {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 68px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
}
#programNotes:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.notes .hint {
  margin: 6px 0 0;
}

/* ---- what a file says about itself ---- */

/* Stacked rather than in two columns: the sidebar is narrow, and a composer's
   name beside a label of its own would wrap to one word a line. */
.lib-tags {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.45;
}
.lib-tags dt {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.lib-tags dd {
  margin: 0 0 7px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.lib-tags dd:last-child {
  margin-bottom: 0;
}
/* The file name under a song that has a title of its own. Quiet: it is here to
   identify the file, not to be read first. */
.lib-file {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}
/* The way out to the licensing site, set apart from the facts above it. */
.lib-rights {
  display: inline-block;
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  width: 100%;
  color: var(--accent);
  font-size: 12px;
}

/* Inside a desktop shell the page is the app, so it behaves like one: controls
   show the arrow a desktop app's controls show rather than the web's pointing
   hand, and the interface is not text to be selected and dragged like a
   document's. What is text somebody may want to copy — a field, a song's
   details, a message — stays selectable. In a browser none of this applies. */
:root[data-shell] :is(button, .row.check, .notes > summary) {
  cursor: default;
}
:root[data-shell] body {
  user-select: none;
}
:root[data-shell] :is(input, textarea, select, .lib-tags, .warn, #toast, #helpBody) {
  user-select: text;
}
