/* The Chords drawer on the move (js/chordsdrawer.js, js/onthemove.js): the stage, the parts, and their
   Play and Tweak layers. Nick's side. The player wears Moon, as v2.css builds the drawers; the stage is
   Moon's window from the kit mix (Readout's warm black glass in a bezel, "for anything that glows"), so
   the chords glow in their own colors. Everything here sits on Moon: in the drawer, or in a Moon-toned
   sheet (drill.css). Color only means music: --c is the chord's step in the key, --nc the next chord's. */

/* ---------- the frame: the stage and the parts take the drawer's full width under Peter's row ---------- */

.drawer-chords > .otm,
.drawer-chords > .cparts {
  flex: 1 1 100%;
  min-width: 0;
}

/* The drawers can grow taller than the screen once a layer opens in place: let the column scroll
   rather than run off the bottom. It bleeds out at the sides so the Moon body's shadow isn't cut, and
   fades at the top and bottom. (Peter's frame; P41 moves the drawers into Create's sheet.) */
body[data-state="riff"] .drawers {
  --bleed: 64px;
  flex: 0 1 auto;
  width: calc(min(var(--col), 100%) + 2 * var(--bleed));
  min-height: 0;
  margin-right: calc(-1 * var(--bleed));
  margin-left: calc(-1 * var(--bleed));
  padding: 16px var(--bleed) 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent, #000 14px, #000 calc(100% - 16px), transparent);
  mask-image: linear-gradient(transparent, #000 14px, #000 calc(100% - 16px), transparent);
}

@media (max-width: 639px) {
  body[data-state="riff"] .drawers {
    --bleed: var(--gutter);
  }
}

body[data-state="riff"] .drawers::-webkit-scrollbar {
  display: none;
}

/* ---------- the window ---------- */

.otm {
  --otm-win: #14100C;
  --otm-win-hi: #2A2119;
  --otm-bezel: #222632;
  --otm-bezel-edge: rgba(241, 237, 228, .16);
  --otm-label: rgba(241, 237, 228, .7);
  --c: var(--starlight);
  --nc: var(--starlight);
  container-type: inline-size;
  padding: 4px;
}

.otm-win {
  position: relative;
  padding: 8px 12px 14px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, 0) 38%), radial-gradient(130% 170% at 50% -10%, var(--otm-win-hi) 0%, var(--otm-win) 68%);
  box-shadow: inset 0 2px 9px rgba(0, 0, 0, .8), inset 0 0 0 1px rgba(0, 0, 0, .65), 0 0 0 3px var(--otm-bezel), 0 0 0 4px var(--otm-bezel-edge), 0 1px 0 4px var(--moon-bevel-hi, rgba(255, 255, 255, .85));
  color: var(--starlight);
}

.otm :focus-visible {
  outline-color: var(--starlight);
}

/* the top line: where the band is, the view, and "i" */
.otm-top {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
}

.otm-where {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--otm-label);
  font-size: 12.5px;
  font-weight: 500;
}

.otm-pick {
  position: relative;
  flex: none;
}

.otm-vbtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 8px 0 13px;
  border: 1px solid rgba(241, 237, 228, .16);
  border-radius: var(--r-pill);
  color: var(--starlight);
  font-size: 13px;
  font-weight: 500;
  transition: border-color var(--t) ease, background-color var(--t) ease;
}

.otm-vchev {
  width: 16px;
  height: 16px;
}

.otm-vbtn[aria-expanded="true"] {
  border-color: rgba(241, 237, 228, .5);
  background-color: rgba(241, 237, 228, .08);
}

.otm-vbtn[aria-expanded="true"] .otm-vchev {
  transform: rotate(180deg);
}

/* The instruments shown, beside the view: the same little button, its menu a list to tick. */
.otm-pick-inst {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0 6px 0 8px;
}

.otm-ibtn {
  max-width: 100%;
}

