﻿:root {
    --bg: #f6f7fb;
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --yellow: #facc15;
    --shadow: 0 12px 30px rgba(0,0,0,.08);
}

* {
    box-sizing: border-box
}

html, body {
    height: 100%
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    background: var(--bg);
    color: var(--ink);
}

.app {
    min-height: 100%;
    display: flex;
    flex-direction: column
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.7);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand .logo {
    font-weight: 900;
    letter-spacing: .12em;
    font-size: 14px
}

.brand .sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted)
}

.topActions {
    display: flex;
    gap: 10px;
    align-items: center
}

.btn {
    border: 1px solid var(--line);
    background: #fff;
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
    font-weight: 800;
}

    .btn.primary {
        border-color: rgba(22,163,74,.25);
        background: rgba(22,163,74,.1)
    }

    .btn:active {
        transform: translateY(1px)
    }

.main {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 18px;
    padding: 18px;
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.board {
    position: relative;
    border-radius: 24px;
    min-height: 980px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 18px;
}

.boardBg {
    position: absolute;
    inset: 0;
    margin: auto;
    width: min(560px, 94vw);
    height: min(1180px, 150vh);
    background: var(--yellow);
    border-radius: 26px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,.06);
    overflow: hidden;
}

    .boardBg::before {
        content: "";
        position: absolute;
        inset: -80px;
        background: radial-gradient(circle at 30% 20%, rgba(0,0,0,.08) 0 2px, transparent 3px) 0 0/28px 28px, radial-gradient(circle at 70% 60%, rgba(0,0,0,.06) 0 1.5px, transparent 2.5px) 0 0/24px 24px;
        opacity: .35;
    }

.tabs {
    position: relative;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 16px;
    z-index: 2;
    margin-bottom: 8px;
    justify-content: center;
}

.tab {
    border: 1px solid rgba(0,0,0,.12);
    background: rgba(255,255,255,.85);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 900;
}

    .tab.active {
        background: rgba(37,99,235,.12);
        border-color: rgba(37,99,235,.30)
    }

.page {
    display: none;
    position: relative;
    z-index: 2;
    width: min(860px, 96vw)
}

    .page.active {
        display: block
    }

.grid {
    width: min(460px, 90vw);
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 16px;
    padding: 18px;
    margin: 0 auto;
}

.pad {
    appearance: none;
    border: 2px solid rgba(22,163,74,.55);
    background: rgba(255,255,255,.92);
    border-radius: 18px;
    padding: 16px 14px;
    box-shadow: 0 10px 22px rgba(0,0,0,.10);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 110px;
    position: relative;
    transition: transform .06s ease, box-shadow .06s ease, background .12s ease;
}

    .pad.center {
        min-height: 120px
    }

    .pad:hover {
        transform: translateY(-1px)
    }

    .pad:active {
        transform: translateY(1px);
        box-shadow: 0 6px 14px rgba(0,0,0,.10)
    }

    .pad.pressed {
        background: rgba(22,163,74,.12);
        box-shadow: 0 14px 30px rgba(22,163,74,.15)
    }

        .pad.pressed::after {
            content: "";
            position: absolute;
            inset: -2px;
            border-radius: 18px;
            box-shadow: 0 0 0 2px rgba(22,163,74,.25), 0 0 24px rgba(22,163,74,.25);
            pointer-events: none;
        }

.key {
    font-weight: 900;
    font-size: 28px;
    letter-spacing: .06em
}

    .key.big {
        font-size: 34px
    }

    .key.mid {
        font-size: 22px;
        letter-spacing: .12em
    }

.label {
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted)
}

.transport {
    width: min(860px, 96vw);
    margin: 6px auto 0;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(0,0,0,.06);
}

.transportRow {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap
}

.smallRow {
    margin-top: 10px;
    justify-content: space-between;
    gap: 10px
}

.tbtn {
    border: 1px solid rgba(0,0,0,.10);
    background: #fff;
    padding: 10px 12px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(0,0,0,.06);
}

    .tbtn:active {
        transform: translateY(1px)
    }

    .tbtn.rec {
        border-color: rgba(239,68,68,.25);
        background: rgba(239,68,68,.10)
    }

    .tbtn.play {
        border-color: rgba(37,99,235,.25);
        background: rgba(37,99,235,.10)
    }

.ctrl {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #374151;
    flex-wrap: wrap
}

    .ctrl label {
        font-weight: 900;
        color: #111827;
        letter-spacing: .04em
    }

    .ctrl input[type="range"] {
        width: 120px
    }

.pillBtn {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(22,163,74,.12);
    border: 1px solid rgba(22,163,74,.25);
    font-weight: 900;
    cursor: pointer;
}

    .pillBtn:active {
        transform: translateY(1px)
    }

    .pillBtn.off {
        background: rgba(239,68,68,.10);
        border-color: rgba(239,68,68,.25)
    }

    .pillBtn.offLike {
        background: rgba(239,68,68,.10);
        border-color: rgba(239,68,68,.25)
    }

