/* ============================================================
   marimba-online.css — Modern Fun Look v2
   Neon purple/cyan/pink theme — fresh, young, energetic
   Mobile-first, tablet margins, NO overflow issues
   tools.dotiam.com
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

/* ═══════════════════════════════════════
   COLOR SYSTEM
   --fun-* = new fun theme (purple/cyan/pink)
   Remove .theme-fun class to revert to classic rosewood
═══════════════════════════════════════ */
:root {
    /* Classic rosewood (default / fallback) */
    --bg:       #080604;
    --surf:     #110e08;
    --card:     #1a1508;
    --card2:    #221c0a;
    --bdr:      #3a2e14;
    --bdr2:     #5a4820;
    --accent:   #e8a83c;
    --accent2:  #c08828;
    --wood:     #c8703a;
    --wood2:    #a05828;
    --natural-bar-top:    #6b3318;
    --natural-bar-mid:    #4a2010;
    --natural-bar-bot:    #321408;
    --sharp-bar:          #1a1208;
    --sharp-bar-mid:      #2a1e0c;
    --txt:      #f0e8d0;
    --muted:    #786040;
    --green:    #4caf78;
    --red:      #e05050;
    --blue:     #5090e0;
    --struck-glow: rgba(232,168,60,.6);
}

/* ═══ FUN THEME — add .theme-fun to .marimba-wrap to activate ═══ */
.theme-fun {
    --bg:       #0a0614;
    --surf:     #0f0a1e;
    --card:     #150e28;
    --card2:    #1c1434;
    --bdr:      #2e1e5a;
    --bdr2:     #4a2e8a;
    --accent:   #c084fc;      /* purple */
    --accent2:  #a855f7;
    --wood:     #22d3ee;      /* cyan */
    --wood2:    #06b6d4;
    --natural-bar-top:    #1e0a4a;
    --natural-bar-mid:    #2d1060;
    --natural-bar-bot:    #150838;
    --sharp-bar:          #0a0620;
    --sharp-bar-mid:      #160c30;
    --txt:      #f0e8ff;
    --muted:    #7060a0;
    --green:    #34d399;
    --red:      #f472b6;      /* pink instead of red — more fun */
    --blue:     #38bdf8;
    --struck-glow: rgba(192,132,252,.7);
}

/* ═══════ OUTER WRAPPER — tablet gets side margins ═══════ */
.marimba-wrap {
    background: var(--bg);
    border-radius: 0;          /* full bleed on mobile */
    overflow: visible;         /* NEVER hidden — keyboard must not clip */
    max-width: 1200px;
    margin: 0 auto;
    box-shadow: none;
    position: relative;
}

/* Tablet (600px+): add side margins, rounded corners, shadow */
@media (min-width: 600px) {
    .marimba-wrap {
        border-radius: 16px;
        overflow: visible;
        margin: 0 16px;
        box-shadow: 0 0 0 1px var(--bdr), 0 24px 80px rgba(0,0,0,.8);
    }
}
/* Desktop: auto-center with max-width */
@media (min-width: 900px) {
    .marimba-wrap {
        margin: 0 auto;
    }
}

/* ═══════ HEADER ═══════ */
.marimba-header {
    background: linear-gradient(135deg, var(--surf) 0%, var(--bg) 100%);
    border-bottom: 2px solid var(--accent2);
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 50px;
    border-radius: 0;
}
@media (min-width: 600px) {
    .marimba-header { border-radius: 16px 16px 0 0; padding: 0 16px; }
}

