@layer components {
  /* ─── Member card ───────────────────────── */

  /* ─── Member list ───────────────────────── */

  /* The list's head: the title, and "Manage" at the end — or, while
     managing, "Delete" for the seats checked and "Done". */
  .member-list__head {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    margin-block-end: 1rem;
  }

  /* "Manage" is a line of text, but padded and bordered like the pills that
     take its place, so the head keeps its height and the list stays put on
     the switch. */
  .member-list__manage {
    background: none;
    border: 1.5px solid transparent;
    color: var(--color-brand);
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.625rem 0;
    white-space: nowrap;
  }

  .member-list__managing {
    display: none;
    gap: 0.5rem;
  }

  .member-list.is-managing .member-list__manage {
    display: none;
  }

  .member-list.is-managing .member-list__managing {
    display: flex;
  }

  /* ─── Member row ────────────────────────── */

  /* One seat in the list: the checkbox of the "Manage" mode beside the
     card, outside it, then the card. */
  .member-row {
    align-items: flex-start;
    display: flex;
    gap: 0.75rem;
  }

  /* The check column is as wide as its box and as tall as the card's header
     line, so the box sits level with the avatar whether the card is open or
     not. It only takes its place while managing; the owner's row carries an
     empty one so its card stays in line with the rest. */
  .member-row__check {
    align-items: center;
    block-size: calc(2.5rem + 2 * 0.875rem);
    display: none;
    flex-shrink: 0;
    inline-size: 1.125rem;
  }

  .member-list.is-managing .member-row__check {
    display: flex;
  }

  .member-row__checkbox {
    accent-color: var(--color-brand);
    block-size: 1.125rem;
    cursor: pointer;
    inline-size: 1.125rem;
    margin: 0;
  }

  /* ─── Member card ───────────────────────── */

  /* The seat's row: who, and "Change access" at its end. */
  .settings-list__row.member-card {
    flex: 1;
    min-inline-size: 0;
  }

  .member-card__header {
    align-items: center;
    display: flex;
    flex: 1;
    gap: 0.875rem;
    min-inline-size: 0;
  }

  /* The holder's photo, or their initials the way the nav's chip shows them;
     outlined for everyone but the owner. */
  .member-card__avatar {
    align-items: center;
    background: var(--color-surface);
    block-size: 2.5rem;
    border: 1.5px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-ink);
    display: flex;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 700;
    inline-size: 2.5rem;
    justify-content: center;
    overflow: hidden;
  }

  .settings-list__row--current .member-card__avatar {
    background: var(--color-brand-fill);
    border-color: transparent;
    color: var(--color-ink-inverted);
  }

  .member-card__avatar--photo {
    background: var(--color-surface-tint);
  }

  .member-card__avatar img {
    block-size: 100%;
    inline-size: 100%;
    object-fit: cover;
  }

  /* ─── Change access dialog ──────────────── */

  .member-dialog {
    inline-size: min(40rem, calc(100dvw - 2rem));
  }

  .member-dialog__head {
    gap: 0.875rem;
    justify-content: flex-start;
  }

  .member-dialog__title {
    font-size: 1.125rem;
    margin: 0;
  }

  .member-dialog__role {
    margin-block-end: 1.25rem;

    @media (width >= 768px) {
      max-inline-size: 50%;
    }
  }

  .member-dialog__foot {
    align-items: center;
    gap: 0.75rem;
  }

  .member-dialog__removal {
    margin-inline-end: auto;
  }

  .member-dialog__remove {
    align-items: center;
    color: var(--color-negative);
    cursor: pointer;
    display: flex;
    font-size: 0.875rem;
    font-weight: 600;
    gap: 0.375rem;
    list-style: none;

    &::-webkit-details-marker {
      display: none;
    }
  }

  /* Asked once more, the question takes the whole foot: the link that asked
     it and the dialog's own buttons step aside. */
  .member-dialog__removal[open] {
    flex: 1;

    .member-dialog__remove {
      display: none;
    }
  }

  .member-dialog__foot:has(.member-dialog__removal[open]) :is(.member-dialog__cancel, .member-dialog__save) {
    display: none;
  }

  .member-dialog__confirm {
    align-items: center;
    background: var(--color-negative-tint);
    border-radius: var(--radius-md);
    color: var(--color-negative-strong);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.875rem;
    font-weight: 600;
    gap: 0.75rem;
    padding: 0.75rem 1rem;

    p {
      flex: 1;
      margin: 0;
      min-inline-size: 12rem;
    }
  }

  /* ─── A firm's team ─────────────────────── */

  /* A colleague at a glance: who, the clients they work on, and their role
     as a pill. */
  .member-card__you {
    color: var(--color-ink-muted);
    font-weight: 500;
  }

  .member-card__clients {
    color: var(--color-ink-secondary);
    flex-shrink: 0;
    font-size: 0.875rem;
    white-space: nowrap;
  }

  .member-card__role {
    align-items: center;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-pill);
    color: var(--color-brand);
    display: inline-flex;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
    gap: 0.25rem;
    padding: 0.375rem 0.875rem;
    white-space: nowrap;
  }

  .member-card__avatar--pending {
    background: var(--color-surface-tint);
    color: var(--color-ink-muted);
  }

  .member-list__pending {
    margin-block-start: 0.75rem;
  }

  @media (width < 768px) {
    .member-card__clients {
      display: none;
    }
  }
}
