#replayDialog {
  width:min(1200px,96vw); height:min(920px,96dvh); max-height:100dvh; max-width:100vw;
  padding:clamp(10px,1.6vw,22px); margin:auto; color:#f8f4ff; background:#17151f;
  border:1px solid #52485f; border-radius:6px; overflow:hidden;
}
#replayDialog[open] { display:grid; grid-template-rows:auto minmax(0,1fr) auto auto; gap:8px; }
.replayHeader,.replayReading,.replayTimeRow { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.replayHeader { border-bottom:1px solid #786c8b59; padding-bottom:8px; }
.replayHeader > div { min-width:0; }
.replayHeaderActions { display:flex;align-items:center;gap:10px;flex-shrink:0; }
#replayDownload { display:inline-flex;align-items:center;gap:4px;color:var(--lav);padding:6px 2px;font:600 13px var(--mono); }
#replayDownload .ico { width:15px;height:15px; }
.replayHeader h2 { font:700 clamp(18px,2.1vw,31px)/1.05 var(--font,'Segoe UI',sans-serif); margin:2px 0; }
#replayMap,#replayCue { font-size:12px; color:#c7bdd4; }
#replaySheet { min-width:0; min-height:0; }
#replaySheet > :is(.score-toolbar,.score-caption) { display:none; }
#replaySheet .score-spread { margin:0; }
.replayPerformance { min-width:0; }
.replayReading { min-height:24px; font:13px/1.25 var(--mono); }
#replayChord { color:#f7f1fe; overflow-wrap:anywhere; }
#replayCue { text-align:right; }
#replayKeys { position:relative; display:flex; height:clamp(38px,6vh,62px); margin:4px 0 1px; overflow:hidden; }
.replayKey { display:flex; position:relative; flex:1; min-width:0; align-items:flex-end; justify-content:center; padding-bottom:2px; border-right:1px solid #514d59; background:#e8e2eb; border-radius:0 0 2px 2px; color:#38303f; font:600 clamp(8px,.8vw,11px) var(--mono); }
.replayKey.black { position:absolute; top:0; height:61%; transform:translateX(-50%); z-index:1; background:#292534; border-inline:1px solid #100d14; }
.replayKey.is-played { background:#c4a4ff; box-shadow:inset 0 -4px #8150c0; }
.replayKey.black.is-played { background:#9456e3; box-shadow:inset 0 -3px #e2caff; }
.replayTransport { min-width:0; border-top:1px solid #786c8b59; padding-top:6px; }
.replayTimeRow { font:11px/1.2 var(--mono); color:#d8cfdf; }
#replayTime { font-variant-numeric:tabular-nums; white-space:nowrap; }
.replayMarkLegend { display:flex; gap:12px; }
.replayMarkLegend span::before { content:''; display:inline-block; width:2px; height:7px; margin-right:4px; background:#fbf7ff; }
.replayMarkLegend span:last-child::before { height:10px; border-top:2px solid #ff7087; background:#ff7087; width:4px; }
#replayMarks { position:relative; height:18px; cursor:crosshair; margin:0 8px; }
.replayMark { position:absolute; bottom:1px; transform:translateX(-50%); width:8px; height:100%; background:transparent; border:0; padding:0; cursor:pointer; }
.replayMark::after { content:''; display:block; position:absolute; bottom:0; left:50%; height:8px; width:2px; background:#fcf7ff; }
.replayMark[data-tone="error"]::after { background:#ff6b82; height:14px; }
.replayMark[data-tone="error"]::before { content:''; display:block; position:absolute; left:calc(50% - 2px); bottom:12px; width:6px; height:2px; background:#ff6b82; }
#replaySeek { display:block; width:100%; cursor:pointer; height:12px; margin:0 0 7px; accent-color:#c9abff; }
.replayControls,.replayRate,.replaySkip,.replayAudio { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
.replayControls .btn,.replayControls .primary,.replayControls select { min-height:29px; padding:4px 9px; font-size:13px; }
.replayControls #replayPlay { min-width:86px; }
.replayRate { margin-left:auto; gap:2px; }
.replayRate .btn { min-width:28px; }
.replayAudio { cursor:pointer; font-size:13px; white-space:nowrap; margin-left:5px; }
#replayScoreLegendBox { position:relative; margin:0; font-size:12px; }
#replayScoreLegend { position:absolute; right:0; bottom:100%; z-index:2; width:min(280px,82vw); max-height:45dvh; overflow:auto; padding:10px; color:#eee7f5; background:#211d2b; }
#replayDialog #pianoMenu { margin:0; padding:2px 0; box-shadow:none; border-width:1px 0 0; border-radius:0; }
@media(max-width:680px) {
  #replayDialog { width:100vw; height:100dvh; border:0; border-radius:0; }
  #replayDialog[open] { gap:5px; }
  .replayRate { margin-left:0; }
  .replayControls { gap:5px; }
  .replayControls .btn,.replayControls .primary,.replayControls select { min-height:30px; }
}
@media(max-height:500px) {
  #replayDialog { width:100vw; height:100dvh; padding:5px 10px; }
  #replayDialog[open] { gap:2px; }
  .replayHeader { padding-bottom:3px; }
  .replayHeader .sectionLabel { display:none; }
  #replayKeys { height:28px; }
  .replayReading { min-height:18px; }
  .replayTransport { padding-top:2px; }
  #replayMarks { height:15px; }
}
