/* Unified Form UX 2026: 56px controls, 24px radius, persistent floating labels. */
:root {
  --ux-form-radius: 24px;
  --ux-form-height: 56px;
  --ux-form-motion: 180ms cubic-bezier(.2,.8,.2,1);
  --ux-form-caption: var(--muted-foreground, var(--muted, #8a8275));
  --ux-form-focus: var(--ring, var(--accent, #9b7e5c));
}

body :is(
  input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"],
    [type="range"], [type="button"], [type="submit"], [type="reset"], [type="color"]),
  select,
  textarea
) {
  min-height: var(--ux-form-height);
  border-radius: var(--ux-form-radius);
  font-size: 16px;
  transition: border-color var(--ux-form-motion),
    box-shadow var(--ux-form-motion), background-color var(--ux-form-motion);
}

body label.ux-floating-nested {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 0 !important;
  min-width: 0;
}

body label.ux-floating-nested::before {
  /* The native label supplies the accessible name. */
  content: attr(data-ux-caption) / "";
  position: absolute;
  top: 28px;
  left: 16px;
  z-index: 2;
  max-width: calc(100% - 32px);
  color: var(--ux-form-caption);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  transform: translateY(-50%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: top var(--ux-form-motion), font-size var(--ux-form-motion),
    color var(--ux-form-motion), transform var(--ux-form-motion);
}

body .ux-floating-parent {
  position: relative;
  min-width: 0;
}

body .ux-floating-parent > label.ux-floating-label {
  position: absolute;
  top: 28px;
  left: 16px;
  z-index: 2;
  width: auto;
  max-width: calc(100% - 32px);
  margin: 0;
  color: var(--ux-form-caption);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  transform: translateY(-50%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: top var(--ux-form-motion), font-size var(--ux-form-motion),
    color var(--ux-form-motion), transform var(--ux-form-motion);
}

body :is(.ux-floating-nested, .ux-floating-parent) .ux-field-control {
  width: 100%;
  min-height: var(--ux-form-height);
  border-radius: var(--ux-form-radius);
  padding: 22px 16px 8px;
  font-size: 16px;
  line-height: 1.4;
}

body :is(.ux-floating-nested, .ux-floating-parent) textarea.ux-field-control {
  padding-top: 26px;
  padding-bottom: 12px;
}

body :is(.ux-floating-nested, .ux-floating-parent) .ux-field-control::placeholder {
  color: transparent;
  opacity: 0;
}

body :is(.ux-floating-nested, .ux-floating-parent):focus-within
  .ux-field-control::placeholder {
  color: var(--ux-form-caption);
  opacity: 1;
}

body label.ux-floating-nested:is(:focus-within, [data-ux-filled="true"])::before,
body .ux-floating-parent:is(:focus-within, [data-ux-filled="true"])
  > label.ux-floating-label {
  top: 11px;
  color: var(--ux-form-focus);
  font-size: 11px;
  font-weight: 600;
  transform: translateY(-10%);
}

body :is(.ux-floating-nested, .ux-floating-parent)
  .ux-field-control:focus-visible {
  border-color: var(--ux-form-focus);
  outline: 2px solid var(--ux-form-focus);
  outline-offset: 2px;
}

body label.ux-floating-nested > :is(small, .hint) {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.5;
}

body :is(.form, .form-grid) label:has(> input[type="checkbox"]),
body :is(.form, .form-grid) label:has(> input[type="radio"]),
body label.checkbox-label,
body label.checkbox-line {
  min-height: 56px;
}

@media (prefers-reduced-motion: reduce) {
  body :is(.ux-floating-nested, .ux-floating-parent, .ux-field-control),
  body label.ux-floating-nested::before,
  body .ux-floating-parent > label.ux-floating-label {
    transition: none !important;
  }
}


@media (max-width: 600px) {
  body [role="dialog"] .form-grid:has(> .ux-floating-nested),
  body dialog .form-grid:has(> .ux-floating-nested) {
    grid-template-columns: minmax(0, 1fr);
  }

  body :is(dialog, [role="dialog"]) .form-grid > .span-two {
    grid-column: 1 / -1;
  }
}
