:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-strong: #eef2f1;
  --border: #d9dfdc;
  --text: #18201d;
  --muted: #63706a;
  --accent: #197a56;
  --accent-strong: #126242;
  --accent-soft: #d9efe6;
  --warning: #ce7a21;
  --info: #4776b8;
  --danger: #ba2d36;
  --shadow: 0 16px 40px rgb(20 31 28 / 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, #f6f7f8 0%, #edf1ef 100%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 18px;
}

.tempo-workspace {
  display: grid;
  gap: 16px;
}

.app-header {
  padding-top: 4px;
}

h2,
p {
  margin: 0;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.mode-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.mode-button {
  min-width: 0;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}

.mode-button.is-selected {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 2px 8px rgb(28 39 35 / 0.12);
}

.tempo-readout {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 10px 0 2px;
}

.tempo-caption {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
  text-transform: uppercase;
}

.tempo-display {
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.6rem, 3.2rem + 3vw, 5.2rem);
  font-weight: 850;
  line-height: 1;
}

.tool-panel {
  display: grid;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.timing-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.timing-stats span {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fbfcfc;
  white-space: nowrap;
}

.timing-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.preset-button {
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: #f8faf9;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.preset-button.is-selected {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.slider-field {
  display: grid;
  gap: 8px;
}

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

.slider-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.play-button {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 66px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 14px 28px rgb(18 98 66 / 0.24);
  font-size: 1.35rem;
  font-weight: 850;
}

.play-button:hover {
  background: var(--accent-strong);
}

.play-button.is-playing {
  background: var(--danger);
  box-shadow: 0 14px 28px rgb(186 45 54 / 0.18);
}

.play-glyph {
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 15px solid currentColor;
}

.stop-glyph {
  width: 17px;
  height: 17px;
  border-radius: 3px;
  background: currentColor;
}

.audio-message {
  min-height: 1.15rem;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.beat-panel {
  gap: 16px;
}

.beat-dots {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.beat-dot {
  display: inline-block;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  position: relative;
}

.beat-dot::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: var(--dot-size);
  height: var(--dot-size);
  border-radius: 999px;
  background: var(--dot-color);
  opacity: 0.36;
  transform: translate(-50%, -50%);
  transition:
    width 160ms ease,
    height 160ms ease,
    opacity 160ms ease,
    box-shadow 160ms ease;
}

.beat-dot-normal {
  --dot-size: 12px;
  --dot-color: var(--muted);
}

.beat-dot-medium {
  --dot-size: 15px;
  --dot-color: var(--warning);
}

.beat-dot-strong {
  --dot-size: 18px;
  --dot-color: var(--accent);
}

.beat-dot.is-active::before {
  width: calc(var(--dot-size) + 8px);
  height: calc(var(--dot-size) + 8px);
  opacity: 1;
  box-shadow: 0 0 0 4px rgb(24 32 29 / 0.1);
}

.options-panel {
  gap: 16px;
}

.options-panel summary {
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
}

.select-field {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  font-weight: 750;
}

select {
  min-width: min(100%, 210px);
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: #fbfcfc;
  padding: 0 36px 0 12px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(71 118 184 / 0.35);
  outline-offset: 3px;
}

@media (min-width: 680px) {
  .app-shell {
    display: grid;
    align-items: center;
    padding-block: 28px;
  }

}

@media (max-width: 390px) {
  .app-shell {
    padding-inline: 12px;
  }

  .tool-panel {
    padding: 14px;
  }

  .panel-header,
  .select-field {
    align-items: stretch;
    flex-direction: column;
  }

  .timing-stats {
    justify-content: flex-start;
  }

  select {
    width: 100%;
  }
}

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