:root {
  --bg:         #e8e8e6;
  --surface:    #f3f3f3;
  --text:       #000;
  --text-muted: #4a4a4a;
  --accent:     #ff3a00;
  --dark:       #050505;
  --dark-soft:  #222;
  --step-off:   #cbcbcb;
  --pill-bg:    #d9d9d9;
  --preset-bg:  #e8e8e6;
  --radius-card: 20px;
  --radius-pill: 140px;
  --radius-pad:  16px;
  --font:       'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  padding: 29px 32px 32px;
}

/* ── Logo ───────────────────────────────────────────────────────────────────── */

.logo {
  font-size: 26px;
  font-weight: 300;
  letter-spacing: 1.82px;
  margin-bottom: 20px;
  padding-left: 16px;
}

/* ── Main layout ────────────────────────────────────────────────────────────── */

main {
  display: flex;
  gap: 38px;
  align-items: flex-start;
}

.col-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 269px;
  flex-shrink: 0;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 20px;
}

/* ── Metronome panel ────────────────────────────────────────────────────────── */

#panel-metro {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.metro-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.label-md {
  font-size: 16px;
  font-weight: 500;
}

.bpm-num {
  font-size: 72px;
  font-weight: 300;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ── BPM controls ───────────────────────────────────────────────────────────── */

.bpm-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.btn-round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--dark);
  color: #fff;
  font-size: 32px;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: opacity 0.15s;
}

.btn-round:hover { opacity: 0.8; }
.btn-round:active { opacity: 0.6; }

.slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}

#bpm-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--dark);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#bpm-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--dark);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 2px var(--dark);
}

#bpm-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--dark);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 2px var(--dark);
}

/* ── Takt pills ─────────────────────────────────────────────────────────────── */

.takt-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 300;
  color: var(--text-muted);
  background: var(--pill-bg);
  border: none;
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.pill:hover {
  background: var(--step-off);
}

.pill.active {
  background: var(--dark);
  color: #fff;
}

/* ── Accent toggle ──────────────────────────────────────────────────────────── */

.accent-row {
  display: flex;
  align-items: center;
  gap: 25px;
}

.toggle-switch {
  width: 58px;
  height: 29px;
  border-radius: 15px;
  background: var(--step-off);
  border: none;
  cursor: pointer;
  position: relative;
  padding: 3px;
  display: flex;
  align-items: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-knob {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  display: block;
  transition: transform 0.2s;
}

.toggle-switch.on {
  background: var(--dark-soft);
}

.toggle-switch.on .toggle-knob {
  transform: translateX(29px);
}

/* ── Play buttons ───────────────────────────────────────────────────────────── */

.btn-play-dark,
.btn-play-accent {
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  border-radius: 30px;
  height: 44px;
}

.btn-play-dark {
  width: 100%;
  background: var(--dark-soft);
  color: #fff;
}

.btn-play-accent {
  width: 87px;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}

.btn-play-dark:hover,
.btn-play-accent:hover { opacity: 0.85; }

.btn-play-dark:active,
.btn-play-accent:active { opacity: 0.7; }

.icon-stop { display: none; }
.running .icon-play { display: none; }
.running .icon-stop { display: block; }

/* ── Beat bars ──────────────────────────────────────────────────────────────── */

.beat-bars {
  display: flex;
  gap: 8px;
  height: 180px;
  width: fit-content;
}

.beat-bar {
  width: 46px;
  height: 100%;
  border-radius: var(--radius-card);
  background: var(--step-off);
  transition: background 0.05s;
}

.beat-bar.active {
  background: var(--dark-soft);
}

/* ── Sequencer panel ────────────────────────────────────────────────────────── */

#panel-seq {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 41px;
  min-width: 0;
}

.preset-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.preset-label {
  flex-shrink: 0;
}

.preset-center {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.preset-right {
  display: flex;
  gap: 16px;
  align-items: center;
}

.btn-preset {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  background: var(--preset-bg);
  border: none;
  border-radius: 30px;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}

.btn-preset:hover {
  background: var(--step-off);
}

.btn-preset:active {
  background: var(--dark);
  color: #fff;
}

/* ── Sequencer grid ─────────────────────────────────────────────────────────── */

.seq-area {
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#seq-grid {
  display: grid;
  grid-template-columns:
    50px
    repeat(4, 28px) 16px
    repeat(4, 28px) 16px
    repeat(4, 28px) 16px
    repeat(4, 28px);
  column-gap: 12px;
  row-gap: 20px;
  align-items: center;
}

.seq-label {
  font-size: 16px;
  font-weight: 400;
  font-family: var(--font);
  text-align: right;
  white-space: nowrap;
  color: var(--text);
}

.seq-step {
  width: 28px;
  height: 50px;
  border-radius: var(--radius-pad);
  background: var(--step-off);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.08s, box-shadow 0.08s;
}

.seq-step:hover {
  background: #b8b8b8;
}

.seq-step.on {
  background: var(--accent);
}

.seq-step.on:hover {
  background: #e03300;
}

.seq-step.playing {
  box-shadow: 0 0 0 2px var(--dark);
}

.seq-step.on.playing {
  background: #ff6633;
  box-shadow: 0 0 0 2px var(--accent);
}

.seq-spacer {
  /* occupies the 16px gap column */
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  main {
    flex-direction: column;
    gap: 20px;
  }

  .col-left {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  #panel-metro {
    flex: 1;
    min-width: 240px;
  }

  .beat-bars {
    height: 140px;
  }

  #panel-seq {
    width: 100%;
  }
}

@media (max-width: 600px) {
  body {
    padding: 16px;
  }

  .logo {
    font-size: 20px;
    padding-left: 0;
  }

  .bpm-num {
    font-size: 56px;
  }

  .col-left {
    flex-direction: column;
  }

  .beat-bars {
    height: 100px;
    width: 100%;
  }

  .beat-bar {
    flex: 1;
    width: auto;
  }

  .preset-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  #seq-grid {
    grid-template-columns:
      40px
      repeat(4, 24px) 10px
      repeat(4, 24px) 10px
      repeat(4, 24px) 10px
      repeat(4, 24px);
    column-gap: 6px;
    row-gap: 12px;
  }

  .seq-step {
    width: 24px;
    height: 40px;
    border-radius: 12px;
  }

  .seq-label {
    font-size: 12px;
  }
}
