/* Layout and controls follow the jt4000m / rk100s pages; accent is the GO:KEYS 3 turquoise body colour (#64C4BF).
   iPad (AUv3 WebKit, iOS 15) is older than desktop WebKit: no container units/queries, no `inset`; use % and @media.
   System fonts only: pages inside the plugin have no internet. */
:root {
  --bg: #24262b;
  --side: #1c1d21;
  --side-dark: #121316;
  --panel: #2d2f35;
  --panel-2: #24262b;
  --border: #4a4d56;
  --accent: #64c4bf;
  --accent-soft: #9fe0da;
  --on-accent: #0b2422;   /* text on accent backgrounds: white is unreadable on this light green */
  --text: #ececef;
  --text-dim: #a9adb8;
  --lcd: #0f1013;
  --lcd-text: #ffd9a0;
  --title-font: "Arial Black", "Helvetica Neue", Helvetica, sans-serif;
  --lcd-font: "Menlo", "Consolas", monospace;
  --ui-font: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
input, textarea { -webkit-user-select: text; user-select: text; }
/* No zooming on the iPad: pan-x pan-y leaves out pinch zoom and double-tap zoom (app.js also blocks Safari's pinch gesture). */
html, body { height: 100%; }
html { touch-action: pan-x pan-y; }
body {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  margin: 0; display: flex; font-family: var(--ui-font); font-size: 13px; background: var(--bg); color: var(--text);
}

/* ---------- left column: tones ---------- */
.side {
  width: 260px; flex: none; height: 100vh;   /* narrow enough for 4 bars on the right on an iPad in landscape (1024px) */ display: flex; flex-direction: column; gap: 6px;
  background: var(--side); padding: 10px 8px 6px; border-right: 4px solid var(--side-dark);
}
.brand { display: flex; align-items: flex-start; gap: 12px; }
.logo { display: flex; flex-direction: column; line-height: 1; }
.logo .model { font: 900 26px/1 var(--title-font); letter-spacing: -.5px; }
.chan { margin-left: auto; display: flex; align-items: center; gap: 6px; font: 700 10px var(--ui-font); color: var(--text-dim); letter-spacing: .5px; }
.chan select {
  -webkit-appearance: none; appearance: none; border-radius: 0; margin: 0; cursor: pointer;
  background: var(--lcd); color: var(--lcd-text); -webkit-text-fill-color: var(--lcd-text); border: 1px solid var(--border);
  font: 16px/20px var(--lcd-font); padding: 1px 6px; min-width: 42px; text-align: center;
}

.port { display: flex; align-items: center; gap: 6px; font: 700 10px var(--ui-font); color: var(--text-dim); letter-spacing: .5px; }
.port select {
  -webkit-appearance: none; appearance: none; border-radius: 0; margin: 0; cursor: pointer; flex: 1; min-width: 0;
  background: var(--lcd); color: var(--lcd-text); -webkit-text-fill-color: var(--lcd-text); border: 1px solid var(--border);
  font: 13px/20px var(--lcd-font); padding: 1px 6px;
}
.status-line { font-size: 11px; min-height: 18px; display: flex; gap: 6px; align-items: center; color: var(--text-dim); }
.status { padding: 1px 7px; border-radius: 9px; white-space: nowrap; cursor: default; }
.status.off { background: #55575d; color: #ddd; }
.status.on { background: #2f8f3a; color: #fff; }
.status.warn { background: #d08a00; color: #fff; }
#status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search { position: relative; display: flex; gap: 6px; }
.search input {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; margin: 0; border-radius: 0;
  background: var(--lcd); color: var(--text); border: 1px solid var(--border);
  font: 16px var(--ui-font); padding: 6px 30px 6px 8px;   /* 16px: iOS doesn't zoom into the field */
}
.search input:focus { outline: none; border-color: var(--accent); }
.search .clear {
  position: absolute; top: 0; right: 42px; width: 30px; height: 100%; border: 0; background: none; cursor: pointer;
  color: var(--text-dim); font: 20px/1 var(--ui-font); padding: 0;
}
/* Star next to the search field: show only the favorites. */
.star.fav-only { width: 36px; margin: 0; padding: 0; border: 1px solid var(--border); background: var(--lcd); display: flex; align-items: center; justify-content: center; }
.star.fav-only.on { border-color: var(--accent); }

/* The selected tone, always in view above the list. */
.cur-tone { flex: none; display: flex; align-items: baseline; gap: 8px; padding: 3px 6px; background: var(--lcd); }
.cur-num { flex: none; color: var(--accent-soft); font: 12px/26px var(--lcd-font); }
.cur-name { flex: 1; min-width: 0; color: var(--lcd-text); font: 15px/26px var(--lcd-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative;
  background: var(--lcd); border: 1px solid var(--border); outline: none;
}
.list .cat {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 1;
  background: #142a29; color: var(--accent-soft); font: 700 10px/20px var(--ui-font); letter-spacing: .8px;
  text-transform: uppercase; padding: 0 8px; border-bottom: 1px solid #1f403e;
}
.row { display: flex; gap: 10px; padding: 0 8px; border-bottom: 1px solid #1b1c20; cursor: pointer; line-height: 26px; }
.row:hover { background: #1c1e24; }
.row .num { flex: none; width: 5.5ch; color: #7c808b; font: 12px/26px var(--lcd-font); }   /* the tone's short code */
.row.cur .num { color: #1d4a47; }
.row .name { flex: 1; min-width: 0; color: var(--lcd-text); font: 15px/26px var(--lcd-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Favorite star: grey until tapped, then green. Negative margins widen the tap target into the row's gap and padding. */
.row-star { flex: none; width: 28px; margin: 0 -8px 0 -6px; text-align: center; color: #565a64; font: 16px/26px var(--ui-font); touch-action: manipulation; }
.row-star:hover { color: var(--accent-soft); }
.row-star.on { color: var(--accent); }
.row-star svg { display: inline-block; vertical-align: middle; fill: currentColor; }
.row.cur { background: var(--accent); box-shadow: inset 3px 0 0 var(--on-accent); }
.row.cur .row-star { color: #3a8580; }   /* the selected row is green, so its stars need their own colours */
.row.cur .row-star.on { color: #fff; }
.row.cur .name { color: var(--on-accent); }
.empty { color: var(--text-dim); padding: 18px; font-size: 13px; line-height: 1.4; }

/* ---------- right: current tone + CC grid ---------- */
.details { flex: 1; min-width: 0; height: 100vh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px; }
.details.on-tones { background: #16171a; }   /* TONE tab: darker so the sections stand out */
/* Favorites filter star: outline when off, filled green when on. Padding = bigger tap target. */
.star { -webkit-appearance: none; appearance: none; flex: none; border: 0; background: none; padding: 4px; margin: -4px 0; cursor: pointer; line-height: 0; }
.star svg path { fill: none; stroke: var(--text-dim); stroke-width: 1.6; stroke-linejoin: round; }
.star:hover svg path { stroke: var(--accent); }
.star.on svg path { fill: var(--accent); stroke: var(--accent); }
.det-note { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }

/* CC sections flow into as many columns as fit (>= 320px each, filled top to bottom so sections of different
   heights pack without gaps); inside a section the controls wrap in their own grid. inline-block + width 100%
   keeps WebKit from splitting a section across columns. */
.cc-grid { -webkit-column-width: 320px; column-width: 320px; -webkit-column-gap: 10px; column-gap: 10px; }
.sect {
  display: inline-block; width: 100%; margin: 0 0 10px; -webkit-column-break-inside: avoid; break-inside: avoid;
  border: 1px solid var(--border); border-top: 2px solid var(--accent); background: linear-gradient(var(--panel), var(--panel-2));
}
.sect-title {   /* slanted tab, as on the jt4000m / rk100s pages */
  display: inline-block; vertical-align: top; background: var(--accent); color: var(--on-accent);
  font: 700 11px var(--ui-font); letter-spacing: .8px; padding: 4px 30px 4px 9px;
  -webkit-clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 100%, 0 100%); clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 100%, 0 100%);
}
/* Dim note in an empty area (the Chords tab uses it). */
.fav-empty { color: #7c808b; font-size: 12px; padding: 6px 0; }
.sect-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px 14px; padding: 8px 10px 10px; }
.sect-body.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.btn .btn-cc { font-weight: 400; opacity: .65; margin-left: 2px; }
.card { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cc-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.cc-num { flex: none; font: 700 10px var(--ui-font); color: var(--accent-soft); letter-spacing: .4px; }
.cc-name { min-width: 0; font: 700 12px var(--ui-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.unknown .sval { color: #7c808b; }   /* not sent or received yet: showing the default */

.btn {
  -webkit-appearance: none; appearance: none; cursor: pointer; border: 1px solid #111; border-radius: 3px; margin: 0;   /* iPad WebKit gives buttons a default margin */
  padding: 4px 10px; font: 700 12px var(--ui-font); color: #fff; -webkit-text-fill-color: #fff;
  background: linear-gradient(#5a5d66, #383a41); min-height: 30px;
}
.btn:active { background: linear-gradient(#383a41, #5a5d66); }
.btn.act { background: linear-gradient(#86d6d1, #4aa8a2); border-color: #1d4a47; color: var(--on-accent); -webkit-text-fill-color: var(--on-accent); }
.btn.act:active { background: linear-gradient(#4aa8a2, #86d6d1); }
.btn.onoff { width: 70px; font-family: var(--lcd-font); letter-spacing: 1px; }
.btn.onoff.on { background: linear-gradient(#86d6d1, #4aa8a2); border-color: #1d4a47; color: var(--on-accent); -webkit-text-fill-color: var(--on-accent); }
.card.toggle.unknown .btn.onoff { color: #aaa; -webkit-text-fill-color: #aaa; }

/* Horizontal sliders (vertical/rotated ranges handle touch badly on iOS). touch-action: pan-y lets a vertical swipe
   still scroll the page while a sideways drag moves the slider. --pct is set inline and while dragging. */
.srow { display: flex; align-items: center; gap: 8px; }
.srow .sval { flex: none; width: 4ch; text-align: right; font: 15px/26px var(--lcd-font); color: var(--lcd-text); cursor: pointer; }
.srow input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 26px; margin: 0; padding: 0;
  background: transparent; cursor: pointer; touch-action: pan-y;
}
.srow input[type=range]::-webkit-slider-runnable-track {
  height: 10px; border: 1px solid #45484f;
  background: linear-gradient(90deg, var(--accent) 0, var(--accent) var(--pct, 0%), var(--lcd) var(--pct, 0%));
}
.srow input[type=range]::-moz-range-track {
  height: 10px; border: 1px solid #45484f;
  background: linear-gradient(90deg, var(--accent) 0, var(--accent) var(--pct, 0%), var(--lcd) var(--pct, 0%));
}
.srow input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 24px; margin-top: -8px;
  background: linear-gradient(#f4f4f6, #b9bcc5); border: 1px solid #111; border-radius: 2px; box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.srow input[type=range]::-moz-range-thumb { width: 16px; height: 24px; background: linear-gradient(#f4f4f6, #b9bcc5); border: 1px solid #111; border-radius: 2px; }

.hint { color: #7c808b; font-size: 11px; margin: 12px 0 4px; }

/* Narrow windows: the tone list on top, the CCs below. */
@media (max-width: 640px) {
  body { flex-direction: column; height: auto; }
  .side { width: auto; height: 50vh; border-right: 0; border-bottom: 4px solid var(--side-dark); }
  .details { height: auto; overflow: visible; }
  .cc-grid { -webkit-column-width: auto; column-width: auto; }
}

/* ---------- tabs + chords ---------- */
.tabs { display: flex; gap: 4px; margin: 0 0 12px; padding-right: 50px; border-bottom: 2px solid var(--accent); }
.tab {
  -webkit-appearance: none; appearance: none; cursor: pointer; border: 1px solid var(--border); border-bottom: 0;
  background: var(--panel-2); color: var(--text-dim); -webkit-text-fill-color: var(--text-dim);
  font: 700 11px var(--ui-font); letter-spacing: .8px; padding: 7px 16px; border-radius: 3px 3px 0 0;
}
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); -webkit-text-fill-color: var(--on-accent); }
.chords-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chords-tools .set { margin-left: 12px; }
.btn.xfer { display: inline-flex; align-items: center; gap: 5px; letter-spacing: .5px; }
.btn.xfer svg { flex: none; fill: currentColor; }
.btn:disabled { opacity: .4; cursor: default; }
.chords-info { font-size: 12px; color: var(--text-dim); margin: 10px 0 4px; }
/* Song name: plain title + Rename button; the button opens a visible field with Save / Cancel (no reliance on blur or
   keyboard events, which are unreliable in the iPad plugin's web view). */
.chords-title { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.chords-name { min-width: 0; font: 900 22px/1.15 var(--title-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 10px; }
.name-input {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 12em; max-width: 34ch; margin: 0; border-radius: 0;
  background: var(--lcd); color: var(--lcd-text); -webkit-text-fill-color: var(--lcd-text); border: 1px solid var(--accent);
  font: 18px var(--lcd-font); padding: 6px 8px;   /* 16px+ so iOS doesn't zoom in */
}
.name-input:focus { outline: none; }
.chords-title .btn, .name-form .btn { min-height: 36px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bars-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.bar { border: 1px solid var(--border); border-top: 2px solid var(--accent); background: var(--lcd); padding: 4px 6px 6px; }
.bar.now { background: var(--accent); }
.bar-head { display: flex; justify-content: space-between; font: 700 10px var(--ui-font); color: #7c808b; letter-spacing: .5px; }
.bar-var { color: var(--accent-soft); }
.bar.now .bar-head, .bar.now .bar-var { color: var(--on-accent); }
/* Repeat signs: a solid line down the whole edge of the bar with two dots beside it. The closing sign is the mirror image. */
.bar.rep-open, .bar.rep-close { position: relative; --rep: var(--accent); }
.bar.now.rep-open, .bar.now.rep-close { --rep: var(--on-accent); }
.bar.lone-open::before, .bar.lone-close::after { --rep: #7c808b; }   /* a sign with no partner */
.bar.now.lone-open::before, .bar.now.lone-close::after { --rep: #2f6f6b; }
.bar.rep-open { padding-left: 22px; }
.bar.rep-close { padding-right: 22px; }
.bar.rep-open::before, .bar.rep-close::after {
  content: ""; position: absolute; top: -2px; bottom: -1px; width: 18px; pointer-events: none;
  background:
    linear-gradient(var(--rep), var(--rep)) 0 0 / 6px 100% no-repeat,
    radial-gradient(circle, var(--rep) 3px, transparent 3.6px) 9px calc(50% - 9px) / 8px 8px no-repeat,
    radial-gradient(circle, var(--rep) 3px, transparent 3.6px) 9px calc(50% + 9px) / 8px 8px no-repeat;
}
.bar.rep-open::before { left: -1px; }
.bar.rep-close::after { right: -1px; -webkit-transform: scaleX(-1); transform: scaleX(-1); }
.bar-num { flex: none; }
.bar-right { flex: none; display: flex; align-items: baseline; gap: 8px; margin-left: auto; }
.rep-end { white-space: nowrap; }
/* Variation or fill on each pass of a repeat: bright = set on this bar, dim = carried on from an earlier bar. */
.bar-passes { flex: 0 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 0 6px; margin: 0 6px; font: 700 10px/14px var(--ui-font); color: #7c808b; }
.pass-var { padding: 0 3px; border: 1px solid transparent; border-radius: 3px; white-space: nowrap; }
.pass-var b { color: var(--text-dim); }
.pass-var.own { color: var(--accent-soft); }
.pass-var.sel { border-color: var(--accent); }
.pass-var.play { background: var(--on-accent); color: var(--accent-soft); }
.bar.now .pass-var { color: var(--on-accent); }
.bar.now .pass-var b { color: inherit; }
.bar.now .pass-var.play { color: var(--accent-soft); }
.beats { display: flex; gap: 3px; margin-top: 4px; }
/* A beat with a chord takes the width its name needs; empty (held) beats share what's left, down to 18px each.
   Only when the names don't fit even then is one cut off with "…". */
.beats .beat { flex: 1 1 0; min-width: 18px; }
.beats .beat:not(.held) { flex: 1 1 auto; min-width: 0; }
.beat { font: 16px/26px var(--lcd-font); color: var(--lcd-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Beat cells are buttons, big enough to tap on the iPad. */
button.beat {
  -webkit-appearance: none; appearance: none; margin: 0; min-width: 0; min-height: 40px; padding: 0 2px; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid #2a2c32; border-radius: 3px; -webkit-text-fill-color: currentColor; touch-action: manipulation;
}
button.beat:hover { border-color: var(--border); }
button.beat.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.beat.held { color: #4a4d56; }
.bar.now .beat { color: var(--on-accent); }
.bar.now .beat.held { color: #2f6f6b; }
.btn.play { width: 44px; padding: 0; display: flex; align-items: center; justify-content: center; }
.btn.play svg { fill: currentColor; }
.btn.play .ico-stop, .btn.play.on .ico-play { display: none; }
.btn.play.on .ico-stop { display: inline; }
.btn.play.on { background: linear-gradient(#86d6d1, #4aa8a2); border-color: #1d4a47; color: var(--on-accent); -webkit-text-fill-color: var(--on-accent); }
.chords-settings { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; }
.set { display: flex; align-items: center; gap: 6px; }
.set-label { font: 700 10px var(--ui-font); color: var(--text-dim); letter-spacing: .5px; }
/* Intro / loop / ending fits a phone's width on one line: tighter buttons, and INTRO / ENDING written vertically on
   either side of the pill (INTRO reads upward, ENDING downward). */
.chords-settings .pill .btn { min-width: 0; padding-left: 9px; padding-right: 9px; }
.chords-settings #set-loop { min-width: 0; }
.chords-settings .set-label { -webkit-writing-mode: vertical-rl; writing-mode: vertical-rl; font-size: 9px; line-height: 1; }
.chords-settings .set-label:first-child { transform: rotate(180deg); }
.set-val { min-width: 3ch; text-align: center; font: 16px/30px var(--lcd-font); color: var(--lcd-text); background: var(--lcd); border: 1px solid var(--border); padding: 0 6px; }
.bar.section { border-top-color: var(--accent-soft); }
.chord-editor.section .bar-only { display: none; }   /* the intro and ending only have a chord */
/* Intro, loop and ending as one long pill: SHORT|LONG||LOOP||SHORT|LONG. */
.set.form { flex-wrap: wrap; }
.pill { display: inline-flex; border: 1px solid #111; border-radius: 16px; overflow: hidden; }
.pill-part { display: inline-flex; }
.pill .btn { border: 0; border-radius: 0; font-family: var(--lcd-font); letter-spacing: 1px; min-width: 58px; }
.pill-part .btn + .btn { border-left: 1px solid #111; }
.pill .set-val { min-width: 58px; border: 0; border-left: 1px solid #111; border-right: 1px solid #111; }   /* transpose value */
#set-loop { border-left: 3px solid #111; border-right: 3px solid #111; min-width: 68px; }
.pill .btn.on { background: linear-gradient(#86d6d1, #4aa8a2); color: var(--on-accent); -webkit-text-fill-color: var(--on-accent); }

/* Chord editor: docked at the bottom of the Chords tab (sticky, so it stays in view while the grid scrolls). */
.chord-editor {   /* in the left column, in place of the tones / songs while a beat is selected */
  gap: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 10px;
}
/* Where the editor or the MIDI settings start, below the title: a thin turquoise line, no box. */
.chord-editor, .settings-pane { border-top: 3px solid var(--accent); padding-top: 10px; margin-top: 4px; }
/* While the chord editor or the MIDI settings are open they take over the left column: the logo, gear and connection
   badge go, and so does the line that set the panel off from them. The status text stays, at the bottom, because the
   page's messages ("Sent.", refusals) show there. */
.side.takeover .brand, .side.takeover #conn-status { display: none; }
.side.takeover .status-line { order: 10; }
.side.takeover .chord-editor, .side.takeover .settings-pane { border-top: 0; margin-top: 0; padding-top: 0; }
.ed-top { display: flex; align-items: center; margin-bottom: 4px; }
#ed-close { margin-left: auto; }   /* upper right, like the settings panel's */
.chord-editor .pill.ed-pill { display: flex; width: 100%; }
.chord-editor .pill.ed-pill .btn { flex: 1; min-width: 0; }
.chord-editor .ed-pos { flex: none; min-width: 58px; }
.chord-editor .ed-row { flex-direction: column; gap: 2px; margin-top: 4px; }   /* tight: phones have little height */
.chord-editor .ed-label { width: auto; padding-top: 0; }
.chord-editor .ed-btns { width: 100%; }
.chord-editor .ed-btns .btn.ed { flex: 1 0 28px; min-width: 0; padding: 0 2px; }
.chord-editor .ed-group { margin: 0; padding: 0; background: none; border: 0; border-radius: 0; }   /* no band: BAR lines up with the other rows */
.chord-editor .ed-select { flex: 1; }
.chord-editor .pill.ed-style-pill { display: grid; grid-template-columns: repeat(10, 1fr); width: 100%; border-radius: 10px; }
.chord-editor .pill.ed-style-pill .btn { grid-column: span 2; }                  /* — (default) V1 V2 V3 V4 on one line */
.chord-editor .pill.ed-style-pill .btn:nth-child(n+6) { grid-column: span 5; }   /* Fill Up, Fill Down below */
.chord-editor #ed-rep-start, .chord-editor #ed-rep-end, .chord-editor .ed-pass .btn.ed { flex: 0 1 56px; min-width: 32px; }
.chord-editor #ed-rep-start, .chord-editor #ed-rep-end { flex-basis: 84px; min-width: 48px; }   /* |: :| half as wide again */
.chord-editor .ed-rep-row { flex-direction: row; gap: 12px; }   /* REPEAT and PASS side by side, each label over its buttons */
.chord-editor .ed-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chord-editor .ed-pass-col { flex: 1; }
.chord-editor .ed-col .ed-btns { flex-wrap: nowrap; }
.chord-editor .ed-btns .btn.ed.acc { flex: 0 0 44px; }
.chord-editor .ed-root-row { display: flex; flex-wrap: nowrap; gap: 0; width: 100%; }   /* hold + C-B: never split */
.chord-editor .ed-root-row .btn.ed { flex: 1 1 0; min-width: 0; }
/* ROOT and TYPE buttons touch: no gap between them or between their lines. */
.chord-editor #ed-root, .chord-editor #ed-type { gap: 0; }
/* …as pills like VARIATION: one rounded outline per line (C-B, sharp/flat, the six types), square buttons inside
   divided by one 1px line. The "more…" menu stays on its own below. */
.chord-editor .ed-pill-row { display: flex; flex-wrap: nowrap; border: 1px solid #111; border-radius: 10px; overflow: hidden; }
.chord-editor #ed-type .ed-pill-row { width: 100%; }
.chord-editor .ed-pill-row .btn.ed { border: 0; border-radius: 0; margin: 0; flex: 1 1 0; min-width: 0; }
.chord-editor .ed-pill-row .btn.ed + .btn.ed { border-left: 1px solid #111; }
.chord-editor .ed-acc-row { margin-top: 4px; }
.chord-editor .ed-acc-row { flex: none; width: 92px; }   /* fixed: older WebKit sized it to one button and cut off the flat */
.chord-editor .ed-acc-row .btn.ed.acc { flex: none; width: 45px; min-width: 0; margin: 0; }
.chord-editor .ed-rep-row .ed-pill-row .btn.ed { flex: 0 0 84px; }   /* |: :| as a pill, each 84px wide */
.chord-editor #ed-type-more { margin-top: 4px; }
.chord-editor #ed-type-more, .chord-editor #ed-bass { flex: 0 0 calc(50% - 2px); min-width: 0; }
.chord-editor .pill.ed-style-pill .btn { padding: 0 2px; min-height: 36px; border-top: 1px solid #111; }
.ed-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ed-select {
  -webkit-appearance: none; appearance: none; border-radius: 3px; margin: 0; cursor: pointer; min-width: 84px; min-height: 40px;
  background: var(--lcd); color: var(--lcd-text); -webkit-text-fill-color: var(--lcd-text); border: 1px solid var(--border);
  font: 16px/20px var(--lcd-font); padding: 1px 10px;
}
.ed-select.on { background: linear-gradient(#86d6d1, #4aa8a2); border-color: #1d4a47; color: var(--on-accent); -webkit-text-fill-color: var(--on-accent); }
.ed-label.ed-inline { width: auto; margin-left: 12px; }
/* Bar navigation as one pill: three buttons, the position (measure:beat), three buttons. */
.pill.ed-pill { flex: none; border-radius: 21px; }
.pill.ed-pill .btn { min-width: 40px; min-height: 40px; padding: 0 4px; letter-spacing: 0; white-space: nowrap; touch-action: manipulation; }
.pill.ed-pill .btn + .btn { border-left: 1px solid #111; }
.ed-pos {
  min-width: 72px; padding: 0 8px; text-align: center; white-space: nowrap; background: var(--lcd); color: var(--lcd-text);
  font: 16px/40px var(--lcd-font); border-left: 1px solid #111; border-right: 1px solid #111;
}
.btn.ed-nav { min-width: 34px; min-height: 40px; padding-left: 4px; padding-right: 4px; white-space: nowrap; }
#ed-del-bar { min-width: 44px; }   /* upper left, away from the other buttons so it isn't tapped by mistake */
#ed-clear { flex: none; width: 100%; min-height: 40px; margin-top: 14px; white-space: nowrap; }   /* at the bottom, away from the other buttons */
#ed-clear.armed { background: linear-gradient(#d0584c, #a8352b); border-color: #5a1510; }   /* waiting for the second tap */
.btn.ed-nav svg { fill: currentColor; vertical-align: middle; }
/* The bar's variation or fill as one pill. It wraps instead of clipping when the window is too narrow for one line. */
.pill.ed-style-pill { flex-wrap: wrap; max-width: 100%; border-radius: 21px; }
.pill.ed-style-pill .btn { min-width: 0; padding: 0 9px; letter-spacing: 0; white-space: nowrap; }
.pill.ed-style-pill .btn + .btn { border-left: 1px solid #111; }
@media (max-width: 760px) { .pill.ed-style-pill { border-radius: 12px; } }
.ed-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 6px; }
/* PASS picks which pass the BAR row edits, so the two share a panel. Negative margins keep the labels in line with the other rows. */
.ed-group { margin: 6px -9px 0; padding: 0 8px 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; }
.ed-label { flex: none; width: 44px; padding-top: 12px; font: 700 10px var(--ui-font); color: var(--text-dim); letter-spacing: .5px; }
.ed-btns { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; }
.btn.ed { min-width: 44px; min-height: 40px; padding-left: 7px; padding-right: 7px; font-family: var(--lcd-font); font-weight: 400; font-size: 14px; touch-action: manipulation; }
.btn.ed.acc { font-size: 18px; margin-left: 4px; }
.btn.ed.acc + .btn.ed.acc { margin-left: 0; }
.btn.ed.on { background: linear-gradient(#86d6d1, #4aa8a2); border-color: #1d4a47; color: var(--on-accent); -webkit-text-fill-color: var(--on-accent); }
.add-bar {
  -webkit-appearance: none; appearance: none; cursor: pointer; min-height: 72px; border: 1px dashed var(--border); border-top: 2px dashed var(--border);
  background: transparent; color: var(--text-dim); -webkit-text-fill-color: var(--text-dim); font: 700 13px var(--ui-font); letter-spacing: .5px;
  touch-action: manipulation;
}
.add-bar:hover { border-color: var(--accent); color: var(--accent); -webkit-text-fill-color: var(--accent); }
.rep-mark { color: var(--accent); font: 900 13px var(--lcd-font); letter-spacing: 0; }
.bar.now .rep-mark { color: var(--on-accent); }
.rep-pass { color: var(--accent-soft); font: 700 11px var(--ui-font); }
.bar.now .rep-pass { color: var(--on-accent); }
.btn.name-edit { min-width: 40px; font-size: 18px; padding: 0 8px; }

/* ---------- left column: TONES / SONGS tabs; saved songs ---------- */
.side-tabs { display: flex; flex: none; }
.side-tabs .btn { flex: 1; border-radius: 0; font: 700 11px var(--ui-font); letter-spacing: .6px; }
.side-tabs .btn.on { background: linear-gradient(#86d6d1, #4aa8a2); border-color: #1d4a47; color: var(--on-accent); -webkit-text-fill-color: var(--on-accent); }
.side-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.song-row .name { font-family: var(--ui-font); font-weight: 700; font-size: 14px; color: var(--text); }
.song-meta { flex: none; color: #7c808b; font: 11px/26px var(--ui-font); }
.song-row.arm .song-meta { color: var(--lcd-text); }
/* Delete: a cross, then "Delete?" until the second tap. Negative margins widen the tap target, as on the tone stars. */
#song-delete.armed { color: #ff8a7a; font-weight: 700; }   /* ⋯ menu: waiting for the second tap */
.row.cur .name { color: var(--on-accent); }
.row.cur .song-meta { color: #1d4a47; }

/* ---------- one toolbar row; the ⋯ menu by the song name; MIDI settings in the left column ---------- */
.tools-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 6px; }
.chords-tools .chords-settings { margin-top: 0; }
.chords-title { position: relative; }
.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 250px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.55); display: flex; flex-direction: column;
}
.menu-item {
  -webkit-appearance: none; appearance: none; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 4px; padding: 9px 10px; cursor: pointer;
  font: 700 13px var(--ui-font); color: var(--text); -webkit-text-fill-color: var(--text);
}
button.menu-item:hover { background: #3a3d45; }
button.menu-item:disabled { opacity: .4; cursor: default; background: none; }
.menu-tr { cursor: default; justify-content: space-between; }
.menu-tr .pill .btn { min-width: 40px; }
.menu-sep { border-top: 1px solid var(--border); margin: 4px 2px; }
.side-gear { margin-left: auto; min-width: 36px; padding: 0 8px; display: flex; align-items: center; justify-content: center; }
.side-gear.on { background: linear-gradient(#86d6d1, #4aa8a2); border-color: #1d4a47; color: var(--on-accent); }
.settings-pane { gap: 12px; }
.settings-head { display: flex; align-items: center; font: 700 11px var(--ui-font); letter-spacing: .6px; color: var(--text-dim); }
.settings-head .btn { margin-left: auto; }
.settings-pane .port, .settings-pane .chan { margin: 0; flex-direction: column; align-items: stretch; gap: 4px; }
.settings-pane .chan select { text-align: left; }
.settings-note { margin: 0; font-size: 11px; line-height: 1.4; color: var(--text-dim); }
.chords-tools .chords-settings .set { margin-left: 0; }
