/* The palette, from Polish stoneware: cobalt navy (the ink -- text, the
   dark surfaces), royal blue and coral (the accents), forest green (the
   nav bar), on warm cream (the page itself, and text on the dark
   surfaces). Around each, a few close relations for depth, never a
   sixth color: its lift (lighter, warmer, richer -- the cream's a
   peach, toward the coral) and its shade (darker, cooler), for the
   light falling from the top left across the dithered shadows and the
   buttons' and cards' relief (relief/, from scripts/build_relief.py),
   and its dim and muted forms, for what's set back. Worked out in
   OKLCH in static/lab/microhue.html, and fixed here as hex.

   --near-black and --cream are what index.html's keyboard reads (via
   getComputedStyle) for its key colors, so they stay plain hex.
   --near-black-rgb is the same navy as an R,G,B triplet, for
   rgba(var(--near-black-rgb), <alpha>). */
:root {
  --navy: #15203c;
  --royal: #294d8e;
  --coral: #d35836;
  --forest: #27442a;
  --cream: #e1ddcf;
  --cream-dark: #d4c6c0;
  /* Each color's lift and shade, and the same three quarters of the way
     from the color (-m), for the relief's gentler gradients. The cream,
     nearly colorless, shades warm instead of cool: a little darker,
     richer, and toward orange -- sand, where turning it cool and dark
     would gray it. */
  --navy-lift: #342555;
  --navy-shade: #00152a;
  --navy-lift-m: #312553;
  --navy-shade-m: #00162c;
  /* The cards' navy, and its lift and shade: the navy's own, a step
     lighter (OKLCH, L + 0.1), so a page of them doesn't glare off the
     cream. */
  --card: #2d3958;
  --card-lift: #4e4072;
  --card-shade: #152e44;
  --card-lift-m: #4b3f70;
  --card-shade-m: #152f47;
  --royal-lift: #6346b9;
  --royal-shade: #004475;
  --royal-lift-m: #5e47b5;
  --royal-shade-m: #004578;
  --cream-lift: #ffddc9;
  --cream-shade: #e3d3bb;
  --cream-lift-m: #ffdeca;
  --cream-shade-m: #e3d5be;
  --forest-lift: #485213;
  --forest-shade: #053627;
  --forest-lift-m: #455017;
  --forest-shade-m: #093727;
  /* The nav's green, a dark gray teal at the window's edges (--nav-lift:
     a little darker than retro's navy-button lift, at a hue a quarter of
     the way from it to the green's, grayed): fading over --edge-fade into the green, half of
     it out past the flower at the left and the setup button at the
     right, and half of it in over them; and between them, the green
     rising gradually to a lighter, warmer glow in the middle. In retro,
     in 1px dots (relief/edge-<side>.svg and relief/glow.svg, from
     scripts/build_relief.py, its EDGE_FADE). Where each fade starts is
     measured across the green's layers (as wide as the window, centered
     on it) from their middle, by the nav's column: its padding, or its
     padding and the gutter, less half the fade; the glow spans the
     column inside its padding. */
  --nav-lift: #253f3b;
  --forest-glow: #334d2b;
  --edge-fade: 256px;
  --nav-column: min(100vw, calc(var(--page-width) + 2 * var(--page-padding-x)));
  --edge-left: calc(50% - var(--nav-column) / 2 + var(--page-padding-x) - var(--edge-fade) / 2);
  --edge-right: calc(50% + var(--nav-column) / 2 - var(--page-padding-x) - var(--stream-gutter) + var(--edge-fade) / 2);
  --edge-left-image: url("relief/edge-left.svg");
  --edge-right-image: url("relief/edge-right.svg");
  --glow-image: url("relief/glow.svg");
  --glow-width: calc(var(--nav-column) - 2 * var(--page-padding-x));
  --coral-lift: #f56500;
  --coral-shade: #be3e52;
  --coral-lift-m: #f26400;
  --coral-shade-m: #c04150;
  /* Set back: the navy, lightened and grayed (folded groups' and hints'
     ink), and the cream, dimmed and grayed (their dither). */
  --navy-muted: #687186;
  --cream-dim: #d0cdc5;
  /* The checkerboards' dot: 2px, or as near as a whole number of the
     display's own pixels comes to it (index.html's snapDither sets it),
     so at any zoom or display scale every dot, and every repeat of the
     checkerboard, is drawn the same and the pattern runs on seamlessly. */
  --dither-cell: 2px;
  /* A quiet fill on the page: the dimmed cream, every other dot. */
  --quiet-dither: conic-gradient(var(--cream-dim) 25%, transparent 0 50%, var(--cream-dim) 0 75%, transparent 0) 0 0 / calc(2 * var(--dither-cell)) calc(2 * var(--dither-cell));
  /* The relief, baked per color (scripts/build_relief.py). */
  --relief-navy: url("relief/navy.svg");
  --relief-card: url("relief/card.svg");
  --relief-royal: url("relief/royal.svg");
  --relief-cream: url("relief/cream.svg");
  --relief-forest: url("relief/forest.svg");
  --relief-coral: url("relief/coral.svg");
  /* The colors' roles, where one color plays two: the page (and the
     panels set on it) and its ink, royal as ink on it, the setup
     panel's ink, and the sand that sets things back. Today each is the
     palette color itself; the dark look (under Themes, below) pulls them apart
     from the surfaces and their ink, which keep the palette's names. */
  --page: var(--cream);
  --ink: var(--navy);
  --accent-ink: var(--royal);
  --panel-ink: var(--forest);
  /* Text in the cream, on the dark surfaces and, in dark, the page. */
  --cream-ink: var(--cream);
  /* What's set back: the cream's sand (--cream-shade), a step deeper
     (OKLCH L - 0.04) to stand off the page. */
  --sand-light: #d7c6ac;
  --sand: var(--sand-light);
  /* The sand's own dark color, for the shadows of things on it. */
  --sand-shade: #bfac90;
  --near-black: #15203c;
  --near-black-rgb: 21, 32, 60;
  /* Cream in light, for a field set into the page (the search box). */
  --cream-light: color-mix(in srgb, var(--cream), #fff 45%);
  /* A halftone: royal dots on the cream, two to every 4px square, as
     the teapot's own shading is -- a tinted fill (the search results').
     Text of less importance is set in royal on the page, or the muted
     ink where it's set back, and smaller or lighter in cream on the dark
     surfaces. */
  --halftone:
    conic-gradient(at 1px 1px, transparent 75%, var(--royal) 0) 0 0 / 4px 4px,
    conic-gradient(at 1px 1px, transparent 75%, var(--royal) 0) 2px 2px / 4px 4px;
  /* The ring that stands things off whatever they're over: in cream,
     the MIDI tip's. */
  --cream-ring: 2.25px;
  /* The edge-to-edge layers (the nav's green, the search area's cream
     and green): a little wider than the window, so rounding at a
     browser's zoom or display scale never leaves a hairline of page at
     either edge. The page clips what runs past (html, below). */
  --full-bleed: calc(100vw + 1rem);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Space Grotesk", system-ui, sans-serif;
  /* The column everything lines up in: the nav, the lists, the player. */
  --page-width: 68rem;
  --page-padding-x: 2rem;
  --nav-height: 5.5rem;
  /* On a page with a search bar the nav's own box is shorter, ending
     where the bar's band of green begins; its row sits at the same
     height either way. */
  --nav-height-searching: calc(var(--nav-height) - 15px);
  --nav-gap: 1.25rem;
  /* Reserved right of every stream card for .stream-item.selected's
     note -- the dock reserves it too, keeping the fingerprint aligned
     with the cards rather than with their gutter. */
  --stream-gutter: 28px;
  /* #now-playing-dock's fixed height -- tall enough for its tallest
     state (the transport over an 88px strip) so switching sections or
     streams never resizes it. The page's bottom padding clears it. */
  --dock-height: 10.5rem;
  /* What's already been heard, in the dock's strip and the playing
     card's thumbnail (#progress-played, .card-played): fully grayscale,
     so the part still to come is the only color. */
  --played-filter: saturate(0);
  /* Outlines the position lines and markers over the fingerprints, whose
     background runs from dark to near-white along their length: a crisp
     dark edge either side plus a soft glow, so the cream reads over
     bright notes as well as dark gaps. A filter, not a box-shadow, so it
     follows each dash's own shape. */
  --line-halo:
    drop-shadow(1px 0 0 rgba(0, 0, 0, 0.55))
    drop-shadow(-1px 0 0 rgba(0, 0, 0, 0.55))
    drop-shadow(0 0 2.5px rgba(0, 0, 0, 0.8));
}

/* Clip, not hidden, so the sticky nav and search area still stick. No
   rubber-band bounce at the page's ends, which would drag the sticky nav
   along with the content. */
html {
  overflow-x: clip;
  overscroll-behavior-y: none;
}
/* Pages without the app shell (e.g. admin_piece_types.html) are a plain
   centered column. */
body {
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--page);
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1rem;
}
button, input, select, textarea { font-family: inherit; }
/* Some browsers draw an open <select>'s popup through a native path that
   doesn't resolve `inherit`; naming the stack sidesteps it. */
option { font-family: var(--font); }

/* The player page (index.html): the top nav, then one section's content
   below it -- and on Perform, the player fixed across the bottom, which
   the page clears. */
body.app-shell {
  max-width: none;
  margin: 0;
  padding: 0 0 3rem;
}
body.app-shell.mode-perform { padding-bottom: calc(var(--dock-height) + 2rem); }
body.app-shell.mode-welcome { padding-bottom: 0; }

/* --- Top nav ---------------------------------------------------------- */

#top-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--nav-height);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: var(--nav-gap);
  max-width: calc(var(--page-width) + 2 * var(--page-padding-x));
  margin: 0 auto;
  /* The lists and the player stop short of the column's right edge, by
     the gutter their playhead marker sits in; the nav ends where they do. */
  /* A little more below than above: the row sits a touch high, the
     search bar (on pages with one) carrying the green on down. */
  padding: 0 calc(var(--page-padding-x) + var(--stream-gutter)) 8px var(--page-padding-x);
  background: var(--forest);
}
/* One solid green bar, edge to edge, though its contents keep to the
   page's column. Its buttons are the same green, so they read as plain
   cream text on the bar until hovered (see below). Over the search
   area, it runs a little past the nav's bottom edge onto the area's
   green: at a fractional display scale that edge falls mid-pixel, and
   the two layers' half-covered pixels would leave a light seam. */
