.tiptap-button-group {
  display: flex;
  width: fit-content;
  align-items: stretch;

  /* nested tiptap-button-group gets a gap */
  &:has(> [data-slot="tiptap-button-group"]) {
    gap: 0.125rem;
  }

  /* focus-visible children stack correctly */
  & > *:focus-visible {
    position: relative;
    z-index: 10;
  }

  /* select trigger without explicit width becomes fit-content */
  & > [data-slot="select-trigger"]:not([class*="w-"]) {
    width: fit-content;
  }

  /* input children fill remaining space */
  & > input {
    flex: 1;
  }
}

/* Corners are only squared where two children meet, so first/last children
   keep their own size-appropriate radius (e.g. small buttons use
   --tt-radius-md, default buttons --tt-radius-lg, input-group buttons a
   pill) instead of a hardcoded group radius. */

/* ─── Horizontal ────────────────────────────────────────── */
.tiptap-button-group-horizontal {
  /* [data-slot] children followed by another: remove right radius */
  & > [data-slot]:has(~ [data-slot]) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  /* non-first [data-slot] children: remove left radius + left border */
  & > [data-slot] ~ [data-slot] {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left-width: 0;
  }
}

/* ─── Vertical ──────────────────────────────────────────── */
.tiptap-button-group-vertical {
  flex-direction: column;

  /* [data-slot] children followed by another: remove bottom radius */
  & > [data-slot]:has(~ [data-slot]) {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  /* non-first [data-slot] children: remove top radius + top border */
  & > [data-slot] ~ [data-slot] {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top-width: 0;
  }
}

/* ─── Separator ──────────────────────────────────────────── */
.tiptap-button-group-separator {
  position: relative;
  align-self: stretch;
}

.tiptap-button-group-separator[data-orientation="horizontal"] {
  margin-left: 1px;
  margin-right: 1px;
}

.tiptap-button-group-separator[data-orientation="horizontal"] {
  width: auto;
}

.tiptap-button-group-separator[data-orientation="vertical"] {
  margin-top: 1px;
  margin-bottom: 1px;
}

.tiptap-button-group-separator[data-orientation="vertical"] {
  height: auto;
}
