:root {
  --bg: #F1E9DC;
  --text: #2B1B14;
  --string-plain: #ECE8DA;
  --string-plain-hot: #FFFFFF;
  --string-wound: #C9CCD0;
  --string-wound-hot: #F4F6F8;
  --pearl: #EFE6D0;
  --dark: #120C08;
  --rim: transparent;
  --drop-opacity: 0.25;
  --stage: var(--bg);
  --dock-bg: #F1E9DC;
  --dock-ink: #8E5A2C;
  --dock-text: #2B1B14;
  --dock-line: color-mix(in srgb, #8E5A2C 50%, transparent);
  --playhead: color-mix(in srgb, #D79B55 25%, transparent);
  --playhead-solid: color-mix(in srgb, #D79B55 25%, var(--dock-bg));
  --bar-h: 3.5rem;
  --body-h: 16rem;
  --reserve: 3.5rem;
  --tools-h: 7rem;
  --edge: 0.5rem;
  --open-w: 0px;
  --k: 1;
  --err: #A12B1E;
  --ease-open: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-close: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110E;
    --text: #F1E9DC;
    --rim: #D9B77E;
    --drop-opacity: 0.6;
    --stage: radial-gradient(ellipse at 55% 50%, #3A2E24 0%, #241C16 45%, #14110E 85%);
    --dock-bg: #1E1612;
    --dock-ink: #E9D8AE;
    --dock-text: #E9D8AE;
    --dock-line: color-mix(in srgb, #E9D8AE 50%, transparent);
    --err: #FF9D8A;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  background: var(--stage);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Declared here, not on :root, so they follow a --body-h that changes on .app (the phone's open
   fields); a custom property resolves its var() where it is declared. */
.app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  --open-h: var(--body-h);
  --guitar-shift: translateY(calc(var(--open-h) / -2));
  --foot-shift: translateY(calc(var(--open-h) * -1));
}

.stage {
  position: absolute;
  inset: 0 0 var(--bar-h) 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The guitar is always laid out at the collapsed size. Open, the dock leaves less room, so the
   wrapper moves up by half the dock's height and shrinks by --k, which src/stage-fit.js sets
   (CSS cannot divide two lengths). Only transform changes, so the animation never relayouts and
   the SVG stays sharp, rasterized at the large size. --body-h is the one number the dock and the
   stage share; the stage reserves --bar-h + --reserve + --body-h, 23rem at the desktop sizes. */
.stage-inner {
  position: absolute;
  inset: 0 0 var(--reserve) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: none;
  transition: transform 240ms var(--ease-close);
}
.app[data-open="true"] .stage-inner {
  transform: var(--guitar-shift) scale(var(--k));
  transition: transform 320ms var(--ease-open);
}
.stage-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--reserve);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.25rem;
  padding-bottom: 0.75rem;
  box-sizing: border-box;
  pointer-events: none;
  transition: transform 240ms var(--ease-close);
}
.app[data-open="true"] .stage-foot {
  transform: var(--foot-shift);
  transition: transform 320ms var(--ease-open);
}
.stage-probe {
  position: absolute;
  visibility: hidden;
  pointer-events: none;
  box-sizing: content-box;
  width: var(--open-w);
  height: var(--open-h);
  padding: var(--reserve) var(--edge) 0;
}
.preload, .preload * { transition: none !important; }

.guitar {
  display: block;
  flex: none;
  width: min(calc(100% - 2 * var(--edge)), calc((100dvh - var(--bar-h) - var(--reserve)) * 1240 / 480));
  aspect-ratio: 1240 / 480;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 0.875rem;
  opacity: 0.7;
  pointer-events: none;
}

.credit {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  column-gap: 0.375rem;
  margin: 0;
  text-align: center;
  font-size: 0.8125rem;
  color: color-mix(in srgb, var(--text) 75%, transparent);
  pointer-events: none;
}

.credit-icons { position: relative; display: inline-flex; align-items: center; gap: 0.125rem; }
/* 2.75rem tall for the finger, pulled back with negative margins so the row keeps its height; 1.5rem
   (24px) wide is the minimum target size and keeps the icons close. */
.credit a.ilink {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 2.75rem;
  margin: -0.75rem 0;
  color: #000;
  text-decoration: none;
  pointer-events: auto;
}
.credit a.ilink:focus-visible { outline: 2px solid currentColor; outline-offset: -0.25rem; border-radius: 0.5rem; }
.mark { display: block; height: 1rem; width: auto; }
.mark-github { width: 1rem; fill: currentColor; stroke: none; }
.mark-linkedin { aspect-ratio: 840 / 779; }
/* The favicon's stroke width, in its own units, so the wave keeps its weight. */
.mark-profile { width: 1rem; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; }
.mark.on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .credit a.ilink { color: #fff; }
  .mark.on-light { display: none; }
  .mark.on-dark { display: block; }
}

.rim { stroke: var(--rim); stroke-opacity: 0.55; }
.drop { opacity: var(--drop-opacity); }

.string { outline: none; }

.string-shadow {
  stroke: #000;
  stroke-opacity: 0.18;
  stroke-linecap: round;
}

.string-wire {
  stroke: #8A8F96;
  stroke-linecap: butt;
}

.string-line {
  stroke: var(--string-plain);
  stroke-linecap: round;
  transition: stroke 120ms;
}
.string-line.wound { stroke: var(--string-wound); }
.string-line:not(.wound) { stroke-opacity: 0.82; }

.string-ghost {
  fill: none;
  stroke: var(--string-plain);
  stroke-linecap: round;
  opacity: 0;
}
.string-ghost.wound { stroke: var(--string-wound); }

.string-live {
  fill: none;
  stroke: var(--string-plain-hot);
  stroke-linecap: round;
  opacity: 0;
}
.string-live.wound { stroke: var(--string-wound-hot); }

.string.hover .string-line,
.string.flash .string-line { stroke: var(--string-plain-hot); }
.string.hover .string-line.wound,
.string.flash .string-line.wound { stroke: var(--string-wound-hot); }

.hover-dot, .press-dot, .key-dot {
  fill: var(--pearl);
  opacity: 0;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
}
.string.hover .hover-dot { opacity: 0.35; }
.string:focus-visible .key-dot { opacity: 0.6; }

.focus-ring, .focus-halo {
  fill: none;
  opacity: 0;
  pointer-events: none;
}
.focus-ring { stroke: var(--pearl); }
.focus-halo { stroke: var(--dark); }
.string:focus-visible .focus-ring,
.string:focus-visible .focus-halo { opacity: 1; }

.hit { fill: #000; fill-opacity: 0; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .string-line { transition: none; }
}

.dock {
  --pad: 0.75rem;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  color: var(--dock-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
}
.dock.dragging .dock-body,
.dock.dragging .transport { outline: 2px dashed var(--dock-ink); outline-offset: -0.25rem; }
.dock :focus-visible { outline: 2px solid var(--dock-ink); outline-offset: 2px; }

.transport {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: var(--bar-h);
  padding: 0 var(--pad);
  background: var(--dock-bg);
  border-top: 1px solid var(--dock-line);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.spacer { flex: 1; }

.dock-body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--bar-h);
  height: var(--body-h);
  display: flex;
  flex-direction: column;
  background: var(--dock-bg);
  border-top: 1px solid var(--dock-line);
  transition: transform 320ms var(--ease-open), opacity 200ms linear, visibility 0s;
}
.app[data-open="false"] .dock-body {
  transform: translateY(100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 240ms var(--ease-close), opacity 160ms linear, visibility 0s 240ms;
}

.tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 200ms linear, visibility 0s;
}
.app[data-open="false"] .tools {
  opacity: 0;
  visibility: hidden;
  transition: opacity 160ms linear, visibility 0s 160ms;
}
.rule { width: 1px; height: 1.5rem; margin: 0 0.25rem; background: var(--dock-line); }

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn, .tempo-input {
  min-height: 2.75rem;
  font: inherit;
  color: var(--dock-text);
  background: transparent;
  border: 1px solid var(--dock-ink);
  border-radius: 0.375rem;
}
.btn {
  position: relative;
  min-width: 2.75rem;
  padding: 0 0.625rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-play { background: var(--dock-ink); color: var(--dock-bg); min-width: 5rem; }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover:not(:disabled) { border-color: var(--dock-ink); }
.btn-toggle .icon { transition: transform 240ms var(--ease-close); }
.app[data-open="false"] .btn-toggle .icon { transform: rotate(180deg); }
.btn-ghost[aria-pressed="true"] { background: color-mix(in srgb, var(--dock-ink) 16%, transparent); }

.tempo { display: flex; align-items: center; gap: 0.375rem; font-size: 0.875rem; }

/* As on YouTube: the button mutes; with a mouse, hovering or focusing the control slides the level
   out beside it. Touch screens keep only the button, since the device's own buttons set the level. */
.volume { display: flex; align-items: center; }
.volume-range {
  width: 0;
  margin: 0;
  opacity: 0;
  accent-color: var(--dock-ink);
  cursor: pointer;
  transition: width 160ms var(--ease-open), opacity 120ms linear, margin 160ms var(--ease-open);
}
.volume:hover .volume-range,
.volume:focus-within .volume-range { width: 5rem; margin: 0 0.5rem 0 0.25rem; opacity: 1; }
@media (hover: none), (pointer: coarse) { .volume-range { display: none; } }
.tempo-input { width: 4.5rem; padding: 0 0.5rem; text-align: center; font-size: 1rem; }

/* One tooltip for everything that carries data-tip. The control's aria-label is its name; the tip is
   only the visual. Each component places it: buttons above themselves, credit links beside the row. */
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  background: var(--dock-text);
  color: var(--dock-bg);
  font: 0.75rem/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms linear;
  z-index: 3;
}
@media (hover: hover) {
  [data-tip]:hover::after { opacity: 1; transition-delay: 450ms; }
}
[data-tip]:focus-visible::after { opacity: 1; transition-delay: 0s; }
.btn[data-tip]::after {
  bottom: calc(100% + 0.375rem);
  left: 50%;
  transform: translateX(-50%);
}
.btn[data-tip].tip-end::after { left: auto; right: 0; transform: none; }
/* Beside the icon row, in the empty stage to its right: nothing is under it, on a phone either. */
.credit-icons [data-tip]::after {
  top: 50%;
  left: calc(100% + 0.5rem);
  transform: translateY(-50%);
}

.seg {
  display: inline-flex;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--dock-ink);
  border-radius: 0.375rem;
  overflow: hidden;
}
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  display: grid;
  place-items: center;
  min-width: 3.25rem;
  min-height: 2.5rem;
  padding: 0 0.75rem;
  font-size: 0.875rem;
}
@media (pointer: coarse) { .seg span { min-height: 2.75rem; } }
.seg input:checked + span { background: var(--dock-ink); color: var(--dock-bg); font-weight: 600; }
.seg label:focus-within { outline: 2px solid var(--dock-ink); outline-offset: 2px; z-index: 1; }
.seg label + label span { border-left: 1px solid var(--dock-ink); }

.dock-status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 1.5rem;
  margin: 0;
  padding: 0 var(--pad);
  font: 0.875rem/1.5rem system-ui, -apple-system, "Segoe UI", sans-serif;
}
.dock-status:empty { display: none; }
.meta {
  flex: none;
  display: grid;
  grid-template-columns: 2fr 2fr 1.5fr;
  gap: 0.75rem;
  padding: 0.5rem var(--pad) 0.375rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.field { display: flex; flex-direction: column; min-width: 0; }
.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  min-height: 1rem;
  font-size: 0.75rem;
  line-height: 1rem;
}
.field [hidden] { display: none; }
.field-label { font-weight: 600; }
.field-note { opacity: 0.75; }
.field-error { color: var(--err); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field input {
  width: 100%;
  min-height: 2.25rem;
  padding: 0 0.625rem;
  font: 0.9375rem system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--dock-text);
  background: transparent;
  border: 1px solid var(--dock-ink);
  border-radius: 0.375rem;
}
.field input[aria-invalid="true"] { border-color: var(--err); box-shadow: inset 0 0 0 1px var(--err); }
.field input:focus-visible { outline-offset: 0; }
.meta-toggle { display: none; }
.summary {
  flex: 1;
  min-width: 0;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.8;
}
.app[data-open="true"] .summary { display: none; }
.app[data-open="false"] .spacer { display: none; }

