:root {
  color-scheme: light;
  --paper: #faf4ef;
  --ink: #151515;
  --accent: #2f5fa8;
  --accent-deep: #173f86;
  --accent-light: #4778c4;
  --orange: var(--accent);
  --line: #a9a9a4;
  --panel: min(100vw, 1506px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
}

body {
  display: grid;
  justify-items: center;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.radio-board {
  position: relative;
  width: var(--panel);
  aspect-ratio: 1506 / 900;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
}

.art-layer {
  position: absolute;
  display: block;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.text-art {
  left: 1.9%;
  top: 0.2%;
  width: 46.9%;
}

.cat-art {
  right: 0.6%;
  top: 0.5%;
  width: 50.8%;
}

.waveform {
  position: absolute;
  left: 3.3%;
  right: 3.7%;
  top: 51.8%;
  height: 14.8%;
  display: flex;
  align-items: flex-end;
  gap: 0.18%;
  pointer-events: none;
}

.bar {
  flex: 1 1 0;
  min-width: 2px;
  height: calc(var(--h) * 1%);
  background: linear-gradient(to top, var(--ink) 0 var(--black-stop, 52%), var(--accent) var(--black-stop, 52%) 100%);
  transition: height 70ms linear;
}

.player {
  position: absolute;
  inset: 0;
}

.track-row {
  position: absolute;
  left: 3.3%;
  top: 69.8%;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: clamp(15px, calc(var(--panel) * 0.018), 27px);
  white-space: nowrap;
}

.note {
  color: var(--accent);
  font-size: 1.35em;
  line-height: 1;
}

.timeline {
  position: absolute;
  left: 3.3%;
  right: 3.3%;
  top: 75.6%;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  font-weight: 700;
  font-size: clamp(15px, calc(var(--panel) * 0.0165), 24px);
}

.progress {
  position: relative;
  width: 100%;
  height: 30px;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.progress::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0 var(--progress, 0%),
    #b9b9b5 var(--progress, 0%) 100%
  );
  transform: translateY(-50%);
}

.progress:focus-visible {
  outline: none;
}

.progress:focus-visible .progress-thumb {
  outline: 3px solid rgb(47 95 168 / 0.34);
  outline-offset: 4px;
}

.progress-thumb {
  position: absolute;
  left: var(--progress, 0%);
  top: 50%;
  width: 26px;
  height: 26px;
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 6px var(--accent);
  transform: translate(-50%, -50%) scale(1);
  transition: transform 120ms ease, box-shadow 120ms ease;
  cursor: grab;
}

.progress:active .progress-thumb,
.progress.is-scrubbing .progress-thumb {
  transform: translate(-50%, -50%) scale(1.18);
  cursor: grabbing;
}

.controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.transport {
  position: absolute;
  left: 12%;
  top: 81.8%;
  display: flex;
  justify-content: center;
  gap: clamp(24px, calc(var(--panel) * 0.04), 58px);
  pointer-events: auto;
}

.control-button {
  display: grid;
  place-items: center;
  width: clamp(96px, calc(var(--panel) * 0.09), 150px);
  height: clamp(58px, calc(var(--panel) * 0.054), 82px);
  border: 2px solid #747876;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.7) inset;
  transform: scale(1);
  transition: transform 120ms ease, border-color 120ms ease, filter 120ms ease;
}

.control-button:hover {
  transform: scale(1.025);
  border-color: #274979;
}

.control-button:active {
  transform: scale(0.96);
  filter: saturate(1.08);
}

.control-button.primary {
  border-color: #24416d;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-deep));
}

.control-button svg {
  width: 42%;
  height: 42%;
  fill: currentColor;
}

.actions {
  position: absolute;
  right: 3.8%;
  top: 83.2%;
  display: flex;
  justify-content: flex-end;
  gap: clamp(22px, calc(var(--panel) * 0.028), 42px);
  pointer-events: auto;
}

.action-button {
  height: clamp(44px, calc(var(--panel) * 0.044), 60px);
  padding: 0 26px;
  border: 2px solid currentColor;
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
  font-size: clamp(13px, calc(var(--panel) * 0.015), 22px);
  letter-spacing: 0;
  white-space: nowrap;
  transform: scale(1);
  transition: transform 120ms ease, color 120ms ease, border-color 120ms ease;
}

.action-button:hover {
  transform: scale(1.02);
}

.action-button:active {
  transform: scale(0.97);
}

.action-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper);
  box-shadow: 0 0 0 5px rgb(47 95 168 / 0.16);
}

