:root { --bo-accent: #7c5cff; }

body { background: #08080d; margin: 0; overflow: hidden; }
#app { width: 100vw; height: calc(100vh - 48px); }
@media (max-width: 768px) { #app { height: calc(100vh - 40px); } }

* { box-sizing: border-box; }

.bo-root {
    position: relative; width: 100%; height: 100%;
    font-family: 'Space Grotesk', 'IBM Plex Mono', sans-serif;
    color: #e8e8f0; overflow: hidden;
}

.bo-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---- Stage ---- */
.bo-stage {
    position: relative; z-index: 2; width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 18px 16px 0; gap: 32px;
}

.bo-readout { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bo-num {
    font-family: 'Space Mono', monospace; font-size: clamp(30px, 6vw, 56px); font-weight: 700;
    color: #fff; letter-spacing: 4px; line-height: 1;
    text-shadow: 0 0 24px rgba(124, 92, 255, 0.35);
}
.bo-binword {
    font-family: 'Space Mono', monospace; font-size: 13px; letter-spacing: 6px; color: #55566a;
}

/* ---- Voice columns ---- */
.bo-voices {
    display: flex; gap: 6px; flex: 0 1 auto; align-items: stretch; width: 100%;
    max-width: 980px; height: 300px; min-height: 0; padding-bottom: 4px;
}
.bo-voice {
    flex: 1 1 0; min-width: 0; cursor: pointer; position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    padding: 8px 4px; border-radius: 9px;
    background: rgba(255, 255, 255, 0.018);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.bo-voice:hover { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.14); }
.bo-voice.editing { border-color: var(--vc); background: rgba(255, 255, 255, 0.05); }
.bo-voice.on { border-color: var(--vc); box-shadow: 0 0 22px -6px var(--vc), inset 0 0 24px -14px var(--vc); }

.bo-bit { font-family: 'Space Mono', monospace; font-size: 18px; font-weight: 700; color: #3a3a4a; transition: color 0.08s; }
.bo-voice.on .bo-bit { color: var(--vc); text-shadow: 0 0 12px var(--vc); }

.bo-lamp {
    width: 9px; height: 9px; border-radius: 50%; background: #23232f;
    border: 1px solid #33333f; transition: all 0.08s;
}
.bo-voice.on .bo-lamp { background: var(--vc); border-color: var(--vc); box-shadow: 0 0 10px var(--vc); }

.bo-inst {
    margin-top: auto; font-size: 11px; line-height: 1.25; text-align: center; color: #b8b8c8;
    writing-mode: vertical-rl; transform: rotate(180deg); max-height: 90px; overflow: hidden;
}
.bo-note { font-family: 'Space Mono', monospace; font-size: 10px; color: var(--vc); opacity: 0.85; max-width: 100%; overflow: hidden; white-space: nowrap; text-align: center; }

/* ---- Controls ---- */
.bo-controls {
    display: flex; align-items: center; gap: 22px; flex-wrap: wrap; justify-content: center;
    padding: 10px 0 16px;
}
/* every control is a 40px rounded-rect chip so the bar reads as one set */
.bo-play {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    height: 40px; min-width: 56px; padding: 0 18px; border-radius: 9px;
    border: 1px solid var(--bo-accent); background: rgba(124, 92, 255, 0.14);
    color: var(--bo-accent); font-size: 14px; cursor: pointer; transition: all 0.15s;
}
.bo-play:hover { background: rgba(124, 92, 255, 0.26); box-shadow: 0 0 16px -5px var(--bo-accent); }
.bo-play.playing { background: var(--bo-accent); color: #0b0b12; }
.bo-play.loading { font-family: 'Space Mono', monospace; font-size: 12px; cursor: default; }
.bo-play.idle { animation: bo-play-pulse 1.9s ease-in-out infinite; }
@keyframes bo-play-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0); } 50% { box-shadow: 0 0 16px -3px var(--bo-accent); } }
.bo-btn {
    display: inline-flex; align-items: center; height: 40px; padding: 0 16px;
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.14);
    color: #c8c8d6; border-radius: 9px; cursor: pointer; font-size: 12px;
    font-family: inherit; transition: all 0.12s; white-space: nowrap;
}
.bo-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.28); }
.bo-tempo {
    display: inline-flex; align-items: center; gap: 11px;
    height: 40px; padding: 0 15px; border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.05);
}
.bo-tempo-lbl { font-size: 10px; color: #889; letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; }
.bo-tempo-val { color: var(--bo-accent); font-weight: 700; }

/* shared slider (matches the cellular/tone-matrix style) */
.bo-slider {
    -webkit-appearance: none; appearance: none; display: block;
    width: 120px; height: 3px; border-radius: 2px; outline: none;
    background: #1c1c26; cursor: pointer;
}
.bo-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 12px; height: 12px; border-radius: 3px;
    background: var(--sc, var(--bo-accent)); box-shadow: 0 0 7px var(--sc, var(--bo-accent)); cursor: pointer;
}
.bo-slider::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 3px; border: none;
    background: var(--sc, var(--bo-accent)); box-shadow: 0 0 7px var(--sc, var(--bo-accent)); cursor: pointer;
}
.bo-btn.active { background: rgba(124, 92, 255, 0.2); border-color: var(--bo-accent); color: #fff; }

/* ---- Presets popover ---- */
.bo-presets-wrap { position: relative; display: inline-flex; }
.bo-presets-backdrop { position: fixed; inset: 0; z-index: 40; }
.bo-presets {
    position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
    z-index: 41; width: 216px;
    background: linear-gradient(180deg, rgba(24, 24, 38, 0.98), rgba(14, 14, 22, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px; padding: 7px;
    box-shadow: 0 18px 52px -18px #000; backdrop-filter: blur(10px);
    display: flex; flex-direction: column; gap: 2px;
    animation: bo-reveal 0.16s ease;
}
.bo-presets::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: rgba(20, 20, 30, 0.98);
}
.bo-presets-head { font-size: 10px; text-transform: uppercase; letter-spacing: 2px; color: #5c5c72; padding: 3px 8px 6px; }
.bo-preset {
    display: flex; align-items: center; width: 100%;
    background: none; border: 1px solid transparent; border-radius: 8px;
    padding: 8px 11px; cursor: pointer; font-family: inherit; color: #d4d4e0; font-size: 13px; text-align: left;
    transition: background 0.1s, border-color 0.1s;
}
.bo-preset:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.14); }
.bo-preset-name { flex: 1; }

/* ---- Picker / editor ---- */
.bo-picker {
    width: 100%; max-width: 720px; margin: 0 auto; flex: 0 0 auto;
    max-height: 58%; overflow-y: auto;
    background: linear-gradient(180deg, rgba(23, 23, 36, 0.72), rgba(14, 14, 22, 0.72));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px; padding: 13px 16px 16px;
    box-shadow: 0 14px 44px -26px #000, inset 0 1px 0 rgba(255, 255, 255, 0.05);
    animation: bo-reveal 0.18s ease;
}
@keyframes bo-reveal { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.bo-picker-head {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 11px; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.bo-picker-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.bo-picker-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--vc); box-shadow: 0 0 10px var(--vc); flex: 0 0 auto; }
.bo-picker-bit { font-family: 'Space Mono', monospace; font-size: 11px; letter-spacing: 1.5px; color: #6a6a80; flex: 0 0 auto; }
.bo-picker-name { font-size: 15px; font-weight: 600; color: #f0f0f6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bo-x { background: none; border: none; color: #889; font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; flex: 0 0 auto; }
.bo-x:hover { color: #fff; }

.bo-sec { margin-top: 14px; }
.bo-seclabel { font-size: 10px; text-transform: uppercase; letter-spacing: 2px; color: #5c5c72; margin-bottom: 9px; }

.bo-fams {
    display: flex; flex-wrap: nowrap; gap: 5px; margin-bottom: 10px;
    overflow-x: auto; padding-bottom: 5px; scrollbar-width: thin;
}
.bo-fam {
    flex: 0 0 auto; white-space: nowrap;
    font-size: 11px; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-family: inherit;
    background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1); color: #aab;
    transition: all 0.1s;
}
.bo-fam:hover { color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.bo-fam.sel { color: #0b0b12; background: var(--fc); border-color: var(--fc); font-weight: 600; }

.bo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.bo-cell {
    font-size: 11px; padding: 10px 6px; border-radius: 8px; cursor: pointer; font-family: inherit;
    background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.08); color: #c4c4d2;
    text-align: center; transition: all 0.1s;
}
.bo-cell:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--fc); color: #fff; }
.bo-cell.sel { background: var(--fc); border-color: var(--fc); color: #0b0b12; font-weight: 600; box-shadow: 0 0 16px -6px var(--fc); }

/* note section */
.bo-noterow2 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.bo-noterow2 .bo-seclabel { margin-bottom: 0; }
.bo-noteval { font-family: 'Space Mono', monospace; font-size: 19px; font-weight: 700; color: var(--vc); min-width: 46px; }
.bo-octbtns { display: flex; gap: 6px; }
.bo-nudge {
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.14);
    color: #c8c8d6; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 11px; font-family: inherit;
}
.bo-nudge:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--vc); }
.bo-lenrow {
    display: flex; align-items: center; gap: 8px; margin-left: auto;
    font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #889;
}
.bo-lenrow .bo-slider { width: 120px; --sc: var(--vc, var(--bo-accent)); }
.bo-lenval { font-family: 'Space Mono', monospace; font-size: 12px; color: #c8c8d6; min-width: 40px; }

.bo-kbd-wrap { width: 100%; overflow-x: auto; padding-bottom: 4px; }
.bo-kbd { position: relative; display: flex; height: 84px; justify-content: center; min-width: min-content; }
.bo-key { cursor: pointer; position: relative; transition: background 0.05s, box-shadow 0.05s; }
.bo-key.white {
    width: 15px; height: 80px; background: #e6e6ea; border: 1px solid #888;
    border-radius: 0 0 3px 3px; z-index: 1;
    display: flex; align-items: flex-end; justify-content: center;
}
.bo-key.white:hover { background: #fff; }
.bo-key.white.sel { background: var(--vc); border-color: var(--vc); box-shadow: 0 0 14px -2px var(--vc); }
.bo-key.black {
    width: 10px; height: 50px; background: #15151c; border: 1px solid #2a2a32;
    border-radius: 0 0 3px 3px; margin-left: -5px; margin-right: -5px; z-index: 2;
}
.bo-key.black:hover { background: #33333f; }
.bo-key.black.sel { background: var(--vc); border-color: var(--vc); box-shadow: 0 0 14px -2px var(--vc); }
.bo-keylabel { font-size: 7px; color: #777; margin-bottom: 3px; pointer-events: none; }
.bo-key.white.sel .bo-keylabel { color: rgba(0, 0, 0, 0.55); }

@media (max-width: 640px) {
    .bo-inst { writing-mode: horizontal-tb; transform: none; font-size: 9px; }
    .bo-grid { grid-template-columns: repeat(2, 1fr); }
    .bo-voice { padding: 8px 2px; }
}