#top-nav { --nav-overlap: 0px; }
#top-nav::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  left: 50%;
  width: var(--full-bleed);
  height: calc(100% + var(--nav-overlap));
  transform: translateX(-50%);
  /* Like the search bar's green (#search-box::before), as wide as the
     window and centered on it, so their edges meet seamlessly. */
}
/* The green's layers, the nav's and the search bar's: each side's navy
   sized to reach from the window's edge to the end of its fade. Retro's
   dots are drawn --edge-y down, --edge-height tall, so the search bar's
   keep in step with the nav's. */
#top-nav::after, #search-box::before {
  background:
    var(--edge-left-image) 0 var(--edge-y, 0px) / calc(var(--edge-left) + var(--edge-fade)) var(--edge-height, 100%) no-repeat,
    var(--edge-right-image) 100% var(--edge-y, 0px) / calc(100% - var(--edge-right) + var(--edge-fade)) var(--edge-height, 100%) no-repeat,
    var(--glow-image) 50% var(--edge-y, 0px) / var(--glow-width) var(--edge-height, 100%) no-repeat,
    var(--forest);
}
/* A chamomile flower in dots, its colors the theme's, on the bar. */
/* Over everything around it: nothing in the nav, or under it
   (#search-area, a lower layer than the nav), may cover it. */
#logo-link { position: relative; z-index: 60; display: block; flex: none; line-height: 0; }
/* Small enough to clear the search bar under it, on the pages with one.
   Its alt text is for screen readers only, never drawn in its place
   while the image loads. */
.logo { width: 60px; height: 60px; color: transparent; }
#logo-link { color: transparent; text-decoration: none; }
/* Three stacked images: retro rests on the coarse pixels, flat on the
   photograph, and hovering crossfades in two quick steps through the
   fine pixels to the other end -- coarse, fine, photo in retro; photo,
   fine, coarse in flat -- and back the same way. The fine pixels show
   only in between: they fade in by opacity and out by filter, two
   properties so each step can have its own delay. Each state's rule
   holds the delays for transitions into it, so the step order reverses
   when the pointer leaves. */
#logo-link { --logo-step: 90ms; }
#logo-link .logo + .logo { position: absolute; inset: 0; }
#logo-link .logo { transition: opacity var(--logo-step) ease-out; }
#logo-link .logo-fine {
  opacity: 0;
  filter: opacity(1);
  transition: opacity var(--logo-step) ease-out var(--logo-step), filter var(--logo-step) ease-out;
}
#logo-link:hover .logo-fine {
  opacity: 1;
  filter: opacity(0);
  transition: opacity var(--logo-step) ease-out, filter var(--logo-step) ease-out var(--logo-step);
}
/* The resting image fades in on the second step back; the hovered end
   fades in on the second step there. */
:root:not([data-look~="flat"]) #logo-link .logo-coarse,
:root[data-look~="flat"] #logo-link .logo-photo { opacity: 1; transition-delay: var(--logo-step); }
:root:not([data-look~="flat"]) #logo-link .logo-photo,
:root[data-look~="flat"] #logo-link .logo-coarse { opacity: 0; transition-delay: 0s; }
:root:not([data-look~="flat"]) #logo-link:hover .logo-coarse,
:root[data-look~="flat"] #logo-link:hover .logo-photo { opacity: 0; transition-delay: 0s; }
:root:not([data-look~="flat"]) #logo-link:hover .logo-photo,
:root[data-look~="flat"] #logo-link:hover .logo-coarse { opacity: 1; transition-delay: var(--logo-step); }
@media (prefers-reduced-motion: reduce) {
  #logo-link .logo, #logo-link:hover .logo { transition: none; }
}
/* Over the search bar's row (counting it gone from the moment it starts
   closing -- see showSearchArea), the bar sits shorter and a touch
   lower. Its height eases between that, its own, and its grown height
   under the open setup panel, as quickly as the panel and the search
   bar open and close. */
#top-nav { transition: height 220ms ease, padding 220ms ease; }
@media (prefers-reduced-motion: reduce) {
  #top-nav { transition: none; }
}
body:has(#search-area:not([hidden], [data-leaving])) #top-nav {
  --nav-overlap: 2px;
  height: var(--nav-height-searching);
  padding-top: 7px;
  padding-bottom: 0;
}
/* The sections' row scrolls sideways rather than wrapping, its
   scrollbar hidden behind the arrows (updateNavScroll); padded out above
   and below, and pulled back by as much, so the scroll's clip leaves
   room for a focused section's outline. Not at the ends: there the clip
   is the arrows' outer edges. */
#nav-scroller { position: relative; flex: 1; min-width: 0; display: flex; }
#top-nav nav {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 0;
  margin: -8px 0;
}
#top-nav nav::-webkit-scrollbar { display: none; }
/* Under the arrows (while each shows), the row fades out into the bar:
   masked, not painted over, so the bar's own fades show through. */
#top-nav nav {
  --fade-start: 0px;
  --fade-end: 0px;
  mask-image: linear-gradient(to right,
    transparent calc(var(--fade-start) * 0.55), #000 var(--fade-start),
    #000 calc(100% - var(--fade-end)), transparent calc(100% - var(--fade-end) * 0.55));
}
#nav-scroller:has(> .nav-scroll[data-dir="-1"]:not([hidden])) nav { --fade-start: 2.25rem; }
#nav-scroller:has(> .nav-scroll[data-dir="1"]:not([hidden])) nav { --fade-end: 2.25rem; }
/* Over the row's ends. */
.nav-scroll {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: 2.25rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--cream-ink);
  font: inherit;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}
.nav-scroll[data-dir="-1"] { left: 0; text-align: left; }
.nav-scroll[data-dir="1"] { right: 0; text-align: right; }
.nav-scroll[hidden] { display: none; }
/* The scroll chevrons have no body: hovered, their shadow is the L that
   would show past one, in the nav's sand. */
.nav-scroll span {
  display: inline-grid;
  place-items: center;
  width: 0.8em;
  height: 1.1em;
  border-radius: 3px;
  transition: box-shadow 120ms ease;
}
.nav-scroll:hover span { box-shadow: 2px 2px 0 var(--cream-shade); }
/* Every button on the site: one color,
   cream on royal blue, and nothing else -- no change of hue on hover, for
   the current section, or for a call to action. Those are marked instead
   by its depth: the button stands out from the page over a plain shadow
   dropped below and to the right -- on hover, and kept for as long as the
   button is the current
   one (the nav's section, the open menu) or the thing to press next
   (enabling MIDI, in the menu). The hero's own Enable is the one
   exception to the single color: coral, the page's call to action.

   Light falls from the top left. The button's body is warm plastic in
   it -- its color's relief (--button-relief), in dots: a soft highlight
   up at its top left, falling through the color to its shade at the far
   corner, under a lit hairline of the color's lift along its top and a
   darker 2px lip of its shade along its bottom (--button-lift,
   --button-shade) -- and its shadow is its own dark color (--shadow), a
   quarter of its --drop deep.

   The button paints nothing itself. Its fill (--button-fill, royal but
   for the nav's own green), and the shadow with it, is its ::after,
   under its text, and isolation keeps them in
   the button's own stacking context -- above whatever it sits on, cream
   page or navy panel. :where() keeps these rules at no specificity, so
   any rule for one button or one state overrides them. */
:root {
  --shadow: var(--royal-shade);
  --button-fill: var(--royal);
  --button-relief: var(--relief-royal);
  --button-lift: var(--royal-lift);
  --button-shade: var(--royal-shade);
  --drop: 12px;
}
/* The nav's buttons have no body at all -- they're words on the bar --
   so one never covers a neighbour's shadow. Their shadow hugs the word,
   inset from the button's generous click area, drops a shorter way, in
   the nav's sand. */
#top-nav {
  --button-fill: transparent;
  --button-relief: none;
  --button-lift: transparent;
  --button-shade: transparent;
  --shadow: var(--cream-shade);
  --drop: 8px;
}
#top-nav :is(.nav-item, #setup-toggle, #nav-play-pause)::after {
  inset: 0.45rem 0.3rem;
  border-radius: 3px;
}
/* Pressed, and while it's the current section (or the open menu's
   toggle), a nav button turns over: a cream body around the word, in
   green, over its whole shadow. */
