/* The song builder (js/songdrawer.js, js/songpart.js, js/chordcard.js): the Song drawer, open. Nick's side.
   The design is "Alive Jam mockups", screens 3 to 6. It's dark, like the rest of Jam (Nick, 2026-11-17: "yes, dark is
   better"): starlight on the panel colour, Newsreader for the song's title and for Riff, Geist for everything you
   tap, Geist Mono for bars and notes. Colour only means music: a chord card takes its step in the key (--c, set by
   js/chordtools.js), with --on as the ink that reads on it.

   While the drawer is open it has the screen: the other drawers step aside, on a phone Riff's chat does too, and on a
   wide screen Riff sits on the right (chat-layout.css). */

/* ---------- the drawer, open: dark, and the screen is its ---------- */

/* The dark body, its tokens (--sb- and Moon's) and the focus ring are every drawer's now: v2.css, "Moon". */

/* Chords and Band step aside. Studio stays, closed, under the song: with Words, Lyrics and Sheet at the foot of the
   builder, the next steps are in reach (Nick, 2026-11-17: "that makes sense to keep, to keep moving in the
   process"). Opening it closes the builder, as opening any drawer does (main.js openDrawer). */
body[data-state="riff"][data-song-open] .drawers .drawer:not([data-drawer="song"], [data-drawer="studio"]) {
  display: none;
}

body[data-state="riff"][data-song-open] .drawers {
  flex: 1 1 auto;
}

#dr-song {
  display: block;
  padding: 0 16px 20px;
}

#dr-song[hidden] {
  display: none;
}

@media (max-width: 639px) {
  #dr-song {
    padding: 0 12px 16px;
  }
}

/* On a phone it's the song or Riff, never both: the chat steps aside while the drawer is open. */
@media (max-width: 639px) {
  body[data-state="riff"][data-song-open] .convo {
    display: none;
  }
}

/* A wide screen gives the song the room beside Riff. */
@media (min-width: 1100px) {
  body[data-state="riff"][data-song-open] .drawers {
    width: calc(min(1240px, 100%) + 2 * var(--bleed));
  }
}

/* When Riff has a phone's screen, the way back to the song sits over his chat. */
button.sb-return {
  display: none;
}

@media (max-width: 639px) {
  body[data-state="riff"][data-song-away] button.sb-return:not([hidden]) {
    display: inline-flex;
    flex: none;
    align-self: flex-start;
    margin-top: 10px;
    background: var(--glass);
  }
}

/* ---------- the builder ---------- */

.sb {
  container: sb / inline-size;
  color: var(--sb-ink);
  font-size: 15px;
  line-height: 1.45;
}

.sb-main,
.sb-adding {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb [hidden] {
  display: none !important;
}

.sb-flex {
  flex: 1;
}

.sb-ic {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-ic.is-fill {
  fill: currentColor;
  stroke: none;
}

/* A Play button holds both pictures: the one that shows is its data-on. */
[data-on="false"] > .sb-ic-pause,
[data-on="true"] > .sb-ic-play {
  display: none;
}

.sb-note {
  margin: 0;
  color: var(--sb-mute);
  font-size: 13px;
}

.sb-h {
  margin: 0;
  color: var(--sb-mute);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
}

.sb-h-strong {
  color: var(--sb-ink);
  font-size: 13.5px;
  font-weight: 600;
}

.sb-sec {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sb-sec-tight {
  gap: 2px;
}

.sb-rule {
  flex: none;
  width: 100%;
  height: 1px;
  background: var(--sb-line);
}

/* Buttons: an outlined pill, a smaller one, and the solid one for the main thing to do. */
.sb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--sb-line2);
  border-radius: 999px;
  background: transparent;
  color: var(--sb-ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color var(--t) ease, border-color var(--t) ease, scale var(--t) ease;
}

.sb-btn-s {
  padding: 0 13px;
  font-size: 13.5px;
}

.sb-btn-solid {
  border-color: var(--starlight);
  background: var(--starlight);
  color: var(--space);
  font-weight: 600;
}

.sb-btn:disabled,
.sb-round:disabled {
  opacity: .38;
}

.sb-btn:active:not(:disabled),
.sb-round:active:not(:disabled),
.sb-play:active,
.sb-feel:active,
.sb-addchip:active {
  scale: .98;
}

@media (hover: hover) {
  .sb-btn:hover:not(:disabled, .sb-btn-solid),
  .sb-round:hover:not(:disabled),
  .sb-play:hover,
  .sb-feel:hover:not([aria-pressed="true"]),
  .sb-addchip:hover,
  .sb-key:hover,
  .sb-i:hover:not([aria-expanded="true"]) {
    border-color: var(--starlight);
    background-color: var(--lift);
  }

  .sb-btn-solid:hover {
    background: #fff;
  }
}

.sb-wide {
  width: 100%;
}

.sb-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  color: var(--sb-ink2);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sb-round {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--sb-line2);
  border-radius: 999px;
  color: var(--sb-ink);
}

.sb-in {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--sb-line2);
  border-radius: 999px;
  outline-offset: 2px;
  background: var(--sb-card);
  color: var(--sb-ink);
  font: inherit;
  font-size: 16px;
}