.otm-iname {
  overflow: hidden;
  max-width: 12em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.otm-imenu {
  min-width: 180px;
}

.otm-imenu button {
  min-height: 44px;
}

/* "i": a 24px hairline circle in a 40px hit area, as in the rooms. */
.otm-i {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
}

.otm-i span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(241, 237, 228, .2);
  border-radius: 50%;
  color: var(--otm-label);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
}

.otm-i[aria-expanded="true"] span {
  border-color: rgba(241, 237, 228, .6);
  color: var(--starlight);
}

@media (hover: hover) {
  .otm-vbtn:hover {
    border-color: rgba(241, 237, 228, .42);
  }

  .otm-i:hover span {
    border-color: rgba(241, 237, 228, .5);
    color: var(--starlight);
  }
}

.otm-about {
  max-width: 62ch;
  margin: 2px 0 8px;
  color: rgba(241, 237, 228, .78);
  font-size: 13px;
  line-height: 1.5;
}

.otm-about[hidden] {
  display: none;
}

/* the view menu: a little list on the window's glass */
.otm-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: -48px;
  z-index: 5;
  width: max-content;
  min-width: 236px;
  max-width: min(300px, calc(100vw - 40px));
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid rgba(241, 237, 228, .14);
  border-radius: var(--r-card);
  background: #1A1511;
}

.otm-menu[hidden] {
  display: none;
}

.otm-menu button {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px 10px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 7px 10px 7px 32px;
  border-radius: 10px;
  color: var(--starlight);
  text-align: left;
}

.otm-mname {
  grid-column: 1;
  font-size: 14px;
  font-weight: 500;
}

.otm-mwhat {
  grid-column: 1;
  color: var(--otm-label);
  font-size: 12px;
}

.otm-mine {
  grid-row: 1 / span 2;
  grid-column: 2;
  padding: 2px 8px;
  border: 1px solid rgba(241, 237, 228, .18);
  border-radius: var(--r-pill);
  color: var(--otm-label);
  font-size: 11px;
  white-space: nowrap;
}

.otm-menu button[aria-checked="true"]::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 13px;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--starlight);
}

@media (hover: hover) {
  .otm-menu button:hover {
    background: rgba(241, 237, 228, .07);
  }
}

.otm-menu button:focus-visible {
  outline-offset: -2px;
  background: rgba(241, 237, 228, .07);
}

/* ---------- Chord: this chord big, its picture, the next one waiting ---------- */

.otm-body {
  position: relative;
  display: grid;
  grid-template-columns: auto auto 1px auto auto;
  grid-template-areas: "now dia rule next ndia";
  gap: 6px 28px;
  align-items: center;
  justify-content: center;
  min-height: 150px;
}

.otm-now {
  grid-area: now;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 84px;
}

.otm-num {
  min-height: 18px;
  color: var(--otm-label);
  font-size: 13px;
  font-weight: 500;
}

.otm-name {
  color: color-mix(in oklab, var(--c) 80%, var(--starlight));
  font-size: 64px;
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -.02em;
  white-space: nowrap;
  text-shadow: 0 0 22px color-mix(in oklab, var(--c) 45%, transparent);
  transform-origin: 50% 60%;
}

.otm-name[data-len="m"] {
  font-size: 52px;
}

.otm-name[data-len="l"] {
  font-size: 38px;
}

.otm-beats {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.otm-beats i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(241, 237, 228, .16);
  transition: transform 140ms var(--ease-out);
}

.otm-beats i.on {
  background: var(--c);
  box-shadow: 0 0 8px color-mix(in oklab, var(--c) 60%, transparent);
}

.otm-beats i.cur {
  transform: scale(1.3);
}

.otm-dia,
.otm-ndia {
  margin: 0;
}

.otm-dia {
  grid-area: dia;
  width: 112px;
}

.otm-ndia {
  grid-area: ndia;
  width: 72px;
}

.otm-dia[data-inst="kb"] {
  width: 230px;
}

.otm-ndia[data-inst="kb"] {
  width: 150px;
}

