:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1b1b1b;
  background: #f7f7f4;
}

body {
  margin: 0;
  background: #f7f7f4;
}

#score {
  position: relative;
  padding: 26px;
  /* Practice gestures own double-tap and long-press on the score: no double-tap zoom, callout or text selection. */
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.empty-state {
  margin: 40px auto;
  max-width: 520px;
  color: #716c66;
  text-align: center;
}

body.selectable .measure,
.syncotonic-surface.selectable .measure {
  cursor: pointer;
}

#web-transport {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 26px;
  border-top: 1px solid #ddd9cf;
  background: #f7f7f4e8;
  backdrop-filter: blur(12px);
}

#web-transport[hidden] {
  display: none;
}

#web-transport button {
  padding: 8px 14px;
  border: 1px solid #b9b3a8;
  border-radius: 8px;
  background: white;
  font: inherit;
}

#web-transport input {
  width: 140px;
}

@media (max-width: 600px) {
  #score {
    padding: 12px;
  }

  #web-transport {
    flex-wrap: wrap;
    padding: 10px 12px;
  }
}

/* The engraving is one SVG for the whole score. Each bar's background rectangle (`.measure-bg`, added by
   the surface) carries the playing, selected, changed and problem highlights, and catches clicks on empty parts of a bar. */
#score > svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Verovio's own stylesheet strokes every rect with an id selector, hence the !important on the strokes. */
.measure-bg {
  fill: transparent;
  stroke: none !important;
  pointer-events: all;
}

/* Palette: blue means playback (the bar being played, the notes sounding), sand means a chosen bar or run of bars on
   the paper, orange marks the selected note, gold outlines a changed bar, and pink marks a bar whose notes do not add
   up (under the other highlights, so a chosen or playing bar still shows as such). */
g.measure.problem > .measure-bg {
  fill: #fbe4e1;
}

g.measure.active > .measure-bg {
  fill: #e6f0fa;
}

g.measure.selected > .measure-bg {
  fill: #ebe5d6;
}

g.measure.in-range > .measure-bg {
  fill: #ddd4bf;
}

g.measure.selected.problem > .measure-bg {
  fill: #f2d3cd;
}

g.measure.selected.active > .measure-bg {
  fill: #d3e4f4;
}

/* Marks and highlights may reach past the engraving's edge, hence the visible overflow. */
#score svg {
  overflow: visible;
}

g.measure.changed > .measure-bg {
  stroke: #e0a526 !important;
  stroke-width: 20;
}

/* Staff lines must not swallow clicks, and hollow noteheads (half and whole notes) are clickable across their box. */
#score g.staff > path,
#score g.ledgerLines,
#score g.ledgerLines * {
  pointer-events: none;
}

/* The hit rectangle round each note and rest is invisible until hovered while editing. Its colours are forced so the
   selected and playing note styles, which colour every child of the note, do not fill it. */
#score .note-target {
  fill: transparent !important;
  stroke: none !important;
  pointer-events: all;
}

body.editable #score g:hover > .note-target,
.syncotonic-surface.editable #score g:hover > .note-target {
  fill: rgba(29, 53, 65, 0.07) !important;
  stroke: rgba(29, 53, 65, 0.55) !important;
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
}

#score g.note .notehead,
#score g.note .notehead * {
  pointer-events: bounding-box;
}

body.editable g.note,
body.editable g.rest,
.syncotonic-surface.editable g.note,
.syncotonic-surface.editable g.rest {
  cursor: pointer;
}

g.note.syncotonic-selected,
g.note.syncotonic-selected *,
g.rest.syncotonic-selected,
g.rest.syncotonic-selected * {
  fill: #d86631;
  stroke: #d86631;
}

g.note.playing-note,
g.note.playing-note * {
  fill: #1f6fb2;
  stroke: #1f6fb2;
}

/* The practice range's handles: a line at each end with a knob, above the first bar and below the last, as text
   selection draws them. The hit area is 44px wide so a finger can take it. */
