/* cybelong.com/tools/drum-machine/ · Developer: Cybelong · https://cybelong.com · © 2026 Cybelong */
.bm { --cell: var(--bg); --on: var(--ink); --r: 8px; user-select: none; -webkit-user-select: none; }
.bm button { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); min-height: 44px; padding: 0 12px; cursor: pointer; transition: background .15s, border-color .15s; }
.bm button:hover { border-color: color-mix(in srgb, var(--muted) 70%, var(--line)); }
.bm button:focus-visible, .bm select:focus-visible, .bm input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bm select, .bm input[type=number] { min-height: 44px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; }
.bm input[type=range] { width: 100%; accent-color: var(--ink); min-height: 32px; }
.bm-f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bm-f > span { font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.bm-f > span b { color: var(--ink); font-weight: 600; text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.bm-transport, .bm-bar { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; background: var(--surface); border: 1px solid var(--line); padding: 16px; }
.bm-transport { border-radius: 16px 16px 0 0; }
.bm-bar { border-top: 0; padding-top: 12px; gap: 12px 16px; }
.bm-play { min-width: 112px; min-height: 56px !important; font-size: 1.05rem !important; font-weight: 700; background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; border-radius: 12px !important; }
.bm-play.on { background: var(--ink) !important; border-color: var(--ink) !important; color: var(--bg) !important; }
.bm-bpm { display: flex; gap: 4px; }
.bm-bpm input { width: 76px; text-align: center; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.bm-bpm button { width: 44px; padding: 0; }
.bm-bpm #bm-tap { width: auto; padding: 0 12px; }
.bm-sw { flex: 1 1 160px; max-width: 240px; }
.bm-seg { display: flex; }
.bm-seg button { border-radius: 0; margin-left: -1px; min-width: 44px; font-weight: 600; }
.bm-seg button:first-child { border-radius: var(--r) 0 0 var(--r); margin-left: 0; }
.bm-seg button:last-child { border-radius: 0 var(--r) var(--r) 0; }
.bm-seg button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); position: relative; }
.bm-seg button.has:not(.on) { box-shadow: inset 0 -3px 0 var(--muted); }
.bm-chk { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: .92rem; color: var(--ink); cursor: pointer; }
.bm-chk input { width: 18px; height: 18px; accent-color: var(--accent); }
.bm-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.bm-bar .bm-acts { margin-left: auto; }

.bm-gridwrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 16px 16px; padding: 12px 16px 16px 0; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.bm-grid { display: grid; grid-template-columns: 184px 1fr; row-gap: 6px; min-width: calc(184px + var(--n) * 34px); }
.bm-head { position: sticky; left: 0; z-index: 2; display: flex; align-items: center; gap: 4px; padding: 0 8px 0 16px; background: var(--surface); }
.bm-name { flex: 1; min-width: 0; text-align: left; border-color: transparent !important; background: transparent !important; font-size: .9rem; font-weight: 600; padding: 0 6px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-name .short { display: none; }
.bm-head.sel .bm-name { box-shadow: inset 3px 0 0 var(--accent); }
.bm-ms { display: flex; gap: 2px; }
.bm-ms button { width: 28px; min-height: 28px !important; height: 28px; padding: 0; font-size: .72rem; font-weight: 700; border-radius: 6px; color: var(--muted); }
.bm-m.on { background: #E5484D !important; border-color: #E5484D !important; color: #fff !important; }
.bm-s.on { background: #F5A524 !important; border-color: #F5A524 !important; color: #111 !important; }
.bm-cells { display: grid; grid-template-columns: repeat(var(--n), minmax(30px, 1fr)); gap: 4px; }
.bm-cell { min-height: 44px !important; padding: 0 !important; border-radius: 6px !important; background: var(--cell) !important; position: relative; overflow: hidden; }
.bm-cell.odd { background: color-mix(in srgb, var(--line) 45%, var(--bg)) !important; }
.bm-cell.beat:not(:first-child) { margin-left: 6px; }
.bm-cell.on { border-color: var(--on) !important; }
.bm-cell.on::after { content: ""; position: absolute; inset: 0; background: var(--on); opacity: calc(.35 + var(--v) * .65); }
.bm-cell.now { box-shadow: 0 0 0 2px var(--accent); }
.bm-cell.now.on::after { background: var(--accent); opacity: 1; }

.bm-lower { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 16px; }
.bm-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.bm-card h3 { margin: 0; font-size: 1rem; color: var(--ink); font-weight: 600; }
.bm-card h3 b { color: var(--accent); }
.bm-knobs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.bm-meter { height: 12px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.bm-meter i { display: block; height: 100%; width: 0; background: #30A46C; transition: width .06s linear; }
.bm-meter i.hot { background: #E5484D; }
.bm-peak { font-size: .85rem; font-variant-numeric: tabular-nums; margin-top: -6px; }
.bm-main { background: var(--ink) !important; color: var(--bg) !important; border-color: var(--ink) !important; font-weight: 600; }
.bm-msg { min-height: 1.2em; font-size: .88rem; word-break: break-all; }
@media (max-width: 900px) { .bm-lower { grid-template-columns: 1fr 1fr; } .bm-lower > :first-child { grid-column: 1 / -1; } }
@media (max-width: 640px) {
  .bm-transport, .bm-bar { padding: 12px; gap: 12px; }
  .bm-play { flex: 1 1 100%; }
  .bm-sw { max-width: none; }
  .bm-bar .bm-acts { margin-left: 0; }
  .bm-grid { grid-template-columns: 128px 1fr; min-width: calc(128px + var(--n) * 34px); }
  .bm-name .full { display: none; } .bm-name .short { display: inline; }
  .bm-ms button { width: 26px; }
  .bm-head { padding: 0 4px 0 8px; }
  .bm-name { padding: 0 2px !important; font-size: .84rem; }
  .bm-lower { grid-template-columns: 1fr; }
  .bm-knobs { grid-template-columns: 1fr; }
}