.sb-in::placeholder {
  color: var(--sb-mute);
  opacity: 1;
}

.sb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sb-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--sb-line2);
  border-radius: 14px;
  background: var(--sb-card);
}

.sb-panelhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ---------- up top: the title, Undo, Redo, Versions, Play the song, the key ---------- */

.sb-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-titlerow,
.sb-hist,
.sb-playrow {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* On the narrowest phones a row takes a second line sooner than it runs off the side. */
.sb-hist,
.sb-playrow {
  flex-wrap: wrap;
}

.sb-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sb-title:focus-visible {
  outline-offset: 4px;
}

.sb-rename {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 6px;
  border-radius: 10px;
  color: var(--sb-ink2);
  font-size: 13px;
}

.sng-title.sb-in {
  font-family: var(--serif);
  font-size: 19px;
}

.sb-status {
  min-height: 0;
  margin: 0;
  color: var(--sb-ink2);
  font-size: 13.5px;
}

.sb-status:empty {
  display: none;
}

.sb-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--sb-line2);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.sb-keylab {
  color: var(--sb-mute);
  font-weight: 400;
}

.sb-i {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--sb-line2);
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 19px;
  font-style: italic;
  font-weight: 500;
  line-height: 1;
}

.sb-i[aria-expanded="true"],
.sb-key[aria-expanded="true"] {
  border-color: var(--starlight);
  background: var(--starlight);
  color: var(--space);
}

.sb-key[aria-expanded="true"] .sb-keylab {
  color: #3F3D45;
}

.sb-keynote {
  margin: 0;
  color: var(--sb-ink2);
  font-size: 13.5px;
}

.sb-keynote .sb-link {
  min-height: 0;
  padding: 0;
  color: var(--sb-ink);
  font-size: inherit;
}