:is(.otm-dia, .otm-ndia, .otm-big, .otm-all) svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  color: var(--starlight);
}

:is(.otm-dia, .otm-big) figcaption {
  margin-top: 4px;
  color: var(--otm-label);
  font-size: 12px;
  text-align: center;
}

.otm-rule {
  grid-area: rule;
  align-self: stretch;
  width: 1px;
  margin: 14px 0;
  background: rgba(241, 237, 228, .12);
}

.otm-next {
  grid-area: next;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 84px;
}

.otm-nlab {
  min-height: 18px;
  color: var(--otm-label);
  font-size: 13px;
}

.otm-nname {
  color: color-mix(in oklab, var(--nc) 66%, var(--starlight));
  font-size: 34px;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
}

.otm-in {
  min-height: 20px;
  margin-top: 2px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The next one waits a little dim, and comes up in the last beat. */
.otm-next,
.otm-ndia,
.otm-bnext {
  opacity: .72;
  transition: opacity 300ms ease;
}

.otm.soon :is(.otm-next, .otm-ndia, .otm-bnext),
.otm[data-mode="stop"] :is(.otm-next, .otm-ndia, .otm-bnext) {
  opacity: 1;
}

.otm[data-mode="stop"] :is(.otm-next, .otm-ndia, .otm-bnext) {
  opacity: .8;
}

.otm-cv,
.otm-big,
.otm-rec,
.otm-all {
  grid-area: pic;
  display: none;
}

/* ---------- the instrument views: this chord and the next on one line, the instrument under it ---------- */

.otm:not([data-view="chord"]) .otm-body {
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "now . next"
    "pic pic pic";
  gap: 4px 12px;
  justify-content: stretch;
  min-height: 0;
}

.otm:not([data-view="chord"]) .otm-now {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 2px 14px;
  align-items: center;
}

.otm:not([data-view="chord"]) .otm-name,
.otm:not([data-view="chord"]) .otm-name[data-len] {
  order: -1;
  font-size: 36px;
}

.otm:not([data-view="chord"]) :is(.otm-num, .otm-dia, .otm-ndia, .otm-rule) {
  display: none;
}

.otm:not([data-view="chord"]) .otm-beats {
  margin-top: 0;
}

.otm:not([data-view="chord"]) .otm-next {
  flex-direction: row;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}

.otm:not([data-view="chord"]) .otm-nname {
  font-size: 22px;
}

.otm:not([data-view="chord"]) .otm-in {
  min-width: 5.2em;
  margin: 0;
}

.otm[data-view="fretboard"] .otm-cv {
  display: block;
  width: 100%;
  height: 156px;
}

.otm[data-view="pics"] .otm-big {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  align-items: flex-end;
  justify-content: center;
  padding: 8px 0 2px;
}

.otm-big figure {
  margin: 0;
}

/* One instrument: its picture of this chord, and the next one beside it. Several (Nick: "you could view guitar and
   piano for example"): this chord on each, side by side, the instrument named under its picture. */
.otm-binst {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
}

.otm-big:not([data-n="1"]) .otm-binst {
  flex-direction: column;
  gap: 5px;
  align-items: center;
}

.otm-bcap {
  color: var(--otm-label);
  font-size: 12px;
}

.otm-binst[data-inst="kb"] {
  flex: 1 1 280px;
  max-width: 520px;
}

.otm-big:not([data-n="1"]) .otm-binst[data-inst="kb"] {
  max-width: 400px;
}

.otm-binst[data-inst="kb"] .otm-bnow {
  width: 100%;
}

.otm-binst[data-inst="kb"] .otm-bnext {
  display: none;
}

.otm-binst:is([data-inst="gtr"], [data-inst="uke"], [data-inst="bass"]) .otm-bnow {
  width: 136px;
}

.otm-big:not([data-n="1"]) .otm-binst:is([data-inst="gtr"], [data-inst="uke"], [data-inst="bass"]) .otm-bnow {
  width: 118px;
}

.otm-binst:is([data-inst="gtr"], [data-inst="uke"], [data-inst="bass"]) .otm-bnext {
  width: 84px;
}

/* ---------- Record: the whole part going round (the Moon kit's dial, on the window's glass) ---------- */

.otm[data-view="record"] .otm-rec {
  display: flex;
  justify-content: center;
  padding: 6px 0 2px;
}

.otm[data-view="record"] .otm-big,
.otm[data-view="all"] .otm-big {
  display: none;
}

.otm-rsvg {
  display: block;
  width: min(100%, 272px);
  height: auto;
  overflow: visible;
}

.otm-rvinyl {
  stroke: rgba(241, 237, 228, .16);
  stroke-width: 1;
}

.otm-rgrv {
  fill: none;
  stroke: rgba(241, 237, 228, .05);
  stroke-width: .7;
}

/* An arc for each chord, in its colour: quiet until the band is on it. */
.otm-rarc {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  opacity: .4;
  transition: opacity 220ms ease, stroke-width 220ms ease;
}

.otm-rarc.is-now {
  stroke-width: 4.5;
  opacity: 1;
  filter: drop-shadow(0 0 4px var(--c));
}

.otm-rname {
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  opacity: .55;
  transition: opacity 220ms ease;
}

.otm-rname.is-now {
  opacity: 1;
}

.otm-rbeat {
  fill: rgba(241, 237, 228, .16);
  transform-box: fill-box;
  transform-origin: center;
}

.otm-rbeat.on {
  fill: var(--c);
}

.otm-rbeat.cur {
  transform: scale(1.5);
}

.otm-rlabel {
  fill: var(--c);
  transition: fill 220ms ease;
}

.otm-rnow {
  font-weight: 650;
  letter-spacing: -.02em;
  text-anchor: middle;
  dominant-baseline: central;
}

.otm-rnum {
  font-size: 9.5px;
  font-weight: 500;
  text-anchor: middle;
  opacity: .75;
}

.otm-rneedle line {
  stroke: var(--starlight);
  stroke-width: 2;
  stroke-linecap: round;
}

.otm-rneedle rect {
  fill: var(--starlight);
}

/* ---------- All chords: every chord of the part, a row for each instrument ---------- */

.otm[data-view="all"] .otm-all {
  display: grid;
  gap: 14px;
  padding: 8px 0 2px;
}

.otm-arow {
  display: grid;
  gap: 6px;
}

.otm-acells {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.otm-acell {
  --ac: var(--starlight);
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 0;
  opacity: .45;
  transition: opacity 220ms ease;
}

.otm-acell.is-now {
  opacity: 1;
}

.otm-aname {
  color: color-mix(in oklab, var(--ac) 80%, var(--starlight));
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.otm-acell figure {
  width: 100%;
  max-width: 96px;
  margin: 0;
}

.otm-arow[data-inst="kb"] .otm-acell figure {
  max-width: 230px;
}

/* ---------- a narrow drawer (a phone) ---------- */

/* Wide: the chord view is short enough to carry its top line in the corners. */
@container (min-width: 521px) {
  .otm[data-view="chord"] .otm-top {
    position: absolute;
    top: 6px;
    right: 8px;
    left: 16px;
    z-index: 2;
    pointer-events: none;
  }

  .otm[data-view="chord"] .otm-top > * {
    pointer-events: auto;
  }

  .otm[data-view="chord"] .otm-top .otm-where {
    align-self: flex-start;
    padding-top: 8px;
  }

  .otm[data-view="chord"] .otm-body {
    padding-top: 14px;
  }

  .otm[data-view="chord"] .otm-about:not([hidden]) {
    margin-top: 44px;
  }
}

/* Narrow (a phone): two rows, this chord and its picture, then the next one and its picture. */
@container (max-width: 520px) {
  .otm-body {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "now dia"
      "next ndia";
    gap: 6px 14px;
    align-items: center;
    justify-content: stretch;
    min-height: 0;
  }

  .otm-rule {
    display: none;
  }

  .otm-now,
  .otm-next {
    align-items: flex-start;
    min-width: 0;
  }

  .otm-name {
    font-size: 50px;
  }

  .otm-name[data-len="m"] {
    font-size: 42px;
  }

  .otm-name[data-len="l"] {
    font-size: 30px;
  }

  .otm-beats {
    margin-top: 8px;
  }

  .otm-next {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0 8px;
    align-items: baseline;
    padding-top: 6px;
    border-top: 1px solid rgba(241, 237, 228, .1);
  }

  .otm-nlab {
    flex-basis: 100%;
  }

  .otm-nname {
    font-size: 26px;
  }

  .otm-dia {
    width: 84px;
  }

  .otm-ndia {
    justify-self: center;
    width: 52px;
  }

  /* The piano picture is wide: it gets the window's width, under the chord, and the next one is named. */
  .otm-body:has(.otm-dia[data-inst="kb"]) {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "now next"
      "dia dia";
  }

  .otm-body:has(.otm-dia[data-inst="kb"]) .otm-next {
    flex-direction: column;
    align-items: flex-end;
    padding-top: 18px;
    border-top: 0;
    text-align: right;
  }

  .otm-dia[data-inst="kb"] {
    width: 100%;
  }

  .otm-ndia[data-inst="kb"] {
    display: none;
  }

  .otm:not([data-view="chord"]) .otm-body {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "now next"
      "pic pic";
  }

  .otm:not([data-view="chord"]) .otm-name,
  .otm:not([data-view="chord"]) .otm-name[data-len] {
    font-size: 32px;
  }

  .otm:not([data-view="chord"]) .otm-now {
    gap: 0 10px;
  }

  .otm:not([data-view="chord"]) .otm-next {
    flex-direction: column;
    gap: 0;
    align-items: flex-end;
    text-align: right;
  }

  .otm:not([data-view="chord"]) .otm-nname {
    font-size: 20px;
  }

  .otm:not([data-view="chord"]) .otm-in {
    min-width: 0;
  }

  .otm[data-view="fretboard"] .otm-cv {
    height: 144px;
  }

  .otm-binst:is([data-inst="gtr"], [data-inst="uke"], [data-inst="bass"]) .otm-bnow,
  .otm-big:not([data-n="1"]) .otm-binst:is([data-inst="gtr"], [data-inst="uke"], [data-inst="bass"]) .otm-bnow {
    width: 112px;
  }

  /* The top line keeps its two menus and the "i"; "Now" is said by the lit beats (and still read out). */
  .otm:not([data-view="chord"]) .otm-where {
    overflow: hidden;
    color: transparent;
    white-space: nowrap;
  }

  /* All chords on a phone: the pianos go two to a row, so their keys can be read. */
  .otm-arow[data-inst="kb"] .otm-acells {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .otm-acells {
    gap: 10px 8px;
  }

  /* Several instruments on a phone: the small pictures share a row, and the piano takes the row under them. */
  .otm[data-view="pics"] .otm-big:not([data-n="1"]) {
    gap: 12px;
  }

  .otm-big:not([data-n="1"]) .otm-binst:is([data-inst="gtr"], [data-inst="uke"], [data-inst="bass"]) {
    flex: 0 1 29%;
  }

  .otm-big:not([data-n="1"]) .otm-binst:is([data-inst="gtr"], [data-inst="uke"], [data-inst="bass"]) .otm-bnow {
    width: 100%;
    max-width: 92px;
  }

  .otm-big:not([data-n="1"]) .otm-binst[data-inst="kb"] {
    order: 2;
    flex-basis: 100%;
    max-width: none;
  }

  .otm-binst:is([data-inst="gtr"], [data-inst="uke"], [data-inst="bass"]) .otm-bnext {
    width: 70px;
  }

  .otm-menu {
    right: -44px;
  }
}

/* ---------- the parts: each one a row, its numbers in the key ---------- */

.cparts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cpart {
  border-top: 1px solid var(--moon-line);
  transition: opacity 220ms var(--ease-out);
}

.cpart-h {
  margin: 0;
  font: inherit;
}

.cpart-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 50px;
  padding: 0 0 0 2px;
  border-radius: 10px;
  color: var(--moon-ink);
  text-align: left;
}

.cpart-name {
  font-size: 15px;
  font-weight: 500;
}

/* A part's chords, as the song builder's small cards (js/chordcard.js). */
.cpart-nums {
  display: flex;
  flex: 1;
  min-width: 0;
}

.cc-row.cpart-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cpart-row .pm {
  color: var(--moon-mtext);
}

.cpart-row[aria-expanded="true"] .pm-v {
  opacity: 0;
}

@media (hover: hover) {
  .cpart-row:hover {
    background-color: color-mix(in srgb, var(--moon-ink) 4%, transparent);
  }
}

.cpart-row:focus-visible {
  outline-offset: 0;
}

/* How the next layer arrives: a plus that turns to a minus in place, a chevron where it slides up as a
   sheet (phones), as in the feature lab. */
.cpart-chev {
  display: none;
  width: 16px;
  height: 16px;
  color: var(--moon-mtext);
}

@media (max-width: 639px) {
  .cpart-row .pm {
    display: none;
  }

  .cpart-chev {
    display: block;
  }
}

/* ---------- Play: the part's chords, big ---------- */

.cplay {
  container-type: inline-size;
  padding: 2px 0 12px;
}

.cplay-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

/* A Moon raised key with words on it. */
.mkey {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--moon-raised), var(--moon-raised-lo));
  box-shadow: inset 0 1px 0 var(--moon-raised-hl), 0 2px 0 var(--moon-raised-edge), 0 7px 11px -7px rgba(0, 0, 0, .35), 0 0 0 1px var(--moon-raised-rim);
  color: var(--moon-ink);
  font-size: 14px;
  font-weight: 500;
  transition: scale var(--t) ease;
}

.mkey:active {
  scale: .98;
}

.mkey[aria-expanded="true"],
.mkey[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--moon-key-hi), var(--moon-key-lo));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 3px 0 var(--moon-key-edge), 0 9px 14px -6px rgba(0, 0, 0, .5), 0 0 0 1px var(--moon-key-rim);
  color: var(--moon-key-ink);
}

