/* Viewer-only structure, followed by the pearl constellation appearance.
   Keep shared player/control rules in styles.css. */

.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #aebbc7;
  border-radius: 8px;
  padding: 0 13px;
  width: 290px;
  background: white;
  color: var(--muted);
}
.search-field:focus-within {
  outline: 3px solid #2869ae;
  outline-offset: 2px;
}
.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 10px 0;
  background: transparent;
  font-size: 14px;
  color: var(--ink);
}
.search-field input::placeholder {
  color: #677481;
}
.work-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.work-filter {
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 12px;
  min-height: 36px;
  white-space: nowrap;
}
.work-filter[aria-pressed='true'] {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.work-filter:hover {
  border-color: #8395a7;
}
.library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}
.work-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: white;
}
.work-card-header {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.work-name {
  display: flex;
  align-items: center;
  gap: 11px;
}
.work-card-header h3 {
  font-size: 17px;
  margin: 0;
}
.song-list {
  margin: 0;
  padding: 7px 0;
  list-style: none;
}
.song-row {
  padding: 0 8px;
}
.song-button {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: white;
  text-align: left;
  padding: 12px 10px;
  min-height: 48px;
  position: relative;
}
.song-button:hover {
  background: var(--wash);
}
.song-title {
  font-size: 14px;
  line-height: 1.8;
  flex: 1;
  min-width: 0;
}
.song-mark {
  color: var(--accent);
  width: 17px;
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.song-mark:empty::before {
  content: '›';
  font-size: 19px;
  line-height: 1;
  color: #8b97a3;
}
.song-mark.has-links::before {
  content: '·';
  font-size: 24px;
  line-height: 0.6;
  font-weight: 700;
}
.song-button.is-context {
  background: var(--accent-bg);
}
.has-selection .song-button:not(.is-context) {
  opacity: 0.48;
}
.no-results {
  grid-column: 1/-1;
  text-align: center;
  color: var(--muted);
  padding: 70px 20px;
}
.no-results h3 {
  color: var(--ink);
  font-size: 18px;
}
.loading-message {
  padding: 60px 0;
}
.load-error {
  padding: 30px;
}
.noscript {
  margin: 20px;
}
.focus-dialog {
  width: calc(100% - 72px);
  max-width: 1200px;
  height: min(730px, calc(100dvh - 64px));
  max-height: none;
  padding: 0;
  border: 1px solid #cad4de;
  border-radius: 18px;
  color: var(--ink);
  background: white;
  box-shadow: 0 24px 100px #23395024;
  overflow: hidden;
}
.focus-dialog[open] {
  display: flex;
  flex-direction: column;
}
.focus-dialog::backdrop {
  background: #f4f7fbc7;
  backdrop-filter: blur(1.5px);
}
.focus-header {
  padding: 22px 26px 17px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-shrink: 0;
}
.focus-heading {
  min-width: 0;
}
.focus-heading .eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
}
.focus-header h2 {
  font-size: 21px;
  line-height: 1.65;
  margin: 5px 0 1px;
}
.focus-work {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.close-button {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
}
.close-button:hover {
  background: var(--wash);
}
.focus-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 346px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.graph-side {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 22px 24px 18px;
  scrollbar-width: thin;
}
.graph-scroll {
  overflow: auto;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
  min-height: 220px;
}
.graph-stage {
  position: relative;
  display: grid;
  min-height: 240px;
  isolation: isolate;
}
.graph-node {
  pointer-events: auto;
  position: relative;
  margin-top: 58px;
  min-height: 74px;
  background: white;
  border: 1px solid #a9b8c6;
  border-radius: 9px;
  padding: 11px 9px;
  text-align: center;
  line-height: 1.8;
}
.graph-node.is-center::before {
  content: '選んだ曲';
  position: absolute;
  bottom: calc(100% + 7px);
  left: 0;
  width: 100%;
  font-size: 11px;
  font-weight: 700;
}
.graph-node:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.graph-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: visible;
  pointer-events: none;
}
.graph-edge {
  fill: none;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
  opacity: 0.7;
}
.graph-edge.is-active {
  opacity: 1;
}
.relation-detail {
  border-top: 1px solid var(--line);
  padding-top: 15px;
  min-height: 65px;
}
.relation-detail h3 {
  font-size: 14px;
  margin: 0 0 5px;
}
.relation-detail p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.relation-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}
.related-song {
  padding: 10px 9px;
  border: 1px solid transparent;
  align-items: center;
  background: white;
  text-align: left;
  border-radius: 7px;
}
.related-song:hover {
  background: var(--wash);
}
.related-song[aria-pressed='true'] {
  border-color: #a7bbcf;
  background: var(--accent-bg);
}
.related-label {
  min-width: 0;
  flex: 1;
}
.related-label strong {
  display: block;
  font-weight: 400;
  font-size: 13px;
  line-height: 1.7;
}
.related-label small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}
.reprise {
  --relation-color: var(--reprise);
}
.player-side {
  background: #fafbfd;
  border-left: 1px solid var(--line);
  padding: 22px 20px;
  overflow: auto;
  min-width: 0;
}
.focus-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding: 10px 25px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
  background: white;
}
@media (min-width: 1500px) {
  .library-grid {
    gap: 28px;
  }
  .work-card-header {
    padding: 22px;
  }
  .song-button {
    padding-top: 13px;
    padding-bottom: 13px;
  }
}
@media (max-width: 1100px) {
  .library-grid {
    gap: 16px;
  }
  .work-card-header {
    padding: 17px 14px;
  }
  .work-card-header h3 {
    font-size: 15px;
  }
  .song-button {
    gap: 8px;
    padding: 11px 6px;
  }
  .song-title {
    font-size: 13px;
  }
  .focus-dialog {
    width: calc(100% - 40px);
  }
  .focus-body {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
  .graph-side {
    padding: 18px;
  }
  .player-side {
    padding: 20px 15px;
  }
  .focus-header {
    padding: 19px 22px 16px;
  }
}
@media (max-width: 820px) {
  .library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .focus-dialog {
    width: calc(100% - 24px);
    height: calc(100dvh - 32px);
  }
  .focus-body {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
  .focus-header h2 {
    font-size: 19px;
  }
}
@media (max-width: 650px) {
  .library-toolbar {
    display: block;
    margin-bottom: 14px;
  }
  .search-field {
    width: 100%;
    min-height: 46px;
  }
  .search-field input {
    font-size: 16px;
  }
  .work-filters {
    flex-wrap: nowrap;
    overflow: auto;
    margin-right: -18px;
    padding-right: 18px;
    padding-bottom: 9px;
    scrollbar-width: thin;
  }
  .work-filter {
    font-size: 12px;
    min-height: 42px;
    padding: 8px 12px;
  }
  .library-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .work-card-header {
    padding: 17px 18px;
  }
  .work-card-header h3 {
    font-size: 17px;
  }
  .song-button {
    padding: 12px 10px;
    gap: 12px;
  }
  .song-title {
    font-size: 14px;
  }
  .song-mark {
    margin-right: 5px;
  }
  .focus-dialog {
    margin: 8px;
    width: calc(100% - 16px);
    height: calc(100dvh - 16px);
    border-radius: 13px;
  }
  .focus-header {
    padding: 14px 16px 11px;
    gap: 10px;
  }
  .focus-header .eyebrow {
    font-size: 10px;
  }
  .focus-header h2 {
    font-size: 16px;
    line-height: 1.7;
    margin-top: 3px;
  }
  .focus-work {
    font-size: 10px;
  }
  .close-button {
    width: 36px;
    height: 36px;
  }
  .focus-body {
    flex-direction: column;
  }
  .graph-side {
    padding: 12px 14px;
    flex: 1;
    min-height: 130px;
  }
  .graph-scroll {
    min-height: 168px;
    margin-top: 5px;
  }
  .graph-stage {
    min-height: 180px;
    grid-template-columns: repeat(var(--columns, 1), minmax(120px, 1fr));
    min-width: calc(var(--columns, 1) * 136px - 16px);
  }
  .graph-node {
    margin-top: 32px;
    min-height: 63px;
    padding: 9px 7px;
  }
  .graph-node.is-center::before {
    font-size: 10px;
    bottom: calc(100% + 4px);
  }
  .relation-detail {
    padding-top: 10px;
    min-height: 0;
  }
  .relation-detail h3 {
    font-size: 12px;
  }
  .relation-detail p {
    font-size: 11px;
  }
  .relation-list {
    margin-top: 8px;
  }
  .player-side {
    flex-shrink: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px 14px;
    background: #fafbfd;
  }
  .focus-footer {
    padding: 7px 14px;
    gap: 7px;
    line-height: 1.7;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .song-button,
  .graph-node,
  .related-song,
  .work-filter {
    transition:
      background-color 0.15s,
      border-color 0.15s;
  }
  .focus-dialog[open] {
    animation: focus-appear 0.18s ease-out;
  }
  @keyframes focus-appear {
    from {
      opacity: 0.7;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}
.graph-node {
  font-size: 14px;
}
.related-label small {
  font-size: 11px;
}
@media (max-width: 650px) {
  .graph-node {
    font-size: 13px;
  }
  .focus-footer {
    font-size: 11px;
  }
  .related-label strong {
    font-size: 13px;
  }
  .related-label small {
    font-size: 11px;
  }
}
@media (max-width: 650px) and (max-height: 740px) {
  .focus-body {
    display: block;
    overflow: auto;
  }
  .graph-side {
    overflow: visible;
  }
  .graph-scroll {
    min-height: 185px;
  }
  .player-side {
    overflow: visible;
  }
  .focus-footer {
    font-size: 10px;
  }
}
.song-button.is-root {
  box-shadow: none;
}
.song-button.is-root .song-title {
  font-weight: 700;
}
.graph-node {
  box-shadow: none;
}
.graph-node[aria-pressed='true'] {
  background: #eef3f7;
  border: 1px solid #9baab8;
  padding: 11px 9px;
}
.graph-node.is-center::before {
  color: var(--muted);
}
.graph-stage {
  --song-card-width: 176px;
  grid-template-columns: repeat(var(--columns, 1), var(--song-card-width));
  gap: 24px;
  width: max-content;
  min-width: 0;
  max-width: none;
  margin-inline: auto;
  padding: 4px 28px 18px;
}
.graph-node {
  width: var(--song-card-width);
  max-width: var(--song-card-width);
}

@media (min-width: 821px) {
  .library-scroll {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 4px 4px 16px;
    scrollbar-width: auto;
  }
  .library-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 220px;
    gap: 16px;
    align-items: start;
  }
  .work-card-header {
    min-height: 84px;
    gap: 8px;
    padding: 16px 12px;
  }
  .work-name {
    min-width: 0;
    gap: 8px;
  }
  .work-card-header h3 {
    font-size: 15px;
    line-height: 1.7;
  }
}
@media (max-width: 650px) {
  .graph-stage {
    --song-card-width: 164px;
  }
  .graph-node[aria-pressed='true'] {
    padding: 9px 7px;
  }
}
.work-filters {
  margin-bottom: 12px;
}
.data-notice {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
}
.relation-detail {
  font-size: 13px;
  color: var(--muted);
}
@media (max-width: 650px) {
  .data-notice {
    font-size: 11px;
  }
  .work-filters {
    margin-bottom: 8px;
  }
}
.relation-list-heading {
  font-size: 14px;
  margin: 16px 0 10px;
  font-weight: 700;
}
.related-song {
  display: grid;
  grid-template-columns: minmax(100px, auto) minmax(0, 1fr) auto;
  gap: 14px;
}
.related-song .related-label {
  min-width: 0;
}
@media (max-width: 650px) {
  .focus-body {
    display: block;
    overflow: auto;
  }
  .graph-side {
    overflow: visible;
  }
  .player-side {
    overflow: visible;
  }
  .related-song {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 10px;
    padding: 10px;
  }
}
.graph-node {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.graph-node > span {
  width: 100%;
}

.graph-stage {
  padding-bottom: 58px;
}
.site-header .edit-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 80px;
  padding: 9px 18px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
  flex-shrink: 0;
}
.site-header .edit-page-link:hover {
  text-decoration-thickness: 2px;
}

/* The constellation treatment is limited to the viewer. Editor controls retain
   their familiar form layout and readable UD type. */
.viewer-shell {
  --accent-bg: #f7f1e5;
  --map-line: #c5c6c2;
  --selected-lyrics-star: #8b8b9d;
  min-height: 100dvh;
  color: var(--ink);
}

/* One compact canvas across performances; no chronological columns or tall
   per-performance headings. Label positions are solved independently of stars. */
.viewer-shell .graph-stage.compact-graph {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
}
.viewer-shell .graph-stage.compact-graph .graph-node,
.viewer-shell .graph-stage.compact-graph .graph-node[aria-pressed='true'] {
  position: absolute;
  width: 64px;
  height: 48px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: visible;
}
.viewer-shell .graph-stage.compact-graph .graph-symbol {
  width: 64px;
  height: 48px;
}
.viewer-shell .graph-stage.compact-graph .star-crown {
  transform: scale(0.7);
}
.viewer-shell .graph-stage.compact-graph .graph-star.is-eight {
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
}
.viewer-shell .graph-stage.compact-graph .graph-label {
  position: absolute;
  width: var(--label-width, 130px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}
.viewer-shell .graph-stage.compact-graph .graph-song-title {
  font-size: 14px;
  margin: 0;
  overflow-wrap: normal;
  word-break: normal;
}
.viewer-shell .graph-stage.compact-graph .graph-node-work {
  color: var(--muted);
  font-family: 'BIZ UDPGothic', sans-serif;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}
.viewer-shell .graph-stage.compact-graph .graph-probe {
  visibility: hidden;
  width: var(--label-width, 130px);
  height: auto;
}
.viewer-shell .graph-stage.compact-graph .graph-probe .graph-label {
  position: static;
}
.viewer-shell .graph-relation-count {
  min-height: 17px;
  font-family: 'BIZ UDPGothic', sans-serif;
  font-size: 11px;
  line-height: 1.5;
  color: var(--accent);
}
.viewer-shell .graph-relation-count.is-empty {
  visibility: hidden;
}
.viewer-shell .relation-position {
  display: inline-block;
  margin-left: 8px;
  padding: 0 5px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.65);
  font-size: 11px;
  white-space: nowrap;
}
.viewer-shell .brand h1,
.viewer-shell .focus-header h2 {
  font-family: 'Shippori Mincho B1', 'Yu Mincho', serif;
  font-weight: 600;
  letter-spacing: 0.035em;
}
.viewer-shell .brand {
  gap: 14px;
}
.viewer-shell .brand-star {
  width: 26px;
  height: 32px;
  flex-shrink: 0;
  background: var(--star-gold);
  clip-path: polygon(
    50% 0,
    57% 33%,
    79% 21%,
    67% 43%,
    100% 50%,
    67% 57%,
    79% 79%,
    57% 67%,
    50% 100%,
    43% 67%,
    21% 79%,
    33% 57%,
    0 50%,
    33% 43%,
    21% 21%,
    43% 33%
  );
}
.viewer-shell .site-header {
  background: transparent;
}
.viewer-shell .search-field {
  min-height: 40px;
  padding: 0 2px;
  gap: 8px;
  border: 0;
  border-bottom: 1px solid #bdb7ae;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}
.viewer-shell .search-field svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.viewer-shell .search-field input {
  padding-block: 6px;
}
.viewer-shell .search-field input::placeholder {
  color: var(--muted);
}
.viewer-shell .search-field:focus-within {
  border-bottom-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.viewer-shell .library-grid.is-empty {
  display: block;
  width: 100%;
  min-width: 0;
}
.viewer-shell .no-results {
  width: 100%;
  padding: 56px 12px;
}
.viewer-shell .no-results h3 {
  line-height: 1.8;
  margin: 0 0 14px;
}
.viewer-shell .no-results p {
  margin: 0;
  font-size: 14px;
  line-height: 1.9;
}
.viewer-shell .no-results span {
  display: inline-block;
}
@media (max-width: 820px) {
  .viewer-shell .search-field {
    min-height: 44px;
  }
}
.viewer-shell .work-card {
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
.viewer-shell .work-card-header {
  padding-inline: 8px;
  border-bottom-color: var(--line);
}
.viewer-shell .song-row {
  padding-inline: 0;
}
.viewer-shell .song-button {
  background: transparent;
  border-radius: 0;
  padding-inline: 8px;
}
.viewer-shell .song-button:hover,
.viewer-shell .song-button.is-context {
  background: #ffffffa8;
}
.viewer-shell .song-mark.has-links::before {
  content: '';
  width: 9px;
  height: 14px;
  background: var(--star-gold);
  clip-path: polygon(50% 0, 60% 39%, 100% 50%, 60% 61%, 50% 100%, 40% 61%, 0 50%, 40% 39%);
}
.viewer-shell .work-filter {
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
}
.viewer-shell .song-mark:not(.has-links)::before {
  content: none;
}
.viewer-shell .work-filter[aria-pressed='true'] {
  color: var(--accent);
  background: transparent;
  border-color: var(--star-gold);
}
.viewer-shell .focus-dialog {
  width: min(1440px, calc(100% - 40px));
  max-width: none;
  height: calc(100dvh - 40px);
  border: 1px solid #ffffff;
  border-radius: 0;
}
.viewer-shell .focus-dialog::backdrop {
  background: #fafbfcce;
  backdrop-filter: blur(5px);
}
.viewer-shell .focus-header h2 {
  margin: 0;
}
.viewer-shell .focus-work {
  font-size: 12px;
}
.viewer-shell .close-button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
}
.viewer-shell .graph-scroll {
  min-height: 0;
  padding: 0;
}
.viewer-shell .graph-stage {
  --song-card-width: 220px;
  --work-column-width: 344px;
  grid-template-columns: repeat(var(--columns, 1), var(--work-column-width));
  gap: 32px;
  width: max-content;
  min-width: 0;
  min-height: 380px;
  margin-inline: auto;
  padding: 26px 42px 32px;
}
.viewer-shell .graph-node,
.viewer-shell .graph-node[aria-pressed='true'] {
  width: var(--song-card-width);
  max-width: none;
  min-height: 168px;
  margin-top: 0;
  margin-inline-start: calc((100% - var(--song-card-width)) * var(--star-position, 0.5));
  margin-inline-end: 0;
  padding: 0 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  justify-content: start;
  gap: 0;
  pointer-events: none;
}
.viewer-shell .graph-node.is-center::before {
  content: none;
}
.viewer-shell .graph-node .graph-symbol {
  display: block;
  position: relative;
  width: 96px;
  height: 72px;
  flex: none;
  pointer-events: none;
}
.viewer-shell .graph-node .graph-symbol::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}
.viewer-shell .graph-node .graph-song-title {
  pointer-events: auto;
}
.viewer-shell .graph-star {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  background: var(--star-gold);
  clip-path: path(
    'M 30 0 C 29 23 26 28 5 30 C 26 32 29 37 30 60 C 31 37 34 32 55 30 C 34 28 31 23 30 0 Z'
  );
  transform: scale(0.333333);
}
.viewer-shell .graph-node[aria-pressed='true'] .graph-star:not(.is-eight) {
  transform: scale(0.4);
}
.viewer-shell .graph-star.is-eight {
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  transform: none;
  clip-path: polygon(
    50% 0,
    56% 33%,
    79% 21%,
    67% 44%,
    100% 50%,
    67% 56%,
    79% 79%,
    56% 67%,
    50% 100%,
    44% 67%,
    21% 79%,
    33% 56%,
    0 50%,
    33% 44%,
    21% 21%,
    44% 33%
  );
}
.viewer-shell .star-crown {
  position: absolute;
  inset: 0;
  background: transparent;
}
.viewer-shell .star-ray {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--ray-width);
  height: var(--ray-length);
  background: var(--ray-gold);
  clip-path: polygon(36% 0, 64% 0, 100% 100%, 0 100%);
  transform-origin: 0 0;
  transform: rotate(var(--ray-angle)) translateY(var(--ray-reach));
}
.viewer-shell .graph-node .graph-song-title {
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  font-family: 'Shippori Mincho B1', 'Yu Mincho', serif;
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0.015em;
  line-height: 1.8;
  word-break: keep-all;
  overflow-wrap: normal;
  text-wrap: balance;
  color: var(--ink);
}
.viewer-shell .graph-node.is-center .graph-song-title {
  color: var(--accent);
  font-weight: 600;
}
.viewer-shell .graph-node:hover .graph-song-title {
  text-decoration: underline;
  text-underline-offset: 5px;
}
.viewer-shell .graph-edge {
  stroke: var(--map-line);
  stroke-width: 1.6px;
  opacity: 0.6;
  stroke-linejoin: round;
}
.viewer-shell .graph-edge.is-other-phrase {
  opacity: 0.3;
}
.viewer-shell .graph-edge.is-active {
  stroke: var(--star-gold);
  opacity: 1;
}
.viewer-shell .graph-edge.is-lyrics-only {
  stroke: #c9c2d1;
  opacity: 0.45;
}
.viewer-shell .graph-edge.is-lyrics-only.is-active {
  stroke: #95849f;
  opacity: 0.8;
}
.viewer-shell .graph-node.is-lyrics-only:not(.is-center) {
  --star-gold: #aaa0b5;
  --ray-gold: #c5bccd;
}
.viewer-shell .lyrics-visibility {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: #55566c;
}
.viewer-shell .lyrics-visibility input {
  width: 16px;
  height: 16px;
  accent-color: #95849f;
}
.viewer-shell .relation-list-heading {
  font-size: 13px;
  font-weight: 400;
  margin: 22px 0 8px;
}
.viewer-shell .relation-list {
  margin-top: 0;
}
.viewer-shell .song-pair-card {
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.viewer-shell .song-pair-card > .relation-card {
  border-bottom: 0;
}
.viewer-shell .song-pair-card > .relation-card + .relation-card {
  padding-top: 8px;
}
.viewer-shell .song-pair-card .relation-position {
  display: block;
  width: fit-content;
  padding: 0;
  background: transparent;
  color: var(--muted);
}
.viewer-shell .song-pair-card .relation-card + .relation-card .relation-position {
  margin-top: 0;
}
.viewer-shell .relation-card,
.viewer-shell .relation-card.is-selected {
  margin: 0;
  padding: 14px 10px;
  background: transparent;
  border-bottom: 1px solid var(--line);
}
.viewer-shell .related-song,
.viewer-shell .related-song[aria-pressed='true'] {
  background: transparent;
  border: 0;
}
.viewer-shell .song-pair-card.is-selected > .relation-card {
  backdrop-filter: none;
}
.viewer-shell .relation-card.is-selected.is-lyrics-only .related-label::before {
  background: var(--selected-lyrics-star);
}
.viewer-shell .related-label {
  display: block;
  position: relative;
}
.viewer-shell .related-label::before {
  position: absolute;
  left: 0;
  top: 7px;
  width: 12px;
  height: 12px;
  background: var(--star-gold);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 0C13.5 8.5 15.5 10.5 24 12C15.5 13.5 13.5 15.5 12 24C10.5 15.5 8.5 13.5 0 12C8.5 10.5 10.5 8.5 12 0Z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  opacity: 0;
}
.viewer-shell .relation-card.is-selected .related-label::before {
  opacity: 1;
}
.viewer-shell .related-label .relation-pair {
  display: block;
  font-size: 13px;
  line-height: 1.9;
  font-weight: 400;
}
.viewer-shell .related-label .relation-pair strong {
  display: inline;
  font-size: inherit;
  font-weight: 700;
  color: var(--accent);
}
.viewer-shell .relation-card.is-selected .relation-pair {
  text-decoration: none;
}
.viewer-shell .relation-playbacks {
  display: grid;
}
.viewer-shell .playback-column {
  display: grid;
  min-width: 0;
  gap: 4px;
  align-content: start;
}
.viewer-shell .relation-heading {
  display: block;
  position: relative;
}
.viewer-shell .relation-edit-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--accent);
  white-space: nowrap;
  text-underline-offset: 4px;
}
.viewer-shell .lyrics-only-label {
  display: flex;
  width: fit-content;
  align-items: center;
  border: 1px solid #c3c4d1;
  border-radius: 0;
  background: rgba(235, 235, 243, 0.85);
  color: #535365;
  font-weight: 400;
  line-height: 1.6;
  white-space: nowrap;
}
.viewer-shell .relation-position + .lyrics-only-label {
  margin-top: 6px;
}
.viewer-shell .clip-button {
  display: inline-flex;
  align-items: center;
  border-bottom: 1px solid rgba(150, 113, 59, 0.35);
  border-radius: 0;
  background: transparent;
  line-height: 1.6;
  text-align: left;
  text-decoration: none;
}
.viewer-shell .clip-play-icon {
  display: grid;
  place-items: center;
  padding-left: 0;
  border-radius: 0;
}
.viewer-shell .clip-play-label {
  min-width: 0;
}
.viewer-shell .clip-play-verb {
  white-space: nowrap;
}
.viewer-shell .clip-play-detail {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.viewer-shell .clip-button:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.32);
}
.viewer-shell .clip-button:not(:disabled):active {
  background: rgba(150, 113, 59, 0.09);
}
.viewer-shell .relation-card.is-lyrics-only .clip-button {
  color: #55566c;
}
.viewer-shell .relation-card.is-lyrics-only .clip-button:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.32);
}
.viewer-shell .clip-button:disabled {
  opacity: 0.5;
  cursor: default;
}
.viewer-shell .relation-card.is-lyrics-only .clip-button:not(:disabled):active {
  background: rgba(108, 108, 135, 0.09);
}
.viewer-shell .player-side {
  border-left: 1px solid #fff;
}
.viewer-shell .player-frame {
  border: 0;
  border-radius: 0;
}
.viewer-shell .player-placeholder {
  background: #f4f3f1;
  color: var(--muted);
}
.viewer-shell .segment-choice {
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  min-height: 44px;
}
.viewer-shell .segment-choice[aria-pressed='true'] {
  color: var(--accent);
  border-color: var(--star-gold);
  background: transparent;
}
.viewer-shell .focus-footer {
  background: transparent;
}
@media (max-width: 900px) {
  .viewer-shell .player-choices:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 10px;
  }
  .viewer-shell .player-choices button {
    min-height: 44px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    padding: 8px 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
  }
  .viewer-shell .player-choices button[aria-pressed='true'] {
    color: var(--accent);
    border-bottom-color: var(--star-gold);
    background: rgba(255, 241, 199, 0.32);
  }
  .viewer-shell .comparison-player + .comparison-player {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
  .viewer-shell .comparison-player .listening-song {
    min-height: 0;
    margin: 0 0 8px;
  }
  .viewer-shell .comparison-player .listening-song [data-field='work'],
  .viewer-shell .player-choices:not([hidden]) + #comparison-players .listening-song {
    display: none;
  }
  .viewer-shell .player-status:empty {
    display: none;
  }
  .viewer-shell .graph-side,
  .viewer-shell .player-side {
    overflow: visible;
  }
  .viewer-shell .graph-stage {
    --song-card-width: min(200px, calc(100% - 112px));
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 10px 16px 24px;
    min-height: 0;
    gap: 28px;
  }
  .viewer-shell .graph-node,
  .viewer-shell .graph-node[aria-pressed='true'] {
    width: var(--song-card-width);
    min-height: 156px;
  }
  .viewer-shell .player-side {
    border-left: 0;
    border-top: 1px solid #fff;
  }
  .viewer-shell #comparison-players {
    max-width: 360px;
    margin-inline: auto;
  }
}
@media (max-width: 650px) {
  .viewer-shell .related-content {
    padding: 0 14px 22px;
  }
  .viewer-shell .focus-dialog {
    width: calc(100% - 12px);
    height: calc(100dvh - 12px);
  }
  .viewer-shell .graph-side {
    padding: 16px 14px 22px;
  }
  .viewer-shell .graph-stage {
    padding-inline: 16px;
  }
  .viewer-shell .graph-node .graph-song-title {
    font-size: 16px;
  }
  .viewer-shell .brand-star {
    width: 18px;
    height: 24px;
  }
  .viewer-shell .brand {
    gap: 9px;
  }
  .viewer-shell .player-side {
    padding: 22px 16px;
  }
}
@media (max-width: 390px) {
  .viewer-shell .graph-node .graph-song-title {
    font-size: 15px;
    letter-spacing: 0;
  }
}

