* {
  box-sizing: border-box;
}

:root {
  --text-scale: 1;
  --nav-font: calc(0.85rem * var(--text-scale));
  --label-font: calc(0.85rem * var(--text-scale));
  --menu-font: calc(0.8rem * var(--text-scale));
  --nav-muted: var(--muted);
  --nav-text: var(--text);
  --nav-active: var(--show-accent);
  --nav-bg: var(--bg);
  --nav-border: var(--border);
  --page-bg: var(--panel-inset);
  --page-text: var(--text);
  --now-green: var(--edit-accent-soft);
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--page-bg);
  color: var(--page-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

button,
.display-nav a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus {
  outline: none;
}

button:focus-visible,
.display-nav a:focus-visible {
  outline: 2px solid var(--nav-active);
  outline-offset: 2px;
}

body.high-contrast {
  --nav-muted: #ffffff;
  --nav-text: #ffffff;
  --nav-active: var(--rehearsal-accent);
  --nav-bg: #000000;
  --nav-border: #ffffff;
  --page-bg: #000000;
  --page-text: #ffffff;
  --now-green: var(--edit-accent-soft);
}

body.rehearsal-mode {
  --nav-active: var(--rehearsal-accent);
  --show-accent: var(--rehearsal-accent);
  --show-accent-hover: var(--rehearsal-accent-hover);
  --show-accent-soft: var(--rehearsal-accent-soft);
  --show-accent-bright: var(--rehearsal-accent-soft);
  --show-accent-pale: var(--rehearsal-accent-frost-text);
  --accent: var(--rehearsal-accent);
  --accent-hover: var(--rehearsal-accent-hover);
  --accent-soft: var(--rehearsal-accent-soft);
}

body.edit-mode {
  --nav-active: var(--edit-accent);
  --show-accent: var(--edit-accent);
  --show-accent-hover: var(--edit-accent-hover);
  --show-accent-soft: var(--edit-accent-soft);
  --accent: var(--edit-accent);
  --accent-hover: var(--edit-accent-hover);
  --accent-soft: var(--edit-accent-soft);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.display-header {
  flex: 0 0 auto;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--nav-bg);
  border-bottom: 2px solid var(--nav-border);
  overflow: visible;
}

.display-nav-row {
  display: flex;
  align-items: stretch;
  min-height: 0;
  width: 100%;
}

.display-settings {
  position: relative;
  flex: 0 0 auto;
  z-index: 35;
  overflow: visible;
  border-right: 1px solid var(--nav-border);
}

.display-nav-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.display-nav-scroll::-webkit-scrollbar {
  height: 4px;
}

.display-nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

body.high-contrast .display-settings {
  border-right-width: 2px;
}

.settings-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 100%;
  min-height: 2.75rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--nav-muted);
  cursor: pointer;
}

.display-settings.open {
  z-index: 60;
}

.display-settings.open .settings-toggle {
  color: var(--nav-active);
  background: rgba(255, 255, 255, 0.06);
}

@media (hover: hover) and (pointer: fine) {
  .settings-toggle:hover {
    color: var(--nav-active);
    background: rgba(255, 255, 255, 0.06);
  }
}

.settings-toggle:active {
  opacity: 0.82;
}

body.high-contrast .settings-toggle {
  color: #ffffff;
  border-right: 2px solid var(--nav-border);
}

body.high-contrast .display-settings.open .settings-toggle {
  background: var(--rehearsal-accent);
  color: var(--on-rehearsal);
}

@media (hover: hover) and (pointer: fine) {
  body.high-contrast .settings-toggle:hover {
    background: var(--rehearsal-accent);
    color: var(--on-rehearsal);
  }
}

.settings-icon {
  display: block;
}

.settings-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  min-width: 13.5rem;
  padding: 0.55rem;
  background: var(--nav-bg);
  border: 1px solid var(--nav-border);
  border-top: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

body.high-contrast .settings-menu {
  border-width: 2px;
}

.settings-menu.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.settings-item {
  display: block;
  width: 100%;
  margin: 0;
}

.settings-item + .settings-item {
  margin-top: 0.45rem;
}