.cplay-ipslot,
.cplay-slot {
  margin-bottom: 10px;
}

.cgrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.cgrid:has(.cd-kb2) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@container (max-width: 520px) {
  .cgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .cgrid:has(.cd-kb2) {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ccard {
  --c: var(--moon-ink);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 8px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--moon-raised), var(--moon-raised-lo));
  box-shadow: inset 0 1px 0 var(--moon-raised-hl), 0 2px 0 var(--moon-raised-edge), 0 7px 11px -7px rgba(0, 0, 0, .3), 0 0 0 1px var(--moon-raised-rim);
  transition: box-shadow var(--t) ease, opacity 220ms var(--ease-out);
}

.ccard.is-now {
  box-shadow: inset 0 1px 0 var(--moon-raised-hl), 0 2px 0 var(--moon-raised-edge), 0 7px 11px -7px rgba(0, 0, 0, .3), 0 0 0 2px var(--c);
}

.ccard.is-open {
  box-shadow: inset 0 1px 0 var(--moon-raised-hl), 0 2px 0 var(--moon-raised-edge), 0 7px 11px -7px rgba(0, 0, 0, .3), 0 0 0 1.5px var(--moon-ink);
}

/* The chord over its pictures is the song builder's large card (js/chordcard.js), and the whole tile is its button. */
.ccard-btn {
  position: static;
}

