/* Music stand (perform view) auto-scroll + sticky song headers */

.ms-autoscroll-anchor {
  height: 0;
  margin: 0;
  padding: 0;
}

.ms-autoscroll-spacer {
  height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

/* Jump control lives in the sticky autoscroll bar */
.ms-jump-inline {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  order: 2;
  margin: 0;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border-gray, #495057);
  border-radius: 4px;
  background: #3a3a3a;
  color: #eee;
  font-size: 1.0625rem;
  -webkit-user-select: none;
  user-select: none;
}

.ms-jump-inline:hover {
  background: #454545;
}

.ms-jump-inline-label {
  font-variant-numeric: tabular-nums;
}

.ms-jump-sheet {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;
}

.ms-jump-sheet[hidden] {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden;
}

.ms-jump-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.ms-jump-sheet-panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--bg-darker, #1f1f1f);
  color: #eee;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  padding: 0.75rem 0.85rem 1rem;
}

.ms-jump-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.ms-jump-sheet-header h2 {
  font-size: 1.25rem;
  margin: 0;
  color: #fff;
}

.ms-jump-sheet-close {
  border: 0;
  background: transparent;
  color: #bbb;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
}

.ms-jump-filter {
  width: 100%;
  margin-bottom: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #555;
  background: #2a2a2a;
  color: #fff;
  font-size: 1.1875rem;
}

.ms-jump-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ms-jump-set {
  font-size: 0.9375rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9aa0a6;
  padding: 0.65rem 0.35rem 0.25rem;
}

.ms-jump-item {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  width: 100%;
  padding: 0.7rem 0.5rem;
  border: 0;
  border-bottom: 1px solid #333;
  background: transparent;
  color: #eee;
  text-align: left;
  font-size: 1.1875rem;
  cursor: pointer;
  min-height: 48px;
}

.ms-jump-item:hover,
.ms-jump-item:focus-visible {
  background: #333;
  outline: none;
}

.ms-jump-item.is-current {
  background: rgba(13, 110, 253, 0.22);
}

.ms-jump-item-num {
  flex: 0 0 2rem;
  font-variant-numeric: tabular-nums;
  color: #9aa0a6;
}

.ms-jump-item-title {
  flex: 1 1 auto;
  min-width: 0;
}

.ms-jump-item-meta {
  flex: 0 0 auto;
  font-size: 1.0375rem;
  color: #9aa0a6;
}

.ms-jump-item[hidden],
.ms-jump-set[hidden] {
  display: none !important;
}

@media (min-width: 768px) {
  .ms-jump-sheet {
    align-items: center;
  }
  .ms-jump-sheet-panel {
    border-radius: 12px;
    max-height: min(70vh, 560px);
  }
}

.ms-autoscroll {
  position: sticky;
  top: 0;
  z-index: 1100;
  margin: 0 0 1.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-darker, #2d2d2d);
  border: 1px solid var(--border-gray, #495057);
  border-radius: 8px;
  transition: box-shadow 0.2s ease;
  pointer-events: auto;
  isolation: isolate;
}

.ms-autoscroll.is-pinned {
  position: fixed;
  top: 0;
  left: var(--ms-bar-left, 0);
  width: var(--ms-bar-width, 100%);
  max-width: 100%;
  margin-bottom: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 1100;
  box-sizing: border-box;
}

/* Phones: pin edge-to-edge — measured column width is flaky on iOS Chrome */
@media (max-width: 768px) {
  .ms-autoscroll.is-pinned {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    border-radius: 0;
  }
}

.ms-autoscroll-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.ms-autoscroll-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-header-muted, #d4d4d4);
  margin-right: 0.15rem;
}

.ms-autoscroll-transport {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  flex: 0 0 auto;
}

.ms-autoscroll-transport[hidden] {
  display: none !important;
}

/* Transport + shared button base */
.ms-autoscroll-transport .ms-btn,
.ms-jump-inline.ms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.6rem;
  font-size: 1.0625rem;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
}

.ms-autoscroll-transport .ms-btn:first-child { border-radius: 4px 0 0 4px; }
.ms-autoscroll-transport .ms-btn:last-child  { border-radius: 0 4px 4px 0; }
.ms-autoscroll-transport .ms-btn:not(:first-child) { margin-left: -1px; }

.ms-btn-secondary {
  color: #adb5bd;
  border-color: #6c757d;
}
.ms-btn-secondary:hover { background: rgba(108,117,125,.15); }
.ms-btn-secondary:disabled { opacity: 0.45; cursor: default; }

