/* Beatbay: its colours over the web iOS kit (src/ioskit/ios.css), the tab bar, and its own pieces: the transport, the
   pattern chips, the step grid (each drum its own colour; accents bright, chance faded, rolls as ticks, the playhead's
   column ringed and lit steps flashing), the sweep, the toolbar, the pads, and the sheets' bits. Dark by default. */
:root {
  --canvas: #F4F2F8; --grouped: #F4F2F8; --row: #FFFFFF; --card: #FFFFFF;
  --hot: #6A4DF0; --tint: var(--hot); --forest: var(--hot); --coral: var(--hot); --rec: #E5364B;
  --cellbg: rgba(40, 30, 70, 0.07); --cellbeat: rgba(40, 30, 70, 0.12); --lab: rgba(40, 30, 70, 0.06);
  --text2: rgba(30, 24, 48, 0.62); --text3: rgba(30, 24, 48, 0.34); --sep: rgba(30, 24, 48, 0.14);
  --fill: rgba(80, 64, 140, 0.12); --fill2: rgba(80, 64, 140, 0.08);
  --glass: rgba(253, 252, 255, 0.86); --glass-edge: rgba(20, 0, 60, 0.07);
  --tabbar-space: calc(var(--sab) + 108px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0B0A12; --grouped: #0B0A12; --row: #17151F; --card: #17151F;
    --hot: #9D8CFF; --cellbg: rgba(255, 255, 255, 0.055); --cellbeat: rgba(255, 255, 255, 0.1); --lab: rgba(255, 255, 255, 0.05);
    --text: #F1EEF8; --text2: rgba(241, 238, 248, 0.62); --text3: rgba(241, 238, 248, 0.3); --sep: rgba(241, 238, 248, 0.12);
    --fill: rgba(220, 210, 255, 0.13); --fill2: rgba(220, 210, 255, 0.08);
    --glass: rgba(28, 26, 38, 0.84); --glass-edge: rgba(240, 230, 255, 0.08);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #0B0A12; --grouped: #0B0A12; --row: #17151F; --card: #17151F;
  --hot: #9D8CFF; --cellbg: rgba(255, 255, 255, 0.055); --cellbeat: rgba(255, 255, 255, 0.1); --lab: rgba(255, 255, 255, 0.05);
  --text: #F1EEF8; --text2: rgba(241, 238, 248, 0.62); --text3: rgba(241, 238, 248, 0.3); --sep: rgba(241, 238, 248, 0.12);
  --fill: rgba(220, 210, 255, 0.13); --fill2: rgba(220, 210, 255, 0.08);
  --glass: rgba(28, 26, 38, 0.84); --glass-edge: rgba(240, 230, 255, 0.08);
  color-scheme: dark;
}
body { background: var(--canvas); }
.btn-primary { --btn: var(--hot); }
:root[data-theme="dark"] .btn-primary { color: #120A2E; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #120A2E; } }

/* ---------- tabs ---------- */
#stack .tab-pane { position: absolute; inset: 0; }
#stack .screen-body { padding-bottom: var(--tabbar-space); }
.tabbar { position: absolute; z-index: 10; left: 50%; bottom: calc(var(--sab) + 18px); transform: translateX(-50%); display: grid; grid-template-columns: repeat(3, 92px); padding: 4px; border-radius: 34px;
  background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(1.8); backdrop-filter: blur(20px) saturate(1.8); box-shadow: 0 0 0 0.5px var(--glass-edge), 0 8px 30px rgba(0, 0, 0, 0.18); --i: 0; }
.tab-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: 92px; border-radius: 30px; background: var(--fill); transform: translateX(calc(var(--i) * 100%)); transition: transform 0.38s var(--ease); }
.tab-item { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 54px; border-radius: 30px; color: var(--text); }
.tab-item.on { color: var(--hot); }
.tab-icon { width: 26px; height: 26px; display: grid; place-items: center; }
.tab-icon svg { width: 26px; height: 26px; }
.tab-label { font-size: 10px; line-height: 12px; font-weight: 600; letter-spacing: 0.01em; }
.tab-item:active .tab-icon { transform: scale(0.92); }
body.has-sheet .tabbar { visibility: hidden; }
@media (min-width: 700px) {
  .tabbar { bottom: auto; top: calc(var(--sat) + 8px); grid-template-columns: repeat(3, 118px); padding: 3px; border-radius: 26px; }
  .tab-pill { top: 3px; bottom: 3px; left: 3px; width: 118px; border-radius: 22px; }
  .tab-item { flex-direction: row; gap: 6px; height: 44px; border-radius: 22px; }
  .tab-icon, .tab-icon svg { width: 20px; height: 20px; }
  .tab-label { font-size: 15px; line-height: 20px; }
  #stack .screen.tab-root .nav-title { visibility: hidden; }
  #stack .screen-body { padding-bottom: calc(var(--sab) + 32px); }
}
/* the Make tab: the tab bar sits low, so the grid scrolls clear of it */
@media (max-width: 699px) { #stack .make .screen-body { padding-bottom: calc(var(--sab) + 96px); } }

/* ---------- shared ---------- */
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; width: 100%; box-sizing: border-box; }
.big-title { font: 800 32px/38px var(--sys); letter-spacing: -0.02em; padding: 4px 4px 2px; }
.lede { color: var(--text2); font-size: 15px; line-height: 21px; padding: 0 4px 6px; }
.pro-tag { display: inline-flex; align-items: center; height: 17px; padding: 0 6px; border-radius: 9px; font: 700 10px/17px var(--sys); letter-spacing: 0.06em; color: #fff; background: var(--hot); vertical-align: middle; }
:root[data-theme="dark"] .pro-tag { color: #120A2E; }
.row .grow { flex: 1 1 auto; min-width: 0; }
.row .r-title { font-weight: 600; }
.row .r-sub, .r-sub { color: var(--text2); font-size: 14px; line-height: 19px; margin-top: 1px; }
.r-about { color: var(--text2); font-size: 13px; line-height: 18px; margin-top: 3px; }
.row .r-end { color: var(--text2); font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row.chosen .row-main::after { content: "✓"; color: var(--hot); font-weight: 800; margin-left: auto; padding-left: 10px; }
.empty { color: var(--text2); text-align: center; padding: 14px 8px; font-size: 15px; }
.slider-row { flex-direction: column; align-items: stretch; gap: 10px; padding-top: 14px; padding-bottom: 16px; }
.slider-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.slider-top .v { color: var(--text2); font-variant-numeric: tabular-nums; margin-left: auto; }
.ios-range { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; cursor: pointer; }
.ios-range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--tint) var(--p, 50%), var(--fill) var(--p, 50%)); }
.ios-range::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -12px; border-radius: 50%; background: #fff; box-shadow: 0 0.5px 4px rgba(0,0,0,.12), 0 6px 13px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); }
.ios-range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--fill); }
.ios-range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--tint); }
.ios-range::-moz-range-thumb { width: 28px; height: 28px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.2); }