.ccard-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
}

.ccard-btn:focus-visible {
  outline: none;
}

.ccard:has(.ccard-btn:focus-visible) {
  outline: 2px solid var(--moon-ink);
  outline-offset: 3px;
}

.cdias {
  display: grid;
  gap: 10px;
  justify-items: center;
  width: 100%;
}

.cdia {
  width: 100%;
  margin: 0;
  text-align: center;
}

.cdia .cd-svg {
  display: block;
  width: 100%;
  max-width: 150px;
  height: auto;
  margin: 0 auto;
  overflow: visible;
  color: var(--moon-ink);
}

.cdias.is-many .cd-svg {
  max-width: 128px;
}

.cdia .cd-svg.cd-kb2 {
  max-width: 340px;
}

.cdia-inst,
.cdia-alt {
  margin: 4px 0 0;
  color: var(--moon-mtext);
  font-size: 12px;
}

.cdia-capo {
  margin: 0 0 4px;
  color: var(--moon-ink);
  font-size: 12.5px;
  font-weight: 500;
}

.cd-svg .basef {
  font-family: var(--mono);
}

/* ---------- Tweak: a chord up close ---------- */

.ctweak {
  padding: 12px 2px 4px;
  color: var(--moon-ink);
}

.drill .ctweak {
  padding-top: 0;
}