.progressWrap {
    margin-top: 10px
}

.progressBar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 8px;
    overflow: hidden
}

#progress {
    height: 100%;
    width: 0%;
    background: #16a34a;
    transition: width .05s linear
}

#beatInfo {
    margin-top: 4px;
    font-size: 12px;
    color: #374151;
    text-align: center
}

.patternBar, .songBar, .humanBar {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px;
    border-radius: 14px;
    background: rgba(0,0,0,.04);
    border: 1px solid rgba(0,0,0,.06);
}

.patTitle, .songTitle {
    font-weight: 900
}

.patBtns {
    display: flex;
    gap: 8px
}

.patBtn {
    width: 44px;
    height: 36px;
    border-radius: 12px;
    border: 2px solid rgba(37,99,235,.20);
    background: #fff;
    font-weight: 1000;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0,0,0,.06);
}

    .patBtn.active {
        background: rgba(37,99,235,.12);
        border-color: rgba(37,99,235,.55)
    }

    .patBtn.queued {
        border-color: rgba(239,68,68,.55);
        box-shadow: 0 0 0 2px rgba(239,68,68,.18)
    }

.patMeta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted)
}

.patLeft {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.patRight {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap
}

.songHint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px
}

.songLeft {
    display: flex;
    flex-direction: column;
    gap: 2px
}

.songRight {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap
}

.songInput {
    width: min(360px,80vw);
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,.14);
    background: #fff;
    font-weight: 800;
}

.songNow {
    font-size: 12px;
    color: var(--muted);
    min-width: 140px
}

.humanLeft {
    display: flex;
    flex-direction: column;
    gap: 2px
}

.humanRight {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap
}

.hCtrl {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #374151
}

    .hCtrl label {
        font-weight: 900;
        color: #111827
    }

    .hCtrl input[type="range"] {
        width: 140px
    }

.ioRow {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap
}

.loopInfo {
    margin-top: 10px;
    text-align: center;
    color: #1f2937;
    font-size: 13px
}

.sequencer {
    width: min(860px, 96vw);
    margin: 12px auto 0;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(0,0,0,.06);
}

.seqHeader {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px
}

.seqTitle {
    font-weight: 900;
    display: flex;
    flex-direction: column;
    gap: 4px
}

.seqHint {
    font-weight: 700;
    font-size: 12px;
    color: var(--muted)
}

.seqTools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center
}

.seqGrid {
    display: grid;
    gap: 8px
}

.seqRow {
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 10px;
    align-items: center
}

.seqRowLabel {
    font-weight: 900;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 12px;
    background: rgba(0,0,0,.04);
    border: 1px solid rgba(0,0,0,.06);
    text-align: center;
}

.seqSteps {
    display: grid;
    gap: 6px;
    align-items: center
}

.step {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,.14);
    background: rgba(255,255,255,.9);
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,.06);
    position: relative;
}

    .step.on1 {
        background: rgba(22,163,74,.20);
        border-color: rgba(22,163,74,.30)
    }

    .step.on2 {
        background: rgba(22,163,74,.42);
        border-color: rgba(22,163,74,.55)
    }

    .step.playhead::after {
        content: "";
        position: absolute;
        inset: -3px;
        border-radius: 8px;
        box-shadow: 0 0 0 2px rgba(37,99,235,.35), 0 0 14px rgba(37,99,235,.25);
        pointer-events: none;
    }

.side {
    display: flex;
    flex-direction: column;
    gap: 12px
}

.panel {
    background: rgba(255,255,255,.85);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 22px rgba(0,0,0,.06);
    padding: 14px;
}

.panelTitle {
    font-weight: 900;
    letter-spacing: .04em;
    margin-bottom: 10px
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px
}

.lbl {
    color: var(--muted);
    font-weight: 700;
    font-size: 12px
}

input[type="range"] {
    width: 180px
}

.pill {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(22,163,74,.12);
    border: 1px solid rgba(22,163,74,.25);
    font-weight: 900;
    font-size: 12px
}

.status, .status2 {
    font-size: 13px;
    color: #1f2937;
    line-height: 1.5
}

.status2 {
    color: var(--muted)
}

.footer {
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    text-align: center
}

/* Pages panels */
.panelWide {
    margin: 0 auto;
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 18px;
    padding: 14px;
}

.divider {
    height: 1px;
    background: rgba(0,0,0,.08);
    margin: 12px 0
}

.muted {
    color: var(--muted)
}

    .muted.small {
        font-size: 12px
    }

.row2 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 12px
}

.card {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 10px 20px rgba(0,0,0,.05);
}

.cardTitle {
    font-weight: 1000;
    margin-bottom: 6px
}

/* Mapping */
.mapWrap {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 14px;
    margin-top: 12px
}

.mapHeader {
    font-weight: 900;
    margin-bottom: 8px
}

