*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #0d1117;
  color: #e6edf3;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
}

#home-link {
  position: fixed;
  top: 1rem;
  right: 1.2rem;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.2);
  text-decoration: none;
  transition: color 0.2s;
}
#home-link:hover {
  color: rgba(255, 255, 255, 0.7);
}

h1 {
  font-size: 1.6rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  color: #8b949e;
}

.freq-display {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
#freqInput {
  font-family: inherit;
  font-size: 3rem;
  font-weight: 200;
  letter-spacing: 0.05em;
  color: #58a6ff;
  background: transparent;
  border: none;
  border-bottom: 1px solid #30363d;
  text-align: right;
  width: 5.5em;
  padding: 0.1rem 0.2rem;
  outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}
#freqInput::-webkit-outer-spin-button,
#freqInput::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#freqInput:focus {
  border-bottom-color: #58a6ff;
}
.freq-display .unit {
  font-size: 1.2rem;
  color: #8b949e;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 360px;
}

.row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.row label {
  white-space: nowrap;
  font-size: 0.85rem;
  color: #8b949e;
  width: 5em;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #30363d;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #58a6ff;
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: #58a6ff;
  cursor: pointer;
}

.vol-display {
  font-size: 0.85rem;
  color: #8b949e;
  width: 3em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#playBtn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: #238636;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 0 0 0 rgba(35, 134, 54, 0.5);
}
#playBtn:hover {
  background: #2ea043;
  transform: scale(1.05);
}
#playBtn.playing {
  background: #da3633;
  animation: pulse 2s infinite;
}
#playBtn.playing:hover {
  background: #f85149;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(218, 54, 51, 0.5);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(218, 54, 51, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(218, 54, 51, 0);
  }
}

.dl-section {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.dl-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.dl-row label {
  white-space: nowrap;
  font-size: 0.85rem;
  color: #8b949e;
  width: 5em;
}

#dlSeconds {
  width: 5em;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 0.9rem;
  padding: 0.3rem 0.5rem;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}
#dlSeconds:focus {
  border-color: #58a6ff;
}

.dl-unit {
  font-size: 0.85rem;
  color: #8b949e;
}

#dlBtn {
  padding: 0.45rem 1rem;
  background: #1f6feb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  margin-left: auto;
}
#dlBtn:hover:not(:disabled) {
  background: #388bfd;
}
#dlBtn:disabled {
  background: #30363d;
  cursor: not-allowed;
  color: #484f58;
}

.dl-status {
  font-size: 0.78rem;
  color: #8b949e;
  min-height: 1.1em;
}

.info {
  max-width: 420px;
  background: #161b22;
  border-radius: 12px;
  padding: 1rem 1.4rem;
  font-size: 0.82rem;
  line-height: 1.7;
  color: #8b949e;
}
.info strong {
  color: #e6edf3;
}

#waveCanvas {
  width: 360px;
  height: 90px;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid #1f6feb;
  outline-offset: 2px;
}
