*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, -apple-system, sans-serif;
  background: #0a0a0a;
  color: #fafafa;
  overflow: hidden;
}

#app {
  width: min(98vw, 960px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

#title-block {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

#title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #ffffff;
}

#bpm-display {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.5);
  min-width: 64px;
}

#controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ctrl-btn {
  font-family: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  padding: 7px 18px;
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.ctrl-btn:hover { background: rgba(255,255,255,0.08); }
.ctrl-btn.active { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.5); }
.ctrl-btn.secondary { color: rgba(255,255,255,0.5); border-color: rgba(255,255,255,0.12); }

#bpm-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#bpm-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

#grid-container {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

#track-labels {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: space-around;
}

.track-label {
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.5);
  text-align: right;
  padding-right: 4px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 46px;
}

#grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
  flex: 1;
}

.cell {
  height: 36px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.1s;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.04);
  position: relative;
  overflow: hidden;
}

.cell:hover { transform: scale(1.06); }

.cell.on {
  border-color: transparent;
}

.cell.active-step::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.25);
  border-radius: inherit;
}

/* Beat group separators every 4 steps */
.cell.beat-start { margin-left: 6px; }

#playhead-row {
  padding-left: 54px; /* align with grid */
}

#beat-indicators {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
}

.beat-dot {
  height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.1);
  transition: background 0.05s, box-shadow 0.05s;
}

.beat-dot.active {
  background: #ffffff;
  box-shadow: 0 0 8px #ffffff;
}

/* Track color themes */
.track-0  .cell.on { background: #ff3355; box-shadow: 0 0 10px #ff3355aa; }
.track-1  .cell.on { background: #ff7722; box-shadow: 0 0 10px #ff7722aa; }
.track-2  .cell.on { background: #ffcc00; box-shadow: 0 0 10px #ffcc00aa; }
.track-3  .cell.on { background: #44ff88; box-shadow: 0 0 10px #44ff88aa; }
.track-4  .cell.on { background: #00ddff; box-shadow: 0 0 10px #00ddffaa; }
.track-5  .cell.on { background: #4466ff; box-shadow: 0 0 10px #4466ffaa; }
.track-6  .cell.on { background: #cc44ff; box-shadow: 0 0 10px #cc44ffaa; }
.track-7  .cell.on { background: #ff44aa; box-shadow: 0 0 10px #ff44aaaa; }

@media (max-width: 600px) {
  .cell { height: 28px; }
  .track-label { height: 28px; font-size: 0.5rem; }
  #bpm-slider { width: 80px; }
}
