:root {
  color-scheme: light;
  --paper: #eef3f5;
  --sleeve: #fafcfd;
  --ink: #203943;
  --secondary: #536872;
  --rule: #cbd8df;
  --action: #215fa6;
  --action-pressed: #174a82;
  --amber: #795414;
  --green: #28613e;
  --red: #8c312a;
  --display: Baskerville, "Palatino Linotype", Palatino, serif;
  --body: "Avenir Next", Avenir, Helvetica, Arial, sans-serif;
  --mono: Menlo, Monaco, "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 8%, rgb(255 255 255 / 0.55), transparent 26rem),
    var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: rgb(33 95 166 / 0.16);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 4;
  background-image:
    repeating-linear-gradient(13deg, transparent 0 5px, rgb(32 57 67 / 0.012) 6px),
    repeating-linear-gradient(91deg, transparent 0 7px, rgb(255 255 255 / 0.18) 8px);
  content: "";
  pointer-events: none;
}

button,
input,
audio {
  font: inherit;
  touch-action: manipulation;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--action);
  outline-offset: 4px;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 10;
  padding: 11px 14px;
  transform: translateY(-180%);
  background: var(--ink);
  color: var(--sleeve);
}

.skip-link:focus {
  transform: translateY(0);
}

main {
  position: relative;
  z-index: 1;
  width: min(100% - 48px, 1180px);
  margin: 0 auto;
  padding: 34px 0 max(52px, env(safe-area-inset-bottom));
}

.mast,
.hero,
.transport,
.player-heading,
.player-footer,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mast {
  min-height: 44px;
  gap: 24px;
}

.project-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.page-status {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 650;
}

.page-status.preparing {
  color: var(--amber);
}

.page-status.loading {
  color: var(--secondary);
}

.page-status.ready {
  color: var(--green);
}

.page-status.error {
  color: var(--red);
}

.hero {
  min-height: 272px;
  gap: 56px;
  padding: 28px 0 36px;
  align-items: end;
}

.hero-copy {
  min-width: 0;
}

h1,
h2,
.moments-intro,
.hero-summary,
.player-instruction,
.keyboard-help,
footer {
  text-wrap: balance;
}

h1,
h2 {
  scroll-margin-top: 20px;
}

h1 {
  max-width: 850px;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3.7rem, 6.9vw, 5.45rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 0.98;
}

.hero-summary {
  max-width: 690px;
  margin-top: 22px;
  color: var(--secondary);
  font-size: 1.12rem;
}

.processing-note {
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) minmax(280px, 1.28fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: start;
  padding: 38px 0;
  border-top: 1px solid var(--rule);
}

.processing-note > div {
  max-width: 720px;
  color: var(--secondary);
  font-size: 1rem;
}

.song-facts {
  display: grid;
  min-width: 170px;
  gap: 12px;
  margin: 0;
  text-align: right;
}

.song-facts div {
  display: grid;
  gap: 1px;
}

.song-facts dt {
  color: var(--secondary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.song-facts dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.83rem;
  font-variant-numeric: tabular-nums;
}

.player-sleeve {
  border: 1px solid var(--rule);
  background: var(--sleeve);
  padding: clamp(22px, 3.2vw, 38px);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.8);
}

.player-heading {
  gap: 24px;
  align-items: start;
}

h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.5vw, 1.9rem);
  letter-spacing: -0.022em;
  line-height: 1.15;
}

.player-instruction,
.moments-intro,
.keyboard-help,
.feedback {
  color: var(--secondary);
  font-size: 0.9rem;
}

.player-instruction {
  margin-top: 7px;
}

.player-time {
  flex: 0 0 auto;
  padding-top: 5px;
  font-family: var(--mono);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.transport {
  gap: 14px;
  margin: 24px 0 20px;
}

.play-button {
  display: grid;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: 1px solid var(--action);
  border-radius: 999px;
  background: var(--action);
  color: var(--sleeve);
  cursor: pointer;
  place-items: center;
  transition: background-color 160ms ease, transform 160ms ease;
}

.play-button:hover:not(:disabled) {
  background: var(--action-pressed);
}

.play-button:active:not(:disabled),
.mix-switch button:active:not(:disabled),
.share-button:active:not(:disabled),
.retry-button:active:not(:disabled),
.moment-button:active:not(:disabled) {
  transform: translateY(1px);
}

#playIcon {
  display: inline-block;
  transform: translateX(1px);
  font-size: 1.2rem;
  line-height: 1;
}

.transport-state {
  min-width: 0;
  flex: 1 1 auto;
  color: var(--secondary);
  font-size: 0.9rem;
}

.mix-switch {
  display: grid;
  min-width: min(100%, 410px);
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  padding: 5px;
}

.mix-switch button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.mix-switch button[aria-pressed="true"] {
  background: var(--action);
  color: var(--sleeve);
}

.waveform-wrap {
  position: relative;
  min-height: 286px;
  overflow: hidden;
  border: 1px solid rgb(203 216 223 / 0.72);
  background: var(--paper);
  cursor: crosshair;
  touch-action: manipulation;
}

