/* Chord fingering diagrams (round 6, fingering lane): the SVG drawings, the tap-a-chord popover, the "Chords in this
   song" strip and the "Playing" row of the account menu. Colours come only from theme tokens, so the same markup reads
   in light, dark, Stage (black) and print. Chords are teal in both appearances (--accent). */

/* ---- Diagrams ---------------------------------------------------------------------------------------------------- */
.fg {
  display: block;
  width: 100%;
  height: auto;
  color: var(--ink);
  overflow: visible;
}

.fg--fretboard { max-width: 8.5rem; margin-inline: auto; }
.fg--fretboard[data-strings="4"] { max-width: 6.2rem; }
.fg--fretboard[data-strings="5"] { max-width: 7.2rem; }
.fg--keyboard { max-width: 17rem; margin-inline: auto; }

.fg-string,
.fg-fret {
  stroke: var(--fg-line, var(--hairline));
  stroke-width: 1.1;
}

.fg-nut {
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: butt;
}

.fg-fretnum {
  fill: var(--ink);
  font: 700 11px/1 var(--font-chord, system-ui, sans-serif);
}

.fg-open {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
}

.fg-open--root { fill: var(--accent); stroke: var(--accent); }
.fg-open--fifth { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }

.fg-muted {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.7;
  stroke-linecap: round;
}

.fg-dot,
.fg-barre { fill: var(--accent); }
.fg-dot--fifth { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }

.fg-finger {
  fill: var(--bg);
  font: 700 10px/1 var(--font-chord, system-ui, sans-serif);
}

.fg-finger--hollow { fill: var(--accent); }

.fg-key {
  fill: var(--paper);
  stroke: var(--fg-line, var(--hairline));
  stroke-width: 1;
}

.fg-key--black { fill: var(--ink); stroke: var(--ink); }
.fg-key--on { fill: var(--paper); stroke: var(--accent); stroke-width: 1.5; }
.fg-key--black.fg-key--on { fill: var(--ink); stroke: var(--ink); }
.fg-key--root { stroke: var(--ink); stroke-width: 2.4; }
.fg-key--bass { fill: var(--surface); stroke: var(--accent); stroke-width: 2.2; stroke-dasharray: 3 2; }

.fg-keylabel {
  fill: var(--bg);
  font: 700 8px/1 var(--font-chord, system-ui, sans-serif);
}

.fg-keylabel--black { fill: var(--bg); }
.fg-keylabel--bass { fill: var(--accent); }

.fg-keyname {
  fill: var(--ink);
  font: 700 8px/1 var(--font-chord, system-ui, sans-serif);
}

/* ---- Popover ----------------------------------------------------------------------------------------------------- */
.fg-popover {
  position: fixed;
  z-index: 40;
  width: min(15rem, calc(100vw - 1rem));
  box-sizing: border-box;
  padding: 0.6rem 0.7rem 0.7rem;
  border: 1px solid var(--hairline);
  border-radius: 0.6rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-floating);
  font-size: 1rem;
  line-height: 1.3;
  /* Arrow toward the chord. */
  --fg-arrow-x: 50%;
}

