/* UG Reader — shared styles (loaded by play, practice, jam pages) */

/* Load JetBrains Mono for cleaner tab rendering */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&display=swap');

/* Disable double-tap zoom on all reader elements */
#ug-reader-overlay {
    touch-action: manipulation;
}

/* ── Content ── */

.ug-section {
    padding: 10px 14px 4px;
}

.ug-section + .ug-section {
    padding-top: 6px;
}

.ug-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.ug-end-marker {
    text-align: center;
    color: var(--text-muted);
    font-size: 18px;
    letter-spacing: 0.05em;
    padding: 32px 0 48px;
    opacity: 0.6;
}

.ug-line {
    line-height: 1;
    margin-bottom: 2px;
    overflow-x: auto;
}

/* Both .ug-chords and .ug-lyrics MUST share identical font metrics so that
   character column positions align. Any weight difference between the two rows
   will cause bold characters to have different advance widths, breaking alignment.
   Use color (not weight) to distinguish chords from lyrics. */
.ug-chords {
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
    font-size: 12px;
    font-weight: 400;
    white-space: pre;
    color: var(--blue);
    line-height: 1.4;
}

.ug-chord {
    /* Individual chord span — keeps chords selectable for future click-to-diagram */
}
.ug-repeat-marker {
    color: #888;
    font-size: 0.85em;
}

.ug-lyrics {
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
    font-size: 12px;
    font-weight: 400;
    white-space: pre;
    color: var(--text);
    line-height: 1.5;
}

/* Plain text lyrics (no chords above) — allow wrapping */
.ug-lyrics-plain {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ug-tab-block {
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
    font-size: 11px;
    white-space: pre;
    overflow-x: auto;
    color: var(--text-muted);
    margin: 4px 0 8px;
    line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}

/* ── Tab block colorization (inside reader) ── */
.ug-reader-scroll .ug-tab-block {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    padding: 10px 14px;
    line-height: 1;
}
/* Fret numbers — the primary information */
.ug-reader-scroll .ug-tab-block .tb-num {
    color: #fff;
    font-weight: 700;
    position: relative;
    z-index: 1;
}
/* String dashes — replaced with solid lines */
.ug-reader-scroll .ug-tab-block .tb-str {
    color: transparent;
    background: linear-gradient(
        transparent calc(50% - 0.5px),
        rgba(255, 255, 255, 0.18) calc(50% - 0.5px),
        rgba(255, 255, 255, 0.18) calc(50% + 0.5px),
        transparent calc(50% + 0.5px)
    );
}
/* Bar lines — subtle vertical separators */
.ug-reader-scroll .ug-tab-block .tb-bar {
    color: rgba(255, 255, 255, 0.3);
}
/* String prefixes (e, B, G, D, A, E) */
.ug-reader-scroll .ug-tab-block .tb-pfx {
    color: rgba(255, 255, 255, 0.45);
    font-weight: 600;
}
/* Technique markers (h=hammer, p=pull, b=bend, r=release) */
.ug-reader-scroll .ug-tab-block .tb-tech {
    color: #e8a04e;
    font-weight: 600;
}
/* Annotation lines (chord names, rhythm markers above tab) */
.ug-reader-scroll .ug-tab-block .tb-ann {
    display: inline-block;
    width: 100%;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
    line-height: 1.6;
}

/* ── Overlay container ── */

#ug-reader-overlay {
    display: none;          /* shown via JS: style.display = 'flex' */
    position: fixed;
    inset: 0;
    z-index: 200;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}

/* ── Trippy canvas ── */

.ug-trippy-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.ug-trippy-canvas.hidden { display: none; }

/* ── Trippy button ── */

.ug-tb-trippy-btn {
    transition: all 0.3s ease;
}
.ug-tb-trippy-btn.active {
    background: linear-gradient(135deg, #ff006e, #8338ec, #3a86ff, #06d6a0);
    background-size: 300% 300%;
    animation: trippyBtnShift 3s ease infinite;
    color: #fff !important;
    border-color: transparent !important;
    box-shadow: 0 0 12px rgba(131, 56, 236, 0.5);
}
@keyframes trippyBtnShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ── Header ── */

.ug-reader-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 8px;
}