.inputsList {
    display: grid;
    gap: 8px
}

.inputChip {
    background: #fff;
    border: 1px solid rgba(0,0,0,.10);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    font-weight: 900;
}

    .inputChip:active {
        cursor: grabbing
    }

.badge {
    font-size: 12px;
    color: var(--muted);
    font-weight: 900
}

.padsDrop {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 10px
}

.dropCell {
    background: rgba(255,255,255,.86);
    border: 2px dashed rgba(0,0,0,.20);
    border-radius: 14px;
    padding: 10px;
    min-height: 74px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
    align-items: center;
}

    .dropCell.over {
        border-color: rgba(37,99,235,.55);
        background: rgba(37,99,235,.08)
    }

.mapActions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

/* Mixer */
.mixerGrid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 12px;
    margin-top: 12px
}

.mixerLane {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,.05);
}

.laneTop {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px
}

.laneTitle {
    font-weight: 1000
}

.laneBtns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap
}

    .laneBtns .pillBtn {
        padding: 6px 10px
    }

.laneVol {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    align-items: center
}

    .laneVol input {
        width: 160px
    }

/* Cloud */
.cloudForm {
    margin-top: 12px
}

.cloudRow {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    align-items: center;
    margin-top: 10px
}

    .cloudRow input {
        padding: 10px 12px;
        border-radius: 12px;
        border: 1px solid rgba(0,0,0,.14);
        background: #fff;
        font-weight: 800
    }

.cloudActions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px
}

/* Gallery */
.galleryActions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px
}

.galleryGrid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 12px;
    margin-top: 12px
}

.gItem {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,.05);
}

.gTitle {
    font-weight: 1000
}

.gMeta {
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px
}

.gBtns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px
}

@media (max-width: 980px) {
    .main {
        grid-template-columns: 1fr
    }

    .side {
        order: 2
    }

    .row2 {
        grid-template-columns: 1fr
    }

    .mapWrap {
        grid-template-columns: 1fr
    }

    .galleryGrid, .mixerGrid {
        grid-template-columns: 1fr
    }
}

@media (max-width: 520px) {
    .step {
        width: 16px;
        height: 16px
    }

    .seqRow {
        grid-template-columns: 60px 1fr
    }
}


/* ===========================
   Layout Final (Responsive)
   Fix: board background + consistent widths (desktop + mobile)
   =========================== */

.main {
    align-items: start;
}

/* Make the yellow board the actual container (no floating bg strip) */
.board {
    position: relative;
    width: clamp(320px, 92vw, 680px);
    margin: 0 auto;
    padding: 18px 16px 22px;
    background: var(--yellow);
    border-radius: 26px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,.06);
    overflow: hidden;
    min-height: unset; /* let content define height */
}

    /* subtle pattern like makeymakey */
    .board::before {
        content: "";
        position: absolute;
        inset: -80px;
        background: radial-gradient(circle at 30% 20%, rgba(0,0,0,.08) 0 2px, transparent 3px) 0 0/28px 28px, radial-gradient(circle at 70% 60%, rgba(0,0,0,.06) 0 1.5px, transparent 2.5px) 0 0/24px 24px;
        opacity: .32;
        pointer-events: none;
    }

/* Disable old absolute background */
.boardBg {
    display: none !important;
}

/* Everything inside board should follow board width */
.page {
    width: 100% !important;
    max-width: 100% !important;
}

.grid {
    width: 100% !important;
    max-width: 520px;
    margin: 0 auto;
    padding: 14px 0;
}

.transport, .sequencer {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto;
    margin-right: auto;
}

/* Keep panels inside yellow board readable */
.transport {
    background: rgba(255,255,255,.86);
}

.sequencer {
    background: rgba(255,255,255,.86);
}

/* Prevent horizontal scroll from long rows */
.transportRow, .ioRow, .smallRow, .patternBar, .songBar, .humanBar {
    max-width: 100%;
}

.songInput {
    max-width: 100%;
}

/* Sidebar: stick on desktop if enough height */
@media (min-width: 981px) {
    .side {
        position: sticky;
        top: 92px;
        height: fit-content;
    }
}

/* Mobile refinements */
@media (max-width: 980px) {
    .main {
        padding: 12px;
    }

    .board {
        width: 100%;
        padding: 14px 12px 18px;
    }

    .grid {
        padding: 12px 0;
    }

    .pad {
        min-height: 96px;
    }

    .transport {
        padding: 12px;
    }

    .sequencer {
        padding: 12px;
    }
}

/* Very small screens */
@media (max-width: 420px) {
    .pad {
        border-radius: 16px;
    }

    .key {
        font-size: 24px;
    }

        .key.big {
            font-size: 30px;
        }

        .key.mid {
            font-size: 18px;
        }

    .tbtn {
        padding: 9px 10px;
    }

    .ctrl input[type="range"] {
        width: 110px;
    }
}
