:root {
  --bg: #edf0ee;
  --surface: #fafbfa;
  --surface-2: #e3e7e3;
  --ink: #15191b;
  --ink-2: #3b4448;
  --muted: #5d6863;
  --rule: #d0d6cf;
  --rule-strong: #b4bdb4;
  --brass: #7a5a0c;
  --teal: #1c5a61;
  --ok: #2f6b3f;
  --warn: #8a5a10;
  --crit: #8f2f2c;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;

  --roll-bg: #14171a;
  --roll-row: #1c2124;
  --roll-row-alt: #171b1e;
  --roll-grid: #272d31;
  --roll-grid-strong: #363e42;
  --roll-note: #d8ab45;
  --roll-note-edge: #f5e3ba;
  --roll-pedal: #5fb0b9;

  --roll-ped: #c2ccd2;
  --roll-muted: #7f8a85;
  --roll-playhead: #f2f5f0;
  --roll-key: #c9cfc9;
  --roll-key-black: #2e3538;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2023;
    --surface-2: #23282b;
    --ink: #e9ece8;
    --ink-2: #c3cac5;
    --muted: #929c96;
    --rule: #2b3134;
    --rule-strong: #3d4548;
    --brass: #d8ab45;
    --teal: #62b7c0;
    --ok: #6fbf85;
    --warn: #d9a94a;
    --crit: #e08079;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: clamp(1rem, 3vw, 2.25rem);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.masthead {
  max-width: 1100px;
  margin: 0 auto 1.5rem;
  padding-bottom: 1.1rem;
  border-bottom: 2px solid var(--rule-strong);
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  align-items: flex-end;
  justify-content: space-between;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -.035em;
  margin: 0 0 .35rem;
}

h1 .tld {
  color: var(--brass);
  font-weight: 400;
  letter-spacing: -.02em;
}

.tagline {
  margin: 0;
  font-size: 1.02rem;
  color: var(--ink-2);
  max-width: 52ch;
}

.env {
  display: grid;
  grid-template-columns: max-content max-content;
  gap: .1rem .8rem;
  margin: 0;
  font-family: var(--mono);
  font-size: .74rem;
}
.env dt { color: var(--muted); }
.env dd { margin: 0; color: var(--ink-2); }
.env dd[data-tone="ok"] { color: var(--ok); }
.env dd[data-tone="warn"] { color: var(--warn); }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1rem 1.15rem 1.15rem;
}

h2 {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .7rem;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .7rem;
}
.panel-head h2 { margin: 0; }

.hint { color: var(--muted); margin: 0; max-width: 70ch; }
.hint.small { font-size: .82rem; margin-top: .7rem; }

.urlrow {
  display: flex;
  gap: .4rem;
  margin-top: .7rem;
  max-width: 34rem;
}
.urlrow input[type="url"] {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  font-size: .82rem;
  padding: .4rem .55rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
}
.urlrow input[type="url"]:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }

.hint.tiny { font-size: .78rem; margin-top: .5rem; max-width: 62ch; }
.hint.tiny[data-tone="warn"] { color: var(--warn); }
.hint.tiny[data-tone="bad"] { color: var(--crit); }

footer { display: flex; flex-wrap: wrap; gap: .3rem 1.5rem; justify-content: space-between; }
footer a { color: var(--muted); }
footer a:hover { color: var(--brass); }

.file-info {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--ink-2);
  margin: .6rem 0 0;
  word-break: break-all;
}

#drop {
  border-style: dashed;
  border-width: 2px;
  border-color: var(--rule-strong);
  transition: border-color .15s, background .15s;
}
#drop.over {
  border-color: var(--brass);
  background: color-mix(in srgb, var(--brass) 8%, var(--surface));
}
#drop h2 { margin-bottom: .5rem; }

button {
  font-family: var(--sans);
  font-size: .88rem;
  font-weight: 600;
  padding: .45rem 1rem;
  border-radius: 4px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.06); }
button:disabled { opacity: .42; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

button.primary { background: var(--brass); color: var(--bg); }
button.ghost { background: transparent; border-color: var(--rule-strong); color: var(--ink-2); }

button.link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--teal);
  text-decoration: underline;
  cursor: pointer;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem 1.5rem;
  align-items: center;
  justify-content: space-between;
}
.status-text { min-width: 0; }
.status { font-weight: 600; }
.status-detail {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  margin-top: .15rem;
}
.actions { display: flex; gap: .5rem; align-items: center; }

.mode { display: flex; flex-direction: column; gap: .15rem; }
.mode > span {
  font-size: .66rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
select {
  font-family: var(--sans);
  font-size: .85rem;
  padding: .35rem .45rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
}
select:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
select:disabled { opacity: .5; }

#mode-hint { margin-top: .8rem; }
#mode-hint[data-tone="warn"] { color: var(--warn); }

.bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: .9rem;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--brass);
  transition: width .18s ease-out;
}

