:root {
  color-scheme: dark;
  --bg: #101419;
  --panel: #182028;
  --panel-strong: #202b34;
  --text: #f6f2e8;
  --muted: #aab7be;
  --line: #31404a;
  --accent: #d5729f;
  --accent-strong: #e783af;
  --mint: #69d5b1;
  --red: #c95f90;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    linear-gradient(135deg, rgba(213, 114, 159, 0.15), transparent 34%),
    linear-gradient(315deg, rgba(231, 131, 175, 0.13), transparent 32%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  align-content: start;
}

.tempo-panel,
.controls {
  border: 1px solid rgba(246, 242, 232, 0.08);
  background: rgba(24, 32, 40, 0.88);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  border-radius: 8px;
}

.tempo-panel {
  padding: 14px;
}

.controls {
  padding: 12px;
}

.topbar {
  min-height: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
}

.pulse-wrap {
  padding: 4px 0 20px;
  display: grid;
  justify-items: center;
}

.pulse {
  width: 100%;
  min-height: 120px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #15120a;
  font-size: 4rem;
  font-weight: 900;
  transition: opacity 30ms ease, background-color 30ms ease, box-shadow 30ms ease;
}

.pulse.hit {
  opacity: 0.85;
}

.pulse.accent {
  background: #ffcce0;
  box-shadow: 0 0 40px rgba(255, 204, 224, 0.6);
  opacity: 1;
}

.pulse.subtle {
  background: var(--red);
}

.tempo-readout {
  display: grid;
  grid-template-columns: 64px minmax(116px, 1fr) 64px;
  justify-items: center;
  align-content: center;
  align-items: start;
  gap: 12px;
  color: rgba(21, 18, 10, 0.74);
  font-weight: 700;
}

.tempo-field {
  width: 132px;
  min-height: 64px;
  padding: 0;
  display: grid;
  justify-items: center;
  align-content: start;
}

.tempo-field input {
  width: 100%;
  min-height: 64px;
  border: 2px solid rgba(21, 18, 10, 0.38);
  background: rgba(255, 235, 244, 0.46);
  color: #15120a;
  text-align: center;
  font-size: 2.75rem;
  font-weight: 900;
  line-height: 0.95;
  border-radius: 8px;
  padding: 0 6px;
  appearance: textfield;
}

.tempo-field input::-webkit-outer-spin-button,
.tempo-field input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.tempo-nudge {
  width: 68px;
  min-height: 62px;
  border-color: rgba(21, 18, 10, 0.32);
  background: rgba(21, 18, 10, 0.12);
  color: #15120a;
  font-size: 1.5rem;
  line-height: 1;
  border: 0;
  display: grid;
  align-self: start;
  align-items: center;
  border-radius: 8px;
}

#tempo-circle-down {
  position: relative;
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M80,10 C88,5 92,10 92,20 L92,80 C92,90 88,95 80,90 L20,56 C12,51 12,49 20,44 Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M80,10 C88,5 92,10 92,20 L92,80 C92,90 88,95 80,90 L20,56 C12,51 12,49 20,44 Z'/%3E%3C/svg%3E");
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

#tempo-circle-down::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 38%;
  transform: translate(50%, -50%);
  width: 0.62em;
  height: 0.12em;
  background: currentColor;
  border-radius: 1px;
}

#tempo-circle-up {
  justify-items: start;
  padding-left: 14px;
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M20,10 C12,5 8,10 8,20 L8,80 C8,90 12,95 20,90 L80,56 C88,51 88,49 80,44 Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M20,10 C12,5 8,10 8,20 L8,80 C8,90 12,95 20,90 L80,56 C88,51 88,49 80,44 Z'/%3E%3C/svg%3E");
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

.range-label {
  display: grid;
  grid-template-columns: 32px 1fr 36px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.transport {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 10px;
  margin-top: 20px;
}

button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-strong);
  font-weight: 800;
  touch-action: manipulation;
}

.primary-button {
  background: var(--accent-strong);
  color: #17140b;
}

.primary-button.playing {
  background: var(--red);
  color: #160d0b;
}

.secondary-button {
  border-color: var(--line);
}

.control-row {
  display: grid;
  gap: 10px;
  align-items: end;
}

.stepper {
  grid-template-columns: 62px 1fr 62px;
}

.stepper button {
  min-height: 52px;
  font-size: 1.65rem;
}

#tempo-down {
  padding-bottom: 0.12em;
}

label span,
legend {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.stepper input,
.stepper select,
.select-field select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111820;
  color: var(--text);
  padding: 0 12px;
  text-align: center;
  font-weight: 900;
}

.select-field {
  display: block;
  margin-top: 10px;
}

.select-field select {
  text-align: left;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset + fieldset {
  margin-top: 10px;
}

.segmented {
  display: grid;
  gap: 8px;
}

.meter-grid {
  grid-template-columns: repeat(6, 1fr);
}

.subdivision-grid {
  grid-template-columns: repeat(4, 1fr);
}

.segmented button {
  min-height: 44px;
  border-color: var(--line);
  color: var(--muted);
}

.subdivision-grid button {
  font-size: 1.55rem;
  line-height: 1;
}

.note-icon {
  height: 28px;
  width: auto;
  max-width: 100%;
  display: block;
  margin: 0 auto;
  fill: currentColor;
}

.note-icon path,
.note-icon rect,
.note-icon ellipse,
.note-icon text {
  fill: currentColor;
}

.segmented button.active {
  border-color: transparent;
  background: var(--mint);
  color: #071711;
}

@media (max-width: 360px) {
  .app {
    padding-inline: 10px;
  }

  .pulse {
    min-height: 120px;
  }

  .tempo-field input {
    font-size: 2.65rem;
  }

  .tempo-readout {
    grid-template-columns: 56px minmax(104px, 1fr) 56px;
    gap: 12px;
  }

  .tempo-field {
    width: 124px;
    min-height: 64px;
  }

  .tempo-nudge {
    width: 72px;
    min-height: 64px;
  }

  .meter-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