.sb-modes,
.sb-notes,
.sb-kinds {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sb-notes {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.sb-kinds {
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}

.sb-notekey {
  padding: 0 4px;
}

/* Versions */
.sb-vlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sb-v {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 4px 10px 4px 12px;
  border: 1px solid var(--sb-line);
  border-radius: 12px;
}

.sb-v.is-here {
  border-color: var(--sb-line2);
}

.sb-vtext {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.sb-vname {
  font-size: 14px;
  font-weight: 600;
}

.sb-vline,
.sb-vsame {
  color: var(--sb-mute);
  font-size: 12.5px;
}

.sb-vhere {
  font-size: 12.5px;
  font-weight: 600;
}

/* Why this key */
.sb-reasons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sb-reason {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.sb-reason-n {
  display: grid;
  flex: none;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 1px solid var(--sb-line2);
  border-radius: 50%;
  font-size: 11.5px;
  line-height: 1;
}

.sb-reason p {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--sb-ink2);
  font-size: 14px;
}

.sb-reason strong,
.sb-cue strong {
  color: var(--sb-ink);
  font-weight: 600;
}

/* ---------- the chord card: one card, three sizes ---------- */

.cc {
  position: relative;
  display: flex;
  box-sizing: border-box;
  border: 0;
  font-family: var(--ui);
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  background: var(--c, #2A2E3A);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 color-mix(in srgb, var(--c, #2A2E3A) 72%, #000);
  color: var(--on, var(--starlight));
  text-align: left;
}

.cc-name {
  overflow: hidden;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cc-num {
  min-height: 1.15em;
  line-height: 1.15;
}

.cc-l {
  height: 56px;
  padding: 0 10px;
  border-radius: 11px;
}

.cc-l .cc-name {
  font-size: 17px;
}

.cc-l .cc-num {
  font-size: 12px;
}

.cc-m {
  height: 44px;
  padding: 0 9px;
}

.cc-m .cc-name {
  font-size: 15px;
}

.cc-m .cc-num {
  font-size: 11px;
}

.cc-s {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-width: 34px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 1px 0 color-mix(in srgb, var(--c, #2A2E3A) 72%, #000);
}

.cc-s .cc-name {
  font-size: 13px;
}

.cc-long.cc-l .cc-name,
.cc-long.cc-m .cc-name {
  font-size: 13px;
}

/* The chord the band is on. */
.cc.is-now {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 color-mix(in srgb, var(--c, #2A2E3A) 72%, #000), 0 0 0 2px color-mix(in srgb, var(--c) 60%, #fff);
}

/* The lines under a card: a word in bold, what it does, its notes, where it's from. */
.cc-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.cc-tag,
.cc-word,
.cc-notes,
.cc-from {
  padding-left: 2px;
  overflow: hidden;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cc-tag {
  overflow: visible;
  color: var(--sb-ink);
  font-size: 12px;
  font-weight: 600;
}

.cc-word {
  color: var(--sb-ink2);
  font-size: 12px;
}

.cc-notes {
  color: var(--sb-mute);
  font-family: var(--mono);
  font-size: 11.5px;
}

.cc-from {
  color: var(--sb-mute);
  font-size: 11px;
  white-space: normal;
}

.cc-row {
  display: grid;
  grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

/* ---------- the parts: drawers, closed ---------- */

.sb-hints {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sb-parts.parts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sb-part.part {
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: none;
}

.sb-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--sb-line);
  border-radius: 14px;
  background: var(--sb-card);
}

/* The part the band and Chords are on: a brighter edge, and its name stays plain (song.css gave it a pill). */
.sb-part[aria-current="true"] .sb-row {
  border-color: var(--sb-line2);
}

.sb-part[aria-current="true"] .sb-name {
  margin-left: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--sb-ink);
}

.sb-grip {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  border-radius: 14px 0 0 14px;
  color: var(--sb-mute);
  cursor: grab;
  touch-action: none;
}

.sb-go {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 4px 12px 12px 0;
  border-radius: 0 14px 14px 0;
  color: var(--sb-ink);
  text-align: left;
}

.sb-go:focus-visible,
.sb-grip:focus-visible {
  outline-offset: -3px;
}

.sb-rowhead {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
}

/* On a phone "same as chorus 1" needs every pixel of the line, and so does Play the song with the key and its "i". */
@container sb (max-width: 380px) {
  .sb-rowhead {
    gap: 6px;
  }

  .sb-part .sb-same {
    font-size: 12px;
  }

  .sb-playrow {
    gap: 6px;
  }

  .sb-playrow .sb-key {
    gap: 5px;
    padding: 0 9px 0 11px;
  }

  .sb-playrow .sng-through {
    padding: 0 13px 0 10px;
  }
}

.sb-part .sb-name {
  flex: none;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--sb-ink);
  font-size: 15px;
  font-weight: 600;
}

.sb-same {
  min-width: 0;
  overflow: hidden;
  color: var(--sb-mute);
  font-size: 12.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sb-bars {
  flex: none;
  color: var(--sb-mute);
  font-family: var(--mono);
  font-size: 12px;
}

.sb-openword {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 2px;
  color: var(--sb-ink2);
  font-size: 13px;
}

.sb-cards {
  display: block;
  width: 100%;
}

.sb-nochords {
  color: var(--sb-mute);
  font-size: 13px;
}

/* A row being dragged to another place. */
.sb-row.is-dragging {
  position: relative;
  z-index: 5;
  border-color: var(--starlight);
  cursor: grabbing;
}

.sb-row.is-dragging .sb-grip {
  cursor: grabbing;
}

.sb-parts.is-sorting .sb-part {
  position: relative;
}

/* ---------- a part, open ---------- */

.sb-openpart {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1.5px solid var(--starlight);
  border-radius: 14px;
  background: var(--sb-card);
}

.sb-ophead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sb-kind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 44px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
}

.sb-done {
  padding: 0 11px 0 15px;
}

.sb-plays {
  display: grid;
  flex: 1 1 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  order: 3;
}

.sb-play {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 52px;
  padding: 6px 10px;
  border: 1px solid var(--sb-line2);
  border-radius: 14px;
  color: var(--sb-ink);
  text-align: left;
  transition: background-color var(--t) ease, border-color var(--t) ease, scale var(--t) ease;
}

.sb-play[data-on="true"] {
  border-color: var(--starlight);
  background: var(--lift);
}

.sb-play-t {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.sb-play-a {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.sb-play-b {
  color: var(--sb-mute);
  font-size: 12px;
}

.sb-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.sb-col {
  display: flex;
  flex: 1 1 340px;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* The part's chords: the drawer's strongest heading, in a box of its own. */
.sb-chordbox {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 12px 14px;
  border: 1.5px solid var(--sb-line2);
  border-radius: 14px;
  background: var(--sb-box);
}

.sb-boxhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.sb-boxh {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.sb-sum {
  color: var(--sb-mute);
  font-size: 12.5px;
  white-space: nowrap;
}

.sb-slotrow {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.sb-slots {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A drag starts on the card itself, so the page doesn't scroll from one (as in Build a progression). */
.sb-slots .cc {
  cursor: grab;
  touch-action: none;
}

/* Only the chord being changed wears a ring. */
.sb-slots .cc[aria-pressed="true"] {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 color-mix(in srgb, var(--c, #2A2E3A) 72%, #000), 0 0 0 2px var(--sb-box), 0 0 0 4px var(--starlight);
}

.sb-slots .cc:focus-visible {
  outline-offset: 5px;
}

.sb-slots .cc.is-dragging {
  z-index: 5;
  cursor: grabbing;
  scale: 1.06;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 color-mix(in srgb, var(--c, #2A2E3A) 72%, #000), 0 0 0 1.5px var(--starlight);
}

.sb-slots.is-sorting li {
  position: relative;
}

.sb-addchord {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 56px;
  border: 1.5px dashed var(--sb-line2);
  border-radius: 11px;
  color: var(--sb-ink);
}

.sb-under {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sb-cue {
  margin: 0;
  color: var(--sb-ink2);
  font-size: 14px;
}

.sb-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* The chords to choose from: quieter, below. */
.sb-fits {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.sb-fam {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
}

.sb-chipwrap {
  display: inline-flex;
}

/* A small card's button is 44px tall to the finger, 28px to the eye. */
.sb-chipwrap .cc-s {
  position: relative;
  margin: 8px 0;
}

.sb-chipwrap .cc-s::after {
  content: "";
  position: absolute;
  inset: -8px -3px;
}

.sb-ownrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-morebox {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-tier {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-riffbox {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--sb-line);
  border-radius: 12px;
  background: rgba(241, 237, 228, .06);
}

.sb-riffline {
  margin: 0;
  color: var(--sb-ink2);
  font-size: 13.5px;
}

.sb-riff-side {
  display: none;
}

.sb-ask {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-namerow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sb-lab {
  color: var(--sb-ink2);
  font-size: 14px;
}

.sb-foot {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-footrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 8px;
}

.sb-length {
  display: flex;
  flex: 1 1 100%;
  align-items: center;
  gap: 8px;
}

.sb-lenlab {
  color: var(--sb-ink2);
  font-size: 14px;
}

.sb-len {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 104px;
  line-height: 1.3;
}

.sb-len-a {
  font-size: 13.5px;
  font-weight: 600;
}

.sb-len-b {
  color: var(--sb-mute);
  font-size: 12.5px;
}

.sb-copies {
  display: flex;
  flex: 1 1 100%;
  flex-direction: column;
  gap: 8px;
}

.sb-copies:empty,
.sb-footrow > .sb-flex {
  display: none;
}

/* ---------- ideas ---------- */

.sb-ideaslot,
.sb-ideabox,
.sb-ideas {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-feels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sb-feel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--sb-line2);
  border-radius: 12px;
  color: var(--sb-ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  transition: background-color var(--t) ease, border-color var(--t) ease, scale var(--t) ease;
}

.sb-feel[aria-pressed="true"] {
  border-color: var(--starlight);
  background: var(--starlight);
  color: var(--space);
  font-weight: 600;
}

.sb-idea {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--sb-line);
  border-radius: 14px;
  background: var(--sb-card);
}

.sb-openpart .sb-idea {
  background: var(--sb-box);
}

.sb-ideatitle {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.25;
}

.sb-ideawhy {
  margin: 0;
  color: #DAD6CF;
  font-size: 14px;
}

.sb-idearow {
  display: flex;
  gap: 8px;
}

.sb-ideaplay {
  padding: 0 14px 0 11px;
}

.sb-ideaplay[data-on="true"] {
  border-color: var(--starlight);
  background: var(--lift);
}

.sb-ideause {
  flex: 1;
}

/* ---------- adding a part ---------- */

.sb-add {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-addtoggle {
  justify-content: center;
  border-style: dashed;
  white-space: normal;
}

.sb-addbody {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sb-addh {
  margin: 0;
  color: var(--sb-ink2);
  font-size: 13.5px;
  font-weight: 400;
}

.sb-addchips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sb-addchip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 14px 0 11px;
  border: 1.5px dashed var(--sb-line2);
  border-radius: 12px;
  color: var(--sb-ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--t) ease, border-color var(--t) ease, scale var(--t) ease;
}

.sb-addchip.is-pick {
  border-style: solid;
  border-color: var(--starlight);
  font-weight: 600;
}

.sb-riffsays,
.sb-lead {
  margin: 0;
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.4;
}

.sb-addhead {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-back {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: -10px;
  border-radius: 12px;
  color: var(--sb-ink);
}

.sb-where {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(241, 237, 228, .06);
}

.sb-wheretext {
  margin: 0;
  color: var(--sb-ink2);
  font-size: 13.5px;
}

.sb-order {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sb-orderchip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--sb-line2);
  border-radius: 8px;
  font-size: 12.5px;
  white-space: nowrap;
}

.sb-orderchip.is-new {
  border-color: var(--starlight);
  background: var(--starlight);
  color: var(--space);
  font-weight: 600;
}

/* Words, Lyrics and Sheet sit under the builder, a little apart. */
#dr-song > .swd {
  margin-top: 16px;
}

/* ---------- from a tablet up: Riff is on the page too, so he gets a box in the open part ---------- */

@media (min-width: 640px) {
  .sb-riffbox {
    display: flex;
  }

  .sb-ask {
    display: none;
  }
}

@media (min-width: 1100px) {
  body:not([data-chat-fold]) .sb-riff-side {
    display: inline;
  }

  body:not([data-chat-fold]) .sb-riff-top {
    display: none;
  }
}

/* ---------- with room to spread out (the builder's own width, since Riff may be beside it) ---------- */

@container sb (min-width: 700px) {
  /* The top bar: the title, Rename and My songs, then one row of Play the song, the key and its i, and Undo, Redo and
     Versions together at the end. With more room still (below) it's all one row, as the mockup's desktop has it. */
  .sb-top {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .sb-titlerow {
    flex: 1 1 100%;
  }

  .sb-hist,
  .sb-playrow {
    display: contents;
  }

  .sb-title {
    max-width: 30ch;
    font-size: 26px;
  }

  .sb-top .sng-title {
    flex: 0 1 26ch;
  }

  .sng-through {
    order: 3;
  }

  .sb-key {
    order: 4;
  }

  .sb-i {
    order: 5;
  }

  .sb-hist .sb-flex {
    order: 6;
  }

  .sng-undo {
    order: 7;
  }

  .sng-redo {
    order: 8;
  }

  .sb-versionsbtn {
    order: 9;
  }

  .sb-top > .sb-panel,
  .sb-top > .sb-keynote,
  .sb-top > .sng-head,
  .sb-top > .sb-status {
    flex: 1 1 100%;
    order: 20;
  }

  /* A closed part is one line: its name, its chords, what it's the same as, its bars, Open. */
  .sb-grip {
    width: 36px;
  }

  .sb-go {
    flex-flow: row wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 8px 14px 10px 0;
  }

  .sb-rowhead {
    display: contents;
  }

  .sb-part .sb-name {
    order: 1;
    width: 84px;
  }

  .sb-cards {
    order: 2;
    width: 320px;
    max-width: 100%;
  }

  .sb-same {
    order: 3;
    font-size: 13px;
  }

  .sb-rowhead .sb-flex {
    order: 4;
  }

  .sb-bars {
    order: 5;
  }

  .sb-openword {
    order: 6;
  }

  /* An open part: its two plays sit in its top line, and its foot is one line. */
  .sb-openpart {
    padding: 12px 14px 14px;
  }

  .sb-plays {
    display: flex;
    flex: none;
    order: 0;
  }

  .sb-wide {
    width: auto;
  }

  .sb-length,
  .sb-copies {
    flex: none;
  }

  .sb-copies {
    flex-direction: row;
  }

  .sb-footrow > .sb-flex {
    display: block;
  }

  .sb-ideas {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  .sb-ideause {
    padding: 0 10px;
  }

  .sb-adding .sb-feels,
  .sb-ideaslot .sb-feels {
    max-width: 520px;
  }

  .sb-notes {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .sb-modes {
    max-width: 320px;
  }
}

@container sb (min-width: 1040px) {
  .sb-titlerow {
    display: contents;
  }

  .sb-title,
  .sb-top .sng-title {
    order: 1;
  }

  .sb-rename {
    order: 2;
    margin-right: 4px;
  }

  .sb-titlerow .sb-flex {
    display: none;
  }

  .sgl-open {
    order: 10;
  }
}

/* ---------- calm ---------- */

@media (prefers-reduced-motion: reduce) {
  .sb .sng-head,
  .sb-btn,
  .sb-play,
  .sb-feel,
  .sb-addchip {
    transition: none;
  }

  .sb-slots .cc.is-dragging {
    scale: 1;
  }
}
