/* PM Beat Stack — studio toy within PMTV brand */

.beat-page {
    --beat-pink: #ff2961;
    --beat-pink-dim: rgba(255, 41, 97, 0.35);
    --beat-pink-glow: rgba(255, 41, 97, 0.45);
    --beat-panel: rgba(18, 18, 22, 0.92);
    --beat-panel-2: rgba(28, 28, 34, 0.95);
    --beat-line: rgba(255, 255, 255, 0.14);
    --beat-line-strong: rgba(255, 255, 255, 0.28);
    --beat-muted: rgba(255, 255, 255, 0.55);
    --beat-cell: rgba(255, 255, 255, 0.06);
    --beat-cell-bar: rgba(255, 255, 255, 0.11);
    --beat-cell-on: #ff2961;
    --beat-playhead: rgba(255, 255, 255, 0.22);
    --beat-sidebar: 268px;
    --beat-step: 28px;
    --beat-piano-keys: 80px;
    --beat-key-h: 20px;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 41, 97, 0.18), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 80%, rgba(80, 40, 90, 0.2), transparent 50%),
        radial-gradient(ellipse 50% 35% at 0% 70%, rgba(40, 60, 100, 0.15), transparent 45%),
        #050506;
}

.beat-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 20px 64px;
}

.beat-intro {
    text-align: center;
    margin-bottom: 28px;
}

.beat-kicker {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--beat-pink);
    margin: 0 0 8px;
}

.beat-title {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    margin: 0 0 10px;
    text-shadow: 0 0 28px var(--beat-pink-glow);
}

.beat-blurb {
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    color: var(--beat-muted);
    margin: 0;
    max-width: 42ch;
    margin-inline: auto;
}

/* Transport */
.beat-transport {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 18px;
    background: var(--beat-panel);
    border: 1px solid var(--beat-line);
    border-radius: 4px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 0 0 1px rgba(0, 0, 0, 0.4);
}

.beat-transport-left,
.beat-transport-right {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.beat-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--beat-line-strong);
    border-radius: 3px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.beat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.45);
}

.beat-btn--primary[aria-pressed="true"],
.beat-btn--primary.is-playing {
    background: var(--beat-pink);
    border-color: var(--beat-pink);
    color: #fff;
    box-shadow: 0 0 18px var(--beat-pink-dim);
}

.beat-btn--accent {
    border-color: var(--beat-pink-dim);
    color: #ffb3c6;
}

.beat-btn--accent:hover {
    border-color: var(--beat-pink);
    color: #fff;
    background: rgba(255, 41, 97, 0.15);
}

.beat-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.beat-bpm {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 220px;
    justify-content: center;
    min-width: 200px;
}

.beat-bpm-label,
.beat-bpm-value {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: #fff;
    min-width: 2.2ch;
}

.beat-range {
    -webkit-appearance: none;
    appearance: none;
    width: min(220px, 40vw);
    height: 4px;
    background: linear-gradient(90deg, var(--beat-pink-dim), rgba(255, 255, 255, 0.2));
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    pointer-events: auto !important;
}

.beat-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--beat-pink);
    border: 2px solid #fff;
    box-shadow: 0 0 10px var(--beat-pink-glow);
    cursor: pointer;
}

.beat-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--beat-pink);
    border: 2px solid #fff;
    box-shadow: 0 0 10px var(--beat-pink-glow);
    cursor: pointer;
}

/* Studio grid */
.beat-studio {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%),
        var(--beat-panel);
    border: 1px solid var(--beat-line);
    border-radius: 4px;
    overflow: auto;
    max-height: calc(100vh - 260px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.beat-step-ruler {
    display: grid;
    grid-template-columns: var(--beat-sidebar) repeat(32, var(--beat-step));
    position: sticky;
    top: 0;
    z-index: 3;
    background: #0c0c10;
    border-bottom: 1px solid var(--beat-line);
    min-width: calc(var(--beat-sidebar) + 32 * var(--beat-step));
}

.beat-step-ruler-label {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--beat-muted);
    border-right: 1px solid var(--beat-line);
}

