:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d232b;
  --muted: #5d6673;
  --line: #dcd7cc;
  --accent: #1f3a5f;
  --accent-ink: #ffffff;
  --accent-soft: #e3eaf3;
  --cursor: rgba(255, 196, 0, 0.30);
  --loop: rgba(31, 58, 95, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181d;
    --card: #1d232b;
    --ink: #e8e4dc;
    --muted: #a3abb6;
    --line: #333b46;
    --accent: #8db4e2;
    --accent-ink: #10161d;
    --accent-soft: #24303f;
    --cursor: rgba(255, 196, 0, 0.28);
    --loop: rgba(141, 180, 226, 0.14);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--accent); color: var(--accent-ink);
}
.brand { color: inherit; text-decoration: none; display: flex; flex-direction: column; }
.brand-title { font-weight: 700; font-size: 1.1rem; }
.brand-sub { font-size: .8rem; opacity: .85; }
.voice-pick { display: flex; flex-direction: column; font-size: .75rem; }
.voice-pick select {
  font-size: 1rem; padding: 4px 8px; border-radius: 8px; border: 0;
  background: var(--accent-ink); color: var(--accent);
}

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.intro { color: var(--muted); }

.movement-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.movement-list a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px; background: var(--card);
  border: 1px solid var(--line); color: inherit; text-decoration: none;
}
.movement-list a:hover { border-color: var(--accent); }
.mv-num {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.mv-info { flex: 1; min-width: 0; }
.mv-name { font-weight: 600; }
.mv-meta { font-size: .85rem; color: var(--muted); }
.badge { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

.mv-head h1 { margin: 6px 0 0; font-size: 1.4rem; }
.mv-ref { margin: 2px 0 12px; color: var(--muted); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }

.player {
  position: sticky; top: 62px; z-index: 5;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; margin-bottom: 12px;
}
.transport { display: flex; align-items: center; gap: 10px; }
.transport button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 50%;
  width: 44px; height: 44px; cursor: pointer; flex: none;
}
.transport .play { width: 56px; height: 56px; font-size: 1.4rem; background: var(--accent); color: var(--accent-ink); border: 0; }
.position { flex: 1; min-width: 0; }
.transport .controls-btn {
  width: auto; height: 36px; border-radius: 999px; padding: 0 12px;
  font-size: .85rem; white-space: nowrap;
}
.player.compact .controls { display: none; }
.player.compact { padding-bottom: 8px; }
.position input { width: 100%; }
.pos-text { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
@media (max-width: 760px) {
  .controls { grid-template-columns: 1fr; }
  .player { position: static; }
  /* on a phone the transport stays at the bottom of the screen while the score scrolls */
  .transport {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 12px rgba(0, 0, 0, .08);
  }
  body { padding-bottom: 96px; }
  .transport { gap: 6px; }
  .transport button { width: 40px; height: 40px; }
  .transport .play { width: 50px; height: 50px; }
  .transport .controls-btn { height: 34px; padding: 0 10px; }
  .pos-text { font-size: .75rem; }
  /* the transport is fixed at the bottom: with Ouvir/Estudo hidden the card has nothing left */
  .player.compact { border: 0; padding: 0; margin: 0; background: none; }
}
.group { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 0; min-width: 0; }
.group legend { font-size: .8rem; color: var(--muted); padding: 0 4px; }
.presets, .seg { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button, .seg button, #pitch-btn, .zoom button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
  padding: 6px 10px; cursor: pointer;
}
.presets button.on, .seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.mixer { display: grid; gap: 6px; margin-top: 10px; }
.mix-row { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 8px; font-size: .9rem; }
.mix-row input[type=range] { width: 100%; }
.mix-row button { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; cursor: pointer; padding: 2px 0; }
.mix-row.muted { opacity: .5; }
.mix-row.mine .mix-name { font-weight: 700; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
.row input[type=number] { width: 72px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); }
.lbl { font-size: .9rem; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; }
.hint { font-size: .8rem; color: var(--muted); margin: 4px 0; }
.loading { margin-top: 8px; font-size: .9rem; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 8px; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; border-bottom: 3px solid transparent; color: var(--muted); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab-body { padding: 12px 0; }

.score-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
.score-wrap {
  position: relative; background: #fff; border-radius: 10px; border: 1px solid var(--line);
  overflow-x: auto; min-height: 120px;
}
.cursor, .loop-box { position: absolute; pointer-events: none; border-radius: 4px; }
.cursor { background: var(--cursor); transition: left .08s linear, top .08s linear; }
.loop-box { background: var(--loop); outline: 2px dashed var(--accent); }

.lyrics { font-size: 1.15rem; line-height: 1.9; max-width: 46em; }
.lyrics p { margin: 0 0 12px; }
.lyrics .w { cursor: pointer; border-radius: 4px; padding: 0 1px; }
.lyrics .w:hover { background: var(--accent-soft); }
.lyrics .w.now { background: var(--cursor); }

.files { padding-left: 18px; }
.files li { margin: 6px 0; }
.files a { color: var(--accent); }
.learned { margin-top: 12px; }