.settings-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: var(--menu-font);
  font-weight: 600;
  color: var(--nav-muted);
}

body.high-contrast .settings-label {
  color: #ffffff;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.text-size-control input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--nav-active);
}

body.high-contrast .text-size-control input[type="range"] {
  accent-color: var(--rehearsal-accent);
}

.settings-value {
  min-width: 2.75rem;
  font-size: var(--menu-font);
  font-variant-numeric: tabular-nums;
  color: var(--nav-text);
  text-align: right;
}

.settings-toggle-btn {
  background: transparent;
  border: 1px solid var(--nav-border);
  color: var(--nav-text);
  border-radius: 6px;
  padding: calc(0.45rem * var(--text-scale)) calc(0.6rem * var(--text-scale));
  font-size: var(--menu-font);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.settings-action-btn {
  background: transparent;
  border: 1px solid var(--nav-border);
  color: var(--nav-text);
  border-radius: 6px;
  padding: calc(0.45rem * var(--text-scale)) calc(0.6rem * var(--text-scale));
  font-size: var(--menu-font);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.settings-text-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--nav-border);
  border-radius: 6px;
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: calc(0.4rem * var(--text-scale)) calc(0.55rem * var(--text-scale));
  font-size: var(--menu-font);
  font-family: inherit;
}

.settings-text-input:focus {
  outline: 2px solid var(--nav-active);
  outline-offset: 1px;
}

.display-device-name-field.hidden {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .settings-toggle-btn:hover,
  .settings-action-btn:hover {
    border-color: var(--nav-active);
    color: var(--nav-active);
  }
}

.settings-toggle-btn:active,
.settings-action-btn:active {
  opacity: 0.82;
}

.settings-toggle-btn[aria-pressed="true"],
.settings-action-btn[aria-pressed="true"] {
  background: var(--nav-active);
  border-color: var(--nav-active);
  color: #ffffff;
}

body.high-contrast .settings-toggle-btn {
  border-width: 2px;
  color: #ffffff;
}

body.high-contrast .settings-action-btn {
  border-width: 2px;
  color: #ffffff;
}

body.high-contrast .settings-toggle-btn[aria-pressed="true"],
body.high-contrast .settings-action-btn[aria-pressed="true"] {
  background: var(--rehearsal-accent);
  border-color: var(--rehearsal-accent);
  color: var(--on-rehearsal);
}

.display-nav {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-wrap: nowrap;
  width: max-content;
  min-width: 100%;
}

.display-nav a {
  flex-shrink: 0;
  padding: calc(0.55rem * var(--text-scale)) calc(0.9rem * var(--text-scale));
  font-size: var(--nav-font);
  font-weight: 500;
  color: var(--nav-muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .display-nav a:hover {
    color: var(--nav-text);
    background: rgba(255, 255, 255, 0.08);
  }
}

.display-nav a:active {
  opacity: 0.82;
}

.display-nav a.active {
  color: var(--nav-active);
  border-bottom-color: var(--nav-active);
  font-weight: 700;
}

body.high-contrast .display-nav a {
  font-weight: 700;
  border: 2px solid var(--nav-border);
  border-bottom: 3px solid var(--nav-border);
  margin: 0.15rem 0.1rem 0;
  border-radius: 6px;
}

body.high-contrast .display-nav a.active {
  background: var(--nav-active);
  color: #000000;
  border-color: var(--nav-active);
}

.chart-viewport {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.5rem;
  min-height: 0;
  background: var(--page-bg);
  position: relative;
}

.chart-stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  perspective: 1600px;
  transform-style: preserve-3d;
}

.chart-sheet {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: perspective(1600px) rotateY(-24deg) scale(0.985);
  transform-origin: left center;
  transition:
    opacity 0.48s ease,
    transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
  backface-visibility: hidden;
  will-change: transform, opacity;
  overflow: hidden;
  min-height: 0;
}

.chart-sheet.is-visible {
  opacity: 1;
  transform: perspective(1600px) rotateY(0deg) scale(1);
  z-index: 2;
}

