/* Pocket Beats: true black, EB Garamond headings, Inter UI, sharp corners. Portrait first, thumb-reach controls. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root { --bg: #000; --panel: #0b0b0b; --panel2: #141414; --rule: #2a2826; --ink: #faf9f7; --stone: #9a9890; --accent: #22e6d4; --yellow: #ede400;
  --serif: 'EB Garamond', Georgia, serif; --sans: 'Inter', system-ui, sans-serif; --cell: max(44px, calc((100vw - 76px) / 8)); }
html, body { height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; padding-top: env(safe-area-inset-top); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ── start gate ── */
#gate { position: fixed; inset: 0; z-index: 100; background: radial-gradient(120% 80% at 50% 0%, #10122a 0%, #000 60%); display: flex; align-items: center; justify-content: center; text-align: center; padding: 32px; cursor: pointer; }
.gate-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 420px; }
.gate-eyebrow { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--stone); }
#gate h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(3.2rem, 17vw, 5.4rem); line-height: .95; letter-spacing: -.02em; }
#gate h1 span { display: block; background: linear-gradient(var(--yellow), var(--yellow)) 0 94% / 100% .08em no-repeat; padding-bottom: .05em; }
.gate-line { font-size: 17px; color: #dad7d0; }
.gate-btn { margin-top: 10px; background: var(--ink); color: #000; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: 13px; padding: 18px 40px; animation: gatePulse 1.6s ease-in-out infinite; }
.gate-note { font-size: 12px; color: var(--stone); margin-top: 6px; }
@keyframes gatePulse { 50% { box-shadow: 0 0 0 10px rgba(34,230,212,.18); } }

/* ── top bar ── */
.top { display: flex; align-items: center; gap: 10px; padding: 10px 14px 8px; }
.brand { font-family: var(--serif); font-size: 1.55rem; letter-spacing: -.01em; margin-right: auto; display: flex; align-items: center; gap: 8px; line-height: .88; flex-shrink: 0; }
.brand-beet { flex: 0 0 auto; width: 30px; height: auto; display: block; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; line-height: .86; }
.brand em { font-style: normal; background: linear-gradient(var(--yellow), var(--yellow)) 0 95% / 100% .09em no-repeat; }
.chip { border: 1px solid var(--rule); padding: 8px 12px; font-size: 12px; font-weight: 500; letter-spacing: .06em; color: var(--stone); background: transparent; min-height: 36px; }
.chip.on { border-color: var(--accent); color: var(--ink); background: rgba(34,230,212,.1); }
.chip.pack b { color: var(--ink); font-weight: 600; }
.icon { flex: 0 0 40px; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--rule); }
.icon svg { width: 20px; height: 20px; fill: none; stroke: var(--stone); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
a.icon { text-decoration: none; }
.icon.on { background: var(--ink); } .icon.on svg { stroke: #000; }
.icon svg[hidden] { display: none; }
#icoPlay { fill: var(--stone); } .icon.on #icoPlay { fill: #000; }
.loopbar { height: 3px; background: var(--rule); }
#progress { height: 100%; width: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
#beatDots { display: flex; justify-content: center; gap: 6px; padding: 8px 0 2px; }
#beatDots i { width: 8px; height: 8px; border: 1px solid var(--rule); }
#beatDots[data-b="0"] i:nth-child(1), #beatDots[data-b="1"] i:nth-child(2), #beatDots[data-b="2"] i:nth-child(3), #beatDots[data-b="3"] i:nth-child(4),
#beatDots[data-b="4"] i:nth-child(5), #beatDots[data-b="5"] i:nth-child(6), #beatDots[data-b="6"] i:nth-child(7), #beatDots[data-b="7"] i:nth-child(8) { background: var(--accent); border-color: var(--accent); }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 10px 14px 12px; overflow-y: auto; overscroll-behavior: contain; }

/* ── pads ── */
.pads { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, minmax(64px, 1fr)) minmax(56px, .62fr); gap: 10px; }
.pad { position: relative; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; text-align: left; padding: 12px 14px; background: var(--panel); border: 1px solid var(--rule); touch-action: none; transition: background .08s, border-color .08s, transform .08s; overflow: hidden; }
.pad:active { transform: scale(.985); }
.pad-name { font-family: var(--serif); font-size: 1.7rem; line-height: 1; letter-spacing: -.01em; }
.pad-var { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--stone); }
.pad-dots { display: flex; gap: 5px; position: absolute; right: 12px; top: 14px; }
.pad-dots i { width: 6px; height: 6px; background: var(--rule); } .pad-dots i.on { background: var(--ink); }
.pad-state { position: absolute; right: 12px; bottom: 10px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--yellow); }
.pad.on { background: rgba(34,230,212,.14); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 0 24px rgba(34,230,212,.18); }
.pad.on .pad-var { color: var(--accent); }
.pad.on.pulse { background: rgba(34,230,212,.26); }
.pad.queued { border-style: dashed; border-color: var(--yellow); box-shadow: none; }

