.document-header-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
  /* Strip view: match the scroll strip’s horizontal gutter (leading only). */
  padding-inline-start: var(--notation-scroll-padding-inline-start, var(--notation-scroll-padding-inline, 0px));
  padding-inline-end: var(--notation-scroll-padding-inline-end, var(--notation-scroll-padding-inline, 0px));
  --text: #222;
  --text-dim: rgba(0, 0, 0, 0.45);
}

.title-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 0.35em 0.85em;
  border-radius: var(--radius, 16px);
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.title-row:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.28);
}

.title-row #song-title {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: center;
  pointer-events: none;
  line-height: 1.15;
}

.title-row select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 16px;
}

.title-row.song-picker-enabled select,
.page-sticky-titlebar__text.song-picker-enabled select {
  pointer-events: none;
}

.page-sticky-titlebar__text:focus-visible,
.title-row:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.28);
  outline-offset: 2px;
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 68px;
  justify-content: flex-start;
}

/* Undo legacy song-bar.css centering/absolute chips when using the Score header row. */
.document-header-row .info-row,
.document-header-row #song-row {
  justify-content: flex-start;
  position: static;
  padding: 0;
  min-height: 68px;
}

.document-header-row #left-chips {
  position: static;
  left: auto;
  top: auto;
  transform: none;
}

.info-row-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.info-row-spacer {
  flex: 1;
  min-width: 0;
}

@media (min-width: 461px) {
  .info-row:not(:has(#song-credits-display:not([hidden]))):not(:has(#song-credits:not([hidden]))) {
    justify-content: center;
  }

  .info-row:not(:has(#song-credits-display:not([hidden]))):not(:has(#song-credits:not([hidden]))) .info-row-spacer {
    display: none;
  }

  .info-row:has(#song-credits-display:not([hidden])) .info-row-spacer,
  .info-row:has(#song-credits:not([hidden])) .info-row-spacer {
    display: block;
    flex: 1;
    min-width: 0;
  }

  /* Keep chips left / credits right until the narrow column breakpoint. */
  .document-header-row .info-row,
  .document-header-row #song-row {
    flex-direction: row;
    align-items: flex-start;
  }

  .document-header-row #left-chips {
    align-self: auto;
  }
}

.document-header-row #song-credits-display,
.document-header-row #song-credits {
  position: static;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-self: flex-start;
  justify-content: flex-start;
  gap: 2px;
  flex-shrink: 1;
  min-width: 0;
  max-width: min(40vw, 260px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.25;
  text-align: right;
  opacity: 0.88;
  color: inherit;
}

.document-header-row #song-credits-display {
  pointer-events: none;
}

.document-header-row #song-credits {
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius, 16px);
  font-family: inherit;
  padding: 0.35em 0.85em;
  transition: background 0.15s, border-color 0.15s;
  margin-left: auto;
}

.document-header-row #song-credits:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.28);
}

.document-header-row #song-credits:active {
  background: rgba(0, 0, 0, 0.08);
}

.document-header-row #song-credits:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.28);
  outline-offset: 2px;
}

.document-header-row #song-credits-display .song-credits-line,
.document-header-row #song-credits .song-credits-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.document-header-row #song-credits-display .song-credits-lead,
.document-header-row #song-credits .song-credits-lead {
  font-weight: inherit;
  opacity: 0.72;
  margin-right: 2px;
}

.document-header-row #song-credits-display .song-credits-name,
.document-header-row #song-credits .song-credits-name {
  font-weight: inherit;
  letter-spacing: inherit;
}

.document-header-row #song-credits .song-credits-placeholder {
  opacity: 0.55;
  font-style: normal;
  font-weight: inherit;
  letter-spacing: inherit;
}

.document-header-row #song-credits .song-credits-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

#song-credits.is-empty .song-credits-content { display: none; }
#song-credits:not(.is-empty) .song-credits-placeholder { display: none; }

.document-header-row vertical-stepper-control .vertical-stepper-body {
  background: transparent !important;
  border: 1px solid var(--stepper-body-border, rgba(0, 0, 0, 0.18));
  box-shadow: none !important;
}

.document-header-row vertical-stepper-control .vertical-stepper-step:hover:not(:disabled) {
  background: var(--stepper-step-hover-bg, rgba(0, 0, 0, 0.04)) !important;
}

/* Stack/center credits + chips when inner page margins reach 12pt (ring 2). */
@media (max-width: 460px) {
  .info-row {
    flex-direction: column;
    align-items: center;
    min-height: unset;
    gap: 16px;
  }

  .info-row-spacer {
    display: none;
  }

  .info-row-chips {
    order: 2;
  }

  .document-header-row #song-credits-display,
  .document-header-row #song-credits {
    order: 1;
    align-items: center;
    align-self: center;
    max-width: 100%;
    text-align: center;
    margin-left: 0;
  }

  .document-header-row #song-credits .song-credits-content {
    align-items: center;
  }
}

