/* Isolated stage surface; works in the app and the offline shell. */
.bm-stage-viewer {
    --stage-ink: var(--bm-ink, #2b2d2c);
    --stage-surface: var(--bm-surface, #fffaf0);
    --stage-soft: var(--bm-surface-soft, #f4ede0);
    --stage-muted: var(--bm-muted, #575e55);
    --stage-border: var(--bm-border, #c5b79f);
    position: fixed; inset: 0; width: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
    border: 0; color: var(--stage-ink); background: var(--stage-soft); font: 16px/1.4 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden; overscroll-behavior: none;
}
.bm-stage-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.bm-stage-viewer::backdrop { background: #141614; }
.bm-stage-viewer *, .bm-stage-viewer *::before, .bm-stage-viewer *::after { box-sizing: border-box; }
.bm-stage-viewer [hidden] { display: none !important; }
.bm-stage-viewer button, .bm-stage-viewer select, .bm-stage-viewer input { font: inherit; }
.bm-stage-viewer button, .bm-stage-viewer select { color: var(--stage-ink); }
.bm-stage-header { display: flex; align-items: center; gap: 12px; padding: max(7px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 7px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--stage-border); background: var(--stage-surface); }
.bm-stage-heading { min-width: 0; flex: 1; display: grid; gap: 2px; }
.bm-stage-heading small { font-size: 11px; color: var(--stage-muted); }
.bm-stage-song-select { display: block; min-width: 0; width: 100%; min-height: 44px; border: 0; border-radius: 6px; background: transparent; font-size: 17px !important; font-weight: 650 !important; padding: 3px 24px 3px 0; cursor: pointer; text-overflow: ellipsis; }
.bm-stage-song-select option { color: var(--stage-ink); background: var(--stage-surface); }
.bm-stage-heading small, .bm-stage-song-select { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-stage-count { font-size: 12px; color: var(--stage-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bm-stage-button { min-width: 44px; min-height: 44px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 8px 12px; cursor: pointer; }
.bm-stage-button:hover:not(:disabled), .bm-stage-button[aria-pressed="true"], .bm-stage-button[aria-expanded="true"] { background: var(--stage-soft); border-color: var(--stage-border); }
.bm-stage-button:disabled { opacity: .35; cursor: default; }
.bm-stage-button:focus-visible, .bm-stage-viewer select:focus-visible, .bm-stage-viewer input:focus-visible { outline: 2px solid var(--stage-ink); outline-offset: 2px; }
.bm-stage-header .bm-stage-button { font-size: 26px; font-weight: 300; padding: 0; }
.bm-stage-viewport { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; position: relative; outline: none; touch-action: pan-x pan-y pinch-zoom; }
.bm-stage-viewport[data-fit="true"] { touch-action: pan-y pinch-zoom; }
.bm-stage-content { min-height: 100%; width: max-content; min-width: 100%; padding: 12px 16px; }
.bm-stage-pdf-wrap { display: flex; align-items: flex-start; justify-content: center; }
.bm-stage-pdf { display: block; flex: 0 0 auto; background: white; box-shadow: 0 1px 8px #0002; }
.bm-stage-text-wrap { width: 100%; }
.bm-stage-text { width: 100%; margin: 0 auto; padding: 20px clamp(8px, 3vw, 40px) 60px; line-height: 1.55; overflow-wrap: anywhere; }
.bm-stage-text p { margin: 0 0 1em; }
.bm-stage-text p:empty { min-height: 1em; }
.bm-stage-text h1, .bm-stage-text h2, .bm-stage-text h3 { line-height: 1.15; margin: 1em 0 .6em; }
.bm-stage-text h1:first-child, .bm-stage-text h2:first-child, .bm-stage-text h3:first-child, .bm-stage-text p:first-child { margin-top: 0; }
.bm-stage-text pre, .bm-stage-text.is-chords { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; tab-size: 4; }
.bm-stage-text pre { overflow-wrap: normal; overflow: auto; }
.bm-stage-text blockquote { margin: 1em 0; padding: .8em; background: var(--stage-surface); border-radius: 8px; }
.bm-stage-text table { border-collapse: collapse; max-width: 100%; }
.bm-stage-text th, .bm-stage-text td { padding: .3em .7em; border: 1px solid var(--stage-border); }
.bm-stage-card-wrap { display: grid; align-items: center; justify-items: center; width: 100%; }
.bm-stage-card { width: min(760px, 100%); text-align: center; padding: 30px 12px; }
.bm-stage-card small { color: var(--stage-muted); font-size: 13px; }
.bm-stage-card h1 { font-size: clamp(30px, 6vw, 70px); letter-spacing: -.035em; line-height: 1.1; margin: 15px 0 22px; overflow-wrap: anywhere; }
.bm-stage-card p { color: var(--stage-muted); max-width: 560px; margin: 12px auto; }
.bm-stage-card .bm-stage-cue-note { color: var(--stage-ink); font-size: clamp(18px, 3vw, 28px); white-space: pre-wrap; }
.bm-stage-card button { border-color: var(--stage-border); background: var(--stage-surface); }
.bm-stage-status { position: absolute; top: 76px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); border: 1px solid var(--stage-border); border-radius: 8px; padding: 7px 16px; text-align: center; font-size: 13px; color: var(--stage-muted); background: var(--stage-surface); }
.bm-stage-status:empty { display: none; }
.bm-stage-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px max(10px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); border-top: 1px solid var(--stage-border); background: var(--stage-surface); }
.bm-stage-control-group { display: flex; align-items: center; justify-content: center; gap: 2px; }
.bm-stage-control-group .bm-stage-button { font-size: 24px; padding: 4px; }
.bm-stage-control-caption { font-size: 12px; color: var(--stage-muted); }
.bm-stage-page-count { font-size: 14px; min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; }
.bm-stage-zoom { max-width: 132px; min-height: 44px; border: 1px solid var(--stage-border); background: var(--stage-surface); border-radius: 8px; padding: 4px 6px; font-size: 13px !important; }
.bm-stage-settings { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: calc(70px + env(safe-area-inset-bottom)); width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 160px); overflow: auto; border: 1px solid var(--stage-border); border-radius: 14px; padding: 18px; color: var(--stage-ink); background: var(--stage-surface); box-shadow: 0 12px 50px #0004; }
.bm-stage-settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bm-stage-settings h2 { font-size: 18px; margin: 0; }
.bm-stage-settings p { font-size: 13px; color: var(--stage-muted); margin: 10px 0 16px; }
.bm-stage-binding { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 5px 0; border-top: 1px solid var(--stage-border); font-size: 13px; }
.bm-stage-binding kbd { font-size: 12px; color: var(--stage-muted); }
.bm-stage-binding button, .bm-stage-settings-actions button, .bm-stage-wake button { border-color: var(--stage-border); font-size: 13px; }
.bm-stage-settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.bm-stage-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 13px; cursor: pointer; }
.bm-stage-check input { flex: 0 0 auto; width: 20px; height: 20px; }
.bm-stage-wake { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--stage-border); padding-top: 15px; margin-top: 14px; font-size: 12px; color: var(--stage-muted); }
.bm-stage-wake span { flex: 1; }
.bm-stage-wake button { flex: 0 0 auto; }
@media (max-width: 620px) {
    .bm-stage-toolbar { flex-wrap: wrap; gap: 0; justify-content: space-between; }
    .bm-stage-control-caption { display: none; }
    .bm-stage-view-controls { width: 100%; order: 3; }
    .bm-stage-control-group .bm-stage-button { min-width: 44px; }
    .bm-stage-song-select { font-size: 15px !important; }
    .bm-stage-settings { bottom: calc(110px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 185px); padding: 12px; }
    .bm-stage-text { padding: 12px 4px 40px; }
}
@media (forced-colors: active) { .bm-stage-viewer { border: 1px solid CanvasText; } .bm-stage-button { border-color: ButtonText; } }

:root[data-bm-theme="dark"] .bm-stage-viewer { --stage-ink: var(--bm-ink, #fffaf0); --stage-surface: var(--bm-surface, #302238); --stage-soft: var(--bm-surface-soft, #291d30); --stage-muted: var(--bm-muted, #c8bca9); --stage-border: var(--bm-border, rgba(255,250,240,.18)); color-scheme: dark; }
@media (prefers-color-scheme: dark) {
    :root:not([data-bm-theme="light"]) .bm-stage-viewer { --stage-ink: var(--bm-ink, #fffaf0); --stage-surface: var(--bm-surface, #302238); --stage-soft: var(--bm-surface-soft, #291d30); --stage-muted: var(--bm-muted, #c8bca9); --stage-border: var(--bm-border, rgba(255,250,240,.18)); color-scheme: dark; }
}