.chart-sheet.is-exiting {
  opacity: 0;
  transform: perspective(1600px) rotateY(26deg) scale(0.99);
  transform-origin: right center;
  z-index: 1;
  transition:
    opacity 0.38s ease,
    transform 0.55s cubic-bezier(0.55, 0, 0.45, 1);
}

.chart-sheet--empty {
  padding: 0.5rem;
  overflow-y: auto;
}

.chart-sheet--background {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.chart-sheet--media {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  padding: 0;
}

.display-media-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.display-media-image,
.display-media-video {
  width: 100%;
  height: 100%;
  max-height: 100vh;
}

.media-aspect-cover .display-media-image,
.media-aspect-cover .display-media-video {
  object-fit: cover;
}

.media-aspect-fill .display-media-image,
.media-aspect-fill .display-media-video {
  object-fit: contain;
}

.media-aspect-stretch .display-media-image,
.media-aspect-stretch .display-media-video {
  object-fit: fill;
}

.chart-sheet--media .display-media-image,
.chart-sheet--media .display-media-video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
}

.chart-sheet--background .chart-lan-background {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  box-shadow: none;
}

.chart-sheet--background .chart-lan-background.lan-background-aspect-cover {
  object-fit: cover;
}

.chart-sheet--background .chart-lan-background.lan-background-aspect-fill {
  object-fit: contain;
}

.chart-sheet--background .chart-lan-background.lan-background-aspect-stretch {
  object-fit: fill;
}

.chart-viewport img,
.chart-sheet img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.chart-viewport embed,
.chart-sheet embed {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

body.night-mode .chart-viewport img,
body.night-mode .chart-viewport embed,
body.night-mode .chart-sheet img,
body.night-mode .chart-sheet embed {
  filter: invert(1) hue-rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .chart-sheet {
    transform: none !important;
    transition: opacity 0.22s ease !important;
  }

  .chart-sheet.is-exiting {
    transform: none !important;
  }
}

.chart-viewport .placeholder {
  color: var(--nav-muted);
  text-align: center;
  max-width: 24rem;
  line-height: 1.5;
  padding: 1rem;
  font-size: var(--label-font);
}

.display-empty-state {
  max-width: min(32rem, 92vw);
  max-height: 100%;
  margin: 0 auto;
  padding: calc(1.75rem * var(--text-scale)) calc(1.5rem * var(--text-scale));
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--nav-border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.display-empty-badge {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.3rem 0.75rem;
  font-size: calc(0.72rem * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--nav-active);
  background: rgba(59, 130, 224, 0.12);
  border: 1px solid rgba(59, 130, 224, 0.35);
  border-radius: 999px;
}

.display-empty-title {
  margin: 0 0 0.85rem;
  font-size: calc(1.5rem * var(--text-scale));
  font-weight: 700;
  line-height: 1.2;
  color: var(--nav-text);
}

.display-empty-message {
  margin: 0;
  font-size: calc(1.05rem * var(--text-scale));
  line-height: 1.55;
  color: var(--nav-muted);
}

.display-empty-message strong {
  color: var(--nav-text);
  font-weight: 700;
}

.display-empty-filename-label {
  margin: 1.15rem 0 0.45rem;
  font-size: calc(0.8rem * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--nav-muted);
}

.display-empty-filename {
  margin: 0;
  padding: 0.65rem 0.85rem;
  font-size: calc(1rem * var(--text-scale));
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.4;
  color: var(--nav-text);
  background: rgba(59, 130, 224, 0.1);
  border: 1px solid rgba(59, 130, 224, 0.28);
  border-radius: 10px;
  word-break: break-word;
}

body.high-contrast .display-empty-state {
  background: #111111;
  border-width: 3px;
  border-color: #ffffff;
}

body.high-contrast .display-empty-badge {
  color: var(--on-rehearsal);
  background: var(--rehearsal-accent);
  border-color: var(--rehearsal-accent);
}

body.high-contrast .display-empty-title,
body.high-contrast .display-empty-message strong {
  color: #ffffff;
}

body.high-contrast .display-empty-message,
body.high-contrast .display-empty-filename-label {
  color: #dddddd;
}

body.high-contrast .display-empty-filename {
  color: var(--on-rehearsal);
  background: var(--rehearsal-accent);
  border-color: var(--rehearsal-accent);
}

body.high-contrast .chart-viewport .placeholder {
  color: #ffffff;
  font-weight: 600;
}

.playback-footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 0 0 auto;
  flex-shrink: 0;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  min-height: calc(2.75rem * var(--text-scale));
  position: sticky;
  bottom: 0;
  z-index: 30;
}

.shelf-toggle {
  flex-shrink: 0;
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--nav-border);
  color: var(--nav-text);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: calc(0.78rem * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.shelf-toggle:active {
  opacity: 0.82;
}

@media (hover: hover) and (pointer: fine) {
  .shelf-toggle:hover {
    border-color: var(--nav-active);
    color: var(--nav-active);
  }
}

.part-badge.missing {
  background: var(--chart-missing-bg);
  color: var(--chart-missing);
}

.part-badges-waffle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid var(--nav-border);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.15);
  color: var(--nav-muted);
  cursor: pointer;
  flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
  .part-badges-waffle:hover {
    border-color: var(--nav-active);
    color: var(--nav-active);
  }
}