.editor { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Editing off: the sheet tints, the cursor stops inviting a click and a label says why nothing types. */
.app[data-editing="false"] { --ro-bg: color-mix(in srgb, var(--dock-ink) 9%, var(--dock-bg)); }
.editor[data-editing] { position: relative; }
.editor[data-editing="false"] { background: var(--ro-bg); }
.editor[data-editing="false"]::after {
  content: "Read only";
  position: absolute;
  z-index: 2;
  top: 0.5rem;
  right: calc(var(--pad) + var(--scrollbar, 0px));
  padding: 0.125rem 0.5rem;
  font: 0.75rem system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--dock-text);
  background: var(--dock-bg);
  border: 1px solid var(--dock-line);
  border-radius: 0.25rem;
  pointer-events: none;
}
.editor[data-editing="false"] .text-area { cursor: default; }
/* Read only, the sheet starts below the label so the label never covers the first line. */
.editor[data-editing="false"] { --sheet-top: 2.25rem; }
.editor[data-editing="false"] .cell { background: var(--ro-bg); cursor: default; }
.editor[data-editing="false"] .cell.playing { background: var(--playhead-solid); }
.field input:read-only { background: var(--ro-bg, transparent); }

.text-editor { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.text-area {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--sheet-top, 0.5rem) var(--pad) 0.5rem;
  resize: none;
  border: 0;
  border-top: 1px solid var(--dock-line);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.5rem;
  white-space: pre;
  overflow: auto;
}
.playhead {
  position: absolute;
  top: 0;
  left: 0;
  width: 1ch;
  height: 9rem;
  background: var(--playhead);
  pointer-events: none;
  transform: translate(
    calc(var(--pad) + var(--ph-col, 0) * 1ch - var(--sx, 0px)),
    calc(var(--sheet-top, 0.5rem) + var(--ph-line, 0) * 1.5rem - var(--sy, 0px))
  );
}
.ch-probe { position: absolute; visibility: hidden; width: 1ch; height: 0; }