.fg-popover::before {
  position: absolute;
  left: var(--fg-arrow-x);
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid var(--hairline);
  background: var(--surface);
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

.fg-popover[data-placement="below"]::before { top: -0.4rem; border-right: 0; border-bottom: 0; }
.fg-popover[data-placement="above"]::before { bottom: -0.4rem; border-top: 0; border-left: 0; }

.fg-popover:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.fg-popover__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.fg-popover__name {
  color: var(--accent);
  font-family: var(--font-chord, inherit);
  font-size: 1.35rem;
  font-weight: 750;
}

.fg-popover__diagram { padding: 0.15rem 0.2rem; touch-action: pan-y; }
.fg-popover__caption,
.fg-popover__note { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.82rem; text-align: center; }

.fg-popover__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.fg-popover__count { min-width: 4rem; color: var(--muted); font-size: 0.85rem; text-align: center; }

.fg-popover__step {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.fg-popover__step:hover { background: var(--tint); }

.member-nav__playing select {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  height: 1.75rem;
  padding: 0 1.75rem 0 0.5rem;
  border: 1px solid var(--hairline);
  border-radius: 0.4rem;
  color: var(--ink);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ---- Chords strip ------------------------------------------------------------------------------------------------ */
.fg-tools { margin: 0 0 0.5rem; padding-inline: 1rem; }

.fg-strip { margin: 0.25rem 0 0.5rem; }

/* Pinned at the top of the chart's scrolling area, under any sheet or page header, on a solid ground with a hairline
   so chart text never shows through. The collapsed state is the slim handle alone. */
.fg-tools--sticky {
  position: sticky;
  z-index: 4;
  top: 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--hairline);
  background: var(--bg);
}

.fg-tools--sticky .fg-strip { margin: 0; }
.fg-strip--collapsed .fg-strip__toggle { min-height: 1.75rem; }

.fg-strip__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0 0.3rem;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.fg-strip__toggle::after {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg) translateY(-2px);
}

.fg-strip__toggle[aria-expanded="true"]::after { transform: rotate(-135deg) translateY(-2px); }
.fg-strip__toggle:hover { color: var(--ink); }

.fg-strip__title { margin: 0 0 0.4rem; font-size: 1rem; }
/* In a Details card the card heading already says it. */
.details-chords .fg-strip { margin: 0; }
.details-chords .fg-strip__title { display: none; }

/* The instrument label stays fixed at the strip's start; only the diagrams beside it scroll. */
.fg-strip__row { display: flex; align-items: flex-start; gap: 0.4rem; }
.fg-strip__instrument { position: relative; flex: none; }

.fg-strip__instrument-button {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 2.25rem;
  padding: 0 0.3rem;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
}

.fg-strip__instrument-button:hover { color: var(--ink); }
.fg-strip__instrument-button:focus-visible,
.fg-strip__pick:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

.fg-strip__chooser {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  display: grid;
  gap: 0.1rem;
  min-width: 10rem;
  margin: 0.15rem 0 0;
  padding: 0.3rem;
  border: 1px solid var(--hairline);
  border-radius: 0.6rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-floating);
  list-style: none;
}

.fg-strip__chooser[hidden] { display: none; }

.fg-strip__pick {
  width: 100%;
  min-height: 2.5rem;
  padding: 0 0.5rem;
  border: 0;
  border-radius: 0.4rem;
  color: var(--ink);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fg-strip__pick:hover { background: var(--tint); }
.fg-strip__pick[aria-current="true"] { color: var(--accent); font-weight: 700; }

/* One row only: never wraps, scrolls sideways inside itself (touch, wheel, keyboard), never vertically. */
.fg-strip__list {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 0.6rem 0.9rem;
  min-width: 0;
  max-width: 100%;
  margin: 0.2rem 0 0;
  padding: 0 0 0.35rem;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  list-style: none;
  scrollbar-width: thin;
}

.fg-strip__list:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

/* Edge hint: the row fades out on a side that has more beyond it. */
.fg-strip__list[data-more-end] {
  -webkit-mask-image: linear-gradient(to right, var(--ink) calc(100% - 1.75rem), transparent);
  mask-image: linear-gradient(to right, var(--ink) calc(100% - 1.75rem), transparent);
}

.fg-strip__list[data-more-start] {
  -webkit-mask-image: linear-gradient(to left, var(--ink) calc(100% - 1.75rem), transparent);
  mask-image: linear-gradient(to left, var(--ink) calc(100% - 1.75rem), transparent);
}

.fg-strip__list[data-more-start][data-more-end] {
  -webkit-mask-image: linear-gradient(to right, transparent, var(--ink) 1.75rem, var(--ink) calc(100% - 1.75rem), transparent);
  mask-image: linear-gradient(to right, transparent, var(--ink) 1.75rem, var(--ink) calc(100% - 1.75rem), transparent);
}

.fg-strip__item { display: flex; flex: none; flex-direction: column; align-items: center; width: 4.4rem; }
.fg-strip__item .fg--keyboard { max-width: 6.5rem; }
.fg-strip__name { margin-bottom: 0.1rem; color: var(--accent); font-family: var(--font-chord, inherit); font-size: 1.05rem; font-weight: 750; }
.fg-strip__empty { margin: 0.25rem 0; color: var(--muted); font-size: 0.9rem; }

/* Wider tiles for piano so the keyboard stays legible. */
.fg-strip__item:has(.fg--keyboard) { width: 6.8rem; }

/* ---- Account menu: "Playing" row, slim like the Appearance row --------------------------------------------------- */
.member-nav__playing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0;
  padding: 0.15rem 0.7rem;
}

