:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --panel: #ffffff;
  --text: #191714;
  --muted: #6f6a62;
  --line: #d8d1c8;
  --accent: #176b5d;
  --accent-dark: #0e4f45;
  --danger: #9b2d20;
  --shadow: 0 12px 30px rgb(34 27 16 / 10%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 62%), rgb(255 255 255 / 0%) 280px), var(--bg);
  color: var(--text);
  font:
    14px/1.5 ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

main {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 16px 0 32px;
}

header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: clamp(18px, 3vw, 24px);
  line-height: 1.05;
  letter-spacing: 0;
}

.status-pill {
  min-width: 190px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 72%);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.app {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fffdfa;
  font: inherit;
  line-height: 1.55;
}

textarea:focus,
select:focus,
input:focus,
button:focus-visible {
  outline: 3px solid rgb(23 107 93 / 24%);
  outline-offset: 2px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.controls > div:first-child {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--text);
  font: inherit;
}

.speed-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  align-items: center;
  height: 42px;
}

.speed-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.checkbox-label {
  min-height: 42px;
  align-content: end;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--text);
  font-size: 13px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

button {
  border: 0;
  border-radius: 8px;
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.player {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.transport {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.icon-button:hover:not(:disabled) {
  background: #f0ebe3;
}

#playButton {
  font-size: 16px;
  line-height: 1;
}

.seek {
  display: grid;
  gap: 6px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.time {
  min-width: 98px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

progress {
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: #e7e0d6;
}

progress::-webkit-progress-value {
  background: var(--accent);
}

progress::-moz-progress-bar {
  background: var(--accent);
}

.message {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

audio {
  display: none;
}

.now-playing {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

.now-playing[hidden] {
  display: none;
}

.now-playing-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.now-playing-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.now-playing-text {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  color: var(--text);
  font: inherit;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.now-playing-text:empty::before {
  content: "Waiting for playback…";
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 980px) {
  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  main {
    width: min(100vw - 20px, 980px);
    padding: 12px 0 24px;
  }

  header,
  .controls,
  .player {
    grid-template-columns: 1fr;
  }

  header {
    display: grid;
    align-items: start;
  }

  .status-pill {
    width: 100%;
    min-width: 0;
  }

  .player {
    gap: 14px;
  }

  .transport {
    justify-content: center;
  }

  .time {
    min-width: 0;
    text-align: center;
  }
}