.chart-badge-menu {
  position: fixed;
  z-index: 1200;
  min-width: 10rem;
  padding: 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--nav-border);
  background: var(--nav-bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.chart-waffle-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--nav-text);
  font: inherit;
  font-size: var(--menu-font);
  text-align: left;
}

.chart-waffle-menu-label {
  flex: 1;
  min-width: 0;
}

.shelf-toggle.has-setlist-update::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--nav-bg);
  pointer-events: none;
}

.footer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.footer-now,
.footer-upnext {
  font-size: var(--label-font);
  font-weight: 500;
  color: var(--nav-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(42vw, 18rem);
}

.footer-now.has-song {
  color: var(--now-green);
  font-weight: 700;
}

.footer-upnext.has-song {
  color: var(--nav-text);
}

.footer-divider {
  color: var(--nav-border);
  font-size: calc(0.85rem * var(--text-scale));
  user-select: none;
}

.playback-footer:not(.has-control) .footer-transport-sep,
.playback-footer:not(.has-control) .footer-transport-btn,
.playback-footer:not(.has-control) .footer-break-btn {
  display: none;
}

.footer-transport-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--nav-border);
  color: var(--nav-text);
  border-radius: 6px;
  padding: 0.28rem 0.6rem;
  font-size: calc(0.78rem * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.footer-transport-btn:active:not(:disabled) {
  opacity: 0.82;
}

@media (hover: hover) and (pointer: fine) {
  .footer-transport-btn:hover:not(:disabled) {
    border-color: var(--nav-active);
    color: var(--nav-active);
  }
}

.footer-transport-btn:disabled {
  opacity: 0.4;
  cursor: default;
  background: rgba(255, 255, 255, 0.04);
  color: var(--nav-muted);
  border-color: var(--nav-border);
}

body:not(.edit-mode) .footer-transport-btn.is-available:not(:disabled) {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent, #fff);
}

body.high-contrast .footer-now.has-song {
  color: var(--now-green);
  font-weight: 800;
}

body.high-contrast .footer-now,
body.high-contrast .footer-upnext {
  color: #ffffff;
  font-weight: 700;
}

.display-lock-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--nav-border);
  color: var(--nav-muted);
  border-radius: 6px;
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
}

.display-lock-btn:active {
  opacity: 0.82;
}

@media (hover: hover) and (pointer: fine) {
  .display-lock-btn:hover {
    border-color: var(--nav-active);
    color: var(--nav-active);
  }
}

.shelf-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.45);
}

.display-shelf {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  width: min(88vw, 22rem);
  display: flex;
  flex-direction: column;
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  transform: translateX(-105%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.display-shelf.open {
  transform: translateX(0);
}

.display-shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--nav-border);
}

.display-shelf-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.shelf-list-prefs {
  position: relative;
}

