/* The set builder keeps the work surface calm; actions live one tap away. */
.set-builder {
  display: grid;
  gap: 1.5rem;
}

.set-builder__header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1.5rem;
}

.set-builder__header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
}

.set-builder__subline,
.set-builder__empty,
.set-builder__transition,
.set-builder-row__secondary,
.set-builder-row__note,
.set-builder__participants-summary {
  color: var(--muted);
}

.set-builder__subline { margin: 0.35rem 0 0; }
.set-builder__reorder-notice { min-height: 1.25rem; margin: 0.5rem 0 0; color: var(--muted); font-size: 0.875rem; }

.set-builder__actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.set-builder .button { min-height: 2.75rem; border-radius: var(--radius-control); }
.set-builder__participants > summary,
.set-builder__details > summary {
  display: flex;
  width: 100%;
  min-height: 2.75rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}

.set-builder__participants > summary::-webkit-details-marker,
.set-builder__details > summary::-webkit-details-marker { display: none; }

.set-builder__participants-panel,
.set-builder__details-panel {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.set-builder__list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.set-builder-row {
  --row-actions: 0px;
  display: grid;
  grid-template-columns: var(--row-handle, 0px) 2rem minmax(0, 1fr) 48px auto var(--row-actions);
  align-items: center;
  min-height: 4rem;
  border-bottom: 1px solid var(--rule);
}

.set-builder-row--managed { --row-actions: 5.25rem; --row-handle: 2.75rem; }
.set-builder-row--segment { grid-template-columns: var(--row-handle, 0px) 2rem minmax(0, 1fr) auto var(--row-actions); min-height: 3.25rem; }
.set-builder-row__drag-handle {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: grab;
  place-items: center;
  touch-action: none;
}
.set-builder-row__drag-handle::before {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 8px 0 currentColor, 0 8px currentColor, 8px 8px currentColor, 0 16px currentColor, 8px 16px currentColor;
  content: "";
}
.set-builder-row__drag-handle:active { cursor: grabbing; }
.set-builder-row__drag-handle:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
.set-builder-row.is-dragging { position: relative; z-index: 1; outline: 2px solid var(--accent); outline-offset: -2px; box-shadow: 0 5px 12px color-mix(in srgb, var(--ink) 18%, transparent); }
.set-builder-row.is-insertion-before { border-top: 3px solid var(--accent); }
.set-builder-row.is-insertion-after { border-bottom: 3px solid var(--accent); }
.set-builder-row__number { color: var(--muted); font-size: 0.94rem; }
.set-builder-row__identity { min-width: 0; }
.set-builder-row__title {
  display: block;
  overflow: hidden;
  font-size: 1.125rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.set-builder-row__secondary {
  display: block;
  overflow: hidden;
  font-size: 0.875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The same key badge as the library: fixed 48px column, 40x32 badge, one spelling. */
.set-builder-row__key {
  display: block;
  width: 40px;
  height: 32px;
  justify-self: center;
  overflow: hidden;
  border: 1.5px solid var(--key-line);
  border-radius: 8px;
  color: var(--key-ink);
  background: var(--key-fill);
  font-family: var(--font-ui);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 29px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.set-builder-row__key:empty { visibility: hidden; }

.set-builder-row__key--editable { text-decoration: none; }
.set-builder-row__duration {
  min-width: 3.75rem;
  padding-inline: 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: right;
  white-space: nowrap;
}
.set-builder-row__note { grid-column: 3 / 6; margin: -0.25rem 0 0.75rem; font-size: 0.875rem; font-style: italic; }
.set-builder-row__note p { margin: 0; }

/* Visible row actions: remove (x) and a chevron that opens an inline panel under the row. */
.set-builder-row__actions { display: flex; justify-content: flex-end; }
.set-builder-row__actions form { margin: 0; }
.set-builder-row__remove,
.set-builder-row__expand {
  display: grid;
  width: 2.5rem;
  height: 2.75rem;
  padding: 0;
  place-items: center;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.set-builder-row__remove:hover,
.set-builder-row__remove:focus-visible { color: var(--danger); }
.set-builder-row__remove .icon { width: 1.1rem; height: 1.1rem; }
.set-builder-row__expand span {
  width: 0.55rem;
  height: 0.55rem;
  margin-top: -0.2rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.set-builder-row__expand[aria-expanded="true"] span { margin-top: 0.2rem; transform: rotate(225deg); }
.set-builder-row__expand:hover,
.set-builder-row__expand:focus-visible { color: var(--ink); }
.set-builder-row__panel {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem 0.75rem;
}
.set-builder-row__panel[hidden] { display: none; }
.set-builder-row__panel form { margin: 0; }
.set-builder-row__panel p { margin: 0; flex-basis: 100%; }
.set-builder-row__transition { min-height: 1.25rem; padding-left: 4.75rem; color: var(--muted); font-size: 13px; font-weight: 600; line-height: 20px; }
.set-builder__footer { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.set-builder__footer .button { color: var(--ink); }

.set-builder__participants,
.set-builder__details { position: relative; }
.set-builder__participants-panel,
.set-builder__details-panel { padding: 1rem; }
.set-builder__details-panel { display: grid; margin-top: 0.5rem; gap: 1rem; }
.set-builder__details-panel > * { margin: 0; }
.set-builder__details-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.set-builder__details-actions form { margin: 0; }
.set-builder__details-danger { padding-top: 0.75rem; border-top: 1px solid var(--hairline); }
.set-builder__details-danger form { margin: 0; }
.set-builder__remove-selected { margin: 0; }
.set-builder__participants-panel ul { display: grid; margin: 0; padding: 0; gap: 0.5rem; list-style: none; }
.set-builder__participants-panel li { display: flex; justify-content: space-between; gap: 1rem; }
.set-builder__participants-panel li span { color: var(--muted); }
.set-builder__participants-panel details { margin-left: auto; }

.set-builder:not(.is-selecting) .list-selection-control,
.set-builder:not(.is-selecting) .list-selection-rail { display: none; }
.set-builder.is-selecting .set-builder-row {
  grid-template-columns: 2.75rem var(--row-handle, 0px) 2rem minmax(0, 1fr) 48px auto var(--row-actions);
}
.set-builder.is-selecting .set-builder-row--segment { grid-template-columns: 2.75rem var(--row-handle, 0px) 2rem minmax(0, 1fr) auto var(--row-actions); }
.set-builder.is-selecting .set-builder-row__note { grid-column: 4 / 7; }

@media (max-width: 640px) {
  .set-builder__header { display: grid; gap: 1rem; }
  .set-builder__actions { justify-content: start; }
  .set-builder__actions > * { flex: 1 1 0; }
  .set-builder__actions .button,
  .set-builder__actions .share-sheet-launch .button { width: 100%; justify-content: center; }
  .set-builder-row { grid-template-columns: var(--row-handle, 0px) minmax(0, 1fr) 48px var(--row-actions); }
  .set-builder-row--managed { --row-actions: 5rem; }
  .set-builder-row--segment { grid-template-columns: var(--row-handle, 0px) minmax(0, 1fr) var(--row-actions); }
  .set-builder-row__number,
  .set-builder-row__secondary,
  .set-builder-row__duration { display: none; }
  .set-builder-row__note { grid-column: 2 / 4; }
  .set-builder-row__transition { padding-left: 0; }
  .set-builder.is-selecting .set-builder-row { grid-template-columns: 2.25rem var(--row-handle, 0px) minmax(0, 1fr) 48px var(--row-actions); }
  .set-builder.is-selecting .set-builder-row--segment { grid-template-columns: 2.25rem var(--row-handle, 0px) minmax(0, 1fr) var(--row-actions); }
  .set-builder.is-selecting .set-builder-row__note { grid-column: 3 / 5; }
}

@media (prefers-reduced-motion: reduce) {
  .set-builder-row { transition: none; }
}

@media print {
  .set-builder__actions,
  .set-builder-row__actions,
  .set-builder-row__panel,
  .set-builder-row__drag-handle,
  .set-builder__details,
  .set-builder__footer,
  .set-builder .list-selection-rail { display: none; }
}

/* Set titles (set index cards and set rows) are ink, never amber, and only underline when pointed at. */
.setlist-card,
.setlist-card__identity strong,
.set-builder-row__title { color: var(--ink); text-decoration: none; }
.setlist-card:hover .setlist-card__identity strong,
.setlist-card:focus-visible .setlist-card__identity strong { text-decoration: underline; text-underline-offset: 3px; }