#top-nav :is(.nav-item.active, #setup-toggle[aria-expanded="true"], .nav-item:active, #setup-toggle:active, #nav-play-pause:active) {
  --button-fill: var(--cream);
  --button-relief: var(--relief-cream);
  --button-lift: var(--cream-lift);
  --button-shade: var(--cream-shade);
  color: var(--forest);
}
:where(.nav-item, #setup-toggle, #nav-play-pause, .btn, .midi-trigger, #live-state-controls button, #stream-list button[hx-get]) {
  position: relative;
  isolation: isolate;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--cream-ink);
  cursor: pointer;
}
:where(.nav-item, #setup-toggle, #nav-play-pause, .btn, .midi-trigger, #live-state-controls button, #stream-list button[hx-get])::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
/* The fill: the color, under its relief, drawn to the button's size,
   and its shadow while it stands out. */
:where(.nav-item, #setup-toggle, #nav-play-pause, .btn, .midi-trigger, #live-state-controls button, #stream-list button[hx-get])::after {
  z-index: -1;
  background: var(--button-relief) 0 0 / 100% 100% no-repeat, var(--button-fill);
  box-shadow:
    inset 0 1px 0 color-mix(in oklab, var(--button-lift) 70%, transparent),
    inset 0 -2px 0 color-mix(in oklab, var(--button-shade) 60%, transparent),
    var(--drop-shadow, 0 0 transparent);
  transition: box-shadow 120ms ease;
}
:where(.nav-item, #setup-toggle, #nav-play-pause, .btn, .midi-trigger, #live-state-controls button, #stream-list button[hx-get]):not(:disabled):hover,
:where(#top-nav .nav-item.active, #setup-toggle[aria-expanded="true"], #top-nav :is(.nav-item, #setup-toggle, #nav-play-pause):active) {
  --drop-shadow: calc(var(--drop) / 4) calc(var(--drop) / 4) 0 var(--shadow);
}
.nav-item {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.nav-item:focus-visible,
#setup-toggle:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

/* What's playing: the link to Now Playing, its note swelling and
   settling while there's music, and a pause/play beside it. */
#nav-now-playing { display: flex; align-items: center; gap: 0.25rem; }
#nav-now-playing[hidden] { display: none; }
#now-playing-link { gap: 0.5rem; }
.nav-note { display: inline-block; font-size: 1rem; line-height: 1; letter-spacing: 0; }
#nav-now-playing.playing .nav-note { animation: nav-note-pulse 1s ease-in-out infinite; }
@keyframes nav-note-pulse {
  50% { transform: scale(1.35); }
}
@media (prefers-reduced-motion: reduce) {
  #nav-now-playing.playing .nav-note { animation: none; }
}
#nav-play-pause {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

/* --- Setup menu ------------------------------------------------------- */

/* Opened, the hamburger turns the bar over: a cream panel growing out
   to its left, as tall as the hamburger, so the bar never grows and
   nothing under it moves; it shoves the sections along. In it, two
   tabs stacked on its right edge beside the hamburger, MIDI I/O and
   Themes, the one showing joined to a well of its controls to their
   left (showSetupTab): the MIDI setup's three triggers, or the look's
   two. All of it runs right to left, out from the hamburger: the tabs
   first, then each control in the markup's order, Enable nearest. Each control cycles through its
   choices on a click, and says so with a caret, its next choice popping
   down into place (setTriggerLabel). The controls keep fixed sizes, so
   the panel's width is known ahead (--setup-panel-width) and doesn't
   jump as their labels change. The menu stays laid out while closed,
   clipped away to its right edge, so it can grow out of it. */
:root {
  /* Each just its longest label, its caret, and its padding: "Enabled",
     and "→ Out: Port 0". */
  --midi-mode-width: 5.6rem;
  --midi-port-width: 7.9rem;
  --setup-tabs-width: 4.9rem;
  --setup-pad: 4px;
  --setup-col-gap: 0.3rem;
  --setup-panel-width: calc(2 * var(--setup-pad) + var(--setup-tabs-width) + var(--midi-mode-width) + 2 * var(--midi-port-width) + 4 * var(--setup-col-gap) + 0.4rem + 3rem + 8px);
  --midi-trigger-height: 1.9rem;
  /* The tabs' well: the bar's own green, the panel turned back over. */
  --setup-well: var(--forest);
}
#setup {
  position: relative;
  flex: none;
  display: flex;
  justify-content: flex-end;
  width: 3rem;
  transition: width 220ms ease;
}
#setup:has(#setup-menu:not([hidden])) {
  width: var(--setup-panel-width);
  --button-fill: var(--forest);
  --button-relief: var(--relief-forest);
  --button-lift: var(--forest-lift);
  --button-shade: var(--forest-shade);
  --shadow: var(--forest-shade);
}
/* Styled with the nav's buttons, above; standing out while its menu is open,
   like the current section, in the panel's green. Over the panel. */
#setup-toggle {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  transition: margin-right 220ms ease;
}
/* Open, on the panel's cream, it turns all the way over from the nav's
   cream-on-green: a green body, in the green's relief, its lines in
   cream -- and steps in from the panel's edge, giving its shadow room. */
#top-nav #setup-toggle[aria-expanded="true"] {
  margin-right: 8px;
  --button-fill: var(--forest);
  --button-relief: var(--relief-forest);
  --button-lift: var(--forest-lift);
  --button-shade: var(--forest-shade);
  color: var(--cream-ink);
}
#setup-menu {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--setup-panel-width);
  border-radius: var(--radius);
  background: var(--cream);
  color: var(--panel-ink);
  clip-path: inset(0 0 0 0 round var(--radius));
  transition: clip-path 220ms ease, visibility 220ms;
}
#setup-menu[hidden] {
  display: block;
  visibility: hidden;
  clip-path: inset(0 0 0 100% round var(--radius));
}
/* The hamburger's room, the tabs, and the well, over the panel. */
#midi-panel {
  display: flex;
  flex-direction: row-reverse;
  height: 3rem;
  box-sizing: border-box;
  padding: var(--setup-pad);
  padding-right: calc(var(--setup-pad) + 0.4rem + 3rem + 8px);
  white-space: nowrap;
}
#setup-tabs { flex: none; width: var(--setup-tabs-width); display: flex; flex-direction: column; }
/* Small words, rounded on the right only: the one showing in the well's
   green, its word in cream, running on into it; the other set back on
   the panel, a hint of the green under it on hover. */
.setup-tab {
  flex: 1;
  border: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent;
  padding: 0 0.45rem;
  color: var(--panel-ink);
  font: inherit;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.6;
  cursor: pointer;
  transition: background-color 120ms ease, opacity 120ms ease;
}
.setup-tab:hover { opacity: 0.85; background: color-mix(in oklab, var(--setup-well) 15%, transparent); }
.setup-tab[aria-selected="true"] { opacity: 1; background: var(--setup-well); color: var(--cream-ink); cursor: default; }
.setup-tab:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
/* The well squares off the corner its tab runs into. On its green the
   controls are the nav's buttons turned over, as the current section
   is: cream bodies, their words in green, their shadows the sand as on
   the bar, but half as deep, to stay in the well. */
#setup-well {
  --button-fill: var(--cream);
  --button-relief: var(--relief-cream);
  --button-lift: var(--cream-lift);
  --button-shade: var(--cream-shade);
  --shadow: var(--cream-shade);
  --drop: 4px;
  color: var(--cream-ink);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: var(--setup-col-gap);
  padding: 0 var(--setup-col-gap);
  border-radius: var(--radius-sm);
  background: var(--setup-well);
}
#midi-panel[data-tab="midi"] #setup-well { border-top-right-radius: 0; }
#midi-panel[data-tab="themes"] #setup-well { border-bottom-right-radius: 0; }
/* Showing Themes, its choices take the MIDI triggers' place. */
#midi-panel[data-tab="themes"] #setup-well > :is(.midi-trigger, #midi-status-icon),
#midi-panel:not([data-tab="themes"]) #theme-choices { display: none; }
#theme-choices { display: flex; flex-direction: row-reverse; gap: var(--setup-col-gap); }
#setup-well .midi-trigger { color: var(--forest); flex: none; width: var(--midi-port-width); height: var(--midi-trigger-height); padding-block: 0; font-size: 0.85rem; }
#setup-well #midi-mode-trigger { width: var(--midi-mode-width); }
#theme-choices .midi-trigger { width: 6rem; }
#midi-status-icon { cursor: help; font-size: 1rem; }
.midi-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.65rem 0.6rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
.midi-trigger.inactive { opacity: 0.45; }
/* Its label, clipped to its own line (setTriggerLabel), so a choice
   arriving drops in from above it and the one leaving falls out below;
   then its caret, the hint there's another. */