.member-nav__playing label {
  color: var(--menu-muted, var(--muted));
  font-weight: 500;
  line-height: 1.75rem;
}

.member-nav__playing select {
  border-color: var(--menu-edge, var(--hairline));
  color: var(--menu-ink, var(--ink));
  background-color: transparent;
}

.member-nav__playing select option { color: var(--ink); background: var(--surface); }
.member-nav__playing select:focus-visible { outline: 2px solid var(--menu-focus, var(--focus-ring)); outline-offset: 1px; }

/* Compact diagrams (the size the chart's own shapes use) on a phone and in landscape, so the strip stays short. */
@media (max-width: 40rem), (orientation: landscape) and (max-height: 32rem) {
  .fg-strip__item { width: 3.4rem; }
  .fg-strip__item .fg--fretboard { max-width: 4.6rem; }
  .fg-strip__item .fg--keyboard { max-width: 5rem; }
  .fg-strip__item:has(.fg--keyboard) { width: 5.4rem; }
  .fg-strip__name { font-size: 0.95rem; }
  .fg-strip__row { gap: 0.2rem; }
  .fg-strip__instrument-button { max-width: 4.6rem; padding: 0 0.15rem; font-size: 0.75rem; }
}

/* Print: nothing changes in this lane. The popover and strip never print. */
@media print {
  .fg-popover,
  .fg-tools,
  .member-nav__playing { display: none !important; }
}

/* ---- Tappable chords must not change the chart's layout ---------------------------------------------------------- */
/* A chord with role="button" would otherwise pick up the 44px minimum size the shared stylesheet gives every button
   (accessibility.css), which moves the chord units. The chord keeps its own box; the larger touch target is an
   invisible pseudo-element that takes no space. */
.chart-unit__chord[data-fingering-chord],
.chart-cell--chord[data-fingering-chord],
.chart-pickup-part[data-fingering-chord] {
  min-width: 0;
  min-height: 0;
  cursor: pointer;
}

.chart-unit__chord[data-fingering-chord]::after {
  position: absolute;
  inset: -6px -8px -4px;
  content: "";
}

/* The instrument in the popover: small muted text that is a link, not a control. Tapping it swaps the body for a list. */
.fg-popover__instrument,
.fg-popover__playing-label {
  min-width: 0;
  min-height: 0;
  padding: 0.25rem 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
}

.fg-popover__instrument {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
}

.fg-popover__instrument .icon { width: 14px; height: 14px; flex: none; }

/* Label and icon are one tap target of at least 32px; the overlay takes no layout space. */
.fg-popover__instrument::after {
  position: absolute;
  inset: -8px -6px;
  content: "";
}
.fg-popover__instrument:hover { color: var(--ink); }
.fg-popover__list { display: grid; gap: 0.1rem; margin: 0; padding: 0; list-style: none; }

.fg-popover__pick {
  width: 100%;
  min-height: 2.5rem;
  padding: 0 0.5rem;
  border: 0;
  border-radius: 0.4rem;
  color: var(--ink);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fg-popover__pick:hover { background: var(--tint); }
.fg-popover__pick[aria-current="true"] { color: var(--accent); font-weight: 700; }