#waveform {
  display: block;
  width: 100%;
  height: 286px;
}

.waveform-empty {
  position: absolute;
  inset: 0;
  display: grid;
  padding: 28px;
  color: var(--secondary);
  font-size: 0.9rem;
  place-items: center;
  text-align: center;
}

.waveform-empty[hidden] {
  display: none;
}

.seek-label {
  display: block;
  margin: 14px 0 5px;
  color: var(--secondary);
  font-size: 0.78rem;
}

.seek {
  width: 100%;
  min-height: 44px;
  margin: 0;
  accent-color: var(--action);
  cursor: pointer;
}

.player-footer {
  gap: 22px;
  margin-top: 16px;
}

.share-button,
.retry-button,
.download-link {
  display: inline-flex;
  min-height: 44px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--action);
  border-radius: 999px;
  background: transparent;
  color: var(--action);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.share-button {
  padding: 0 18px;
}

.retry-button {
  padding: 0 18px;
}

.retry-button[hidden] {
  display: none;
}

.player-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.download-link {
  padding: 0 16px;
}

.share-button:hover:not(:disabled),
.retry-button:hover:not(:disabled),
.download-link:hover {
  background: var(--action);
  color: var(--sleeve);
}

.feedback {
  min-height: 1.4em;
  margin-top: 8px;
  text-align: right;
}

.native-player {
  margin-top: 22px;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
}

.native-player summary {
  min-height: 44px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 650;
}

.native-player audio {
  display: block;
  width: 100%;
  margin-top: 12px;
}

.no-script {
  margin-top: 14px;
  color: var(--red);
  font-weight: 650;
}

.moments {
  padding: 52px 0 34px;
  scroll-margin-top: 20px;
}

.moments-intro {
  margin-top: 8px;
}

.moment-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 26px;
  margin-top: 26px;
}

.moment-list.empty {
  display: block;
  min-height: 120px;
  border-top: 1px solid var(--rule);
  padding-top: 20px;
  color: var(--secondary);
}

.moment-button {
  display: grid;
  min-width: 0;
  min-height: 184px;
  align-content: start;
  gap: 9px;
  border: 0;
  border-top: 1px solid var(--rule);
  background: transparent;
  padding: 17px 0 0;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}

.moment-button:hover:not(:disabled) {
  border-color: var(--action);
}

.moment-time {
  color: var(--action);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.moment-title {
  overflow-wrap: anywhere;
  font-family: var(--display);
  font-size: 1.45rem;
  line-height: 1.15;
}

.moment-description {
  max-width: 28ch;
  overflow-wrap: anywhere;
  color: var(--secondary);
  font-size: 0.86rem;
}

.moment-action {
  align-self: end;
  color: var(--action);
  font-size: 0.78rem;
  font-weight: 700;
}

footer {
  gap: 24px;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  color: var(--secondary);
  font-size: 0.78rem;
}

@media (max-width: 1000px) and (min-width: 761px) {
  .moment-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  main {
    width: min(100% - 32px, 540px);
    padding-top: 18px;
  }

  .mast {
    align-items: start;
  }

  .project-label {
    padding-top: 7px;
    font-size: 0.66rem;
  }

  .page-status {
    font-size: 0.75rem;
  }

  .hero {
    min-height: 0;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
    padding: 24px 0 30px;
  }

  h1 {
    font-size: clamp(2.65rem, 13.6vw, 4rem);
    line-height: 1.02;
  }

  .hero-summary {
    margin-top: 18px;
    font-size: 1rem;
  }

  .song-facts {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 13px 24px;
    text-align: left;
  }

  .song-facts dt {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .player-heading {
    display: block;
  }

  .player-time {
    display: block;
    margin-top: 9px;
    padding: 0;
  }

  .transport {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 14px;
    margin-top: 20px;
  }

  .mix-switch {
    width: 100%;
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .waveform-wrap,
  #waveform {
    height: 232px;
    min-height: 232px;
  }

  .player-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .share-button {
    align-self: start;
  }

  .player-actions {
    justify-content: flex-start;
  }

  .feedback {
    text-align: left;
  }

  .moment-list {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .processing-note {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .moment-button {
    min-height: 132px;
    grid-template-columns: 48px minmax(0, 1fr);
    column-gap: 14px;
  }

  .moment-time {
    grid-column: 1;
    grid-row: 1 / span 3;
  }

  .moment-title,
  .moment-description,
  .moment-action {
    grid-column: 2;
  }

  footer {
    align-items: start;
    flex-direction: column;
    gap: 6px;
  }
}

@media (max-width: 390px) {
  main {
    width: min(100% - 24px, 366px);
  }

  .player-sleeve {
    padding: 18px 14px;
  }

  .mix-switch button {
    padding-inline: 8px;
    font-size: 0.78rem;
  }

  .keyboard-help {
    font-size: 0.82rem;
  }
}

@media (max-width: 350px) {
  .mix-switch {
    grid-template-columns: 1fr;
    border-radius: 22px;
  }
}

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