:root {
  color-scheme: light;
  --bg: #f4f0e8;
  --surface: #fbf9f5;
  --surface-raised: #fffdf9;
  --text: #24211d;
  --muted: #777168;
  --line: rgba(36, 33, 29, 0.14);
  --line-strong: rgba(36, 33, 29, 0.24);
  --accent: #d75b3f;
  --accent-hover: #c94e34;
  --accent-soft: #edc1ae;
  --shadow: 0 24px 70px rgba(54, 45, 35, 0.1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191816;
  --surface: #22211e;
  --surface-raised: #282622;
  --text: #f2eee6;
  --muted: #aaa49a;
  --line: rgba(242, 238, 230, 0.13);
  --line-strong: rgba(242, 238, 230, 0.24);
  --accent: #e57457;
  --accent-hover: #f18163;
  --accent-soft: #7b3e30;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 80% 8%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 28rem),
    var(--bg);
  font-family: "Manrope", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: color 180ms ease, background-color 180ms ease;
}

body.has-ad {
  padding-bottom: 112px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.site-header {
  width: min(1180px, calc(100% - 48px));
  height: 96px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-decoration: none;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50% 50% 50% 2px;
  background: var(--accent);
  transform: rotate(-45deg);
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface);
  transform: rotate(6deg);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.moon-icon,
[data-theme="dark"] .sun-icon {
  display: none;
}

[data-theme="dark"] .moon-icon {
  display: block;
}

main {
  width: min(1180px, calc(100% - 48px));
  min-height: calc(100vh - 96px);
  margin: 0 auto;
}

.upload-view {
  min-height: calc(100vh - 136px);
  padding: 7vh 0 12vh;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(380px, 0.8fr);
  align-items: center;
  gap: clamp(60px, 9vw, 140px);
}

.eyebrow {
  margin: 0 0 22px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro h1,
.track-heading h1 {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.intro h1 {
  max-width: 630px;
  font-size: clamp(64px, 7.2vw, 108px);
  line-height: 0.88;
}

.intro h1 em {
  color: var(--accent);
  font-weight: inherit;
}

.intro-copy {
  max-width: 510px;
  margin: 34px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 1.4vw, 19px);
  line-height: 1.65;
}

.drop-zone {
  width: 100%;
  min-width: 0;
  min-height: 400px;
  padding: 52px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: 28px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--surface-raised);
  transform: translateY(-3px);
}

.upload-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--accent);
}

.upload-icon svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.drop-title {
  font-size: 18px;
  font-weight: 600;
}

.drop-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.player-view {
  width: min(870px, 100%);
  margin: 0 auto;
  padding: 6vh 0 10vh;
}

.player-view[hidden],
.upload-view[hidden] {
  display: none;
}

.track-heading {
  margin-bottom: 28px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
}

.track-heading .eyebrow {
  margin-bottom: 10px;
}

.track-heading h1 {
  max-width: 680px;
  overflow: hidden;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.change-file {
  flex: 0 0 auto;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  cursor: pointer;
}

.change-file:hover {
  color: var(--text);
  border-color: var(--text);
}

.player-card {
  padding: clamp(26px, 5vw, 52px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: color-mix(in srgb, var(--surface-raised) 94%, transparent);
  box-shadow: var(--shadow);
}

.waveform-wrap {
  position: relative;
  height: 190px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
  cursor: pointer;
}

.waveform {
  width: 100%;
  height: 100%;
}

.play-button {
  position: absolute;
  width: 68px;
  height: 68px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 30%, transparent);
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.play-button:hover {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.play-button svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.play-icon {
  margin-left: 3px;
}

.pause-icon,
.is-playing .play-icon {
  display: none;
}

.is-playing .pause-icon {
  display: block;
}

.timeline {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.speed-control {
  margin-top: 38px;
}

.speed-label-row {
  margin-bottom: 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.speed-label-row label {
  font-size: 15px;
  font-weight: 600;
}

.speed-value {
  font-family: "Newsreader", Georgia, serif;
  font-size: 38px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

input[type="range"] {
  --progress: 33.33%;
  width: 100%;
  height: 22px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--accent) var(--progress), var(--line) var(--progress));
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 4px;
  background: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -8px;
  appearance: none;
  border: 4px solid var(--surface-raised);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 3px 10px rgba(0, 0, 0, 0.16);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 4px solid var(--surface-raised);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 3px 10px rgba(0, 0, 0, 0.16);
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 7px;
  border-radius: 4px;
}

.speed-ticks {
  margin-top: 9px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.download-button {
  width: 100%;
  height: 58px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  color: white;
  background: var(--text);
  cursor: pointer;
  transition: opacity 150ms ease, transform 150ms ease;
}

.export-options {
  min-width: 0;
  margin: 38px 0 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 0;
}

.format-label {
  font-size: 13px;
  font-weight: 600;
}

.format-switch {
  position: relative;
  padding: 3px;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.format-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.format-switch label {
  min-width: 58px;
  padding: 7px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.format-switch input:checked + label {
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: 0 2px 8px rgba(38, 32, 26, 0.08);
}

.format-switch input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ad-banner {
  position: fixed;
  right: 24px;
  bottom: 24px;
  left: 24px;
  z-index: 10;
  width: min(720px, calc(100% - 48px));
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-raised) 94%, transparent);
  box-shadow: 0 14px 42px rgba(45, 38, 31, 0.14);
  backdrop-filter: blur(14px);
}

.ad-banner[hidden] {
  display: none;
}

.ad-link {
  min-height: 68px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  color: inherit;
  text-decoration: none;
}

.ad-link[href]:hover .ad-action {
  color: var(--accent);
}

.ad-label {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ad-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ad-title,
.ad-description {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ad-title {
  font-size: 13px;
  font-weight: 600;
}

.ad-description {
  color: var(--muted);
  font-size: 11px;
}

.ad-action {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: color 150ms ease;
}

[data-theme="dark"] .download-button {
  color: #1d1b18;
}

.download-button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.download-button:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.download-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.privacy-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 10px;
  color: var(--surface-raised);
  background: var(--text);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .upload-view {
    padding-top: 4vh;
    grid-template-columns: 1fr;
    gap: 52px;
  }

  .drop-zone {
    min-height: 270px;
  }
}

@media (max-width: 560px) {
  .site-header,
  main {
    width: calc(100% - 30px);
  }

  .site-header {
    height: 78px;
  }

  .upload-view {
    min-height: calc(100vh - 90px);
    padding: 4vh 0 8vh;
  }

  .intro h1 {
    font-size: clamp(52px, 16vw, 66px);
  }

  .track-heading {
    align-items: start;
  }

  .track-heading h1 {
    max-width: 66vw;
  }

  .player-view {
    padding-top: 4vh;
  }

  .player-card {
    padding: 20px;
    border-radius: 22px;
  }

  .waveform-wrap {
    height: 150px;
  }

  .play-button {
    width: 58px;
    height: 58px;
  }

  body.has-ad {
    padding-bottom: 104px;
  }

  .ad-banner {
    right: 15px;
    bottom: 15px;
    left: 15px;
    width: calc(100% - 30px);
  }

  .ad-link {
    min-height: 64px;
    grid-template-columns: auto 1fr;
    gap: 12px;
  }

  .ad-description,
  .ad-action {
    display: none;
  }
}

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