.ms-btn-primary {
  color: #0d6efd;
  border-color: #0d6efd;
}
.ms-btn-primary:hover { background: rgba(13,110,253,.12); }
.ms-btn-primary.playing {
  background: #198754;
  border-color: #198754;
  color: #fff;
}

.ms-autoscroll-fwd[hidden] {
  display: none !important;
}

.ms-autoscroll-chevron {
  font-size: 1.3rem;
  line-height: 1;
  font-weight: 700;
}

.ms-autoscroll-play {
  min-width: 2.5rem;
}

.ms-autoscroll-play .bi {
  font-size: 1.3rem;
  line-height: 1;
}

.ms-autoscroll-play-icon[hidden],
.ms-autoscroll-pause-icon[hidden] {
  display: none !important;
}

/* Speed slider always lives on its own second row */
.ms-autoscroll-speed {
  order: 10;
  flex: 0 0 100%;
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  position: relative;
  z-index: 0;
}

.ms-autoscroll-speed-label {
  font-size: 1rem;
  margin: 0;
  color: var(--text-muted, #aaa);
  white-space: nowrap;
}

.ms-autoscroll-range {
  flex: 1 1 4rem;
  min-width: 4rem;
  accent-color: var(--color-primary, #0d6efd);
}

.ms-autoscroll-speed-out {
  display: inline-block;
  min-width: 1.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-header-muted, #d4d4d4);
  text-align: center;
}

.ms-autoscroll-close {
  margin-left: auto;
  order: 9;
  padding: 0 0.35rem;
  font-size: 1.45rem;
  line-height: 1;
  text-decoration: none;
}

.ms-autoscroll-close:hover {
  color: var(--text-header-muted, #d4d4d4) !important;
}

.ms-autoscroll-hint {
  order: 11;
  font-size: 0.9375rem;
  color: var(--text-muted, #aaa);
  margin: 0;
  flex: 0 0 100%;
}

/* Collapsed: hide bar, no sticky headers, minimal restore chip */
html.ms-autoscroll-dismissed .ms-autoscroll {
  display: none;
}

html.ms-autoscroll-dismissed .ms-autoscroll-spacer {
  height: 0 !important;
}

.ms-autoscroll-restore {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
  padding: 0.2rem 0.55rem;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--text-muted, #aaa);
  background: var(--bg-darker, #2d2d2d);
  border: 1px solid var(--border-gray, #495057);
  border-radius: 6px;
  cursor: pointer;
}

.ms-autoscroll-restore:hover {
  color: var(--text-header-muted, #d4d4d4);
  border-color: var(--color-primary, #0d6efd);
}

.ms-autoscroll-restore[hidden] {
  display: none !important;
}

/* Song title scrolls up, then sticks under the pinned auto-scroll bar.
   Ancestors of .song-header must keep overflow: visible or sticky dies. */
.song-document {
  overflow: visible !important;
}

/* Panel strip: bg-darker (not bg-darkest) so it stays visible vs card/chart below */
.song-document .song-header,
.song-document > .song-header {
  padding: 11px;
  background-color: var(--bg-darker, #2d2d2d) !important;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--color-primary, #007bff);
}

.song-document .song-header.ms-sticky-header,
.song-header.ms-sticky-header {
  position: sticky;
  top: var(--ms-header-sticky-top, var(--ms-bar-height, 52px));
  scroll-margin-top: var(--ms-header-sticky-top, var(--ms-bar-height, 52px));
  z-index: 1020;
  background-color: var(--bg-darker, #2d2d2d) !important;
}

html.ms-autoscroll-dismissed .song-document .song-header.ms-sticky-header,
html.ms-autoscroll-dismissed .song-header.ms-sticky-header {
  top: 0;
  scroll-margin-top: 0;
  background-color: var(--bg-darker, #2d2d2d) !important;
}

.song-document .song-header.ms-sticky-header h2 {
  margin-bottom: 0.25rem;
}

@media (max-width: 576px) {
  .ms-autoscroll-hint {
    display: none;
  }

  .ms-autoscroll {
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.5rem;
  }

  .ms-autoscroll-range {
    max-width: none;
  }
}

@media print {
  .ms-autoscroll,
  .ms-autoscroll-anchor,
  .ms-autoscroll-spacer,
  .ms-autoscroll-restore,
  .ms-jump-sheet {
    display: none !important;
  }

  .song-document .song-header,
  .song-document > .song-header,
  .song-document .song-header.ms-sticky-header,
  .song-header.ms-sticky-header {
    position: static;
    background-color: transparent !important;
    border-bottom-color: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Auto-scroll is user-initiated — keep controls. Only drop decorative motion. */
  .ms-autoscroll {
    transition: none;
  }
}