.marimba-logo { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.marimba-logo-icon { font-size: 1.4rem; }
.marimba-logo-text {
    font-size: .68rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: .12em; color: var(--muted);
}
.marimba-logo-text b { color: var(--accent); }

.marimba-tabs { display: flex; gap: 3px; margin-left: auto; flex-shrink: 0; }
.tab-btn {
    background: transparent; color: var(--muted);
    border: 1px solid var(--bdr); border-radius: 6px;
    padding: 5px 10px; font-size: .68rem; font-weight: 700;
    cursor: pointer; white-space: nowrap; transition: all .15s;
    -webkit-tap-highlight-color: transparent; min-height: 32px;
}
.tab-btn.active { background: var(--accent); color: #08040c; border-color: var(--accent); }
.tab-btn:not(.active):hover { border-color: var(--accent); color: var(--accent); }

/* ═══════ TOOLBAR — scrolls horizontally on mobile ═══════ */
.marimba-toolbar {
    background: var(--surf); border-bottom: 1px solid var(--bdr);
    padding: 6px 12px; display: flex; align-items: center;
    gap: 8px; flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
}
.marimba-toolbar::-webkit-scrollbar { display: none; }

.m-ctrl { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
.m-ctrl label { font-size: .68rem; color: var(--muted); white-space: nowrap; }
.m-ctrl input[type="range"] { width: 70px; accent-color: var(--accent); }
.m-ctrl select {
    background: var(--card); color: var(--txt);
    border: 1px solid var(--bdr); border-radius: 6px;
    padding: 3px 6px; font-size: .68rem; outline: none;
}
#volNum { font-size: .75rem; color: var(--accent); font-weight: 700; }
.m-sep { width: 1px; height: 18px; background: var(--bdr); flex-shrink: 0; }

.oct-nav { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.oct-btn {
    background: var(--card2); color: var(--txt);
    border: 1px solid var(--bdr); border-radius: 5px;
    width: 28px; height: 28px; font-size: .85rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s; -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.oct-btn:hover { border-color: var(--accent); color: var(--accent); }
#octaveRange { font-size: .65rem; color: var(--muted); min-width: 72px; text-align: center; }

.active-note-display {
    margin-left: auto; font-size: .78rem;
    color: var(--accent); font-weight: 700; flex-shrink: 0;
}
#activeNote { min-width: 32px; }

/* ═══════ TAB PANES ═══════ */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ═══════ PATTERN TAB ═══════ */
.pattern-pane { padding: 12px; }
.pattern-top { margin-bottom: 10px; }
.pattern-top h3 { font-size: .9rem; color: var(--txt); margin: 0 0 3px; }
.pattern-top p  { font-size: .72rem; color: var(--muted); margin: 0; }
.pattern-controls {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap; margin-bottom: 10px;
}
.pattern-controls label { font-size: .72rem; color: var(--muted); }
.pattern-controls select {
    background: var(--card); color: var(--txt);
    border: 1px solid var(--bdr); border-radius: 7px;
    padding: 5px 8px; font-size: .74rem; outline: none;
}
.pattern-now { font-size: .78rem; color: var(--accent); font-weight: 700; margin-left: auto; }
.pattern-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
}
@media (min-width: 480px)  { .pattern-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 768px)  { .pattern-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .pattern-grid { grid-template-columns: repeat(6, 1fr); } }

.pattern-btn {
    background: var(--card); border: 1px solid var(--bdr); border-radius: 10px;
    padding: 10px 10px; cursor: pointer; transition: all .16s; text-align: left;
    display: flex; flex-direction: column; gap: 2px;
    -webkit-tap-highlight-color: transparent;
}
.pattern-btn:hover { border-color: var(--accent); background: var(--card2); }
.pattern-btn.active {
    border-color: var(--accent); background: rgba(192,132,252,.08);
    box-shadow: 0 0 18px rgba(192,132,252,.2);
}
.theme-fun .pattern-btn.active {
    background: rgba(192,132,252,.08);
    box-shadow: 0 0 18px rgba(192,132,252,.2);
}
.pattern-icon  { font-size: 1.2rem; line-height: 1; }
.pattern-name  { font-size: .75rem; font-weight: 700; color: var(--txt); }
.pattern-style { font-size: .62rem; color: var(--accent); }
.pattern-desc  { font-size: .62rem; color: var(--muted); }

/* ═══════ RECORD TAB ═══════ */
.rec-pane { padding: 12px; }
.rec-status-row {
    display: flex; align-items: center; gap: 8px;
    background: var(--card); border: 1px solid var(--bdr);
    border-radius: 9px; padding: 9px 12px; margin-bottom: 9px;
}
#recDot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--bdr); flex-shrink: 0; transition: all .3s;
}
#recDot.blink {
    background: var(--red);
    box-shadow: 0 0 8px rgba(244,114,182,.6);
    animation: blink 1s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.2} }
#recStatusTxt { font-size: .76rem; color: var(--txt); }
#recTimer {
    margin-left: auto; font-size: .88rem; font-weight: 700;
    color: var(--accent); font-variant-numeric: tabular-nums;
}
.rec-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.rec-info { font-size: .7rem; color: var(--muted); text-align: center; margin: 0; }