/* ---------- the transport ---------- */
.make-wrap { padding-top: 4px; }
.transport { display: flex; align-items: center; gap: 10px; padding: 2px 0 10px; }
.transport .grow { flex: 1; }
.go { flex: none; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; color: #fff; background: var(--hot); box-shadow: 0 6px 22px color-mix(in srgb, var(--hot) 45%, transparent); transition: transform 0.12s, background 0.2s; }
:root[data-theme="dark"] .go { color: #120A2E; }
.go.on { background: #FF4D8D; color: #fff; box-shadow: 0 6px 26px rgba(255, 77, 141, 0.5); }
.go:active { transform: scale(0.94); }
.tempo { flex: none; min-width: 64px; min-height: 52px; padding: 4px 10px; border-radius: 16px; background: var(--fill2); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.tempo b { font: 800 22px/1 var(--sys); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tempo small { font: 600 11px/1.3 var(--sys); color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 3px; }
.view-seg { width: 150px; flex: none; }
@media (max-width: 420px) { .view-seg { width: 120px; } .tempo { min-width: 56px; padding: 4px 6px; } .go { width: 54px; height: 54px; } }

/* ---------- patterns ---------- */
.pats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 10px; }
.pats::-webkit-scrollbar { display: none; }
.pat { position: relative; flex: none; min-width: 40px; height: 40px; border-radius: 12px; background: var(--fill2); font: 800 16px/1 var(--sys); color: var(--text2); display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px; }
.pat.has::after { content: ""; position: absolute; bottom: 5px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.pat.sel { background: var(--hot); color: #fff; }
:root[data-theme="dark"] .pat.sel { color: #120A2E; }
.pat.playing { box-shadow: 0 0 0 2px #FF4D8D inset; }
.pat.queued { animation: blink 0.5s steps(2) infinite; }
.pat.locked::before { content: ""; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--text3); }
.song-btn { margin-left: auto; font-size: 14px; gap: 6px; padding: 0 12px; }
.song-btn svg { width: 18px; height: 18px; }
@media (max-width: 480px) { .pats { gap: 5px; } .pat { min-width: 34px; padding: 0 6px; font-size: 15px; } .song-btn span { display: none; } .song-btn { padding: 0 9px; } }
@keyframes blink { 50% { box-shadow: 0 0 0 2px var(--hot) inset; background: transparent; } }

/* ---------- the grid ---------- */
.grid-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 8px; }
.brush-seg { flex: 1 1 200px; max-width: 420px; }
@media (max-width: 480px) { .grid-head { flex-wrap: nowrap; } .brush-seg .seg { font-size: 13px; } .page { padding: 0 7px; font-size: 12px; } .pages { gap: 4px; } }
.pages { display: flex; gap: 6px; margin-left: auto; }
.page { min-height: 34px; padding: 0 10px; border-radius: 10px; background: var(--fill2); font: 700 13px/1 var(--sys); color: var(--text2); font-variant-numeric: tabular-nums; }
.page.on { background: var(--fill); color: var(--text); }
.grid { display: grid; grid-template-columns: 68px repeat(var(--cols, 16), minmax(0, 1fr)); gap: 4px; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
@media (min-width: 500px) { .grid { grid-template-columns: 108px repeat(var(--cols, 16), minmax(0, 1fr)); gap: 5px; } }
.lab { display: flex; align-items: center; gap: 5px; min-height: 44px; padding: 0 5px; border-radius: 10px; background: var(--lab); font: 700 11.5px/1.1 var(--sys); letter-spacing: -0.01em; text-align: left; overflow: hidden; color: var(--text); }
.lab i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.lab span:not(.pro-tag) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lab .pro-tag { display: none; }
@media (min-width: 500px) { .lab { font-size: 14px; } .lab .pro-tag { display: inline-flex; margin-left: auto; } }
.lab.muted { opacity: 0.4; }
.lab.muted i { box-shadow: none; background: var(--text3); }
.lab.solo { box-shadow: 0 0 0 1.5px var(--c) inset; }
.lab.ghost { opacity: 0.55; }
.cell { position: relative; display: grid; place-items: center; min-height: 44px; border-radius: 9px; background: var(--cellbg); padding: 0; overflow: hidden; transition: background 0.08s, transform 0.08s; }
@media (min-width: 500px) { .cell { min-height: 44px; } }
@media (max-width: 499px) { .cell, .lab { min-height: 42px; } .grid { gap: 4px; } .sweep-row { padding-top: 4px; } }
.cell.beat { background: var(--cellbeat); }
.cell.bar:not([data-i="0"]) { box-shadow: -3px 0 0 -1px var(--sep); }
.cell.on { background: color-mix(in srgb, var(--c) 62%, transparent); }
.cell.on.acc { background: var(--c); box-shadow: 0 0 12px color-mix(in srgb, var(--c) 55%, transparent); }
.cell.c75 { background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgba(0,0,0,0.16) 4px 6px); }
.cell.c50 { background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(0,0,0,0.26) 3px 6px); }
.cell.c25 { background-image: repeating-linear-gradient(135deg, transparent 0 2px, rgba(0,0,0,0.36) 2px 6px); opacity: 0.8; }
.cell .rolls { position: absolute; left: 4px; right: 4px; bottom: 4px; display: flex; gap: 2px; }
.cell .rolls i { flex: 1; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, 0.45); }
.cell .pc { position: absolute; top: 2px; right: 3px; font: 700 9px/1 var(--sys); color: rgba(0, 0, 0, 0.6); }
.cell .nudge { position: absolute; top: 1px; left: 3px; font: 800 11px/1 var(--sys); color: rgba(0, 0, 0, 0.55); }
.cell .nm { font: 800 11px/1 var(--sys); color: rgba(0, 0, 0, 0.75); white-space: nowrap; }
@media (min-width: 500px) { .cell .nm { font-size: 13px; } }
.cell.held { background: color-mix(in srgb, var(--c) 22%, transparent); }
.cell.out { opacity: 0.18; }
.cell.now { box-shadow: 0 0 0 2px color-mix(in srgb, var(--text) 70%, transparent) inset; }
.cell.flash { animation: flash 0.22s ease-out; }
@keyframes flash { 0% { filter: brightness(1.9); transform: scale(1.08); } 100% { filter: none; transform: none; } }
.cell:focus-visible { outline: 2px solid var(--hot); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .cell.flash { animation: none; filter: brightness(1.5); } }

/* ---------- the sweep and the toolbar ---------- */
.sweep-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px 6px; }
.sweep-row .sw-l { font: 700 13px/1 var(--sys); color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; }
.sweep-row .sw-r { color: var(--text2); display: grid; }
.sweep { -webkit-appearance: none; appearance: none; flex: 1; height: 44px; background: transparent; margin: 0; cursor: pointer; }
.sweep::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: linear-gradient(to right, #FF4D8D, var(--hot) var(--p, 100%), var(--fill) var(--p, 100%)); }
.sweep::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -11px; border-radius: 50%; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.sweep::-moz-range-track { height: 8px; border-radius: 4px; background: var(--fill); }
.sweep::-moz-range-progress { height: 8px; border-radius: 4px; background: var(--hot); }
.sweep::-moz-range-thumb { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #fff; }
.toolbar { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; padding: 6px 0 10px; }
@media (max-width: 560px) { .toolbar { gap: 4px; } .tb { min-height: 50px; font-size: 9.5px; letter-spacing: -0.02em; border-radius: 12px; } .tb svg { width: 19px; height: 19px; } }
.tb { min-height: 52px; border-radius: 14px; background: var(--fill2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font: 600 12px/1 var(--sys); color: var(--text); touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tb svg { width: 21px; height: 21px; color: var(--hot); }
.tb:disabled { opacity: 0.35; }
.tb.on, #fill.on { background: #FF4D8D; color: #fff; }
.tb.on svg, #fill.on svg { color: #fff; }

/* ---------- the pads ---------- */
.pads-head { display: flex; align-items: center; gap: 12px; padding: 0 0 10px; }
.rec { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 22px; background: var(--fill2); font-weight: 700; }
.rec i { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); opacity: 0.5; }
.rec.on { background: var(--rec); color: #fff; }
.rec.on i { background: #fff; opacity: 1; animation: blinkdot 1s steps(2) infinite; }
@keyframes blinkdot { 50% { opacity: 0.3; } }
.pads-note { color: var(--text2); font-size: 14px; line-height: 19px; }
.padgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
@media (max-width: 560px) and (orientation: portrait) { .padgrid { grid-template-columns: repeat(2, 1fr); gap: 8px; } .pad { aspect-ratio: 1.75; padding: 12px; } }
.pad { position: relative; aspect-ratio: 1.35; border-radius: 22px; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px; padding: 14px; text-align: left;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 34%, var(--row)), color-mix(in srgb, var(--c) 14%, var(--row))); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent); color: var(--text); }
.pad b { font: 800 20px/1.1 var(--sys); }
.pad small { font: 500 13px/1.2 var(--sys); color: var(--text2); }
.pad kbd { position: absolute; top: 10px; right: 12px; font: 700 12px/1 var(--sys); color: var(--text3); }
@media (hover: none) { .pad kbd { display: none; } }
.pad.hit { animation: padhit 0.28s ease-out; }
@keyframes padhit { 0% { background: var(--c); transform: scale(0.96); } 100% { transform: none; } }

/* ---------- sheets ---------- */
.sheet-wrap { padding-top: 4px; padding-bottom: 24px; }
.notes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; }
.notes.chords { grid-template-columns: repeat(4, 1fr); }
.note { min-height: 48px; border-radius: 12px; background: var(--fill2); font: 800 16px/1 var(--sys); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.note small { font: 600 11px/1 var(--sys); color: var(--text2); }
.note.on { background: var(--hot); color: #fff; }
.note.on small { color: rgba(255, 255, 255, 0.8); }
.bpm-row { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 0 14px; }
.big-bpm { font: 800 64px/1 var(--sys); letter-spacing: -0.04em; min-width: 3ch; text-align: center; font-variant-numeric: tabular-nums; }
.round { width: 52px; height: 52px; border-radius: 50%; background: var(--fill2); font: 600 28px/1 var(--sys); }
.tap-btn { min-height: 52px; padding: 0 22px; border-radius: 26px; background: var(--hot); color: #fff; font-weight: 800; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.chain .pat small { font-size: 13px; opacity: 0.6; margin-left: 2px; }
.ms-pair { display: inline-flex; gap: 6px; }
.ms { width: 32px; height: 28px; border-radius: 8px; background: var(--fill2); font: 800 12px/1 var(--sys); color: var(--text2); }
.ms.on { background: #FFB13D; color: #241500; }
.ms.solo.on { background: #4BE3A0; color: #062014; }
.progress { position: relative; height: 34px; margin: 8px 0; border-radius: 17px; background: var(--fill2); overflow: hidden; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.progress i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: color-mix(in srgb, var(--hot) 40%, transparent); transition: width 0.2s; }
.progress span { position: relative; }
.btn-primary.wide, .btn-secondary.wide { width: 100%; min-height: 50px; margin-top: 10px; }
.shared-top { display: flex; align-items: center; gap: 16px; padding: 8px 4px 14px; }
.shared-name { font: 800 24px/1.2 var(--sys); letter-spacing: -0.02em; }
.go.big { width: 76px; height: 76px; font-size: 28px; }

/* ---------- the Beats tab ---------- */
.beat-row { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; }
.thumb { flex: none; width: 64px; height: 32px; border-radius: 6px; background: var(--fill2); }
.open-tag { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 8px; background: var(--fill); font: 700 11px/16px var(--sys); color: var(--text2); vertical-align: middle; }
.mini-play { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; color: var(--hot); }
.mini-play.on { background: #FF4D8D; color: #fff; }
.mini-play svg { width: 16px; height: 16px; }
:root:root .tb, :root:root .pat, :root:root .page, :root:root .ms { min-height: 44px; }
:root:root .ms { min-width: 40px; }
.foot-links { text-align: center; padding-top: 14px; }
.foot-links a { color: var(--text2); }
@media (min-width: 481px) { :root:root .pat { min-width: 44px; } }