.shelf-list-prefs-btn {
  background: transparent;
  border: 1px solid var(--nav-border);
  color: var(--nav-text);
  border-radius: 6px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

@media (hover: hover) and (pointer: fine) {
  .shelf-list-prefs-btn:hover,
  .shelf-list-prefs-btn[aria-expanded="true"] {
    border-color: var(--nav-active);
    color: var(--nav-active);
  }
}

.shelf-list-prefs-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 120;
  min-width: 11.5rem;
  padding: 0.4rem;
  background: var(--nav-bg);
  border: 1px solid var(--nav-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.shelf-list-pref-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--nav-text);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .shelf-list-pref-item:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

.shelf-list-pref-item[aria-checked="false"] .shelf-list-pref-label {
  color: var(--nav-muted);
}

.shelf-list-pref-eye {
  display: inline-flex;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: var(--nav-active);
}

.shelf-list-pref-divider {
  height: 1px;
  margin: 0.35rem 0;
  background: var(--nav-border);
}

.shelf-song-btn .part-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-left: auto;
  flex-shrink: 1;
  justify-content: flex-end;
}

.shelf-song-btn .part-badge {
  font-size: 0.62rem;
  font-weight: 700;
  width: 1.15rem;
  height: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  flex-shrink: 0;
}

.shelf-song-btn .part-badge.has {
  background: var(--chart-available-bg);
  color: var(--chart-available);
}

.shelf-song-btn .part-badge.pushed {
  background: var(--chart-pushed-bg);
  color: var(--chart-pushed);
}

.shelf-song-btn .part-badge.has-pushed {
  background: linear-gradient(
    135deg,
    var(--chart-pushed) 0%,
    var(--chart-pushed) 50%,
    var(--chart-available) 50%,
    var(--chart-available) 100%
  );
  color: var(--on-accent);
}

.shelf-song-btn .part-badge.missing {
  background: var(--chart-missing-bg);
  color: var(--chart-missing);
}

.shelf-song-btn .type-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--nav-active);
  text-transform: uppercase;
  flex-shrink: 0;
}

.shelf-song-row-break .shelf-song-btn {
  font-style: italic;
}

.display-shelf-title {
  margin: 0;
  font-size: calc(0.95rem * var(--text-scale));
  font-weight: 700;
  color: var(--nav-text);
}

.shelf-close-btn {
  background: transparent;
  border: 1px solid var(--nav-border);
  color: var(--nav-muted);
  border-radius: 6px;
  width: 2rem;
  height: 2rem;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.shelf-close-btn:active {
  opacity: 0.82;
}

@media (hover: hover) and (pointer: fine) {
  .shelf-close-btn:hover {
    border-color: var(--nav-active);
    color: var(--nav-active);
  }
}

.display-shelf-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.shelf-song-row {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  margin-bottom: 0.1rem;
}

.shelf-song-row.shelf-reorder-slide {
  position: relative;
  z-index: 2;
  will-change: transform;
  transition: none !important;
}

.shelf-song-row.shelf-reorder-slider {
  z-index: 3;
}

.shelf-song-row.shelf-reorder-ghost {
  position: fixed;
  z-index: 5000;
  margin: 0;
  pointer-events: none;
  border-radius: 8px;
  background: rgba(17, 24, 33, 0.98);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  will-change: transform, top, left, opacity;
  transition: none !important;
}

.shelf-song-row.shelf-reorder-shrinking {
  z-index: 4999;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.shelf-song-row.shelf-reorder-arriving {
  z-index: 5001;
}

.shelf-reorder-placeholder {
  list-style: none;
  box-sizing: border-box;
  margin-bottom: 0.1rem;
  border: 2px dashed rgba(100, 149, 237, 0.55);
  border-radius: 8px;
  background: rgba(100, 149, 237, 0.1);
  overflow: hidden;
  flex-shrink: 0;
  transition: none !important;
}

body.shelf-reorder-animating .display-shelf-list {
  overflow: hidden;
}

body.shelf-reorder-animating .shelf-song-btn,
body.shelf-reorder-animating .shelf-visibility-btn,
body.shelf-reorder-animating .shelf-drag-handle {
  pointer-events: none;
}

.shelf-song-row.is-dragging {
  position: fixed;
  z-index: 3000;
  margin: 0;
  pointer-events: none;
  opacity: 1;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  background: var(--nav-bg);
  border-radius: 8px;
  padding: 0.15rem 0.5rem;
}

.is-reordering .shelf-song-row {
  transition: none;
}

.reorder-placeholder {
  display: flex;
  align-items: stretch;
  box-sizing: border-box;
  width: 100%;
  margin: 0.1rem 0.5rem;
  border: 2px dashed var(--nav-active);
  border-radius: 8px;
  background: rgba(59, 130, 224, 0.1);
  flex-shrink: 0;
  pointer-events: none;
}

.shelf-song-row-inactive {
  opacity: 0.55;
}

.shelf-visibility-btn {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--nav-muted);
  cursor: pointer;
}

.shelf-visibility-btn:active {
  opacity: 0.82;
}

@media (hover: hover) and (pointer: fine) {
  .shelf-visibility-btn:hover {
    border-color: var(--nav-border);
    color: var(--nav-text);
  }
}

.shelf-visibility-btn.is-inactive {
  color: var(--muted);
}

.shelf-drag-handle {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  color: var(--nav-muted);
  cursor: grab;
  user-select: none;
  touch-action: none;
  font-size: 0.85rem;
  letter-spacing: -0.08em;
}

.is-reordering .shelf-drag-handle,
.is-reordering .drag-handle {
  cursor: grabbing;
}

body:not(.shelf-edit-mode) .shelf-drag-handle,
body:not(.shelf-edit-mode) .shelf-visibility-btn {
  display: none;
}

.shelf-song-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--nav-text);
  padding: 0.45rem 0.55rem;
  font-size: calc(0.82rem * var(--text-scale));
  font-family: inherit;
  cursor: pointer;
}