/* ═══════ BUTTONS ═══════ */
.m-btn {
    background: var(--card2); color: var(--txt); border: 1px solid var(--bdr);
    border-radius: 7px; padding: 6px 12px; font-size: .74rem; font-weight: 600;
    cursor: pointer; transition: all .15s; white-space: nowrap; min-height: 34px;
    -webkit-tap-highlight-color: transparent;
}
.m-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.m-btn:disabled { opacity: .35; cursor: not-allowed; }
.m-btn.green { background: rgba(52,211,153,.1); color: var(--green); border-color: var(--green); }
.m-btn.green:hover:not(:disabled) { background: var(--green); color: #fff; }
.m-btn.red   { background: rgba(244,114,182,.1); color: var(--red); border-color: var(--red); }
.m-btn.red:hover:not(:disabled)   { background: var(--red); color: #fff; }
.m-btn.blue  { background: rgba(56,189,248,.1); color: var(--blue); border-color: var(--blue); }
.m-btn.blue:hover:not(:disabled)  { background: var(--blue); color: #fff; }

/* ═══════ MARIMBA BODY ═══════ */
.marimba-body {
    position: relative;
    background: linear-gradient(160deg,
        var(--bg) 0%, var(--surf) 50%, var(--bg) 100%);
    padding: 16px 10px 16px;
    /* NO overflow:hidden here — bars must never clip */
}
@media (min-width: 600px) {
    .marimba-body { padding: 20px 16px; }
}

.marimba-body::before {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        88deg,
        transparent 0px,
        rgba(192,132,252,.012) 1px,
        transparent 3px,
        transparent 14px
    );
    pointer-events: none;
}

.marimba-frame {
    position: relative;
    background: linear-gradient(180deg, var(--card) 0%, var(--surf) 100%);
    border: 2px solid var(--bdr2);
    border-radius: 8px;
    padding: 14px 8px 18px;
    box-shadow:
        inset 0 0 30px rgba(0,0,0,.5),
        0 6px 24px rgba(0,0,0,.5),
        0 0 0 1px rgba(192,132,252,.06);
    overflow: visible; /* NEVER clip bars */
}
@media (min-width: 600px) {
    .marimba-frame { padding: 16px 12px 22px; }
}

/* ═══════════════════════════════════════
   MOBILE KEYBOARD — Pad Grid Layout
   On small screens: show bars as big tappable pads
   arranged in a piano-like grid (2 rows)
═══════════════════════════════════════ */
.mb-keyboard {
    user-select: none;
    -webkit-user-select: none;
    overflow: visible;
}

/* ── MOBILE: pad grid ── */
.mb-natural-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr); /* 7 naturals per octave */
    gap: 4px;
    padding: 0 2px;
}

.mb-sharp-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 sharps per octave (C# D# F# G# A#) */
    gap: 4px;
    padding: 0 2px;
    margin-bottom: 4px;
}

/* ── DESKTOP: traditional horizontal bars ── */
@media (min-width: 768px) {
    .mb-natural-row {
        display: flex;
        align-items: flex-end;
        gap: 3px;
        padding: 0 4px;
        grid-template-columns: unset;
    }
    .mb-sharp-row {
        display: flex;
        gap: 3px;
        padding: 0 4px;
        margin-bottom: 4px;
        align-items: flex-end;
        justify-content: center;
        grid-template-columns: unset;
        min-height: 70px;
    }
}

