:where(h1, h2, h3, h4, [data-slot="card-title"]) {
  letter-spacing: -0.025em;
}

:where(.ui-button[data-size="default"]) {
  padding-inline: 0.75rem;
}

:where(.ui-button[data-size="lg"]) {
  padding-inline: 1rem;
}

:where(.ui-button:is([data-variant="default"], [data-variant="destructive"])) {
  box-shadow: var(--raised-highlight), var(--ui-shadow-xs);
}

:where(.ui-button[data-variant="outline"]) {
  border-color: var(--input);
}

:where(.ui-button:not([data-variant="ghost"], [data-variant="link"])):active {
  box-shadow: none;
}

:where(.ui-button):focus-visible {
  box-shadow: var(--ui-focus-ring);
}

:where(.ui-button[data-variant="destructive"]):focus-visible {
  box-shadow: var(--ui-invalid-ring);
}

:where([data-slot="card"]) {
  border-radius: calc(var(--radius) + 6px);
}

:where([data-slot="badge"]) {
  border-radius: calc(var(--radius) / 2);
  padding-inline: 0.375rem;
}

:where([data-slot="table"]) {
  --table-inset: 1rem;
}

:where([data-slot="table"] th) {
  height: 2.5rem;
  color: var(--muted-foreground);
  font-weight: 500;
}

:where([data-slot="table"] td) {
  padding-block: 0.75rem;
}

:where([data-slot="table"] :is(th, td):first-child) {
  padding-inline-start: var(--table-inset);
}

:where([data-slot="table"] :is(th, td):last-child) {
  padding-inline-end: var(--table-inset);
}

:where([data-slot="table"] tbody tr:last-child) {
  border-bottom: 0;
}

@media (hover: hover) and (pointer: fine) {
  :where([data-slot="table"] tbody tr:not([aria-selected="true"], [data-state="selected"])):hover {
    background: var(--row-hover);
  }
}

:where([data-slot="table-container"]) {
  border: 1px solid var(--border);
  border-radius: var(--ui-radius-xl);
  background: var(--card);
  box-shadow: var(--ui-shadow-xs);
  overflow: hidden;
}

:where([data-slot="data-table"] [data-slot="table-scroll"]) {
  border: 0;
  border-radius: 0;
}

:where([data-slot="card"]) {
  --card-inset: 1.5rem;
}

:where([data-slot="card"][data-size="sm"]) {
  --card-inset: 1rem;
}

:where([data-slot="card-content"] [data-slot="table-container"]) {
  width: calc(100% + 2 * var(--card-inset));
  margin-inline: calc(-1 * var(--card-inset));
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

:where([data-slot="card-content"] [data-slot="table-container"]) [data-slot="table"] {
  --table-inset: var(--card-inset);
}

:where([data-slot="card-content"] [data-slot="table-container"]:not(:first-child)) {
  border-top: 1px solid var(--border);
}

[data-slot="card-content"] :where([data-slot="data-table"]) {
  gap: 0;
}

:where([data-slot="card"]:has([data-slot="table-container"]):not(:has(> [data-slot="card-footer"]))) {
  overflow: hidden;
  padding-bottom: 0;
}

:where([data-slot="card"]:not(:has(> [data-slot="card-header"])):has([data-slot="table-container"])) {
  padding-top: 0;
}

:where([data-slot="card-content"] [data-slot="data-table-pages"]) {
  margin-inline: calc(-1 * var(--card-inset));
  padding: 0.75rem var(--card-inset);
  border-top: 1px solid var(--border);
}

/* Form controls: white, a clear border, the brand's ring when focused and a red one when wrong. Roomier where a
   form is the whole page (the setup flow and signing in). */

@media (hover: hover) and (pointer: fine) {
  :where(.ui-input, [data-slot="select-trigger"], .ui-textarea):not(
    :focus-visible,
    [aria-invalid="true"],
    [data-invalid],
    :disabled
  ):hover {
    border-color: color-mix(in oklab, var(--foreground) 24%, transparent);
  }
}

:where(.ui-input, [data-slot="select-trigger"], .ui-textarea):is([aria-invalid="true"], [data-invalid]) {
  background: color-mix(in oklab, var(--destructive) 3%, var(--background));
}

:where(.ui-button[data-variant="default"]) {
  background-image: linear-gradient(
    to bottom,
    color-mix(in oklab, var(--primary) 86%, var(--primary-foreground)),
    var(--primary)
  );
}

:where(.ui-button[data-variant="secondary"]) {
  box-shadow: var(--ui-shadow-xs);
}

:where(.ui-button[data-variant="destructive"]) {
  border-color: color-mix(in oklab, var(--destructive) 45%, transparent);
  background: color-mix(in oklab, var(--destructive) 7%, var(--background));
  color: var(--destructive);
  box-shadow: none;
}

@media (hover: hover) and (pointer: fine) {
  .ui-button[data-variant="default"]:hover {
    background-image: linear-gradient(
      to bottom,
      color-mix(in oklab, var(--primary) 78%, var(--primary-foreground)),
      color-mix(in oklab, var(--primary) 92%, var(--primary-foreground))
    );
  }

  .ui-button[data-variant="destructive"]:hover {
    background: color-mix(in oklab, var(--destructive) 13%, var(--background));
  }
}

:where(.flow, .auth) {
  --ui-h: 2.75rem;
  --ui-h-sm: 2.25rem;
}

:where(.flow, .auth) :is(.ui-input, [data-slot="select-trigger"], .ui-textarea) {
  padding-inline: 0.875rem;
  font-size: 0.9375rem;
}

:where(.flow, .auth) .ui-button:not([data-size="sm"], [data-variant="link"]) {
  font-size: 0.9375rem;
}

:where(.flow, .auth) [data-slot="field-label"] {
  font-size: 0.875rem;
}

:where(.flow, .auth)
  [data-slot="field"]
  :is([data-slot="select-trigger"], [data-slot="combobox"], [data-slot="combobox-trigger"][data-picker]) {
  width: 100%;
}

:where(.flow, .auth) [data-slot="field"] ui-combobox-trigger {
  display: block;
}
