/* Guitar Tab app layout (v4). Phone-first, portrait: one column (max 430px), sized to the dynamic viewport
 * (100dvh) so the transport, ruler and grid always fit without page scroll. The grid scrolls inside itself.
 * Theme + shared components live in ../css/jlr-theme.css. */
:root { --col: 430px; --lane: 40px; --t0: #2ec4b6; --t1: #f5b942; --t2: #a78bfa; }
@media (max-height: 800px) { :root { --lane: 34px; } }
@media (max-height: 640px) { :root { --lane: 30px; } }
html, body.daw { height: 100%; }
body.daw { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; background: var(--bg-deep); overscroll-behavior: none; }
.phone-col { max-width: var(--col); margin: 0 auto; background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
.app { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.app > * { flex: none; }

.app-header { position: relative; }
.app-header .bar { padding: 4px 6px 4px 12px; display: flex; align-items: center; gap: 8px; min-height: 48px; }
.app-header .brand { flex: 1 1 auto; min-width: 0; gap: 8px; }
.app-header .logo-mark { height: 34px; }
.app-header .brand-title { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state { font-size: .7rem; color: var(--dim); white-space: nowrap; }
.save-state.ok { color: var(--teal); }

/* ---- Transport bar ---- */
.transport { display: flex; align-items: center; gap: 6px; padding: 8px 10px 6px; }
.tb { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 46px; padding: 0 8px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: 700 1.15rem var(--font); }
.tb svg { width: 22px; height: 22px; }
.tb:hover, .tb:focus-visible { border-color: var(--teal); outline: none; }
.tb[disabled] { opacity: .35; cursor: default; }
.tb.play { min-width: 58px; background: var(--neon); border-color: var(--neon); color: #062312; }
.tb.play .i-pause { display: none; }
.tb.play.on .i-play { display: none; }
.tb.play.on .i-pause { display: block; }
.tb.play.on { box-shadow: 0 0 0 3px rgba(61,255,138,.35), 0 0 20px rgba(61,255,138,.35); }
.tb.stop svg { color: var(--red); }
.tb.loop.on { border-color: var(--amber); color: var(--amber); background: var(--amber-dim); }
.tb.sm { min-width: 38px; height: 40px; padding: 0 6px; }
.tb.sm svg { width: 19px; height: 19px; }
.bpm { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.bpm .tb.sm { min-width: 32px; height: 46px; }
.bpm-val { position: relative; display: block; width: 58px; }
.bpm-val .field { min-height: 46px; text-align: center; padding: 4px 2px 14px; -moz-appearance: textfield; font-weight: 700; }
.bpm-val .field::-webkit-inner-spin-button, .bpm-val .field::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.bpm-val small { position: absolute; left: 0; right: 0; bottom: 3px; text-align: center; font-size: .55rem; color: var(--muted); letter-spacing: .08em; }

/* ---- Toolbar ---- */
.toolbar { display: flex; align-items: center; gap: 6px; padding: 0 10px 6px; }
.grid-sel { display: flex; align-items: center; gap: 4px; flex: none; }
.grid-sel .field { min-height: 40px; width: 66px; padding: 6px 20px 6px 7px; background-position: right 6px center; font-size: 16px; font-weight: 700; }
/* note style: two-segment control, Dotted | Triplet (mutually exclusive; neither lit = plain) */
.gstyle { display: flex; height: 40px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.gs { width: 29px; height: 100%; border: 0; background: var(--bg2); color: var(--muted); font: 800 1.05rem var(--font); padding: 0; cursor: pointer; }
.gs#grid-dot { font-size: 1.7rem; line-height: 1; }
.gs + .gs { border-left: 1px solid var(--line); }
.gs.on { background: var(--teal); color: #04201d; }
.gs:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.bpm .tb.sm { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.toolbar .tb.sm { min-width: 36px; padding: 0 4px; }
.pos { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-align: center; font: 700 .9rem var(--mono); color: var(--neon); font-variant-numeric: tabular-nums; }
.pos.long { font-size: .7rem; letter-spacing: -.02em; }
@media (max-width: 374px) { .toolbar { gap: 4px; padding: 0 8px 6px; } .toolbar .tb.sm { min-width: 32px; } }

/* ---- Track headers ---- */
.tracks { display: flex; flex-direction: column; gap: 4px; padding: 0 10px 6px; }
.trk { --tc: var(--t0); display: grid; grid-template-columns: minmax(0, 1fr) 58px 34px 34px 24%; align-items: center; gap: 4px; height: 40px;
  padding-right: 8px; border-radius: 9px; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--tc); }
.trk.c1 { --tc: var(--t1); } .trk.c2 { --tc: var(--t2); }
.trk.armed { border-color: var(--tc); border-left-width: 5px; background: #18233a; }
.trk-arm { display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 6px 0 8px; min-width: 0; text-align: left; color: var(--text); }
.trk-arm .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--tc); flex: none; }
.trk.armed .trk-arm .sw { box-shadow: 0 0 0 3px rgba(255,255,255,.12), 0 0 10px var(--tc); }
.trk-arm .nm { font-weight: 700; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.trk-arm small { font-size: .68rem; color: var(--muted); white-space: nowrap; flex: none; }
.trk.silent .trk-arm, .trk.silent .vol { opacity: .45; }
.ms { width: 34px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg2); color: var(--muted); font: 800 .8rem var(--font); }
.ms.m.on { background: var(--amber); border-color: var(--amber); color: #2a1d00; }
.ms.s.on { background: var(--neon); border-color: var(--neon); color: #062312; }
.vol { width: 100%; height: 30px; margin: 0; accent-color: var(--tc); background: none; }
/* v9: per-track Sound button + the Sound list */
.trk-snd { position: relative; width: 58px; height: 30px; padding: 0 12px 0 5px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg2); color: var(--teal);
  font: 700 .7rem var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.trk-snd::after { content: ""; position: absolute; right: 5px; top: 12px; border: 4px solid transparent; border-top: 5px solid var(--muted); }
.trk-snd[aria-expanded="true"] { border-color: var(--teal); background: var(--teal-dim); }
.trk-snd.loading { color: var(--muted); }
.trk-snd.loading::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--teal); animation: gt-load 1s linear infinite; transform-origin: left; }
.trk-snd.failed { color: var(--amber); }
.trk.silent .trk-snd { opacity: .55; }
@keyframes gt-load { 0% { transform: scaleX(0); } 100% { transform: scaleX(1); } }
.tone-pop { position: fixed; z-index: 70; width: 214px; padding: 5px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--teal); box-shadow: 0 12px 34px rgba(0,0,0,.6);
  display: flex; flex-direction: column; gap: 2px; }
.tone-pop[hidden] { display: none; }
.tone-opt { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-height: 40px; padding: 3px 10px 3px 28px; border-radius: 8px; position: relative;
  color: var(--text); text-align: left; font: 700 .86rem var(--font); }
.tone-opt small { font-size: .66rem; font-weight: 600; color: var(--muted); }
.tone-opt.bass small { color: var(--blue); }
.tone-opt:hover, .tone-opt:focus-visible { background: var(--card2); outline: none; }
.tone-opt[aria-selected="true"] { background: var(--teal-dim); color: var(--neon); }
.tone-opt[aria-selected="true"]::before { content: ""; position: absolute; left: 11px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--neon); box-shadow: 0 0 8px var(--neon); }
/* Play while the Sounds load: a ring spins round the button */
.tb.play.loading { background: var(--neon-dim); color: var(--neon); }
.tb.play.loading::after { content: ""; position: absolute; width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(61,255,138,.25); border-top-color: var(--neon); animation: gt-spin .8s linear infinite; }
.tb.play.loading svg { visibility: hidden; }
.tb.play { position: relative; }
@keyframes gt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tb.play.loading::after, .trk-snd.loading::before { animation-duration: 3s; } }
.trk-add { height: 30px; border-radius: 9px; border: 1px dashed var(--line); color: var(--neon); font-size: .82rem; font-weight: 700; }

/* ---- Arrangement: ruler + grid fill the rest; only they scroll (sideways, and down if very short) ---- */
.arrange { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0 10px; overflow: hidden; }
.ruler-wrap { flex: none; overflow: hidden; border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; background: #0d1626;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: ew-resize; }
.editor-wrap { flex: 0 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 0 0 12px 12px; background: var(--bg-deep); }
.editor { display: inline-flex; padding: 2px 6px 4px 0; min-width: 100%; }
.labels, .col { display: flex; flex-direction: column; flex: none; }
.labels { position: sticky; left: 0; z-index: 3; background: var(--bg-deep); padding: 0 4px 0 6px; border-right: 1px solid var(--line); }
.labels span { height: var(--lane); display: flex; align-items: center; justify-content: center; font: 700 .84rem var(--mono); color: var(--tc, var(--teal)); min-width: 26px; }
.editor { --tc: var(--t0); } .editor.tc1 { --tc: var(--t1); } .editor.tc2 { --tc: var(--t2); }
.du { height: 16px; display: flex; align-items: center; justify-content: center; font: 700 .7rem var(--mono); color: var(--muted); }
.labels .du { font-size: .56rem; color: var(--dim); font-weight: 500; }
.du.cont { color: var(--dim); }
.bm { height: 14px; position: relative; }
.tp { height: 11px; position: relative; }
.col { position: relative; padding: 0 1px; }
.col.bar { border-left: 2px solid #56657f; margin-left: 4px; }
.col.loop { background: rgba(245,185,66,.07); }
.col.cur { background: rgba(46,196,182,.10); border-radius: 8px; }
.col.cur .du { color: var(--teal); }
.col.playing { background: rgba(61,255,138,.16); box-shadow: inset 0 0 0 1px var(--neon); border-radius: 8px; }
.cell { position: relative; width: 40px; height: var(--lane); display: flex; align-items: center; justify-content: center; font: 700 .95rem var(--mono); color: var(--text); }
.cell::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: #3a4760; }
.cell b { position: relative; z-index: 1; min-width: 26px; height: calc(var(--lane) - 10px); max-height: 28px; padding: 0 3px; border-radius: 7px; display: flex; align-items: center; justify-content: center; }
.cell.has b { background: var(--card2); border: 1.5px solid var(--tc); }
.cell.mute b { color: var(--amber); }
/* insert position (edit cursor): dashed outline on the exact lane cell */
.cell.at::after { content: ""; position: absolute; inset: 3px 2px; border: 2px dashed var(--teal); border-radius: 8px; z-index: 2; pointer-events: none; }
.cell.sel b { background: var(--neon); color: #062312; border-color: var(--neon); }
.cell:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; border-radius: 8px; }
/* other tracks: faint, colour-coded */
.cell.ghost b { color: var(--g); opacity: .55; border: 1px dashed var(--g); background: transparent; font-weight: 600; }
.cell.ghost.g0 { --g: var(--t0); } .cell.ghost.g1 { --g: var(--t1); } .cell.ghost.g2 { --g: var(--t2); }
.gdot { position: absolute; left: 3px; top: 4px; width: 7px; height: 7px; border-radius: 50%; z-index: 2; box-shadow: 0 0 0 2px var(--bg-deep); }
.gdot.n1 { left: 3px; top: auto; bottom: 4px; }
.gdot.c0 { background: var(--t0); } .gdot.c1 { background: var(--t1); } .gdot.c2 { background: var(--t2); }
.cell.off .gdot { display: none; }
.cell.off::after { content: ""; position: absolute; right: 3px; top: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); z-index: 2; box-shadow: 0 0 0 2px var(--bg-deep); }
.cell.off.at::after { right: 2px; top: 3px; left: 2px; bottom: 3px; width: auto; height: auto; background: none; border: 2px dashed var(--teal); border-radius: 8px; box-shadow: none; }
.cell sup { position: absolute; right: 1px; bottom: 2px; z-index: 2; font: 700 .55rem var(--mono); color: var(--amber); }

/* stems + 1-4 beams (8th, 16th, 32nd, 64th) under each step; flags on a lone note; a dot for dotted values */
.bm i { position: absolute; height: 2px; background: var(--muted); border-radius: 1px; display: none; }
.bm::before { content: ""; position: absolute; left: 50%; top: 0; width: 2px; height: 14px; background: var(--muted); transform: translateX(-1px); display: none; }
.bm.stem::before, .bm[class*="b-"]::before { display: block; }
.bm.nostem::before { display: none !important; }
.bm i:nth-child(1) { bottom: 0; } .bm i:nth-child(2) { bottom: 3px; } .bm i:nth-child(3) { bottom: 6px; } .bm i:nth-child(4) { bottom: 9px; }
.bm.lv1 i:nth-child(-n+1), .bm.lv2 i:nth-child(-n+2), .bm.lv3 i:nth-child(-n+3), .bm.lv4 i:nth-child(-n+4) { display: block; }
.bm.dot::after { content: ""; position: absolute; left: calc(50% + 4px); top: 1px; width: 4px; height: 4px; border-radius: 50%; background: var(--text); }
/* triplet mark under the beams: "3" (beamed 8th and shorter) or a bracket with "3" (quarter, half, whole) */
.tp span { position: absolute; left: 50%; top: -1px; transform: translateX(-50%); padding: 0 2px; font: 800 .62rem/11px var(--mono); color: var(--amber); background: var(--bg-deep); z-index: 1; }
.tp.br::before { content: ""; position: absolute; top: 5px; height: 4px; border-top: 1.5px solid var(--amber); left: -2px; right: -2px; }
.tp.br.t-start::before { left: 50%; border-left: 1.5px solid var(--amber); top: 2px; height: 3px; border-top: 0; border-bottom: 1.5px solid var(--amber); }
.tp.br.t-end::before { right: 50%; border-right: 1.5px solid var(--amber); top: 2px; height: 3px; border-top: 0; border-bottom: 1.5px solid var(--amber); }
.tp.br.t-only::before { left: 20%; right: 20%; border: 1.5px solid var(--amber); border-top: 0; top: 2px; height: 3px; }
.tp.br.t-mid::before { top: 2px; height: 3px; border-top: 0; border-bottom: 1.5px solid var(--amber); }
.col.bar .tp.br.t-mid::before, .col.bar .tp.br.t-end::before { left: -6px; }
.bm.b-start i { left: 50%; right: -2px; }
.bm.b-mid i { left: -2px; right: -2px; }
.bm.b-end i { left: -2px; right: 50%; }
.bm.b-flag i { left: 50%; width: 9px; transform: skewY(-25deg); }
.col.bar .bm.b-mid i, .col.bar .bm.b-end i { left: -6px; }

/* ---- Ruler: bar|beat. Top lane = bar numbers + loop brace, bottom lane = beats + playhead ---- */
.ruler { display: inline-flex; padding: 0 6px 0 0; min-width: 100%; }
.r-lab { position: sticky; left: 0; z-index: 3; flex: none; display: flex; flex-direction: column; background: #0d1626; border-right: 1px solid var(--line); }
.r-lab span { height: 22px; display: flex; align-items: center; justify-content: center; font-size: .56rem; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.r-lab span:last-child { height: 24px; }
.r-lab .r-g { text-transform: none; color: var(--teal); font: 700 .74rem var(--mono); }
.rcol { position: relative; flex: none; display: flex; flex-direction: column; padding: 0 1px; margin: 0; border: 0; background: none; color: var(--muted); font: inherit; text-align: left; cursor: pointer; }
.rcol.bar { border-left: 2px solid #56657f; margin-left: 4px; }
.r-m { height: 22px; display: flex; align-items: center; padding-left: 4px; font: 700 .72rem var(--mono); color: var(--text); white-space: nowrap; cursor: col-resize; }
.r-len { height: 24px; display: flex; align-items: center; justify-content: center; font: 700 .72rem var(--mono); color: var(--dim); }
.rcol.beat .r-len { color: var(--text); font-size: .84rem; }
/* loop brace */
.rcol.loop .r-m { background: var(--amber-dim); color: var(--amber); box-shadow: inset 0 4px 0 var(--amber); }
.rcol.loop-off .r-m { box-shadow: inset 0 3px 0 rgba(245,185,66,.3); }
.rcol.loop.ls .r-m { border-top-left-radius: 6px; box-shadow: inset 0 4px 0 var(--amber), inset 4px 0 0 var(--amber); }
.rcol.loop.le .r-m { border-top-right-radius: 6px; box-shadow: inset 0 4px 0 var(--amber), inset -4px 0 0 var(--amber); }
.rcol.loop.ls.le .r-m { box-shadow: inset 0 4px 0 var(--amber), inset 4px 0 0 var(--amber), inset -4px 0 0 var(--amber); }
.rcol:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; border-radius: 6px; }
/* playhead: neon line through ruler and grid with a draggable marker on the ruler */
.rcol.ph .r-len, .rcol.ph.beat .r-len { color: #062312; background: var(--neon); border-radius: 7px; margin: 2px 2px 2px; height: 20px; }
.rcol.ph::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--neon); z-index: 2; box-shadow: 0 0 8px var(--neon); }
.rcol.ph::after { content: ""; position: absolute; left: -5px; top: 0; border: 6px solid transparent; border-top: 8px solid var(--neon); z-index: 2; }
.col.ph::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--neon); z-index: 2; box-shadow: 0 0 8px var(--neon); pointer-events: none; }

/* ---- Pinned idea notes ---- */
.idea-bar { padding: 6px 10px calc(6px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg); margin-top: 6px; }
.idea-bar .field { min-height: 44px; padding: 9px 12px; }
/* v9.1: the box is a two-line preview of the lyrics; tapping it opens the lyrics sheet */
.idea-prev { width: 100%; height: 44px; display: flex; align-items: center; gap: 10px; padding: 3px 10px 3px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.idea-prev:hover, .idea-prev:focus-visible { border-color: var(--teal); outline: none; }
.idea-prev svg { width: 18px; height: 18px; flex: none; color: var(--teal); }
.ip-text { flex: 1 1 auto; min-width: 0; font-size: .78rem; line-height: 17px; max-height: 34px; white-space: pre-line; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.ip-text .ih { color: var(--teal); font-weight: 800; }
.ip-text .ie { color: var(--dim); }

/* ---- Lyrics sheet (v9.1) ----
 * Full height, pinned to the visual viewport by JS (top/height follow visualViewport), so the on-screen keyboard
 * shrinks the writing area instead of covering it. Section headers are styled by a mirror layer behind the native
 * textarea: same font, padding, width and wrapping, scroll-synced; it paints a band and a bold outline under each
 * [Header] line while the textarea keeps its own glyphs, caret, selection and autocorrect. */
.sheet.lsheet { top: 0; bottom: auto; height: 100vh; height: 100dvh; max-height: none; z-index: 64; display: flex; flex-direction: column; overflow: hidden;
  border-radius: 0; border-top: 0; box-shadow: none; background: var(--bg); padding: calc(6px + env(safe-area-inset-top, 0px)) 12px calc(8px + var(--safe-b)); }
.lsheet > * { flex: none; }
.lsheet .sheet-head { align-items: center; gap: 10px; margin-bottom: 6px; }
.lsheet .card-h { flex: 1 1 auto; margin: 0; }
.lcount { font: 600 .72rem var(--mono); color: var(--dim); white-space: nowrap; }
.lcount.near { color: var(--amber); }
.lrow { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px 6px; padding: 0 12px; overscroll-behavior-x: contain; }
.lrow::-webkit-scrollbar { display: none; }
.lrow .chip { flex: none; min-height: 34px; padding: 4px 12px; font-size: .8rem; white-space: nowrap; touch-action: manipulation; }
.lchips .chip { border-color: rgba(46,196,182,.55); color: var(--teal); font-weight: 800; }
.lchips .chip.on { background: var(--teal); border-color: var(--teal); color: #04201d; }
.lchips .lnone { font-size: .74rem; color: var(--dim); line-height: 34px; white-space: nowrap; }
.lins .chip { border-style: dashed; color: var(--muted); }
.ledit { flex: 1 1 auto; min-height: 0; position: relative; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-deep); overflow: hidden; }
.ledit:focus-within { border-color: var(--teal); }
.lmirror, .ltext { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; box-sizing: border-box; padding: 10px 14px 28px;
  font-family: var(--font); font-size: 16px; font-weight: 400; line-height: 1.55; letter-spacing: normal; word-spacing: normal; text-transform: none; text-indent: 0; text-align: left;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4; }
.ltext { display: block; background: transparent; color: var(--text); caret-color: var(--neon); resize: none; outline: none; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none; -webkit-appearance: none; appearance: none; overscroll-behavior: contain; }
.ltext::-webkit-scrollbar { display: none; }
.ltext::placeholder { color: var(--dim); }
.lmirror { color: transparent; overflow: hidden; pointer-events: none; }
.lmirror .lh { display: inline-block; width: 100%; vertical-align: top; border-radius: 6px; background: rgba(46,196,182,.15); color: var(--teal);
  -webkit-text-stroke: 2.4px var(--teal); box-shadow: -9px 0 0 rgba(46,196,182,.15), -13px 0 0 var(--teal); }
.lmini { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.lmini .tb { height: 54px; min-width: 54px; }
.lrestart { flex: 1 1 auto; gap: 10px; justify-content: center; border-color: var(--teal); color: var(--teal); background: var(--teal-dim); touch-action: manipulation; }
.lrestart svg { width: 24px; height: 24px; flex: none; }
.lrestart span { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.lrestart b { font-size: 1rem; letter-spacing: .02em; }
.lrestart small { font: 600 .68rem var(--mono); color: var(--muted); white-space: nowrap; }
.lrestart.hit { box-shadow: 0 0 0 3px rgba(46,196,182,.45); }
.lpos { min-width: 50px; text-align: right; font: 700 .76rem var(--mono); color: var(--muted); white-space: nowrap; }
.lsheet.kb .sheet-head { margin-bottom: 4px; }
.lsheet.kb .lrow { margin-bottom: 4px; }
.lsheet.kb .lrow .chip { min-height: 30px; padding: 2px 10px; }
.lsheet.kb .lmini { padding-top: 6px; }
.lsheet.kb .lmini .tb { height: 44px; min-width: 46px; }
.lsheet.tiny .lchips { display: none; }
@media (max-width: 374px) { .lpos { display: none; } }

/* ---- First-run hint ---- */
.hint-pop { position: fixed; z-index: 50; left: 50%; transform: translateX(-50%); bottom: calc(64px + var(--safe-b)); width: calc(100% - 24px); max-width: calc(var(--col) - 24px);
  background: var(--card); border: 1px solid var(--teal); border-radius: 14px; padding: 10px 12px; box-shadow: 0 16px 50px rgba(0,0,0,.6);
  }
.hint-pop p { margin: 0; font-size: .78rem; line-height: 1.45; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint-pop .btn { display: flex; margin: 8px 0 0 auto; min-height: 36px; }

/* ---- Sheets (picker, drawer) ---- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(3,6,12,.6); z-index: 60; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; width: 100%; max-width: var(--col); margin: 0 auto;
  background: var(--card); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0;
  padding: 12px 12px calc(12px + var(--safe-b)); box-shadow: 0 -20px 60px rgba(0,0,0,.5); max-height: 94vh; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain; }
[hidden] { display: none !important; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.sheet-head .card-h { margin: 0 0 2px; }
.drawer { background: var(--bg); }
.drawer .card { margin-bottom: 10px; padding: 12px; }
.song-info { margin: -4px 0 10px; font-size: .78rem; color: var(--muted); }
.sec-lab.sub { color: var(--muted); font-size: .64rem; margin-bottom: 4px; }
.mt { margin-top: 12px; }
.mt-s { margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid2 .btn, .grid3 .btn { width: 100%; white-space: normal; text-align: center; line-height: 1.2; }
.btn.wide { width: 100%; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card-row .sec-lab { margin: 0; }
.loop-info, .note { font-size: .78rem; color: var(--muted); margin: 8px 0 0; line-height: 1.4; }
.links { text-align: center; font-size: .86rem; margin: 6px 0 4px; }
.links.credits { font-size: .72rem; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.ascii { margin: 6px 0 0; padding: 10px; max-height: 40vh; overflow: auto; background: var(--bg-deep); border: 1px solid var(--line); border-radius: 12px; font: 400 .78rem/1.4 var(--mono); color: var(--text); white-space: pre; }

/* fret picker: vertical neck */
.picker-sub { display: block; font-size: .85rem; color: var(--muted); }
.picker-body { display: grid; grid-template-columns: 1fr 140px; gap: 10px; align-items: start; }
.neck { position: relative; display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.neck.scrolls { max-height: var(--neckh, none); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.neck.scrolls .frow { flex: none; }
.frow { display: grid; grid-template-columns: 38px 1fr; align-items: stretch; height: var(--frow, 38px); padding: 0; text-align: left; color: var(--text); background: none; }
.frow .n { display: flex; align-items: center; justify-content: center; font: 700 .95rem var(--mono); color: var(--muted); background: #121a29; border-bottom: 1px solid var(--line); }
.frow .board { position: relative; display: flex; align-items: center; justify-content: center; background:
  repeating-linear-gradient(90deg, transparent 0 calc(16.66% - 1px), rgba(154,166,184,.35) calc(16.66% - 1px) 16.66%), #1b2231;
  border-bottom: 3px solid #5b6a84; }
.frow.open .board { background: #121a29; border-bottom: 6px solid #d9d4c4; }
.frow.open .n { border-bottom-width: 6px; border-bottom-color: #121a29; }
.frow .dots { display: flex; gap: 22px; position: relative; z-index: 1; }
.frow .dots i { width: 14px; height: 14px; border-radius: 50%; background: #e8e2cf; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.frow.inlay .n { color: var(--text); }
.frow:hover .board, .frow:focus-visible .board { outline: 2px solid var(--teal); outline-offset: -2px; }
.frow.on .n { background: var(--neon); color: #062312; }
.frow.on .board { box-shadow: inset 0 0 0 3px var(--neon); background-color: rgba(61,255,138,.15); }
.picker-side { display: flex; flex-direction: column; gap: 8px; }
.picker-side .sec-lab { margin: 0; }
.pstrings { display: grid; grid-template-columns: 1fr; gap: 5px; }
.pstrings .chip { font-family: var(--mono); min-width: 0; min-height: var(--chip, 42px); padding: 2px 10px; justify-content: space-between; display: flex; }
.pstrings .chip b { font-size: 1.05rem; }
.pstrings .chip small { font-size: .62rem; font-weight: 500; opacity: .75; font-family: var(--font); }
.pstrings .chip.has:not(.on) { color: var(--text); }
.picker-tip { margin: 0; font-size: .72rem; line-height: 1.3; color: var(--muted); }
/* v5 step editor: yellow = the string you're on (chip + roll row), Back/Next + bar jumps, mini tab roll */
:root { --sel: #f5d547; }
.pstrings .chip.on { background: var(--sel); border-color: var(--sel); color: #231d00; box-shadow: 0 0 0 2px rgba(245,213,71,.25); }
.pstrings .chip.on small { opacity: .85; }
#picker { padding-top: 10px; }
#picker .sheet-head { margin-bottom: 6px; align-items: center; }
.ph-text { min-width: 0; }
.ph-btns { display: flex; gap: 6px; flex: none; }
.ph-btns .btn.icon { min-width: 40px; padding: 0 8px; font-size: 1.1rem; }
.pk2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pk2 .btn { padding: 0 4px; min-height: 40px; font-size: .8rem; }
.pnav { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pnav .btn { min-width: 0; padding: 2px 4px; white-space: normal; line-height: 1.15; text-align: center; font-size: .8rem; }
.pnav #picker-prev, .pnav #picker-next { min-height: 50px; }
.pnav #picker-prev-bar, .pnav #picker-next-bar { min-height: 40px; }
.roll-cap { display: flex; justify-content: space-between; gap: 8px; font-size: .7rem; color: var(--muted); margin: 0 0 3px; }
.roll-cap #roll-bar { color: var(--text); font-weight: 650; }
.roll { display: grid; grid-template-columns: 22px repeat(var(--rc, 16), minmax(0, 1fr)); grid-auto-rows: 13px; margin: 0 0 8px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg-deep, #0b111c); font: 600 .62rem/13px var(--mono); user-select: none; }
.roll .rl { color: var(--muted); text-align: center; background: #121a29; border-right: 1px solid var(--line); overflow: hidden; }
.roll .rc { position: relative; text-align: center; color: var(--text); cursor: pointer; overflow: hidden; white-space: nowrap;
  background: linear-gradient(transparent 6px, rgba(154,166,184,.28) 6px, rgba(154,166,184,.28) 7px, transparent 7px); }
.roll .rc.bt { box-shadow: inset 1px 0 0 rgba(154,166,184,.22); }
.roll .rc.has b { position: relative; z-index: 1; display: inline-block; min-width: 11px; padding: 0 1px; border-radius: 3px; background: #1b2638; color: var(--tc, var(--teal)); }
.roll .rc.gh { color: var(--gc); opacity: .55; font-weight: 500; }
.roll .rc.gh.g0 { --gc: var(--t0); } .roll .rc.gh.g1 { --gc: var(--t1); } .roll .rc.gh.g2 { --gc: var(--t2); }
.roll.tc0 { --tc: var(--t0); } .roll.tc1 { --tc: var(--t1); } .roll.tc2 { --tc: var(--t2); }
.roll .sel { background-color: rgba(245,213,71,.16); }
.roll .rl.sel { color: #231d00; background: var(--sel); }
.roll .rc.now { background-color: rgba(46,196,182,.22); }
.roll .rc.now.sel { background-color: rgba(245,213,71,.42); box-shadow: inset 0 0 0 2px var(--sel); }
.roll .rc.ph::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--neon); opacity: .5; }
#pick-mute.on { border-color: var(--amber); color: var(--amber); }

/* ---- Modal + toast ---- */
.modal { position: fixed; z-index: 71; left: 50%; top: 50%; transform: translate(-50%, -50%); width: calc(100% - 32px); max-width: calc(var(--col) - 32px);
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal p { color: var(--muted); font-size: .92rem; line-height: 1.5; margin: 6px 0 14px; white-space: pre-line; }
.modal-actions { display: grid; gap: 8px; }
#modal-scrim { z-index: 70; }
.toast { position: fixed; left: 50%; bottom: calc(66px + var(--safe-b)); transform: translateX(-50%); z-index: 80; background: var(--bg2); border: 1px solid var(--teal);
  color: var(--text); border-radius: 12px; padding: 9px 14px; font-size: .88rem; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: calc(min(100%, var(--col)) - 32px); }
/* MIDI export sheet: one row per track, marked with its colour */
.modal-actions .btn.trk-x { justify-content: flex-start; white-space: normal; text-align: left; border-left: 6px solid var(--tc); }
.modal-actions .btn.trk-x.c0 { --tc: var(--t0); } .modal-actions .btn.trk-x.c1 { --tc: var(--t1); } .modal-actions .btn.trk-x.c2 { --tc: var(--t2); }

/* ---- v8: per-track note style ---- */
/* the coloured tab in front of the Dotted | Triplet toggles: which track they set */
.gs-trk { display: flex; align-items: center; justify-content: center; width: 15px; height: 100%; font: 800 .62rem var(--mono); color: #04121a; background: var(--tc, var(--t0)); flex: none; }
.gs-trk.c0 { --tc: var(--t0); } .gs-trk.c1 { --tc: var(--t1); } .gs-trk.c2 { --tc: var(--t2); }
.gs-trk + .gs { border-left: 0; }
/* style badge on a track row: "3" (triplet) or "·" (dotted) */
.trk-arm .st { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 3px; border-radius: 5px;
  font: 800 .7rem/1 var(--mono); font-style: normal; color: #04121a; background: var(--tc); }
.trk-arm .st.dotted { font-size: 1.05rem; }
.grid2 .span2 { grid-column: 1 / -1; }

/* ---- v8: chord library (sheet over the step editor) ---- */
.csheet-scrim { z-index: 62; }
.csheet { z-index: 63; display: flex; flex-direction: column; height: calc(100dvh - 70px); max-height: none; overflow: hidden; padding: 10px 12px calc(10px + var(--safe-b)); }
@media (max-height: 700px) { .csheet { height: calc(100dvh - 34px); } }
.csheet .sheet-head { margin-bottom: 8px; align-items: center; }
.csheet .sheet-head .btn { flex: none; }
.csearch { position: relative; flex: none; display: block; }
.csearch .field { width: 100%; min-height: 42px; padding: 8px 12px 8px 38px; font-size: 16px; }
.csearch svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.cfilters { flex: none; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 8px -12px 8px 0; padding-right: 12px; }
.cfilters::-webkit-scrollbar { display: none; }
.cfilters .chip { min-height: 36px; padding: 4px 12px; flex: none; font-size: .8rem; }
.cfilters .chip small { font-size: .66rem; opacity: .7; font-weight: 600; margin-left: 4px; }
.cfilters .chip.on { border-color: var(--teal); color: var(--teal); background: var(--teal-dim); }
.cwrap-o { position: relative; flex: 1 1 auto; min-height: 0; }
.cwrap { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  -webkit-mask-image: linear-gradient(#000 0 calc(100% - 22px), transparent); mask-image: linear-gradient(#000 0 calc(100% - 22px), transparent); }
.cgh { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: baseline; background: var(--card); padding: 6px 2px; margin: 0; }
.cgh .sec-lab { margin: 0; }
.cgh small { font-size: .68rem; color: var(--dim); }
.cgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 2px 0 10px; }
.cempty { color: var(--muted); font-size: .85rem; text-align: center; margin: 24px 0; }
.ccard { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 80px; align-items: center; gap: 4px; min-height: 104px; padding: 8px 8px 8px 11px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card2); text-align: left; color: var(--text); cursor: pointer; font: inherit; }
.ccard:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.ccard .cn { display: block; font: 800 1.3rem/1.1 var(--font); letter-spacing: -.01em; overflow-wrap: anywhere; }
.ccard .cn.long { font-size: 1rem; }
.ccard .cq { display: block; font-size: .68rem; color: var(--muted); margin-top: 3px; }
.ccard .cf { display: block; font: 700 .72rem var(--mono); color: var(--teal); margin-top: 8px; letter-spacing: .04em; white-space: nowrap; }
.ccard .cf i { font-style: normal; color: var(--dim); font-weight: 600; font-size: .6rem; }
.ccard svg { width: 80px; height: 90px; display: block; }
.ccard.sel { border-color: var(--sel); box-shadow: 0 0 0 2px var(--sel), 0 0 18px rgba(245,213,71,.25); background: #222a2a; }
.ccard.sel .cn { color: var(--sel); }
.ccard .tag { position: absolute; top: -8px; left: 10px; font: 700 .55rem var(--font); letter-spacing: .06em; text-transform: uppercase; color: #231d00; background: var(--sel); border-radius: 5px; padding: 1px 4px; }
.cfoot { flex: none; margin: 6px 0 0; font-size: .72rem; color: var(--muted); text-align: center; }
/* detail state: the list shrinks to a band (or goes, on short screens), the preview takes the rest */
.csheet.detail .csearch, .csheet.detail .cfilters, .csheet.detail .cfoot { display: none; }
.csheet.detail .cwrap-o { flex: none; height: 128px; }
.csheet.detail.nolist .cwrap-o { display: none; }
.cdetail { flex: none; border-top: 1px solid var(--line); margin: 4px -12px 0; padding: 8px 12px 0; }
.csheet.nolist .cdetail { border-top: 0; margin-top: 0; padding-top: 0; }
.cd-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cd-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; row-gap: 0; }
.cd-name b { font: 800 1.5rem/1 var(--font); color: var(--sel); white-space: nowrap; }
.cd-name span { font-size: .74rem; color: var(--muted); }
.cd-name span em { font: 700 .76rem var(--mono); font-style: normal; color: var(--text); }
.cd-note { margin: -2px 0 6px; font-size: .7rem; line-height: 1.3; color: var(--amber); }
.roll .rc.pv { background-color: rgba(245,213,71,.20); box-shadow: inset 1px 0 0 var(--sel), inset -1px 0 0 var(--sel); }
.roll .rc.pv b { background: var(--sel); color: #231d00; }
.cbody { --frow: 22px; --cchip: 30px; }
.cbody .picker-side { gap: 6px; }
.cneck { min-width: 0; }
.cstr { display: grid; grid-template-columns: 38px repeat(6, 1fr); height: 16px; font: 700 .66rem/16px var(--mono); color: var(--muted); text-align: center; }
.cstr span:first-child { font: 600 .56rem/16px var(--font); color: var(--dim); }
.cneck .neck { border-radius: 10px; }
.cneck .frow { cursor: default; }
.cneck .frow .n { font-size: .82rem; }
.cneck .frow .board { background: repeating-linear-gradient(90deg, transparent 0 calc(8.333% - 1px), rgba(154,166,184,.45) calc(8.333% - 1px) calc(8.333% + 1px), transparent calc(8.333% + 1px) 16.666%), #1b2231; }
.cneck .frow.open .board { background: repeating-linear-gradient(90deg, transparent 0 calc(8.333% - 1px), rgba(154,166,184,.25) calc(8.333% - 1px) calc(8.333% + 1px), transparent calc(8.333% + 1px) 16.666%), #121a29; }
.cneck .frow .dots i { width: 9px; height: 9px; }
.cneck .frow.hit .n { color: var(--sel); }
.cneck .frow:hover .board { outline: 0; }
.mk { position: absolute; top: 50%; width: 19px; height: 19px; margin: -9.5px 0 0 -9.5px; border-radius: 50%; z-index: 2; display: flex; align-items: center; justify-content: center;
  background: var(--sel); color: #231d00; font: 800 .68rem var(--mono); font-style: normal; box-shadow: 0 0 0 2px rgba(0,0,0,.35); }
.mk.o { background: transparent; border: 2px solid var(--sel); box-shadow: none; }
.mk.x { background: none; color: var(--amber); box-shadow: none; font-size: .8rem; }
.cside .sec-lab small { color: var(--dim); font-size: .58rem; letter-spacing: .04em; text-transform: none; font-weight: 600; }
.cside-chips { display: grid; gap: 4px; }
.cside-chips .chip { min-height: var(--cchip); padding: 2px 10px; justify-content: space-between; display: flex; font-family: var(--mono); color: var(--text); cursor: default; }
.cside-chips .chip b { font-size: .95rem; }
.cside-chips .chip small { font: 500 .62rem var(--font); opacity: .8; }
.cside-chips .chip.fr small { color: var(--sel); opacity: 1; font-weight: 700; }
.cside-chips .chip.mu small { color: var(--amber); opacity: 1; }
.cside .pk2 .btn.on { border-color: var(--teal); color: var(--teal); background: var(--teal-dim); }
.cside .drop { min-height: 50px; white-space: normal; line-height: 1.15; text-align: center; padding: 4px 6px; font-size: .9rem; }
.cside .cancel { min-height: 40px; }
/* Chords button in the step editor */
.chords-open { width: 100%; min-height: 38px; font-size: .8rem; gap: 6px; padding: 0 6px; }
.chords-open.on { border-color: var(--sel); color: var(--sel); }
/* toast with an action (Undo) */
.toast.act { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 14px; bottom: calc(14px + var(--safe-b)); }
.toast.act b { color: var(--sel); }
.toast.act button { flex: none; min-height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--teal); background: transparent; color: var(--teal); font: 800 .84rem var(--font); cursor: pointer; }
#picker.tight .picker-side { gap: 4px; }
#picker.tight .pk2 .btn { min-height: 34px; }
#picker.tight .chords-open { min-height: 32px; }
#picker.tight .pnav #picker-prev, #picker.tight .pnav #picker-next { min-height: 42px; }
#picker.tight .pnav #picker-prev-bar, #picker.tight .pnav #picker-next-bar { min-height: 34px; }
#picker.tight .pstrings { gap: 4px; }

/* chord neck marker columns, high e first (k0) */
.mk.k0 { left: 8.333%; }
.mk.k1 { left: 25.000%; }
.mk.k2 { left: 41.667%; }
.mk.k3 { left: 58.333%; }
.mk.k4 { left: 75.000%; }
.mk.k5 { left: 91.667%; }
.mk.barre { width: auto; height: 12px; margin: -6px 0 0 0; border-radius: 6px; background: var(--sel); opacity: .55; z-index: 1; box-shadow: none; }
.cneck .frow.hit .dots i { opacity: .25; }

/* v8.1: chart-order boxes (string names under the box), movable shapes (root string, ‹ fret ›, 3 / 2 notes) */
.ccard svg { height: 100px; }
.ccard.mv .cq { color: var(--teal); }
.cd-name span small { font-size: .62rem; color: var(--dim); }
.cd-move { display: flex; align-items: center; gap: 6px; margin: -2px 0 6px; flex-wrap: nowrap; }
.cd-move[hidden] { display: none; }
.cd-rootlab { font: 700 .62rem var(--font); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cd-rootlab:empty { display: none; }
.cd-move .seg, .cd-move .step { display: inline-flex; gap: 0; }
.cd-move .seg[hidden] { display: none; }
.cd-move .btn { min-height: 34px; padding: 0 9px; font-size: .8rem; border-radius: 0; }
.cd-move .seg .btn:first-child, .cd-move .step .btn:first-child { border-radius: 9px 0 0 9px; }
.cd-move .seg .btn:last-child, .cd-move .step .btn:last-child { border-radius: 0 9px 9px 0; }
.cd-move .seg .btn + .btn { margin-left: -1px; }
.cd-move .seg .btn.on { border-color: var(--teal); color: var(--teal); background: var(--teal-dim); position: relative; z-index: 1; }
.cd-move .step .btn { font-size: 1.15rem; line-height: 1; width: 36px; padding: 0; }
.cd-move .step .btn:disabled { opacity: .35; }
.cd-move output { display: flex; align-items: center; justify-content: center; min-width: 58px; height: 34px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font: 800 .85rem var(--mono); color: var(--sel); white-space: nowrap; }
.cd-move #cd-ns { margin-left: auto; }
.cneck .frow.gap { border-top: 3px dashed rgba(154,166,184,.5); }
@media (max-width: 370px) { .cd-move { gap: 4px; } .cd-move .btn { padding: 0 6px; } .cd-move .step .btn { width: 30px; } .cd-move output { min-width: 50px; } }

/* v8.2: metronome click toggle */
.tb.click.on { border-color: var(--teal); color: var(--teal); background: rgba(46,196,182,.14); }
/* six transport buttons + BPM fit 360px wide without scrolling */
.transport { gap: 4px; padding: 8px 8px 6px; }
.transport > .tb { min-width: 40px; padding: 0 6px; }
.transport > .tb.play { min-width: 52px; }
.transport .bpm .tb.sm { min-width: 30px; }
.transport .bpm-val { width: 54px; }
.transport .bpm { gap: 2px; }
.lsheet:focus { outline: none; }
body.lyr-open .toast { bottom: calc(84px + var(--safe-b)); }
