@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-sans/IBMPlexSans-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-sans/IBMPlexSans-SemiBold.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f1f3f7;
  --ink: #181817;
  --muted: #606675;
  --line: #d9dde7;
  --accent: #3D59F5;
  --accent-strong: #2841d9;
  --accent-soft: #eef3ff;
  --warn: #9f4d2f;
  font-family:
    "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-y: auto;
}

button,
input,
select {
  font: inherit;
}

button,
.file-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

button:hover,
.file-button:hover {
  border-color: #b7c5ff;
  background: var(--accent-soft);
}

button:active,
.file-button:active {
  transform: translateY(1px);
}

button:focus-visible,
.file-button:focus-within,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(61, 89, 245, 0.25);
  outline-offset: 2px;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.file-details,
.status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.app-title {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0 18px;
  font-weight: 600;
}

.language-control select {
  min-width: 124px;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-zone,
.player-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.drop-zone {
  min-height: 56vh;
  display: grid;
  place-items: center;
  padding: 36px;
  border-style: dashed;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-copy {
  display: grid;
  justify-items: center;
  gap: 18px;
  max-width: min(100%, 720px);
  text-align: center;
}

.drop-copy strong {
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
  white-space: nowrap;
}

.privacy-note {
  max-width: 34rem;
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

.drop-copy button {
  padding: 0 18px;
  font-weight: 600;
}

.player-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.is-hidden {
  display: none;
}

.track-meta {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.file-name {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.status-text {
  text-align: right;
}

.status-text.is-error {
  color: var(--warn);
  font-weight: 600;
}

.waveform-wrap {
  position: relative;
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9fc;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 430px;
  cursor: crosshair;
}

@media (min-height: 700px) {
  body:has(#playerPanel:not(.is-hidden)) {
    overflow: hidden;
  }

  body:has(#playerPanel:not(.is-hidden)) .app-shell {
    height: min(100dvh, 980px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  #playerPanel:not(.is-hidden) {
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }

  #playerPanel:not(.is-hidden) .waveform-wrap {
    min-height: 0;
    height: 100%;
    max-height: 620px;
  }

  #playerPanel:not(.is-hidden) canvas {
    height: 100%;
    min-height: 280px;
    max-height: 620px;
  }
}

.time-row {
  display: grid;
  grid-template-columns: max-content 1fr max-content;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  background: transparent;
  accent-color: var(--accent);
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border: 1px solid #bfc5d3;
  border-radius: 999px;
  background: #eef1f6;
}

input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  appearance: none;
}

input[type="range"]:hover::-webkit-slider-runnable-track,
input[type="range"]:active::-webkit-slider-runnable-track,
input[type="range"]:focus::-webkit-slider-runnable-track {
  background: #eef1f6;
  border-color: #bfc5d3;
}

input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:active::-webkit-slider-thumb,
input[type="range"]:focus::-webkit-slider-thumb {
  background: var(--accent);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border: 1px solid #bfc5d3;
  border-radius: 999px;
  background: #eef1f6;
}

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

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}

input[type="range"]:hover::-moz-range-track,
input[type="range"]:active::-moz-range-track,
input[type="range"]:focus::-moz-range-track {
  background: #eef1f6;
  border-color: #bfc5d3;
}

input[type="range"]:hover::-moz-range-progress,
input[type="range"]:active::-moz-range-progress,
input[type="range"]:focus::-moz-range-progress,
input[type="range"]:hover::-moz-range-thumb,
input[type="range"]:active::-moz-range-thumb,
input[type="range"]:focus::-moz-range-thumb {
  background: var(--accent);
}

.controls-grid {
  display: grid;
  gap: 14px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.transport-row {
  justify-content: flex-start;
}

.settings-row {
  justify-content: flex-start;
  gap: 18px;
  padding-top: 10px;
  border-top: 1px solid var(--surface-soft);
}

.control-row button {
  padding: 0 12px;
  font-weight: 600;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.primary-control {
  width: 92px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

#nextAudio {
  width: 148px;
  white-space: nowrap;
}

.primary-control:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.jump-control {
  display: inline-flex;
  align-items: center;
  height: 42px;
  gap: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f8ff;
  box-shadow: inset 0 0 0 1px rgba(61, 89, 245, 0.04);
  overflow: hidden;
}

.jump-control button {
  min-height: 40px;
  border-color: transparent;
  border-radius: 0;
  background: transparent;
}

.jump-control > .icon-button {
  width: 48px;
  padding: 0;
}

.jump-control select {
  width: 78px;
  min-height: 40px;
  height: 40px;
  border-top: 0;
  border-bottom: 0;
  border-color: var(--line);
  border-radius: 0;
  background: var(--surface);
  font-weight: 600;
  text-align: center;
}

.jump-control > :first-child {
  border-radius: 9px 0 0 9px;
}

.jump-control > :last-child {
  border-radius: 0 9px 9px 0;
}

.speed-control,
.volume-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid var(--surface-soft);
  border-radius: 8px;
  background: #fbfcff;
}

.volume-control {
  width: 260px;
  flex: 0 0 260px;
}

.speed-control {
  width: 220px;
  flex: 0 0 220px;
}

.volume-control input,
.speed-control input {
  min-width: 0;
  flex: 1 1 auto;
}

.volume-control output {
  min-width: 44px;
}

.speed-control output {
  min-width: 24px;
}

select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(3px);
}

.loading-overlay.is-hidden {
  display: none;
}

.loader {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(320px, calc(100vw - 40px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(24, 24, 23, 0.12);
  text-align: center;
}

.loader strong {
  font-size: 1rem;
}

.loader span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.progress-track.is-indeterminate span {
  width: 38%;
  animation: progress-slide 900ms ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(270%);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 18px 0;
  }

  .app-header,
  .track-meta,
  .controls-grid {
    display: grid;
  }

  .header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .file-button,
  .speed-control,
  .volume-control {
    width: 100%;
    flex: 1 1 100%;
  }

  .language-control,
  .language-control select {
    flex: 1 1 auto;
    width: 100%;
  }

  .status-text {
    text-align: left;
  }

  .drop-zone {
    min-height: 48vh;
    padding: 24px;
  }

  .drop-copy strong {
    white-space: normal;
  }

  .waveform-wrap {
    min-height: 330px;
  }

  canvas {
    height: 330px;
  }

  .control-row button {
    flex: 1 1 72px;
  }

  .primary-control,
  #nextAudio {
    width: auto;
  }

  .transport-row,
  .settings-row {
    justify-content: stretch;
  }

  .jump-control {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    width: 100%;
  }

  .jump-control button {
    flex: none;
  }

  .jump-control > .icon-button {
    width: 100%;
  }
}
