[data-fui-comp="ui-button"], .ui-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  /* Token-scaled touch target: --spacing-touch-target defaults to
     44px (WCAG 2.5.5 floor). Apps that want a larger tap zone for
     accessibility-mode skins can bump it via theme.Layout.
     TouchTarget without forking the component. */
  min-height: var(--spacing-touch-target);
  padding: 10px var(--spacing-lg);
  border: 1px solid transparent;
  border-radius: var(--radii-md);
  font: inherit;
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  /* flex: 0 0 auto sizes the button to its unwrapped label (max-content), so
     wrapping action rows move whole controls to the next line first. The
     clamp below is container-driven, not viewport-driven: only a label wider
     than its own container (a sidebar rail, a card cell — at any viewport)
     wraps inside the bounded button. break-word, NOT anywhere: break-word
     adds emergency break points at render time without entering min-content
     sizing, so table/grid layout (a DataTable actions column under column
     pressure) keeps the intact label as the button's minimum and overflows
     horizontally instead of letter-stacking it. */
  max-inline-size: 100%;
  overflow-wrap: break-word;
  cursor: pointer;
  background: var(--color-primary);
  color: var(--color-primary-fg);
  text-decoration: none;
  transition: filter 150ms ease, opacity 150ms ease;
}
[data-fui-comp="ui-button"]:hover, .ui-button:hover { filter: brightness(0.95); }
/* Layered focus ring: inner halo in the surface color creates a
   visible gap between the button and the outer primary ring, so
   keyboard focus stays visible regardless of the button's own
   background color. */
[data-fui-comp="ui-button"]:focus-visible, .ui-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-primary);
}
[data-fui-comp="ui-button"]:disabled, .ui-button:disabled,
[data-fui-comp="ui-button"][aria-disabled="true"], .ui-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.6;
  filter: none;
}

/* Variants — Primary is the default style above. */
.ui-button--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.ui-button--secondary:hover { filter: none; background: var(--color-surface-soft); }
/* secondary's bg IS --color-surface, so the layered-shadow inner halo
   would be invisible. Use a plain outline with offset instead — it
   contrasts against any page background. */
.ui-button--secondary:focus-visible {
  box-shadow: none;
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

.ui-button--danger {
  /* Theme status token with a red-700 literal fallback: the default
     --color-danger IS #B91C1C (7.07:1 vs white), so axe's
     color-contrast scanner resolves the same unambiguous pair
     whether or not the theme :root block is present. Themes that
     override --color-danger own keeping ≥4.5:1 against
     --color-primary-fg. */
  background: var(--color-danger, #B91C1C);
  color: var(--color-primary-fg, #FFFFFF);
}
.ui-button--danger:focus-visible {
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-danger);
}

.ui-button--ghost {
  background: transparent;
  color: var(--color-text);
  border-color: transparent;
}
.ui-button--ghost:hover { filter: none; background: var(--color-surface-soft); }
/* ghost sits on --color-background; a halo of --color-surface collapses
   to near-invisible. Plain outline + offset is reliable on any bg. */
.ui-button--ghost:focus-visible {
  box-shadow: none;
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Size modifiers — the default Button size already meets WCAG 2.5.5
   touch-target via min-height. --small explicitly opts out for compact
   row-action contexts (table rows, dense toolbars) where the parent
   row already provides the 44px tap area. --large bumps padding +
   font-size for hero CTAs. */
.ui-button--small {
  min-height: auto;
  padding: var(--spacing-sm, 4px) var(--spacing-md, 8px);
  font-size: var(--text-xs, 0.75rem);
}
.ui-button--large {
  padding: 14px var(--spacing-xl, 24px);
  /* --text-lg, NOT --text-base: :root always emits --text-base (1rem),
     so reading it here would collapse --large into the default size. */
  font-size: var(--text-lg, 1.125rem);
}
