:root {
  color-scheme: dark;
  --bg: #050814;
  --panel: #0b152c;
  --elevated: #10203f;
  --border: #16324f;
  --text: #e8f7ff;
  --muted: #8fb4c9;
  --accent: #22d3ee;
  --accent-fg: #041018;
  --live: #14b8a6;
  --danger: #fb7185;
  --step: #0e1a33;
  --step-on: #22d3ee;
  --step-play: #e8f7ff;
  --lcd: #071018;
  --radius: 16px;
  --radius-sm: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --motion-quick: 150ms;
  --motion-fast: 250ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--kp-font), Outfit, "Noto Sans", "Noto Sans Arabic", "Noto Sans Ethiopic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  padding: calc(0.75rem + env(safe-area-inset-top)) 0.75rem calc(1.5rem + env(safe-area-inset-bottom));
  max-width: none;
  margin: 0;
}
button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; }
button {
  font: inherit;
  color: inherit;
}
.tabular { font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.7rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}
.chip i {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--live);
  display: inline-block;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: var(--bg);
}
.gate[hidden] {
  display: none;
}
.gate-inner {
  width: min(28rem, 100%);
  text-align: center;
}
.gate-mark {
  width: 4.5rem;
  height: 4.5rem;
  display: block;
  margin: 0 auto 0.9rem;
}
.gate h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
.lede {
  margin: 0 0 1.2rem;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 500;
}
.hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  min-height: 44px;
}
.brand img { width: 36px; height: 36px; }
.brand strong {
  display: block;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.brand em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.top-actions { display: flex; gap: 0.5rem; }

.lesson-next.ready { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.spot { outline: 3px solid var(--accent); outline-offset: 3px; }
.lesson {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0 0 0.8rem;
}
.lesson h2 { margin: 0.1rem 0 0.3rem; font-size: 1.15rem; }
.lesson-kicker { margin: 0; color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.lesson-body { margin: 0.25rem 0 0; line-height: 1.45; }
.lesson-miss { margin: 0.4rem 0 0; min-height: 1.2em; font-weight: 750; }
.lesson-actions { display: flex; gap: 0.45rem; margin-top: 0.7rem; }
.help {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 0 0 0.9rem;
}
.help h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 750;
}
.help ol, .help p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 500;
  font-size: 0.92rem;
}
.help ol { padding-left: 1.2rem; margin-bottom: 0.5rem; }

.stage {
  background: var(--lcd);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  padding: 0.55rem;
  margin-bottom: 0.75rem;
}
.stage-canvas {
  width: 100%;
  height: 220px;
  display: block;
  border-radius: var(--radius);
  background: #050814;
}
.stage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem 0.85rem;
  padding: 0.55rem 0.25rem 0.1rem;
}
.stage-look {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 12rem;
}
.stage-look .tool-label {
  width: auto;
  margin-right: 0.15rem;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
button.lcd-name {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 750;
  letter-spacing: -0.02em;
  text-align: left;
  padding: 0;
  min-height: 44px;
  cursor: pointer;
}
.lcd-readout {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  color: var(--live);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.7rem;
  margin-bottom: 0.7rem;
}
.dials {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.7rem;
}
.more-btn { width: 100%; margin: 0 0 0.75rem; }
body.is-day .deep,
body:not(.show-more) .deep { display: none; }
.arrive,
.now-line {
  margin: 0 0 0.55rem;
  min-height: 1.4em;
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.cell.arrived {
  box-shadow: inset 0 0 0 3px #f7f1e4;
}
#mute-btn { min-height: 48px; }
.play {
  width: auto;
  height: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 800;
  transition: transform var(--motion-quick) var(--ease);
}
.play:active { transform: scale(0.96); }
.play.is-on {
  background: var(--live);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 72%, transparent);
}
body.is-loop .stage {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
}
body.is-loop #lcd-pos {
  color: var(--text);
}
.play-icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 0 8px 14px;
  border-color: transparent transparent transparent currentColor;
  margin-left: 3px;
}
.play.is-on .play-icon {
  width: 12px;
  height: 12px;
  border: 0;
  background: currentColor;
  border-radius: 1px;
  margin: 0;
}
.stop-icon {
  display: block;
  width: 11px;
  height: 11px;
  background: currentColor;
  border-radius: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-weight: 650;
  font-size: 0.92rem;
  text-decoration: none;
  transition: background var(--motion-quick) var(--ease), transform var(--motion-quick) var(--ease);
}
.btn:active { transform: scale(0.96); }
.btn:focus-visible, .play:focus-visible, .cell:focus-visible, .seg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
}
.btn.ghost {
  background: transparent;
}
.btn.danger { color: var(--danger); }
.btn.xl { min-width: 12rem; font-size: 1.05rem; }
.btn.icon {
  width: 44px;
  padding: 0;
}
.btn[disabled] { opacity: 0.45; }