.beat-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.35);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.beat-step-num:nth-child(4n+2) {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 41, 97, 0.08);
}

.beat-step-num.is-playhead {
    color: #fff;
    background: var(--beat-playhead);
}

.beat-tracks {
    min-width: calc(var(--beat-sidebar) + 32 * var(--beat-step));
}

.beat-track {
    border-bottom: 1px solid var(--beat-line);
}

.beat-track.is-muted .beat-steps,
.beat-track.is-muted .beat-piano-roll {
    opacity: 0.35;
}

.beat-track-main {
    display: grid;
    grid-template-columns: var(--beat-sidebar) repeat(32, var(--beat-step));
    min-height: 52px;
}

.beat-track-side {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    background: var(--beat-panel-2);
    border-right: 1px solid var(--beat-line);
    position: sticky;
    left: 0;
    z-index: 2;
}

.beat-track-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.beat-expand {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--beat-line);
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease, background 0.15s ease;
}

.beat-expand[aria-expanded="true"] i {
    transform: rotate(90deg);
}

.beat-expand:hover {
    background: rgba(255, 41, 97, 0.2);
    border-color: var(--beat-pink-dim);
}

.beat-track-name {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.beat-track-type {
    font-size: 0.62rem;
    color: var(--beat-pink);
    letter-spacing: 0.04em;
}

.beat-icon-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--beat-line);
    border-radius: 3px;
    color: var(--beat-muted);
    cursor: pointer;
    flex-shrink: 0;
}

.beat-icon-btn:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}

.beat-icon-btn.is-active {
    color: #fff;
    background: rgba(255, 41, 97, 0.25);
    border-color: var(--beat-pink);
}

.beat-icon-btn--danger:hover {
    color: #ff6b8a;
    border-color: rgba(255, 41, 97, 0.55);
}

.beat-vol {
    display: flex;
    align-items: center;
    gap: 6px;
}

.beat-vol span {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    color: var(--beat-muted);
}

.beat-vol .beat-range {
    width: 100%;
    max-width: none;
}

.beat-steps {
    display: contents;
}

.beat-step {
    box-sizing: border-box;
    width: var(--beat-step);
    height: 52px;
    padding: 0;
    margin: 0;
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    background: var(--beat-cell);
    cursor: pointer;
    position: relative;
    transition: background 0.1s ease, box-shadow 0.1s ease;
}

/* Steps sit after .beat-track-side, so beat 1/5/9… = nth-child 2/6/10… */
.beat-step:nth-child(4n+2) {
    background: var(--beat-cell-bar);
}

.beat-step:hover {
    background: rgba(255, 41, 97, 0.18);
}

.beat-step.is-on {
    background: var(--beat-cell-on);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 10px var(--beat-pink-dim);
}

.beat-step.is-playhead::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--beat-playhead);
    pointer-events: none;
}

.beat-step.is-on.is-playhead {
    filter: brightness(1.15);
}

/* Expanded panels — no side padding so piano columns line up with step grid */
.beat-track-panel {
    display: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.35);
    padding: 10px 0 12px;
    overflow: visible;
}

.beat-track.is-expanded .beat-track-panel {
    display: block;
}

.beat-variants {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: var(--beat-sidebar);
    margin-bottom: 10px;
    padding-right: 12px;
    box-sizing: border-box;
}

.beat-variants + .beat-piano-wrap {
    margin-top: 2px;
}

.beat-chip {
    font-family: 'Poppins', sans-serif;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--beat-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--beat-line);
    border-radius: 3px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.12s ease;
}

.beat-chip:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.35);
}

.beat-chip.is-selected {
    color: #fff;
    background: rgba(255, 41, 97, 0.28);
    border-color: var(--beat-pink);
    box-shadow: 0 0 12px var(--beat-pink-dim);
}