.trigger-label {
  flex: 1;
  min-width: 0;
  display: grid;
  overflow: hidden;
}
.trigger-word {
  grid-area: 1 / 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trigger-word.arriving { animation: trigger-arrive 260ms cubic-bezier(0.3, 1.35, 0.5, 1); }
.trigger-word.leaving { animation: trigger-leave 180ms ease-in forwards; }
@keyframes trigger-arrive { from { transform: translateY(-110%); } }
@keyframes trigger-leave { to { transform: translateY(110%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .trigger-word:is(.arriving, .leaving) { animation: none; }
}
.trigger-caret { flex: none; width: 0.6rem; height: 0.6rem; margin-left: 0.4rem; opacity: 0.75; }
/* The real port lists, never shown -- the triggers cycle through them. */
.port-list.disabled { pointer-events: none; }

/* Royal blue tips hanging under the hamburger, pointing up at it: the
   enable-MIDI nudge, and in Perform the pointer to choosing an input
   (see updateMidiHints). */
.theme-tooltip {
  position: absolute;
  top: calc(100% + 0.9rem);
  right: 0;
  z-index: 50;
  width: 15rem;
  padding: 1rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--royal);
  color: var(--cream-ink);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
  pointer-events: none;
  /* A cream ring, standing it off whatever it's over. */
  box-shadow: 0 0 0 var(--cream-ring) var(--cream);
}
.theme-tooltip::before,
.theme-tooltip::after {
  content: "";
  position: absolute;
  bottom: 100%;
  right: 1rem;
  border: 0.5rem solid transparent;
  border-bottom-color: var(--royal);  // the arrow behind the tooltip
}
/* The pointer's ring: the same triangle grown the ring's width out from
   each side (times sqrt 2 along the 45-degree ones). */
.theme-tooltip::before {
  right: calc(1rem - var(--cream-ring) * 1.414);
  border-width: calc(0.5rem + var(--cream-ring) * 1.414);
  border-bottom-color: var(--cream);
}
/* The open menu covers the spot. */
#setup:has(#setup-menu:not([hidden])) .theme-tooltip { display: none; }

/* --- Themes ---------------------------------------------------------- */

/* Two knobs (Setup -> Themes, toggleLook), each a word in <html>'s
   data-look: "flat" or not (retro), and "dark" or not (light) -- four
   looks in all. Light retro is everything above. */

/* Retro: the relief's steps bolder than flat's gradients -- each
   color's lift and shade twice as far off it (the lab's --mh-dl 0.13
   against flat's 0.06) and its lift a little richer (--mh-sat 1.6). */
:root:not([data-look~="flat"]) {
  --navy-lift: #46376c;
  --navy-shade: #000519;
  --navy-lift-m: #413567;
  --navy-shade-m: #00081c;
  --royal-lift: #7759d6;
  --royal-shade: #003160;
  --royal-lift-m: #7058cf;
  --royal-shade-m: #003365;
  --cream-lift: #ffe2cc;
  --cream-lift-m: #ffe2cd;
  --forest-lift: #5b6624;
  --forest-shade: #002416;
  --forest-lift-m: #566225;
  --forest-shade-m: #002718;
  --coral-lift: #ff7800;
  --coral-shade: #a6263f;
  --coral-lift-m: #ff7500;
  --coral-shade-m: #ab2c3f;
  --card-lift: #61538a;
  --card-shade: #0d1b32;
  --card-lift-m: #5c5085;
  --card-shade-m: #0f1f35;
}

/* Dark: the cream's page goes dark -- the cream's own warm hue, nearly
   black -- and the cream turns to ink on it; the sand that sets things
   back is a step up from the page, and the search suggestions' field
   half a step. The royal and the green keep under a third of their
   chroma (OKLCH, C x 0.3) at their own lightness and hue; the navy,
   still the cards' surface, is drained and lifted a step off the page
   so a card still stands up from it, its lift and shade worked out from
   there as the lab does (static/lab/microhue.html); the coral keeps
   three quarters of its chroma, still the thing to press. Royal as ink,
   the gray, and the dimmed cream of the quiet dots are pitched to the
   dark. The cream itself -- the nav's current section, the search box,
   the open setup panel (still the bar turned over, green on cream) --
   steps down to the dark cream, its peach and sand
   carried along with it (the same steps in OKLCH from the light cream's). Retro's relief and
   edges are baked from these colors too, into relief/dark/
   (scripts/build_relief.py); flat, below, paints over them. */
:root[data-look~="dark"] {
  color-scheme: dark;
  --page: #1a1814;
  /* Text keeps the light palette's cream, a step brighter than the
     dark cream that surfaces take. */
  --cream-ink: #e1ddcf;
  --ink: var(--cream-ink);
  --accent-ink: #9cb2d8;
  --sand: #2e2b25;
  --sand-shade: #0d0b08;
  --cream-light: #26241f;
  --navy-muted: #858991;
  --cream-dim: #3a362f;
  --cream: var(--cream-dark);
  --cream-lift: #ebc6ce;
  --cream-shade: #d7bab5;
  --cream-lift-m: #ebc7ce;
  --cream-shade-m: #d7bcb7;
  --navy: #242b3b;
  --navy-lift: #3c3650;
  --navy-shade: #101e2a;
  --navy-lift-m: #3a354e;
  --navy-shade-m: #12202c;
  /* The cards' navy, as in light: the dark navy a step lighter (OKLCH,
     L + 0.1), standing them up off the page. */
  --card: #3d4556;
  --card-lift: #57516c;
  --card-shade: #283744;
  --card-lift-m: #55506a;
  --card-shade-m: #2a3946;
  --royal: #455063;
  --forest: #363f37;
  --nav-lift: #374846;
  --forest-glow: #40473e;
  --royal-lift: #605b7c;
  --royal-shade: #354352;
  --royal-lift-m: #5d5a7a;
  --royal-shade-m: #364553;
  --forest-lift: #4b4e3e;
  --forest-shade: #25302b;
  --forest-lift-m: #484c3d;
  --forest-shade-m: #26312c;
  --coral: #c2674e;
  --coral-lift: #e07745;
  --coral-shade: #ae505a;
  --coral-lift-m: #de7544;
  --coral-shade-m: #b05359;
  --relief-navy: url("relief/dark/navy.svg");
  --relief-card: url("relief/dark/card.svg");
  --relief-royal: url("relief/dark/royal.svg");
  --relief-cream: url("relief/dark/cream.svg");
  --relief-forest: url("relief/dark/forest.svg");
  --relief-coral: url("relief/dark/coral.svg");
  --edge-left-image: url("relief/dark/edge-left.svg");
  --edge-right-image: url("relief/dark/edge-right.svg");
  --glow-image: url("relief/dark/glow.svg");
}
/* Dark retro: the same bolder steps, worked out from the dark colors
   as the dark block's own are. */
:root[data-look~="dark"]:not([data-look~="flat"]) {
  --navy-lift: #4f4865;
  --navy-shade: #030e19;
  --navy-lift-m: #4a4560;
  --navy-shade-m: #05111c;
  --royal-lift: #746f93;
  --royal-shade: #273240;
  --royal-lift-m: #6f6c8e;
  --royal-shade-m: #293443;
  --forest-lift: #5e6250;
  --forest-shade: #171f1b;
  --forest-lift-m: #595e4d;
  --forest-shade-m: #19221d;
  --coral-lift: #eb874b;
  --coral-shade: #973c47;
  --coral-lift-m: #eb854a;
  --coral-shade-m: #9b4048;
  --cream-lift: #edcace;
  --cream-lift-m: #edcacf;
  --card-lift: #6b6482;
  --card-shade: #172531;
  --card-lift-m: #66617d;
  --card-shade-m: #1b2935;
}

/* Retro is the buttons' and cards' relief in dots. Flat has no dots but
   the hero teapot's. Its fills are the micro-hue
   lab's G4, warm plastic: a soft warm highlight up at the top left,
   falling through the color to its shade at the far corner, under a lit
   hairline along the top and a darker 2px lip along the bottom; the
   nav's navy edges fade smoothly into its green. What's set back sits on
   sand (--sand), or on nothing at all in the gray ink. */
:root[data-look~="flat"] {
  --relief-navy: radial-gradient(120% 100% at 15% 0%, var(--navy-lift-m), var(--navy) 55%, var(--navy-shade-m));
  --relief-card: radial-gradient(120% 100% at 15% 0%, var(--card-lift-m), var(--card) 55%, var(--card-shade-m));
  --relief-royal: radial-gradient(120% 100% at 15% 0%, var(--royal-lift-m), var(--royal) 55%, var(--royal-shade-m));
  --relief-cream: radial-gradient(120% 100% at 15% 0%, var(--cream-lift-m), var(--cream) 55%, var(--cream-shade-m));
  --relief-forest: radial-gradient(120% 100% at 15% 0%, var(--forest-lift-m), var(--forest) 55%, var(--forest-shade-m));
  --relief-coral: radial-gradient(120% 100% at 15% 0%, var(--coral-lift-m), var(--coral) 55%, var(--coral-shade-m));
}
:root[data-look~="flat"] #top-nav::after, :root[data-look~="flat"] #search-box::before {
  background: linear-gradient(in oklab to right,
    var(--nav-lift) var(--edge-left),
    var(--forest) calc(var(--edge-left) + var(--edge-fade)),
    var(--forest-glow) 50%,
    var(--forest) calc(var(--edge-right) - var(--edge-fade)),
    var(--nav-lift) var(--edge-right));
}
/* The field and view chips: sand. */
:root[data-look~="flat"] :is(:is(#search-tips, #list-controls, #history-filter) button, .account-form-page .text-chip)::after { background: var(--sand); }
/* A folded group's name: just the gray ink. Search results: sand. */
:root[data-look~="flat"] .group > h2 button[aria-expanded="false"] > span:not(.group-count) { background: none; }
:root[data-look~="flat"] .search-result { background: var(--sand); }

/* --- Hero page -------------------------------------------------------- */

/* Fills the window under the nav: the full teapot faded into the page
   behind, the copy and the call to action over it. */
#hero {
  position: relative;
  min-height: calc(100dvh - var(--nav-height));
  box-sizing: border-box;
  display: grid;
  align-items: center;
  max-width: calc(var(--page-width) + 2 * var(--page-padding-x));
  margin: 0 auto;
  padding: clamp(1rem, 4dvh, 2rem) var(--page-padding-x);
  overflow: hidden;
}
#hero[hidden] { display: none; }
#hero-art {
  position: absolute;
  top: 50%;
  right: -8%;
  width: min(68rem, 92%);
  height: auto;
  /* Mirrored, spout to the left: pushed off to the right, it faces
     into the page. */
  transform: translateY(-50%) scaleX(-1);
  opacity: 0.2;
  pointer-events: none;
  user-select: none;
}
#hero-copy { position: relative; max-width: 42rem; }
#hero-kicker {
  margin: 0 0 1rem;
  color: var(--coral);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
#hero h1 {
  margin: 0;
  font-size: clamp(2.75rem, min(6.5vw, 10dvh), 5.25rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
#hero-lede {
  margin: 1.75rem 0 0;
  max-width: 34rem;
  font-size: 1.35rem;
  line-height: 1.5;
}
#hero-midi-status {
  margin: clamp(1.25rem, 3.5dvh, 2.5rem) 0 1rem;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--accent-ink);
}
#hero-midi-status a { color: inherit; text-underline-offset: 0.2em; }
/* The copy reads clear of the teapot behind on a wide, soft glow of
   cream: an ellipse reaching far past it on every side, under 0.6 at
   its heart and easing out to nothing, with no edge to be seen. */
#hero-copy { isolation: isolate; }
#hero-copy::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -10rem -18rem;
  pointer-events: none;
  background: radial-gradient(farthest-side,
    color-mix(in srgb, var(--page) 55%, transparent) 0%,
    color-mix(in srgb, var(--page) 53%, transparent) 20%,
    color-mix(in srgb, var(--page) 46%, transparent) 38%,
    color-mix(in srgb, var(--page) 35%, transparent) 54%,
    color-mix(in srgb, var(--page) 22%, transparent) 68%,
    color-mix(in srgb, var(--page) 11%, transparent) 80%,
    color-mix(in srgb, var(--page) 4%, transparent) 90%,
    transparent 100%);
}
#hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
#hero-outputs { display: contents; }
#hero-outputs[hidden] { display: none; }

/* Big buttons: the hero's calls to action. */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 1rem 1.75rem;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
}
.btn[hidden] { display: none; }
#hero-enable { --button-fill: var(--coral); --button-relief: var(--relief-coral); --button-lift: var(--coral-lift); --button-shade: var(--coral-shade); --shadow: var(--coral-shade); }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* --- Content column --------------------------------------------------- */

#content-column {
  max-width: calc(var(--page-width) + 2 * var(--page-padding-x));
  box-sizing: border-box;
  margin: 0 auto;
  padding: 0 var(--page-padding-x);
}
#content-column[hidden] { display: none; }
#content { margin: 0; }
/* Now Playing: the piece in large type, the player docked below. */
#player-page { padding: 4rem 0 2rem; }
#player-kicker {
  margin: 0 0 1rem;
  color: var(--coral);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
#player-title {
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 4rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
#player-composer { margin: 1rem 0 0; font-size: 1.4rem; color: var(--accent-ink); }
/* Sign in and account: one column of short forms, each a label over
   its field and button. */
.account-form-page { max-width: 36rem; padding: 2rem 0 3rem; }
.account-form-page[hidden] { display: none; }
.account-form-page h1 { margin: 0 0 0.5rem; font-size: clamp(2rem, 4vw, 2.75rem); line-height: 1.1; }
.account-form-page h2 { margin: 2rem 0 0.6rem; font-size: 1.15rem; }
.account-form-page label { display: block; margin: 1.25rem 0 0.4rem; font-weight: 700; }
.account-form-page form[hidden], .account-form-page [hidden] { display: none; }
.account-lede, .account-detail { color: var(--accent-ink); }
.field-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: stretch; }
.text-field {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--navy);
  border-radius: var(--radius-sm);
  background: var(--page);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
}
.text-field:focus-visible { outline: 3px solid var(--royal); outline-offset: 2px; }
.account-form-page .text-chip { margin-top: 0.75rem; font-size: 0.85rem; text-decoration: none; display: inline-block; }
.account-form-page .text-chip.danger { color: var(--coral-shade); }
#signin-alternatives { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.form-error { margin: 1rem 0 0; padding: 0.6rem 0.9rem; border-left: 4px solid var(--coral); background: color-mix(in srgb, var(--coral) 12%, var(--page)); }
.account-list { margin: 0; padding: 0; list-style: none; }
.account-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; padding: 0.4rem 0; border-bottom: 1px solid color-mix(in srgb, var(--navy) 15%, transparent); }
.account-list .text-chip { margin: 0 0 0 auto; }
.account-item-detail { color: var(--accent-ink); font-size: 0.9rem; }
/* The sign-out buttons, one to a line. */
.account-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; margin-top: 1rem; }
.account-actions :is(.text-chip, .account-call) { margin: 0; }
/* The account page's parts, each on a navy card like a stream card's,
   standing still: cream text, its details a softer cream, its rules
   faint cream lines. */
