:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #ecebe6;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: #dcdbd5;
  --accent: #2f6fde;
  --accent-ink: #ffffff;
  --chord: #1d1d1f;
  --rn: #8a5a00;
  --cursor-bar: rgba(47, 111, 222, .10);
  --cursor-beat: rgba(47, 111, 222, .85);
  --radius: 10px;
  --tap: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1c1f;
    --surface: #25262a;
    --surface-2: #303137;
    --text: #ececef;
    --muted: #a0a0a8;
    --line: #3a3b41;
    --accent: #6d9cff;
    --accent-ink: #0d1220;
    --chord: #ececef;
    --rn: #f0b45a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1c1f; --surface: #25262a; --surface-2: #303137; --text: #ececef; --muted: #a0a0a8;
  --line: #3a3b41; --accent: #6d9cff; --accent-ink: #0d1220; --chord: #ececef; --rn: #f0b45a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
button, select, input { font: inherit; color: inherit; }

/* ---------- buttons ---------- */
.icon-btn, .toggle, .btn, .seg button, .play {
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn { min-width: var(--tap); font-size: 22px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }
.toggle { padding: 0 12px; }
.toggle.on, .toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn { padding: 0 14px; display: inline-flex; align-items: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
button:disabled { opacity: .4; cursor: default; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 0 14px; background: var(--surface); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
/* Generated / Corrected: lives next to Piano/Original on wide screens, in the now bar on phones. */
.version-seg button { padding: 0 10px; }
@media (max-width: 640px) {
  .nowbar { flex-wrap: wrap; }
  #version-seg { flex: 1 0 100%; order: -1; }
  #version-seg button { flex: 1; min-height: 34px; padding: 0 8px; font-size: 13px; }
}

/* ---------- list ---------- */
#list-view { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
.list-head h1 { margin: 0 0 4px; font-size: 28px; }
.tagline { margin: 0; max-width: 62ch; }
.tagline .how-to { margin-left: 6px; white-space: nowrap; color: var(--accent); }
.song-list { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 12px; }
.song-list a {
  display: block; padding: 16px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); color: inherit; text-decoration: none;
}
.song-list a:active { background: var(--surface-2); }
.song-list .t { font-size: 19px; font-weight: 600; overflow-wrap: anywhere; }
.list-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.add-song, .restore-song { cursor: pointer; }
.list-sort { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.list-sort select {
  min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
/* Phones: the three front-page actions still fit on one row at 375px. */
@media (max-width: 480px) {
  .list-actions .btn { padding: 0 8px; }
}
.song-item { position: relative; }
.song-item.local a { border-left: 3px solid var(--rn); padding-right: 58px; }
.song-artist { margin-top: 1px; overflow-wrap: anywhere; }
.song-del {
  position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--muted); font-size: 18px; line-height: 1;
  cursor: pointer; touch-action: manipulation;
}
.song-del:active { background: var(--surface-2); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.warn { color: #9a5b00; background: #fbecd2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.warn { color: #f0b45a; background: #3b2f1c; } }
.song-added { margin-top: 6px; font-size: 12px; }
.last-backup { margin: 8px 0 0; }
.last-backup.warn { color: #9a5b00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .last-backup.warn { color: #f0b45a; } }

/* Bring-your-own: no server songs, nothing added yet. */
.empty-state {
  margin: 20px 0 0; padding: 20px 16px; border-radius: 14px; text-align: center;
  background: var(--surface); border: 1px dashed var(--line);
}
.empty-state p { margin: 0 0 12px; }
.empty-state p:last-child { margin-bottom: 0; }
.empty-lead { font-size: 19px; font-weight: 600; }
.empty-state code { padding: 1px 5px; border-radius: 5px; background: var(--surface-2); }
.empty-add { width: 100%; justify-content: center; }
.empty-restore { margin-top: 8px; }
#empty-converter { color: var(--accent); }

/* ---------- player layout ---------- */
/* Column flex, not a fixed grid: strips like #tracks are hidden per view, and
   with fixed grid rows that shifted the score into an auto row and squashed the transport. */
#player-view {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
#player-view > * { flex: none; min-width: 0; }
#player-view > .score-wrap { flex: 1 1 auto; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.title-block { flex: 1; min-width: 0; }
.song-title, #song-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-title { font-weight: 600; }

/* ---------- chord chart strip ---------- */
.nowbar {
  display: flex; align-items: stretch; gap: 10px;
  padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.where {
  flex: none; width: 92px; display: flex; flex-direction: column; justify-content: center; gap: 1px;
}
.where-sec { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.where-next { color: var(--muted); line-height: 1.2; }
.where-next.soon { color: var(--rn); font-weight: 600; }

.chord-grid {
  --cell-w: 96px;
  flex: 1; min-width: 0; display: flex; gap: 4px; overflow: hidden;
}
.bar-cell {
  flex: 1 0 calc(var(--cell-w) - 4px); min-width: 0;
  display: grid; grid-template-rows: 14px 1fr auto;
  padding: 2px 6px 3px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  touch-action: manipulation;
}
.bar-cell.past { opacity: .45; }
.bar-cell.now { background: var(--surface-2); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.bar-cell.sec-start { border-left: 3px solid var(--rn); }
.bar-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--rn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Each chord is a tap zone: equal share of the cell's width, full height, divider between.
   (The negative margin lets the zones reach the cell's edges past its padding.) */
.bar-chords { display: flex; align-items: stretch; min-width: 0; overflow: hidden; margin: 0 -6px; }
.bc {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center;
  padding: 0 6px; border-radius: 6px; overflow: hidden;
}
.bc + .bc { border-left: 1px solid var(--line); }
.bc:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.bc:active { background: color-mix(in srgb, var(--accent) 20%, transparent); }
/* Function first and big, name small underneath. */
.bc i {
  font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 20px; line-height: 1.15;
  color: var(--rn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bc b { font-size: 12px; font-weight: 600; color: var(--chord); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc.carry i { opacity: .5; }
.bc.carry b { font-weight: 400; color: var(--muted); }
.bc.carry b::before { content: "("; }
.bc.carry b::after { content: ")"; }
.bc.on i { color: var(--accent); font-weight: 700; }
.bc.on b { color: var(--accent); opacity: 1; }
/* Bars with a chord change get a wider cell and slightly smaller text. */
.bar-cell.multi { flex-grow: 1.6; flex-basis: calc(var(--cell-w) * 1.4); }
.bar-cell.multi .bc i { font-size: 17px; }
.bar-cell.multi .bc b { font-size: 11px; }
.bar-num { font-size: 10px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.tracks {
  display: flex; gap: 6px; overflow-x: auto; padding: 6px 12px; scrollbar-width: none;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.tracks::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 34px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.current { outline: 2px solid var(--accent); outline-offset: -2px; }
.chip.upnext { border: 2px dashed var(--rn); color: var(--rn); font-weight: 600; }

/* The score is always on white paper, even in dark mode. */
.score-wrap { position: relative; overflow: auto; background: #fff; color: #000; -webkit-overflow-scrolling: touch; }
#alphatab { min-height: 100%; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: #777; background: #fff; z-index: 5; }
.at-cursor-bar { background: var(--cursor-bar); }
.at-cursor-beat { background: var(--cursor-beat); width: 3px; }
.at-selection div { background: rgba(47, 111, 222, .18); }
.at-highlight * { fill: #2f6fde; stroke: #2f6fde; }

.transport {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.play { width: 56px; height: 56px; border-radius: 50%; font-size: 22px; background: var(--accent); color: var(--accent-ink); border: 0; }
.hands { display: flex; gap: 6px; }

/* Icon toggles (loop, metronome, count-in, volume): stroke icons in currentColor. */
.icon-toggle { width: var(--tap); padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon-toggle svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; }
.icon-toggle svg .fill { fill: currentColor; stroke: none; }
/* Count-in: four digits overlapping like a fanned stack. */
.count-svg text {
  font: 800 11px/1 system-ui, -apple-system, sans-serif; fill: currentColor; stroke: var(--surface);
  stroke-width: 2.6px; paint-order: stroke;
}
.toggle.on .count-svg text, .toggle[aria-pressed="true"] .count-svg text { stroke: var(--accent); }

/* Speed: −5 −1 [value] +1 +5 */
.speed { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.speed .step {
  min-width: 36px; min-height: 40px; padding: 0 4px; font-size: 14px; font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 8px; cursor: pointer;
  touch-action: manipulation;
}
.speed .step:active { background: var(--surface-2); }
.speed-value {
  min-width: 72px; min-height: 40px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.speed-value.changed { color: var(--rn); border-color: var(--rn); }

/* Volume button + popover panel, and the sections popover (same pattern) */
.vol, .sec { position: relative; }
.vol-panel, .sec-panel {
  position: absolute; right: 0; bottom: calc(100% + 10px); z-index: 40;
  padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
}
.vol-panel { width: min(320px, calc(100vw - 24px)); }
.sec-panel {
  width: min(340px, calc(100vw - 24px)); max-height: min(50dvh, 360px); overflow: auto;
  display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
}
.sec-btn { min-width: var(--tap); font-variant-numeric: tabular-nums; }
/* Panel chips: label big, name and bar small underneath. */
.sec-panel .sec-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 58px; padding: 4px; border-radius: 10px; line-height: 1.2; white-space: normal;
}
.sec-chip b { font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.sec-chip .sec-name, .sec-chip .sec-bar {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sec-chip .sec-name { font-size: 10px; font-weight: 600; color: var(--text); }
.sec-chip .sec-bar { font-size: 9px; color: var(--muted); }
.sec-chip.upnext b, .sec-chip.upnext .sec-name { color: var(--rn); }
.sec-chip.on .sec-name, .sec-chip.on .sec-bar { color: var(--accent-ink); opacity: .9; }
.vol-row { display: grid; grid-template-columns: 32px 84px 1fr 30px; align-items: center; gap: 6px; min-height: 36px; }
.mute-btn {
  width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); cursor: pointer;
  touch-action: manipulation;
}
.mute-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.mute-btn svg .fill { fill: currentColor; stroke: none; }
.mute-btn .off-only { display: none; }
.mute-btn.muted { background: #c92a2a; border-color: #c92a2a; color: #fff; }
.mute-btn.muted .off-only { display: inline; }
.mute-btn.muted .on-only { display: none; }
.vol-row.is-muted .vol-name, .vol-row.is-muted .vol-num { opacity: .45; text-decoration: line-through; }
.vol-row.is-muted input { opacity: .35; }
#vol-btn.muted { color: #c92a2a; }
.vol-row.master .vol-name { font-weight: 700; }
.vol-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vol-row input { width: 100%; accent-color: var(--accent); }
.vol-num { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.vol-sep { margin: 8px 0 2px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.vol-note { margin: 8px 0 0; }

@media (max-width: 640px) {
  .topbar { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .topbar .seg button { padding: 0 10px; }
  .song-title { font-size: 15px; }
  .nowbar { gap: 6px; padding: 4px 8px; }
  /* Phones: give the whole width to the chart; section tags in the cells carry the section info. */
  .where { display: none; }
  .chord-grid { --cell-w: 66px; gap: 3px; flex-basis: 100%; }
  .bar-cell { padding: 2px 4px 2px; }
  .bar-chords { margin: 0 -4px; }
  .bc { padding: 0 4px; }
  .bc i { font-size: 16px; }
  .bc b { font-size: 10px; }
  .bar-cell.multi .bc i { font-size: 14px; }
  .bar-cell.multi .bc b { font-size: 10px; }
  /* Phones: row 1 = play, back, loop, metronome, count-in, RH, LH, volume;
     row 2 = speed stepper + sections button. */
  .transport { gap: 5px; padding-left: 8px; padding-right: 8px; }
  .play { width: 46px; height: 46px; }
  .transport .icon-btn, .transport .icon-toggle { min-width: 38px; width: 38px; }
  .transport .hands .toggle { padding: 0 8px; }
  .vol { order: 5; }
  .speed { order: 10; margin-left: 0; }
  .speed .step { min-width: 30px; padding: 0 2px; font-size: 13px; }
  .speed-value { min-width: 58px; padding: 0 4px; }
  .sec { order: 11; margin-left: auto; }
}

/* ---------- sheets ---------- */
dialog.sheet {
  width: min(560px, 100vw); max-height: 85dvh; margin: auto auto 0; padding: 12px 16px 24px;
  border: 0; border-radius: 16px 16px 0 0; background: var(--surface); color: var(--text);
}
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 16px; } }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet h3 { margin: 18px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; min-height: 40px; flex-wrap: wrap; }
.row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.row input[type="number"] { width: 5em; min-height: 36px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.row input[type="text"] {
  flex: 1 1 12em; min-width: 0; min-height: 38px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.row select { min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 6px; }
.cmd {
  margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- edit mode ---------- */
.edit-btn { position: relative; }
.edit-btn.on, .edit-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.edit-count {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--rn); color: #000; font-size: 11px; font-weight: 700; line-height: 18px;
}
.editbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 8px 12px; background: var(--surface-2); border-top: 2px solid var(--accent);
}
.edit-info { flex: 1 1 260px; min-width: 0; font-size: 14px; }
.edit-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.edit-actions .btn { min-height: 40px; padding: 0 10px; }
#alphatab { position: relative; }
.edit-hl {
  position: absolute; z-index: 20; pointer-events: none; border-radius: 50%;
  border: 3px solid #e8590c; box-shadow: 0 0 0 3px rgba(232, 89, 12, .25);
}
#player-view.editing .score-wrap { outline: 3px solid var(--accent); outline-offset: -3px; }
#player-view.editing .bc { cursor: pointer; border-bottom: 1px dashed var(--muted); }
.bc.edited b::after { content: "✎"; font-size: 10px; margin-left: 2px; color: var(--rn); }

.chord-edit-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
#chord-input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 12px; font-size: 22px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.chord-preview { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 22px; color: var(--rn); min-width: 4ch; }
.chord-error { color: #c92a2a; margin: 0; }
.chord-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.chord-picks .chip i { font-family: Georgia, serif; color: var(--rn); margin-left: 2px; }
.chord-picks .chip:hover { border-color: var(--accent); }

/* ---------- recording player (recording.js) ---------- */
.rec { background: var(--surface); border-top: 1px solid var(--line); padding: 4px 12px 6px; }
.rec-head { display: flex; align-items: center; gap: 10px; min-height: 26px; }
.rec-toggle { border: 0; background: none; padding: 2px 0; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text); }
.rec-toggle .chev { display: inline-block; transition: transform .15s; }
.rec.collapsed .rec-toggle .chev { transform: rotate(-90deg); }
.rec.collapsed .rec-body { display: none; }
.rec-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-body { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.rec-play {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--accent); background: var(--surface);
  color: var(--accent); font-size: 14px; cursor: pointer; touch-action: manipulation;
}
.rec-line { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; min-width: 0; }
.rec-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.4em; }
#rec-time { text-align: right; }
.rec-seek-wrap { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; }
.rec-seek { width: 100%; accent-color: var(--accent); position: relative; z-index: 1; }
.rec-loop-band {
  position: absolute; top: 50%; height: 14px; transform: translateY(-50%); border-radius: 4px;
  background: color-mix(in srgb, var(--rn) 35%, transparent); border: 1px solid var(--rn);
}
.rec-loop-band.off { background: transparent; border-style: dashed; }
.rec-loop { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; }
.rec-end { display: inline-flex; align-items: center; gap: 2px; }
.rec-loop .step {
  min-height: 32px; min-width: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.rec-loop .step.set { border-color: var(--rn); color: var(--rn); }
.rec-loop .icon-toggle { width: 36px; min-height: 32px; }
.end-x {
  min-height: 32px; min-width: 28px; padding: 0 4px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer;
  touch-action: manipulation;
}
.end-x:active { background: var(--surface-2); }
.loop-del { color: var(--text); }
.rec-loops {
  min-height: 32px; max-width: 190px; min-width: 0; padding: 0 4px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); font-size: 12px; font-variant-numeric: tabular-nums;
}
.rec-rate { min-height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 0 4px; font-size: 13px; }
@media (max-width: 640px) {
  .rec { padding: 2px 8px 4px; }
  /* Two rows: play, A, B, loop, speed; then loop picker, delete, time + seek bar. */
  .rec-body { gap: 5px; }
  .rec-loop { display: contents; }
  .rec-end { order: 1; }
  #rec-loop { order: 3; }
  .rec-rate { order: 4; margin-left: auto; }
  #rec-loops { order: 5; flex: 0 1 158px; max-width: 158px; font-size: 11px; }
  #rec-loop-del { order: 6; }
  .rec-line { order: 10; flex: 1 1 140px; }
  .rec-loop .step { padding: 0 4px; font-size: 11px; }
  .end-x { min-width: 22px; }
}
/* Options → Edits: every edit on this device, newest first, each with Undo */
.edits-list { list-style: none; margin: 6px 0; padding: 0; max-height: 220px; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; }
.edits-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 6px 4px 10px; font-size: 13px; }
.edits-list li + li { border-top: 1px solid var(--line); }
.edits-list .btn { min-height: 32px; padding: 0 10px; font-size: 13px; }