.toolbar { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.time {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 8ch;
}

.roll {
  display: block;
  width: 100%;
  height: 440px;
  border-radius: 4px;
  border: 1px solid var(--rule-strong);
  background: var(--roll-bg);
  touch-action: none;
  cursor: ns-resize;
}

.speed { display: flex; align-items: center; gap: .4rem; }
.speed > span {
  font-size: .66rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.speed input[type="range"] { width: 5.5rem; accent-color: var(--brass); }

.soundbar {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem 1.3rem;
  align-items: flex-end;
  margin-top: .9rem;
  padding-top: .9rem;
  border-top: 1px solid var(--rule);
}
.soundbar select {
  font-family: var(--sans);
  font-size: .85rem;
  padding: .32rem .45rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
}
.soundbar input[type="range"] { width: 6.5rem; accent-color: var(--brass); }
.soundbar-actions { display: flex; gap: .4rem; margin-left: auto; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin-top: .9rem;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}
.stats:empty { display: none; }

.stat {
  flex: 1 1 7rem;
  background: var(--surface);
  padding: .55rem .7rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.stat-v {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stat-l {
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.envwrap { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; }

.warn {
  max-width: 1100px;
  margin: 0 auto 1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--warn);
  border-radius: 4px;
  padding: .8rem 1rem;
  font-size: .87rem;
  color: var(--ink-2);
}
.warn strong { color: var(--warn); }

code {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--surface-2);
  padding: .08em .32em;
  border-radius: 3px;
}

footer {
  max-width: 1100px;
  margin: 1.6rem auto 0;
  padding-top: .9rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--muted);
}
footer .copyright { color: var(--ink-2); }
footer .credits { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.ncontrols {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem 1.4rem;
  align-items: flex-end;
  padding: .9rem 0 1rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: .9rem;
}

.nfield { display: flex; flex-direction: column; gap: .2rem; }
.nfield > span {
  font-size: .66rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.nfield > em {
  font-family: var(--mono);
  font-size: .68rem;
  font-style: normal;
  color: var(--muted);
}
.nfield input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--brass); margin: .3rem 0; }
.nfield input[type="range"] { width: 7.5rem; accent-color: var(--brass); }
.nfield input.text {
  width: 13rem;
  font-size: .9rem;
  padding: .3rem .45rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
}
.nfield input.num {
  width: 5rem;
  font-family: var(--mono);
  font-size: .85rem;
  padding: .3rem .4rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
}

.nrow { display: flex; gap: .25rem; align-items: center; }

button.mini {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 500;
  padding: .28rem .42rem;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--ink-2);
  border-radius: 3px;
}

.nanalysis {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: .9rem;
}
.nanalysis:empty { display: none; }

.ncell {
  flex: 1 1 8rem;
  background: var(--surface);
  padding: .45rem .65rem;
  display: flex;
  flex-direction: column;
  gap: .05rem;
  border-top: 2px solid transparent;
}
.ncell[data-tone="ok"] { border-top-color: var(--ok); }
.ncell[data-tone="warn"] { border-top-color: var(--warn); }
.ncell[data-tone="low"] { border-top-color: var(--crit); }
.ncell-v {
  font-family: var(--mono);
  font-size: .92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ncell-l {
  font-size: .66rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.nwarn {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--warn);
  background: var(--surface);
  border-radius: 4px;
  padding: .55rem .8rem;
  margin-bottom: .5rem;
  font-size: .85rem;
  color: var(--ink-2);
  max-width: 90ch;
}

.sheet {
  background: #ffffff;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  padding: .5rem;
  min-height: 8rem;
  overflow-x: auto;
}
.sheet:empty::after {
  content: "The score appears here once a recording has been transcribed.";
  display: block;
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: .85rem;
  color: #7a8078;
}
.sheet svg { display: block; max-width: 100%; height: auto; }
.sheet-loading {
  margin: 0;
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: .85rem;
  color: #7a8078;
}
.sheet-page + .sheet-page { margin-top: 1.25rem; border-top: 1px solid var(--rule); padding-top: 1.25rem; }

@media print {
  body { padding: 0; background: #fff; }
  .masthead, .warn, footer, .panel, .toolbar, .ncontrols, .nanalysis, .nwarn, #notation-intro {
    display: none !important;
  }
  #notation-panel {
    display: block !important;
    border: 0;
    padding: 0;
    background: #fff;
  }
  #notation-panel .panel-head { display: none !important; }
  .sheet {
    display: block !important;
    border: 0;
    padding: 0;
    background: #fff;
    overflow: visible;
  }
  .sheet svg { max-width: 100%; page-break-inside: avoid; }
}