.account-card {
  --accent-ink: color-mix(in oklab, var(--cream-ink) 72%, var(--card));
  margin-top: 1.25rem;
  padding: 1rem 1.25rem 1.25rem;
  border-radius: var(--radius);
  background: var(--relief-card) 0 0 / 100% 100% no-repeat, var(--card);
  box-shadow:
    inset 0 1px 0 color-mix(in oklab, var(--card-lift) 70%, transparent),
    inset 0 -2px 0 color-mix(in oklab, var(--card-shade) 60%, transparent),
    0 0 0 1.5px color-mix(in oklab, var(--card) 40%, var(--page));
  color: var(--cream-ink);
}
.account-card h2 { margin: 0 0 0.75rem; }
.account-card h2 label { display: inline; margin: 0; font-weight: inherit; }
.account-card .account-detail { margin: 0.75rem 0 0; }
.account-card .account-detail:empty { display: none; }
.account-card .account-list li { border-bottom-color: color-mix(in oklab, var(--cream-ink) 18%, transparent); }
.account-card .account-list li:last-child { border-bottom: none; }
/* A numbered list: each item's number in navy on a cream circle. */
.account-list.numbered { counter-reset: account-item; }
.account-list.numbered > li:not(.empty) { counter-increment: account-item; }
.account-list.numbered > li:not(.empty)::before {
  content: counter(account-item);
  flex: none;
  align-self: center;
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--cream);
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* A passkey: its number, then its name and dates, with Remove under
   them, lined up at their left. */
.account-list li.passkey-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 0.4rem 0.75rem; }
.account-list.numbered > li.passkey-item::before { grid-row: 1 / span 2; align-self: start; }
.passkey-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; }
.account-list li.passkey-item .text-chip { grid-column: 2; justify-self: start; margin: 0; }
/* The page's call to action, in coral like the hero's Enable. */
.account-call {
  --button-fill: var(--coral);
  --button-relief: var(--relief-coral);
  --button-lift: var(--coral-lift);
  --button-shade: var(--coral-shade);
  --shadow: var(--coral-shade);
  margin-top: 1rem;
}
.account-form-page .btn:disabled { opacity: 0.45; cursor: default; }

/* History: the filter, then its cards in the flat list's layout. */
#history-page { padding: 1.5rem 0 2rem; }
#history-page[hidden] { display: none; }
#history-filter[hidden] { display: none; }
#history-filter { display: flex; gap: 0.4rem; margin-bottom: 1.25rem; }
#history-filter button { padding-block: 0.2rem; font-size: 0.85rem; line-height: 1.2; white-space: nowrap; }
#history-list { --row-gap: 0.75rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--row-gap) 0; margin: 0; }
#history-list > li { margin: 0; min-width: 0; }
.history-note { color: var(--navy-muted); }
#coming-soon { margin: 3rem 0; font-size: 2rem; font-weight: 700; color: var(--accent-ink); }

/* The search box and its tips, spanning the stream cards, not their
   right-hand gutter, pinned just under the nav. A speech bubble spoken
   by the current section: #search-bubble draws the box's shape and a
   tail rising from its top edge up into the nav, under that section's
   button, and #search-bubble-tail the whole tail again, in the nav,
   over its green (placeSearchBubble).
   Hidden where there's nothing to search (setNavMode) -- no display
   override on #search-area, which would beat [hidden]. */
#search-area {
  position: sticky;
  top: var(--nav-height-searching);
  z-index: 20;
  width: calc(100% - var(--stream-gutter));
  /* Just clear of the nav's row, the tail bridging the gap. */
  --bubble-gap: 5px;
  padding: var(--bubble-gap) 0 1.25rem;
  margin-bottom: 1rem;
}
/* The cream the lists scroll under, edge to edge. */
#search-area::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 50%;
  width: var(--full-bleed);
  transform: translateX(-50%);
  background: var(--page);
}
/* Behind the box (which comes after it, and is positioned too): the
   box's fill, one path with the tail. */
#search-bubble {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}
/* Over the nav's green, under its buttons (which come after it); an
   SVG clips to its own box, which ends at the box's top edge. */
#search-bubble-tail {
  position: absolute;
  pointer-events: none;
}
#search-bubble-tail[hidden] { display: none; }
:is(#search-bubble, #search-bubble-tail) path {
  fill: var(--cream);
  transition: d 200ms ease;
}
/* Looks like one text field, one line high: the chips (see the search
   box script in index.html), then the real, borderless input filling
   the rest, scrolling sideways together when they outrun it, behind a
   magnifying glass -- a background image, so it never catches a
   click; its stroke is the navy, written out, since a data: URL can't
   read a custom property. */
#search-box {
  position: relative;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 3.5rem;
  padding: 0.4rem 0.75rem 0.4rem 3rem;
  /* Room for #search-bubble's outline, which is drawn there instead. */
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2315203c' stroke-width='1.8' stroke-linecap='round'><circle cx='6.75' cy='6.75' r='4.75'/><path d='M10.25 10.25 L14 14'/></svg>") 1rem 50% / 1.2rem 1.2rem no-repeat;
  cursor: text;
}
/* The nav's green carried on down around the bar, edge to edge, so the
   bar sits within the nav; the tips and view switch under it are back
   on the page's cream. */
#search-box::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: calc(-2px - var(--bubble-gap));
  bottom: calc(-2px - 1rem);
  left: 50%;
  width: var(--full-bleed);
  /* Centered on the page's column, which runs on past the bar by the
     cards' gutter. */
  transform: translateX(calc(-50% + var(--stream-gutter) / 2));
  /* The nav's edges, their dots in step with the nav's: this layer
     starts right at the nav's bottom edge (it reaches up past the box by
     the box's own border, which it's set inside), so its images are
     drawn the nav's height up, to the dither's 8px repeat, and tall
     enough to still cover it. */
  --edge-y: calc(-1 * mod(var(--nav-height-searching), 8px));
  --edge-height: calc(100% + 8px);
}
/* Scrolled by a drag, a trackpad, or the caret; no scrollbar of its own. */
#search-scroll {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
}
#search-scroll::-webkit-scrollbar { display: none; }
#search-chips { display: contents; }
.search-chip { flex: none; }
#search-input {
  flex: 1 0 10rem;
  min-width: 10rem;
  padding: 0.35rem 0;
  border: none;
  outline: none;
  background: none;
  color: var(--navy);
  font-size: 1.15rem;
}
#search-input::placeholder { color: var(--royal); }
/* A finished field:value token: a royal chip, the field in bold, with an
   x to drop it. */
.search-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.25rem 0.2rem 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--royal);
  color: var(--cream-ink);
  font-size: 1rem;
  white-space: nowrap;
}
.search-chip b { font-weight: 700; }
.search-chip button {
  border: none;
  background: none;
  padding: 0 0.35rem;
  color: inherit;
  opacity: 0.7;
  font: inherit;
  cursor: pointer;
}
.search-chip button:hover { opacity: 1; }
/* Under the box: what the field names are, each one a button that
   starts that filter in the box. */
/* The row under the box: the tips at the left, Browse's view switch at
   the right. */
#list-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.75rem; }
#search-tips { margin: 0; font-size: 0.95rem; color: var(--ink); }
/* The grouping options (order, sort, fold all), then a whole button's
   width apart each, the three groupings (setGrouping) and the three
   views (setStreamView): chips, side by side. */
#list-controls { display: flex; align-items: center; gap: calc(18px + 2 * 0.45rem); margin-left: auto; }
#list-controls[hidden] { display: none; }
#group-options, #group-mode, #view-toggle { display: flex; gap: 0.4rem; }
#group-options[hidden] { display: none; }
#list-controls button { display: grid; place-items: center; line-height: 0; }
#list-controls svg { width: 18px; height: 18px; }
/* The grouping options: words rather than icons, on the same chips. */
#list-controls button.text-chip { padding-block: 0.2rem; font-size: 0.85rem; line-height: 1.2; white-space: nowrap; }
#list-controls button:disabled { opacity: 0.45; cursor: default; }
/* A group (groupResultList): across the whole row in every view, its
   heading -- a button folding the group away, a
   triangle pointing down into it while it's open, along the heading
   while it's shut, then its name and how many it holds -- and under
   it, its body, a step in, holding its cards and subgroups laid out
   like the results themselves. */
.plain-list {
  --group-step: 1.5rem;
  /* Where the tree's lines run: under the heading's triangle. In the
     muted ink, set back, out of the way of what they connect. */
  --line-x: calc(0.35rem - 1px);
  --tree-line: var(--navy-muted);
}
.group > h2 {
  margin: 0 var(--stream-gutter) 0 0;
  font-size: 1.15rem;
}
.group[data-depth="1"] > h2 { font-size: 1rem; }
.group[data-depth="2"] > h2 { font-size: 0.9rem; }
.group > h2 button {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
  padding: 0 0 0.35rem;
  border: none;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}
/* A piece's title, as it's written. */
.group[data-field="title"] > h2 button { text-transform: none; letter-spacing: 0; }
.group > h2 button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.group-caret {
  flex: none;
  width: 0.7em;
  height: 0.7em;
  fill: currentColor;
  transform: rotate(90deg);
  transition: transform 150ms ease;
}
.group > h2 button[aria-expanded="false"] .group-caret { transform: none; }
/* Folded away, a group's heading steps back: set in the muted ink, its
   count too, its name on the quiet dither the search tips' chips sit
   on. */
.group > h2 button[aria-expanded="false"],
.group > h2 button[aria-expanded="false"] .group-count { color: var(--navy-muted); }
.group > h2 button[aria-expanded="false"] > span:not(.group-count) {
  margin: -0.15rem -0.2rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--quiet-dither);
}
@media (prefers-reduced-motion: reduce) {
  .group-caret { transition: none; }
}
.group-count { color: var(--accent-ink); font-size: 0.95rem; font-weight: 500; letter-spacing: 0; }
/* Laid out and painted only near the screen (content-visibility), so a
   list of hundreds of cards costs about what the few in view do. That
   clips whatever draws past the body, so it's padded out above and
   below (and pulled back by as much) for its cards' shadows and focus
   rings; the tree's lines and the cards' right-hand gutter are already
   inside it. */