.grid-hint { flex: none; margin: 0; padding: 0 var(--pad); font: 0.875rem/1.5rem system-ui, -apple-system, "Segoe UI", sans-serif; }
.grid {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.25rem var(--pad);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
/* Blocks sit in the vertical middle, where the eye already is during playback, read only included:
   the label covers only the right end of the top row. Auto margins center without ever cutting a
   block when the sheet is shorter than it. */
.grid-block { flex: none; margin-block: auto; }
.grid-row { display: flex; height: 1.5rem; }
.grid-label { width: 1rem; text-align: center; line-height: 1.5rem; }
.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 1rem;
  height: 1.5rem;
  background: var(--dock-bg);
  line-height: 1;
  cursor: pointer;
}
.cell::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--dock-line);
}
.cell-fret { position: relative; z-index: 1; background: inherit; }
/* A two-digit fret is wider than a 1rem cell: it starts at its own column and runs over the empty cell
   after it, above that cell's background. */
@media (pointer: fine) { .cell-fret.wide { justify-self: start; } }
@media (pointer: coarse) { .grid-label, .cell { width: 1.5rem; } }
.cell.playing { background: var(--playhead-solid); }
.cell.cursor { outline: 1px dotted var(--dock-ink); outline-offset: -1px; }
.cell:focus-visible { outline: 2px solid var(--dock-ink); outline-offset: -2px; z-index: 1; }

