.floating-field,
.auth-code-group {
  --control-main: 40px;
}

.floating-field {
  --floating-field-inset: 12px;
  --floating-field-backdrop: var(--canvas);
  --floating-field-fill: var(--surface);
  --floating-field-focus: var(--primary);
  position: relative;
  min-width: 0;
}

:is(.auth-card, .password-reset-card) .floating-field {
  --floating-field-inset: 13px;
  --floating-field-backdrop: var(--surface);
}

.floating-field:has(> [data-slot="password-input"]) {
  --floating-field-inset: 16px;
  --floating-field-fill: var(--rare-input-surface);
}

.form-field > .floating-field,
.form-field > .auth-code-group {
  margin-block-start: 14px;
}

@media (min-width: 701px) {
  .profile-edit-field:has(> .floating-field) > :is(.floating-field, .field-error, .field-hint) {
    grid-column: 2;
  }
}

.auth-code-group > .floating-field {
  flex: 1 1 0;
}

.ai-provider-page .floating-field.ai-input-wrap {
  --control-regular: var(--control-main);
  --floating-field-fill: var(--soft);
}

.floating-field > .floating-field-label {
  position: absolute;
  z-index: 1;
  inset-block-start: calc(var(--control-main) / 2);
  inset-inline-start: calc(var(--floating-field-inset) - 4px);
  max-inline-size: calc(100% - var(--floating-field-inset) - 4px);
  margin: 0;
  padding-inline: 4px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateY(-50%);
  transform-origin: left center;
  transition: transform 160ms ease, color 160ms ease;
  cursor: text;
}

:is(.auth-card, .password-reset-card, .security-form, .profile-edit-field, .developer-work-field, .admin-workspace) .floating-field > .floating-field-label {
  font-size: 14px;
}

.floating-field.input-count-field > .floating-field-label {
  max-inline-size: calc(100% - var(--floating-field-inset) - 60px + 4px);
}

.floating-field-label > .profile-field-optional {
  margin-inline-start: .5em;
}

.floating-field:has(input:is(:focus, :autofill, :not(:placeholder-shown))) > .floating-field-label {
  background: linear-gradient(
    to bottom,
    var(--floating-field-backdrop) 50%,
    var(--floating-field-fill) 50%
  );
  transform: translateY(calc(-50% - var(--control-main) / 2)) scale(.8);
}

.floating-field > input.form-input:not(:focus)::placeholder {
  opacity: 0;
}

.floating-field:has(input[aria-invalid="true"]) {
  --floating-field-focus: var(--error);
}

.floating-field:has(input:is(:focus, [aria-invalid="true"])) > .floating-field-label {
  color: var(--floating-field-focus);
}

.floating-field > input.form-input:focus,
.owner-console .ai-provider-page .floating-field > .ai-input:focus,
.floating-field [data-slot="password-input-field"]:has(input:focus) {
  border-color: var(--floating-field-focus);
  outline: none;
}

@media (forced-colors: active) {
  .floating-field:has(input:is(:focus, :autofill, :not(:placeholder-shown))) > .floating-field-label {
    background: Canvas;
  }

  .floating-field,
  .floating-field:has(input[aria-invalid="true"]) {
    --floating-field-focus: Highlight;
  }
}

@media (prefers-reduced-motion: reduce) {
  .floating-field > .floating-field-label {
    transition: none;
  }
}