/* 星の記録帳 — shared paper, restrained marks, readable listening controls.
   Viewer-only: the editor and persistent YouTube player lifecycle are unchanged. */
html:has(.viewer-shell),
body:has(.viewer-shell) {
  background-color: #f5f1f5;
}
.viewer-shell {
  --ink: #343345;
  --muted: #686475;
  --accent: #795c30;
  --star-gold: #987a44;
  --ray-gold: #b49b6e;
  --line: #d6d0cb;
  --selected-music-bg: rgba(247, 236, 209, 0.55);
  --selected-lyrics-bg: rgba(230, 228, 241, 0.62);
  --ledger-paper:
    radial-gradient(ellipse at 47% 32%, #ffffffbf, transparent 49%),
    radial-gradient(ellipse at 96% 50%, #ffffff80, transparent 45%),
    radial-gradient(ellipse at 0% 13%, #f4e6cde1, transparent 56%),
    radial-gradient(ellipse at 90% 9%, #dfd8f2b3, transparent 41%),
    radial-gradient(ellipse at 85% 80%, #dceef4bf, transparent 49%),
    radial-gradient(ellipse at 20% 88%, #f2dfe7a1, transparent 47%), #fdfcfb;
  background: var(--ledger-paper);
}
.viewer-shell .site-header {
  border-bottom: 0;
}
.viewer-shell .site-header > .edit-page-link {
  flex-shrink: 0;
  font-size: 13px;
  margin-left: 20px;
}
.viewer-shell .relation-card .related-song {
  border-radius: 0;
  width: 100%;
}
.viewer-shell .clip-unset {
  font-size: 11px;
  color: var(--muted);
}
.viewer-shell .relation-note {
  white-space: pre-wrap;
}
.viewer-shell .clip-button {
  font-variant-numeric: tabular-nums;
}
.viewer-shell .graph-scroll {
  margin-top: 0;
}
.viewer-shell .site-heading {
  min-width: 0;
}
.viewer-shell .site-header {
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 8px;
}
.viewer-shell .page {
  padding-top: 12px;
}
.viewer-shell .site-intro {
  max-width: 900px;
  margin-top: 18px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--muted);
}
.viewer-shell .site-intro p {
  margin: 0;
}
.viewer-shell .intro-star {
  color: var(--star-gold);
}
.viewer-shell .work-card-header h3 {
  font-family: 'Shippori Mincho B1', 'Yu Mincho', serif;
  font-weight: 600;
}
.viewer-shell .song-button {
  border-bottom-color: transparent;
  text-decoration: none;
  color: inherit;
}
.viewer-shell .work-card-header {
  position: relative;
  z-index: 2;
  min-height: 0;
  padding: 16px 8px 8px;
}
.viewer-shell .library-table {
  position: relative;
}
.viewer-shell .library-heading-layer {
  position: sticky;
  top: 0;
  z-index: 3;
  height: var(--library-heading-height, 0px);
  margin-bottom: calc(-1 * var(--library-heading-height, 0px));
  pointer-events: none;
}
.viewer-shell .library-heading-viewport {
  height: 100%;
  overflow: hidden;
  background: var(--ledger-paper);
  background-repeat: no-repeat;
}
.viewer-shell .library-heading-track {
  position: relative;
  height: 100%;
}
.viewer-shell .library-heading-track .work-card-header {
  position: absolute;
  top: 0;
}
.viewer-shell .has-heading-layer .library-grid .work-card-header {
  opacity: 0;
}

.viewer-shell .work-card-header h3 {
  font-size: 18px;
  line-height: 1.7;
}
.viewer-shell .library-toolbar {
  justify-content: flex-start;
  margin-bottom: 10px;
}
.viewer-shell .library-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 16px;
}
.viewer-shell .library-grid:not(.is-empty) {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, max-content);
  width: max-content;
  min-width: 100%;
  gap: 20px;
}
.viewer-shell .work-card {
  min-width: 220px;
}
.viewer-shell .song-title {
  flex: 1 0 auto;
  min-width: max-content;
  white-space: nowrap;
  overflow: visible;
}
.viewer-shell .song-mark {
  flex: 0 0 17px;
}
.viewer-shell .focus-dialog {
  background: var(--ledger-paper);
  box-shadow: 0 18px 80px #38304614;
}
.viewer-shell .focus-header {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-bottom: 0;
  padding: 24px 30px 18px;
  align-items: center;
  gap: 12px;
}
/* Complete concentric circles clipped at the card edges. Their entire painted
   area stays in the header, so no decoration can cross a constellation line. */
.viewer-shell .focus-header::before {
  content: '';
  position: absolute;
  z-index: -1;
  pointer-events: none;
  width: 1100px;
  height: 1100px;
  right: -260px;
  bottom: 22px;
  border: 1px solid #bba37160;
  border-radius: 50%;
}
.viewer-shell .focus-header::after {
  content: '';
  position: absolute;
  z-index: -1;
  pointer-events: none;
  width: 1080px;
  height: 1080px;
  right: -250px;
  bottom: 32px;
  border: 1px solid #bba37138;
  border-radius: 50%;
}
.viewer-shell .focus-heading {
  flex: 1;
  min-width: 0;
  overflow: visible;
}
.viewer-shell .focus-header h2 {
  width: auto;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 30px;
  line-height: 1.7;
  letter-spacing: 0.045em;
}
.viewer-shell .focus-work {
  margin: 3px 0 0;
  padding-inline-start: 2px;
  text-align: left;
}
.viewer-shell .close-button {
  align-self: flex-start;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  color: var(--accent);
  border-radius: 0;
}
.viewer-shell .close-emblem {
  width: 44px;
  height: 44px;
}
.viewer-shell .close-button:hover {
  color: #644718;
  background: transparent;
}
.viewer-shell :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.viewer-shell[data-input-mode='pointer'] :focus-visible {
  outline: none;
}
.viewer-shell .focus-body {
  grid-template-columns: minmax(0, 1fr) 312px;
}
.viewer-shell .graph-side {
  padding: 8px 30px 24px;
}
.viewer-shell .lyrics-visibility {
  font-size: 12px;
  min-height: 36px;
}
.viewer-shell .graph-scroll {
  margin-bottom: 12px;
}
.viewer-shell .graph-stage.compact-graph .graph-song-title {
  display: block;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  overflow: visible;
  text-wrap: wrap;
  line-break: strict;
  pointer-events: auto;
  line-height: 1.75;
}
.viewer-shell .graph-title-word {
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
  word-break: keep-all;
  /* Only a single word longer than the entire label may break internally. */
  overflow-wrap: anywhere;
}
.viewer-shell .related-content {
  padding-top: 10px;
}
.viewer-shell .phrase-relations-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(260px, 70%);
  margin: 40px auto;
  color: #b9afb6;
  font-size: 15px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}
.viewer-shell .phrase-relations-divider::before,
.viewer-shell .phrase-relations-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: currentColor;
}
.viewer-shell .relation-list {
  display: grid;
  gap: 24px;
}
.viewer-shell .song-pair-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0;
  border: 0;
  padding: 0;
  min-width: 0;
}
.viewer-shell .pair-heading {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 6px 10px 8px;
}
.viewer-shell .song-pair-card.is-selected > .pair-heading,
.viewer-shell .song-pair-card.is-selected > .relation-card {
  --selection-tint: var(--selected-music-bg);
  background: linear-gradient(
      to right,
      var(--selection-tint) 0%,
      var(--selection-tint) 65%,
      transparent 100%
    )
    left top / min(100%, 620px) 100% no-repeat;
}
.viewer-shell .song-pair-card.is-selected > .pair-heading .relation-work {
  color: #5b5668;
}
.viewer-shell
  .song-pair-card.is-selected:has(> .relation-card.is-selected.is-lyrics-only)
  > .pair-heading {
  --selection-tint: var(--selected-lyrics-bg);
}
.viewer-shell .relation-pair {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 0;
  padding: 2px 0;
  font-family: 'Shippori Mincho B1', 'Yu Mincho', serif;
  font-size: 23px;
  font-weight: 500;
  line-height: 1.65;
  overflow: visible;
}
.viewer-shell .relation-pair > * {
  min-width: 0;
  max-width: 100%;
}
.viewer-shell .pair-select {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}
.viewer-shell .pair-select > * {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.viewer-shell .pair-peer {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  margin-left: 0;
  max-width: 100%;
}
.viewer-shell .pair-peer > :last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.viewer-shell .pair-divider {
  display: inline-block;
  flex: 0 0 16px;
  width: 16px;
  margin-inline: 12px;
  height: 1px;
  background: var(--muted);
  align-self: center;
  pointer-events: none;
  user-select: none;
}
.viewer-shell .pair-select:hover {
  text-decoration: underline;
  text-underline-offset: 5px;
}
.viewer-shell .relation-pair strong {
  color: var(--accent);
  font-weight: 600;
}
.viewer-shell .relation-work {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin: 5px 0 0;
}
.viewer-shell .relation-work .pair-divider {
  flex-basis: 10px;
  width: 10px;
  margin-inline: 6px;
}
.viewer-shell .song-pair-card > .relation-card,
.viewer-shell .song-pair-card > .relation-card + .relation-card {
  min-width: 0;
  padding: 6px 10px 10px;
  border: 0;
}
.viewer-shell .song-pair-card > .relation-card:only-of-type {
  grid-column: 1 / -1;
}
.viewer-shell .song-pair-card.is-selected > .relation-card {
  box-shadow: none;
}
.viewer-shell .song-pair-card.is-selected > .relation-card.is-lyrics-only {
  --selection-tint: var(--selected-lyrics-bg);
}
.viewer-shell .related-song,
.viewer-shell .related-song[aria-pressed='true'] {
  display: block;
  min-width: 0;
  min-height: 24px;
  padding: 0;
  text-align: left;
}
.viewer-shell .related-label {
  padding-left: 0;
}
.viewer-shell .related-label::before {
  content: none;
}
.viewer-shell .song-pair-card .relation-position {
  margin: 0;
  font-size: 12px;
}
.viewer-shell .relation-edit-link {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
  min-width: 44px;
  min-height: 32px;
  font-size: 11px;
  padding: 4px 0;
}
.viewer-shell .related-song:has(.related-label > .sr-only:only-child) {
  min-height: 0;
  padding: 0;
}
.viewer-shell .lyrics-only-label {
  font-size: 10px;
  padding: 1px 4px;
  margin: 3px 0 0;
}
.viewer-shell .relation-playbacks {
  grid-template-columns: minmax(0, 136px) minmax(0, 1fr);
  width: 100%;
  max-width: 500px;
  margin-top: 4px;
  gap: 6px 10px;
  align-items: stretch;
}
.viewer-shell .relation-playbacks .playback-column {
  grid-auto-rows: minmax(44px, auto);
  justify-items: start;
}
.viewer-shell .clip-button {
  --clip-line: #bca77a;
  width: fit-content;
  max-width: min(100%, 280px);
  min-height: 44px;
  padding: 7px 8px;
  font-size: 13px;
  gap: 7px;
  border: 1px solid var(--clip-line);
  color: #795c30;
}
.viewer-shell .clip-play-icon {
  flex: 0 0 12px;
  width: 12px;
  height: 14px;
  font-size: 0;
  background: none;
  clip-path: none;
  transform: none;
  color: var(--clip-line);
}
.viewer-shell .clip-button:not(:disabled):hover {
  --clip-line: #96713b;
  border-color: var(--clip-line);
}
.viewer-shell .relation-card.is-lyrics-only .clip-button {
  --clip-line: #b3afc1;
  border-color: var(--clip-line);
}
.viewer-shell .relation-card.is-lyrics-only .clip-button:not(:disabled):hover {
  --clip-line: #85859c;
  border-color: var(--clip-line);
}
.viewer-shell .clip-play-label {
  white-space: normal;
  overflow-wrap: anywhere;
}
.viewer-shell .relation-card.is-lyrics-only .clip-play-icon {
  background: none;
  color: var(--clip-line);
}
.viewer-shell .clip-play-verb {
  font-size: inherit;
}
.viewer-shell .relation-note {
  font-size: 14px;
  line-height: 1.85;
  margin: 12px 0 0;
  color: var(--ink);
}
.viewer-shell .player-side {
  background: #ffffff40;
  border: 0;
  padding: 14px 16px;
  backdrop-filter: none;
}
.viewer-shell .comparison-player + .comparison-player {
  border: 0;
  margin-top: 20px;
  padding-top: 0;
}
.viewer-shell .comparison-player .listening-song h3 {
  font-family: 'Shippori Mincho B1', 'Yu Mincho', serif;
  font-size: 16px;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}
.viewer-shell .youtube-terms {
  font-size: 10px;
  line-height: 1.9;
}
.viewer-shell .focus-footer {
  border: 0;
}
@media (max-width: 900px) {
  .viewer-shell .page {
    padding-inline: 0;
  }
  .viewer-shell .library-toolbar,
  .viewer-shell .work-filters,
  .viewer-shell .data-notice,
  .viewer-shell .site-footer {
    margin-inline: 16px;
  }
  .viewer-shell .library-scroll {
    padding-inline: 0;
  }
  .viewer-shell .site-header {
    padding-top: max(16px, env(safe-area-inset-top, 0px));
  }
  .viewer-shell .focus-dialog::backdrop {
    background: var(--ledger-paper);
    backdrop-filter: none;
  }
  .viewer-shell .focus-dialog[open] {
    isolation: isolate;
    background: transparent;
    position: fixed;
    inset: 0;
    margin: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  /* One viewport-sized paper behind both the sticky heading and the content.
     Avoid restarting the gradient in the short heading or stretching it with
     the length of the song's related entries. */
  .viewer-shell .focus-dialog[open]::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--ledger-paper);
    pointer-events: none;
  }
  .viewer-shell .focus-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--ledger-paper);
    background-size: 100vw 100dvh;
    background-position: top left;
    background-repeat: no-repeat;
    padding-top: max(14px, env(safe-area-inset-top, 0px));
  }
  .viewer-shell .focus-heading {
    overflow: visible;
    text-align: left;
  }
  .viewer-shell .focus-header h2 {
    width: 100%;
    white-space: nowrap;
    overflow-wrap: normal;
    font-size: var(--mobile-title-size, 30px);
    line-height: 1.4;
  }
  .viewer-shell .focus-body {
    flex: none;
    overflow: visible;
    min-height: 0;
  }
  .viewer-shell .graph-side,
  .viewer-shell .player-side,
  .viewer-shell .graph-scroll {
    overflow: visible;
  }
  .viewer-shell .relation-pair {
    display: block;
    overflow: visible;
  }
  .viewer-shell .pair-select {
    width: 100%;
    flex-wrap: wrap;
    gap: 2px 0;
    position: relative;
    min-height: 0;
  }
  /* Keep a generous tap target over the heading and performance, without
     reserving an empty row between their text. */
  .viewer-shell .pair-select::after {
    content: '';
    position: absolute;
    inset: 0;
    min-height: 44px;
  }
  .viewer-shell .pair-select > :first-child {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    margin-right: -2em;
  }
  .viewer-shell .pair-select > .pair-peer {
    flex: 0 1 auto;
    min-width: 0;
    max-width: calc(100% - 2em);
    /* Cancels the first title's margin on one row; adds two characters only
       when this counterpart wraps onto a new row. */
    margin-left: 2em;
    white-space: normal;
  }
  .viewer-shell .pair-peer > :last-child {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .viewer-shell .edit-page-link,
  .viewer-shell .relation-edit-link {
    display: none;
  }
  .viewer-shell .relation-heading:has(.related-label > .sr-only:only-child) {
    display: none;
  }
  .viewer-shell .focus-body {
    display: block;
  }
  .viewer-shell .graph-side {
    padding: 4px 20px 8px;
  }
  .viewer-shell .related-content {
    padding: 14px 20px 24px;
  }
  .viewer-shell .player-side {
    padding: 8px 20px 4px;
  }
  .viewer-shell .relation-list {
    gap: 20px;
  }
  .viewer-shell .song-pair-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .viewer-shell .relation-pair {
    font-size: 18px;
    line-height: 1.5;
    padding-block: 0;
  }
  .viewer-shell .relation-work {
    margin-top: 0;
    line-height: 1.4;
  }
  .viewer-shell .pair-heading {
    padding-block: 4px 3px;
  }
  .viewer-shell .player-choices button {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .viewer-shell .relation-playbacks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 650px) {
  .viewer-shell .work-card-header h3 {
    font-size: 17px;
  }
  .viewer-shell .focus-header {
    padding: max(14px, env(safe-area-inset-top, 0px)) 14px 8px 18px;
  }
  .viewer-shell .focus-header h2 {
    font-size: var(--mobile-title-size, 24px);
  }
  .viewer-shell .graph-side {
    padding-inline: 14px;
  }
  .viewer-shell .related-content {
    padding-inline: 14px;
  }
  .viewer-shell .song-pair-card {
    column-gap: 0;
  }
  .viewer-shell .song-pair-card > .relation-card,
  .viewer-shell .song-pair-card > .relation-card + .relation-card {
    padding-inline: 7px;
  }
  .viewer-shell .pair-heading {
    padding-inline: 7px;
  }
  .viewer-shell .clip-button {
    font-size: 12px;
  }
  .viewer-shell .relation-pair {
    font-size: 17px;
  }
}

/* Muted internal scrollbars. Firefox uses its native thin width; browsers with
   scrollbar pseudo-elements get an exact 6px track and thumb-only hover. */
.viewer-shell,
.viewer-shell * {
  scrollbar-width: thin;
  scrollbar-color: #c8c1b8 transparent;
}
.viewer-shell *:hover {
  scrollbar-color: #afa394 transparent;
}
@supports selector(::-webkit-scrollbar) {
  .viewer-shell,
  .viewer-shell *,
  .viewer-shell *:hover {
    scrollbar-width: auto;
    scrollbar-color: auto;
  }
  .viewer-shell::-webkit-scrollbar,
  .viewer-shell *::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  .viewer-shell::-webkit-scrollbar-track,
  .viewer-shell *::-webkit-scrollbar-track {
    background: transparent;
  }
  .viewer-shell::-webkit-scrollbar-thumb,
  .viewer-shell *::-webkit-scrollbar-thumb {
    background: #c8c1b8;
    border: 0;
    border-radius: 3px;
  }
  .viewer-shell::-webkit-scrollbar-thumb:hover,
  .viewer-shell *::-webkit-scrollbar-thumb:hover {
    background: #afa394;
  }
  .viewer-shell::-webkit-scrollbar-corner,
  .viewer-shell *::-webkit-scrollbar-corner {
    background: transparent;
  }
  .viewer-shell::-webkit-scrollbar-button,
  .viewer-shell *::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
  }
}