.group-body {
  --body-gap: 0.75rem;
  position: relative;
  margin: calc(var(--body-gap) - 14px) 0 -14px;
  padding: 14px 0 14px var(--group-step);
  list-style: none;
  content-visibility: auto;
  contain-intrinsic-block-size: auto 600px;
}
#content .group-body[hidden] { display: none; }

/* The tree's lines: from each heading, down under its triangle, a line
   reaching across to each of its rows -- a subgroup's heading, or the
   first card of a row of them -- turning into the last in a rounded
   corner. Each row draws its own stretch: an elbow, from the row (or
   heading) above down into its tick, and below that, but for the last
   row, the line running on down past it. All borders, on whole pixels,
   so every line is drawn the same crisp width. A subgroup draws them in
   its own ::after and ::before; a card in its ::after and its button's
   ::after. --reach is how far in from the
   line's body the row starts; --tick-y, how far down its tick meets it. */
[data-grouping="tree"] {
  --group-step: 24px;
  --line-x: 6px;
}
[data-grouping="tree"] .group-body { --body-gap: 8px; }
[data-grouping="tree"] .group-body > li {
  --reach: var(--group-step);
  --gap-above: var(--row-gap);
  --tick-y: 22px;
  /* Set below on the rows the line reaches, and on the last of them;
     reset here, so a subgroup's own rows don't inherit its. */
  --line: none;
  --last: 0;
  position: relative;
  isolation: isolate;
}
[data-grouping="tree"] .group-body > li:first-child { --gap-above: var(--body-gap); }
[data-grouping="tree"] .group-body > .group { --tick-y: 10px; }
#content.view-list [data-grouping="tree"] .group-body > li[id^="stream-item-"] { --tick-y: 17px; }
/* Which rows the line reaches: every subgroup, and every card that
   starts a row -- each one in the wide cards and the flat list, the
   first of each three in tiles. */
[data-grouping="tree"] .group-body > .group,
#content:not(.view-wide, .view-list) [data-grouping="tree"] .group-body > li[id^="stream-item-"]:nth-child(3n + 1 of li[id^="stream-item-"]),
#content:is(.view-wide, .view-list) [data-grouping="tree"] .group-body > li[id^="stream-item-"] {
  --line: 2px solid var(--tree-line);
}
/* The elbow. */
[data-grouping="tree"] .group-body > li::after {
  content: "";
  position: absolute;
  z-index: -2;
  top: calc(-1 * var(--gap-above));
  left: calc(var(--line-x) - var(--reach));
  width: calc(var(--reach) - var(--line-x) - 5px);
  height: calc(var(--gap-above) + var(--tick-y) + 1px);
  box-sizing: border-box;
  border-left: var(--line);
  border-bottom: var(--line);
  border-bottom-left-radius: calc(var(--last) * 8px);
  pointer-events: none;
}
/* The line running on below the tick: from a subgroup's ::before, or a
   card's button's ::after (the button fills the card). */
[data-grouping="tree"] .group-body > .group::before,
[data-grouping="tree"] .group-body > li[id^="stream-item-"] > .stream-item::after {
  content: "";
  position: absolute;
  z-index: -2;
  top: calc(var(--tick-y) + 1px);
  bottom: 0;
  left: calc(var(--line-x) - var(--reach));
  border-left: var(--line);
  opacity: calc(1 - var(--last));
  pointer-events: none;
}
/* The last row: the line turns into it in a rounded corner, and ends.
   In tiles, the first card of the last row, with no subgroup after it. */
[data-grouping="tree"] .group-body > .group:last-child,
#content:not(.view-wide, .view-list) [data-grouping="tree"] .group-body > li[id^="stream-item-"]:nth-child(3n + 1 of li[id^="stream-item-"]):nth-last-child(-n + 3 of li[id^="stream-item-"]):not(:has(~ .group)),
#content:is(.view-wide, .view-list) [data-grouping="tree"] .group-body > li[id^="stream-item-"]:last-child {
  --last: 1;
}
/* Each field name, and each view, a little cream chip; hover stands it
   out a little from the page over a plain shadow, like the site's
   buttons (see .nav-item), instead of changing its color -- and the view
   in use keeps it. */