.ug-rh-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.ug-rh-titles {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    flex: 1;
    overflow: hidden;      /* clips the marquee when a line scrolls */
    gap: 1px;
}
.ug-rh-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.ug-rh-sub {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
/* When a line is wider than the header, scroll it (ticker) instead of clipping. The
   distance + duration come from JS-set CSS vars so the scroll matches the text length. */
.ug-rh-title.ug-rh-scroll,
.ug-rh-sub.ug-rh-scroll {
    overflow: visible;
    text-overflow: clip;
    animation: ug-rh-marquee var(--marquee-dur, 8s) linear infinite alternate;
}
@keyframes ug-rh-marquee {
    0%, 12%   { transform: translateX(0); }
    88%, 100% { transform: translateX(var(--marquee-shift, 0)); }
}
@media (prefers-reduced-motion: reduce) {
    .ug-rh-title.ug-rh-scroll,
    .ug-rh-sub.ug-rh-scroll { animation: none; }
}

.ug-rh-meta {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Play-history stat line — desktop only, sized to read from across the room mid-jam. */
.ug-rh-stats { display: none; }
@media (min-width: 900px) {
    .ug-rh-stats {
        display: flex;
        align-items: center;
        flex: 0 1 auto;
        min-width: 0;
        max-width: 55%;
        font-size: 24px;
        line-height: 1.2;
        color: var(--text-muted);
        white-space: nowrap;
    }
    .ug-rh-stats.hidden { display: none; }
}
.ug-rh-stats-line {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.4s ease;
}
.ug-rh-stats-line.fading { opacity: 0; }
.ug-rh-stats b {
    color: var(--accent, #d4622a);
    font-weight: 700;
}

.ug-rh-close {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.ug-rh-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
}
.ug-rh-right-top {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ug-rh-mobile-info {
    display: none;
}
.ug-rh-mobile-song, .ug-rh-mobile-artist {
    display: block;
    text-align: right;
    line-height: 1.3;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ug-rh-mobile-song {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
}
.ug-rh-mobile-artist {
    font-size: 10px;
    color: var(--text-muted);
}

.ug-rh-art {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    margin-right: 6px;
}

/* ── Scroll area ── */

.ug-reader-scroll {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    scroll-behavior: auto; /* JS handles all smooth scrolling via rAF */
}

/* Font-size variable applied to chord+lyric rows AND tab blocks */
.ug-reader-scroll .ug-chords,
.ug-reader-scroll .ug-lyrics,
.ug-reader-scroll .ug-tab-block {
    font-size: var(--ug-font-size, 20px);
}

/* Extra breathing room between tab systems in the reader */
.ug-reader-scroll .ug-tab-block {
    margin-bottom: 24px;
}

/* Centered content area — width scales with font so margins auto-balance.
   Capped at 96vw so larger fonts still get the full viewport. */
.ug-reader-content {
    max-width: min(96vw, calc(var(--ug-font-size, 20px) * 48));
    margin: 0 auto;
    padding: 8px 12px;
}

/* Section labels (VERSE, CHORUS etc) larger with breathing room */
.ug-reader-scroll .ug-section {
    padding-top: 40px;
}
.ug-reader-scroll .ug-section:first-child {
    padding-top: 8px;
}
.ug-reader-scroll .ug-section-label {
    font-size: 16px;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}
/* Brief highlight on the section landed on by a V / C / B jump */
.ug-reader-scroll .ug-section-label.ug-section-flash {
    animation: ug-section-flash 1.2s ease-out;
}
@keyframes ug-section-flash {
    0%, 30% { color: var(--accent, #f5a623); }
    100%    { color: var(--text-muted); }
}

/* Chord spans become tappable in reader */
.ug-reader-content .ug-chord {
    cursor: pointer;
}
.ug-reader-content .ug-chord:active {
    opacity: 0.6;
}
.ug-reader-content .ug-tab-block .ug-chord {
    color: var(--blue);
}

/* ── Toolbar ── */

.ug-reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0 12px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    gap: 6px;
}

/* Hide chord scroll and trippy mode buttons */
.ug-tb-chord-scroll-btn,
.ug-tb-trippy-btn { display: none !important; }

/* Row break only visible on mobile (used by flex-wrap layout) */
.ug-tb-row-break { display: none; }

.ug-tb-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ug-tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2, var(--surface));
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.ug-tb-btn:active { background: var(--border); }
.ug-tb-instrument-btn { color: var(--accent); }
.ug-tb-instrument-btn .hidden { display: none; }

#ug-tb-versions {
    width: auto;
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
}

.ug-tb-autoscroll {
    padding: 0 10px;
    height: 32px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--surface2, var(--surface));
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ug-tb-autoscroll.active {
    background: var(--blue, #007aff);
    border-color: var(--blue, #007aff);
    color: #fff;
}
.ug-tb-autoscroll:active { opacity: 0.75; }
/* Waiting for the vocals ("Listening…"): armed after "from the top", or paused at a break /
   the next lyric. No background swap (the grey flash was jarring) — the button keeps its
   look (blue while scrolling, clear before) and just breathes a soft ring. */
.ug-tb-autoscroll.armed {
    border-color: var(--blue, #007aff);
    animation: ug-armed-pulse 1.8s ease-in-out infinite;
}
.ug-tb-autoscroll.armed:not(.active) {
    background: transparent;
    color: var(--blue, #007aff);
}
@keyframes ug-armed-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0); }
    50%      { box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.28); }
}

/* ── Follow (mic) button: on / listening / heard / lost / unavailable ── */
.ug-tb-follow-btn { color: var(--text-muted, #888); }
.ug-tb-follow-btn .ug-follow-slash { display: none; }
.ug-tb-follow-btn.on { color: var(--text); }
.ug-tb-follow-btn.listening {
    color: #fff;
    background: #2e9d5b;
    border-color: #2e9d5b;
}
.ug-tb-follow-btn.lost {
    color: #2e9d5b;
    border-color: #2e9d5b;
}
.ug-tb-follow-btn.heard { animation: ug-follow-heard-btn 0.6s ease-out; }
@keyframes ug-follow-heard-btn {
    0%   { box-shadow: 0 0 0 0 rgba(46, 157, 91, 0.6); }
    100% { box-shadow: 0 0 0 7px rgba(46, 157, 91, 0); }
}
.ug-tb-follow-btn.unavailable,
.ug-tb-follow-btn:not(.on):not(.unavailable) { opacity: 0.55; }
.ug-tb-follow-btn.unavailable .ug-follow-slash,
.ug-tb-follow-btn:not(.on) .ug-follow-slash { display: inline; }

/* The lyric line Follow just recognised — a thin green tick in the left margin that fades,
   so you can see it's tracking. (Was a background flash over the whole line: too loud.) */
.ug-line.ug-follow-heard { animation: ug-follow-heard-tick 1.6s ease-out; }
@keyframes ug-follow-heard-tick {
    0%   { box-shadow: inset 3px 0 0 rgba(46, 157, 91, 0.9); }
    100% { box-shadow: inset 3px 0 0 rgba(46, 157, 91, 0); }
}

/* Mode label on the mic button: "Lyrics" / "Follow" */
/* Same width in every mode (Off / Lyrics / Follow) so the controls beside it never shift */
#ug-tb-follow { width: 78px; padding: 0 6px; gap: 4px; justify-content: flex-start; }
.ug-follow-label { font-size: 11px; font-weight: 700; }

/* ── Chord Scroll button ── */

.ug-tb-chord-scroll-btn {
    padding: 0 12px;
    height: 34px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--surface2, var(--surface));
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    width: auto;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ug-tb-chord-scroll-btn.active {
    background: var(--accent, #e0723a);
    border-color: var(--accent, #e0723a);
    color: #fff;
}
.ug-tb-chord-scroll-btn:active { opacity: 0.75; }

/* ── Chord Scroll waypoint highlights ── */

.ug-chord.cs-current {
    background: rgba(224, 114, 58, 0.22);
    border-radius: 3px;
    outline: 1.5px solid rgba(224, 114, 58, 0.7);
    color: var(--accent, #e0723a);
}
.ug-chord.cs-upcoming {
    border-bottom: 2px solid rgba(224, 114, 58, 0.35);
}

/* ── Chord Scroll active: pointer cursor on chords ── */

.ug-chord-scroll-active .ug-chord {
    cursor: crosshair;
}
.ug-chord-scroll-active .ug-chord:hover {
    outline: 1.5px dashed rgba(224, 114, 58, 0.5);
    border-radius: 3px;
}

/* ── Chord Scroll detection badge ── */

.ug-cs-badge {
    position: fixed;
    bottom: 72px; /* above the toolbar */
    right: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(20, 20, 22, 0.88);
    border: 1px solid rgba(224, 114, 58, 0.3);
    border-radius: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-size: 13px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
    color: #e0723a;
    z-index: 500;
    pointer-events: none;
    user-select: none;
}
.ug-cs-badge.hidden { display: none; }

/* ── Speed calibration bubble (transient feedback) ── */

.ug-speed-bubble {
    position: fixed;
    bottom: 72px; /* above the toolbar */
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    background: rgba(20, 20, 22, 0.88);
    border: 1px solid rgba(224, 114, 58, 0.3);
    border-radius: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-size: 13px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
    color: #e0723a;
    z-index: 500;
    pointer-events: none;
    user-select: none;
}
.ug-speed-bubble.hidden { display: none; }
.ug-cs-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e0723a;
    animation: cs-pulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes cs-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.7); }
}

.ug-tb-font { font-size: 11px; width: 28px; }

.ug-tb-speed-group { gap: 4px; }

.ug-tb-icon { font-size: 14px; line-height: 1; cursor: pointer; user-select: none; }

.ug-tb-speed {
    width: 144px;
    cursor: pointer;
    accent-color: var(--blue, #007aff);
}

/* Key button — replaces old +0 transpose span */
.ug-tb-key-btn {
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
    font-size: 12px;
    font-weight: 700;
    min-width: 34px;
    letter-spacing: 0;
}

/* Key picker popup — opens upward from toolbar */
.ug-key-picker {
    position: absolute;
    z-index: 400;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.ug-key-picker button {
    font-size: 12px;
    font-weight: 600;
    padding: 5px 4px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    min-width: 34px;
    text-align: center;
    transition: background 0.1s;
}
.ug-key-picker button:hover { background: var(--surface-hover, #f0f0f0); }
.ug-key-picker button.active {
    background: var(--blue, #007aff);
    color: #fff;
    border-color: var(--blue, #007aff);
}

/* Transpose group container for picker positioning */
.ug-tb-transpose-group {
    position: relative;
}

/* Capo picker */
.ug-tb-capo-group {
    position: relative;
}
.ug-tb-capo-val {
    font-size: 12px;
    font-weight: 600;
    min-width: 56px;
    white-space: nowrap;
}

/* Capo / tuning meta display */
.ug-tb-meta-group {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    padding: 0 4px;
}

/* ── Save button ── */

.ug-tb-save-btn {
    padding: 0 10px;
    height: 32px;
    width: auto;
    border-radius: 8px;
    border: 1.5px solid var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}
.ug-tb-save-btn:active { background: var(--accent); color: #fff; }
.ug-tb-save-btn:disabled { opacity: 0.6; cursor: default; }

/* ── Star button ── */

.ug-tb-star-btn { font-size: 18px; }
.ug-tb-star-btn.starred { color: #f0a030; }

/* ── Versions sheet ── */

.ug-versions-sheet {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.ug-versions-sheet.hidden {
    display: none;
}

.ug-versions-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.ug-versions-panel {
    position: relative;
    background: var(--surface, #fff);
    border-radius: 16px 16px 0 0;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.ug-versions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border, #e5e5ea);
    flex-shrink: 0;
}

.ug-versions-title {
    font-size: 16px;
    font-weight: 600;
}

.ug-versions-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted, #6e6e73);
    cursor: pointer;
    padding: 4px 8px;
}

.ug-versions-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.ug-version-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #e5e5ea);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ug-version-item:last-child {
    border-bottom: none;
}

.ug-version-item:active {
    background: var(--surface2, #f2f2f7);
}

.ug-version-item.active {
    background: rgba(212, 98, 42, 0.06);
}

.ug-version-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent, #d4622a);
    background: rgba(212, 98, 42, 0.10);
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

.ug-version-info {
    flex: 1;
    min-width: 0;
}

.ug-version-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ug-version-meta {
    font-size: 12px;
    color: var(--text-muted, #6e6e73);
    margin-top: 2px;
}

.ug-version-check {
    color: var(--accent, #d4622a);
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.ug-versions-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    font-size: 13px;
    color: var(--text-muted, #6e6e73);
    border-top: 1px solid var(--border, #e5e5ea);
}

.ug-versions-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border, #e5e5ea);
    border-top-color: var(--accent, #d4622a);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

/* ── Theory button & picker ── */

.ug-tb-theory-btn {
    width: auto;
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.02em;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.ug-tb-theory-btn.active {
    background: var(--accent, #d4622a);
    color: #fff;
}

#ug-theory-group {
    position: relative;
}

.ug-theory-picker {
    position: fixed;
    background: var(--surface, #1c1c1e);
    border: 1px solid var(--border, #38383a);
    border-radius: 10px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 1200;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    min-width: 120px;
}
.ug-theory-picker.hidden { display: none; }

.ug-theory-level {
    display: block;
    width: 100%;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text, #e5e5e7);
    cursor: pointer;
    transition: background 0.1s;
}
.ug-theory-level:hover { background: var(--surface2, #2c2c2e); }
.ug-theory-level.active {
    background: var(--accent, #d4622a);
    color: #fff;
}
.ug-theory-off {
    color: var(--text-muted, #6e6e73);
    border-top: 1px solid var(--border, #38383a);
    border-radius: 0 0 7px 7px;
    margin-top: 2px;
    padding-top: 8px;
}

/* ── Tempo control ── */

.ug-tb-tempo-group {
    gap: 6px;
    align-items: center;
}
.ug-tb-tempo-group.hidden { display: none; }

.ug-tb-tempo-label {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted, #6e6e73);
    min-width: 28px;
    text-align: center;
}
.ug-tb-tempo-label::after {
    content: ' bpm';
    font-size: 9px;
}

.ug-tb-tempo-slider {
    width: 70px;
    accent-color: var(--accent, #d4622a);
}

/* ── Section progression ── */

.ug-section-prog {
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: none;
    color: var(--accent, #d4622a);
    opacity: 0.85;
    vertical-align: middle;
}

/* ── Share button & toast ── */

.ug-share-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.ug-share-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.ug-share-btn:active { opacity: 0.7; }
.ug-share-btn.hidden { display: none; }
.ug-share-btn svg { pointer-events: none; }

.ug-share-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: rgba(30, 32, 38, 0.92);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 7px;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 1100;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.ug-share-toast svg { color: #30d158; flex-shrink: 0; }
.ug-share-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Spotify toggle & embed ── */

.ug-spotify-toggle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: #1DB954;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    padding: 0;
}
.ug-spotify-toggle:hover { background: #1ed760; }
.ug-spotify-toggle.hidden { display: none; }
.ug-spotify-toggle svg { pointer-events: none; }

.ug-spotify-embed {
    position: fixed;
    top: 48px;
    right: 12px;
    z-index: 1060;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.ug-spotify-embed.hidden { display: none; }
/* Prewarm: keeps the iframe loading + ready to play, but invisible/inert */
.ug-spotify-embed.prewarm {
    display: block;
    position: fixed;
    top: -9999px;
    left: -9999px;
    right: auto;
    opacity: 0;
    pointer-events: none;
    box-shadow: none;
}
.ug-spotify-embed iframe {
    display: block;
    border-radius: 12px;
}

/* Apple Music listeners: same button + slot, Apple's colour, holds the shared player card */
.ug-spotify-toggle.ug-apple { background: #fa2d48; }
.ug-spotify-toggle.ug-apple:hover { background: #ff4560; }
.ug-spotify-embed.ug-apple-embed { width: min(340px, calc(100vw - 24px)); }


/* ── Scale toggle ── */

.ug-scale-toggle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #d8d0c6;
    background: #f0ebe3;
    color: #8a8070;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}
.ug-scale-toggle:hover {
    background: #e8e0d6;
    color: #6a6055;
    border-color: #c4baa8;
}
.ug-scale-toggle.active {
    background: #c87a4e;
    color: #fff;
    border-color: #b56a3e;
    box-shadow: 0 1px 4px rgba(200, 110, 60, 0.25);
}
.ug-scale-toggle.hidden { display: none; }
.ug-scale-toggle svg { pointer-events: none; }

/* ── Help toggle (?) ── */

.ug-help-toggle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #d8d0c6;
    background: #f0ebe3;
    color: #8a8070;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.ug-help-toggle:hover {
    background: #e8e0d6;
    color: #6a6055;
    border-color: #c4baa8;
}
.ug-help-toggle:active { transform: translateY(0.5px); }
.ug-help-toggle svg { pointer-events: none; }
[data-theme="dark"] .ug-help-toggle {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.14);
    color: rgba(255,255,255,0.7);
}
[data-theme="dark"] .ug-help-toggle:hover {
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.22);
    color: #fff;
}

/* ── Tooltip (CSS-only, opt-in via .ug-has-tooltip + data-tooltip="…") ── */

.ug-has-tooltip { position: relative; }

.ug-has-tooltip::after,
.ug-has-tooltip::before {
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease 0.25s, transform 0.18s ease 0.25s;
    position: absolute;
    z-index: 1300;
}
.ug-has-tooltip::after {
    content: attr(data-tooltip);
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    background: rgba(28, 22, 16, 0.95);
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.ug-has-tooltip::before {
    content: '';
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: rgba(28, 22, 16, 0.95);
}
.ug-has-tooltip:hover::after,
.ug-has-tooltip:hover::before,
.ug-has-tooltip:focus-visible::after,
.ug-has-tooltip:focus-visible::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.ug-has-tooltip:focus-visible::before {
    transform: translateX(-50%);
}
[data-theme="dark"] .ug-has-tooltip::after {
    background: rgba(245, 240, 232, 0.95);
    color: #1c1c1e;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}
[data-theme="dark"] .ug-has-tooltip::before {
    border-bottom-color: rgba(245, 240, 232, 0.95);
}
/* Hide tooltip on touch devices (where hover is sticky and looks broken) */
@media (hover: none) {
    .ug-has-tooltip::after,
    .ug-has-tooltip::before {
        display: none;
    }
}

/* ── Help modal ── */

.ug-help-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.22s ease;
    pointer-events: none;
}
.ug-help-modal.hidden { display: none; }
.ug-help-modal.ug-help-open {
    opacity: 1;
    pointer-events: auto;
}

.ug-help-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 16, 12, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ug-help-card {
    position: relative;
    z-index: 1;
    width: min(460px, 100%);
    max-height: calc(100dvh - 48px);
    overflow: hidden;
    background: var(--surface);
    border-radius: 18px;
    box-shadow:
        0 32px 80px rgba(20, 14, 8, 0.32),
        0 0 0 1px var(--border);
    transform: translateY(14px) scale(0.98);
    transition: transform 0.28s cubic-bezier(0.2, 0.85, 0.25, 1);
}
.ug-help-modal.ug-help-open .ug-help-card {
    transform: translateY(0) scale(1);
}
.ug-help-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, rgba(212, 98, 42, 0.45) 50%, transparent 100%);
    pointer-events: none;
}

.ug-help-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    z-index: 2;
}
.ug-help-close:hover {
    background: var(--surface2, var(--border));
    color: var(--text);
}

.ug-help-card-inner {
    padding: 28px 28px 22px;
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
}

.ug-help-eyebrow {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 6px;
}

.ug-help-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 22px;
    letter-spacing: -0.01em;
}

.ug-help-rows {
    display: flex;
    flex-direction: column;
}
.ug-help-row {
    display: grid;
    grid-template-columns: minmax(110px, auto) 1fr;
    gap: 18px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.ug-help-row:last-child { border-bottom: none; }

.ug-help-keys {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    padding-top: 1px;
}
.ug-help-sep {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 400;
    user-select: none;
}

.ug-help-desc {
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
}
.ug-help-desc em {
    font-style: normal;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.ug-help-footer {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── kbd pill — tactile keyboard-key style ── */

.ug-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 6px;
    font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
    color: var(--text);
    background: linear-gradient(180deg, #ffffff 0%, #f4f0e9 100%);
    border: 1px solid #d8d0c6;
    box-shadow:
        inset 0 -1.5px 0 rgba(120, 100, 80, 0.18),
        0 1px 2px rgba(120, 100, 80, 0.08);
    user-select: none;
    flex-shrink: 0;
}
.ug-kbd-wide { padding: 0 14px; }
.ug-kbd-tiny {
    height: 20px;
    min-width: 20px;
    padding: 0 6px;
    font-size: 10px;
    border-radius: 4px;
}
[data-theme="dark"] .ug-kbd {
    background: linear-gradient(180deg, #2a2a2d 0%, #1f1f22 100%);
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--text);
    box-shadow:
        inset 0 -1.5px 0 rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ── Mobile tweaks ── */

@media (max-width: 480px) {
    .ug-help-modal { padding: 16px; }
    .ug-help-card-inner { padding: 24px 20px 18px; }
    .ug-help-title { font-size: 19px; margin-bottom: 18px; }
    .ug-help-row {
        grid-template-columns: minmax(96px, auto) 1fr;
        gap: 14px;
        padding: 11px 0;
    }
    .ug-help-desc { font-size: 13px; }
    .ug-kbd { min-width: 26px; height: 26px; font-size: 11px; padding: 0 7px; }
    .ug-kbd-wide { padding: 0 12px; }
}

/* ── Scale panel ── */

.ug-scale-panel {
    position: absolute;
    top: 52px;
    right: 8px;
    z-index: 55;
    background: rgba(252, 249, 244, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 10px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.10),
        0 1px 4px rgba(0, 0, 0, 0.06),
        inset 0 0 0 1px rgba(0, 0, 0, 0.06);
    padding: 8px 10px 24px;
    overflow: visible;
    user-select: none;
    -webkit-user-select: none;
    max-width: 96vw;
}
.ug-scale-panel.hidden { display: none; }
.ug-scale-panel button { cursor: pointer; }

.ug-scale-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
    padding: 2px 4px;
    cursor: grab;
}
.ug-scale-header:active {
    cursor: grabbing;
}

.ug-scale-label {
    font-size: 12px;
    font-weight: 700;
    color: #5a5248;
    white-space: nowrap;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ug-scale-mode-label {
    font-size: 9px;
    color: #9a9490;
    white-space: nowrap;
    font-style: italic;
    /* Truncate rather than push the header's toggles off the panel */
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ug-scale-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ug-scale-close {
    background: none;
    border: none;
    color: #b0a8a0;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 5px;
    transition: color 0.15s, background 0.15s;
}
.ug-scale-close:hover {
    color: #6a6258;
    background: rgba(0, 0, 0, 0.08);
}

.ug-scale-type-toggle {
    display: flex;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.10);
    flex-shrink: 0;
}

.ug-scale-type-btn {
    background: transparent;
    border: none;
    color: #9a9490;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
}
.ug-scale-type-btn:first-child { border-right: 1px solid rgba(0, 0, 0, 0.08); }
/* Notes/Degrees labels sit alongside Full/Pent — slightly tighter so both fit */
.ug-scale-labels-toggle .ug-scale-type-btn { padding: 4px 9px; }
.ug-scale-type-btn.active {
    background: rgba(200, 110, 60, 0.15);
    color: #b06830;
    font-weight: 700;
}
.ug-scale-type-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.05);
    color: #6a6258;
}

/* ── Scale fretboard grid ── */

.ug-scale-fretboard {
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    background: #f0ebe3;
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 2px 0;
    position: relative;
    z-index: 1;
}

.ug-sf-inner {
    display: inline-block;
    min-width: max-content;
}

/* Fret numbers */
.ug-sf-fret-numbers {
    display: flex;
    align-items: center;
    height: 14px;
}

.ug-sf-fret-num {
    width: 32px;
    text-align: center;
    font-size: 8px;
    font-weight: 600;
    color: #a09888;
    flex-shrink: 0;
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
}
.ug-sf-fret-num-muted {
    width: 32px;
    flex-shrink: 0;
}

/* String labels */
.ug-sf-string-label-cell {
    width: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ug-sf-string-label {
    font-size: 9px;
    font-weight: 700;
    color: #a09888;
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
}

/* String rows */
.ug-sf-string-row {
    display: flex;
    align-items: center;
}

/* Fret cells */
.ug-sf-cell {
    width: 32px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    /* String wire — warm gray line through center */
    background: linear-gradient(
        to bottom,
        transparent calc(50% - 0.5px),
        #c8c0b4 calc(50% - 0.5px),
        #c8c0b4 calc(50% + 0.5px),
        transparent calc(50% + 0.5px)
    );
    /* Fret wire */
    border-right: 1px solid #d8d0c6;
}

/* Nut — thicker, darker line after open strings */
.ug-sf-string-label-cell + .ug-sf-cell {
    border-right: 2.5px solid #8a8070;
}

/* Scale degree dots — base style (non-chord-tone scale notes) */
.ug-sf-dot {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #cec6be;
    border: 1px solid #b8b0a8;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07);
    transition: transform 0.1s ease;
}

/* 1 — Root: app signature orange, largest */
.ug-sf-dot-root {
    width: 22px;
    height: 22px;
    background: #d4622a;
    border: 1.5px solid #b8501f;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.22),
        0 2px 5px rgba(212, 98, 42, 0.40);
}

/* 3 — Third: sky blue */
.ug-sf-dot-third {
    width: 20px;
    height: 20px;
    background: #4a86c8;
    border: 1.5px solid #3870ae;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.20),
        0 2px 4px rgba(74, 134, 200, 0.35);
}

/* 5 — Fifth: sage green */
.ug-sf-dot-fifth {
    width: 20px;
    height: 20px;
    background: #4aa06b;
    border: 1.5px solid #378a56;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.20),
        0 2px 4px rgba(74, 160, 107, 0.35);
}

/* 7 — Seventh: muted violet */
.ug-sf-dot-seventh {
    width: 19px;
    height: 19px;
    background: #8a6aae;
    border: 1.5px solid #745a96;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 2px 4px rgba(138, 106, 174, 0.30);
}

/* Note name text — all dots */
.ug-sf-note-text {
    font-size: 8.5px;
    font-weight: 700;
    line-height: 1;
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
    color: #7a7268;
    letter-spacing: -0.3px;
}

/* White text on coloured chord-tone dots */
.ug-sf-dot-root .ug-sf-note-text,
.ug-sf-dot-third .ug-sf-note-text,
.ug-sf-dot-fifth .ug-sf-note-text,
.ug-sf-dot-seventh .ug-sf-note-text {
    color: #fff;
    font-size: 8px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}

/* Root slightly larger text */
.ug-sf-dot-root .ug-sf-note-text {
    font-size: 9px;
}

/* Scale-degree labels (1, ♭3, 5…) — shorter than note names, so they can run
   a touch larger for readability. Specificity beats the per-dot sizes above. */
.ug-sf-dot .ug-sf-note-text.is-degree {
    font-size: 9.5px;
    letter-spacing: -0.1px;
}
.ug-sf-dot-root .ug-sf-note-text.is-degree {
    font-size: 10.5px;
}

/* Legend row */
.ug-sf-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    row-gap: 2px;
    padding: 6px 10px 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
    margin-top: 3px;
}

.ug-sf-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 600;
    color: #8a8278;
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
    letter-spacing: 0.01em;
}

.ug-sf-legend-sep {
    width: 1px;
    height: 10px;
    background: rgba(0, 0, 0, 0.12);
    margin: 0 10px;
    flex-shrink: 0;
}

.ug-sf-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #cec6be;
    border: 1px solid rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

.ug-sf-legend-root    { background: #d4622a; border-color: #b8501f; }
.ug-sf-legend-third   { background: #4a86c8; border-color: #3870ae; }
.ug-sf-legend-fifth   { background: #4aa06b; border-color: #378a56; }
.ug-sf-legend-seventh { background: #8a6aae; border-color: #745a96; }

/* ── Chord tone selector row ── */

.ug-sf-chord-selector {
    display: flex;
    align-items: stretch;
    gap: 5px;
    padding: 4px 4px 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.ug-sf-chord-selector::-webkit-scrollbar { display: none; }
.ug-sf-chord-selector:empty { display: none; }

.ug-sf-chord-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 42px;
    padding: 5px 10px 4px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: rgba(0, 0, 0, 0.03);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.ug-sf-chord-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.07);
    border-color: rgba(0, 0, 0, 0.15);
}
.ug-sf-chord-btn.active {
    background: rgba(200, 110, 60, 0.16);
    border-color: rgba(200, 110, 60, 0.35);
    box-shadow: 0 1px 4px rgba(200, 110, 60, 0.15);
}

.ug-sf-chord-name {
    font-size: 12px;
    font-weight: 700;
    color: #7a7268;
    line-height: 1.1;
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.ug-sf-chord-btn.active .ug-sf-chord-name {
    color: #b06830;
}

.ug-sf-chord-roman {
    font-size: 9px;
    font-weight: 600;
    color: #a09890;
    line-height: 1;
    letter-spacing: 0.02em;
}
.ug-sf-chord-btn.active .ug-sf-chord-roman {
    color: #c8925a;
}

/* Resize grips — bottom corners of the scale panel */
.ug-sf-resize-grip {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    border-radius: 0 0 10px 0;
    z-index: 100;
    background-image: linear-gradient(
        135deg,
        transparent 0,
        transparent 45%,
        rgba(106, 96, 85, 0.55) 45%,
        rgba(106, 96, 85, 0.55) 55%,
        transparent 55%,
        transparent 70%,
        rgba(106, 96, 85, 0.55) 70%,
        rgba(106, 96, 85, 0.55) 80%,
        transparent 80%
    );
    opacity: 0.7;
    transition: opacity 0.15s ease;
    touch-action: none;
}
.ug-sf-resize-grip:hover {
    opacity: 1;
}

.ug-sf-resize-grip-left {
    right: auto;
    left: 0;
    cursor: nesw-resize;
    border-radius: 0 0 0 10px;
    transform: scaleX(-1);
}

[data-theme="dark"] .ug-sf-resize-grip {
    background-image: linear-gradient(
        135deg,
        transparent 0,
        transparent 45%,
        rgba(220, 210, 195, 0.45) 45%,
        rgba(220, 210, 195, 0.45) 55%,
        transparent 55%,
        transparent 70%,
        rgba(220, 210, 195, 0.45) 70%,
        rgba(220, 210, 195, 0.45) 80%,
        transparent 80%
    );
}

/* ── Chord popup ── */

#ug-chord-popup {
    display: none;       /* shown/hidden via JS */
    position: fixed;
    z-index: 300;
    width: 162px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    overflow: hidden;
}

.ug-cp-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0 2px;
}

.ug-cp-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.ug-cp-diagram {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px 0;
    min-height: 80px;
}

.ug-cp-no-diagram {
    font-size: 12px;
    color: var(--text-muted);
    padding: 16px;
    text-align: center;
}

.ug-cp-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px 8px;
    gap: 8px;
}

.ug-cp-idx {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 28px;
    text-align: center;
}

/* Override dark overlay button styling inside the light chord popup */
#ug-chord-popup .ug-tb-btn,
#ug-reader-overlay #ug-chord-popup .ug-tb-btn {
    border-color: #e5e5ea;
    background: #f2f2f7;
    color: #1c1c1e;
}
#ug-chord-popup .ug-tb-btn:active { background: #e5e5ea; }

/* ── Mobile reader ── */

@media (max-width: 768px) {
    .ug-reader-header {
        padding: 6px 12px;
    }
    .ug-rh-art {
        width: 34px;
        height: 34px;
        margin-right: 0;      /* no dead space after the artwork */
    }
    .ug-rh-badge {
        display: none;        /* reclaim horizontal space for the song/artist */
    }
    .ug-rh-left {
        gap: 8px;
    }
    .ug-rh-title {
        font-size: 13.5px;
        line-height: 1.2;
    }
    .ug-rh-sub {
        font-size: 11.5px;
        line-height: 1.2;
    }
    .ug-rh-meta {
        display: none !important;
    }
    .ug-rh-mobile-info {
        display: none;        /* replaced by the two-line title block on the left */
    }
    .ug-reader-content {
        max-width: 100%;
        padding: 4px 8px;
    }
    .ug-reader-scroll .ug-section {
        padding-top: 24px;
    }
    .ug-reader-scroll .ug-section:first-child {
        padding-top: 8px;
    }
    .ug-line {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .ug-reader-toolbar {
        flex-wrap: wrap;
        justify-content: center;
        min-height: auto;
        padding: 6px 8px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
        gap: 6px 8px;
        width: 100%;
        box-sizing: border-box;
    }
    /* Row 1 (top) — secondary: font, theory, save, star */
    #ug-font-group        { order: 1; }
    #ug-theory-group      { order: 2; }
    .ug-tb-tempo-group    { order: 3; }
    #ug-save-group        { order: 4; }
    #ug-star-group        { order: 5; }
    #ug-instrument-group  { display: none !important; }
    .ug-tb-meta-group     { display: none !important; }
    /* Row break — visible only on mobile */
    .ug-tb-row-break {
        display: block;
        flex-basis: 100%;
        height: 0;
        order: 10;
    }
    /* Row 2 (bottom, thumb zone) — primary: autoscroll+speed, transpose, versions */
    .ug-tb-speed-group    { order: 11; }
    .ug-tb-transpose-group { order: 12; }
    #ug-versions-group    { order: 13; }
    /* Hide capo on mobile — use transpose/key instead */
    .ug-tb-capo-group     { display: none !important; }

    /* Compact sizing */
    .ug-tb-speed {
        width: 80px;
    }
    .ug-tb-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
        border-radius: 6px;
    }
    .ug-tb-autoscroll {
        height: 28px;
        padding: 0 8px;
        font-size: 12px;
        font-weight: 600;
    }
    .ug-tb-capo-val {
        min-width: 44px;
        font-size: 11px;
    }
    .ug-tb-font {
        font-size: 10px;
        width: 24px;
    }
    .ug-tb-key-btn {
        font-size: 11px;
        min-width: 28px;
    }
    /* Text buttons must expand to fit their label */
    .ug-tb-autoscroll,
    .ug-tb-save-btn,
    .ug-tb-theory-btn,
    #ug-tb-versions {
        width: auto !important;
        font-size: 12px !important;
        font-weight: 600 !important;
        height: 28px;
        padding: 0 8px;
    }
    .ug-tb-star-btn {
        width: 28px;
        height: 28px;
    }
    #ug-chord-popup {
        width: 140px;
    }
    .ug-key-picker {
        grid-template-columns: repeat(3, 1fr);
        left: 0;
        transform: none;
    }
}
@media (max-width: 374px) {
    .ug-reader-content {
        padding: 4px 4px;
    }
    .ug-tb-speed {
        width: 80px;
    }
}

/* ── Inline UG Reader (Split View panels) ───────────────── */
.sv-ug-inline {
    font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Courier New', monospace;
    line-height: 1.5;
    white-space: pre;
    overflow-x: auto;
}
.sv-ug-inline .ug-section-header {
    font-weight: 700;
    color: var(--accent, #d4622a);
    margin: 14px 0 4px;
}
.sv-ug-inline .ug-chord {
    color: var(--accent, #d4622a);
    font-weight: 700;
    cursor: pointer;
}
.sv-ug-inline .ug-chord:hover {
    text-decoration: underline;
}
.sv-ug-inline .ug-tab-block {
    color: var(--text-muted, #888);
}

/* ── "What's next?" recommendations card (end of chart) ─────────────────────
   Lives inside the reader's scroll area, so it is styled for the reader's dark
   "Midnight Karaoke" theme (jam.css / songs.css) rather than the page's light tokens. */

.ug-next {
    max-width: min(96vw, 640px);
    margin: 8px auto 0;
    padding: 16px 12px calc(40px + env(safe-area-inset-bottom, 0px));
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #f0f0f5;
    position: relative;
    z-index: 1;
}
.ug-next.hidden,
.ug-next.collapsed { display: none; }

.ug-next-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.ug-next-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #f0f0f5;
}
.ug-next-auto {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.ug-next-auto input { accent-color: #2979ff; width: 16px; height: 16px; margin: 0; }

.ug-next-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.ug-next-chip {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.8);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-tap-highlight-color: transparent;
}
.ug-next-chip.active {
    background: #2979ff;
    border-color: #2979ff;
    color: #fff;
}
.ug-next-chip.ug-next-chip-add { color: #ffc940; border-style: dashed; }
.ug-next-chip:active { opacity: 0.75; }

.ug-next-custom {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}
.ug-next-custom.hidden { display: none; }
.ug-next-custom input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
    color: #f0f0f5;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
}
.ug-next-custom input::placeholder { color: rgba(255,255,255,0.4); }
.ug-next-custom button {
    border: none;
    border-radius: 10px;
    background: #2979ff;
    color: #fff;
    font-weight: 600;
    font-family: inherit;
    padding: 0 14px;
    cursor: pointer;
}

.ug-next-sub {
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    margin: 2px 0 8px;
    min-height: 16px;
}
.ug-next-retry {
    background: none;
    border: none;
    color: #ffc940;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0 0 0 6px;
}

.ug-next-list {
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    background: rgba(8,10,20,0.55);
    overflow: hidden;
}
.ug-next-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ug-next-row:last-child { border-bottom: none; }
.ug-next-row:active { background: rgba(255,255,255,0.06); }
.ug-next-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.4);
    font-size: 18px;
}
.ug-next-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ug-next-info { flex: 1; min-width: 0; }
.ug-next-name {
    font-size: 15px;
    font-weight: 600;
    color: #f0f0f5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ug-next-meta {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ug-next-reason {
    font-size: 12px;
    color: #ffc940;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ug-next-add {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.07);
    color: #ffc940;
    font-size: 20px;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.ug-next-add:disabled { cursor: default; }
.ug-next-add.done { color: #5de0d8; border-color: rgba(93,224,216,0.6); }

.ug-next-empty {
    padding: 18px 12px;
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
}
.ug-next-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 22px 12px;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
}
.ug-next-loading .ug-versions-spinner { margin: 0; border-color: rgba(255,255,255,0.15); border-top-color: #ffc940; }

.ug-tb-next-btn { font-size: 15px; }
#ug-reader-overlay .ug-tb-next-btn.active { background: #2979ff; border-color: #2979ff; color: #fff; }

/* Participants never get the card or the button — the host drives the room. */
.ug-reader-participant .ug-next,
.ug-reader-participant #ug-next-group { display: none !important; }

/* ── Follow debug overlay (D) ──
   A full-height column on the right; the tab re-centres in the space to its left. */
#ug-reader-overlay { --fdbg-w: clamp(280px, 36vw, 580px); }
.ug-fdbg-on .ug-reader-scroll { padding-right: calc(var(--fdbg-w, 36vw) + 12px); }
.ug-fdbg {
    position: fixed;
    top: 64px;            /* set from the header / toolbar in JS */
    bottom: 72px;
    right: 6px;
    width: var(--fdbg-w, 36vw);
    box-sizing: border-box;
    z-index: 3000;
    margin: 0;
    padding: 10px 12px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.88);
    color: #d6f5df;
    font: 14px/1.5 ui-monospace, 'SF Mono', Menlo, monospace;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid rgba(46, 157, 91, 0.5);
    border-radius: 8px;
}
/* Compact debug: a small translucent strip bottom-right; the tab keeps its full width */
#ug-reader-overlay.ug-fdbg-compact .ug-fdbg {
    width: min(460px, calc(100vw - 12px));
    max-height: 6.6em;
    overflow: hidden;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1.45;
    background: rgba(0, 0, 0, 0.7);
    pointer-events: none;
}
#ug-reader-overlay.ug-fdbg-compact .ug-fdbg-line { right: 0; }
.ug-fdbg-line {
    position: fixed;
    left: 0;
    right: calc(var(--fdbg-w, 36vw) + 12px);
    height: 0;
    z-index: 2999;
    pointer-events: none;
}
.ug-fdbg-line span {
    position: absolute;
    left: 6px;
    top: -17px;
    font: 11px ui-monospace, Menlo, monospace;
    padding: 0 4px;
    border-radius: 3px;
}
.ug-fdbg-band { border-top: 1px dashed rgba(255, 255, 255, 0.35); }
.ug-fdbg-band span { color: rgba(255, 255, 255, 0.6); background: rgba(0, 0, 0, 0.5); }
.ug-fdbg-you { border-top: 2px solid #2e9d5b; }
.ug-fdbg-you span { color: #fff; background: #2e9d5b; }