.examples {
  width: min(32rem, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100dvh - 4rem);
  padding: 1rem 1.25rem;
  color: var(--dock-text);
  background: var(--dock-bg);
  border: 1px solid var(--dock-ink);
  border-radius: 0.5rem;
  font: 1rem system-ui, -apple-system, "Segoe UI", sans-serif;
}
/* The list scrolls between a fixed heading and a fixed Close, so Close is always on screen. */
.examples[open] { display: flex; flex-direction: column; }
.examples-groups { min-height: 0; overflow-y: auto; padding: 0.25rem; margin: 0 -0.25rem; }
.examples-title, .examples-intro, .examples-close { flex: none; }
.examples::backdrop { background: rgb(0 0 0 / 0.45); }
.examples-title { margin: 0 0 0.25rem; font-size: 1.125rem; }
.examples-intro { margin: 0 0 0.75rem; font-size: 0.875rem; }
.examples-groups { display: grid; gap: 0.75rem 1rem; margin-bottom: 0.75rem; }
.examples-group-title { margin: 0 0 0.375rem; font-size: 0.875rem; font-weight: 600; opacity: 0.8; }
.examples-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
/* Side by side on a wide screen, so every song shows without scrolling. */
@media (min-width: 48rem) {
  .examples { width: min(56rem, calc(100vw - 4rem)); }
  .examples-groups {
    grid-template-columns: repeat(var(--groups, 1), minmax(0, 1fr));
    grid-template-rows: auto repeat(var(--rows, 1), 1fr);
    gap: 0.5rem 1rem;
  }
  .examples-group, .examples-list { display: grid; grid-template-rows: subgrid; row-gap: 0.5rem; }
  .examples-group { grid-row: span var(--group-rows, 2); }
  .examples-group-title { margin: 0; }
  .examples-list { grid-row: span var(--rows, 1); }
  .examples-list > li { display: flex; }
  .example { height: 100%; justify-content: flex-start; }
}
/* In a short window the list scrolls anyway: rows fit their own cards and the frame is tighter. */
@media (min-width: 48rem) and (max-height: 30rem) {
  .examples { padding: 0.75rem 1rem; }
  .examples-groups { grid-template-rows: auto repeat(var(--rows, 1), auto); }
}
.example {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 1px solid var(--dock-line);
  border-radius: 0.375rem;
  cursor: pointer;
}
.example:hover, .example:focus-visible { border-color: var(--dock-ink); background: color-mix(in srgb, var(--dock-ink) 10%, transparent); }
.example-title { font-weight: 600; }
.example-by, .example-note { font-size: 0.875rem; }
.example-note { opacity: 0.8; }
.examples-close { margin-left: auto; display: flex; }