.ct-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
}

/* The chord itself: the song builder's large card. */
.ct-head .ct-name {
  flex: none;
  width: 96px;
}

.ct-jobs {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
}

.ct-job {
  font-weight: 500;
}

.ct-guide {
  color: var(--moon-mtext);
  font-size: 12px;
}

.ct-sec {
  margin-top: 16px;
}

.ct-sec[hidden] {
  display: none;
}

.ct-h {
  margin: 0 0 8px;
  color: var(--moon-mtext);
  font-size: 13px;
  font-weight: 500;
}

.ct-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ct-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 54px;
}

.ct-nname {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--c);
  color: var(--on, var(--space));
  font-size: 16px;
  font-weight: 600;
}

.ct-role {
  color: var(--moon-mtext);
  font-size: 12px;
}

.ct-shapes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ct-shapes .cdia {
  width: 96px;
}

.ct-capo {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}

.ct-capoview .cdia {
  width: 132px;
}

/* A select in Moon's recess. */
.msel-wrap {
  position: relative;
  display: inline-flex;
}

.msel {
  min-height: 40px;
  padding: 0 34px 0 14px;
  border: 0;
  border-radius: 12px;
  appearance: none;
  background: #05070D url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F1EDE4' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .6), 0 0 0 1px var(--moon-raised-rim);
  color-scheme: dark;
  color: var(--moon-ink);
  font: inherit;
  font-size: 14px;
}