.page-sticky-titlebar {
  margin-inline: calc(-1 * var(--body-margin-inline, 0px));
  width: calc(100% + 2 * var(--body-margin-inline, 0px));
  box-sizing: border-box;
}

body[data-layout="page"] {
  --notation-surface-bg: #fff;
  --sticky-header-shadow:
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.05);
}

body[data-layout="page"] .page-sticky-titlebar {
  position: sticky;
  top: 0;
  z-index: 120;
  overflow: visible;
  box-sizing: border-box;
  border: none;
}

body[data-layout="scroll"] .document-header-row {
  --btn-bg: rgba(0, 0, 0, 0.07);
  --toolbar-control-border: rgba(0, 0, 0, 0.1);
}

/* Shell tokens: page-header.css (.page-sticky-titlebar__toolbar) */

body:not(.dark-bg) .page-sticky-titlebar__toolbar {
  color: #222;
  --text: #222;
  --text-dim: rgba(0, 0, 0, 0.45);
  --btn-bg: rgba(0, 0, 0, 0.07);
  --btn-hover: rgba(0, 0, 0, 0.12);
  --toolbar-control-border: rgba(0, 0, 0, 0.1);
  --toolbar-control-active-bg: rgba(255, 255, 255, 0.72);
}

body[data-layout="page"] .page-sticky-titlebar.is-stuck {
  background: var(--shell-bg, var(--bg, #D1D1D6));
}

body[data-layout="scroll"] .page-sticky-titlebar__inner {
  display: none !important;
}

body[data-layout="page"] .page-sticky-titlebar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44pt;
  max-height: 0;
  box-sizing: border-box;
  background: var(--notation-surface-bg, #fff);
  border: none;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  position: relative;
  z-index: 1;
  transition:
    max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.24s ease,
    transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

body:not(.dark-bg)[data-layout="page"] .page-sticky-titlebar__inner {
  color: #222;
  --text: #222;
  --text-dim: rgba(0, 0, 0, 0.45);
  --stepper-body-border: rgba(0, 0, 0, 0.18);
  --stepper-step-hover-bg: rgba(0, 0, 0, 0.04);
}

body[data-layout="page"] .page-sticky-titlebar.is-stuck .page-sticky-titlebar__inner {
  max-height: 44pt;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  overflow: visible;
  box-shadow: var(--sticky-header-shadow);
}

@media (prefers-reduced-motion: reduce) {
  body[data-layout="page"] .page-sticky-titlebar__inner {
    transition: none;
    transform: none;
  }
}

.page-sticky-titlebar__text {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  flex: 0 1 auto;
  max-width: min(52vw, 360px);
  padding: 0.35em 0.85em;
  border-radius: var(--radius, 16px);
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.page-sticky-titlebar__text:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.28);
}

.page-sticky-titlebar__text select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 16px;
}

.page-sticky-titlebar__title {
  margin: 0;
  font-size: clamp(1rem, 2.8vw, 1.125rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.01em;
  text-transform: none;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.page-sticky-titlebar__subtitle {
  margin: 0;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.page-sticky-titlebar__spacer {
  flex: 1;
  min-width: 8px;
}

.page-sticky-titlebar__chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.page-sticky-titlebar vertical-stepper-control {
  gap: 0;
}

.page-sticky-titlebar vertical-stepper-control .vertical-stepper-label {
  display: none;
}

.page-sticky-titlebar vertical-stepper-control .vertical-stepper-body {
  grid-template-rows: 12px 18px 12px !important;
  min-width: 40px !important;
  min-height: 42px !important;
  padding: 2px 6px !important;
  background: transparent !important;
  border: 1px solid var(--stepper-body-border, rgba(0, 0, 0, 0.18));
  box-shadow: none !important;
}

.page-sticky-titlebar vertical-stepper-control .vertical-stepper-step {
  width: 28px;
  height: 12px;
  color: var(--text-dim);
}

.page-sticky-titlebar vertical-stepper-control .vertical-stepper-step svg {
  width: 14px;
  height: 14px;
}

.page-sticky-titlebar vertical-stepper-control .vertical-stepper-value {
  font-size: 11px;
  min-width: 24px;
}

.page-sticky-titlebar vertical-stepper-control .vertical-stepper-step:hover:not(:disabled) {
  background: var(--stepper-step-hover-bg, rgba(0, 0, 0, 0.04)) !important;
  color: var(--text);
}