/* ═══════ INDIVIDUAL BAR ═══════ */
.mb-bar {
    position: relative;
    border-radius: 8px;
    cursor: pointer;
    transition: transform .06s, filter .08s, box-shadow .08s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

/* ── MOBILE natural bar: big square pad ── */
.mb-natural {
    width: 100%;
    height: 72px;
    min-width: unset;
    max-width: unset;
    background: linear-gradient(160deg,
        var(--natural-bar-top) 0%,
        var(--natural-bar-mid) 55%,
        var(--natural-bar-bot) 100%
    );
    border: 1px solid rgba(192,132,252,.18);
    box-shadow:
        inset 0 2px 6px rgba(255,255,255,.05),
        inset 0 -3px 8px rgba(0,0,0,.5),
        0 3px 10px rgba(0,0,0,.4);
}

/* ── DESKTOP natural bar: traditional tall horizontal bar ── */
@media (min-width: 768px) {
    .mb-natural {
        width: var(--bar-width, 4%);
        height: var(--bar-height, 65px);
        min-width: 28px;
        max-width: 62px;
        background:
            linear-gradient(90deg,
                rgba(0,0,0,.4) 0%,
                rgba(255,255,255,calc(.06 + var(--bar-warm,0.5)*.08)) 25%,
                rgba(255,255,255,calc(.1  + var(--bar-warm,0.5)*.1))  50%,
                rgba(255,255,255,calc(.06 + var(--bar-warm,0.5)*.08)) 75%,
                rgba(0,0,0,.4) 100%
            ),
            linear-gradient(180deg,
                var(--natural-bar-top) 0%,
                var(--natural-bar-mid) 60%,
                var(--natural-bar-bot) 100%
            );
        border-radius: 6px 6px 10px 10px;
    }
}

.mb-natural:hover { filter: brightness(1.4) saturate(1.2); transform: translateY(2px); }
.mb-natural:active { filter: brightness(1.7) !important; transform: translateY(3px) !important; }
.mb-natural.struck {
    filter: brightness(1.9) saturate(1.5) !important;
    transform: translateY(3px) !important;
    box-shadow:
        0 0 20px var(--struck-glow),
        0 0 40px var(--struck-glow),
        inset 0 0 12px rgba(255,255,255,.08) !important;
    transition: transform .03s, filter .03s, box-shadow .03s !important;
}

/* ── MOBILE sharp bar: smaller pad above ── */
.mb-sharp {
    width: 100%;
    height: 52px;
    background: linear-gradient(160deg,
        var(--sharp-bar) 0%, var(--sharp-bar-mid) 50%, var(--sharp-bar) 100%
    );
    border: 1px solid rgba(192,132,252,.12);
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,.04),
        inset 0 -2px 6px rgba(0,0,0,.6),
        0 2px 8px rgba(0,0,0,.4);
}

/* ── DESKTOP sharp bar ── */
@media (min-width: 768px) {
    .mb-sharp { width: 34px; height: 52px; }
}

.mb-sharp:hover  { filter: brightness(1.5); transform: translateY(1px); }
.mb-sharp:active { filter: brightness(2.0) !important; transform: translateY(2px) !important; }
.mb-sharp.struck {
    filter: brightness(2.2) !important;
    transform: translateY(2px) !important;
    box-shadow: 0 0 16px var(--struck-glow) !important;
    transition: transform .03s, filter .03s !important;
}

/* Bar inner content */
.mb-bar-inner {
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-end;
    padding: 4px 2px 5px;
    border-radius: inherit;
    position: relative;
    overflow: hidden;
}
.mb-sharp-inner { padding: 3px 2px 4px; }

.mb-bar-grain {
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        180deg,
        transparent 0px, rgba(255,255,255,.025) 1px,
        transparent 2px, transparent 7px
    );
    border-radius: inherit;
    pointer-events: none;
}

.mb-bar-label {
    display: flex; flex-direction: column;
    align-items: center; gap: 0; z-index: 1;
}
.mb-note-name {
    font-size: .65rem; font-weight: 800;
    color: rgba(255,240,255,.65); line-height: 1;
}
.mb-oct-num {
    font-size: .5rem; color: rgba(192,132,252,.45);
    font-weight: 600; line-height: 1;
}
.mb-key-hint {
    font-size: .48rem;
    color: rgba(192,132,252,.4);
    background: rgba(192,132,252,.07);
    border: 1px solid rgba(192,132,252,.14);
    border-radius: 2px;
    padding: 0 3px; font-weight: 700;
    margin-top: 2px; line-height: 1.3;
}
.mb-sharp-label .mb-note-name { color: rgba(200,180,220,.4); font-size: .58rem; }
.mb-sharp-label .mb-oct-num   { display: none; }