.action-button.secondary {
  color: var(--ink);
  border-color: #777b78;
}

.action-button.secondary[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 0 0 5px rgb(21 21 21 / 0.12);
}

.icon-button {
  display: grid;
  place-items: center;
  width: clamp(46px, calc(var(--panel) * 0.044), 60px);
  height: clamp(44px, calc(var(--panel) * 0.044), 60px);
  border: 2px solid #777b78;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transform: scale(1);
  transition: transform 120ms ease, color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.icon-button svg {
  width: 58%;
  height: 58%;
  fill: currentColor;
}

.icon-button:hover {
  transform: scale(1.04);
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button:active {
  transform: scale(0.94);
}

.icon-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper);
  box-shadow: 0 0 0 5px rgb(47 95 168 / 0.16);
}

.bpm {
  position: absolute;
  left: 3.3%;
  right: 3.3%;
  top: 93.6%;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 22px;
  font-weight: 800;
  font-size: clamp(13px, calc(var(--panel) * 0.015), 22px);
  pointer-events: auto;
}

.bpm-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    #b9b9b5 0 var(--low, 0%),
    var(--accent) var(--low, 0%) var(--high, 100%),
    #b9b9b5 var(--high, 100%) 100%
  );
}

.bpm-handle {
  position: absolute;
  top: 50%;
  width: 30px;
  height: 30px;
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: var(--paper);
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.bpm-handle:active,
.bpm-handle.is-dragging {
  transform: translate(-50%, -50%) scale(1.16);
  cursor: grabbing;
  box-shadow: 0 0 0 8px rgb(47 95 168 / 0.14);
}

.bpm-handle:focus-visible {
  outline: 3px solid rgb(47 95 168 / 0.34);
  outline-offset: 4px;
}

.bpm-handle::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: inherit;
  background: var(--accent);
}

.bpm-handle::before {
  content: attr(data-value);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  min-width: 34px;
  padding: 3px 7px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  line-height: 1;
  text-align: center;
  transform: translateX(-50%) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.bpm-handle:hover::before,
.bpm-handle:focus-visible::before,
.bpm-handle.is-dragging::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.bpm-handle.low {
  left: 18%;
}

.bpm-handle.high {
  left: 74%;
}

.audio-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 760px) {
  :root {
    --panel: 100vw;
  }

  body {
    overflow-x: hidden;
  }

  .radio-board {
    width: 100vw;
    min-height: 100svh;
    aspect-ratio: auto;
    overflow: visible;
    padding: 18px 16px 30px;
  }

  .art-layer,
  .waveform,
  .player {
    position: static;
  }

  .track-row,
  .timeline,
  .controls,
  .transport,
  .actions,
  .bpm {
    position: static;
  }

  .text-art,
  .cat-art {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
  }

  .text-art {
    margin-bottom: 18px;
  }

  .cat-art {
    margin-top: 8px;
  }

  .waveform {
    height: 130px;
    margin: 8px 0 24px;
    gap: 2px;
  }

  .track-row {
    white-space: normal;
    line-height: 1.25;
  }

  .timeline {
    grid-template-columns: auto 1fr auto;
    gap: 26px;
    margin-bottom: 34px;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    pointer-events: auto;
  }

  .transport {
    order: 1;
    gap: 20px;
  }

  .actions {
    order: 2;
    justify-content: stretch;
    gap: 14px;
  }

  .icon-button {
    flex: 0 0 auto;
  }

  .action-button {
    flex: 1 1 0;
    padding: 0 10px;
  }

  .bpm {
    order: 3;
    grid-template-columns: auto auto 1fr auto;
    gap: 24px;
    margin-top: 2px;
  }

  .bpm-track {
    margin-inline: 6px;
  }
}