.range-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.range-handle {
  position: absolute;
  width: 44px;
  margin-left: -22px;
  pointer-events: auto;
  touch-action: none;
  cursor: ew-resize;
}

.range-layer.dragging .range-handle {
  pointer-events: none;
}

.range-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 20px;
  width: 4px;
  border-radius: 2px;
  background: #8a6d2b;
}

.range-handle::after {
  content: "";
  position: absolute;
  left: 12px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #8a6d2b;
}

.range-handle.start::after {
  top: -16px;
}

.range-handle.end::after {
  bottom: -16px;
}

/* The bar menu opened by a long-press or a right-click. */
.syncotonic-bar-menu {
  position: fixed;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  padding: 6px;
  border: 1px solid #ddd9cf;
  border-radius: 12px;
  background: #fffdf8;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

.syncotonic-bar-menu-title {
  padding: 6px 12px 4px;
  color: #716c66;
  font-size: 13px;
}

.syncotonic-bar-menu button {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #1b1b1b;
  font: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}

.syncotonic-bar-menu-rule {
  height: 1px;
  margin: 4px 8px;
  background: #ddd9cf;
}

.syncotonic-bar-menu button:hover,
.syncotonic-bar-menu button:focus-visible {
  background: #ebe5d6;
}

/* A voice that is not heard (muted, or left out by a solo) is drawn faded, so the score shows what will sound. A
   chord, beam or tuplet whose notes are all faded fades its own marks (stem, beam lines, dots, bracket) too. */
#score g.muted-note,
#score g.outside-note {
  opacity: 0.25;
}

#score g.muted-group > :not(.note):not(.rest):not(.chord):not(.beam):not(.tuplet),
#score g.outside-group > :not(.note):not(.rest):not(.chord):not(.beam):not(.tuplet) {
  opacity: 0.25;
}

/* Practice hints (`.practice-hint`, added by the surface while a viewed score plays): the count-in in large numbers,
   a dot per beat of the bar that lights on the beat, the pass of a loop, and a ring that drains through the gap
   between passes. It sits at the foot of the view, clear of the playing bar (which is scrolled to the middle), and
   never takes a touch. */
.practice-hint {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 15;
  display: flex;
  gap: 14px;
  align-items: center;
  min-height: 44px;
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(27, 27, 27, 0.86);
  color: #fffdf8;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  transform: translateX(-50%);
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.practice-hint[hidden] {
  display: none;
}

/* The standalone surface's own transport is sticky at the bottom: sit above it. */
body:has(#web-transport:not([hidden])) .practice-hint {
  bottom: 84px;
}

.practice-hint .hint-count {
  min-width: 1ch;
  font-size: 40px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
}

.practice-hint .hint-label {
  color: #ddd6c6;
  font-size: 14px;
  white-space: nowrap;
}

.practice-hint .hint-dots {
  display: flex;
  gap: 10px;
  align-items: center;
}

.practice-hint .hint-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.28);
}

.practice-hint .hint-dots span.down {
  width: 14px;
  height: 14px;
}

.practice-hint .hint-dots span.on {
  background: #f2c14e;
  animation: hint-pulse 0.25s ease-out;
}

.practice-hint .hint-ring {
  position: relative;
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
}

.practice-hint .hint-ring svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.practice-hint .hint-ring circle {
  fill: none;
  stroke: rgba(255, 253, 248, 0.25);
  stroke-width: 3;
}

.practice-hint .hint-ring circle.hint-drain {
  stroke: #f2c14e;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  animation-name: hint-drain;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.practice-hint .hint-ring .hint-count {
  font-size: 22px;
}

@keyframes hint-pulse {
  from { transform: scale(1.6); }
  to { transform: scale(1); }
}

@keyframes hint-drain {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 94.25; }
}

@media (prefers-reduced-motion: reduce) {
  .practice-hint .hint-dots span.on { animation: none; }
}

@media (max-width: 600px) {
  .practice-hint { bottom: 16px; padding: 6px 16px; }
  .practice-hint .hint-count { font-size: 32px; }
}