/* Hide key hints on mobile (no keyboard there) */
@media (max-width: 767px) {
    .mb-key-hint { display: none; }
    .mb-oct-num  { display: none; }
}

/* Show resonator on desktop */
.mb-resonator { display: none; }
@media (min-width: 900px) {
    .mb-resonator {
        display: block;
        width: 60%; height: 26px;
        background: linear-gradient(180deg,
            rgba(48,64,80,.8) 0%, rgba(26,42,58,.9) 100%
        );
        border-radius: 0 0 6px 6px;
        border: 1px solid rgba(80,120,160,.25);
        border-top: none;
        box-shadow: inset 0 4px 8px rgba(0,0,0,.5);
        margin-top: 3px;
    }
}

/* ═══════ FUN THEME — bar colors override ═══════ */
.theme-fun .mb-natural {
    background: linear-gradient(160deg, #1e0a4a 0%, #2d1060 55%, #150838 100%);
    border-color: rgba(192,132,252,.22);
    box-shadow:
        inset 0 2px 6px rgba(192,132,252,.06),
        inset 0 -3px 8px rgba(0,0,0,.5),
        0 3px 12px rgba(168,85,247,.15);
}
@media (min-width: 768px) {
    .theme-fun .mb-natural {
        background:
            linear-gradient(90deg,
                rgba(0,0,0,.4) 0%, rgba(192,132,252,.08) 50%, rgba(0,0,0,.4) 100%
            ),
            linear-gradient(180deg, #1e0a4a 0%, #2d1060 60%, #150838 100%);
    }
}
.theme-fun .mb-sharp {
    background: linear-gradient(160deg, #0a0620 0%, #160c30 50%, #0a0620 100%);
    border-color: rgba(34,211,238,.1);
}
.theme-fun .mb-note-name { color: rgba(216,180,254,.7); }
.theme-fun .mb-key-hint  { color: rgba(192,132,252,.5); background: rgba(192,132,252,.08); border-color: rgba(192,132,252,.2); }
.theme-fun .mb-natural.struck {
    box-shadow:
        0 0 24px rgba(192,132,252,.8),
        0 0 50px rgba(168,85,247,.4),
        inset 0 0 16px rgba(192,132,252,.1) !important;
}
.theme-fun .mb-sharp.struck {
    box-shadow: 0 0 18px rgba(34,211,238,.7) !important;
}

/* ═══════ MOBILE OCTAVE SWITCHER UI ═══════ */
.mb-oct-switcher {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px 4px;
    flex-wrap: wrap;
}
.mb-oct-pill {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: .68rem;
    font-weight: 700;
    border: 1px solid var(--bdr);
    background: var(--card);
    color: var(--muted);
    cursor: pointer;
    transition: all .15s;
    -webkit-tap-highlight-color: transparent;
}
.mb-oct-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #08040c;
}
.mb-oct-pill:not(.active):hover {
    border-color: var(--accent);
    color: var(--accent);
}
@media (min-width: 768px) {
    .mb-oct-switcher { display: none; } /* desktop uses toolbar oct nav */
}

/* ═══════ PARTICLES ═══════ */
.marimba-particles {
    position: absolute; inset: 0;
    pointer-events: none; z-index: 10;
    border-radius: inherit;
}

/* ═══════ INFO BAR ═══════ */
.marimba-info-bar {
    background: var(--surf); border-top: 1px solid var(--bdr);
    padding: 6px 12px; display: flex; align-items: center;
    justify-content: space-between; flex-wrap: wrap; gap: 4px;
    font-size: .66rem; color: var(--muted);
}
.marimba-info-bar b { color: var(--accent); opacity: .7; }

/* ── Hide keyboard hints on mobile info bar ── */
@media (max-width: 599px) {
    .marimba-info-bar .kb-hint { display: none; }
}

/* ═══════ THEME TOGGLE BUTTON ═══════ */
.theme-toggle-btn {
    background: var(--card2); color: var(--muted);
    border: 1px solid var(--bdr); border-radius: 6px;
    padding: 4px 10px; font-size: .64rem; font-weight: 700;
    cursor: pointer; transition: all .15s; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.theme-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }