:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --ink: #1e1b18;
  --muted: #6d665f;
  --line: #e2ddd6;
  --accent: #a4442f;
  --accent-soft: #f3e6e1;
  --f0: #a4442f;
  --target: #8c9bb0;
  --rms: #cbbfae;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16151a;
    --panel: #1e1d23;
    --ink: #ece8e3;
    --muted: #a09a92;
    --line: #302e36;
    --accent: #e08a6e;
    --accent-soft: #332624;
    --f0: #e08a6e;
    --target: #7c8ba0;
    --rms: #5a5348;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 1.5rem;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header { max-width: 1180px; margin: 0 auto 1.25rem; }
h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}
.tagline { margin: 0.3rem 0 0; color: var(--muted); max-width: 60ch; }

main {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 980px) { main { grid-template-columns: 1fr; } }

/* The voice panel carries a lot of controls. Two columns on a wide screen keeps it roughly
   the same height as the score beside it instead of trailing a metre below. */
@media (min-width: 1240px) {
  main { max-width: 1500px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
  .play-panel, header, footer { max-width: 1500px; }
  .controls { grid-template-columns: 1fr 1fr; column-gap: 1.4rem; align-items: start; }
  .group-title { grid-column: 1 / -1; }
  .control { grid-template-columns: 7.5rem 1fr 3.2rem; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.play-panel { max-width: 1180px; margin: 1rem auto 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}
h2 { margin: 0; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  tab-size: 2;
}
textarea:focus, select:focus, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#notation {
  margin-top: 0.75rem;
  overflow-x: auto;
  min-height: 60px;
}
#notation svg { max-width: 100%; }

.controls { display: grid; gap: 0.65rem; }
.control { display: grid; grid-template-columns: 8.5rem 1fr 3.4rem; align-items: center; gap: 0.6rem; }
/* A class selector outranks the user agent's `[hidden] { display: none }`, so without this
   the rate-law controls that are meant to be mutually exclusive all appear at once. */
.control[hidden] { display: none; }
.control label { color: var(--muted); font-size: 0.83rem; }
.control output { font: 12px ui-monospace, Menlo, monospace; text-align: right; color: var(--ink); }
.control input[type="range"] { width: 100%; accent-color: var(--accent); }
.control select { grid-column: 2 / span 2; }
.control .hint {
  grid-column: 1 / -1;
  margin: -0.15rem 0 0.2rem;
  font-size: 0.76rem;
  color: var(--muted);
}
.group-title {
  margin: 0.5rem 0 -0.1rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}

select, button, .download {
  font: inherit;
  padding: 0.4rem 0.7rem;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 1.4rem;
  cursor: pointer;
}
button.primary:disabled { opacity: 0.55; cursor: progress; }

.transport { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
audio { height: 36px; flex: 1 1 260px; min-width: 220px; }
.download { text-decoration: none; }
.status { color: var(--muted); font-size: 0.84rem; }
.error {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 7px;
  padding: 0.5rem 0.7rem;
  margin: 0.7rem 0 0;
  font: 13px ui-monospace, Menlo, monospace;
}

canvas { width: 100%; margin-top: 0.9rem; display: block; }
.legend { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.8rem; display: flex; gap: 1.1rem; flex-wrap: wrap; }
.key { display: inline-block; width: 1.5rem; height: 0.2rem; border-radius: 2px; vertical-align: middle; margin-right: 0.3rem; }
.key-f0 { background: var(--f0); }
.key-target { background: var(--target); }
.key-rms { background: var(--rms); }

footer { max-width: 1180px; margin: 1.5rem auto 0; color: var(--muted); font-size: 0.8rem; }
footer a { color: inherit; }