.noscript { margin: 2rem 1rem; text-align: center; color: var(--text); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}


/* Portrait phones and tablets: the guitar stands upright. Its layout box keeps the landscape shape
   and rotates about its center, so the width below is the guitar's length down the screen. A
   tablet keeps the desktop dock, a little taller so the fields leave room for a whole system. */
@media (orientation: portrait) and (max-width: 64rem) {
  :root { --body-h: 20rem; }
  .guitar {
    width: min(calc(100dvh - var(--bar-h) - var(--reserve)), calc((100vw - 2 * var(--edge)) * 1240 / 480));
    transform: rotate(90deg);
  }
}

@media (orientation: portrait) and (max-width: 48rem) {
  /* Enough for one six-string system under the read-only label; the guitar gets the rest. */
  :root { --body-h: min(17rem, 32dvh); }
  /* The tools take two rows on a phone: editing on the first, files on the second. */
  .app { --open-h: calc(var(--body-h) + var(--tools-h)); }
  .app[data-meta="open"] { --body-h: 64dvh; }
  .transport { gap: 0.25rem; padding: 0 0.5rem; }
  .btn { padding: 0 0.5rem; }
  .btn-play { flex: 1; min-width: 0; }
  .spacer { display: none; }
  .tempo { gap: 0.25rem; font-size: 0.75rem; }
  .tempo-input { width: 3.5rem; padding: 0 0.25rem; }
  .tools {
    position: absolute;
    left: 0;
    right: 0;
    /* The containing block is the transport's padding box, inside its 1px top border. */
    bottom: calc(100% + 1px);
    height: var(--tools-h);
    flex-wrap: wrap;
    align-content: center;
    padding: 0 0.5rem;
    gap: 0 0.25rem;
    background: var(--dock-bg);
    border-top: 1px solid var(--dock-line);
    transition: transform 320ms var(--ease-open), opacity 200ms linear, visibility 0s;
  }
  .tools .seg { margin-right: auto; }
  /* The first divider becomes the line break between the two rows. */
  .tools .rule:first-of-type { flex-basis: 100%; height: 0; margin: 0.25rem 0; background: none; }
  .seg span { min-width: 2.75rem; padding: 0 0.5rem; }
  .app[data-open="false"] .tools {
    transform: translateY(100%);
    transition: transform 240ms var(--ease-close), opacity 160ms linear, visibility 0s 240ms;
  }
  .dock-body { bottom: calc(var(--bar-h) + var(--tools-h)); }
}