.actions { display: flex; gap: 10px; }
.actions.wrap { flex-wrap: wrap; }
.btn { flex: 1 1 auto; min-height: 52px; padding: 0 18px; border: 1px solid rgba(250,249,247,.55); font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.btn:active { background: var(--ink); color: #000; }
.btn.primary { background: var(--ink); color: #000; border-color: var(--ink); }
.btn.primary:active { background: var(--accent); border-color: var(--accent); }
.btn.rec { border-color: var(--yellow); color: var(--yellow); }
.btn.rec.on { background: var(--yellow); color: #000; animation: recBlink 1s steps(2) infinite; }
@keyframes recBlink { 50% { opacity: .7; } }
.btn.file { cursor: pointer; }

/* ── build ── */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; flex-shrink: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; padding: 10px 14px; min-height: 44px; border: 1px solid var(--rule); font-size: 13px; letter-spacing: .06em; color: var(--stone); }
.tab.on { background: var(--ink); color: #000; border-color: var(--ink); font-weight: 600; }
.rowbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-shrink: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.gridwrap { flex-shrink: 0; border: 1px solid var(--rule); background: var(--panel); }
.gridhead { display: flex; border-bottom: 1px solid var(--rule); height: 24px; }
.gridhead .spacer, .labels { width: 52px; flex: 0 0 52px; }
.gridhead-steps { overflow: hidden; display: flex; }
.gridhead-steps span { flex: 0 0 calc(var(--cell) * 4); font-size: 10px; letter-spacing: .08em; color: var(--stone); padding: 5px 6px; text-transform: uppercase; border-left: 1px solid var(--rule); }
.gridbody { display: flex; }
.labels { display: grid; grid-template-rows: repeat(var(--rows), var(--cell)); border-right: 1px solid var(--rule); background: var(--panel2); }
.lab { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--stone); letter-spacing: .04em; border-bottom: 1px solid var(--rule); }
.scroller { flex: 1; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; touch-action: pan-x; }
.scroller::-webkit-scrollbar { display: none; }
.grid { position: relative; width: calc(var(--cell) * 32); display: grid; grid-template-rows: repeat(var(--rows), var(--cell)); }
.row { display: grid; grid-template-columns: repeat(32, var(--cell)); }
.cell { width: var(--cell); height: var(--cell); border-right: 1px solid #1a1a1a; border-bottom: 1px solid var(--rule); background: transparent; position: relative; scroll-snap-align: none; }
.cell.beat { border-left: 1px solid #333; }
.cell.bar { border-left: 2px solid #4a4844; }
.cell:nth-child(8n+1) { scroll-snap-align: start; }
.cell::after { content: ''; position: absolute; inset: 5px; }
.cell.on::after { background: var(--accent); box-shadow: 0 0 12px rgba(34,230,212,.45); }
#playhead { position: absolute; top: 0; bottom: 0; left: 0; width: var(--cell); transform: translateX(calc(var(--x, 0) * var(--cell))); background: rgba(237,228,0,.14); border-left: 1px solid rgba(237,228,0,.6); pointer-events: none; }
.hint { font-size: 12px; color: var(--stone); }

/* ── arrange ── */
.arr { border: 1px solid var(--rule); background: var(--panel); flex-shrink: 0; overflow-x: auto; position: relative; }
.blocks-head { display: flex; height: 22px; border-bottom: 1px solid var(--rule); width: max-content; min-width: 100%; }
.blocks-head .spacer { flex: 0 0 62px; }
#blocksHead { display: flex; } #blocksHead span { width: 66px; font-size: 10px; letter-spacing: .08em; color: var(--stone); padding: 4px 6px; border-left: 1px solid var(--rule); }
.lanes-scroll { position: relative; width: max-content; min-width: 100%; }
.lane { display: flex; align-items: stretch; border-bottom: 1px solid var(--rule); }
.lane-name { flex: 0 0 62px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--stone); padding: 10px 8px; background: var(--panel2); border-right: 1px solid var(--rule); }
.lane-blocks { display: flex; }
.block { width: 66px; height: 66px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--stone); font-size: 20px; }
.block.full { background: rgba(34,230,212,.16); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.block b { font-family: var(--serif); font-weight: 400; font-size: 16px; } .block i { font-style: normal; font-size: 10px; letter-spacing: .1em; color: var(--accent); }
#songHead { position: absolute; top: 0; bottom: 0; left: calc(62px + var(--x, 0) * 66px); width: 2px; background: var(--yellow); pointer-events: none; box-shadow: 0 0 10px rgba(237,228,0,.6); }
.top-actions { flex-shrink: 0; }

/* ── nav ── */
.nav { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rule); background: #000; padding-bottom: env(safe-area-inset-bottom); }
.nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 62px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--stone); }
.nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav button.on { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }

/* ── sheets, tips, toast ── */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.72); display: flex; align-items: flex-end; }
.sheet-card { width: 100%; max-height: 82dvh; overflow-y: auto; background: var(--panel); border-top: 1px solid var(--rule); padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.sheet-card p { color: #dad7d0; font-size: 14px; line-height: 1.6; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; font-family: var(--serif); font-size: 1.4rem; }
.sheet-head button { font-size: 30px; line-height: 1; color: var(--stone); width: 44px; height: 44px; }
.sheet-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.sheet-row span { flex: 0 0 64px; font-family: var(--serif); font-size: 1.15rem; }
.tip { flex-shrink: 0; background: var(--yellow); color: #111; padding: 14px 14px 14px 16px; display: flex; gap: 12px; align-items: center; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 22px), calc(100% - 22px) 100%, 0 100%); }
.tip p { flex: 1; font-size: 14px; line-height: 1.45; font-weight: 500; }
.tip .btn { flex: 0 0 auto; min-height: 44px; background: #141414; color: var(--yellow); border-color: #141414; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(112px + env(safe-area-inset-top)); z-index: 60; background: var(--ink); color: #000; padding: 10px 16px; font-size: 13px; font-weight: 500; max-width: 88vw; text-align: center; }

@media (min-width: 720px) { body { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); } :root { --cell: 46px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* loops sheet (hold a pad) */
.loop-list { display: flex; flex-direction: column; gap: 8px; }
.loop-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; min-height: 56px; border: 1px solid var(--rule); background: #0b0b0b; text-align: left; }
.loop-row b { font-family: var(--serif); font-weight: 400; font-size: 1.35rem; }
.loop-row span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--stone); }
.loop-row.on { border-color: var(--accent); background: rgba(34,230,212,.1); }
.loop-row.on span { color: var(--accent); }

/* style sheet (the chip in the top bar) */
.style-list { display: flex; flex-direction: column; gap: 8px; }
.style-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline; text-align: left; padding: 14px 16px; border: 1px solid var(--rule); background: #0b0b0b; }
.style-row b { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; }
.style-row em { font-style: normal; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--stone); }
.style-row span { grid-column: 1 / -1; font-size: 13px; color: #b9b5ad; line-height: 1.4; }
.style-row.on { border-color: var(--accent); background: rgba(34,230,212,.1); }
.style-row.on em { color: var(--accent); }

/* the tutorial: a shield over the screen, a finger, and a caption */
#demo { position: fixed; inset: 0; z-index: 300; pointer-events: none; }
#demo[hidden] { display: none; }
#demoShield { position: absolute; inset: 0; pointer-events: auto; background: transparent; }
#demoFinger { position: fixed; left: 0; top: 0; width: 46px; height: 46px; pointer-events: none; z-index: 2; transition: transform .6s cubic-bezier(.3,.7,.2,1); will-change: transform; }
#demoFinger i { position: absolute; inset: 0; border-radius: 50%; background: rgba(250,249,247,.28); border: 2px solid #faf9f7; box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 6px 20px rgba(0,0,0,.45); transition: transform .15s, background .15s; }
#demoFinger.tap i { transform: scale(.7); background: rgba(34,230,212,.6); }
#demoFinger.down i { transform: scale(.85); background: rgba(250,249,247,.5); }
#demoFinger.hold i { animation: demoHold .9s linear forwards; }
@keyframes demoHold { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(237,228,0,.9); } 100% { transform: scale(.8); box-shadow: 0 0 0 16px rgba(237,228,0,0); background: rgba(237,228,0,.55); } }
#demoCap { position: fixed; left: 10px; right: 10px; top: max(8px, env(safe-area-inset-top)); z-index: 3; pointer-events: auto; background: var(--yellow); color: #141414; padding: 10px 14px 14px; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%); box-shadow: 0 10px 30px rgba(0,0,0,.5); }
#demoCap.bottom { top: auto; bottom: calc(84px + env(safe-area-inset-bottom)); }
.dc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; opacity: .75; }
.dc-btns { display: inline-flex; gap: 6px; }
.dc-btns button { font: 700 10px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; padding: 8px 10px; min-height: 32px; border: 1px solid #141414; color: #141414; background: transparent; }
#demoSkip { background: #141414; color: var(--yellow); }
#demoCap p { margin: 5px 0 7px; font-size: 14px; line-height: 1.35; font-weight: 600; }
.dc-bar { height: 3px; background: rgba(20,20,20,.18); } .dc-bar i { display: block; height: 100%; width: 0; background: #141414; transition: width .5s; }
body.demoing .nav, body.demoing .top { pointer-events: none; }
@media (prefers-reduced-motion: reduce) { #demoFinger { transition: none !important; } }

/* custom-sound pads: empty ones invite a tap */
.pad.empty { border-style: dashed; background: transparent; }
.pad.empty .pad-name { color: var(--stone); font-size: 1.3rem; }
.pad.empty .pad-var { color: var(--accent); }
.pad.empty::after { content: "+"; position: absolute; right: 14px; top: 8px; font-size: 26px; line-height: 1; color: var(--stone); }

@media (max-width: 380px) {
  .top { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .brand { font-size: 1.35rem; gap: 6px; } .brand-beet { width: 26px; }
  .chip.pack { min-width: 0; padding: 6px 7px; font-size: 10.5px; letter-spacing: .03em; }
  .icon { flex-basis: 36px; width: 36px; height: 36px; }
}

.chip.pack { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.15; text-align: center; }
.chip.pack { padding: 6px 9px; letter-spacing: .03em; white-space: nowrap; }

/* projects sheet */
.field { display: flex; flex-direction: column; gap: 6px; }
.field input { min-height: 52px; padding: 0 14px; background: #000; color: var(--ink); border: 1px solid rgba(250,249,247,.55); font-size: 16px; border-radius: 0; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.proj-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--rule); }
.proj-row.on { box-shadow: inset 3px 0 0 var(--accent); }
.proj-open { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; text-align: left; min-height: 56px; }
.proj-open b { font-family: var(--serif); font-size: 1.15rem; font-weight: 400; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-open span { font-size: 12px; color: var(--stone); }
.proj-del { width: 52px; font-size: 26px; color: var(--stone); }
.proj-del:active { color: var(--yellow); }