:is(:is(#search-tips, #list-controls, #history-filter) button, .account-form-page .text-chip) {
  position: relative;
  isolation: isolate;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  padding: 0.1rem 0.45rem;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
:is(:is(#search-tips, #list-controls, #history-filter) button, .account-form-page .text-chip)::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
/* The body: the quiet dither on the solid page; hovered, and while it's
   the view in use, its shadow, 2px deep (half the chips' --drop: a
   quarter is too slight), in the sand's dark color; the navy's, on a
   chip turned over (below). */
:is(:is(#search-tips, #list-controls, #history-filter) button, .account-form-page .text-chip)::after {
  z-index: -1;
  background: var(--quiet-dither), var(--page);
  box-shadow: var(--drop-shadow, 0 0 transparent);
  transition: box-shadow 120ms ease;
}
:is(:is(#search-tips, #list-controls, #history-filter) button, .account-form-page .text-chip) {
  --drop: 4px;
  --shadow: var(--sand-shade);
}
/* In the dark, the chips' shadow is the day's sand, standing them up off
   the page. */
:root[data-look~="dark"] :is(:is(#search-tips, #list-controls, #history-filter) button, .account-form-page .text-chip) { --shadow: var(--sand-light); }
:is(#list-controls, #history-filter) button:is([aria-pressed="true"], :not(:disabled):active) { --shadow: var(--navy-shade); }
:is(:is(#search-tips, #list-controls, #history-filter) button, .account-form-page .text-chip):not(:disabled):hover,
:is(#list-controls, #history-filter) button:is([aria-pressed="true"], :not(:disabled):active) {
  --drop-shadow: calc(var(--drop) / 2) calc(var(--drop) / 2) 0 var(--shadow);
}
/* Pressed, and while it's the view in use, a view chip turns over, as
   the nav's buttons do: a navy body, its lines in cream. */
:is(#list-controls, #history-filter) button:is([aria-pressed="true"], :not(:disabled):active) { color: var(--cream-ink); }
:is(#list-controls, #history-filter) button:is([aria-pressed="true"], :not(:disabled):active)::after { background: var(--navy); }
/* Completions for the token at the caret (see the search box script),
   hanging just under the box, over the results: eight and a half rows
   tall at most -- the half row says there's more -- scrolling to the
   rest. */
#search-suggest {
  --suggest-row: calc(0.8rem + 1rem * 1.45);
  position: absolute;
  top: calc(100% + 6px);
  left: -2px;
  z-index: 5;
  min-width: 18rem;
  max-width: 100%;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--cream-light);
  cursor: default;
  max-height: calc(8.5 * var(--suggest-row));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--ink) transparent;
}
#search-suggest li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  line-height: 1.45;
  cursor: pointer;
}
#search-suggest li.active { background: var(--navy); color: var(--cream-ink); }
#search-suggest .suggest-count { opacity: 0.6; font-size: 0.85rem; }

h1 { margin-bottom: 0; }
.subtitle { color: var(--accent-ink); margin-top: 0.25rem; }
section { margin-top: 2rem; }
.card { border: 2px solid var(--ink); border-radius: var(--radius); padding: 1rem; }
.card h2 { margin-top: 0; }
#stream-list, #extra-streams { list-style: none; padding: 0; }
#stream-list li, #extra-streams li { margin-bottom: 0.9rem; }
/* The li's padding-right reserves the gutter .stream-item.selected's
   note sits in, on every row, so selecting a card doesn't narrow it. */
li.stream-card { padding-right: var(--stream-gutter); }
/* Browse's results: tiles, three to a row, each with its gutter for the
   playing note; anything that isn't a card (no matches) spans the row. */
:is(#content > .plain-list, #content .group-body) {
  --row-gap: 1.25rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--row-gap) 0;
}
#content > .plain-list { margin: 0; }
:is(#content > .plain-list, #content .group-body) > li { margin: 0; min-width: 0; }
:is(#content > .plain-list, #content .group-body) > li:not(.stream-card) { grid-column: 1 / -1; }
/* The flat list: one card a row, all its text on one line -- title,
   composer, then when and by whom -- over a fingerprint a third the
   tiles' height. The right end is left to the Play button. */
/* Wide cards: the tiles as they are, one to a row. */
:is(#content.view-wide > .plain-list, #content.view-wide .group-body) { grid-template-columns: minmax(0, 1fr); }
:is(#content.view-list > .plain-list, #content.view-list .group-body) { --row-gap: 0.75rem; grid-template-columns: minmax(0, 1fr); }
:is(#content.view-list, #history-list) .stream-item {
  --thumb-height: 16px;
  --thumb-inset-bottom: 0.5rem;
  row-gap: 0.4rem;
  padding: 0.5rem 0.9rem;
}
:is(#content.view-list, #history-list) .stream-item-content {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding-right: calc(var(--play-size) + 0.5rem + var(--note-size) + 0.75rem);
  white-space: nowrap;
}
:is(#content.view-list, #history-list) .stream-item-heading { display: contents; }
:is(#content.view-list, #history-list) :is(.piece-title, .composer-name, .stream-item-credit) { flex: 0 1 auto; min-width: 0; margin-right: 0; overflow: hidden; text-overflow: ellipsis; }
:is(#content.view-list, #history-list) :is(.piece-title, .composer-name) { font-size: 1rem; }
/* Centered on the row's height. */
:is(#content.view-list, #history-list) .card-actions { top: 0; bottom: 0; }
.plain-list li.stream-card { margin-bottom: 0.9rem; }

/* --- Stream cards ----------------------------------------------------- */

/* Navy cards: the text, then the fingerprint under it. Browse lays
   them out as tiles, three to a row, as wide cards (#content.view-wide),
   one to a row, or (#content.view-list, see setStreamView) as a flat
   list, one compact row each. Hovered, and while it's the one chosen, a
   card stands out from the page over a plain shadow, 3px deep, in its
   navy's shade, like the site's buttons. */
.stream-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* A tile as tall as the tallest in its row, the fingerprint kept at
     the bottom. */
  grid-template-rows: auto 1fr;
  row-gap: 0.6rem;
  width: 100%;
  flex: 1;
  box-sizing: border-box;
  padding: 0.75rem 0.9rem;
  border: none;
  border-radius: var(--radius);
  background: var(--relief-navy) 0 0 / 100% 100% no-repeat, var(--navy);
  box-shadow:
    inset 0 1px 0 color-mix(in oklab, var(--navy-lift) 70%, transparent),
    inset 0 -2px 0 color-mix(in oklab, var(--navy-shade) 60%, transparent),
    var(--card-ring),
    var(--drop-shadow, 0 0 transparent);
  transition: box-shadow 120ms ease;
  color: var(--cream-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.stream-item:focus-visible { outline: 3px solid var(--royal); outline-offset: 6px; }
li.stream-card { position: relative; isolation: isolate; display: flex; flex-direction: column; }
/* Inside a card, the navy is the card's, a step lighter (--card), and
   the card's edge eases into the page through a ring halfway between
   them -- given up while its shadow shows, for it to meet it. */
li.stream-card {
  --navy: var(--card);
  --navy-lift: var(--card-lift);
  --navy-shade: var(--card-shade);
  --navy-lift-m: var(--card-lift-m);
  --navy-shade-m: var(--card-shade-m);
  --relief-navy: var(--relief-card);
  --card-ring: 0 0 0 1.5px color-mix(in oklab, var(--card) 40%, var(--page));
}
li.stream-card:is(.chosen, :has(> .stream-item:hover)) { --card-ring: 0 0 transparent; }
li.stream-card:is(.chosen, :has(> .stream-item:hover)) > .stream-item { --drop-shadow: 3px 3px 0 var(--navy-shade); }
/* The chosen card (chooseStream) shows its actions over its top right
   corner, where the title and composer leave room for them; on a short
   card they may run down over the fingerprint. */
li.stream-card { --play-size: 2.25rem; --note-size: 1rem; }
.card-actions {
  --button-fill: var(--coral);
  --button-relief: var(--relief-coral);
  --button-lift: var(--coral-lift);
  --button-shade: var(--coral-shade);
  --shadow: var(--coral-shade);
  --drop: 8px;
  position: absolute;
  top: 0.75rem;
  right: calc(var(--stream-gutter) + 0.9rem);
  display: none;
  align-items: center;
  gap: 0.5rem;
}
/* Shown on the card chosen, and on the one playing. */
li:is(.chosen, :has(> .stream-item.selected)) .card-actions { display: flex; }
/* Play, or on the card playing, Pause (index.html's markChosenStream),
   crossfading in one grid cell as the nav's does. */
.card-actions .btn { display: inline-grid; place-items: center; width: var(--play-size); height: var(--play-size); padding: 0; }
/* The card playing is marked by a cream eighth note right of its
   Pause. While music is playing (#content-column.playing, see index.html's
   updatePlayPauseButton) it pulses steadily, swelling and settling about
   once a second; paused, it holds still. */
/* Its room is kept on every card, so Play sits in the same place
   whether or not the note shows. */
.card-note {
  display: inline-block;
  visibility: hidden;
  width: var(--note-size);
  font-size: var(--note-size);
  line-height: 1;
  text-align: center;
  color: var(--cream-ink);
}
li:has(> .stream-item.selected) .card-note { visibility: visible; }
#content-column.playing .card-note { animation: note-pulse 1s ease-in-out infinite; }
@keyframes note-pulse {
  50% { transform: scale(1.35); }
}
@media (prefers-reduced-motion: reduce) {
  #content-column.playing .card-note { animation: none; }
}
/* The selected card's copy of the dock's playhead and played stretch
   (index.html's markSelectedStream adds both; syncCardPlayhead keeps
   --progress, 0-100, in step with #progress-bar): display only, over
   the card's fingerprint band -- .fingerprint-thumb's height at the
   bottom of the card's padding. */
.stream-item { --thumb-inset-x: 0.9rem; --thumb-inset-bottom: 0.75rem; --thumb-height: 48px; }
.card-playhead,
.card-played {
  position: absolute;
  bottom: var(--thumb-inset-bottom);
  height: var(--thumb-height);
  pointer-events: none;
}
.card-played {
  left: var(--thumb-inset-x);
  width: calc((100% - 2 * var(--thumb-inset-x)) * var(--progress, 0) / 100);
  z-index: 0;
  backdrop-filter: var(--played-filter);
}
.card-playhead {
  left: calc(var(--thumb-inset-x) + (100% - 2 * var(--thumb-inset-x)) * var(--progress, 0) / 100);
  width: 0;
  z-index: 1;
  border-left: 1px dashed var(--cream);
  filter: var(--line-halo);
}
.card-playhead::before,
.card-playhead::after {
  content: "";
  position: absolute;
  left: -4px;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
}
.card-playhead::before { top: 0; border-top: 4px solid var(--cream); }
.card-playhead::after { bottom: 0; border-bottom: 4px solid var(--cream); }
/* Card text, scoped here since .piece-title/.composer-name/the badges
   are shared with _search_result.html's rows. */
.stream-item-credit { color: var(--cream-ink); }
.stream-item .piece-title,
.stream-item .composer-name,
.stream-item .live-badge { color: var(--cream-ink); }
/* fill, not just color: the note glyph's head/flag are filled shapes. */
.stream-item .live-note { color: var(--cream-ink); fill: currentColor; }
.piece-title { font-weight: 700; font-size: 1.15rem; }
.composer-name { color: var(--accent-ink); font-size: 0.95rem; font-weight: normal; }
/* Title, then its composer on the same line -- the same size and cream,
   a lighter weight -- stopping short of the Play button in the corner; the credit
   under them runs the card's full width. */
.stream-item-heading { margin-right: calc(var(--play-size) + 0.5rem + var(--note-size) + 0.6rem); }
.stream-item .piece-title { margin-right: 0.45em; }
.stream-item .composer-name { font-size: 1.15rem; font-weight: 500; }
.stream-item-credit { margin-top: 0.35rem; font-size: 0.85rem; }
/* Under the text, across the card's full width at a fixed height: a
   thumbnail is never scrubbed by column, so there's no position to
   preserve. */
.fingerprint-thumb { grid-row: 2; align-self: end; width: 100%; height: var(--thumb-height, 48px); object-fit: fill; z-index: 0; pointer-events: none; border-radius: 3px; }
/* Unselected thumbnails are a little dimmed (darker, not grayer -- each
   key keeps its color) so a page of them stays calm; full brightness
   on hover and once selected. */
.stream-item .fingerprint-thumb { filter: brightness(0.75); transition: filter 0.15s ease, opacity 0.4s ease; }
/* Invisible until loadImageWhenReady (index.html) marks it .loaded,
   then faded in -- before that the navy behind it is the whole
   placeholder, with no empty frame or broken-image icon. */
.fingerprint-thumb,
#progress-fingerprint { opacity: 0; transition: opacity 0.4s ease; }
.fingerprint-thumb.loaded,
#progress-fingerprint.loaded { opacity: 1; }
.stream-item:hover .fingerprint-thumb { filter: none; }
.stream-item.selected .fingerprint-thumb { filter: none; }
.stream-item-content { grid-row: 1; min-width: 0; }
.stream-item-credit .live-badge { margin-left: 0; }
.live-badge { font-size: 0.95rem; margin-left: 0.4em; }
.live-badge { display: inline-flex; align-items: center; gap: 0.3em; color: var(--ink); }

/* search.html's filter form: four labeled fields in a row, wrapping on
   narrow viewports. */
#search-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
#search-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9em; color: var(--accent-ink); }

/* search_results.html / admin_piece_types.html's plain lists. */
.plain-list { list-style: none; padding: 0; }
.plain-list li { margin-bottom: 0.5rem; }
.search-result { display: block; padding: 0.75rem; border: 2px solid transparent; border-radius: var(--radius); background: var(--halftone); text-decoration: none; color: inherit; }
.search-result:hover { border-color: var(--ink); }
.live-note { color: var(--ink); animation: live-note-pulse 1.4s ease-in-out infinite; }
@keyframes live-note-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}
#stream-list button[hx-get] { width: 100%; text-align: center; padding: 0.6rem; font: inherit; font-weight: 700; }

/* --- The player ------------------------------------------------------- */

/* Fixed to the bottom of the viewport, edge to edge, ruled off from the
   page above like the nav is from below; its contents keep to the
   page's column, the fingerprint spanning exactly the stream cards'
   width above it. overflow: hidden keeps #scrub-hover-time, which sits
   just under the strip, inside the dock. */
#now-playing-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  height: var(--dock-height);
  box-sizing: border-box;
  padding: 0.75rem 0 0;
  border-top: 2px solid var(--ink);
  background: var(--page);
  overflow: hidden;
}
#now-playing-dock[hidden] { display: none; }
/* On Now Playing the player is the page: no longer docked and ruled off
   at the bottom, but set in it, right under the piece's name. */
body.mode-now-playing #now-playing-dock { position: static; border-top: none; }
/* The page names the piece already, large. */
body.mode-now-playing #now-playing-piece { display: none; }
#now-playing-center {
  width: 100%;
  max-width: calc(var(--page-width) + 2 * var(--page-padding-x));
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0 calc(var(--page-padding-x) + var(--stream-gutter)) 0 var(--page-padding-x);
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
/* The transport row, directly on top of the strip below it. Only the
   buttons get a backing; the rest of the row is open page, with the
   playing piece's title in it. */
#transport-block {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  position: relative;
}
#transport-block[hidden] { display: none; }
/* Rewind/back, play/pause, forward, plus #drift-warning riding along, on
   a navy tab joined to the navy strip below. */
#transport-keys {
  height: 2.5rem;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.25rem;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--navy);
}
/* The playing piece's title and composer, pinned to the row's left
   edge, truncated rather than reaching under the transport. */
#now-playing-piece {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  max-width: calc(50% - 8rem);
  line-height: 1.2;
  font-size: 1rem;
}
#now-playing-piece[hidden] { display: none; }
#now-playing-piece > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#now-playing-piece .composer-name { font-size: 0.9rem; }
.transport-btn {
  background: none;
  border: none;
  color: var(--cream-ink);
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}
.transport-btn:hover { color: var(--coral); }
/* Nothing chosen to play (see updateNowPlayingCenter): dimmed, though
   still pressable -- pressing flashes the empty strip's instructions. */
#transport-keys.idle .transport-btn { opacity: 0.4; }
/* Play and pause share one grid cell, so the button is always as wide
   as the wider of the two and the bar never resizes; .playing (set by
   updatePlayPauseButton) crossfades between them. */
#play-pause-btn { display: inline-grid; }
.pp-icon { grid-area: 1 / 1; text-align: center; transition: opacity 120ms ease, transform 120ms ease; }
#play-pause-btn.playing .pp-play,
#play-pause-btn:not(.playing) .pp-pause,
.card-play.playing .pp-play,
.card-play:not(.playing) .pp-pause,
#nav-play-pause.playing .pp-play,
#nav-play-pause:not(.playing) .pp-pause { opacity: 0; transform: scale(0.6); }
.icon-btn { font-size: 1.1rem; line-height: 1; padding: 0.3rem 0.5rem; }
#drift-warning { cursor: help; }

/* Roman numerals on/off (see index.html's toggleRomanNumerals), pinned
   inside #scrub-wrap's top-right corner, above the fingerprint and every
   overlay on it (#progress-playhead is z-index 3). A serif "V", so it
   reads as a numeral, not a letter. Off: navy ringed in cream; on
   (aria-pressed): solid cream. */
#roman-toggle {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border: 1.5px solid var(--cream);
  border-radius: 50%;
  background: var(--navy);
  color: var(--cream-ink);
  font: bold 0.75rem/1 Georgia, "Times New Roman", serif;
  cursor: pointer;
}
#roman-toggle[aria-pressed="true"] { background: var(--cream); color: var(--navy); }
#roman-toggle:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }

#keyboard { margin: 0.5rem 0 1rem; cursor: pointer; }
/* Scales to the dock's width via the SVG's own viewBox, so all 88 keys
   show at once. Edges are left to normal anti-aliasing, not crispEdges:
   at a fractional scale, crispEdges can snap a hairline out to two
   device pixels. */
#keyboard svg { display: block; width: 100%; height: auto; }
#keyboard svg rect[data-note]:hover { opacity: 0.85; }

/* One 88px row in #scrub-wrap's exact footprint (it stands in for the
   fingerprint while a stream is still recording), so a live stream
   doesn't make the dock's contents any taller than a finished one. */
#live-state-controls:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; align-content: center; justify-content: center; gap: 0.4rem 0.5rem; height: 88px; margin-bottom: 1rem; border-radius: var(--radius); background: var(--navy); color: var(--cream-ink); }
#live-state-controls button {
  padding: 0.35rem 0.8rem;
  font: inherit;
  font-size: 0.95rem;
}
#live-seek-controls:not([hidden]) { display: flex; align-items: center; gap: 0.5rem; }
/* .loud: the stream finished and its chunks are already swept -- the
   live view has nothing left to show. */
#lifecycle-notice:not([hidden]) { display: flex; flex-basis: 100%; justify-content: center; align-items: baseline; gap: 0.5rem; font-size: 0.95rem; opacity: 0.8; }
#lifecycle-notice.loud { opacity: 1; font-weight: 700; color: var(--coral); }
#lifecycle-notice a { color: inherit; }
#live-btn:disabled { opacity: 0.5; cursor: default; }

/* The stand-in for #scrub-wrap while there's no performance chosen, in
   its exact footprint: a navy block saying what to do -- choose one,
   then (see updateIdleMidiNudge) whatever MIDI setup is still missing
   for it to reach an instrument. .nudge flashes it when play or rewind
   is pressed with nothing to play. */
#fingerprint-placeholder:not([hidden]) {
  height: 88px;
  margin-bottom: 1rem;
  box-sizing: border-box;
  border-radius: var(--radius);
  background: var(--navy);
  color: var(--cream-ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.3rem;
  padding: 0 1rem;
  text-align: center;
}
#fingerprint-placeholder .idle-title { font-size: 1.1rem; font-weight: 500; }
#fingerprint-placeholder .idle-midi { font-size: 0.9rem; opacity: 0.7; }
#fingerprint-placeholder.nudge { animation: idle-nudge 0.6s ease; }
@keyframes idle-nudge {
  30% { background: var(--royal); }
}

/* --- The fingerprint strip -------------------------------------------- */

/* Fingerprint (fingerprint.py's HEIGHT=88, one row per piano key) fills
   this box at a 1:1 pixel mapping vertically, so no key row blurs into
   its neighbors. #progress-bar is stacked on top, same box, fully
   transparent, with #progress-playhead's two triangles as the visible
   playhead, and the hover-only overlays (see index.html's onScrubHover)
   above that. The fingerprint PNG's quiet pixels are transparent, so
   the navy behind it is what silence reads as. margin-bottom reserves
   room for #scrub-hover-time below the strip. */
#scrub-wrap { position: relative; width: 100%; height: 88px; margin-bottom: 1rem; border-radius: var(--radius); background: var(--navy); }
/* The part of the fingerprint already played, from the left edge to the
   playhead (--progress, 0-100, set alongside it in setProgressBarValue),
   desaturated in place by filtering what's behind it. Above the image,
   below the playhead and every other overlay; never takes the pointer. */
#progress-played {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: calc(var(--progress, 0) * 1%);
  border-radius: var(--radius) 0 0 var(--radius);
  backdrop-filter: var(--played-filter);
  pointer-events: none;
  transition: opacity 150ms ease;
}
/* Hovering the strip -- looking back through the performance -- brings
   the played stretch's color back, and a lens around the pointer lifts
   saturation further, over past and future alike: up to
   --lens-saturation at the pointer (the ceiling), fading out over about
   --lens-radius either side. --lens-x is set by index.html's
   onScrubHover. */
#scrub-wrap {
  --lens-saturation: 1.6;
  --lens-radius: 30px;
}
#scrub-wrap:hover #progress-played { opacity: 0; }
#scrub-lens {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backdrop-filter: saturate(var(--lens-saturation));
  -webkit-mask-image: radial-gradient(ellipse var(--lens-radius) 150% at var(--lens-x, -999px) 50%, #000 20%, transparent 100%);
  mask-image: radial-gradient(ellipse var(--lens-radius) 150% at var(--lens-x, -999px) 50%, #000 20%, transparent 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
#scrub-wrap:hover #scrub-lens { opacity: 1; }
#progress-fingerprint {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  /* No outline of its own -- #scrub-wrap's rounded box is the edge --
     just the same rounding, so the image's corners don't poke out
     square past it. */
  border-radius: var(--radius);
}
#progress-bar {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  accent-color: var(--near-black);
}
#progress-bar::-webkit-slider-runnable-track { background: transparent; }
/* The native thumb is made fully invisible, not removed -- #progress-bar
   itself stays the full-box drag surface exactly as before (inset:0),
   so hit-testing/dragging is untouched; only its own visible rendering
   is replaced by #progress-playhead's two triangles below, since a
   single native thumb can't become two independent shapes above/below
   the track. */
#progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 2px;
  height: 88px;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
}
#progress-bar::-moz-range-track { background: transparent; border: none; height: 88px; }
#progress-bar::-moz-range-thumb {
  width: 2px;
  height: 88px;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
}
/* A thin, always-visible white dashed line at the current playback
   position, joining #progress-playhead's two triangles, so "where in
   the piece are we hearing notes from" reads at a glance against the
   fingerprint even before the pointer ever touches this control. Same left-position/full-height/
   pointer-events:none treatment as #scrub-hover-line (see there and
   setProgressBarValue in index.html, which keeps this and
   #progress-playhead in lockstep), and painted just before it in the
   DOM so a hover preview at nearly the same position still draws on
   top rather than getting lost under this one. */
#progress-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-left: 1px dashed var(--cream);
  filter: var(--line-halo);
  pointer-events: none;
  z-index: 1;
}

/* The actual visible playhead: two small white triangles inside
   #scrub-wrap's top/bottom edges, pointing in at the current position
   -- positioned via left (a JS-set percentage, see setProgressBarValue
   in index.html), centered on that point via the translateX below.
   pointer-events: none so it never steals the drag from #progress-bar
   sitting underneath it. */
#progress-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  transform: translateX(-50%);
  filter: var(--line-halo);
  pointer-events: none;
  /* Above #scrub-hover-line/#key-region-layer (z-index 1/2 below) -- the
     real playback position should never be visually obscured by a
     hover-only preview. */
  z-index: 3;
}
#progress-playhead::before,
#progress-playhead::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
}
/* Flat edge along the strip's top, pointing down into it. */
#progress-playhead::before { top: 0; border-top: 6px solid var(--cream); }
/* Flat edge along the strip's bottom, pointing up into it. */
#progress-playhead::after { bottom: 0; border-bottom: 6px solid var(--cream); }

/* Hover scrub-preview line: a dashed vertical line at the cursor's own
   x position (see index.html's onScrubHover), spanning #scrub-wrap's
   full height -- "over the fingerprint" (z-index above the image/
   #progress-bar's own stacking, both un-indexed/0) but under the
   key regions (#key-region-layer's own z-index is higher, below). Hidden
   (opacity 0) except while actually hovering -- .visible is what
   onScrubHover/onScrubLeave toggle. pointer-events: none throughout --
   #progress-bar underneath stays the only interactive surface. */
#scrub-hover-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-left: 1.5px dashed rgba(239, 233, 211, 0.85); /* --cream at 85% */
  filter: var(--line-halo);
  pointer-events: none;
  opacity: 0;
  z-index: 1;
  transition: opacity 0.1s ease;
}
#scrub-hover-line.visible { opacity: 1; }

/* Elapsed-time readout at the bottom of the hover line, outside the
   fingerprint entirely (top: 100% -- see #scrub-wrap's own
   margin-bottom, which reserves the room this needs below the strip).
   Tracks the same cursorX the line itself does. */
#scrub-hover-time {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.2rem;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: var(--accent-ink);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 1;
  transition: opacity 0.1s ease;
}
#scrub-hover-time.visible { opacity: 1; }

/* Key-change regions (see index.html -- fetchKeyChanges/
   renderKeyRegions): one borderless box per detected key, spanning its
   full extent left-to-right (from its own key change to the next) and
   #scrub-wrap's full height, filled with the key's color at 50% alpha
   (set inline). Hidden except for whichever region the cursor is over
   (.visible, toggled by onScrubHover/onScrubLeave). The layer and
   regions are pointer-events:none so #progress-bar underneath stays
   draggable everywhere; only the label opts back in, for click-to-seek.
   Above #scrub-hover-line in stacking order, below #progress-playhead. */
#key-region-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.key-region {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.key-region.visible { opacity: 1; }
/* The key's name, pinned to the very bottom of the strip at the region's
   left edge (where the key begins) -- white-on-black.
   Allowed to overflow a region narrower than its own text rather than
   wrapping or truncating. */
.key-region-label {
  position: absolute;
  bottom: 0;
  left: 0;
  padding: 0.05rem 0.3rem;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--cream-ink);
  background: var(--navy);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
}