.dial {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 7rem;
  flex: 1;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dial input[type="range"] {
  width: 100%;
  height: 44px;
  accent-color: var(--accent);
  cursor: pointer;
}

.song-box { margin: 0 0 0.7rem; }
.song-box .tool-row { margin-bottom: 0.45rem; }
.kit-play { margin: 0.2rem 0 0.7rem; }
.pads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.45rem;
}
.pad {
  min-height: 84px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--elevated);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}
.pad.hit { background: var(--accent); color: var(--accent-fg); }
.cell.quiet, .nums.quiet { opacity: 0.28; pointer-events: none; }
.mixer h2 { margin: 0 0 0.2rem; font-size: 1.05rem; letter-spacing: -0.02em; }
.staff-hint { margin: 0 0 0.55rem; color: var(--muted); font-weight: 650; }
.mix { display: flex; flex-direction: column; gap: 0.15rem; }
.mix-row {
  display: grid;
  grid-template-columns: minmax(5.5rem, 1.3fr) auto;
  gap: 0.35rem;
  align-items: center;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
}
.mix-tones { display: flex; gap: 0.3rem; grid-column: 1 / -1; }
.mix-tones .btn { flex: 1; min-height: 44px; }
.mix-row .mix-name,
.mix-row .mix-solo { min-height: 44px; }
.mix-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 44px;
  accent-color: var(--accent);
}
.mix .btn.on { background: var(--accent); color: var(--accent-fg); }
@media (min-width: 760px) {
  .mix-row { grid-template-columns: minmax(6rem, 8rem) auto minmax(14rem, 1fr); }
  .mix-tones { grid-column: auto; }
}

.bank-bar {
  display: none;
  gap: 0.4rem;
  margin: 0 0 0.55rem;
}
.seg {
  flex: 1;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-weight: 650;
}
.seg.on {
  background: var(--elevated);
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

.grid-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  background: var(--panel);
  padding: 0.55rem;
  margin-bottom: 0.85rem;
}
.grid {
  display: grid;
  direction: ltr;
  grid-template-columns: 4.6rem repeat(16, minmax(2.75rem, 1fr));
  gap: 0.28rem;
  min-width: 52rem;
}
.lab {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 44px;
  padding: 0 0.35rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  font-size: 0.78rem;
  text-align: left;
  border-radius: 8px;
}
.lab.muted { color: var(--muted); opacity: 0.45; }
.lab small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.65rem;
}
.nums, .pad {
  min-height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
}
.nums { background: transparent; }
.nums.play { color: var(--text); }
.cell {
  min-height: 44px;
  min-width: 44px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: 8px;
  background: var(--step);
  padding: 0;
  transition: background var(--motion-quick) var(--ease), border-color var(--motion-quick) var(--ease), transform var(--motion-quick) var(--ease);
}
.cell.beat { background: color-mix(in srgb, var(--elevated) 80%, var(--step)); }
.cell.on {
  background: var(--step-on);
  border-color: color-mix(in srgb, var(--step-on) 70%, #fff);
}
.cell.play {
  box-shadow: inset 0 0 0 2px var(--step-play);
}
body.is-loop .cell.play {
  box-shadow: inset 0 0 0 2px var(--step-play), 0 0 8px color-mix(in srgb, var(--accent) 32%, transparent);
}
.cell.on.play {
  background: var(--step-play);
}
.cell:active { transform: scale(0.96); }

.tools {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 0.9rem 1rem;
}
.tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}
.tool-label {
  width: 3.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; flex: 1; }
