:root {
  color-scheme: light dark;
  --background: #f4f5f7;
  --surface: #fff;
  --ink: #131826;
  --muted: #5b616f;
  --primary: #0e7c86;
  --on-primary: #fff;
  --line: #c7ccd6;
  font: 16px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #101521; --surface: #171c29; --ink: #e7eaf2;
    --muted: #b6bfce; --primary: #5fd8e3; --on-primary: #07333a; --line: #647086;
  }
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); }
main { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, select, input, summary { font: inherit; }
button, select, summary { min-height: 44px; }
button, select {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); padding: 6px 8px;
}
button { min-width: 44px; cursor: pointer; font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
button:focus-visible, select:focus-visible, input:focus-visible,
summary:focus-visible, #paper:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }
button:hover:not(:disabled) { filter: brightness(.93); }
#controls {
  flex: none; position: relative; z-index: 2; height: 53px;
  padding: 4px 6px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.transport {
  display: grid; grid-template-columns: 44px 44px minmax(28px, 1fr) 52px 64px 44px;
  align-items: center; gap: 4px; height: 44px;
}
.transport > button, .transport > select { width: 100%; padding: 4px; font-size: 12px; }
#restart { font-size: 25px; font-weight: 400; line-height: 1; }
#play { display: flex; align-items: center; justify-content: center; }
#play > svg { width: 24px; height: 24px; fill: currentColor; }
#position { font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: center; }
#practice > summary {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; cursor: pointer; font-size: 26px;
  list-style: none; border-radius: 8px;
}
#practice > summary::-webkit-details-marker { display: none; }
#practice[open] > summary { background: var(--background); }
.options {
  position: absolute; top: 56px; right: 6px;
  width: min(360px, calc(100vw - 12px)); max-height: calc(100dvh - 66px);
  overflow: auto; padding: 16px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); color: var(--ink);
  box-shadow: 0 8px 24px #0003;
}
.options-heading { display: flex; justify-content: space-between; font-weight: 600; }
#duration { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.secondary, .practice-fields { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.secondary { font-size: 14px; }
.secondary > label { margin-left: auto; }
.practice-fields { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
.practice-fields label, .secondary label { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.practice-fields label { font-size: 14px; }
.seek { display: flex; align-items: center; min-height: 44px; }
.seek input { width: 100%; min-height: 44px; margin: 0; accent-color: var(--primary); }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); }
#page { min-width: 65px; text-align: center; }
.practice-fields p, #notice { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 8px 0 0; }
#notice { margin-top: 16px; }
#diagnostics summary { font-size: 13px; cursor: pointer; padding: 12px 0; }
#log { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 monospace; }
#message { padding: 12px 16px; line-height: 1.45; }
#message:empty { display: none; }
#message.error { border-bottom: 1px solid var(--line); }
#paper {
  flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; overflow-anchor: none;
  background: #fff; color: #111; padding: 4px;
}
.score-page { position: relative; width: 100%; }
.score-page > svg { display: block; width: 100%; height: auto; min-width: 0; margin: 0 auto; color: #111; fill: #111; }
#paper .sounding, #paper .sounding * { color: #145dff !important; fill: #145dff !important; stroke: #145dff !important; }
#paper .note-backing { fill: #dce9ff; stroke: #90b6ff; stroke-width: 12; pointer-events: none; }
#paper svg ellipse, #paper svg path, #paper svg polygon, #paper svg polyline, #paper svg rect { stroke: currentColor; }
#paper g.ending, #paper g.fing, #paper g.reh, #paper g.tempo { font-weight: bold; }
#paper g.dir, #paper g.dynam, #paper g.mNum { font-style: italic; }
#paper g.label { font-weight: normal; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#keyboard-panel { flex: none; padding: 4px 8px 8px; border-top: 1px solid var(--line); background: var(--surface); }
.keyboard-caption { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
#keyboard { display: block; width: 100%; height: clamp(54px, 12dvh, 100px); }
.piano-key { stroke-width: 1; vector-effect: non-scaling-stroke; }
.white-key { fill: #fff; stroke: #7b8494; }
.black-key { fill: #172030; stroke: #172030; }
.piano-key.active { fill: #145dff; stroke: #b9d2ff; stroke-width: 2; }
.key-label { fill: #5b616f; font-size: 9px; text-anchor: middle; pointer-events: none; }
.key-label.active { fill: #fff; }
[hidden] { display: none !important; }