/* Short landscape: the bar becomes a rail on the right edge and the body slides in on X. */
@media (orientation: landscape) and (max-height: 30rem) {
  :root {
    --rail-w: 3.5rem;
    --body-w: 18rem;
    --reserve: 3rem;
    --open-w: var(--body-w);
  }
  .app {
    --open-h: 0px;
    --guitar-shift: translateX(calc(var(--open-w) / -2));
    --foot-shift: translateX(calc(var(--open-w) / -2));
  }
  .stage { inset: 0 var(--rail-w) 0 0; }
  .stage-foot { padding-bottom: 0.25rem; }
  .credit { max-width: calc(100vw - var(--rail-w) - var(--body-w) - 1rem); margin: 0 auto; }
  .guitar {
    width: min(calc(100% - 2 * var(--edge)), calc((100dvh - var(--reserve)) * 1240 / 480));
  }
  .hint { display: none; }
  .dock { left: auto; top: 0; width: var(--rail-w); }
  .transport {
    flex-direction: column;
    height: 100%;
    padding: 0.5rem 0;
    gap: 0.25rem;
    border-top: 0;
    border-left: 1px solid var(--dock-line);
  }
  .btn-play { min-width: 2.75rem; padding: 0; }
  /* The rail is one control wide, so the unit sits under the number. */
  .tempo { flex-direction: column; gap: 0; font-size: 0.625rem; line-height: 1; }
  .tempo-input { width: 2.75rem; padding: 0; }
  .tools {
    position: absolute;
    top: 0;
    right: calc(100% + 1px);
    width: var(--body-w);
    height: var(--tools-h);
    flex-wrap: wrap;
    align-content: center;
    padding: 0 0.5rem;
    gap: 0 0.25rem;
    background: var(--dock-bg);
    border-left: 1px solid var(--dock-line);
    transition: transform 320ms var(--ease-open), opacity 200ms linear, visibility 0s;
  }
  .tools .seg { margin-right: auto; }
  .seg span { min-width: 2.75rem; padding: 0 0.5rem; }
  .app[data-open="false"] .tools {
    transform: translateX(100%);
    transition: transform 240ms var(--ease-close), opacity 160ms linear, visibility 0s 240ms;
  }
  .dock-body {
    top: var(--tools-h);
    bottom: 0;
    left: auto;
    right: var(--rail-w);
    width: var(--body-w);
    height: auto;
    border-top: 0;
    border-left: 1px solid var(--dock-line);
  }
  .app[data-open="false"] .dock-body { transform: translateX(100%); }
  .btn-toggle .icon { transform: rotate(-90deg); }
  .app[data-open="false"] .btn-toggle .icon { transform: rotate(90deg); }
  .btn[data-tip]::after {
    bottom: auto;
    top: 50%;
    left: auto;
    right: calc(100% + 0.375rem);
    transform: translateY(-50%);
  }
  .btn[data-tip].tip-end::after { right: calc(100% + 0.375rem); transform: translateY(-50%); }
  .tools .btn[data-tip]::after,
  .tools .btn[data-tip].tip-end::after {
    top: calc(100% + 0.125rem);
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
}

/* Phone portrait: the fields fold into a summary row that opens them, Title on its own line. */
@media (orientation: portrait) and (max-width: 48rem) {
  .meta { display: none; grid-template-columns: 1fr 1fr; row-gap: 0.25rem; }
  .meta .field:first-child { grid-column: 1 / -1; }
  .app[data-meta="open"] .meta { display: grid; }
  .meta-toggle {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 2.75rem;
    padding: 0 var(--pad);
    font: 0.875rem system-ui, -apple-system, "Segoe UI", sans-serif;
    color: inherit;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
  }
  .meta-toggle .mt-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .meta-toggle .icon { transition: transform 200ms; }
  .app[data-meta="open"] .meta-toggle .icon { transform: rotate(180deg); }
  .summary { display: none !important; }
}

/* Short landscape: the body is 18rem wide, so the fields stack as on a phone, always shown. */
@media (orientation: landscape) and (max-height: 30rem) {
  .meta { grid-template-columns: 1fr 1fr; row-gap: 0.25rem; }
  .meta .field:first-child { grid-column: 1 / -1; }
  .summary { display: none; }
  .app[data-open="false"] .spacer { display: block; }
  /* Two rows of tools share 18rem: the rules go, except the first, which breaks the rows. */
  .tools { padding: 0 0.25rem; gap: 0 0.125rem; }
  .tools .rule { display: none; }
  .tools .rule:first-of-type { display: block; flex-basis: 100%; height: 0; margin: 0.25rem 0; background: none; }
  .credit-icons [data-tip]::after {
    top: auto;
    bottom: calc(100% + 0.25rem);
    left: 50%;
    transform: translateX(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .text-area, .grid { scroll-behavior: auto; }
  .stage-inner, .stage-foot, .dock-body, .tools, .btn-toggle .icon, .meta-toggle .icon, .volume-range { transition: none !important; }
  [data-tip]::after { transition-duration: 0s; }
}

.print-root { display: none; }

/* Paper is measured in points and millimeters, not rem: a sheet has a fixed physical size and the
   type must stay the same whatever the screen's root font size is. At 10pt a monospaced character is
   about 6pt wide, so the 68-column lines of the real tabs take 410pt of the 510pt or so that remain
   after the margins on Letter and A4. */
@media print {
  @page { margin: 16mm 14mm; }
  html, body {
    height: auto;
    overflow: visible;
    background: #fff;
    color: #000;
  }
  .app { display: none; }
  .print-root {
    display: block;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 10pt;
    line-height: 1.25;
    color: #000;
    background: #fff;
  }
  .print-root pre {
    margin: 0 0 1.1em;
    font: inherit;
    white-space: pre;
  }
  /* A text run is usually the section label of the system after it, so it never ends a page alone. */
  .print-root .print-text { white-space: pre-wrap; overflow-wrap: anywhere; break-after: avoid; }
  .print-root .print-system { break-inside: avoid; }
  .print-heading { margin: 0 0 1.6em; break-after: avoid; }
  .print-title { margin: 0 0 0.3em; font: 700 16pt/1.2 system-ui, -apple-system, "Segoe UI", sans-serif; }
  .print-meta { margin: 0; font: 11pt/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
}
