.tbg-group {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--tbg-option-count, 1), minmax(0, 1fr));
  align-items: stretch;
  gap: 0;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--background);
  overflow: hidden;
  isolation: isolate;
}

.tbg-indicator {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px) / var(--tbg-option-count, 1));
  border-radius: 999px;
  background: var(--primary);
  transform: translateX(calc(var(--tbg-active-index, 0) * 100%));
  transition: transform 0.22s ease, opacity 0.2s ease;
  opacity: 0;
  z-index: 0;
}

.tbg-group.has-active .tbg-indicator {
  opacity: 1;
}

.tbg-button {
  position: relative;
  z-index: 1;
  margin: 0;
  width: 100%;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
  white-space: nowrap;
}

.tbg-button.tbg-size-default {
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.tbg-button.tbg-size-xs {
  padding: 0.35rem 0.5rem;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.tbg-button.tbg-size-xxs {
  padding: 0.25rem 0.38rem;
  font-size: 0.68rem;
  font-weight: var(--font-weight-semibold);
}

.tbg-button.is-active {
  color: var(--color-text-inverse);
  background: transparent;
}

.tbg-button.is-inactive:hover:not(:disabled) {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .tbg-button.is-inactive:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.tbg-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.tbg-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