.chips .btn { min-height: 44px; padding: 0.35rem 0.75rem; }
.chips .btn.on {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
}
.code-look {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
  padding: 0.35rem 0.15rem 0.1rem;
}
.code-look[hidden] { display: none; }
.code-line {
  width: min(22rem, 100%);
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 0 0.7rem;
  font: inherit;
}
.code-note { margin: 0; color: var(--muted); font-size: 0.88rem; }
.code-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.code-group .btn { min-height: 44px; min-width: 44px; }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.modal-actions .btn { flex: 1; min-width: 8rem; }
.tools .hint { margin: 0.65rem 0 0; }
.foot {
  margin: 1.1rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.modal {
  width: min(40rem, calc(100vw - 1.5rem));
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--elevated);
  color: var(--text);
  padding: 1.15rem 1.15rem 1.05rem;
}
.modal::backdrop {
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}
.title-live {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  font-weight: 750;
}
.menu-btn {
  width: auto;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}
.menu-mark { font-size: 1.15rem; line-height: 1; }
.menu-word { line-height: 1; }
.drawer-plate {
  margin: 0 0 0.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.whats-line { margin: 0 0 0.75rem; line-height: 1.4; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
body.menu-open .scrim { display: block; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(22rem, 88vw); background: var(--bg); border-right: 1px solid var(--border);
  z-index: 40; overflow: auto; padding: 0.85rem 0.85rem 2rem; transform: translateX(-105%);
}
body.menu-open .drawer { transform: none; }
.drawer h2 { margin: 0.9rem 0 0.35rem; font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.drawer .chips { display: grid; grid-template-columns: 1fr 1fr; }
.drawer .btn { width: 100%; justify-content: flex-start; }
input[type="range"] { width: 100%; accent-color: var(--accent, #22d3ee); }
.drawer .chips .btn, .drawer .chips button { margin-top: 0; }
.lesson { padding: 0.65rem 0.75rem; }
.lesson-body { display: block; overflow: visible; }
.title-build .title-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.4rem;
  align-items: center;
  margin: 0.35rem 0;
}
.title-build .title-row select {
  min-height: 44px; width: 100%; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit;
}
.title-build .title-row > span { min-width: 4.4rem; font-weight: 750; }
.title-build .btn.on {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
}
.modal h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 750;
}
.desc {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.modal input, .modal select {
  width: 100%;
  height: 2.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 0 0.9rem;
  font: inherit;
  margin-bottom: 0.7rem;
}
.saved-list {
  list-style: none;
  margin: 0 0 0.8rem;
  padding: 0;
  max-height: 14rem;
  overflow: auto;
}
.saved-list li {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 0.4rem;
}
.saved-list button { flex: 1; }
.modal textarea {
  width: 100%;
  min-height: 4.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.4;
  resize: vertical;
  margin-bottom: 0.55rem;
}
.foot a, .foot .link {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}
.foot .link {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 44px;
  font-weight: 650;
}
.foot a:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .stage-canvas { height: min(32vh, 220px); min-height: 168px; }
  .bank-bar { display: flex; }
  .grid {
    min-width: 0;
    grid-template-columns: 4.4rem repeat(8, minmax(44px, 1fr));
  }
  .grid.is-b1 .bank0 { display: none; }
  .grid.is-b0 .bank1 { display: none; }
  .play, #mute-btn, #stop-btn { min-width: 44px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .play, .cell { transition: none; }
  .btn:active, .play:active, .cell:active { transform: none; }
}

/* BZ 1.10.1 — the Hub bar is the only Menu. The app button stays for classic. */
html[data-kb-bar] #menu-btn.menu-btn { display: none !important; }
html[dir="rtl"] .top { direction: ltr; }
html[dir="rtl"] .grid,
html[dir="rtl"] .grid-wrap,
.grid-wrap { direction: ltr; }
#stop-btn {
  width: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.85rem;
  gap: 0.4rem;
}
html[dir="rtl"] .drawer {
  left: 0 !important;
  right: auto !important;
  transform: translateX(-105%);
}
html[dir="rtl"] body.menu-open .drawer { transform: none !important; }