/* ---------- "I play": pick any number ---------- */

.ip {
  color: var(--moon-ink);
}

.ip-note {
  margin: 0 0 10px;
  color: var(--moon-mtext);
  font-size: 13px;
}

.ip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ip-row[hidden] {
  display: none;
}

.ip-pick,
.ip-more {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
}

.ip-pick {
  background: linear-gradient(180deg, var(--moon-raised), var(--moon-raised-lo));
  box-shadow: inset 0 1px 0 var(--moon-raised-hl), 0 2px 0 var(--moon-raised-edge), 0 7px 11px -7px rgba(0, 0, 0, .35), 0 0 0 1px var(--moon-raised-rim);
  color: var(--moon-ink);
}

.ip-pick[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--moon-key-hi), var(--moon-key-lo));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 3px 0 var(--moon-key-edge), 0 9px 14px -6px rgba(0, 0, 0, .5), 0 0 0 1px var(--moon-key-rim);
  color: var(--moon-key-ink);
}

.ip-more {
  margin: 6px 0;
  padding: 0 10px;
  color: var(--moon-mtext);
}

@media (hover: hover) {
  .ip-more:hover {
    color: var(--moon-ink);
  }
}

/* ---------- calm: reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .otm *,
  .otm-beats i,
  .cpart,
  .ccard {
    transition: none !important;
  }

  .otm-beats i.cur {
    transform: none;
  }

  .mkey:active {
    scale: none;
  }
}

.otm.otm-still .otm-beats i.cur {
  transform: none;
}