.shelf-song-btn:active:not(:disabled):not(.is-readonly) {
  opacity: 0.82;
}

@media (hover: hover) and (pointer: fine) {
  .shelf-song-btn:hover:not(:disabled):not(.is-readonly) {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--nav-border);
  }
}

.shelf-song-btn.active {
  background: rgba(81, 207, 102, 0.12);
  border-color: rgba(81, 207, 102, 0.45);
  color: var(--now-green);
  font-weight: 700;
}

.shelf-song-btn.up-next {
  border-color: rgba(59, 130, 224, 0.35);
}

.shelf-song-btn.is-readonly {
  cursor: default;
}

.shelf-song-btn:disabled {
  cursor: default;
}

.shelf-preview-btn {
  flex-shrink: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.shelf-preview-btn:active {
  transform: scale(0.96);
}

@media (hover: hover) and (pointer: fine) {
  .shelf-preview-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

.shelf-chart-preview {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.shelf-chart-preview.hidden {
  display: none;
}

.shelf-chart-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.shelf-chart-preview-panel {
  position: relative;
  z-index: 1;
  width: min(96vw, 56rem);
  height: min(88vh, 48rem);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.shelf-chart-preview-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.shelf-chart-preview-content {
  width: 100%;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.shelf-chart-preview-content .chart-sheet,
.shelf-chart-preview-content .chart-sheet img,
.shelf-chart-preview-content .chart-sheet embed {
  width: 100%;
  height: 100%;
}

.shelf-chart-preview-loading,
.shelf-chart-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 12rem;
  padding: 2rem;
  color: var(--nav-muted);
  text-align: center;
}

.shelf-song-position {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--nav-muted);
  min-width: 1.5rem;
}

.shelf-song-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.high-contrast .display-shelf {
  border-right-width: 2px;
}

body.high-contrast .shelf-song-btn.active {
  background: rgba(105, 219, 124, 0.2);
  border-color: var(--now-green);
  color: var(--now-green);
}

@media (prefers-reduced-motion: reduce) {
  .display-shelf {
    transition: none;
  }
}

.show-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  background: rgba(10, 10, 12, 0.94);
  text-align: center;
}

.show-overlay.hidden {
  display: none !important;
}

.show-overlay-message {
  margin: 0;
  font-size: calc(2.75rem * var(--text-scale));
  font-weight: 800;
  line-height: 1.15;
  color: var(--page-text);
  max-width: 90vw;
}

.show-overlay-countdown {
  margin: 0;
  font-size: calc(5.5rem * var(--text-scale));
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--nav-active);
  letter-spacing: 0.04em;
}

.show-overlay-countdown.hidden {
  display: none !important;
}

.show-overlay.overlay-break .show-overlay-message {
  color: var(--rehearsal-accent);
}

.show-overlay.overlay-break-dismissible {
  cursor: pointer;
}

.show-overlay.overlay-break-dismissible::after {
  content: "Double-tap to end break";
  position: absolute;
  left: 50%;
  bottom: 2.5rem;
  transform: translateX(-50%);
  font-size: calc(0.95rem * var(--text-scale));
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.02em;
}

.show-overlay.overlay-countdown .show-overlay-message {
  font-size: calc(2.1rem * var(--text-scale));
  font-weight: 700;
  color: var(--rehearsal-accent);
  margin-bottom: 0.15rem;
}

.show-overlay.overlay-showtime .show-overlay-message {
  color: var(--now-green);
  font-size: calc(3.25rem * var(--text-scale));
}

body.high-contrast .show-overlay {
  background: #000000;
  border: 4px solid #ffffff;
}

body.high-contrast .show-overlay.overlay-break .show-overlay-message {
  color: var(--rehearsal-accent);
}

body.high-contrast .show-overlay.overlay-countdown .show-overlay-message {
  color: var(--rehearsal-accent);
}

body.high-contrast .show-overlay.overlay-showtime .show-overlay-message {
  color: var(--edit-accent-soft);
}

body.passcode-gate-open .chart-viewport,
body.passcode-gate-open .display-header,
body.passcode-gate-open .playback-footer,
body.passcode-gate-open .display-shelf,
body.passcode-gate-open .shelf-backdrop {
  visibility: hidden;
}

.passcode-gate {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 9, 12, 0.92);
}

