/* HPR test: HighlandDanceMusic's "Highland Gold" dark theme, score on a paper card. */
:root {
  --bg: #0b0f10; --panel: #121819; --panel2: #182021; --text: #eee9df; --muted: #9da59f;
  --line: #2b3534; --accent: #c1a05d; --accent-hover: #cfb274; --accent2: #6f8875;
  --paper: #f7f3ea; --ink: #15191a; --r: 16px; --rs: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
.app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }

.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 800; letter-spacing: .04em; color: var(--accent); white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
.tune { min-width: 0; flex: 1; }
.tune-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tune-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn { width: 38px; height: 38px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2);
  display: grid; place-items: center; font-weight: 700; }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn:hover { border-color: var(--accent); }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.score-card { position: relative; flex: 1; min-height: 0; margin: 10px 12px 0; border-radius: var(--r); background: var(--paper);
  color: var(--ink); overflow: hidden; }
.score-scroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.score-wrap { position: relative; padding: 4px 0 40vh; }
.score-card.with-fingering .score-wrap { margin-right: 92px; }
#score { transition: opacity .3s; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.loop-box { position: absolute; background: rgba(193, 160, 93, .22); border: 2px solid rgba(193, 160, 93, .8); border-radius: 6px; }
.loop-box.pending { background: rgba(111, 136, 117, .22); border-color: rgba(111, 136, 117, .9); }
.score-card.mem-1 #score { opacity: .35; }
.score-card.mem-2 #score { opacity: .12; }
.score-card.mem-3 #score { opacity: 0; }

.status { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: var(--panel); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.status[hidden] { display: none; }
.loop-hint { position: absolute; left: 12px; right: 12px; bottom: 12px; background: var(--panel); color: var(--text); padding: 8px 12px;
  border-radius: 999px; font-size: 13px; text-align: center; }

.fingering { position: absolute; right: 10px; top: 10px; width: 78px; padding: 8px 6px 6px; border-radius: 12px; background: rgba(18, 24, 25, .92);
  color: var(--text); text-align: center; pointer-events: none; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.fingering[hidden] { display: none; }
.fingering .fn { font-weight: 750; font-size: 17px; color: var(--accent); line-height: 1.1; }
.fingering .fnext { font-size: 11px; color: var(--muted); margin-top: 2px; }
.fingering svg { display: block; margin: 4px auto 0; }

.controls { padding: 10px 14px; padding-bottom: max(12px, env(safe-area-inset-bottom)); max-height: 46vh; overflow-y: auto; }
.transport { display: flex; align-items: center; gap: 10px; }
.play { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--accent); color: #111; display: grid; place-items: center; flex: none; }
.play:hover { background: var(--accent-hover); }
.play:disabled { opacity: .45; cursor: default; }
.play svg { width: 26px; height: 26px; fill: currentColor; }
.play .i-pause { display: none; }
body.is-playing .play .i-pause { display: block; }
body.is-playing .play .i-play { display: none; }
.where { flex: 1; min-width: 0; text-align: right; }
.where-bar { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.where-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

input[type=range] { -webkit-appearance: none; appearance: none; height: 28px; background: transparent; min-width: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--accent); border: 0; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 0; }
.scrub { width: 100%; margin: 4px 0 2px; }

.row { display: grid; grid-template-columns: 58px 30px 1fr 30px 112px; align-items: center; gap: 6px; margin-top: 2px; }
.row:has(> input:nth-child(2)) { grid-template-columns: 58px 1fr 112px; }
.row label { color: var(--muted); font-size: 13px; }
.row output { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.step { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); padding: 0; line-height: 1; }
.step:hover { border-color: var(--accent); }

.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed=true] { background: var(--accent); color: #111; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 2px 0; }

.info { max-width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--text); }
.info::backdrop { background: rgba(0,0,0,.55); }
.info h2 { margin: 0 0 8px; font-size: 18px; }
.info li { margin: 6px 0; color: var(--muted); }

@media (max-width: 599px) {
  .fingering { width: 58px; right: 6px; top: 6px; padding: 6px 4px 4px; }
  .fingering .fn { font-size: 14px; }
  .fingering svg { width: 36px; height: 131px; }
  .score-card.with-fingering .score-wrap { margin-right: 66px; }
  .row { grid-template-columns: 52px 30px 1fr 30px 92px; }
  .row:has(> input:nth-child(2)) { grid-template-columns: 52px 1fr 92px; }
  .controls { padding: 6px 12px max(8px, env(safe-area-inset-bottom)); max-height: 44vh; }
  .play { width: 46px; height: 46px; }
  .row { margin-top: 0; }
  .tools { flex-wrap: nowrap; overflow-x: auto; margin: 6px -12px 0; padding: 0 12px 4px; scrollbar-width: none; }
  .tools::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; flex: none; }
  .hint { display: none; }
  .score-card { margin: 8px 8px 0; }
}

/* desktop: score left, controls in a side column */
@media (min-width: 900px) {
  .stage { flex-direction: row; }
  .score-card { margin: 12px 0 12px 12px; }
  .controls { width: 400px; max-height: none; border-left: 1px solid var(--line); margin-left: 12px; }
}