/*
 * BandLab piano geometry:
 * - Grid: equal 1-row lanes per semitone (gutter + cells)
 * - Keyboard overlay: stepped white heads (left) + 1-row tails / black keys (right)
 */
.beat-piano-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    width: calc(var(--beat-piano-keys) + 32 * var(--beat-step));
    margin-left: calc(var(--beat-sidebar) - var(--beat-piano-keys));
    background: #2b3038;
    box-sizing: border-box;
}

.beat-piano-kbd {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--beat-piano-keys);
    height: calc(24 * var(--beat-key-h));
    z-index: 4;
    overflow: hidden;
    border-right: 2px solid #0a0a0a;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.beat-piano-kbd-bed {
    position: absolute;
    inset: 0;
    background: #d0d0d0;
}

/* Mirrored: fronts + black keys LEFT; multi-row heads RIGHT (against grid) */
.beat-wk {
    position: absolute;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 1;
}

/* Multi-row head — right side, bridges into the grid */
.beat-wk-head {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 38%;
    background: linear-gradient(180deg, #f2f2f2 0%, #e6e6e6 45%, #d8d8d8 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.28);
    border-left: none;
    box-sizing: border-box;
}

.beat-wk--c .beat-wk-head {
    background: linear-gradient(180deg, #e4e4e4 0%, #d6d6d6 45%, #c8c8c8 100%);
}

/* 1-row front with label — left side */
.beat-wk-tail {
    position: absolute;
    left: 0;
    width: 62%;
    height: var(--beat-key-h);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 5px;
    background: linear-gradient(180deg, #f2f2f2 0%, #e6e6e6 45%, #d8d8d8 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.28);
}

.beat-wk--c .beat-wk-tail {
    background: linear-gradient(180deg, #e4e4e4 0%, #d6d6d6 45%, #c8c8c8 100%);
}

.beat-wk-label {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: #222;
    line-height: 1;
}

.beat-wk--c .beat-wk-label {
    color: #000;
    font-weight: 800;
}

/* Black keys: shorter, 1 row, flush left */
.beat-bk {
    position: absolute;
    left: 0;
    width: 62%;
    z-index: 3;
    box-sizing: border-box;
    border-radius: 0 2px 2px 0;
    background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 35%, #0e0e0e 100%);
    border-bottom: 1px solid #000;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.16),
        inset 0 -2px 3px rgba(0, 0, 0, 0.65),
        1px 0 2px rgba(0, 0, 0, 0.35);
}

.beat-wk.is-cross-key .beat-wk-head,
.beat-wk.is-cross-key .beat-wk-tail {
    background: linear-gradient(180deg, #f0c8d4 0%, #e8a8bc 100%);
}

.beat-bk.is-cross-key {
    background: linear-gradient(180deg, #6a3a48 0%, #3a1824 35%, #220e14 100%);
}

/* Lanes: gutter under keyboard + track cells — 1 row = 1 semitone */
.beat-piano-lane {
    display: grid;
    grid-template-columns: var(--beat-piano-keys) repeat(32, var(--beat-step));
    height: var(--beat-key-h);
    width: 100%;
    box-sizing: border-box;
}

.beat-piano-gutter {
    grid-column: 1;
    height: var(--beat-key-h);
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

.beat-piano-cells {
    display: contents;
}

.beat-piano-cell {
    position: relative;
    box-sizing: border-box;
    width: var(--beat-step);
    height: var(--beat-key-h);
    padding: 0;
    margin: 0;
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(0, 0, 0, 0.35);
    cursor: pointer;
    overflow: hidden;
}

.beat-piano-lane:not(.is-black-row) .beat-piano-cell {
    background: #3a404a;
}

.beat-piano-lane:not(.is-black-row) .beat-piano-cell:nth-of-type(4n+1) {
    background: #404650;
}

.beat-piano-lane.is-black-row .beat-piano-cell,
.beat-piano-lane.is-black-row .beat-piano-cell:nth-of-type(4n+1) {
    background: #252a32;
}

.beat-piano-lane.is-c-row:not(.is-black-row) .beat-piano-cell {
    background: #4a3840;
}

.beat-piano-lane:not(.is-black-row) .beat-piano-cell.is-cross-row:not(.is-on),
.beat-piano-lane:not(.is-black-row) .beat-piano-cell.is-cross-col:not(.is-on) {
    background: #5a4650 !important;
}

.beat-piano-lane.is-black-row .beat-piano-cell.is-cross-row:not(.is-on),
.beat-piano-lane.is-black-row .beat-piano-cell.is-cross-col:not(.is-on) {
    background: #3a2a32 !important;
}

.beat-piano-cell.is-cross-row.is-cross-col:not(.is-on) {
    background: #7a3a52 !important;
    box-shadow: inset 0 0 0 1px rgba(255, 41, 97, 0.4);
}

.beat-piano-cell.is-on.is-cross-row,
.beat-piano-cell.is-on.is-cross-col {
    filter: brightness(1.08);
}

.beat-piano-cell.is-on {
    background: linear-gradient(180deg, #ff4d7a 0%, #ff2961 55%, #e0184d 100%) !important;
    border-right-color: transparent;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.beat-piano-cell.is-note-single {
    border-radius: 3px;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.beat-piano-cell.is-note-start {
    border-radius: 3px 0 0 3px;
}

.beat-piano-cell.is-note-end {
    border-radius: 0 3px 3px 0;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.beat-note-label {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 0.58rem;
    letter-spacing: 0.02em;
    color: rgba(20, 8, 14, 0.85);
    pointer-events: none;
    white-space: nowrap;
    z-index: 1;
}

.beat-piano-cell.is-draft {
    opacity: 0.78;
    filter: brightness(1.12);
}

.beat-piano-cell.has-resize {
    cursor: ew-resize;
}

.beat-piano-cell.has-resize::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 2px;
    bottom: 3px;
    width: 3px;
    border-radius: 1px;
    background: rgba(255, 255, 255, 0.55);
    pointer-events: none;
    z-index: 2;
}

.beat-piano-cell.is-playhead {
    outline: 1px solid rgba(255, 255, 255, 0.5);
    outline-offset: -1px;
}

.beat-step--melody {
    cursor: zoom-in;
}

.beat-step--melody:hover {
    background: rgba(255, 41, 97, 0.22);
}

.beat-hint {
    margin: 14px 0 0;
    text-align: center;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
}

/* Add modal */
.beat-modal[hidden] {
    display: none !important;
}

.beat-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.beat-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}

.beat-modal-dialog {
    position: relative;
    width: min(480px, 100%);
    background: #121218;
    border: 1px solid var(--beat-line-strong);
    border-radius: 4px;
    box-shadow: 0 0 40px var(--beat-pink-dim), 0 20px 60px rgba(0, 0, 0, 0.6);
    padding: 18px;
}

.beat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.beat-modal-title {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 1.15rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0;
}

.beat-modal-body {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.beat-add-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    text-align: left;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--beat-line);
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
}

.beat-add-option:hover {
    border-color: var(--beat-pink);
    background: rgba(255, 41, 97, 0.12);
}

.beat-add-option strong {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.beat-add-option span {
    font-size: 0.72rem;
    color: var(--beat-muted);
}

@media (max-width: 720px) {
    .beat-page {
        --beat-sidebar: 200px;
        --beat-step: 22px;
        --beat-piano-keys: 64px;
        --beat-key-h: 18px;
    }

    .beat-transport {
        flex-direction: column;
        align-items: stretch;
    }

    .beat-bpm {
        justify-content: stretch;
    }

    .beat-modal-body {
        grid-template-columns: 1fr;
    }
}