.passcode-gate.hidden {
  display: none !important;
}

.passcode-gate-panel {
  width: min(100%, 22rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.35rem 1.1rem;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.passcode-gate-title {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.2rem;
}

.passcode-gate-hint {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  line-height: 1.45;
}

.passcode-input {
  width: 8rem;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  padding: 0.45rem 0.55rem;
  margin: 0 auto 0.65rem;
  display: block;
}

.passcode-error {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--danger-soft);
}

.passcode-error.hidden {
  display: none;
}

.passcode-submit {
  background: var(--show-accent);
  border: none;
  color: var(--on-accent);
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.passcode-submit:active:not(:disabled) {
  opacity: 0.85;
}

@media (hover: hover) and (pointer: fine) {
  .passcode-submit:hover:not(:disabled) {
    background: var(--show-accent-hover);
  }
}

.display-qr-dialog {
  position: fixed;
  inset: 0;
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 9, 12, 0.92);
}

.display-qr-dialog.hidden {
  display: none !important;
}

.display-qr-panel {
  width: min(100%, 22rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.35rem 1.1rem;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.display-qr-title {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.2rem;
}

.display-qr-hint {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted, #adb5bd);
}

.display-qr-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.65rem;
}

.display-qr-image {
  display: block;
  width: 12.5rem;
  height: 12.5rem;
  border-radius: 8px;
  background: #fff;
}

.display-qr-url {
  margin: 0 0 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted, #adb5bd);
  word-break: break-all;
}

.display-qr-error {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--danger-soft);
}

.display-qr-error.hidden {
  display: none;
}

.display-qr-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.display-qr-action-btn {
  width: 100%;
  margin: 0;
  padding: 0.5rem 0.65rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .display-qr-action-btn:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

body.high-contrast .display-qr-panel {
  border-width: 2px;
}

body.high-contrast .display-qr-action-btn {
  border-width: 2px;
}

body.display-fullscreen {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body.display-fullscreen .display-header,
body.display-fullscreen .playback-footer {
  display: none !important;
}

body.display-fullscreen .chart-viewport {
  flex: 1 1 0;
  padding: 0;
  min-height: 0;
}

body.display-fullscreen .display-shelf,
body.display-fullscreen .shelf-backdrop {
  display: none !important;
}

body.display-media-mode {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body.display-media-mode .display-header,
body.display-media-mode .playback-footer {
  display: none !important;
}

body.display-media-mode .chart-viewport {
  flex: 1 1 0;
  padding: 0;
  min-height: 0;
}

body.display-media-mode .display-shelf,
body.display-media-mode .shelf-backdrop {
  display: none !important;
}

.chart-sheet--media.is-media-stopped {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.display-media-video {
  pointer-events: none;
}

.chart-sheet--karaoke .karaoke-chart-mount {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(70vh, 100%);
}

.chart-sheet--karaoke .karaoke-cdg-canvas {
  display: block;
  width: min(100%, 56rem);
  height: auto;
  aspect-ratio: 300 / 216;
  border-radius: 8px;
  background: #000;
  image-rendering: pixelated;
}

body.display-media-mode .chart-sheet--karaoke .karaoke-cdg-canvas {
  width: min(100vw, 72rem);
}

.karaoke-playback-unlock {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.karaoke-playback-unlock:active {
  background: rgba(0, 0, 0, 0.85);
}

.fullscreen-exit-btn {
  position: fixed;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  background: rgba(17, 24, 33, 0.88);
  border: 1px solid var(--nav-border);
  color: var(--nav-text);
  border-radius: 50%;
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  opacity: 1;
  transition: opacity 0.28s ease;
}

.fullscreen-exit-btn.is-auto-hidden {
  opacity: 0;
  pointer-events: none;
}

.fullscreen-exit-btn:active {
  opacity: 0.82;
}

@media (hover: hover) and (pointer: fine) {
  .fullscreen-exit-btn:hover {
    border-color: var(--nav-active);
    color: var(--nav-active);
  }
}

.passcode-submit:disabled {
  opacity: 0.55;
  cursor: wait;
}

.connection-lost-spinner-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
  pointer-events: none;
}

.display-empty-state--offline {
  position: relative;
  min-height: 16rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.display-empty-state--syncing {
  position: relative;
  min-height: 16rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1rem;
}

.display-sync-hold-icon {
  display: block;
  width: 3.5rem;
  height: 3.5rem;
  opacity: 0.88;
  filter: brightness(0) invert(1);
}

.display-empty-state-card {
  position: relative;
  z-index: 1;
  max-width: 28rem;
  padding: 1.25rem 1.35rem;
  border-radius: 14px;
  background: rgba(12, 16, 28, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}

.connection-lost-spinner {
  position: relative;
  width: 6.5rem;
  height: 6.5rem;
  margin: 0;
}

.connection-lost-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 50%;
  background: rgba(72, 118, 196, 0.55);
  transform: rotate(calc(var(--i) * 30deg)) translateY(-2.75rem);
  animation: connection-lost-chase 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.14s);
}

@keyframes connection-lost-chase {
  0%,
  100% {
    opacity: 0.22;
    transform: rotate(calc(var(--i) * 30deg)) translateY(-2.75rem) scale(0.82);
  }
  50% {
    opacity: 0.95;
    transform: rotate(calc(var(--i) * 30deg)) translateY(-2.75rem) scale(1.08);
  }
}

body.display-part-locked .display-nav-scroll,
body.display-part-locked .shelf-toggle,
body.display-part-locked .footer-transport-btn,
body.display-part-locked .footer-transport-sep,
body.display-part-locked .display-lock-btn {
  display: none !important;
}

body.night-mode .connection-lost-dot {
  background: rgba(130, 175, 255, 0.62);
}

body.high-contrast .display-empty-state-card {
  background: #111;
  border-color: #fff;
}

/* Companion app (native WKWebView): chart-only, no browser chrome */
body.companion-client {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body.companion-client .display-header,
body.companion-client .playback-footer,
body.companion-client .display-shelf,
body.companion-client .shelf-backdrop,
body.companion-client .shelf-toggle,
body.companion-client .passcode-gate,
body.companion-client .display-qr-dialog {
  display: none !important;
}

body.companion-client .chart-viewport {
  flex: 1 1 0;
  padding: 0;
  min-height: 0;
}

/* Hidden karaoke preload while another chart part is visible (companion + LAN browser). */
.display-karaoke-preload {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
