:root {
  --ink: #171b26;
  --muted: #667083;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(38, 44, 60, 0.14);
  --coral: #ff6458;
  --teal: #16b6a1;
  --gold: #f4b940;
  --plum: #8e5cf4;
  --shadow: 0 26px 72px rgba(30, 35, 48, 0.22);
  --ring-angle: 0deg;
  --pulse-scale: 1;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(22, 182, 161, 0.92), rgba(244, 185, 64, 0.72) 38%, rgba(255, 100, 88, 0.86)),
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, 0.82), transparent 24%),
    #f7f8fc;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  border: 0;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.switch input:focus-visible + span {
  outline: 3px solid rgba(23, 27, 38, 0.24);
  outline-offset: 3px;
}

.metronome {
  width: min(100%, 390px);
  display: grid;
  gap: 21px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 249, 252, 0.88)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar,
.action-row,
.option-row,
.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  align-items: flex-start;
}

.eyebrow {
  margin: 0 0 5px;
  color: #087e71;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 12ch;
  font-size: 27px;
  line-height: 1.04;
}

.tempo-pill {
  min-width: 86px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(22, 182, 161, 0.14);
}

body.is-running .status-dot {
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(255, 100, 88, 0.18);
}

.tempo-face {
  display: grid;
  justify-items: center;
  gap: 17px;
  padding: 3px 0 0;
}

.pulse-ring {
  position: relative;
  width: min(70vw, 250px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(from -90deg, var(--coral) 0 var(--ring-angle), rgba(38, 44, 60, 0.1) var(--ring-angle) 360deg),
    linear-gradient(135deg, var(--teal), var(--gold) 48%, var(--coral));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.62),
    0 20px 44px rgba(255, 100, 88, 0.2);
  transform: scale(var(--pulse-scale));
  transition: transform 90ms ease-out, box-shadow 120ms ease;
}

.pulse-ring::before {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from -1deg, rgba(255, 255, 255, 0.92) 0 1deg, transparent 1deg 15deg),
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.34));
  opacity: 0.7;
  mask: radial-gradient(circle, transparent 0 67%, #000 68% 100%);
  -webkit-mask: radial-gradient(circle, transparent 0 67%, #000 68% 100%);
}

.pulse-core {
  position: relative;
  z-index: 1;
  width: 71%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border: 1px solid rgba(38, 44, 60, 0.12);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 34%, #ffffff 0 35%, #f7f9fc 72%, #e9eef6 100%);
  box-shadow: inset 0 -16px 28px rgba(31, 37, 51, 0.1);
}

#bpmReadout {
  display: block;
  min-width: 132px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 66px;
  font-weight: 900;
  line-height: 0.94;
}

.pulse-core span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.beat-row {
  width: min(100%, 214px);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
}

.beat-dot {
  height: 9px;
  border-radius: 999px;
  background: rgba(38, 44, 60, 0.13);
  transition: background 120ms ease, transform 120ms ease;
}

.beat-dot.is-current {
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral));
  transform: translateY(-2px);
}

.controls {
  display: grid;
  gap: 15px;
}

.range-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

#tempoHint {
  color: var(--ink);
}

.tempo-range {
  width: 100%;
  height: 30px;
  margin: 0;
  accent-color: var(--coral);
}

.nudge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.nudge-grid button,
.secondary-button,
.primary-button,
.select-label select {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 850;
}

.nudge-grid button,
.secondary-button,
.select-label select {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
}

.primary-button {
  flex: 1;
  min-width: 0;
  background: linear-gradient(135deg, var(--teal), var(--gold) 48%, var(--coral));
  color: #111722;
  box-shadow: 0 12px 26px rgba(255, 100, 88, 0.22);
}

.secondary-button {
  flex: 0 0 102px;
}

.option-row {
  align-items: stretch;
}

.select-label {
  min-width: 120px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.select-label select {
  width: 100%;
  padding: 0 12px;
  appearance: none;
}

.switch {
  min-width: 126px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 820;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  width: 48px;
  height: 28px;
  position: relative;
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(38, 44, 60, 0.13);
  transition: background 140ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 9px rgba(23, 27, 38, 0.2);
  transition: transform 140ms ease;
}

.switch input:checked + span {
  background: linear-gradient(135deg, var(--teal), var(--coral));
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.switch em {
  font-style: normal;
}

@media (max-width: 380px) {
  body {
    padding: 14px;
  }

  .metronome {
    padding: 18px;
  }

  h1 {
    font-size: 24px;
  }

  .tempo-pill {
    min-width: 78px;
    padding: 0 9px;
  }

  #bpmReadout {
    font-size: 56px;
  }

  .secondary-button {
    flex-basis: 88px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
